From 29c8eba49cf16b14b91d2c6176e4d5466e6e6b28 Mon Sep 17 00:00:00 2001 From: "kaosat.dev" Date: Thu, 6 Jun 2024 20:16:32 +0200 Subject: [PATCH] feat(Blenvy): ui tweaks --- tools/blenvy/TODO.md | 4 +++- .../auto_export/common/prepare_and_export.py | 3 ++- .../auto_export/common/settings_diff.py | 1 + .../add_ons/auto_export/common/tracker.py | 2 +- tools/blenvy/assets/ui.py | 16 +++++++------- tools/blenvy/blueprints/ui.py | 21 +++++++++++++++++++ tools/blenvy/core/blenvy_manager.py | 2 -- tools/blenvy/levels/ui.py | 5 +++-- 8 files changed, 38 insertions(+), 16 deletions(-) diff --git a/tools/blenvy/TODO.md b/tools/blenvy/TODO.md index a362344..085e82d 100644 --- a/tools/blenvy/TODO.md +++ b/tools/blenvy/TODO.md @@ -108,4 +108,6 @@ General issues: - [ ] handle scene renames between saves (breaks diffing) - [ ] change scene selector to work on actual scenes aka to deal with renamed scenes - [x] fix asset file selection -- [x] change "assets" tab to "levels"/worlds tab & modify UI accordingly \ No newline at end of file +- [x] change "assets" tab to "levels"/worlds tab & modify UI accordingly +- [ ] add option to 'split out' meshes from blueprints ? + - [ ] ie considering meshletts etc , it would make sense to keep blueprints seperate from purely mesh gltfs \ No newline at end of file diff --git a/tools/blenvy/add_ons/auto_export/common/prepare_and_export.py b/tools/blenvy/add_ons/auto_export/common/prepare_and_export.py index e5c9730..ebfa07e 100644 --- a/tools/blenvy/add_ons/auto_export/common/prepare_and_export.py +++ b/tools/blenvy/add_ons/auto_export/common/prepare_and_export.py @@ -15,7 +15,8 @@ def prepare_and_export(): # determine changed objects per_scene_changes = get_changes_per_scene(settings=blenvy) # determine changed parameters - setting_changes = False # get_setting_changes() + setting_changes = get_setting_changes() + print("setting_changes", setting_changes) # do the actual export blenvy.auto_export.dry_run = 'NO_EXPORT'#'DISABLED'# auto_export(per_scene_changes, setting_changes, blenvy) diff --git a/tools/blenvy/add_ons/auto_export/common/settings_diff.py b/tools/blenvy/add_ons/auto_export/common/settings_diff.py index 5375918..9ece74c 100644 --- a/tools/blenvy/add_ons/auto_export/common/settings_diff.py +++ b/tools/blenvy/add_ons/auto_export/common/settings_diff.py @@ -37,6 +37,7 @@ def get_setting_changes(): previous_gltf_settings = load_settings(".blenvy_gltf_settings_previous") current_gltf_settings = load_settings(".blenvy_gltf_settings") + print("previous_gltf_settings", previous_gltf_settings, "current_gltf_settings", current_gltf_settings) gltf_settings_changed = not are_settings_identical(previous_gltf_settings, current_gltf_settings) # write the new settings to the old settings diff --git a/tools/blenvy/add_ons/auto_export/common/tracker.py b/tools/blenvy/add_ons/auto_export/common/tracker.py index 9bb9b77..9902aa2 100644 --- a/tools/blenvy/add_ons/auto_export/common/tracker.py +++ b/tools/blenvy/add_ons/auto_export/common/tracker.py @@ -83,7 +83,7 @@ class AutoExportTracker(PropertyGroup): print("last operators", ops) for op in ops: print("operator", op)""" - active_operator = getattr(bpy.context.active_operator, 'active_operator' , None) + active_operator = getattr(bpy.context, 'active_operator' , None) if active_operator is not None: #print("Operator", active_operator.bl_label, active_operator.bl_idname) if active_operator.bl_idname == "EXPORT_SCENE_OT_gltf" and active_operator.gltf_export_id == "gltf_auto_export": diff --git a/tools/blenvy/assets/ui.py b/tools/blenvy/assets/ui.py index 4b843d2..f98678c 100644 --- a/tools/blenvy/assets/ui.py +++ b/tools/blenvy/assets/ui.py @@ -4,6 +4,7 @@ from .assets_scan import get_main_scene_assets_tree from .asset_helpers import get_user_assets, does_asset_exist def draw_assets(layout, name, title, asset_registry, target_type, target_name, editable=True, user_assets= [], generated_assets = []): + nesting_indent = 0.05 number_of_user_assets = len(user_assets) number_of_generated_assets = len(generated_assets) @@ -20,7 +21,6 @@ def draw_assets(layout, name, title, asset_registry, target_type, target_name, e add_possible = does_asset_exist(target, {"path": asset_registry.asset_path_selector}) #"name": asset_registry.asset_name_selector, if header: - row = header.row() row.alert = add_possible @@ -38,9 +38,6 @@ def draw_assets(layout, name, title, asset_registry, target_type, target_name, e add_asset.asset_type = asset_registry.asset_type_selector add_asset.asset_path = asset_registry.asset_path_selector - - - if panel: if editable: row = panel.row() @@ -61,16 +58,17 @@ def draw_assets(layout, name, title, asset_registry, target_type, target_name, e add_asset.asset_type = asset_registry.asset_type_selector add_asset.asset_path = asset_registry.asset_path_selector""" - panel.separator() + #panel.separator() for asset in user_assets: row = panel.row() - split = row.split(factor=0.005) + split = row.split(factor=nesting_indent) col = split.column() col.label(text=" ") col = split.column() row = col.row() + row.label(icon="ASSET_MANAGER") row.prop(asset, "name", text="") row.label(text=asset.path) asset_selector = row.operator(operator="asset.open_filebrowser", text="", icon="FILE_FOLDER") @@ -80,11 +78,11 @@ def draw_assets(layout, name, title, asset_registry, target_type, target_name, e remove_asset.target_name = target_name remove_asset.asset_path = asset.path - for asset in generated_assets: + '''for asset in generated_assets: row = panel.row() #row.label(text=asset.name) #row.label(text=asset.path) - split = row.split(factor=0.005) + split = row.split(factor=nesting_indent) col = split.column() col.label(text=" ") col = split.column() @@ -97,7 +95,7 @@ def draw_assets(layout, name, title, asset_registry, target_type, target_name, e """remove_asset = row.operator(operator="bevyassets.remove", text="", icon="TRASH") remove_asset.target_type = target_type remove_asset.target_name = target_name - remove_asset.asset_path = asset.path""" + remove_asset.asset_path = asset.path"""''' return panel diff --git a/tools/blenvy/blueprints/ui.py b/tools/blenvy/blueprints/ui.py index 40f01ba..5664c79 100644 --- a/tools/blenvy/blueprints/ui.py +++ b/tools/blenvy/blueprints/ui.py @@ -5,6 +5,27 @@ from ..assets.asset_helpers import get_user_assets, get_generated_assets from ..assets.ui import draw_assets + +def draw_blueprints(layout, name, title, generated_assets): + nesting_indent = 0.05 + number_of_generated_assets = len(generated_assets) + + header, panel = layout.panel(f"assets{name}", default_closed=True) + header.label(text=title + f"({number_of_generated_assets})", icon="XRAY") + + if panel: + for asset in generated_assets: + row = panel.row() + split = row.split(factor=nesting_indent) + col = split.column() + col.label(text=" ") + col = split.column() + + sub_header, sub_panel = col.panel(f"assets_sub{asset.name}", default_closed=False) + sub_header.label(text=f"{asset.name} ({asset.path})", icon="XRAY") + if sub_panel: + sub_panel.label(text=" some stuff") + class GLTF_PT_auto_export_blueprints_list(bpy.types.Panel): bl_space_type = 'VIEW_3D' bl_region_type = 'UI' diff --git a/tools/blenvy/core/blenvy_manager.py b/tools/blenvy/core/blenvy_manager.py index a18f0c6..beae1f0 100644 --- a/tools/blenvy/core/blenvy_manager.py +++ b/tools/blenvy/core/blenvy_manager.py @@ -137,8 +137,6 @@ class BlenvyManager(PropertyGroup): bpy.types.WindowManager.blenvy = PointerProperty(type=BlenvyManager) # unsure - # you can add components to both objects & collections - #bpy.types.Object.components_meta = PointerProperty(type=ComponentsMeta) bpy.types.Collection.always_export = BoolProperty(default=False, description="always export this blueprint, regardless of changed status") # FIXME: not sure about this one bpy.types.Scene.always_export = BoolProperty(default=False, description="always export this blueprint, regardless of changed status") # FIXME: not sure about this one diff --git a/tools/blenvy/levels/ui.py b/tools/blenvy/levels/ui.py index 9d4a9a5..a82c2a1 100644 --- a/tools/blenvy/levels/ui.py +++ b/tools/blenvy/levels/ui.py @@ -2,6 +2,7 @@ from types import SimpleNamespace import bpy from ..assets.asset_helpers import get_generated_assets, get_user_assets from ..assets.ui import draw_assets +from ..blueprints.ui import draw_blueprints class Blenvy_levels(bpy.types.Panel): bl_space_type = 'VIEW_3D' @@ -18,7 +19,7 @@ class Blenvy_levels(bpy.types.Panel): layout.use_property_split = True layout.use_property_decorate = False # No animation. blenvy = context.window_manager.blenvy - layout.operator(operator="bevyassets.test") + layout.operator(operator="bevyassets.test", text="Generate") asset_registry = context.window_manager.assets_registry blueprints_registry = context.window_manager.blueprints_registry @@ -54,7 +55,7 @@ class Blenvy_levels(bpy.types.Panel): col = split.column() scene_assets_panel = draw_assets(layout=col, name=f"{scene.name}_assets", title=f"Assets", asset_registry=asset_registry, user_assets=user_assets, generated_assets=generated_assets, target_type="SCENE", target_name=scene.name) - + scene_blueprints_panel = draw_blueprints(layout=col, name=f"{scene.name}_blueprints", title=f"Blueprints", generated_assets=generated_assets, ) settings = {"blueprints_path": "blueprints", "export_gltf_extension": ".glb"} settings = SimpleNamespace(**settings)