From 5aa666ef00a61836aa78a7e1776a3b701ad3c0be Mon Sep 17 00:00:00 2001 From: "kaosat.dev" Date: Fri, 19 Jul 2024 14:13:48 +0200 Subject: [PATCH] feat(Blenvy:Blender): settings/configuration is now also tabbed for less scrolling & confusion --- tools/blenvy/__init__.py | 3 +- tools/blenvy/core/blenvy_manager.py | 11 ++ tools/blenvy/core/operators.py | 29 ++++- tools/blenvy/core/ui/ui.py | 186 +++++++++++++++------------- 4 files changed, 139 insertions(+), 90 deletions(-) diff --git a/tools/blenvy/__init__.py b/tools/blenvy/__init__.py index d875fdf..5fc93d9 100644 --- a/tools/blenvy/__init__.py +++ b/tools/blenvy/__init__.py @@ -49,7 +49,7 @@ from .blueprints.operators import BLENVY_OT_blueprint_select # blenvy core from .core.blenvy_manager import BlenvyManager -from .core.operators import BLENVY_OT_tooling_switch +from .core.operators import BLENVY_OT_configuration_switch, BLENVY_OT_tooling_switch from .core.ui.ui import (BLENVY_PT_SidePanel) from .core.ui.scenes_list import BLENVY_OT_scenes_list_actions from .assets.assets_folder_browser import BLENVY_OT_assets_paths_browse @@ -110,6 +110,7 @@ classes = [ # blenvy BlenvyManager, BLENVY_OT_tooling_switch, + BLENVY_OT_configuration_switch, Asset, AssetsRegistry, diff --git a/tools/blenvy/core/blenvy_manager.py b/tools/blenvy/core/blenvy_manager.py index d6135a0..dbdea8c 100644 --- a/tools/blenvy/core/blenvy_manager.py +++ b/tools/blenvy/core/blenvy_manager.py @@ -53,6 +53,17 @@ class BlenvyManager(PropertyGroup): default="SETTINGS", update=save_settings ) # type: ignore + + config_mode: EnumProperty( + items=( + ('COMMON', "Common", "Switch to common configuration"), + ('COMPONENTS', "Components", "Switch to components configuration"), + ('EXPORT', "Export", "Switch to export configuration"), + ), + default="COMMON", + update=save_settings + ) # type: ignore + project_root_path: StringProperty( name = "Project Root Path", diff --git a/tools/blenvy/core/operators.py b/tools/blenvy/core/operators.py index 852aac7..ad545b8 100644 --- a/tools/blenvy/core/operators.py +++ b/tools/blenvy/core/operators.py @@ -1,11 +1,8 @@ from bpy_types import (Operator) from bpy.props import (EnumProperty) - - - class BLENVY_OT_tooling_switch(Operator): - """Switch bevy tooling""" + """Switch blenvy tooling""" bl_idname = "bevy.tooling_switch" bl_label = "Switch bevy tooling" #bl_options = {} @@ -28,4 +25,28 @@ class BLENVY_OT_tooling_switch(Operator): def execute(self, context): context.window_manager.blenvy.mode = self.tool return {'FINISHED'} + + + +class BLENVY_OT_configuration_switch(Operator): + """Switch tooling configuration""" + bl_idname = "bevy.config_switch" + bl_label = "Switch blenvy configuration" + #bl_options = {} + + tool: EnumProperty( + items=( + ('COMMON', "Common", "Switch to common configuration"), + ('COMPONENTS', "Components", "Switch to components configuration"), + ('EXPORT', "Export", "Switch to export configuration"), + ) + ) # type: ignore + + @classmethod + def description(cls, context, properties): + return properties.tool + + def execute(self, context): + context.window_manager.blenvy.config_mode = self.tool + return {'FINISHED'} \ No newline at end of file diff --git a/tools/blenvy/core/ui/ui.py b/tools/blenvy/core/ui/ui.py index 9edc07f..624f6fa 100644 --- a/tools/blenvy/core/ui/ui.py +++ b/tools/blenvy/core/ui/ui.py @@ -72,95 +72,111 @@ class BLENVY_PT_SidePanel(bpy.types.Panel): tool_switch_components = target.operator(operator="bevy.tooling_switch", text="", icon="TOOL_SETTINGS") tool_switch_components.tool = "TOOLS" - # Debug stuff - """layout.label(text="Active Blueprint: "+ active_collection.name.upper()) - layout.label(text="World scene active: "+ str(world_scene_active)) - layout.label(text="Library scene active: "+ str(library_scene_active)) - layout.label(text=blenvy.mode)""" - if blenvy.mode == "SETTINGS": - header, panel = layout.panel("common", default_closed=False) - header.label(text="Common") - if panel: - row = panel.row() - draw_folder_browser(layout=row, label="Root Folder", prop_origin=blenvy, target_property="project_root_path") - row = panel.row() - draw_folder_browser(layout=row, label="Assets Folder", prop_origin=blenvy, target_property="assets_path") - row = panel.row() - draw_folder_browser(layout=row, label="Blueprints Folder", prop_origin=blenvy, target_property="blueprints_path") - row = panel.row() - draw_folder_browser(layout=row, label="Levels Folder", prop_origin=blenvy, target_property="levels_path") - row = panel.row() - draw_folder_browser(layout=row, label="Materials Folder", prop_origin=blenvy, target_property="materials_path") + config_mode = blenvy.config_mode + row = layout.row() + config_target = row.box() if config_mode == 'COMMON' else row + config_switch = config_target.operator(operator="bevy.config_switch", text="", icon="OPTIONS") + config_switch.tool = "COMMON" - panel.separator() - # scenes selection - if len(blenvy.level_scenes) == 0 and len(blenvy.library_scenes) == 0: - row = panel.row() - row.alert = True - panel.alert = True - row.label(text="NO library or level scenes specified! at least one level scene or library scene is required!") - row = panel.row() - row.label(text="Please select and add one using the UI below") + config_target = row.box() if config_mode == 'COMPONENTS' else row + config_switch = config_target.operator(operator="bevy.config_switch", text="", icon="PROPERTIES") + config_switch.tool = "COMPONENTS" - section = panel - rows = 2 - row = section.row() - col = row.column() - col.label(text="level scenes") - col = row.column() - col.prop(blenvy, "level_scene_selector", text='') - col = row.column() - add_operator = col.operator("blenvy.scenes_list_actions", icon='ADD', text="") - add_operator.action = 'ADD' - add_operator.scene_type = 'LEVEL' - col.enabled = blenvy.level_scene_selector is not None + config_target = row.box() if config_mode == 'EXPORT' else row + config_switch = config_target.operator(operator="bevy.config_switch", text="", icon="EXPORT") + config_switch.tool = "EXPORT" + + if config_mode == 'COMMON': + header, panel = layout.panel("common", default_closed=False) + header.label(text="Common") + if panel: + draw_common_settings_ui(panel, blenvy) + + if config_mode == 'COMPONENTS': + header, panel = layout.panel("components", default_closed=False) + header.label(text="Components") + if panel: + components_ui.draw_settings_ui(panel, blenvy.components) + + if config_mode == 'EXPORT': + header, panel = layout.panel("auto_export", default_closed=False) + header.label(text="Auto Export") + if panel: + auto_export_ui.draw_settings_ui(panel, blenvy.auto_export) - row = section.row() - col = row.column() - for scene in blenvy.level_scenes: - sub_row = col.box().row() - sub_row.label(text=scene.name) - remove_operator = sub_row.operator("blenvy.scenes_list_actions", icon='TRASH', text="") - remove_operator.action = 'REMOVE' - remove_operator.scene_type = 'LEVEL' - remove_operator.scene_name = scene.name - - col.separator() - - # library scenes - row = section.row() - - col = row.column() - col.label(text="library scenes") - col = row.column() - col.prop(blenvy, "library_scene_selector", text='') - col = row.column() - add_operator = col.operator("blenvy.scenes_list_actions", icon='ADD', text="") - add_operator.action = 'ADD' - add_operator.scene_type = 'LIBRARY' - col.enabled = blenvy.library_scene_selector is not None - - row = section.row() - col = row.column() - for scene in blenvy.library_scenes: - sub_row = col.box().row() - sub_row.label(text=scene.name) - remove_operator = sub_row.operator("blenvy.scenes_list_actions", icon='TRASH', text="") - remove_operator.action = 'REMOVE' - remove_operator.scene_type = 'LEVEL' - remove_operator.scene_name = scene.name - col.separator() - - header, panel = layout.panel("components", default_closed=False) - header.label(text="Components") - if panel: - components_ui.draw_settings_ui(panel, blenvy.components) - - header, panel = layout.panel("auto_export", default_closed=False) - header.label(text="Auto Export") - if panel: - auto_export_ui.draw_settings_ui(panel, blenvy.auto_export) +def draw_common_settings_ui(layout, settings): + blenvy = settings + row = layout.row() + draw_folder_browser(layout=row, label="Root Folder", prop_origin=blenvy, target_property="project_root_path") + row = layout.row() + draw_folder_browser(layout=row, label="Assets Folder", prop_origin=blenvy, target_property="assets_path") + row = layout.row() + draw_folder_browser(layout=row, label="Blueprints Folder", prop_origin=blenvy, target_property="blueprints_path") + row = layout.row() + draw_folder_browser(layout=row, label="Levels Folder", prop_origin=blenvy, target_property="levels_path") + row = layout.row() + draw_folder_browser(layout=row, label="Materials Folder", prop_origin=blenvy, target_property="materials_path") + + layout.separator() + # scenes selection + if len(blenvy.level_scenes) == 0 and len(blenvy.library_scenes) == 0: + row = layout.row() + row.alert = True + layout.alert = True + row.label(text="NO library or level scenes specified! at least one level scene or library scene is required!") + row = layout.row() + row.label(text="Please select and add one using the UI below") + + section = layout + rows = 2 + row = section.row() + col = row.column() + col.label(text="level scenes") + col = row.column() + col.prop(blenvy, "level_scene_selector", text='') + col = row.column() + add_operator = col.operator("blenvy.scenes_list_actions", icon='ADD', text="") + add_operator.action = 'ADD' + add_operator.scene_type = 'LEVEL' + col.enabled = blenvy.level_scene_selector is not None + + + row = section.row() + col = row.column() + for scene in blenvy.level_scenes: + sub_row = col.box().row() + sub_row.label(text=scene.name) + remove_operator = sub_row.operator("blenvy.scenes_list_actions", icon='TRASH', text="") + remove_operator.action = 'REMOVE' + remove_operator.scene_type = 'LEVEL' + remove_operator.scene_name = scene.name + + col.separator() + + # library scenes + row = section.row() + + col = row.column() + col.label(text="library scenes") + col = row.column() + col.prop(blenvy, "library_scene_selector", text='') + col = row.column() + add_operator = col.operator("blenvy.scenes_list_actions", icon='ADD', text="") + add_operator.action = 'ADD' + add_operator.scene_type = 'LIBRARY' + col.enabled = blenvy.library_scene_selector is not None + + row = section.row() + col = row.column() + for scene in blenvy.library_scenes: + sub_row = col.box().row() + sub_row.label(text=scene.name) + remove_operator = sub_row.operator("blenvy.scenes_list_actions", icon='TRASH', text="") + remove_operator.action = 'REMOVE' + remove_operator.scene_type = 'LEVEL' + remove_operator.scene_name = scene.name + col.separator() \ No newline at end of file