feat(Blenvy): ui tweaks

This commit is contained in:
kaosat.dev 2024-06-06 20:16:32 +02:00
parent 0cf3ec99cb
commit 29c8eba49c
8 changed files with 38 additions and 16 deletions

View File

@ -109,3 +109,5 @@ General issues:
- [ ] 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
- [ ] add option to 'split out' meshes from blueprints ?
- [ ] ie considering meshletts etc , it would make sense to keep blueprints seperate from purely mesh gltfs

View File

@ -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)

View File

@ -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

View File

@ -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":

View File

@ -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

View File

@ -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'

View File

@ -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

View File

@ -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)