This fixes is to get everything working on the new auto load and properties system.
Also some other small fixes.
This commit is contained in:
Yusarina
2024-12-03 01:26:10 +00:00
parent fe8f5f69d5
commit 7e584e3648
10 changed files with 189 additions and 244 deletions
+8 -9
View File
@@ -161,15 +161,15 @@ def get_armatures(self, context: Context) -> List[Tuple[str, str, str]]:
return armatures
def get_armatures_that_are_not_selected(self, context: Context) -> List[Tuple[str, str, str]]:
armatures = [(obj.name, obj.name, "") for obj in bpy.data.objects if ((obj.type == 'ARMATURE') and (obj.name != context.scene.selected_armature))]
armatures = [(obj.name, obj.name, "") for obj in bpy.data.objects if ((obj.type == 'ARMATURE') and (obj.name != context.scene.avatar_toolkit.selected_armature))]
if not armatures:
return [('NONE', 'No Other Armature', '')]
return armatures
def get_selected_armature(context: Context) -> Optional[Object]:
try:
if hasattr(context.scene, 'selected_armature'):
armature_name = context.scene.selected_armature
if hasattr(context.scene, 'avatar_toolkit'):
armature_name = context.scene.avatar_toolkit.selected_armature
if isinstance(armature_name, bytes):
try:
armature_name = armature_name.decode('utf-8')
@@ -209,9 +209,8 @@ def get_merge_armature_source(context: Context) -> Optional[Object]:
pass
return None
def set_selected_armature(context: Context, armature: Optional[Object]) -> None:
context.scene.selected_armature = armature.name if armature else ""
context.scene.avatar_toolkit.selected_armature = armature.name if armature else ""
def is_valid_armature(armature: Object) -> bool:
if not armature or armature.type != 'ARMATURE':
@@ -451,12 +450,12 @@ def remove_default_objects():
def init_progress(context, steps):
context.window_manager.progress_begin(0, 100)
context.scene.avatar_toolkit_progress_steps = steps
context.scene.avatar_toolkit_progress_current = 0
context.scene.avatar_toolkit.progress_steps = steps
context.scene.avatar_toolkit.progress_current = 0
def update_progress(self, context, message):
context.scene.avatar_toolkit_progress_current += 1
progress = (context.scene.avatar_toolkit_progress_current / context.scene.avatar_toolkit_progress_steps) * 100
context.scene.avatar_toolkit.progress_current += 1
progress = (context.scene.avatar_toolkit.progress_current / context.scene.avatar_toolkit.progress_steps) * 100
context.window_manager.progress_update(progress)
context.area.header_text_set(message)
self.report({'INFO'}, message)
+13 -4
View File
@@ -99,6 +99,13 @@ class AvatarToolkitSceneProperties(PropertyGroup):
set=MaterialListBool.set_bool
)
avatar_toolkit_updater_version_list: EnumProperty(
items=get_version_list,
name="Version List",
description="List of available versions"
)
class AvatarToolkitMaterialProperties(PropertyGroup):
material_expanded: BoolProperty(
name="Expand Material",
@@ -113,11 +120,13 @@ class AvatarToolkitMaterialProperties(PropertyGroup):
)
def get_texture_node_list(self, context):
if self.use_nodes:
# Access the material through the property group's id_data
material = self.id_data
if material and material.use_nodes:
nodes = [(i.image.name if i.image else i.name+"_image",
i.image.name if i.image else "node with no image...",
i.image.name if i.image else i.name, index+1)
for index, i in enumerate(self.node_tree.nodes)
i.image.name if i.image else "node with no image...",
i.image.name if i.image else i.name, index+1)
for index, i in enumerate(material.node_tree.nodes)
if i.bl_idname == "ShaderNodeTexImage"]
if not nodes:
nodes = [("Error", "No images found", "Error", 0)]
+3 -3
View File
@@ -84,11 +84,11 @@ def get_languages_list(self, context) -> List[Tuple[str, str, str]]:
return [(str(i), get_language_display_name(lang), f"Use {lang} language") for i, lang in enumerate(languages)]
def update_language(self, context):
print(f"Updating language to: {self.avatar_toolkit_language}") # Debug print
save_preference("language", int(self.avatar_toolkit_language))
print(f"Updating language to: {self.language}") # Debug print
save_preference("language", int(self.language))
load_translations()
# Set a flag to indicate that a language change has occurred
context.scene.avatar_toolkit_language_changed = True
context.scene.avatar_toolkit.language_changed = True
# Show popup after language change
bpy.ops.avatar_toolkit.translation_restart_popup('INVOKE_DEFAULT')
+1 -1
View File
@@ -287,7 +287,7 @@ def draw_updater_panel(context: bpy.types.Context, layout: bpy.types.UILayout) -
col.separator()
row = col.row(align=True)
row.prop(context.scene, 'avatar_toolkit_updater_version_list', text='')
row.prop(context.scene.avatar_toolkit, 'avatar_toolkit_updater_version_list', text='')
row.operator(AvatarToolkit_OT_UpdateToLatest.bl_idname, text=t('Updater.UpdateToSelectedButton.label'))
col.separator()