feat(Blenvy:Blender): settings/configuration is now also tabbed for less scrolling & confusion

This commit is contained in:
kaosat.dev 2024-07-19 14:13:48 +02:00
parent 4519fb94a5
commit 5aa666ef00
4 changed files with 139 additions and 90 deletions

View File

@ -49,7 +49,7 @@ from .blueprints.operators import BLENVY_OT_blueprint_select
# blenvy core # blenvy core
from .core.blenvy_manager import BlenvyManager 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.ui import (BLENVY_PT_SidePanel)
from .core.ui.scenes_list import BLENVY_OT_scenes_list_actions from .core.ui.scenes_list import BLENVY_OT_scenes_list_actions
from .assets.assets_folder_browser import BLENVY_OT_assets_paths_browse from .assets.assets_folder_browser import BLENVY_OT_assets_paths_browse
@ -110,6 +110,7 @@ classes = [
# blenvy # blenvy
BlenvyManager, BlenvyManager,
BLENVY_OT_tooling_switch, BLENVY_OT_tooling_switch,
BLENVY_OT_configuration_switch,
Asset, Asset,
AssetsRegistry, AssetsRegistry,

View File

@ -53,6 +53,17 @@ class BlenvyManager(PropertyGroup):
default="SETTINGS", default="SETTINGS",
update=save_settings update=save_settings
) # type: ignore ) # 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( project_root_path: StringProperty(
name = "Project Root Path", name = "Project Root Path",

View File

@ -1,11 +1,8 @@
from bpy_types import (Operator) from bpy_types import (Operator)
from bpy.props import (EnumProperty) from bpy.props import (EnumProperty)
class BLENVY_OT_tooling_switch(Operator): class BLENVY_OT_tooling_switch(Operator):
"""Switch bevy tooling""" """Switch blenvy tooling"""
bl_idname = "bevy.tooling_switch" bl_idname = "bevy.tooling_switch"
bl_label = "Switch bevy tooling" bl_label = "Switch bevy tooling"
#bl_options = {} #bl_options = {}
@ -28,4 +25,28 @@ class BLENVY_OT_tooling_switch(Operator):
def execute(self, context): def execute(self, context):
context.window_manager.blenvy.mode = self.tool context.window_manager.blenvy.mode = self.tool
return {'FINISHED'} 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'}

View File

@ -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 = target.operator(operator="bevy.tooling_switch", text="", icon="TOOL_SETTINGS")
tool_switch_components.tool = "TOOLS" 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": if blenvy.mode == "SETTINGS":
header, panel = layout.panel("common", default_closed=False) config_mode = blenvy.config_mode
header.label(text="Common") row = layout.row()
if panel: config_target = row.box() if config_mode == 'COMMON' else row
row = panel.row() config_switch = config_target.operator(operator="bevy.config_switch", text="", icon="OPTIONS")
draw_folder_browser(layout=row, label="Root Folder", prop_origin=blenvy, target_property="project_root_path") config_switch.tool = "COMMON"
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")
panel.separator() config_target = row.box() if config_mode == 'COMPONENTS' else row
# scenes selection config_switch = config_target.operator(operator="bevy.config_switch", text="", icon="PROPERTIES")
if len(blenvy.level_scenes) == 0 and len(blenvy.library_scenes) == 0: config_switch.tool = "COMPONENTS"
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")
section = panel config_target = row.box() if config_mode == 'EXPORT' else row
rows = 2 config_switch = config_target.operator(operator="bevy.config_switch", text="", icon="EXPORT")
row = section.row() config_switch.tool = "EXPORT"
col = row.column()
col.label(text="level scenes") if config_mode == 'COMMON':
col = row.column() header, panel = layout.panel("common", default_closed=False)
col.prop(blenvy, "level_scene_selector", text='') header.label(text="Common")
col = row.column() if panel:
add_operator = col.operator("blenvy.scenes_list_actions", icon='ADD', text="") draw_common_settings_ui(panel, blenvy)
add_operator.action = 'ADD'
add_operator.scene_type = 'LEVEL' if config_mode == 'COMPONENTS':
col.enabled = blenvy.level_scene_selector is not None 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()