mirror of
https://github.com/kaosat-dev/Blender_bevy_components_workflow.git
synced 2024-11-22 20:00:53 +00:00
feat(Blenvy): more improvements to repair/upgrade components UI
This commit is contained in:
parent
ba4e2c03e6
commit
7d4b0a4bae
@ -362,22 +362,34 @@ class BLENVY_PT_component_tools_panel(bpy.types.Panel):
|
|||||||
operator.component_name = component_name
|
operator.component_name = component_name
|
||||||
operator.item_type = get_selection_type(target)
|
operator.item_type = get_selection_type(target)
|
||||||
|
|
||||||
def draw_invalid_item_entry(self, layout, item, invalid_component_names, items_with_invalid_components, item_type):
|
def draw_invalid_items(self, layout, upgreadable_entries):
|
||||||
|
for entry in upgreadable_entries:
|
||||||
|
(status, custom_property, item, item_type) = entry
|
||||||
|
print("ENTRY", entry)
|
||||||
|
self.draw_invalid_or_unregistered(layout, status, custom_property, item, item_type)
|
||||||
|
|
||||||
|
def gather_invalid_item_data(self, item, invalid_component_names, items_with_invalid_components, items_with_original_components, original_name, item_type):
|
||||||
blenvy_custom_properties = ['components_meta', 'bevy_components', 'user_assets', 'generated_assets' ] # some of our own hard coded custom properties that should be ignored
|
blenvy_custom_properties = ['components_meta', 'bevy_components', 'user_assets', 'generated_assets' ] # some of our own hard coded custom properties that should be ignored
|
||||||
|
upgreadable_entries = []
|
||||||
|
|
||||||
if "components_meta" in item:
|
if "components_meta" in item:
|
||||||
components_metadata = item.components_meta.components
|
components_metadata = item.components_meta.components
|
||||||
object_component_names = []
|
object_component_names = []
|
||||||
|
|
||||||
|
|
||||||
for index, component_meta in enumerate(components_metadata):
|
for index, component_meta in enumerate(components_metadata):
|
||||||
long_name = component_meta.long_name
|
long_name = component_meta.long_name
|
||||||
if component_meta.invalid:
|
if component_meta.invalid:
|
||||||
self.draw_invalid_or_unregistered(layout, "Invalid", long_name, item, item_type)
|
upgreadable_entries.append(("Invalid", long_name, item, item_type))
|
||||||
|
#self.draw_invalid_or_unregistered(layout, "Invalid", long_name, item, item_type)
|
||||||
if not item.name in items_with_invalid_components:
|
if not item.name in items_with_invalid_components:
|
||||||
items_with_invalid_components.append((item.name, item_type))
|
items_with_invalid_components.append((item.name, item_type))
|
||||||
|
|
||||||
if not long_name in invalid_component_names:
|
if not long_name in invalid_component_names:
|
||||||
invalid_component_names.append(long_name)
|
invalid_component_names.append(long_name)
|
||||||
|
|
||||||
|
if original_name != "":
|
||||||
|
if long_name == original_name:
|
||||||
|
items_with_original_components.append((item.name, item_type))
|
||||||
|
|
||||||
object_component_names.append(long_name)
|
object_component_names.append(long_name)
|
||||||
|
|
||||||
@ -391,12 +403,14 @@ class BLENVY_PT_component_tools_panel(bpy.types.Panel):
|
|||||||
status = "Upgrade Needed"
|
status = "Upgrade Needed"
|
||||||
|
|
||||||
if status is not None:
|
if status is not None:
|
||||||
self.draw_invalid_or_unregistered(layout, status, custom_property, item, item_type)
|
upgreadable_entries.append((status, custom_property, item, item_type))
|
||||||
|
# self.draw_invalid_or_unregistered(layout, status, custom_property, item, item_type)
|
||||||
|
|
||||||
if not item.name in items_with_invalid_components:
|
if not item.name in items_with_invalid_components:
|
||||||
items_with_invalid_components.append((item.name, item_type))
|
items_with_invalid_components.append((item.name, item_type))
|
||||||
"""if not long_name in invalid_component_names:
|
"""if not long_name in invalid_component_names:
|
||||||
invalid_component_names.append(custom_property)""" # FIXME
|
invalid_component_names.append(custom_property)""" # FIXME
|
||||||
|
return upgreadable_entries
|
||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
layout = self.layout
|
layout = self.layout
|
||||||
@ -406,49 +420,35 @@ class BLENVY_PT_component_tools_panel(bpy.types.Panel):
|
|||||||
selected_component = bpy.context.window_manager.blenvy.components.component_selector
|
selected_component = bpy.context.window_manager.blenvy.components.component_selector
|
||||||
|
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
row.label(text= "------------------ Single item actions: Rename / Fix / Upgrade -------------------")#"Invalid/ unregistered components")
|
row.label(text= "* Single item actions: Rename / Fix / Upgrade")#"Invalid/ unregistered components")
|
||||||
|
|
||||||
items_with_invalid_components = []
|
items_with_invalid_components = []
|
||||||
invalid_component_names = []
|
invalid_component_names = []
|
||||||
items_with_original_components = []
|
items_with_original_components = []
|
||||||
|
|
||||||
|
|
||||||
self.draw_invalid_or_unregistered_header(layout, ["Item","Status", "Component", "Target"])
|
|
||||||
|
|
||||||
# for possible bulk actions
|
# for possible bulk actions
|
||||||
original_name = bpy.context.window_manager.blenvy.components.source_component_selector
|
original_name = bpy.context.window_manager.blenvy.components.source_component_selector
|
||||||
target_component_name = bpy.context.window_manager.blenvy.components.target_component_selector
|
target_component_name = bpy.context.window_manager.blenvy.components.target_component_selector
|
||||||
|
|
||||||
|
upgreadable_entries = []
|
||||||
for object in bpy.data.objects: # TODO: very inneficent
|
for object in bpy.data.objects: # TODO: very inneficent
|
||||||
if len(object.keys()) > 0:
|
if len(object.keys()) > 0:
|
||||||
self.draw_invalid_item_entry(layout, object, invalid_component_names, items_with_invalid_components, "OBJECT")
|
upgreadable_entries += self.gather_invalid_item_data(object, invalid_component_names, items_with_invalid_components, items_with_original_components, original_name, "OBJECT")
|
||||||
|
|
||||||
if original_name != "" and "components_meta" in object:
|
|
||||||
components_metadata = object.components_meta.components
|
|
||||||
for index, component_meta in enumerate(components_metadata):
|
|
||||||
long_name = component_meta.long_name
|
|
||||||
if long_name == original_name:
|
|
||||||
items_with_original_components.append((object.name, "OBJECT"))
|
|
||||||
|
|
||||||
for collection in bpy.data.collections:
|
for collection in bpy.data.collections:
|
||||||
if len(collection.keys()) > 0:
|
if len(collection.keys()) > 0:
|
||||||
self.draw_invalid_item_entry(layout, collection, invalid_component_names, items_with_invalid_components, "COLLECTION")
|
upgreadable_entries += self.gather_invalid_item_data(collection, invalid_component_names, items_with_invalid_components, items_with_original_components, original_name, "COLLECTION")
|
||||||
|
|
||||||
if original_name != "" and "components_meta" in collection:
|
if len(items_with_invalid_components) > 0:
|
||||||
components_metadata = collection.components_meta.components
|
self.draw_invalid_or_unregistered_header(layout, ["Item","Status", "Component", "Target"])
|
||||||
for index, component_meta in enumerate(components_metadata):
|
self.draw_invalid_items(layout, upgreadable_entries)
|
||||||
long_name = component_meta.long_name
|
else:
|
||||||
if long_name == original_name:
|
layout.box().label(text="No components with anomalies , all good !")
|
||||||
items_with_original_components.append((collection.name, "COLLECTION"))
|
|
||||||
|
|
||||||
if len(items_with_invalid_components) == 0:
|
|
||||||
layout.label(text="Nothing to see here , all good !")
|
|
||||||
|
|
||||||
#print("items_with_original_components", items_with_original_components)
|
#print("items_with_original_components", items_with_original_components)
|
||||||
layout.separator()
|
layout.separator()
|
||||||
layout.separator()
|
layout.separator()
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
row.label(text="------------------Bulk actions: Rename / Fix / Upgrade -------------------")
|
row.label(text="*Bulk actions: Rename / Fix / Upgrade")
|
||||||
|
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
col = row.column()
|
col = row.column()
|
||||||
|
Loading…
Reference in New Issue
Block a user