diff options
author | Vilem Duha <vilem.duha@gmail.com> | 2021-07-01 13:09:55 +0300 |
---|---|---|
committer | Jeroen Bakker <jeroen@blender.org> | 2021-07-26 09:08:10 +0300 |
commit | 526557bba142a359b9aad773cecf5d702577eb2e (patch) | |
tree | ce7a6db6561821e0dd834ec1fa5d1dc613f9c179 /blenderkit/ui_panels.py | |
parent | 0d880d1273a3640a089b5fa6c75d4cc67efb4c62 (diff) |
BlenderKit: many post-release fixes
Fix for rerequests recursion crash
rename timers
fix manual link
attemt to fix mysterious crashes on some machines by limiting some calls to assetbar operator, and not copying image into it's preview so often
fix search when & was present
add a popup when appending a scene
improve starup dialog with an image
Diffstat (limited to 'blenderkit/ui_panels.py')
-rw-r--r-- | blenderkit/ui_panels.py | 68 |
1 files changed, 53 insertions, 15 deletions
diff --git a/blenderkit/ui_panels.py b/blenderkit/ui_panels.py index 3c5f4dcf..fe91658c 100644 --- a/blenderkit/ui_panels.py +++ b/blenderkit/ui_panels.py @@ -36,6 +36,7 @@ from bpy.props import ( import bpy import os +import random import logging bk_logger = logging.getLogger('blenderkit') @@ -887,6 +888,15 @@ class VIEW3D_PT_blenderkit_categories(Panel): def draw(self, context): draw_panel_categories(self, context) +def draw_scene_import_settings(self, context): + s = context.scene + props = s.blenderkit_scene + layout = self.layout + layout.prop(props, 'switch_after_append') + # layout.label(text='Import method:') + row = layout.row() + row.prop(props, 'append_link', expand=True, icon_only=False) + class VIEW3D_PT_blenderkit_import_settings(Panel): bl_category = "BlenderKit" @@ -931,11 +941,8 @@ class VIEW3D_PT_blenderkit_import_settings(Panel): row.prop(props, 'append_method', expand=True, icon_only=False) if ui_props.asset_type == 'SCENE': - props = s.blenderkit_scene - layout.prop(props, 'switch_after_append') - layout.label(text='Import method:') - row = layout.row() - row.prop(props, 'append_link', expand=True, icon_only=False) + draw_scene_import_settings(self,context) + if ui_props.asset_type == 'HDR': props = s.blenderkit_HDR @@ -1113,13 +1120,19 @@ class BlenderKitWelcomeOperator(bpy.types.Operator): if self.step == 0: user_preferences = bpy.context.preferences.addons['blenderkit'].preferences - message = "BlenderKit connects from Blender to an online, " \ - "community built shared library of models, " \ - "materials, and brushes. " \ - "Use addon preferences to set up where files will be saved in the Global directory setting." + # message = "BlenderKit connects from Blender to an online, " \ + # "community built shared library of models, " \ + # "materials, and brushes. " \ + # "Use addon preferences to set up where files will be saved in the Global directory setting." + # + # utils.label_multiline(layout, text=message, width=300) + + layout.template_icon(icon_value=self.img.preview.icon_id, scale=18) + + # utils.label_multiline(layout, text="\n Let's start by searching for some cool materials?", width=300) + op = layout.operator("wm.url_open", text='Watch Video Tutorial', icon='QUESTION') + op.url = paths.BLENDERKIT_MANUAL - utils.label_multiline(layout, text=message, width=300) - utils.label_multiline(layout, text="\n Let's start by searching for some cool materials?", width=300) else: message = "Operator Tutorial called with invalid step" @@ -1131,14 +1144,36 @@ class BlenderKitWelcomeOperator(bpy.types.Operator): # bpy.context.window_manager.windows[0].screen.areas[5].spaces[0].show_region_ui = False print('running search no') ui_props = bpy.context.scene.blenderkitUI - ui_props.asset_type = 'MATERIAL' - bpy.context.scene.blenderkit_mat.search_keywords = 'ice' + random_searches = [ + ('MATERIAL','ice'), + ('MODEL','car'), + ('MODEL','vase'), + ('MODEL','grass'), + ('MODEL','plant'), + ('MODEL','man'), + ('MATERIAL','metal'), + ('MATERIAL','wood'), + ('MATERIAL','floor'), + ('MATERIAL','bricks'), + ] + random_search = random.choice(random_searches) + ui_props.asset_type = random_search[0] + + bpy.context.scene.blenderkit_mat.search_keywords = ''#random_search[1] + bpy.context.scene.blenderkit_mat.search_keywords = '+is_free:true+score_gte:1000+order:-created'#random_search[1] # search.search() return {'FINISHED'} def invoke(self, context, event): wm = bpy.context.window_manager - return wm.invoke_props_dialog(self) + img = utils.get_thumbnail('intro.jpg') + utils.img_to_preview(img, copy_original = True) + self.img = img + w, a, r = utils.get_largest_area(area_type='VIEW_3D') + if a is not None: + a.spaces.active.show_region_ui = True + + return wm.invoke_props_dialog(self, width = 500) def draw_asset_context_menu(layout, context, asset_data, from_panel=False): @@ -1779,8 +1814,9 @@ class AssetPopupCard(bpy.types.Operator, ratings_utils.RatingsProperties): # top draggabe bar with name of the asset top_row = layout.row() top_drag_bar = top_row.box() + bcats = bpy.context.window_manager['bkit_categories'] - cat_path = categories.get_category_path(bpy.context.window_manager['bkit_categories'], + cat_path = categories.get_category_path(bcats, self.asset_data['category'])[1:] for i,c in enumerate(cat_path): cat_path[i] = c.capitalize() @@ -1821,6 +1857,8 @@ class AssetPopupCard(bpy.types.Operator, ratings_utils.RatingsProperties): sr = bpy.context.window_manager['search results'] asset_data = sr[ui_props.active_index] self.img = ui.get_large_thumbnail_image(asset_data) + utils.img_to_preview(self.img, copy_original = True) + self.asset_type = asset_data['assetType'] self.asset_id = asset_data['id'] # self.tex = utils.get_hidden_texture(self.img) |