-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathget_meshes_from_storage.py
107 lines (88 loc) · 3.8 KB
/
get_meshes_from_storage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# Nikita Akimov
#
# GitHub
# https://github.com/Korchy/BIS
from bpy.types import Operator, PropertyGroup, WindowManager
from bpy.utils import register_class, unregister_class
from bpy.props import StringProperty, BoolProperty, EnumProperty, IntProperty, PointerProperty
from .mesh_manager import MeshManager
from .bis_items import BISItems
class BISGetMeshesInfoFromStorage(Operator):
bl_idname = 'bis.get_meshes_info_from_storage'
bl_label = 'BIS: get items'
bl_description = 'Search meshes in BIS'
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
MeshManager.items_from_bis(
context,
search_filter=context.window_manager.bis_get_meshes_info_from_storage_vars.search_filter,
page=0,
update_preview=context.window_manager.bis_get_meshes_info_from_storage_vars.update_previews
)
return {'FINISHED'}
class BISGetMeshesInfoFromStoragePrevPage(Operator):
bl_idname = 'bis.get_meshes_info_from_storage_prev_page'
bl_label = 'BIS: get items (prev page)'
bl_description = 'Get prev page'
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
MeshManager.items_from_bis(
context,
search_filter=context.window_manager.bis_get_meshes_info_from_storage_vars.search_filter,
page=context.window_manager.bis_get_meshes_info_from_storage_vars.current_page - 1,
update_preview=context.window_manager.bis_get_meshes_info_from_storage_vars.update_previews
)
return {'FINISHED'}
@classmethod
def poll(cls, context):
return context.window_manager.bis_get_meshes_info_from_storage_vars.current_page > 0
class BISGetMeshesInfoFromStorageNextPage(Operator):
bl_idname = 'bis.get_meshes_info_from_storage_next_page'
bl_label = 'BIS: get items (next page)'
bl_description = 'Get next page'
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
MeshManager.items_from_bis(
context,
search_filter=context.window_manager.bis_get_meshes_info_from_storage_vars.search_filter,
page=context.window_manager.bis_get_meshes_info_from_storage_vars.current_page + 1,
update_preview=context.window_manager.bis_get_meshes_info_from_storage_vars.update_previews
)
return {'FINISHED'}
@classmethod
def poll(cls, context):
return context.window_manager.bis_get_meshes_info_from_storage_vars.current_page_status not in ('', 'EOF')
class BISGetMeshesInfoFromStorageVars(PropertyGroup):
search_filter: StringProperty(
name='Search',
description='Filter to search',
default=''
)
update_previews: BoolProperty(
name='Update Previews',
description='Update previews from server',
default=False
)
items: EnumProperty(
items=lambda self, context: BISItems.get_previews(MeshManager.storage_type(context)),
update=lambda self, context: BISItems.on_preview_select(self, MeshManager.storage_type(context))
)
current_page: IntProperty(
default=0
)
current_page_status: StringProperty(
default=''
)
def register():
register_class(BISGetMeshesInfoFromStorageVars)
WindowManager.bis_get_meshes_info_from_storage_vars = PointerProperty(type=BISGetMeshesInfoFromStorageVars)
register_class(BISGetMeshesInfoFromStorage)
register_class(BISGetMeshesInfoFromStoragePrevPage)
register_class(BISGetMeshesInfoFromStorageNextPage)
def unregister():
unregister_class(BISGetMeshesInfoFromStorageNextPage)
unregister_class(BISGetMeshesInfoFromStoragePrevPage)
unregister_class(BISGetMeshesInfoFromStorage)
del WindowManager.bis_get_meshes_info_from_storage_vars
unregister_class(BISGetMeshesInfoFromStorageVars)