diff --git a/core/updater.py b/core/updater.py index bfe4cbc..125cc7a 100644 --- a/core/updater.py +++ b/core/updater.py @@ -84,7 +84,7 @@ class AvatarToolkit_PT_UpdaterPanel(bpy.types.Panel): bl_region_type = 'UI' bl_category = CATEGORY_NAME bl_parent_id = AvatarToolKit_PT_AvatarToolkitPanel.bl_idname - bl_order = 8 + bl_order = 9 bl_options = {'DEFAULT_CLOSED'} def draw(self, context: bpy.types.Context) -> None: diff --git a/functions/custom_tools/armature_merging.py b/functions/custom_tools/armature_merging.py index cfe197a..133fe65 100644 --- a/functions/custom_tools/armature_merging.py +++ b/functions/custom_tools/armature_merging.py @@ -11,8 +11,8 @@ from ...core.common import ( clear_unused_data_blocks, join_mesh_objects, remove_unused_shapekeys, - simplify_bonename ) +from ...core.dictionaries import simplify_bonename class AvatarToolkit_OT_MergeArmature(bpy.types.Operator): """Operator for merging two armatures together with their associated meshes""" diff --git a/functions/tools/convert_resonite.py b/functions/tools/convert_resonite.py deleted file mode 100644 index a41678a..0000000 --- a/functions/tools/convert_resonite.py +++ /dev/null @@ -1,90 +0,0 @@ -import bpy -import re -from typing import Set, Dict, Optional -from bpy.types import Operator, Context -from ...core.translations import t -from ...core.logging_setup import logger -from ...core.common import get_active_armature, simplify_bonename, ProgressTracker -from ...core.dictionaries import bone_names, resonite_translations -from ...core.armature_validation import validate_armature - -class AvatarToolkit_OT_ConvertResonite(Operator): - """Convert armature bone names to Resonite format with progress tracking and validation""" - bl_idname = "avatar_toolkit.convert_resonite" - bl_label = t("Tools.convert_resonite") - bl_description = t("Tools.convert_resonite_desc") - bl_options = {'REGISTER', 'UNDO'} - - @classmethod - def poll(cls, context: Context) -> bool: - armature = get_active_armature(context) - if not armature: - return False - valid, _, _ = validate_armature(armature) - return valid - - def execute(self, context: Context) -> Set[str]: - armature = get_active_armature(context) - if not armature: - logger.warning("No armature selected for Resonite conversion") - self.report({'WARNING'}, t("Armature.validation.no_armature")) - return {'CANCELLED'} - - translate_bone_fails: int = 0 - untranslated_bones: Set[str] = set() - simplified_names: Dict[str, str] = {} - - # Create reverse lookup dictionary - reverse_bone_lookup = {} - for preferred_name, name_list in bone_names.items(): - for name in name_list: - reverse_bone_lookup[name] = preferred_name - - try: - context.view_layer.objects.active = armature - bpy.ops.object.mode_set(mode='EDIT') - bpy.ops.object.mode_set(mode='OBJECT') - - # Cache simplified bone names - for bone in armature.data.bones: - simplified_names[bone.name] = simplify_bonename(bone.name) - - total_bones = len(armature.data.bones) - with ProgressTracker(context, total_bones, t("Tools.convert_resonite.operation")) as progress: - for bone in armature.data.bones: - # Remove any existing "" tags - bone.name = re.compile(re.escape(""), re.IGNORECASE).sub("", bone.name) - simplified_name = simplified_names[bone.name] - - if simplified_name in reverse_bone_lookup and reverse_bone_lookup[simplified_name] in resonite_translations: - new_name = resonite_translations[reverse_bone_lookup[simplified_name]] - logger.debug(f"Translating bone: {bone.name} -> {new_name}") - bone.name = new_name - else: - untranslated_bones.add(bone.name) - bone.name = bone.name + "" - translate_bone_fails += 1 - logger.debug(f"Failed to translate bone: {bone.name}") - - progress.step(t("Tools.convert_resonite.processing", name=bone.name)) - - except Exception as e: - logger.error(f"Error during Resonite conversion: {str(e)}") - self.report({'ERROR'}, str(e)) - return {'CANCELLED'} - - finally: - try: - bpy.ops.object.mode_set(mode='OBJECT') - except Exception as e: - logger.warning(f"Error returning to object mode: {str(e)}") - - if translate_bone_fails > 0: - logger.info(f"Conversion completed with {translate_bone_fails} untranslated bones") - logger.debug(f"Untranslated bones: {untranslated_bones}") - self.report({'INFO'}, t("Tools.bones_translated_with_fails", translate_bone_fails=translate_bone_fails)) - else: - logger.info("All bones translated successfully") - self.report({'INFO'}, t("Tools.bones_translated_success")) - - return {'FINISHED'} \ No newline at end of file diff --git a/ui/atlas_materials_panel.py b/ui/atlas_materials_panel.py index ee940ba..8f8c056 100644 --- a/ui/atlas_materials_panel.py +++ b/ui/atlas_materials_panel.py @@ -213,7 +213,7 @@ class AvatarToolKit_PT_TextureAtlasPanel(Panel): bl_region_type = 'UI' bl_category = CATEGORY_NAME bl_parent_id = AvatarToolKit_PT_AvatarToolkitPanel.bl_idname - bl_order = 6 + bl_order = 7 def draw(self, context: Context): layout = self.layout diff --git a/ui/settings_panel.py b/ui/settings_panel.py index d0bd2f3..6e7c322 100644 --- a/ui/settings_panel.py +++ b/ui/settings_panel.py @@ -36,7 +36,7 @@ class AvatarToolKit_PT_SettingsPanel(Panel): bl_region_type: str = 'UI' bl_category: str = CATEGORY_NAME bl_parent_id: str = AvatarToolKit_PT_AvatarToolkitPanel.bl_idname - bl_order: int = 7 + bl_order: int = 8 bl_options = {'DEFAULT_CLOSED'} def draw(self, context: Context) -> None: