mirror of
https://github.com/kaosat-dev/Blender_bevy_components_workflow.git
synced 2024-11-22 11:50:53 +00:00
Compare commits
4 Commits
9cb0c6262e
...
7d4b0a4bae
Author | SHA1 | Date | |
---|---|---|---|
|
7d4b0a4bae | ||
|
ba4e2c03e6 | ||
|
85f0d11632 | ||
|
b424a73a46 |
@ -2,7 +2,7 @@
|
||||
[![License](https://img.shields.io/crates/l/bevy_gltf_components)](https://github.com/kaosat-dev/Blender_bevy_components_workflow/blob/main/LICENSE.md)
|
||||
[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/F1F5TO32O)
|
||||
|
||||
# Blenvy: a Blender <=> bevy components workflow
|
||||
# BLENVY: a friendly Blender <=> Bevy workflow !
|
||||
|
||||
![demo](./docs/blender_bevy.png)
|
||||
|
||||
|
@ -51,12 +51,12 @@ Blueprints:
|
||||
|
||||
Components:
|
||||
- [x] add support for adding components to collections
|
||||
- [ ] upgrade all operators:
|
||||
- [x] upgrade all operators:
|
||||
- [x] add
|
||||
- [x] remove
|
||||
- [x] copy & paste
|
||||
- [ ] OT_rename_component
|
||||
- [ ] Fix_Component_Operator
|
||||
- [x] BLENVY_OT_component_rename_component
|
||||
- [x] BLENVY_OT_component_fix
|
||||
- [ ] add handling for core::ops::Range<f32> & other ranges
|
||||
- [x] fix is_component_valid that is used in gltf_auto_export
|
||||
- Hashmap Support
|
||||
@ -64,21 +64,23 @@ Components:
|
||||
- [x] fix weird issue with missing "0" property when adding new entry in empty hashmap => happens only if the values for the "setter" have never been set
|
||||
- [ ] handle missing types in registry for keys & values
|
||||
|
||||
- [ ] Add correct upgrade handling from individual component to bevy_components
|
||||
- [x] Add correct upgrade handling from individual component to bevy_components
|
||||
- [x] Settings handling:
|
||||
- [x] move saveable settings out to a settings file
|
||||
- [x] update save & load
|
||||
- [x] add handling of polling frequency & enabling
|
||||
- [x] move advanced tools to components tab
|
||||
- [ ] remove most of the (bulk) advanced tools, too complex, too unclear (even for me !) and of limited use
|
||||
- [x] remove most of the (bulk) advanced tools, too complex, too unclear (even for me !) and of limited use
|
||||
- component renaming should be kept, but perhaps simplified:
|
||||
- if a renaming fails because the parameters are incompatible, nuke the old parameters
|
||||
- perhaps just add a display list of all NON component custom properties, so the user can find them easilly ?
|
||||
- [ ] status "unregistered" is often false and misleading
|
||||
- [x] status "unregistered" is often false and misleading
|
||||
-> see in registry ui "for custom_property in object.keys():"
|
||||
|
||||
|
||||
- [x] overhaul / improve the component selector (with built in searching, etc)
|
||||
- [ ] remove select_component_name_to_replace
|
||||
- [x] remove select_component_name_to_replace
|
||||
- [ ] display of invalid components is not working ?
|
||||
|
||||
|
||||
General things to solve:
|
||||
@ -139,4 +141,16 @@ General issues:
|
||||
- [ ] rename repo to "Blenvy"
|
||||
|
||||
|
||||
- [ ] simplify testing example:
|
||||
- [ ] remove use of rapier physics (or even the whole common boilerplate ?)
|
||||
- [ ] remove/replace bevy editor pls with some native ui to display hierarchies
|
||||
- [ ] switch to bevy rc2
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
- [x] overall cleanup
|
||||
- [x] object.add_bevy_component => blenvy.component_add
|
||||
|
||||
clear && pytest -svv --blender-template ../../testing/bevy_example/art/testing_library.blend --blender-executable /home/ckaos/tools/blender/blender-4.1.0-linux-x64/blender tests/test_bevy_integration_prepare.py && pytest -svv --blender-executable /home/ckaos/tools/blender/blender-4.1.0-linux-x64/blender tests/test_bevy_integration.py
|
@ -199,7 +199,7 @@ UI:
|
||||
|
||||
- [x] remove metadata when deleting components
|
||||
- [x] add try catch around custom_prop => propGroup
|
||||
- [x] enhance the GenerateComponent_From_custom_property_Operator to use the new system to actually generate the stuff
|
||||
- [x] enhance the BLENVY_OT_component_from_custom_property to use the new system to actually generate the stuff
|
||||
|
||||
- coherence in operators:
|
||||
- component_name vs component_type
|
||||
|
@ -17,15 +17,16 @@ from bpy.props import (StringProperty)
|
||||
|
||||
|
||||
# components management
|
||||
from .add_ons.bevy_components.components.operators import CopyComponentOperator, Fix_Component_Operator, OT_rename_component, RemoveComponentFromAllItemsOperator, RemoveComponentOperator, GenerateComponent_From_custom_property_Operator, PasteComponentOperator, AddComponentOperator, RenameHelper, Toggle_ComponentVisibility
|
||||
from .add_ons.bevy_components.components.operators import BLENVY_OT_component_copy, BLENVY_OT_component_fix, BLENVY_OT_component_rename_component, BLENVY_OT_component_remove_from_all_items, BLENVY_OT_component_remove, BLENVY_OT_component_from_custom_property, BLENVY_OT_component_paste, BLENVY_OT_component_add, RenameHelper, BLENVY_OT_component_toggle_visibility, BLENVY_OT_components_refresh_custom_properties_all, BLENVY_OT_components_refresh_custom_properties_current, BLENVY_OT_components_refresh_propgroups_all, BLENVY_OT_components_refresh_propgroups_current
|
||||
from .add_ons.bevy_components.registry.registry import ComponentsRegistry,MissingBevyType
|
||||
from .add_ons.bevy_components.registry.operators import (COMPONENTS_OT_REFRESH_CUSTOM_PROPERTIES_ALL, COMPONENTS_OT_REFRESH_CUSTOM_PROPERTIES_CURRENT, COMPONENTS_OT_REFRESH_PROPGROUPS_FROM_CUSTOM_PROPERTIES_ALL, COMPONENTS_OT_REFRESH_PROPGROUPS_FROM_CUSTOM_PROPERTIES_CURRENT, OT_select_component_name_to_replace, OT_select_object, ReloadRegistryOperator, OT_OpenSchemaFileBrowser)
|
||||
from .add_ons.bevy_components.registry.ui import (BEVY_COMPONENTS_PT_Configuration, BEVY_COMPONENTS_PT_AdvancedToolsPanel, BEVY_COMPONENTS_PT_MissingTypesPanel, MISSING_TYPES_UL_List)
|
||||
from .add_ons.bevy_components.registry.operators import (BLENVY_OT_components_registry_reload, BLENVY_OT_components_registry_browse_schema)
|
||||
from .add_ons.bevy_components.registry.ui import (BLENVY_PT_components_missing_types_panel, BLENVY_UL_components_missing_types)
|
||||
from .add_ons.bevy_components.components.metadata import (ComponentMetadata, ComponentsMeta)
|
||||
from .add_ons.bevy_components.components.lists import GENERIC_LIST_OT_actions, Generic_LIST_OT_AddItem, Generic_LIST_OT_RemoveItem, Generic_LIST_OT_SelectItem
|
||||
from .add_ons.bevy_components.components.maps import GENERIC_MAP_OT_actions
|
||||
from .add_ons.bevy_components.components.ui import (BEVY_COMPONENTS_PT_ComponentsPanel)
|
||||
from .add_ons.bevy_components.components.lists import BLENVY_OT_component_list_actions, BLENVY_OT_component_list_add_item, BLENVY_OT_component_list_remove_item, BLENVY_OT_component_list_select_item
|
||||
from .add_ons.bevy_components.components.maps import BLENVY_OT_component_map_actions
|
||||
from .add_ons.bevy_components.components.ui import BLENVY_PT_components_panel, BLENVY_PT_component_tools_panel
|
||||
from .add_ons.bevy_components.settings import ComponentsSettings
|
||||
from .add_ons.bevy_components.utils import BLENVY_OT_item_select
|
||||
|
||||
# auto export
|
||||
from .add_ons.auto_export import gltf_post_export_callback
|
||||
@ -33,25 +34,25 @@ from .add_ons.auto_export.common.tracker import AutoExportTracker
|
||||
from .add_ons.auto_export.settings import AutoExportSettings
|
||||
|
||||
# asset management
|
||||
from .assets.ui import Blenvy_assets
|
||||
from .assets.ui import BLENVY_PT_assets_panel
|
||||
from .assets.assets_registry import Asset, AssetsRegistry
|
||||
from .assets.operators import OT_Add_asset_filebrowser, OT_add_bevy_asset, OT_remove_bevy_asset, OT_test_bevy_assets
|
||||
from .assets.operators import BLENVY_OT_assets_browse, BLENVY_OT_assets_add, BLENVY_OT_assets_remove, BLENVY_OT_assets_generate_files
|
||||
|
||||
# levels management
|
||||
from .levels.ui import Blenvy_levels
|
||||
from .levels.operators import OT_select_level
|
||||
from .levels.ui import BLENVY_PT_levels_panel
|
||||
from .levels.operators import BLENVY_OT_level_select
|
||||
|
||||
# blueprints management
|
||||
from .blueprints.ui import GLTF_PT_auto_export_blueprints_list
|
||||
from .blueprints.ui import BLENVY_PT_blueprints_panel
|
||||
from .blueprints.blueprints_registry import BlueprintsRegistry
|
||||
from .blueprints.operators import OT_select_blueprint
|
||||
from .blueprints.operators import BLENVY_OT_blueprint_select
|
||||
|
||||
# blenvy core
|
||||
from .core.blenvy_manager import BlenvyManager
|
||||
from .core.operators import OT_switch_bevy_tooling
|
||||
from .core.operators import BLENVY_OT_tooling_switch
|
||||
from .core.ui.ui import (BLENVY_PT_SidePanel)
|
||||
from .core.ui.scenes_list import SCENES_LIST_OT_actions
|
||||
from .core.ui.assets_folder_browser import OT_OpenAssetsFolderBrowser
|
||||
from .core.ui.scenes_list import BLENVY_OT_scenes_list_actions
|
||||
from .assets.assets_folder_browser import BLENVY_OT_assets_paths_browse
|
||||
|
||||
|
||||
# this needs to be here, as it is how Blender's gltf exporter callbacks are defined, at the add-on root level
|
||||
@ -61,55 +62,49 @@ def glTF2_post_export_callback(data):
|
||||
|
||||
classes = [
|
||||
# common/core
|
||||
SCENES_LIST_OT_actions,
|
||||
OT_OpenAssetsFolderBrowser,
|
||||
BLENVY_OT_scenes_list_actions,
|
||||
BLENVY_OT_assets_paths_browse,
|
||||
|
||||
# blenvy
|
||||
BLENVY_PT_SidePanel,
|
||||
|
||||
# bevy components
|
||||
ComponentsSettings,
|
||||
AddComponentOperator,
|
||||
CopyComponentOperator,
|
||||
PasteComponentOperator,
|
||||
RemoveComponentOperator,
|
||||
RemoveComponentFromAllItemsOperator,
|
||||
Fix_Component_Operator,
|
||||
OT_rename_component,
|
||||
BLENVY_OT_component_add,
|
||||
BLENVY_OT_component_copy,
|
||||
BLENVY_OT_component_paste,
|
||||
BLENVY_OT_component_remove,
|
||||
BLENVY_OT_component_remove_from_all_items,
|
||||
BLENVY_OT_component_fix,
|
||||
BLENVY_OT_component_rename_component,
|
||||
RenameHelper,
|
||||
GenerateComponent_From_custom_property_Operator,
|
||||
Toggle_ComponentVisibility,
|
||||
BLENVY_OT_component_from_custom_property,
|
||||
BLENVY_OT_component_toggle_visibility,
|
||||
|
||||
ComponentMetadata,
|
||||
ComponentsMeta,
|
||||
MissingBevyType,
|
||||
ComponentsRegistry,
|
||||
|
||||
OT_OpenSchemaFileBrowser,
|
||||
ReloadRegistryOperator,
|
||||
COMPONENTS_OT_REFRESH_CUSTOM_PROPERTIES_ALL,
|
||||
COMPONENTS_OT_REFRESH_CUSTOM_PROPERTIES_CURRENT,
|
||||
BLENVY_OT_components_registry_browse_schema,
|
||||
BLENVY_OT_components_registry_reload,
|
||||
BLENVY_OT_components_refresh_custom_properties_all,
|
||||
BLENVY_OT_components_refresh_custom_properties_current,
|
||||
BLENVY_OT_components_refresh_propgroups_all,
|
||||
BLENVY_OT_components_refresh_propgroups_current,
|
||||
|
||||
COMPONENTS_OT_REFRESH_PROPGROUPS_FROM_CUSTOM_PROPERTIES_ALL,
|
||||
COMPONENTS_OT_REFRESH_PROPGROUPS_FROM_CUSTOM_PROPERTIES_CURRENT,
|
||||
|
||||
OT_select_object,
|
||||
OT_select_component_name_to_replace,
|
||||
BLENVY_OT_item_select,
|
||||
|
||||
BEVY_COMPONENTS_PT_ComponentsPanel,
|
||||
BEVY_COMPONENTS_PT_AdvancedToolsPanel,
|
||||
#BEVY_COMPONENTS_PT_Configuration,
|
||||
|
||||
MISSING_TYPES_UL_List,
|
||||
BEVY_COMPONENTS_PT_MissingTypesPanel,
|
||||
|
||||
Generic_LIST_OT_SelectItem,
|
||||
Generic_LIST_OT_AddItem,
|
||||
Generic_LIST_OT_RemoveItem,
|
||||
GENERIC_LIST_OT_actions,
|
||||
|
||||
GENERIC_MAP_OT_actions,
|
||||
BLENVY_PT_components_panel,
|
||||
BLENVY_PT_component_tools_panel,
|
||||
BLENVY_UL_components_missing_types,
|
||||
BLENVY_PT_components_missing_types_panel,
|
||||
|
||||
BLENVY_OT_component_list_select_item,
|
||||
BLENVY_OT_component_list_add_item,
|
||||
BLENVY_OT_component_list_remove_item,
|
||||
BLENVY_OT_component_list_actions,
|
||||
BLENVY_OT_component_map_actions,
|
||||
|
||||
# gltf auto export
|
||||
AutoExportTracker,
|
||||
@ -117,22 +112,22 @@ classes = [
|
||||
|
||||
# blenvy
|
||||
BlenvyManager,
|
||||
OT_switch_bevy_tooling,
|
||||
BLENVY_OT_tooling_switch,
|
||||
|
||||
Asset,
|
||||
AssetsRegistry,
|
||||
OT_add_bevy_asset,
|
||||
OT_remove_bevy_asset,
|
||||
OT_test_bevy_assets,
|
||||
OT_Add_asset_filebrowser,
|
||||
Blenvy_assets,
|
||||
BLENVY_OT_assets_add,
|
||||
BLENVY_OT_assets_remove,
|
||||
BLENVY_OT_assets_generate_files,
|
||||
BLENVY_OT_assets_browse,
|
||||
BLENVY_PT_assets_panel,
|
||||
|
||||
Blenvy_levels,
|
||||
OT_select_level,
|
||||
BLENVY_PT_levels_panel,
|
||||
BLENVY_OT_level_select,
|
||||
|
||||
BlueprintsRegistry,
|
||||
OT_select_blueprint,
|
||||
GLTF_PT_auto_export_blueprints_list,
|
||||
BLENVY_OT_blueprint_select,
|
||||
BLENVY_PT_blueprints_panel,
|
||||
]
|
||||
|
||||
|
||||
|
@ -2,9 +2,9 @@ import json
|
||||
from bpy_types import Operator, UIList
|
||||
from bpy.props import (StringProperty, EnumProperty, PointerProperty, FloatVectorProperty, IntProperty)
|
||||
|
||||
class Generic_LIST_OT_AddItem(Operator):
|
||||
class BLENVY_OT_component_list_add_item(Operator):
|
||||
"""Add a new item to the list."""
|
||||
bl_idname = "generic_list.add_item"
|
||||
bl_idname = "blenvy.component_list_add_item"
|
||||
bl_label = "Add a new item"
|
||||
|
||||
property_group_path: StringProperty(
|
||||
@ -39,9 +39,9 @@ class Generic_LIST_OT_AddItem(Operator):
|
||||
return{'FINISHED'}
|
||||
|
||||
|
||||
class Generic_LIST_OT_RemoveItem(Operator):
|
||||
class BLENVY_OT_component_list_remove_item(Operator):
|
||||
"""Remove an item to the list."""
|
||||
bl_idname = "generic_list.remove_item"
|
||||
bl_idname = "blenvy.component_list_remove_item"
|
||||
bl_label = "Remove selected item"
|
||||
|
||||
property_group_path: StringProperty(
|
||||
@ -72,9 +72,9 @@ class Generic_LIST_OT_RemoveItem(Operator):
|
||||
return{'FINISHED'}
|
||||
|
||||
|
||||
class Generic_LIST_OT_SelectItem(Operator):
|
||||
class BLENVY_OT_component_list_select_item(Operator):
|
||||
"""Remove an item to the list."""
|
||||
bl_idname = "generic_list.select_item"
|
||||
bl_idname = "blenvy.component_list_select_item"
|
||||
bl_label = "select an item"
|
||||
|
||||
|
||||
@ -109,9 +109,9 @@ class Generic_LIST_OT_SelectItem(Operator):
|
||||
return{'FINISHED'}
|
||||
|
||||
|
||||
class GENERIC_LIST_OT_actions(Operator):
|
||||
class BLENVY_OT_component_list_actions(Operator):
|
||||
"""Move items up and down, add and remove"""
|
||||
bl_idname = "generic_list.list_action"
|
||||
bl_idname = "blenvy.component_list_actions"
|
||||
bl_label = "List Actions"
|
||||
bl_description = "Move items up and down, add and remove"
|
||||
bl_options = {'REGISTER', 'UNDO'}
|
||||
|
@ -4,9 +4,9 @@ from bpy.props import (StringProperty, EnumProperty, PointerProperty, FloatVecto
|
||||
|
||||
from ..propGroups.conversions_from_prop_group import property_group_value_to_custom_property_value
|
||||
|
||||
class GENERIC_MAP_OT_actions(Operator):
|
||||
class BLENVY_OT_component_map_actions(Operator):
|
||||
"""Move items up and down, add and remove"""
|
||||
bl_idname = "generic_map.map_action"
|
||||
bl_idname = "blenvy.component_map_actions"
|
||||
bl_label = "Map Actions"
|
||||
bl_description = "Move items up and down, add and remove"
|
||||
bl_options = {'REGISTER', 'UNDO'}
|
||||
|
@ -168,6 +168,7 @@ def add_metadata_to_components_without_metadata(item):
|
||||
|
||||
# adds a component to an item (including metadata) using the provided component definition & optional value
|
||||
def add_component_to_item(item, component_definition, value=None):
|
||||
warnings = []
|
||||
cleanup_invalid_metadata(item)
|
||||
if item is not None:
|
||||
# print("add_component_to_item", component_definition)
|
||||
@ -182,10 +183,15 @@ def add_component_to_item(item, component_definition, value=None):
|
||||
value = property_group_value_to_custom_property_value(propertyGroup, definition, registry, None)
|
||||
else: # we have provided a value, that is a raw , custom property value, to set the value of the propertyGroup
|
||||
item["__disable__update"] = True # disable update callback while we set the values of the propertyGroup "tree" (as a propertyGroup can contain other propertyGroups)
|
||||
property_group_value_from_custom_property_value(propertyGroup, definition, registry, value)
|
||||
try:
|
||||
property_group_value_from_custom_property_value(propertyGroup, definition, registry, value)
|
||||
except:
|
||||
# if we failed to get the value, we default... to the default
|
||||
value = property_group_value_to_custom_property_value(propertyGroup, definition, registry, None)
|
||||
warnings.append(f"failed to get the initial value of {item.name}, using default value")
|
||||
del item["__disable__update"]
|
||||
|
||||
upsert_bevy_component(item, long_name, value)
|
||||
return warnings
|
||||
|
||||
def upsert_component_in_item(item, long_name, registry):
|
||||
# print("upsert_component_in_item", item, "component name", component_name)
|
||||
@ -338,17 +344,17 @@ def add_component_from_custom_property(item):
|
||||
add_metadata_to_components_without_metadata(item)
|
||||
apply_customProperty_values_to_item_propertyGroups(item)
|
||||
|
||||
def rename_component(item, original_long_name, new_long_name):
|
||||
registry = bpy.context.window_manager.components_registry
|
||||
def rename_component(registry, item, original_long_name, new_long_name):
|
||||
type_infos = registry.type_infos
|
||||
component_definition = type_infos[new_long_name]
|
||||
|
||||
component_ron_value = get_bevy_component_value_by_long_name(item=item, long_name=original_long_name)
|
||||
if component_ron_value is None and original_long_name in item:
|
||||
component_ron_value = item[original_long_name]
|
||||
|
||||
|
||||
remove_component_from_item(item, original_long_name)
|
||||
add_component_to_item(item, component_definition, component_ron_value)
|
||||
print("remove & rename")
|
||||
return add_component_to_item(item, component_definition, component_ron_value)
|
||||
|
||||
|
||||
def toggle_component(item, component_name):
|
||||
|
@ -4,12 +4,13 @@ import bpy
|
||||
from bpy_types import Operator
|
||||
from bpy.props import (StringProperty)
|
||||
|
||||
from .metadata import add_component_from_custom_property, add_component_to_item, apply_propertyGroup_values_to_item_customProperties_for_component, copy_propertyGroup_values_to_another_item, get_bevy_component_value_by_long_name, get_bevy_components, is_bevy_component_in_item, remove_component_from_item, rename_component, toggle_component
|
||||
from .metadata import add_component_from_custom_property, add_component_to_item, apply_customProperty_values_to_item_propertyGroups, apply_propertyGroup_values_to_item_customProperties, apply_propertyGroup_values_to_item_customProperties_for_component, copy_propertyGroup_values_to_another_item, get_bevy_component_value_by_long_name, get_bevy_components, is_bevy_component_in_item, remove_component_from_item, rename_component, toggle_component
|
||||
|
||||
from ..utils import get_selected_object_or_collection
|
||||
|
||||
class AddComponentOperator(Operator):
|
||||
class BLENVY_OT_component_add(Operator):
|
||||
"""Add Bevy component to object/collection"""
|
||||
bl_idname = "object.add_bevy_component"
|
||||
bl_idname = "blenvy.component_add"
|
||||
bl_label = "Add component to object/collection Operator"
|
||||
bl_options = {"UNDO"}
|
||||
|
||||
@ -30,9 +31,9 @@ class AddComponentOperator(Operator):
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
class CopyComponentOperator(Operator):
|
||||
class BLENVY_OT_component_copy(Operator):
|
||||
"""Copy Bevy component from object"""
|
||||
bl_idname = "object.copy_bevy_component"
|
||||
bl_idname = "blenvy.component_copy"
|
||||
bl_label = "Copy component Operator"
|
||||
bl_options = {"UNDO"}
|
||||
|
||||
@ -75,10 +76,10 @@ class CopyComponentOperator(Operator):
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
class PasteComponentOperator(Operator):
|
||||
class BLENVY_OT_component_paste(Operator):
|
||||
"""Paste Bevy component to object"""
|
||||
bl_idname = "object.paste_bevy_component"
|
||||
bl_label = "Paste component to object Operator"
|
||||
bl_idname = "blenvy.component_paste"
|
||||
bl_label = "Paste component to item Operator"
|
||||
bl_options = {"UNDO"}
|
||||
|
||||
def execute(self, context):
|
||||
@ -104,9 +105,9 @@ class PasteComponentOperator(Operator):
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
class RemoveComponentOperator(Operator):
|
||||
class BLENVY_OT_component_remove(Operator):
|
||||
"""Remove Bevy component from object/collection"""
|
||||
bl_idname = "object.remove_bevy_component"
|
||||
bl_idname = "blenvy.component_remove"
|
||||
bl_label = "Remove component from object/collection Operator"
|
||||
bl_options = {"UNDO"}
|
||||
|
||||
@ -149,9 +150,9 @@ class RemoveComponentOperator(Operator):
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
class RemoveComponentFromAllItemsOperator(Operator):
|
||||
class BLENVY_OT_component_remove_from_all_items(Operator):
|
||||
"""Remove Bevy component from all items"""
|
||||
bl_idname = "object.remove_bevy_component_all"
|
||||
bl_idname = "blenvy.component_remove_from_all_items"
|
||||
bl_label = "Remove component from all items Operator"
|
||||
bl_options = {"UNDO"}
|
||||
|
||||
@ -210,9 +211,9 @@ class RenameHelper(bpy.types.PropertyGroup):
|
||||
# remove handlers & co
|
||||
del bpy.types.WindowManager.bevy_component_rename_helper
|
||||
|
||||
class OT_rename_component(Operator):
|
||||
class BLENVY_OT_component_rename_component(Operator):
|
||||
"""Rename Bevy component"""
|
||||
bl_idname = "object.rename_bevy_component"
|
||||
bl_idname = "blenvy.component_rename"
|
||||
bl_label = "rename component"
|
||||
bl_options = {"UNDO"}
|
||||
|
||||
@ -226,7 +227,7 @@ class OT_rename_component(Operator):
|
||||
|
||||
@classmethod
|
||||
def register(cls):
|
||||
bpy.types.WindowManager.components_rename_progress = bpy.props.FloatProperty(default=-1.0) #bpy.props.PointerProperty(type=RenameHelper)
|
||||
bpy.types.WindowManager.components_rename_progress = bpy.props.FloatProperty(default=-1.0)
|
||||
|
||||
@classmethod
|
||||
def unregister(cls):
|
||||
@ -234,7 +235,6 @@ class OT_rename_component(Operator):
|
||||
|
||||
def execute(self, context):
|
||||
registry = context.window_manager.components_registry
|
||||
type_infos = registry.type_infos
|
||||
settings = context.window_manager.bevy_component_rename_helper
|
||||
original_name = settings.original_name if self.original_name == "" else self.original_name
|
||||
target_name = self.target_name
|
||||
@ -243,19 +243,29 @@ class OT_rename_component(Operator):
|
||||
print("renaming components: original name", original_name, "target_name", self.target_name, "targets", self.target_items)
|
||||
target_items = json.loads(self.target_items)
|
||||
errors = []
|
||||
warnings = []
|
||||
total = len(target_items)
|
||||
|
||||
|
||||
if original_name != '' and target_name != '' and original_name != target_name and len(target_items) > 0:
|
||||
for index, item_name in enumerate(target_items):
|
||||
object = bpy.data.objects[item_name]
|
||||
if object and original_name in get_bevy_components(object) or original_name in object:
|
||||
for index, item_data in enumerate(target_items):
|
||||
[item_name, item_type] = item_data
|
||||
item = None
|
||||
if item_type == "OBJECT":
|
||||
item = bpy.data.objects[item_name]
|
||||
elif item_type == "COLLECTION":
|
||||
item = bpy.data.collections[item_name]
|
||||
|
||||
print("heloooo", item, get_bevy_components(item))
|
||||
|
||||
if item and original_name in get_bevy_components(item) or original_name in item:
|
||||
try:
|
||||
# attempt conversion
|
||||
rename_component(item=object, original_long_name=original_name, new_long_name=target_name)
|
||||
warnings += rename_component(registry=registry, item=item, original_long_name=original_name, new_long_name=target_name)
|
||||
except Exception as error:
|
||||
if '__disable__update' in object:
|
||||
del object["__disable__update"] # make sure custom properties are updateable afterwards, even in the case of failure
|
||||
components_metadata = getattr(object, "components_meta", None)
|
||||
if '__disable__update' in item:
|
||||
del item["__disable__update"] # make sure custom properties are updateable afterwards, even in the case of failure
|
||||
components_metadata = getattr(item, "components_meta", None)
|
||||
if components_metadata:
|
||||
components_metadata = components_metadata.components
|
||||
component_meta = next(filter(lambda component: component["long_name"] == target_name, components_metadata), None)
|
||||
@ -263,8 +273,8 @@ class OT_rename_component(Operator):
|
||||
component_meta.invalid = True
|
||||
component_meta.invalid_details = "wrong custom property value, overwrite them by changing the values in the ui or change them & regenerate"
|
||||
|
||||
errors.append( "wrong custom property values to generate target component: object: '" + object.name + "', error: " + str(error))
|
||||
|
||||
errors.append( "wrong custom property values to generate target component: object: '" + item.name + "', error: " + str(error))
|
||||
|
||||
progress = index / total
|
||||
context.window_manager.components_rename_progress = progress
|
||||
|
||||
@ -276,7 +286,7 @@ class OT_rename_component(Operator):
|
||||
if len(errors) > 0:
|
||||
self.report({'ERROR'}, "Failed to rename component: Errors:" + str(errors))
|
||||
else:
|
||||
self.report({'INFO'}, "Sucessfully renamed component")
|
||||
self.report({'INFO'}, f"Sucessfully renamed component for {total} items: Warnings: {str(warnings)}")
|
||||
|
||||
#clear data after we are done
|
||||
self.original_name = ""
|
||||
@ -286,9 +296,9 @@ class OT_rename_component(Operator):
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
class GenerateComponent_From_custom_property_Operator(Operator):
|
||||
class BLENVY_OT_component_from_custom_property(Operator):
|
||||
"""Generate Bevy components from custom property"""
|
||||
bl_idname = "object.generate_bevy_component_from_custom_property"
|
||||
bl_idname = "blenvy.component_from_custom_property"
|
||||
bl_label = "Generate component from custom_property Operator"
|
||||
bl_options = {"UNDO"}
|
||||
|
||||
@ -312,9 +322,9 @@ class GenerateComponent_From_custom_property_Operator(Operator):
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
class Fix_Component_Operator(Operator):
|
||||
class BLENVY_OT_component_fix(Operator):
|
||||
"""Attempt to fix Bevy component"""
|
||||
bl_idname = "object.fix_bevy_component"
|
||||
bl_idname = "blenvy.component_fix"
|
||||
bl_label = "Fix component (attempts to)"
|
||||
bl_options = {"UNDO"}
|
||||
|
||||
@ -337,9 +347,9 @@ class Fix_Component_Operator(Operator):
|
||||
self.report({'INFO'}, "Sucessfully fixed component (please double check component & its custom property value)")
|
||||
return {'FINISHED'}
|
||||
|
||||
class Toggle_ComponentVisibility(Operator):
|
||||
class BLENVY_OT_component_toggle_visibility(Operator):
|
||||
"""Toggle Bevy component's visibility"""
|
||||
bl_idname = "object.toggle_bevy_component_visibility"
|
||||
bl_idname = "blenvy.component_toggle_visibility"
|
||||
bl_label = "Toggle component visibility"
|
||||
bl_options = {"UNDO"}
|
||||
|
||||
@ -353,3 +363,142 @@ class Toggle_ComponentVisibility(Operator):
|
||||
toggle_component(target, self.component_name)
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class BLENVY_OT_components_refresh_custom_properties_all(Operator):
|
||||
"""Apply registry to ALL objects: update the custom property values of all objects based on their definition, if any"""
|
||||
bl_idname = "object.refresh_custom_properties_all"
|
||||
bl_label = "Apply Registry to all objects"
|
||||
bl_options = {"UNDO"}
|
||||
|
||||
@classmethod
|
||||
def register(cls):
|
||||
bpy.types.WindowManager.custom_properties_from_components_progress_all = bpy.props.FloatProperty(default=-1.0)
|
||||
|
||||
@classmethod
|
||||
def unregister(cls):
|
||||
del bpy.types.WindowManager.custom_properties_from_components_progress_all
|
||||
|
||||
def execute(self, context):
|
||||
print("apply registry to all")
|
||||
#context.window_manager.components_registry.load_schema()
|
||||
total = len(bpy.data.objects)
|
||||
|
||||
for index, object in enumerate(bpy.data.objects):
|
||||
apply_propertyGroup_values_to_item_customProperties(object)
|
||||
progress = index / total
|
||||
context.window_manager.custom_properties_from_components_progress_all = progress
|
||||
# now force refresh the ui
|
||||
bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1)
|
||||
context.window_manager.custom_properties_from_components_progress_all = -1.0
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
class BLENVY_OT_components_refresh_custom_properties_current(Operator):
|
||||
"""Apply registry to CURRENT object: update the custom property values of current object based on their definition, if any"""
|
||||
bl_idname = "object.refresh_custom_properties_current"
|
||||
bl_label = "Apply Registry to current object"
|
||||
bl_options = {"UNDO"}
|
||||
|
||||
@classmethod
|
||||
def register(cls):
|
||||
bpy.types.WindowManager.custom_properties_from_components_progress = bpy.props.FloatProperty(default=-1.0)
|
||||
|
||||
@classmethod
|
||||
def unregister(cls):
|
||||
del bpy.types.WindowManager.custom_properties_from_components_progress
|
||||
|
||||
def execute(self, context):
|
||||
print("apply registry to current object")
|
||||
object = context.object
|
||||
context.window_manager.custom_properties_from_components_progress = 0.5
|
||||
# now force refresh the ui
|
||||
bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1)
|
||||
apply_propertyGroup_values_to_item_customProperties(object)
|
||||
|
||||
context.window_manager.custom_properties_from_components_progress = -1.0
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
class BLENVY_OT_components_refresh_propgroups_current(Operator):
|
||||
"""Update UI values from custom properties to CURRENT object"""
|
||||
bl_idname = "object.refresh_ui_from_custom_properties_current"
|
||||
bl_label = "Apply custom_properties to current object"
|
||||
bl_options = {"UNDO"}
|
||||
|
||||
@classmethod
|
||||
def register(cls):
|
||||
bpy.types.WindowManager.components_from_custom_properties_progress = bpy.props.FloatProperty(default=-1.0)
|
||||
|
||||
@classmethod
|
||||
def unregister(cls):
|
||||
del bpy.types.WindowManager.components_from_custom_properties_progress
|
||||
|
||||
def execute(self, context):
|
||||
print("apply custom properties to current object")
|
||||
object = context.object
|
||||
error = False
|
||||
try:
|
||||
apply_customProperty_values_to_item_propertyGroups(object)
|
||||
progress = 0.5
|
||||
context.window_manager.components_from_custom_properties_progress = progress
|
||||
try:
|
||||
# now force refresh the ui
|
||||
bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1)
|
||||
except:pass # ony run in ui
|
||||
|
||||
except Exception as error_message:
|
||||
del object["__disable__update"] # make sure custom properties are updateable afterwards, even in the case of failure
|
||||
error = True
|
||||
self.report({'ERROR'}, "Failed to update propertyGroup values from custom property: Error:" + str(error_message))
|
||||
if not error:
|
||||
self.report({'INFO'}, "Sucessfully generated UI values for custom properties for selected object")
|
||||
context.window_manager.components_from_custom_properties_progress = -1.0
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
class BLENVY_OT_components_refresh_propgroups_all(Operator):
|
||||
"""Update UI values from custom properties to ALL object"""
|
||||
bl_idname = "object.refresh_ui_from_custom_properties_all"
|
||||
bl_label = "Apply custom_properties to all objects"
|
||||
bl_options = {"UNDO"}
|
||||
|
||||
@classmethod
|
||||
def register(cls):
|
||||
bpy.types.WindowManager.components_from_custom_properties_progress_all = bpy.props.FloatProperty(default=-1.0)
|
||||
|
||||
@classmethod
|
||||
def unregister(cls):
|
||||
del bpy.types.WindowManager.components_from_custom_properties_progress_all
|
||||
|
||||
def execute(self, context):
|
||||
print("apply custom properties to all object")
|
||||
bpy.context.window_manager.components_registry.disable_all_object_updates = True
|
||||
errors = []
|
||||
total = len(bpy.data.objects)
|
||||
|
||||
for index, object in enumerate(bpy.data.objects):
|
||||
|
||||
try:
|
||||
apply_customProperty_values_to_item_propertyGroups(object)
|
||||
except Exception as error:
|
||||
del object["__disable__update"] # make sure custom properties are updateable afterwards, even in the case of failure
|
||||
errors.append( "object: '" + object.name + "', error: " + str(error))
|
||||
|
||||
progress = index / total
|
||||
context.window_manager.components_from_custom_properties_progress_all = progress
|
||||
# now force refresh the ui
|
||||
bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1)
|
||||
|
||||
|
||||
|
||||
if len(errors) > 0:
|
||||
self.report({'ERROR'}, "Failed to update propertyGroup values from custom property: Errors:" + str(errors))
|
||||
else:
|
||||
self.report({'INFO'}, "Sucessfully generated UI values for custom properties for all objects")
|
||||
bpy.context.window_manager.components_registry.disable_all_object_updates = False
|
||||
context.window_manager.components_from_custom_properties_progress_all = -1.0
|
||||
return {'FINISHED'}
|
||||
|
@ -2,10 +2,9 @@ import json
|
||||
import bpy
|
||||
|
||||
from ..utils import get_selection_type
|
||||
from ..registry.operators import COMPONENTS_OT_REFRESH_CUSTOM_PROPERTIES_CURRENT
|
||||
from .metadata import do_item_custom_properties_have_missing_metadata, get_bevy_components
|
||||
from .operators import AddComponentOperator, CopyComponentOperator, Fix_Component_Operator, RemoveComponentOperator, GenerateComponent_From_custom_property_Operator, PasteComponentOperator, Toggle_ComponentVisibility
|
||||
|
||||
|
||||
|
||||
def draw_propertyGroup( propertyGroup, layout, nesting =[], rootName=None):
|
||||
is_enum = getattr(propertyGroup, "with_enum")
|
||||
is_list = getattr(propertyGroup, "with_list")
|
||||
@ -47,7 +46,7 @@ def draw_propertyGroup( propertyGroup, layout, nesting =[], rootName=None):
|
||||
row = list_column.row()
|
||||
draw_propertyGroup(item, row, nesting, rootName)
|
||||
icon = 'CHECKBOX_HLT' if list_index == index else 'CHECKBOX_DEHLT'
|
||||
op = row.operator('generic_list.select_item', icon=icon, text="")
|
||||
op = row.operator('blenvy.component_list_select_item', icon=icon, text="")
|
||||
op.component_name = rootName
|
||||
op.property_group_path = json.dumps(nesting)
|
||||
op.selection_index = index
|
||||
@ -55,26 +54,26 @@ def draw_propertyGroup( propertyGroup, layout, nesting =[], rootName=None):
|
||||
#various control buttons
|
||||
buttons_column.separator()
|
||||
row = buttons_column.row()
|
||||
op = row.operator('generic_list.list_action', icon='ADD', text="")
|
||||
op = row.operator('blenvy.component_list_actions', icon='ADD', text="")
|
||||
op.action = 'ADD'
|
||||
op.component_name = rootName
|
||||
op.property_group_path = json.dumps(nesting)
|
||||
|
||||
row = buttons_column.row()
|
||||
op = row.operator('generic_list.list_action', icon='REMOVE', text="")
|
||||
op = row.operator('blenvy.component_list_actions', icon='REMOVE', text="")
|
||||
op.action = 'REMOVE'
|
||||
op.component_name = rootName
|
||||
op.property_group_path = json.dumps(nesting)
|
||||
|
||||
buttons_column.separator()
|
||||
row = buttons_column.row()
|
||||
op = row.operator('generic_list.list_action', icon='TRIA_UP', text="")
|
||||
op = row.operator('blenvy.component_list_actions', icon='TRIA_UP', text="")
|
||||
op.action = 'UP'
|
||||
op.component_name = rootName
|
||||
op.property_group_path = json.dumps(nesting)
|
||||
|
||||
row = buttons_column.row()
|
||||
op = row.operator('generic_list.list_action', icon='TRIA_DOWN', text="")
|
||||
op = row.operator('blenvy.component_list_actions', icon='TRIA_DOWN', text="")
|
||||
op.action = 'DOWN'
|
||||
op.component_name = rootName
|
||||
op.property_group_path = json.dumps(nesting)
|
||||
@ -93,7 +92,7 @@ def draw_propertyGroup( propertyGroup, layout, nesting =[], rootName=None):
|
||||
values_setter = getattr(propertyGroup, "values_setter")
|
||||
draw_propertyGroup(values_setter, row, nesting, rootName)
|
||||
|
||||
op = row.operator('generic_map.map_action', icon='ADD', text="")
|
||||
op = row.operator('blenvy.component_map_actions', icon='ADD', text="")
|
||||
op.action = 'ADD'
|
||||
op.component_name = rootName
|
||||
op.property_group_path = json.dumps(nesting)
|
||||
@ -110,7 +109,7 @@ def draw_propertyGroup( propertyGroup, layout, nesting =[], rootName=None):
|
||||
value = values_list[index]
|
||||
draw_propertyGroup(value, row, nesting, rootName)
|
||||
|
||||
op = row.operator('generic_map.map_action', icon='REMOVE', text="")
|
||||
op = row.operator('blenvy.component_map_actions', icon='REMOVE', text="")
|
||||
op.action = 'REMOVE'
|
||||
op.component_name = rootName
|
||||
op.property_group_path = json.dumps(nesting)
|
||||
@ -143,8 +142,8 @@ def draw_propertyGroup( propertyGroup, layout, nesting =[], rootName=None):
|
||||
subrow.separator()
|
||||
|
||||
|
||||
class BEVY_COMPONENTS_PT_ComponentsPanel(bpy.types.Panel):
|
||||
bl_idname = "BEVY_COMPONENTS_PT_ComponentsPanel"
|
||||
class BLENVY_PT_components_panel(bpy.types.Panel):
|
||||
bl_idname = "BLENVY_PT_components_panel"
|
||||
bl_label = ""
|
||||
bl_space_type = 'VIEW_3D'
|
||||
bl_region_type = 'UI'
|
||||
@ -199,7 +198,7 @@ def draw_component_ui(layout, object_or_collection, registry, selected_component
|
||||
|
||||
# add components
|
||||
row = layout.row(align=True)
|
||||
op = row.operator(AddComponentOperator.bl_idname, text="Add", icon="ADD")
|
||||
op = row.operator("blenvy.component_add", text="Add", icon="ADD")
|
||||
op.component_type = selected_component
|
||||
row.enabled = selected_component != ''
|
||||
|
||||
@ -207,7 +206,7 @@ def draw_component_ui(layout, object_or_collection, registry, selected_component
|
||||
|
||||
# paste components
|
||||
row = layout.row(align=True)
|
||||
row.operator(PasteComponentOperator.bl_idname, text="Paste component ("+bpy.context.window_manager.copied_source_component_name+")", icon="PASTEDOWN")
|
||||
row.operator("blenvy.component_paste", text="Paste component ("+bpy.context.window_manager.copied_source_component_name+")", icon="PASTEDOWN")
|
||||
row.enabled = registry_has_type_infos and context.window_manager.copied_source_item_name != ''
|
||||
|
||||
layout.separator()
|
||||
@ -216,7 +215,7 @@ def draw_component_ui(layout, object_or_collection, registry, selected_component
|
||||
upgradeable_customProperties = registry.has_type_infos() and do_item_custom_properties_have_missing_metadata(object_or_collection)
|
||||
if upgradeable_customProperties:
|
||||
row = layout.row(align=True)
|
||||
op = row.operator(GenerateComponent_From_custom_property_Operator.bl_idname, text="generate components from custom properties" , icon="LOOP_FORWARDS")
|
||||
op = row.operator("blenvy.component_from_custom_property", text="generate components from custom properties" , icon="LOOP_FORWARDS")
|
||||
layout.separator()
|
||||
|
||||
|
||||
@ -224,7 +223,6 @@ def draw_component_ui(layout, object_or_collection, registry, selected_component
|
||||
#print("components_names", dict(components_bla).keys())
|
||||
|
||||
for component_name in sorted(get_bevy_components(object_or_collection)) : # sorted by component name, practical
|
||||
#print("component_name", component_name)
|
||||
if component_name == "components_meta":
|
||||
continue
|
||||
# anything withouth metadata gets skipped, we only want to see real components, not all custom props
|
||||
@ -277,17 +275,17 @@ def draw_component_ui(layout, object_or_collection, registry, selected_component
|
||||
if propertyGroup:
|
||||
unit_struct = len(propertyGroup.field_names) == 0
|
||||
if unit_struct:
|
||||
op = row.operator(Fix_Component_Operator.bl_idname, text="", icon="SHADERFX")
|
||||
op = row.operator("blenvy.component_fix", text="", icon="SHADERFX")
|
||||
op.component_name = component_name
|
||||
row.separator()
|
||||
|
||||
op = row.operator(RemoveComponentOperator.bl_idname, text="", icon="X")
|
||||
op = row.operator("blenvy.component_remove", text="", icon="X")
|
||||
op.component_name = component_name
|
||||
op.item_name = object_or_collection.name
|
||||
op.item_type = get_selection_type(object_or_collection)
|
||||
row.separator()
|
||||
|
||||
op = row.operator(CopyComponentOperator.bl_idname, text="", icon="COPYDOWN")
|
||||
op = row.operator("blenvy.component_copy", text="", icon="COPYDOWN")
|
||||
op.source_component_name = component_name
|
||||
op.source_item_name = object_or_collection.name
|
||||
op.source_item_type = get_selection_type(object_or_collection)
|
||||
@ -295,6 +293,257 @@ def draw_component_ui(layout, object_or_collection, registry, selected_component
|
||||
|
||||
#if not single_field:
|
||||
toggle_icon = "TRIA_DOWN" if component_visible else "TRIA_RIGHT"
|
||||
op = row.operator(Toggle_ComponentVisibility.bl_idname, text="", icon=toggle_icon)
|
||||
op = row.operator("blenvy.component_toggle_visibility", text="", icon=toggle_icon)
|
||||
op.component_name = component_name
|
||||
#row.separator()
|
||||
|
||||
|
||||
|
||||
class BLENVY_PT_component_tools_panel(bpy.types.Panel):
|
||||
"""panel listing all the missing bevy types in the schema"""
|
||||
bl_idname = "BLENVY_PT_component_tools_panel"
|
||||
bl_label = "Rename / Fix/ Update Components"
|
||||
bl_space_type = 'VIEW_3D'
|
||||
bl_region_type = 'UI'
|
||||
bl_category = "Bevy Components"
|
||||
bl_context = "objectmode"
|
||||
bl_parent_id = "BLENVY_PT_SidePanel"
|
||||
bl_options = {'DEFAULT_CLOSED'}
|
||||
bl_description = "advanced tooling"
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return context.window_manager.blenvy.mode == 'COMPONENTS'
|
||||
|
||||
def draw_invalid_or_unregistered_header(self, layout, items):
|
||||
row = layout.row()
|
||||
|
||||
for item in items:
|
||||
col = row.column()
|
||||
col.label(text=item)
|
||||
|
||||
def draw_invalid_or_unregistered(self, layout, status, component_name, target, item_type):
|
||||
item_type_short = item_type.lower()
|
||||
registry = bpy.context.window_manager.components_registry
|
||||
registry_has_type_infos = registry.has_type_infos()
|
||||
selected_component = target.components_meta.component_selector
|
||||
|
||||
row = layout.row()
|
||||
|
||||
col = row.column()
|
||||
operator = col.operator("blenvy.select_item", text=f"{target.name}({item_type_short})")
|
||||
operator.target_name = target.name
|
||||
operator.item_type = item_type
|
||||
|
||||
col = row.column()
|
||||
col.label(text=status)
|
||||
|
||||
col = row.column()
|
||||
col.label(text=component_name)
|
||||
|
||||
col = row.column()
|
||||
# each components_meta has a component selector to pick components from
|
||||
components_meta = target.components_meta
|
||||
col.prop(components_meta, "component_selector", text="")
|
||||
|
||||
|
||||
col = row.column()
|
||||
operator = col.operator("blenvy.component_rename", text="", icon="SHADERFX") #rename
|
||||
target_component_name = registry.type_infos[selected_component]['long_name'] if selected_component in registry.type_infos else ""
|
||||
operator.original_name = component_name
|
||||
operator.target_items = json.dumps([(target.name, item_type)]) # tupple
|
||||
operator.target_name = target_component_name
|
||||
col.enabled = registry_has_type_infos and component_name != "" and target_component_name != "" and component_name != target_component_name
|
||||
|
||||
|
||||
col = row.column()
|
||||
operator = col.operator("blenvy.component_remove", text="", icon="X")
|
||||
operator.item_name = target.name
|
||||
operator.component_name = component_name
|
||||
operator.item_type = get_selection_type(target)
|
||||
|
||||
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
|
||||
upgreadable_entries = []
|
||||
|
||||
if "components_meta" in item:
|
||||
components_metadata = item.components_meta.components
|
||||
object_component_names = []
|
||||
|
||||
|
||||
for index, component_meta in enumerate(components_metadata):
|
||||
long_name = component_meta.long_name
|
||||
if component_meta.invalid:
|
||||
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:
|
||||
items_with_invalid_components.append((item.name, item_type))
|
||||
if not long_name in invalid_component_names:
|
||||
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)
|
||||
|
||||
for custom_property in item.keys():
|
||||
# Invalid (something is wrong)
|
||||
# Unregistered (not in registry)
|
||||
# Upgrade Needed (Old-style component)
|
||||
|
||||
status = None
|
||||
if custom_property not in blenvy_custom_properties and custom_property not in object_component_names:
|
||||
status = "Upgrade Needed"
|
||||
|
||||
if status is not None:
|
||||
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:
|
||||
items_with_invalid_components.append((item.name, item_type))
|
||||
"""if not long_name in invalid_component_names:
|
||||
invalid_component_names.append(custom_property)""" # FIXME
|
||||
return upgreadable_entries
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
registry = bpy.context.window_manager.components_registry
|
||||
registry_has_type_infos = registry.has_type_infos()
|
||||
selected_object = context.selected_objects[0] if len(context.selected_objects) > 0 else None
|
||||
selected_component = bpy.context.window_manager.blenvy.components.component_selector
|
||||
|
||||
row = layout.row()
|
||||
row.label(text= "* Single item actions: Rename / Fix / Upgrade")#"Invalid/ unregistered components")
|
||||
|
||||
items_with_invalid_components = []
|
||||
invalid_component_names = []
|
||||
items_with_original_components = []
|
||||
|
||||
# for possible bulk actions
|
||||
original_name = bpy.context.window_manager.blenvy.components.source_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
|
||||
if len(object.keys()) > 0:
|
||||
upgreadable_entries += self.gather_invalid_item_data(object, invalid_component_names, items_with_invalid_components, items_with_original_components, original_name, "OBJECT")
|
||||
for collection in bpy.data.collections:
|
||||
if len(collection.keys()) > 0:
|
||||
upgreadable_entries += self.gather_invalid_item_data(collection, invalid_component_names, items_with_invalid_components, items_with_original_components, original_name, "COLLECTION")
|
||||
|
||||
if len(items_with_invalid_components) > 0:
|
||||
self.draw_invalid_or_unregistered_header(layout, ["Item","Status", "Component", "Target"])
|
||||
self.draw_invalid_items(layout, upgreadable_entries)
|
||||
else:
|
||||
layout.box().label(text="No components with anomalies , all good !")
|
||||
|
||||
#print("items_with_original_components", items_with_original_components)
|
||||
layout.separator()
|
||||
layout.separator()
|
||||
row = layout.row()
|
||||
row.label(text="*Bulk actions: Rename / Fix / Upgrade")
|
||||
|
||||
row = layout.row()
|
||||
col = row.column()
|
||||
col.label(text="Component")
|
||||
col = row.column()
|
||||
col.label(text="Target")
|
||||
col = row.column()
|
||||
col.label(text="------")
|
||||
|
||||
row = layout.row()
|
||||
col = row.column()
|
||||
col.prop(bpy.context.window_manager.blenvy.components, "source_component_selector", text="")
|
||||
|
||||
col = row.column()
|
||||
col.prop(bpy.context.window_manager.blenvy.components, "target_component_selector", text="")
|
||||
|
||||
col = row.column()
|
||||
components_rename_progress = context.window_manager.components_rename_progress
|
||||
if components_rename_progress == -1.0:
|
||||
operator = col.operator("blenvy.component_rename", text="apply", icon="SHADERFX")
|
||||
operator.original_name = original_name
|
||||
operator.target_name = target_component_name
|
||||
operator.target_items = json.dumps(items_with_original_components)
|
||||
col.enabled = registry_has_type_infos and original_name != "" and original_name != target_component_name
|
||||
else:
|
||||
if hasattr(layout,"progress") : # only for Blender > 4.0
|
||||
col.progress(factor = components_rename_progress, text=f"updating {components_rename_progress * 100.0:.2f}%")
|
||||
|
||||
col = row.column()
|
||||
remove_components_progress = context.window_manager.components_remove_progress
|
||||
if remove_components_progress == -1.0:
|
||||
operator = row.operator("blenvy.component_remove_from_all_items", text="", icon="X")
|
||||
operator.component_name = context.window_manager.bevy_component_rename_helper.original_name
|
||||
col.enabled = registry_has_type_infos and original_name != ""
|
||||
else:
|
||||
if hasattr(layout,"progress") : # only for Blender > 4.0
|
||||
col.progress(factor = remove_components_progress, text=f"updating {remove_components_progress * 100.0:.2f}%")
|
||||
|
||||
layout.separator()
|
||||
"""layout.separator()
|
||||
row = layout.row()
|
||||
box= row.box()
|
||||
box.label(text="Conversions between custom properties and components & vice-versa")
|
||||
|
||||
row = layout.row()
|
||||
row.label(text="WARNING ! The following operations will overwrite your existing custom properties if they have matching types on the bevy side !")
|
||||
row.alert = True
|
||||
|
||||
##
|
||||
row = layout.row()
|
||||
custom_properties_from_components_progress_current = context.window_manager.custom_properties_from_components_progress
|
||||
|
||||
if custom_properties_from_components_progress_current == -1.0:
|
||||
row.operator(BLENVY_OT_components_refresh_custom_properties_current.bl_idname, text="update custom properties of current object" , icon="LOOP_FORWARDS")
|
||||
row.enabled = registry_has_type_infos and selected_object is not None
|
||||
else:
|
||||
if hasattr(layout,"progress") : # only for Blender > 4.0
|
||||
layout.progress(factor = custom_properties_from_components_progress_current, text=f"updating {custom_properties_from_components_progress_current * 100.0:.2f}%")
|
||||
|
||||
layout.separator()
|
||||
row = layout.row()
|
||||
custom_properties_from_components_progress_all = context.window_manager.custom_properties_from_components_progress_all
|
||||
|
||||
if custom_properties_from_components_progress_all == -1.0:
|
||||
row.operator(BLENVY_OT_components_refresh_custom_properties_all.bl_idname, text="update custom properties of ALL objects" , icon="LOOP_FORWARDS")
|
||||
row.enabled = registry_has_type_infos
|
||||
else:
|
||||
if hasattr(layout,"progress") : # only for Blender > 4.0
|
||||
layout.progress(factor = custom_properties_from_components_progress_all, text=f"updating {custom_properties_from_components_progress_all * 100.0:.2f}%")
|
||||
|
||||
########################
|
||||
|
||||
row = layout.row()
|
||||
row.label(text="WARNING ! The following operations will try to overwrite your existing ui values if they have matching types on the bevy side !")
|
||||
row.alert = True
|
||||
|
||||
components_from_custom_properties_progress_current = context.window_manager.components_from_custom_properties_progress
|
||||
|
||||
row = layout.row()
|
||||
if components_from_custom_properties_progress_current == -1.0:
|
||||
row.operator(BLENVY_OT_components_refresh_propgroups_current.bl_idname, text="update UI FROM custom properties of current object" , icon="LOOP_BACK")
|
||||
row.enabled = registry_has_type_infos and selected_object is not None
|
||||
else:
|
||||
if hasattr(layout,"progress") : # only for Blender > 4.0
|
||||
layout.progress(factor = components_from_custom_properties_progress_current, text=f"updating {components_from_custom_properties_progress_current * 100.0:.2f}%")
|
||||
|
||||
layout.separator()
|
||||
row = layout.row()
|
||||
components_from_custom_properties_progress_all = context.window_manager.components_from_custom_properties_progress_all
|
||||
|
||||
if components_from_custom_properties_progress_all == -1.0:
|
||||
row.operator(BLENVY_OT_components_refresh_propgroups_all.bl_idname, text="update UI FROM custom properties of ALL objects" , icon="LOOP_BACK")
|
||||
row.enabled = registry_has_type_infos
|
||||
else:
|
||||
if hasattr(layout,"progress") : # only for Blender > 4.0
|
||||
layout.progress(factor = components_from_custom_properties_progress_all, text=f"updating {components_from_custom_properties_progress_all * 100.0:.2f}%")
|
||||
|
||||
"""
|
@ -5,13 +5,12 @@ from bpy.props import (StringProperty)
|
||||
from bpy_extras.io_utils import ImportHelper
|
||||
|
||||
from blenvy.settings import upsert_settings
|
||||
|
||||
from ..components.metadata import apply_customProperty_values_to_item_propertyGroups, apply_propertyGroup_values_to_item_customProperties, ensure_metadata_for_all_items
|
||||
from ..components.metadata import ensure_metadata_for_all_items
|
||||
from ..propGroups.prop_groups import generate_propertyGroups_for_components
|
||||
|
||||
class ReloadRegistryOperator(Operator):
|
||||
class BLENVY_OT_components_registry_reload(Operator):
|
||||
"""Reloads registry (schema file) from disk, generates propertyGroups for components & ensures all objects have metadata """
|
||||
bl_idname = "blenvy.reload_components_registry"
|
||||
bl_idname = "blenvy.components_registry_reload"
|
||||
bl_label = "Reload Registry"
|
||||
bl_options = {"UNDO"}
|
||||
|
||||
@ -36,146 +35,10 @@ class ReloadRegistryOperator(Operator):
|
||||
region.tag_redraw()
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
class COMPONENTS_OT_REFRESH_CUSTOM_PROPERTIES_ALL(Operator):
|
||||
"""Apply registry to ALL objects: update the custom property values of all objects based on their definition, if any"""
|
||||
bl_idname = "object.refresh_custom_properties_all"
|
||||
bl_label = "Apply Registry to all objects"
|
||||
bl_options = {"UNDO"}
|
||||
|
||||
@classmethod
|
||||
def register(cls):
|
||||
bpy.types.WindowManager.custom_properties_from_components_progress_all = bpy.props.FloatProperty(default=-1.0) #bpy.props.PointerProperty(type=RenameHelper)
|
||||
|
||||
@classmethod
|
||||
def unregister(cls):
|
||||
del bpy.types.WindowManager.custom_properties_from_components_progress_all
|
||||
|
||||
def execute(self, context):
|
||||
print("apply registry to all")
|
||||
#context.window_manager.components_registry.load_schema()
|
||||
total = len(bpy.data.objects)
|
||||
|
||||
for index, object in enumerate(bpy.data.objects):
|
||||
apply_propertyGroup_values_to_item_customProperties(object)
|
||||
progress = index / total
|
||||
context.window_manager.custom_properties_from_components_progress_all = progress
|
||||
# now force refresh the ui
|
||||
bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1)
|
||||
context.window_manager.custom_properties_from_components_progress_all = -1.0
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
class COMPONENTS_OT_REFRESH_CUSTOM_PROPERTIES_CURRENT(Operator):
|
||||
"""Apply registry to CURRENT object: update the custom property values of current object based on their definition, if any"""
|
||||
bl_idname = "object.refresh_custom_properties_current"
|
||||
bl_label = "Apply Registry to current object"
|
||||
bl_options = {"UNDO"}
|
||||
|
||||
@classmethod
|
||||
def register(cls):
|
||||
bpy.types.WindowManager.custom_properties_from_components_progress = bpy.props.FloatProperty(default=-1.0) #bpy.props.PointerProperty(type=RenameHelper)
|
||||
|
||||
@classmethod
|
||||
def unregister(cls):
|
||||
del bpy.types.WindowManager.custom_properties_from_components_progress
|
||||
|
||||
def execute(self, context):
|
||||
print("apply registry to current object")
|
||||
object = context.object
|
||||
context.window_manager.custom_properties_from_components_progress = 0.5
|
||||
# now force refresh the ui
|
||||
bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1)
|
||||
apply_propertyGroup_values_to_item_customProperties(object)
|
||||
|
||||
context.window_manager.custom_properties_from_components_progress = -1.0
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
class COMPONENTS_OT_REFRESH_PROPGROUPS_FROM_CUSTOM_PROPERTIES_CURRENT(Operator):
|
||||
"""Update UI values from custom properties to CURRENT object"""
|
||||
bl_idname = "object.refresh_ui_from_custom_properties_current"
|
||||
bl_label = "Apply custom_properties to current object"
|
||||
bl_options = {"UNDO"}
|
||||
|
||||
@classmethod
|
||||
def register(cls):
|
||||
bpy.types.WindowManager.components_from_custom_properties_progress = bpy.props.FloatProperty(default=-1.0) #bpy.props.PointerProperty(type=RenameHelper)
|
||||
|
||||
@classmethod
|
||||
def unregister(cls):
|
||||
del bpy.types.WindowManager.components_from_custom_properties_progress
|
||||
|
||||
def execute(self, context):
|
||||
print("apply custom properties to current object")
|
||||
object = context.object
|
||||
error = False
|
||||
try:
|
||||
apply_customProperty_values_to_item_propertyGroups(object)
|
||||
progress = 0.5
|
||||
context.window_manager.components_from_custom_properties_progress = progress
|
||||
try:
|
||||
# now force refresh the ui
|
||||
bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1)
|
||||
except:pass # ony run in ui
|
||||
|
||||
except Exception as error_message:
|
||||
del object["__disable__update"] # make sure custom properties are updateable afterwards, even in the case of failure
|
||||
error = True
|
||||
self.report({'ERROR'}, "Failed to update propertyGroup values from custom property: Error:" + str(error_message))
|
||||
if not error:
|
||||
self.report({'INFO'}, "Sucessfully generated UI values for custom properties for selected object")
|
||||
context.window_manager.components_from_custom_properties_progress = -1.0
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
class COMPONENTS_OT_REFRESH_PROPGROUPS_FROM_CUSTOM_PROPERTIES_ALL(Operator):
|
||||
"""Update UI values from custom properties to ALL object"""
|
||||
bl_idname = "object.refresh_ui_from_custom_properties_all"
|
||||
bl_label = "Apply custom_properties to all objects"
|
||||
bl_options = {"UNDO"}
|
||||
|
||||
@classmethod
|
||||
def register(cls):
|
||||
bpy.types.WindowManager.components_from_custom_properties_progress_all = bpy.props.FloatProperty(default=-1.0) #bpy.props.PointerProperty(type=RenameHelper)
|
||||
|
||||
@classmethod
|
||||
def unregister(cls):
|
||||
del bpy.types.WindowManager.components_from_custom_properties_progress_all
|
||||
|
||||
def execute(self, context):
|
||||
print("apply custom properties to all object")
|
||||
bpy.context.window_manager.components_registry.disable_all_object_updates = True
|
||||
errors = []
|
||||
total = len(bpy.data.objects)
|
||||
|
||||
for index, object in enumerate(bpy.data.objects):
|
||||
|
||||
try:
|
||||
apply_customProperty_values_to_item_propertyGroups(object)
|
||||
except Exception as error:
|
||||
del object["__disable__update"] # make sure custom properties are updateable afterwards, even in the case of failure
|
||||
errors.append( "object: '" + object.name + "', error: " + str(error))
|
||||
|
||||
progress = index / total
|
||||
context.window_manager.components_from_custom_properties_progress_all = progress
|
||||
# now force refresh the ui
|
||||
bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1)
|
||||
|
||||
|
||||
|
||||
if len(errors) > 0:
|
||||
self.report({'ERROR'}, "Failed to update propertyGroup values from custom property: Errors:" + str(errors))
|
||||
else:
|
||||
self.report({'INFO'}, "Sucessfully generated UI values for custom properties for all objects")
|
||||
bpy.context.window_manager.components_registry.disable_all_object_updates = False
|
||||
context.window_manager.components_from_custom_properties_progress_all = -1.0
|
||||
return {'FINISHED'}
|
||||
|
||||
class OT_OpenSchemaFileBrowser(Operator, ImportHelper):
|
||||
class BLENVY_OT_components_registry_browse_schema(Operator, ImportHelper):
|
||||
"""Browse for registry json file"""
|
||||
bl_idname = "blenvy.open_schemafilebrowser"
|
||||
bl_idname = "blenvy.components_registry_browse_schema"
|
||||
bl_label = "Open the file browser"
|
||||
|
||||
filter_glob: StringProperty(
|
||||
@ -197,41 +60,3 @@ class OT_OpenSchemaFileBrowser(Operator, ImportHelper):
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
class OT_select_object(Operator):
|
||||
"""Select object by name"""
|
||||
bl_idname = "object.select"
|
||||
bl_label = "Select object"
|
||||
bl_options = {"UNDO"}
|
||||
|
||||
target_name: StringProperty(
|
||||
name="target name",
|
||||
description="target to select's name ",
|
||||
) # type: ignore
|
||||
|
||||
def execute(self, context):
|
||||
if self.target_name:
|
||||
object = bpy.data.objects[self.target_name]
|
||||
scenes_of_object = list(object.users_scene)
|
||||
if len(scenes_of_object) > 0:
|
||||
bpy.ops.object.select_all(action='DESELECT')
|
||||
bpy.context.window.scene = scenes_of_object[0]
|
||||
object.select_set(True)
|
||||
bpy.context.view_layer.objects.active = object
|
||||
return {'FINISHED'}
|
||||
|
||||
class OT_select_component_name_to_replace(Operator):
|
||||
"""Select component name to replace"""
|
||||
bl_idname = "object.select_component_name_to_replace"
|
||||
bl_label = "Select component name for bulk replace"
|
||||
bl_options = {"UNDO"}
|
||||
|
||||
component_name: StringProperty(
|
||||
name="component_name",
|
||||
description="component name to replace",
|
||||
) # type: ignore
|
||||
|
||||
def execute(self, context):
|
||||
context.window_manager.bevy_component_rename_helper.original_name = self.component_name
|
||||
return {'FINISHED'}
|
||||
|
@ -1,293 +1,9 @@
|
||||
import json
|
||||
import bpy
|
||||
from bpy_types import (UIList)
|
||||
from bpy.props import (StringProperty)
|
||||
|
||||
from ..utils import get_selection_type
|
||||
|
||||
from ..components.operators import OT_rename_component, RemoveComponentFromAllItemsOperator
|
||||
from .operators import(
|
||||
COMPONENTS_OT_REFRESH_PROPGROUPS_FROM_CUSTOM_PROPERTIES_ALL,
|
||||
COMPONENTS_OT_REFRESH_PROPGROUPS_FROM_CUSTOM_PROPERTIES_CURRENT,
|
||||
OT_OpenSchemaFileBrowser, ReloadRegistryOperator,
|
||||
COMPONENTS_OT_REFRESH_CUSTOM_PROPERTIES_ALL,
|
||||
COMPONENTS_OT_REFRESH_CUSTOM_PROPERTIES_CURRENT)
|
||||
|
||||
class BEVY_COMPONENTS_PT_Configuration(bpy.types.Panel):
|
||||
bl_idname = "BEVY_COMPONENTS_PT_Configuration"
|
||||
bl_label = "Components"
|
||||
bl_space_type = 'VIEW_3D'
|
||||
bl_region_type = 'UI'
|
||||
bl_category = "Bevy Components"
|
||||
bl_context = "objectmode"
|
||||
bl_parent_id = "BLENVY_PT_SidePanel"
|
||||
bl_options = {'DEFAULT_CLOSED'}
|
||||
bl_description = "list of missing/unregistered type from the bevy side"
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return context.window_manager.blenvy.mode == 'SETTINGS'
|
||||
return context.object is not None
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
registry = context.window_manager.components_registry
|
||||
blenvy = context.window_manager.blenvy
|
||||
component_settings = blenvy.components
|
||||
|
||||
row = layout.row()
|
||||
col = row.column()
|
||||
col.enabled = False
|
||||
col.prop(component_settings, "schema_path", text="Registry Schema path")
|
||||
col = row.column()
|
||||
col.operator("blenvy.open_schemafilebrowser", text="Browse for registry schema file (json)")
|
||||
|
||||
layout.separator()
|
||||
layout.operator("blenvy.reload_components_registry", text="reload registry" , icon="FILE_REFRESH")
|
||||
|
||||
layout.separator()
|
||||
row = layout.row()
|
||||
|
||||
row.prop(component_settings, "watcher_enabled", text="enable registry file polling")
|
||||
row.prop(component_settings, "watcher_poll_frequency", text="registry file poll frequency (s)")
|
||||
|
||||
layout.separator()
|
||||
layout.separator()
|
||||
|
||||
|
||||
class BEVY_COMPONENTS_PT_AdvancedToolsPanel(bpy.types.Panel):
|
||||
class BLENVY_PT_components_missing_types_panel(bpy.types.Panel):
|
||||
"""panel listing all the missing bevy types in the schema"""
|
||||
bl_idname = "BEVY_COMPONENTS_PT_AdvancedToolsPanel"
|
||||
bl_label = "Advanced tools"
|
||||
bl_space_type = 'VIEW_3D'
|
||||
bl_region_type = 'UI'
|
||||
bl_category = "Bevy Components"
|
||||
bl_context = "objectmode"
|
||||
bl_parent_id = "BLENVY_PT_SidePanel"
|
||||
bl_options = {'DEFAULT_CLOSED'}
|
||||
bl_description = "advanced tooling"
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return context.window_manager.blenvy.mode == 'COMPONENTS'
|
||||
|
||||
def draw_invalid_or_unregistered_header(self, layout, items):
|
||||
row = layout.row()
|
||||
|
||||
for item in items:
|
||||
col = row.column()
|
||||
col.label(text=item)
|
||||
|
||||
def draw_invalid_or_unregistered(self, layout, status, component_name, target):
|
||||
registry = bpy.context.window_manager.components_registry
|
||||
registry_has_type_infos = registry.has_type_infos()
|
||||
selected_component = target.components_meta.component_selector
|
||||
|
||||
row = layout.row()
|
||||
|
||||
col = row.column()
|
||||
operator = col.operator("object.select", text=target.name)
|
||||
operator.target_name = target.name
|
||||
|
||||
col = row.column()
|
||||
col.label(text=status)
|
||||
|
||||
col = row.column()
|
||||
col.label(text=component_name)
|
||||
|
||||
col = row.column()
|
||||
# each components_meta has a component selector to pick components from
|
||||
components_meta = target.components_meta
|
||||
col.prop(components_meta, "component_selector", text="")
|
||||
|
||||
|
||||
col = row.column()
|
||||
operator = col.operator("object.rename_bevy_component", text="", icon="SHADERFX") #rename
|
||||
target_name = registry.type_infos[selected_component]['long_name'] if selected_component in registry.type_infos else ""
|
||||
operator.original_name = component_name
|
||||
operator.target_items = json.dumps([target.name])
|
||||
operator.target_name = target_name
|
||||
col.enabled = registry_has_type_infos and component_name != "" and component_name != target_name
|
||||
|
||||
|
||||
col = row.column()
|
||||
operator = col.operator("object.remove_bevy_component", text="", icon="X")
|
||||
operator.item_name = target.name
|
||||
operator.component_name = component_name
|
||||
operator.item_type = get_selection_type(target)
|
||||
|
||||
|
||||
"""col = row.column()
|
||||
col = row.column()
|
||||
operator = col.operator("object.select_component_name_to_replace", text="", icon="EYEDROPPER") #text="select for rename",
|
||||
operator.component_name = component_name"""
|
||||
|
||||
def draw_invalid_item_entry(self, layout, item, invalid_component_names, items_with_invalid_components):
|
||||
if "components_meta" in item:
|
||||
components_metadata = item.components_meta.components
|
||||
object_component_names = []
|
||||
for index, component_meta in enumerate(components_metadata):
|
||||
long_name = component_meta.long_name
|
||||
if component_meta.invalid:
|
||||
self.draw_invalid_or_unregistered(layout, "Invalid", long_name, item)
|
||||
|
||||
if not item.name in items_with_invalid_components:
|
||||
items_with_invalid_components.append(item.name)
|
||||
|
||||
if not long_name in invalid_component_names:
|
||||
invalid_component_names.append(long_name)
|
||||
|
||||
|
||||
object_component_names.append(long_name)
|
||||
|
||||
for custom_property in item.keys():
|
||||
# Invalid (something is wrong)
|
||||
# Unregistered (not in registry)
|
||||
# Upgrade Needed (Old-style component)
|
||||
|
||||
status = None
|
||||
if custom_property != 'components_meta' and custom_property != 'bevy_components' and custom_property not in object_component_names:
|
||||
status = "Upgrade Needed"
|
||||
|
||||
if status is not None:
|
||||
self.draw_invalid_or_unregistered(layout, status, custom_property, item)
|
||||
|
||||
if not item.name in items_with_invalid_components:
|
||||
items_with_invalid_components.append(item.name)
|
||||
"""if not long_name in invalid_component_names:
|
||||
invalid_component_names.append(custom_property)""" # FIXME
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
registry = bpy.context.window_manager.components_registry
|
||||
registry_has_type_infos = registry.has_type_infos()
|
||||
selected_object = context.selected_objects[0] if len(context.selected_objects) > 0 else None
|
||||
selected_component = bpy.context.window_manager.blenvy.components.component_selector
|
||||
|
||||
row = layout.row()
|
||||
box= row.box()
|
||||
box.label(text="Invalid/ unregistered components")
|
||||
|
||||
items_with_invalid_components = []
|
||||
invalid_component_names = []
|
||||
|
||||
self.draw_invalid_or_unregistered_header(layout, ["Item","Status", "Component", "Target"])
|
||||
|
||||
for object in bpy.data.objects: # TODO: very inneficent
|
||||
if len(object.keys()) > 0:
|
||||
self.draw_invalid_item_entry(layout, object, invalid_component_names, items_with_invalid_components)
|
||||
|
||||
for collection in bpy.data.collections:
|
||||
if len(collection.keys()) > 0:
|
||||
self.draw_invalid_item_entry(layout, collection, invalid_component_names, items_with_invalid_components)
|
||||
|
||||
|
||||
layout.separator()
|
||||
layout.separator()
|
||||
layout.label(text="------------------Bulk actions: Rename/ Upgrade -------------------")
|
||||
original_name = bpy.context.window_manager.blenvy.components.source_component_selector
|
||||
target_name = bpy.context.window_manager.blenvy.components.target_component_selector
|
||||
|
||||
row = layout.row()
|
||||
col = row.column()
|
||||
col.label(text="Component")
|
||||
col = row.column()
|
||||
col.label(text="Target")
|
||||
col = row.column()
|
||||
col.label(text="------")
|
||||
|
||||
row = layout.row()
|
||||
col = row.column()
|
||||
col.prop(bpy.context.window_manager.blenvy.components, "source_component_selector", text="")
|
||||
|
||||
col = row.column()
|
||||
col.prop(bpy.context.window_manager.blenvy.components, "target_component_selector", text="")
|
||||
|
||||
col = row.column()
|
||||
components_rename_progress = context.window_manager.components_rename_progress
|
||||
print("components_rename_progress", components_rename_progress)
|
||||
if components_rename_progress == -1.0:
|
||||
operator = col.operator(OT_rename_component.bl_idname, text="apply", icon="SHADERFX")
|
||||
operator.target_items = json.dumps(items_with_invalid_components)
|
||||
operator.target_name = target_name
|
||||
col.enabled = registry_has_type_infos and original_name != "" and original_name != target_name
|
||||
else:
|
||||
if hasattr(layout,"progress") : # only for Blender > 4.0
|
||||
col.progress(factor = components_rename_progress, text=f"updating {components_rename_progress * 100.0:.2f}%")
|
||||
|
||||
col = row.column()
|
||||
remove_components_progress = context.window_manager.components_remove_progress
|
||||
if remove_components_progress == -1.0:
|
||||
operator = row.operator(RemoveComponentFromAllItemsOperator.bl_idname, text="", icon="X")
|
||||
operator.component_name = context.window_manager.bevy_component_rename_helper.original_name
|
||||
col.enabled = registry_has_type_infos and original_name != ""
|
||||
else:
|
||||
if hasattr(layout,"progress") : # only for Blender > 4.0
|
||||
col.progress(factor = remove_components_progress, text=f"updating {remove_components_progress * 100.0:.2f}%")
|
||||
|
||||
layout.separator()
|
||||
"""layout.separator()
|
||||
row = layout.row()
|
||||
box= row.box()
|
||||
box.label(text="Conversions between custom properties and components & vice-versa")
|
||||
|
||||
row = layout.row()
|
||||
row.label(text="WARNING ! The following operations will overwrite your existing custom properties if they have matching types on the bevy side !")
|
||||
row.alert = True
|
||||
|
||||
##
|
||||
row = layout.row()
|
||||
custom_properties_from_components_progress_current = context.window_manager.custom_properties_from_components_progress
|
||||
|
||||
if custom_properties_from_components_progress_current == -1.0:
|
||||
row.operator(COMPONENTS_OT_REFRESH_CUSTOM_PROPERTIES_CURRENT.bl_idname, text="update custom properties of current object" , icon="LOOP_FORWARDS")
|
||||
row.enabled = registry_has_type_infos and selected_object is not None
|
||||
else:
|
||||
if hasattr(layout,"progress") : # only for Blender > 4.0
|
||||
layout.progress(factor = custom_properties_from_components_progress_current, text=f"updating {custom_properties_from_components_progress_current * 100.0:.2f}%")
|
||||
|
||||
layout.separator()
|
||||
row = layout.row()
|
||||
custom_properties_from_components_progress_all = context.window_manager.custom_properties_from_components_progress_all
|
||||
|
||||
if custom_properties_from_components_progress_all == -1.0:
|
||||
row.operator(COMPONENTS_OT_REFRESH_CUSTOM_PROPERTIES_ALL.bl_idname, text="update custom properties of ALL objects" , icon="LOOP_FORWARDS")
|
||||
row.enabled = registry_has_type_infos
|
||||
else:
|
||||
if hasattr(layout,"progress") : # only for Blender > 4.0
|
||||
layout.progress(factor = custom_properties_from_components_progress_all, text=f"updating {custom_properties_from_components_progress_all * 100.0:.2f}%")
|
||||
|
||||
########################
|
||||
|
||||
row = layout.row()
|
||||
row.label(text="WARNING ! The following operations will try to overwrite your existing ui values if they have matching types on the bevy side !")
|
||||
row.alert = True
|
||||
|
||||
components_from_custom_properties_progress_current = context.window_manager.components_from_custom_properties_progress
|
||||
|
||||
row = layout.row()
|
||||
if components_from_custom_properties_progress_current == -1.0:
|
||||
row.operator(COMPONENTS_OT_REFRESH_PROPGROUPS_FROM_CUSTOM_PROPERTIES_CURRENT.bl_idname, text="update UI FROM custom properties of current object" , icon="LOOP_BACK")
|
||||
row.enabled = registry_has_type_infos and selected_object is not None
|
||||
else:
|
||||
if hasattr(layout,"progress") : # only for Blender > 4.0
|
||||
layout.progress(factor = components_from_custom_properties_progress_current, text=f"updating {components_from_custom_properties_progress_current * 100.0:.2f}%")
|
||||
|
||||
layout.separator()
|
||||
row = layout.row()
|
||||
components_from_custom_properties_progress_all = context.window_manager.components_from_custom_properties_progress_all
|
||||
|
||||
if components_from_custom_properties_progress_all == -1.0:
|
||||
row.operator(COMPONENTS_OT_REFRESH_PROPGROUPS_FROM_CUSTOM_PROPERTIES_ALL.bl_idname, text="update UI FROM custom properties of ALL objects" , icon="LOOP_BACK")
|
||||
row.enabled = registry_has_type_infos
|
||||
else:
|
||||
if hasattr(layout,"progress") : # only for Blender > 4.0
|
||||
layout.progress(factor = components_from_custom_properties_progress_all, text=f"updating {components_from_custom_properties_progress_all * 100.0:.2f}%")
|
||||
|
||||
"""
|
||||
class BEVY_COMPONENTS_PT_MissingTypesPanel(bpy.types.Panel):
|
||||
"""panel listing all the missing bevy types in the schema"""
|
||||
bl_idname = "BEVY_COMPONENTS_PT_MissingTypesPanel"
|
||||
bl_idname = "BLENVY_PT_components_missing_types_panel"
|
||||
bl_label = "Missing/Unregistered Types"
|
||||
bl_space_type = 'VIEW_3D'
|
||||
bl_region_type = 'UI'
|
||||
@ -306,10 +22,10 @@ class BEVY_COMPONENTS_PT_MissingTypesPanel(bpy.types.Panel):
|
||||
registry = bpy.context.window_manager.components_registry
|
||||
|
||||
layout.label(text="Missing types ")
|
||||
layout.template_list("MISSING_TYPES_UL_List", "Missing types list", registry, "missing_types_list", registry, "missing_types_list_index")
|
||||
layout.template_list("BLENVY_UL_components_missing_types", "Missing types list", registry, "missing_types_list", registry, "missing_types_list_index")
|
||||
|
||||
|
||||
class MISSING_TYPES_UL_List(UIList):
|
||||
class BLENVY_UL_components_missing_types(UIList):
|
||||
"""Missing components UIList."""
|
||||
|
||||
use_filter_name_reverse: bpy.props.BoolProperty(
|
||||
|
@ -5,10 +5,10 @@ def draw_settings_ui(layout, component_settings):
|
||||
col.enabled = False
|
||||
col.prop(component_settings, "schema_path", text="Registry Schema path")
|
||||
col = row.column()
|
||||
col.operator(operator="blenvy.open_schemafilebrowser", text="Browse for registry schema file (json)")
|
||||
col.operator(operator="blenvy.components_registry_browse_schema", text="Browse for registry schema file (json)")
|
||||
|
||||
layout.separator()
|
||||
layout.operator(operator="blenvy.reload_components_registry", text="reload registry" , icon="FILE_REFRESH")
|
||||
layout.operator(operator="blenvy.components_registry_reload", text="reload registry" , icon="FILE_REFRESH")
|
||||
|
||||
layout.separator()
|
||||
row = layout.row()
|
||||
|
@ -1,5 +1,14 @@
|
||||
import bpy
|
||||
from .constants import HIDDEN_COMPONENTS
|
||||
from bpy.props import StringProperty, EnumProperty
|
||||
from bpy_types import Operator
|
||||
from blenvy.core.helpers_collections import (set_active_collection)
|
||||
|
||||
def get_collection_scene(collection):
|
||||
for scene in bpy.data.scenes:
|
||||
if scene.user_of_id(collection):
|
||||
return scene
|
||||
return None
|
||||
|
||||
#FIXME: does not work if object is hidden !!
|
||||
def get_selected_object_or_collection(context):
|
||||
@ -12,6 +21,52 @@ def get_selected_object_or_collection(context):
|
||||
target = collection
|
||||
return target
|
||||
|
||||
|
||||
class BLENVY_OT_item_select(Operator):
|
||||
"""Select object by name"""
|
||||
bl_idname = "blenvy.select_item"
|
||||
bl_label = "Select item (object or collection)"
|
||||
bl_options = {"UNDO"}
|
||||
|
||||
|
||||
item_type : EnumProperty(
|
||||
name="item type",
|
||||
description="type of the item to select: object or collection",
|
||||
items=(
|
||||
('OBJECT', "Object", ""),
|
||||
('COLLECTION', "Collection", ""),
|
||||
),
|
||||
default="OBJECT"
|
||||
) # type: ignore
|
||||
|
||||
target_name: StringProperty(
|
||||
name="target name",
|
||||
description="target to select's name ",
|
||||
) # type: ignore
|
||||
|
||||
def execute(self, context):
|
||||
if self.target_name:
|
||||
if self.item_type == "OBJECT":
|
||||
object = bpy.data.objects[self.target_name]
|
||||
scenes_of_object = list(object.users_scene)
|
||||
if len(scenes_of_object) > 0:
|
||||
bpy.ops.object.select_all(action='DESELECT')
|
||||
bpy.context.window.scene = scenes_of_object[0]
|
||||
object.select_set(True)
|
||||
bpy.context.view_layer.objects.active = object
|
||||
elif self.item_type == "COLLECTION":
|
||||
collection = bpy.data.collections[self.target_name]
|
||||
scene_of_collection = get_collection_scene(collection)
|
||||
if scene_of_collection is not None:
|
||||
bpy.ops.object.select_all(action='DESELECT')
|
||||
bpy.context.window.scene = scene_of_collection
|
||||
bpy.context.view_layer.objects.active = None
|
||||
set_active_collection(bpy.context.window.scene, collection.name)
|
||||
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
def get_selection_type(selection):
|
||||
if isinstance(selection, bpy.types.Object):
|
||||
return 'Object'
|
||||
@ -19,7 +74,6 @@ def get_selection_type(selection):
|
||||
return 'Collection'
|
||||
|
||||
def add_component_to_ui_list(self, context, _):
|
||||
print("add components to ui_list")
|
||||
items = []
|
||||
type_infos = context.window_manager.components_registry.type_infos
|
||||
for long_name in type_infos.keys():
|
||||
|
@ -4,11 +4,11 @@ import os
|
||||
from bpy_extras.io_utils import ImportHelper
|
||||
from bpy.types import Operator
|
||||
|
||||
from ..path_helpers import absolute_path_from_blend_file
|
||||
from ..core.path_helpers import absolute_path_from_blend_file
|
||||
|
||||
class OT_OpenAssetsFolderBrowser(Operator, ImportHelper):
|
||||
class BLENVY_OT_assets_paths_browse(Operator, ImportHelper):
|
||||
"""Assets folder's browser"""
|
||||
bl_idname = "generic.open_folderbrowser"
|
||||
bl_idname = "blenvy.assets_paths_browse"
|
||||
bl_label = "Select folder"
|
||||
|
||||
# Define this to tell 'fileselect_add' that we want a directoy
|
@ -6,13 +6,11 @@ from bpy.props import (BoolProperty, StringProperty, EnumProperty)
|
||||
|
||||
from .asset_helpers import does_asset_exist, get_user_assets, remove_asset, upsert_asset
|
||||
from .assets_scan import get_main_scene_assets_tree
|
||||
|
||||
from ..core.path_helpers import absolute_path_from_blend_file
|
||||
from ..settings import load_settings
|
||||
|
||||
class OT_add_bevy_asset(Operator):
|
||||
class BLENVY_OT_assets_add(Operator):
|
||||
"""Add asset"""
|
||||
bl_idname = "bevyassets.add"
|
||||
bl_idname = "blenvy.assets_add"
|
||||
bl_label = "Add bevy asset"
|
||||
bl_options = {"UNDO"}
|
||||
|
||||
@ -79,9 +77,9 @@ class OT_add_bevy_asset(Operator):
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
class OT_remove_bevy_asset(Operator):
|
||||
class BLENVY_OT_assets_remove(Operator):
|
||||
"""Remove asset"""
|
||||
bl_idname = "bevyassets.remove"
|
||||
bl_idname = "blenvy.assets_remove"
|
||||
bl_label = "remove bevy asset"
|
||||
bl_options = {"UNDO"}
|
||||
|
||||
@ -132,9 +130,9 @@ import os
|
||||
from bpy_extras.io_utils import ImportHelper
|
||||
from pathlib import Path
|
||||
|
||||
class OT_Add_asset_filebrowser(Operator, ImportHelper):
|
||||
class BLENVY_OT_assets_browse(Operator, ImportHelper):
|
||||
"""Browse for asset files"""
|
||||
bl_idname = "asset.open_filebrowser"
|
||||
bl_idname = "blenvy.assets_open_filebrowser"
|
||||
bl_label = "Select asset file"
|
||||
|
||||
# Define this to tell 'fileselect_add' that we want a directoy
|
||||
@ -200,9 +198,9 @@ def write_ron_assets_file(level_name, assets_hierarchy, internal_only=False, lev
|
||||
assets_file.writelines(formated_assets)
|
||||
assets_file.write("\n})")
|
||||
|
||||
class OT_test_bevy_assets(Operator):
|
||||
class BLENVY_OT_assets_generate_files(Operator):
|
||||
"""Test assets"""
|
||||
bl_idname = "bevyassets.test"
|
||||
bl_idname = "blenvy.assets_generate_files"
|
||||
bl_label = "test bevy assets"
|
||||
bl_options = {"UNDO"}
|
||||
|
||||
|
@ -26,12 +26,12 @@ def draw_assets(layout, name, title, asset_registry, target_type, target_name, e
|
||||
|
||||
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")
|
||||
row.operator(operator="blenvy.assets_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 = add_asset_layout.operator(operator="blenvy.assets_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
|
||||
@ -55,15 +55,15 @@ def draw_assets(layout, name, title, asset_registry, target_type, target_name, e
|
||||
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")
|
||||
asset_selector = row.operator(operator="blenvy.assets_open_filebrowser", text="", icon="FILE_FOLDER")
|
||||
|
||||
remove_asset = row.operator(operator="bevyassets.remove", text="", icon="TRASH")
|
||||
remove_asset = row.operator(operator="blenvy.assets_remove", text="", icon="TRASH")
|
||||
remove_asset.target_type = target_type
|
||||
remove_asset.target_name = target_name
|
||||
remove_asset.asset_path = asset.path
|
||||
return panel
|
||||
|
||||
class Blenvy_assets(bpy.types.Panel):
|
||||
class BLENVY_PT_assets_panel(bpy.types.Panel):
|
||||
bl_space_type = 'VIEW_3D'
|
||||
bl_region_type = 'UI'
|
||||
bl_label = ""
|
||||
@ -79,7 +79,7 @@ class Blenvy_assets(bpy.types.Panel):
|
||||
layout.use_property_decorate = False # No animation.
|
||||
blenvy = context.window_manager.blenvy
|
||||
|
||||
layout.operator(operator="bevyassets.test")
|
||||
layout.operator(operator="blenvy.assets_generate_files")
|
||||
|
||||
asset_registry = context.window_manager.assets_registry
|
||||
blueprints_registry = context.window_manager.blueprints_registry
|
||||
|
@ -4,9 +4,9 @@ from bpy_types import (Operator)
|
||||
from bpy.props import (StringProperty)
|
||||
from blenvy.core.helpers_collections import set_active_collection
|
||||
|
||||
class OT_select_blueprint(Operator):
|
||||
class BLENVY_OT_blueprint_select(Operator):
|
||||
"""Select blueprint """
|
||||
bl_idname = "blueprint.select"
|
||||
bl_idname = "blenvy.blueprint_select"
|
||||
bl_label = "Select blueprint"
|
||||
bl_options = {"UNDO"}
|
||||
|
||||
@ -22,18 +22,12 @@ class OT_select_blueprint(Operator):
|
||||
|
||||
def execute(self, context):
|
||||
if self.blueprint_collection_name:
|
||||
collection = bpy.data.collections[self.blueprint_collection_name]
|
||||
scene = bpy.data.scenes[self.blueprint_scene_name]
|
||||
if scene:
|
||||
bpy.ops.object.select_all(action='DESELECT')
|
||||
bpy.context.window.scene = scene
|
||||
bpy.context.view_layer.objects.active = None
|
||||
set_active_collection(scene, self.blueprint_collection_name)
|
||||
#bpy.context.view_layer.active_layer_collection = bpy.context.view_layer.layer_collection.children[self.blueprint_collection_name]
|
||||
#bpy.context.view_layer.collections.active = collection
|
||||
# bpy.context.view_layer.active_layer_collection = collection
|
||||
"""for o in collection.objects:
|
||||
o.select_set(True)"""
|
||||
|
||||
return {'FINISHED'}
|
||||
|
@ -26,7 +26,7 @@ def draw_blueprints(layout, name, title, generated_assets):
|
||||
if sub_panel:
|
||||
sub_panel.label(text=" some stuff")
|
||||
|
||||
class GLTF_PT_auto_export_blueprints_list(bpy.types.Panel):
|
||||
class BLENVY_PT_blueprints_panel(bpy.types.Panel):
|
||||
bl_space_type = 'VIEW_3D'
|
||||
bl_region_type = 'UI'
|
||||
bl_label = "Blueprints"
|
||||
@ -54,7 +54,7 @@ class GLTF_PT_auto_export_blueprints_list(bpy.types.Panel):
|
||||
header.prop(blueprint.collection, "always_export")
|
||||
|
||||
if blueprint.local:
|
||||
select_blueprint = header.operator(operator="blueprint.select", text="", icon="RESTRICT_SELECT_OFF")
|
||||
select_blueprint = header.operator(operator="blenvy.blueprint_select", text="", icon="RESTRICT_SELECT_OFF")
|
||||
if blueprint.collection and blueprint.collection.name:
|
||||
select_blueprint.blueprint_collection_name = blueprint.collection.name
|
||||
select_blueprint.blueprint_scene_name = blueprint.scene.name
|
||||
|
@ -4,7 +4,7 @@ from bpy.props import (EnumProperty)
|
||||
|
||||
|
||||
|
||||
class OT_switch_bevy_tooling(Operator):
|
||||
class BLENVY_OT_tooling_switch(Operator):
|
||||
"""Switch bevy tooling"""
|
||||
bl_idname = "bevy.tooling_switch"
|
||||
bl_label = "Switch bevy tooling"
|
||||
|
@ -1,9 +1,9 @@
|
||||
import bpy
|
||||
from bpy.types import Operator
|
||||
|
||||
class SCENES_LIST_OT_actions(Operator):
|
||||
class BLENVY_OT_scenes_list_actions(Operator):
|
||||
"""Move items up and down, add and remove"""
|
||||
bl_idname = "scene_list.list_action"
|
||||
bl_idname = "blenvy.scenes_list_actions"
|
||||
bl_label = "List Actions"
|
||||
bl_description = "Move items up and down, add and remove"
|
||||
bl_options = {'REGISTER'}
|
||||
|
@ -17,7 +17,7 @@ def draw_folder_browser(layout, label, prop_origin, target_property):
|
||||
col.enabled = False
|
||||
col.prop(prop_origin, target_property, text="")
|
||||
|
||||
folder_selector = row.operator("generic.open_folderbrowser", icon="FILE_FOLDER", text="")
|
||||
folder_selector = row.operator("blenvy.assets_paths_browse", icon="FILE_FOLDER", text="")
|
||||
folder_selector.target_property = target_property #"project_root_path"
|
||||
|
||||
# side panel
|
||||
@ -109,7 +109,7 @@ class BLENVY_PT_SidePanel(bpy.types.Panel):
|
||||
row = section.row()
|
||||
row.label(text="main scenes")
|
||||
row.prop(blenvy, "main_scene_selector", text='')
|
||||
add_operator = row.operator("scene_list.list_action", icon='ADD', text="")
|
||||
add_operator = row.operator("blenvy.scenes_list_actions", icon='ADD', text="")
|
||||
add_operator.action = 'ADD'
|
||||
add_operator.scene_type = 'LEVEL'
|
||||
#sub_row.enabled = blenvy.main_scene_selector is not None
|
||||
@ -119,7 +119,7 @@ class BLENVY_PT_SidePanel(bpy.types.Panel):
|
||||
for scene in blenvy.main_scenes:
|
||||
sub_row = col.box().row()
|
||||
sub_row.label(text=scene.name)
|
||||
remove_operator = sub_row.operator("scene_list.list_action", icon='TRASH', text="")
|
||||
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
|
||||
@ -130,7 +130,7 @@ class BLENVY_PT_SidePanel(bpy.types.Panel):
|
||||
row = section.row()
|
||||
row.label(text="library scenes")
|
||||
row.prop(blenvy, "library_scene_selector", text='')
|
||||
add_operator = row.operator("scene_list.list_action", icon='ADD', text="")
|
||||
add_operator = row.operator("blenvy.scenes_list_actions", icon='ADD', text="")
|
||||
add_operator.action = 'ADD'
|
||||
add_operator.scene_type = 'LIBRARY'
|
||||
|
||||
@ -139,7 +139,7 @@ class BLENVY_PT_SidePanel(bpy.types.Panel):
|
||||
for scene in blenvy.library_scenes:
|
||||
sub_row = col.box().row()
|
||||
sub_row.label(text=scene.name)
|
||||
remove_operator = sub_row.operator("scene_list.list_action", icon='TRASH', text="")
|
||||
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
|
||||
|
@ -3,9 +3,9 @@ import bpy
|
||||
from bpy_types import (Operator)
|
||||
from bpy.props import (StringProperty)
|
||||
|
||||
class OT_select_level(Operator):
|
||||
class BLENVY_OT_level_select(Operator):
|
||||
"""Select level """
|
||||
bl_idname = "level.select"
|
||||
bl_idname = "blenvy.level_select"
|
||||
bl_label = "Select level"
|
||||
bl_options = {"UNDO"}
|
||||
|
||||
@ -20,7 +20,6 @@ class OT_select_level(Operator):
|
||||
if scene:
|
||||
# bpy.ops.object.select_all(action='DESELECT')
|
||||
bpy.context.window.scene = scene
|
||||
|
||||
|
||||
return {'FINISHED'}
|
||||
|
@ -4,12 +4,13 @@ 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):
|
||||
class BLENVY_PT_levels_panel(bpy.types.Panel):
|
||||
bl_space_type = 'VIEW_3D'
|
||||
bl_region_type = 'UI'
|
||||
bl_label = ""
|
||||
bl_parent_id = "BLENVY_PT_SidePanel"
|
||||
bl_options = {'DEFAULT_CLOSED','HIDE_HEADER'}
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return context.window_manager.blenvy.mode == 'LEVELS'
|
||||
@ -19,7 +20,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", text="Generate")
|
||||
layout.operator(operator="blenvy.assets_generate_files", text="Generate")
|
||||
|
||||
asset_registry = context.window_manager.assets_registry
|
||||
blueprints_registry = context.window_manager.blueprints_registry
|
||||
@ -31,7 +32,7 @@ class Blenvy_levels(bpy.types.Panel):
|
||||
if header:
|
||||
header.label(text=scene.name)#, icon="HIDE_OFF")
|
||||
header.prop(scene, "always_export")
|
||||
select_level = header.operator(operator="level.select", text="", icon="RESTRICT_SELECT_OFF")
|
||||
select_level = header.operator(operator="blenvy.level_select", text="", icon="RESTRICT_SELECT_OFF")
|
||||
select_level.level_name = scene.name
|
||||
|
||||
if panel:
|
||||
|
@ -15,7 +15,7 @@ def setup_data(request):
|
||||
|
||||
type_infos = registry.type_infos
|
||||
object = bpy.context.object
|
||||
remove_component_operator = bpy.ops.object.remove_bevy_component
|
||||
remove_component_operator = bpy.ops.blenvy.component_remove
|
||||
|
||||
for long_name in type_infos:
|
||||
definition = type_infos[long_name]
|
||||
|
@ -196,7 +196,7 @@ def test_remove_components(setup_data):
|
||||
|
||||
# now test component removal
|
||||
errors.clear()
|
||||
remove_component_operator = bpy.ops.object.remove_bevy_component
|
||||
remove_component_operator = bpy.ops.blenvy.component_remove
|
||||
for long_name in added_components:
|
||||
try:
|
||||
remove_component_operator(component_name=long_name)
|
||||
@ -225,7 +225,7 @@ def test_copy_paste_components(setup_data):
|
||||
|
||||
setattr(propertyGroup, propertyGroup.field_names[0], 25.0)
|
||||
|
||||
copy_component_operator = bpy.ops.object.copy_bevy_component
|
||||
copy_component_operator = bpy.ops.blenvy.component_copy
|
||||
copy_component_operator(source_component_name=long_name, source_item_name=object.name)
|
||||
|
||||
# ---------------------------------------
|
||||
@ -240,7 +240,7 @@ def test_copy_paste_components(setup_data):
|
||||
# first check that there is no component currently
|
||||
assert component_meta == None
|
||||
|
||||
paste_component_operator = bpy.ops.object.paste_bevy_component
|
||||
paste_component_operator = bpy.ops.blenvy.component_paste
|
||||
paste_component_operator()
|
||||
|
||||
target_components_metadata = new_cube.components_meta.components
|
||||
|
@ -27,7 +27,7 @@ def test_rename_component_single_unit_struct(setup_data):
|
||||
registry.schema_path = setup_data["components_schemaPath"]
|
||||
bpy.ops.object.reload_registry()
|
||||
|
||||
rename_component_operator = bpy.ops.object.rename_bevy_component
|
||||
rename_component_operator = bpy.ops.blenvy.component_rename
|
||||
object = bpy.context.object
|
||||
|
||||
|
||||
@ -50,7 +50,7 @@ def test_rename_component_single_complex_struct(setup_data):
|
||||
registry.schema_path = setup_data["components_schemaPath"]
|
||||
bpy.ops.object.reload_registry()
|
||||
|
||||
rename_component_operator = bpy.ops.object.rename_bevy_component
|
||||
rename_component_operator = bpy.ops.blenvy.component_rename
|
||||
object = bpy.context.object
|
||||
|
||||
|
||||
@ -73,7 +73,7 @@ def test_rename_component_bulk(setup_data):
|
||||
registry.schema_path = setup_data["components_schemaPath"]
|
||||
bpy.ops.object.reload_registry()
|
||||
|
||||
rename_component_operator = bpy.ops.object.rename_bevy_component
|
||||
rename_component_operator = bpy.ops.blenvy.component_rename
|
||||
|
||||
source_component_name = "bevy_example::test_components::SomeOldUnitStruct"
|
||||
target_component_name = "bevy_example::test_components::UnitTest"
|
||||
@ -98,7 +98,7 @@ def test_rename_component_single_error_handling(setup_data):
|
||||
registry.schema_path = setup_data["components_schemaPath"]
|
||||
bpy.ops.object.reload_registry()
|
||||
|
||||
rename_component_operator = bpy.ops.object.rename_bevy_component
|
||||
rename_component_operator = bpy.ops.blenvy.component_rename
|
||||
object = bpy.context.object
|
||||
|
||||
|
||||
@ -128,7 +128,7 @@ def test_rename_component_single_error_handling_clean_errors(setup_data):
|
||||
registry.schema_path = setup_data["components_schemaPath"]
|
||||
bpy.ops.object.reload_registry()
|
||||
|
||||
rename_component_operator = bpy.ops.object.rename_bevy_component
|
||||
rename_component_operator = bpy.ops.blenvy.component_rename
|
||||
object = bpy.context.object
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user