From bf6a32febbfdf53edf0d0cb820ed83e19209d9c0 Mon Sep 17 00:00:00 2001 From: Yusarina Date: Fri, 7 Feb 2025 18:31:04 +0000 Subject: [PATCH 1/2] Went into wrong branch, whoops This went into the current branch as it was approved I just going to directly add into Alpha 2. --- core/logging_setup.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/core/logging_setup.py b/core/logging_setup.py index 37aab50..6769c2e 100644 --- a/core/logging_setup.py +++ b/core/logging_setup.py @@ -1,8 +1,10 @@ import logging +import traceback from typing import Optional, Any from bpy.types import Context logger = logging.getLogger('avatar_toolkit') +_original_error = logger.error def configure_logging(enabled: bool = False) -> None: """Configure logging for Avatar Toolkit""" @@ -18,6 +20,15 @@ def configure_logging(enabled: bool = False) -> None: formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') handler.setFormatter(formatter) logger.addHandler(handler) + + def error_with_traceback(msg, *args, **kwargs): + if kwargs.get('exc_info', False) or isinstance(msg, Exception): + full_msg = f"{msg}\n{traceback.format_exc()}" + _original_error(full_msg, *args, **{**kwargs, 'exc_info': False}) + else: + _original_error(msg, *args, **kwargs) + + logger.error = error_with_traceback def update_logging_state(self: Any, context: Context) -> None: """Update logging state based on user preference""" From 2524634ef4d84d14198b783a0c2afc11a1ac4d71 Mon Sep 17 00:00:00 2001 From: Yusarina Date: Fri, 7 Feb 2025 18:33:56 +0000 Subject: [PATCH 2/2] Update common.py --- core/common.py | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/core/common.py b/core/common.py index c232856..fdd7a41 100644 --- a/core/common.py +++ b/core/common.py @@ -19,6 +19,50 @@ from ..core.logging_setup import logger from ..core.translations import t from ..core.dictionaries import bone_names +class SceneMatClass(PropertyGroup): + mat: PointerProperty(type=Material) + +register_class(SceneMatClass) + +class MaterialListBool: + #For the love that is holy do not ever touch these. If this was java I would make these private + #They should only be accessed via context.scene.texture_atlas_Has_Mat_List_Shown + #This is so we know if the materials are up to date. messing with these variables directly will make the thing blow up. + + #The only exception to this is the ExpandSection_Materials operator which populates this with new data once the materials have changed and need reloading. + old_list: dict[str,list[Material]] = {} + bool_material_list_expand: dict[str,bool] = {} + + def set_bool(self, value: bool) -> None: + MaterialListBool.bool_material_list_expand[bpy.context.scene.name] = value + if value == False: + MaterialListBool.old_list[bpy.context.scene.name] = [] + + def get_bool(self) -> bool: + newlist: list[Material] = [] + for obj in bpy.context.scene.objects: + if len(obj.material_slots)>0: + for mat_slot in obj.material_slots: + if mat_slot.material: + if mat_slot.material not in newlist: + newlist.append(mat_slot.material) + + still_the_same: bool = True + if bpy.context.scene.name in MaterialListBool.old_list: + for item in newlist: + if item not in MaterialListBool.old_list[bpy.context.scene.name]: + still_the_same = False + break + for item in MaterialListBool.old_list[bpy.context.scene.name]: + if item not in newlist: + still_the_same = False + break + else: + still_the_same = False + MaterialListBool.bool_material_list_expand[bpy.context.scene.name] = still_the_same + + return MaterialListBool.bool_material_list_expand[bpy.context.scene.name] + class ProgressTracker: """Universal progress tracking for Avatar Toolkit operations"""