diff options
author | Vilém Duha <vilda.novak@gmail.com> | 2020-12-22 18:29:18 +0300 |
---|---|---|
committer | Vilém Duha <vilda.novak@gmail.com> | 2020-12-22 18:29:18 +0300 |
commit | 48a792c58c16d0e846fd015f3ea5fdf491647a7a (patch) | |
tree | 2fc4b44004d823926b063cd06ff539964f2287fc | |
parent | 10ae0f7a5a84b0d9ac8ccbb4abe97e42ab6ca9d1 (diff) |
BlenderKit: improve category upload drawing.
Now this works automatically from the categories as specified on the server
-rw-r--r-- | blenderkit/__init__.py | 7 | ||||
-rw-r--r-- | blenderkit/categories.py | 11 | ||||
-rw-r--r-- | blenderkit/ui_panels.py | 6 |
3 files changed, 16 insertions, 8 deletions
diff --git a/blenderkit/__init__.py b/blenderkit/__init__.py index d69f3e0d..ceca7207 100644 --- a/blenderkit/__init__.py +++ b/blenderkit/__init__.py @@ -682,9 +682,14 @@ class BlenderKitCommonUploadProps(object): ) subcategory: EnumProperty( name="Subcategory", - description="main category to put into", + description="Subcategory to put into", items=categories.get_subcategory_enums ) + subcategory1: EnumProperty( + name="Subcategory lvl2", + description="Subcategory to put into", + items=categories.get_subcategory1_enums + ) class BlenderKitRatingProps(PropertyGroup): diff --git a/blenderkit/categories.py b/blenderkit/categories.py index 43d6f2ba..abdfbe48 100644 --- a/blenderkit/categories.py +++ b/blenderkit/categories.py @@ -112,8 +112,6 @@ def get_upload_asset_type(self): return asset_type - - def get_category_enums(self, context): wm = bpy.context.window_manager props = bpy.context.scene.blenderkitUI @@ -123,6 +121,8 @@ def get_category_enums(self, context): items = [] for c in asset_categories['children']: items.append((c['slug'], c['name'], c['description'])) + if len(items) == 0: + items.append(('NONE', '', 'no categories on this level defined')) return items def get_subcategory_enums(self, context): @@ -134,7 +134,9 @@ def get_subcategory_enums(self, context): asset_categories = get_category(wm['bkit_categories'], cat_path=(asset_type, self.category,)) for c in asset_categories['children']: items.append((c['slug'], c['name'], c['description'])) - + if len(items) == 0: + items.append(('NONE', '', 'no categories on this level defined')) + # print('subcategory', items) return items def get_subcategory1_enums(self, context): @@ -146,7 +148,8 @@ def get_subcategory1_enums(self, context): asset_categories = get_category(wm['bkit_categories'], cat_path=(asset_type, self.category, self.subcategory, )) for c in asset_categories['children']: items.append((c['slug'], c['name'], c['description'])) - + if len(items) == 0: + items.append(('NONE', '', 'no categories on this level defined')) return items def copy_categories(): diff --git a/blenderkit/ui_panels.py b/blenderkit/ui_panels.py index 9d5777a1..c4ed5e40 100644 --- a/blenderkit/ui_panels.py +++ b/blenderkit/ui_panels.py @@ -110,7 +110,6 @@ def draw_upload_common(layout, props, asset_type, context): if props.upload_state != '': utils.label_multiline(layout, text=props.upload_state, width=context.region.width) if props.uploading: - print(bpy.context.scene.name) op = layout.operator('object.kill_bg_process', text="", icon='CANCEL') op.process_source = asset_type op.process_type = 'UPLOAD' @@ -142,10 +141,11 @@ def draw_upload_common(layout, props, asset_type, context): # row = layout.row() # row.enabled = False # row.prop(props, 'id', icon='FILE_TICK') - layout.prop(props, 'category') - if asset_type == 'MODEL' and props.subcategory != '': # by now block this for other asset types. + if props.category != 'NONE' and props.subcategory != 'NONE': layout.prop(props, 'subcategory') + if props.subcategory != 'NONE' and props.subcategory1 != 'NONE': + layout.prop(props, 'subcategory1') layout.prop(props, 'is_private', expand=True) if props.is_private == 'PUBLIC': |