mirror of
https://github.com/kaosat-dev/Blender_bevy_components_workflow.git
synced 2024-11-22 20:00:53 +00:00
feat(Blenvy): more work done on generated assets
* quick superficial hooking up of data * more ui improvements & tweaks * various minor related experiments
This commit is contained in:
parent
ec95ab5541
commit
0cf3ec99cb
@ -112,4 +112,12 @@ def get_main_scene_assets_tree(main_scene, blueprints_data, settings):
|
||||
assets_list += get_blueprint_assets_tree(blueprint, blueprints_data, parent=blueprint.name, settings=settings)
|
||||
|
||||
print("TOTAL ASSETS", assets_list)
|
||||
# FIXME: do not do it here !!
|
||||
scene = bpy.data.scenes[main_scene.name]
|
||||
scene.generated_assets.clear()
|
||||
for asset in assets_list:
|
||||
if asset.get("generated", False):
|
||||
added_asset = scene.generated_assets.add()
|
||||
added_asset.name = asset["name"]
|
||||
added_asset.path = asset["path"]
|
||||
return assets_list
|
||||
|
@ -7,21 +7,46 @@ def draw_assets(layout, name, title, asset_registry, target_type, target_name, e
|
||||
number_of_user_assets = len(user_assets)
|
||||
number_of_generated_assets = len(generated_assets)
|
||||
|
||||
header, panel = layout.panel(f"assets{name}", default_closed=False)
|
||||
header, panel = layout.panel(f"assets{name}", default_closed=True)
|
||||
header.label(text=title + f"({number_of_user_assets + number_of_generated_assets})", icon="ASSET_MANAGER")
|
||||
|
||||
|
||||
blueprint_assets = target_type == 'BLUEPRINT'
|
||||
if blueprint_assets:
|
||||
target = bpy.data.collections[target_name]
|
||||
else:
|
||||
target = bpy.data.scenes[target_name]
|
||||
|
||||
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
|
||||
|
||||
row.prop(asset_registry, "asset_name_selector", text="")
|
||||
row.label(text=asset_registry.asset_path_selector)
|
||||
row.operator(operator="asset.open_filebrowser", text="", icon="FILE_FOLDER")
|
||||
|
||||
add_asset_layout = row.column()
|
||||
add_asset_layout.enabled = not add_possible
|
||||
|
||||
add_asset = add_asset_layout.operator(operator="bevyassets.add", text="", icon="ADD")
|
||||
add_asset.target_type = target_type
|
||||
add_asset.target_name = target_name
|
||||
add_asset.asset_name = asset_registry.asset_name_selector
|
||||
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()
|
||||
blueprint_assets = target_type == 'BLUEPRINT'
|
||||
if blueprint_assets:
|
||||
target = bpy.data.collections[target_name]
|
||||
else:
|
||||
target = bpy.data.scenes[target_name]
|
||||
|
||||
add_possible = does_asset_exist(target, {"path": asset_registry.asset_path_selector}) #"name": asset_registry.asset_name_selector,
|
||||
|
||||
row.alert = add_possible
|
||||
"""row.alert = add_possible
|
||||
row.prop(asset_registry, "asset_name_selector", text="")
|
||||
row.label(text=asset_registry.asset_path_selector)
|
||||
asset_selector = row.operator(operator="asset.open_filebrowser", text="", icon="FILE_FOLDER")
|
||||
@ -34,14 +59,19 @@ def draw_assets(layout, name, title, asset_registry, target_type, target_name, e
|
||||
add_asset.target_name = target_name
|
||||
add_asset.asset_name = asset_registry.asset_name_selector
|
||||
add_asset.asset_type = asset_registry.asset_type_selector
|
||||
add_asset.asset_path = asset_registry.asset_path_selector
|
||||
add_asset.asset_path = asset_registry.asset_path_selector"""
|
||||
|
||||
panel.separator()
|
||||
|
||||
for asset in user_assets:
|
||||
row = panel.row()
|
||||
split = row.split(factor=0.005)
|
||||
col = split.column()
|
||||
col.label(text=" ")
|
||||
col = split.column()
|
||||
|
||||
row = col.row()
|
||||
row.prop(asset, "name", text="")
|
||||
#row.prop(asset, "path", text="")
|
||||
row.label(text=asset.path)
|
||||
asset_selector = row.operator(operator="asset.open_filebrowser", text="", icon="FILE_FOLDER")
|
||||
|
||||
@ -49,15 +79,26 @@ def draw_assets(layout, name, title, asset_registry, target_type, target_name, e
|
||||
remove_asset.target_type = target_type
|
||||
remove_asset.target_name = target_name
|
||||
remove_asset.asset_path = asset.path
|
||||
"""if not asset["internal"] and editable:
|
||||
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"]
|
||||
else:
|
||||
row.label(text="")"""
|
||||
|
||||
for asset in generated_assets:
|
||||
pass
|
||||
row = panel.row()
|
||||
#row.label(text=asset.name)
|
||||
#row.label(text=asset.path)
|
||||
split = row.split(factor=0.005)
|
||||
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")
|
||||
"""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"""
|
||||
|
||||
|
||||
return panel
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import bpy
|
||||
import json
|
||||
|
||||
from ..assets.asset_helpers import get_user_assets
|
||||
from ..assets.asset_helpers import get_user_assets, get_generated_assets
|
||||
|
||||
from ..assets.ui import draw_assets
|
||||
|
||||
@ -29,7 +29,7 @@ class GLTF_PT_auto_export_blueprints_list(bpy.types.Panel):
|
||||
|
||||
header, panel = layout.box().panel(f"blueprint_assets{blueprint.name}", default_closed=True)
|
||||
if header:
|
||||
header.label(text=blueprint.name)
|
||||
header.label(text=blueprint.name, icon="XRAY")
|
||||
header.prop(blueprint.collection, "always_export")
|
||||
|
||||
if blueprint.local:
|
||||
@ -47,9 +47,13 @@ class GLTF_PT_auto_export_blueprints_list(bpy.types.Panel):
|
||||
|
||||
if blueprint.local:
|
||||
user_assets = get_user_assets(blueprint.collection)
|
||||
draw_assets(layout=col, name=blueprint.name, title="Assets", asset_registry=asset_registry, user_assets=user_assets, target_type="BLUEPRINT", target_name=blueprint.name)
|
||||
generated_assets = get_generated_assets(blueprint.collection)
|
||||
|
||||
draw_assets(layout=col, name=blueprint.name, title="Assets", asset_registry=asset_registry, user_assets=user_assets, generated_assets=generated_assets, target_type="BLUEPRINT", target_name=blueprint.name)
|
||||
|
||||
else:
|
||||
assets = get_user_assets(blueprint.collection)
|
||||
draw_assets(layout=col, name=blueprint.name, title="Assets", asset_registry=asset_registry, user_assets=user_assets, target_type="BLUEPRINT", target_name=blueprint.name, editable=False)
|
||||
user_assets = get_user_assets(blueprint.collection)
|
||||
generated_assets = get_generated_assets(blueprint.collection)
|
||||
|
||||
draw_assets(layout=col, name=blueprint.name, title="Assets", asset_registry=asset_registry, user_assets=user_assets, generated_assets=generated_assets, target_type="BLUEPRINT", target_name=blueprint.name, editable=False)
|
||||
panel.label(text="External")
|
||||
|
@ -51,7 +51,6 @@ class Blenvy_levels(bpy.types.Panel):
|
||||
split = panel.split(factor=0.005)
|
||||
col = split.column()
|
||||
col.label(text=" ")
|
||||
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user