oml fix!
This commit is contained in:
989onan
2024-07-24 17:53:02 -04:00
parent bf108eb94a
commit ce1cc79664
3 changed files with 5 additions and 93 deletions
+3
View File
@@ -1,4 +1,6 @@
import bpy import bpy
from ..functions.translations import t, get_languages_list, update_language
from ..core.addon_preferences import get_preference
def register(): def register():
default_language = get_preference("language", 0) default_language = get_preference("language", 0)
@@ -12,6 +14,7 @@ def register():
) )
bpy.types.Scene.avatar_toolkit_language_changed = bpy.props.BoolProperty(default=False) bpy.types.Scene.avatar_toolkit_language_changed = bpy.props.BoolProperty(default=False)
def unregister(): def unregister():
if hasattr(bpy.types.Scene, "avatar_toolkit_language"): if hasattr(bpy.types.Scene, "avatar_toolkit_language"):
del bpy.types.Scene.avatar_toolkit_language del bpy.types.Scene.avatar_toolkit_language
+2 -1
View File
@@ -63,9 +63,10 @@ def load_translations() -> bool:
print(f"Loaded default translations: {dictionary}") # Debug print print(f"Loaded default translations: {dictionary}") # Debug print
else: else:
print("Default translation file 'en_US.json' not found.") print("Default translation file 'en_US.json' not found.")
return dictionary != old_dictionary return dictionary != old_dictionary
def t(phrase: str, *args, **kwargs) -> str: def t(phrase: str, default: str = None) -> str:
output: str = dictionary.get(phrase) output: str = dictionary.get(phrase)
if output is None: if output is None:
if verbose: if verbose:
-92
View File
@@ -1,92 +0,0 @@
from bpy.types import UIList, Panel, UILayout, Object, Context,Material, Operator
import bpy
from ..core.register import register_wrap
from .panel import AvatarToolkitPanel
from ..core.properties import SceneMatClass, material_list_bool
from ..functions.atlas_materials import Atlas_Materials
@register_wrap
class ExpandSection_Materials(Operator):
bl_idname = 'avatar_toolkit.expand_section_materials'
bl_label = ""
bl_description = ""
@classmethod
def poll(cls, context: Context) -> bool:
return True
def execute(self, context: Context) -> set:
if not context.scene.texture_atlas_Has_Mat_List_Shown:
context.scene.materials.clear()
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)
newitem: SceneMatClass = context.scene.materials.add()
newitem.mat = mat_slot.material
material_list_bool.old_list[context.scene.name] = newlist
else:
context.scene.texture_atlas_Has_Mat_List_Shown = False
return {'FINISHED'}
@register_wrap
class MaterialTextureAtlasProperties(UIList):
bl_label = "Texture Atlas Material List Material"
bl_idname = "Material_UL_avatar_toolkit_texture_atlas_mat_list_mat"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
def draw_item(self , context: Context, layout: UILayout, data: bpy.types.Object, item:SceneMatClass, icon, active_data, active_propname, index):
if context.scene.texture_atlas_Has_Mat_List_Shown:
box = layout.box()
row = box.row()
row.label(text=item.mat.name, icon = "MATERIAL")
col = box.row()
col.prop(item.mat, "texture_atlas_albedo")
col = box.row()
col.prop(item.mat, "texture_atlas_normal")
col = box.row()
col.prop(item.mat, "texture_atlas_emission")
col = box.row()
col.prop(item.mat, "texture_atlas_ambient_occlusion")
col = box.row()
col.prop(item.mat, "texture_atlas_height")
col = box.row()
col.prop(item.mat, "texture_atlas_roughness")
@register_wrap
class TextureAtlasPanel(Panel):
bl_label = "Texture Atlasing"
bl_idname = "OBJECT_PT_avatar_toolkit_texture_atlas"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = "Avatar Toolkit"
bl_parent_id = "OBJECT_PT_avatar_toolkit"
def draw(self, context: Context):
layout = self.layout
row = layout.row()
boxoutter = row.box()
direction_icon = 'RIGHTARROW' if not context.scene.texture_atlas_Has_Mat_List_Shown else 'DOWNARROW_HLT'
row = boxoutter.row()
row.operator(ExpandSection_Materials.bl_idname, text=("Reload Texture Atlas Material List" if not context.scene.texture_atlas_Has_Mat_List_Shown else "Loaded Texture Atlas Material List"), icon=direction_icon)
if context.scene.texture_atlas_Has_Mat_List_Shown:
#get_texture_node_list(bpy.context)
row = boxoutter.row()
row.template_list(MaterialTextureAtlasProperties.bl_idname, 'material_list', context.scene, 'materials',
context.scene, 'texture_atlas_material_index', rows=12, type='DEFAULT')
row = layout.row()
row.operator(Atlas_Materials.bl_idname, text="Atlas Materials!")