@@ -3,7 +3,7 @@
|
||||
schema_version = "1.0.0"
|
||||
|
||||
id = "avatar_toolkit"
|
||||
version = "0.2.0"
|
||||
version = "0.2.1"
|
||||
name = "Avatar Toolkit"
|
||||
tagline = "A modern tool for importing and optimizing models for VRChat, Resonite, and other similar games."
|
||||
maintainer = "Team NekoNeo"
|
||||
|
||||
@@ -6,9 +6,14 @@ from ..core.logging_setup import logger
|
||||
from bpy.types import AddonPreferences
|
||||
from typing import Any, Dict
|
||||
|
||||
# Get the directory of the current file
|
||||
PREFERENCES_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
PREFERENCES_FILE = os.path.join(PREFERENCES_DIR, "preferences.json")
|
||||
# Get the user preferences directory instead of addon directory
|
||||
def get_preferences_path():
|
||||
user_path = bpy.utils.resource_path('USER')
|
||||
addon_prefs_dir = os.path.join(user_path, "config", "avatar_toolkit_prefs")
|
||||
os.makedirs(addon_prefs_dir, exist_ok=True)
|
||||
return os.path.join(addon_prefs_dir, "preferences.json")
|
||||
|
||||
PREFERENCES_FILE = get_preferences_path()
|
||||
|
||||
def get_current_version():
|
||||
main_dir = os.path.dirname(os.path.dirname(__file__))
|
||||
|
||||
@@ -113,7 +113,6 @@ def validate_armature(armature: Object, detailed_messages: bool = False) -> Unio
|
||||
non_standard_bones.append(bone_name)
|
||||
|
||||
if non_standard_bones:
|
||||
logger.warning(f"Found {len(non_standard_bones)} non-standard bones")
|
||||
non_standard_list = "\n".join([f"- {bone}" for bone in non_standard_bones])
|
||||
non_standard_messages.append(t("Armature.validation.non_standard_bones", bones=non_standard_list))
|
||||
|
||||
|
||||
+2
-50
@@ -592,46 +592,7 @@ def register() -> None:
|
||||
"""Register the Avatar Toolkit property group"""
|
||||
logger.info("Registering Avatar Toolkit properties")
|
||||
|
||||
# Clear any existing registrations to prevent conflicts
|
||||
if hasattr(bpy.types.Scene, "avatar_toolkit"):
|
||||
try:
|
||||
del bpy.types.Scene.avatar_toolkit
|
||||
except:
|
||||
logger.warning("Failed to remove existing avatar_toolkit property")
|
||||
|
||||
# Register classes
|
||||
try:
|
||||
# Try to register all classes at once
|
||||
bpy.utils.register_class(ZeroWeightBoneItem)
|
||||
bpy.utils.register_class(ValidationMessageItem)
|
||||
bpy.utils.register_class(AvatarToolkitSceneProperties)
|
||||
except ValueError as e:
|
||||
logger.warning(f"Class registration issue: {e}")
|
||||
# Try to unregister first in case they're already registered
|
||||
try:
|
||||
# Try to unregister in reverse order
|
||||
try:
|
||||
bpy.utils.unregister_class(AvatarToolkitSceneProperties)
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
bpy.utils.unregister_class(ValidationMessageItem)
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
bpy.utils.unregister_class(ZeroWeightBoneItem)
|
||||
except:
|
||||
pass
|
||||
|
||||
# Then register again
|
||||
bpy.utils.register_class(ZeroWeightBoneItem)
|
||||
bpy.utils.register_class(ValidationMessageItem)
|
||||
bpy.utils.register_class(AvatarToolkitSceneProperties)
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to recover from registration error: {e}")
|
||||
raise
|
||||
|
||||
# Register the property
|
||||
# Only register the property, not the classes (auto_load will handle that)
|
||||
bpy.types.Scene.avatar_toolkit = PointerProperty(type=AvatarToolkitSceneProperties)
|
||||
logger.debug("Properties registered successfully")
|
||||
|
||||
@@ -640,20 +601,11 @@ def unregister() -> None:
|
||||
"""Unregister the Avatar Toolkit property group"""
|
||||
logger.info("Unregistering Avatar Toolkit properties")
|
||||
|
||||
# Remove the property first
|
||||
# Remove the property
|
||||
if hasattr(bpy.types.Scene, "avatar_toolkit"):
|
||||
try:
|
||||
del bpy.types.Scene.avatar_toolkit
|
||||
logger.debug("Removed avatar_toolkit property")
|
||||
except Exception as e:
|
||||
logger.warning(f"Failed to remove avatar_toolkit property: {e}")
|
||||
|
||||
# Then unregister the classes
|
||||
try:
|
||||
bpy.utils.unregister_class(AvatarToolkitSceneProperties)
|
||||
bpy.utils.unregister_class(ValidationMessageItem)
|
||||
bpy.utils.unregister_class(ZeroWeightBoneItem)
|
||||
logger.debug("Unregistered property classes")
|
||||
except (RuntimeError, ValueError) as e:
|
||||
logger.warning(f"Error during property class unregistration: {e}")
|
||||
# Not fatal - continue
|
||||
|
||||
@@ -280,6 +280,17 @@ class AvatarToolKit_OT_AtlasMaterials(Operator):
|
||||
mesh.materials[i] = atlased_mat.material
|
||||
progress.step(f"Updated materials for {obj.name}")
|
||||
|
||||
MaterialListBool.old_list.pop(context.scene.name, None)
|
||||
was_open = context.scene.avatar_toolkit.texture_atlas_Has_Mat_List_Shown
|
||||
context.scene.avatar_toolkit.texture_atlas_Has_Mat_List_Shown = False
|
||||
|
||||
if was_open:
|
||||
bpy.ops.avatar_toolkit.expand_section_materials()
|
||||
|
||||
for area in context.screen.areas:
|
||||
if area.type == 'VIEW_3D':
|
||||
area.tag_redraw()
|
||||
|
||||
logger.info("Material atlas creation completed successfully")
|
||||
self.report({'INFO'}, t("TextureAtlas.atlas_completed"))
|
||||
return {"FINISHED"}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"authors": ["Avatar Toolkit Team"],
|
||||
"messages": {
|
||||
"AvatarToolkit.label": "Avatar Toolkit (Alpha 0.2.0)",
|
||||
"AvatarToolkit.label": "Avatar Toolkit (Alpha 0.2.1)",
|
||||
"AvatarToolkit.desc1": "Avatar Toolkit is in Early Access there",
|
||||
"AvatarToolkit.desc2": "will be issues, if you find any issues,",
|
||||
"AvatarToolkit.desc3": "please report it on our Github.",
|
||||
@@ -472,6 +472,23 @@
|
||||
"TextureAtlas.ambient_occlusion": "Ambient Occlusion",
|
||||
"TextureAtlas.height": "Height",
|
||||
"TextureAtlas.roughness": "Roughness",
|
||||
"TextureAtlas.description_1": "Create a single material with combined textures",
|
||||
"TextureAtlas.description_2": "to optimize your avatar for better performance.",
|
||||
"TextureAtlas.texture_maps": "Texture Maps",
|
||||
"TextureAtlas.material_ready": "Material is ready for atlas",
|
||||
"TextureAtlas.material_not_ready": "Material needs at least one texture",
|
||||
"TextureAtlas.select_all_tooltip": "Select all materials for atlas",
|
||||
"TextureAtlas.select_none_tooltip": "Deselect all materials",
|
||||
"TextureAtlas.expand_all_tooltip": "Expand all material settings",
|
||||
"TextureAtlas.collapse_all_tooltip": "Collapse all material settings",
|
||||
"TextureAtlas.estimated_size": "Estimated Atlas Size",
|
||||
"TextureAtlas.materials": "materials",
|
||||
"TextureAtlas.no_materials_selected": "No materials selected",
|
||||
"TextureAtlas.select_armature_first": "Please select an armature first",
|
||||
"TextureAtlas.how_to_use_1": "1. Select an armature in the scene",
|
||||
"TextureAtlas.how_to_use_2": "2. Click 'Load Materials' to begin",
|
||||
"TextureAtlas.load_error": "Error loading materials. Check console for details.",
|
||||
"TextureAtlas.material_not_included": "Material is not included in atlas",
|
||||
|
||||
"Settings.label": "Settings",
|
||||
"Settings.language": "Language",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"authors": ["Avatar Toolkit Team"],
|
||||
"messages": {
|
||||
"AvatarToolkit.label": "アバターツールキット (アルファ 0.2.0)",
|
||||
"AvatarToolkit.label": "アバターツールキット (アルファ 0.2.1)",
|
||||
"AvatarToolkit.desc1": "アバターツールキットは早期アクセス中であり、",
|
||||
"AvatarToolkit.desc2": "問題が発生する可能性があります。問題を見つけた場合は、",
|
||||
"AvatarToolkit.desc3": "GitHubで報告してください。",
|
||||
@@ -472,6 +472,23 @@
|
||||
"TextureAtlas.ambient_occlusion": "アンビエントオクルージョン",
|
||||
"TextureAtlas.height": "高さ",
|
||||
"TextureAtlas.roughness": "粗さ",
|
||||
"TextureAtlas.description_1": "テクスチャを組み合わせた単一のマテリアルを作成",
|
||||
"TextureAtlas.description_2": "アバターのパフォーマンスを最適化します。",
|
||||
"TextureAtlas.texture_maps": "テクスチャマップ",
|
||||
"TextureAtlas.material_ready": "マテリアルはアトラス作成の準備ができています",
|
||||
"TextureAtlas.material_not_ready": "マテリアルには少なくとも1つのテクスチャが必要です",
|
||||
"TextureAtlas.select_all_tooltip": "すべてのマテリアルを選択",
|
||||
"TextureAtlas.select_none_tooltip": "すべての選択を解除",
|
||||
"TextureAtlas.expand_all_tooltip": "すべてのマテリアル設定を展開",
|
||||
"TextureAtlas.collapse_all_tooltip": "すべてのマテリアル設定を折りたたむ",
|
||||
"TextureAtlas.estimated_size": "推定アトラスサイズ",
|
||||
"TextureAtlas.materials": "マテリアル",
|
||||
"TextureAtlas.no_materials_selected": "マテリアルが選択されていません",
|
||||
"TextureAtlas.select_armature_first": "最初にアーマチュアを選択してください",
|
||||
"TextureAtlas.how_to_use_1": "1. シーン内のアーマチュアを選択",
|
||||
"TextureAtlas.how_to_use_2": "2. 「マテリアルを読み込む」をクリックして開始",
|
||||
"TextureAtlas.load_error": "マテリアルの読み込みエラー。詳細はコンソールを確認してください。",
|
||||
"TextureAtlas.material_not_included": "マテリアルはアトラスに含まれていません",
|
||||
|
||||
"Settings.label": "設定",
|
||||
"Settings.language": "言語",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"authors": ["Avatar Toolkit Team"],
|
||||
"messages": {
|
||||
"AvatarToolkit.label": "아바타 툴킷 (알파 0.2.0)",
|
||||
"AvatarToolkit.label": "아바타 툴킷 (알파 0.2.1)",
|
||||
"AvatarToolkit.desc1": "아바타 툴킷은 초기 액세스 단계에 있으므로",
|
||||
"AvatarToolkit.desc2": "문제가 있을 수 있습니다. 문제를 발견하시면",
|
||||
"AvatarToolkit.desc3": "Github에 보고해 주세요.",
|
||||
@@ -472,6 +472,23 @@
|
||||
"TextureAtlas.ambient_occlusion": "앰비언트 오클루전",
|
||||
"TextureAtlas.height": "높이",
|
||||
"TextureAtlas.roughness": "거칠기",
|
||||
"TextureAtlas.description_1": "텍스처를 결합한 단일 재질 생성",
|
||||
"TextureAtlas.description_2": "아바타의 성능을 최적화합니다.",
|
||||
"TextureAtlas.texture_maps": "텍스처 맵",
|
||||
"TextureAtlas.material_ready": "재질이 아틀라스 생성 준비가 되었습니다",
|
||||
"TextureAtlas.material_not_ready": "재질에는 최소 하나의 텍스처가 필요합니다",
|
||||
"TextureAtlas.select_all_tooltip": "모든 재질 선택",
|
||||
"TextureAtlas.select_none_tooltip": "모든 선택 해제",
|
||||
"TextureAtlas.expand_all_tooltip": "모든 재질 설정 펼치기",
|
||||
"TextureAtlas.collapse_all_tooltip": "모든 재질 설정 접기",
|
||||
"TextureAtlas.estimated_size": "예상 아틀라스 크기",
|
||||
"TextureAtlas.materials": "재질",
|
||||
"TextureAtlas.no_materials_selected": "선택된 재질이 없습니다",
|
||||
"TextureAtlas.select_armature_first": "먼저 아마추어를 선택해주세요",
|
||||
"TextureAtlas.how_to_use_1": "1. 장면에서 아마추어 선택",
|
||||
"TextureAtlas.how_to_use_2": "2. '재질 불러오기'를 클릭하여 시작",
|
||||
"TextureAtlas.load_error": "재질 로딩 오류. 자세한 내용은 콘솔을 확인하세요.",
|
||||
"TextureAtlas.material_not_included": "재질이 아틀라스에 포함되지 않았습니다",
|
||||
|
||||
"Settings.label": "설정",
|
||||
"Settings.language": "언어",
|
||||
|
||||
+122
-27
@@ -5,6 +5,7 @@ from .main_panel import AvatarToolKit_PT_AvatarToolkitPanel, CATEGORY_NAME
|
||||
from ..core.common import SceneMatClass, MaterialListBool, get_active_armature
|
||||
from ..functions.atlas_materials import AvatarToolKit_OT_AtlasMaterials
|
||||
from ..core.translations import t
|
||||
from ..core.logging_setup import logger
|
||||
|
||||
class AvatarToolKit_OT_SelectAllMaterials(Operator):
|
||||
bl_idname = 'avatar_toolkit.select_all_materials'
|
||||
@@ -56,9 +57,12 @@ class AvatarToolKit_OT_ExpandSectionMaterials(Operator):
|
||||
return True
|
||||
|
||||
def execute(self, context: Context) -> set:
|
||||
try:
|
||||
if not context.scene.avatar_toolkit.texture_atlas_Has_Mat_List_Shown:
|
||||
context.scene.avatar_toolkit.materials.clear()
|
||||
newlist: list[Material] = []
|
||||
|
||||
logger.debug("Loading materials for texture atlas")
|
||||
for obj in context.scene.objects:
|
||||
if len(obj.material_slots) > 0:
|
||||
for mat_slot in obj.material_slots:
|
||||
@@ -67,11 +71,19 @@ class AvatarToolKit_OT_ExpandSectionMaterials(Operator):
|
||||
newlist.append(mat_slot.material)
|
||||
newitem: SceneMatClass = context.scene.avatar_toolkit.materials.add()
|
||||
newitem.mat = mat_slot.material
|
||||
|
||||
MaterialListBool.old_list[context.scene.name] = newlist
|
||||
context.scene.avatar_toolkit.texture_atlas_Has_Mat_List_Shown = True
|
||||
logger.info(f"Loaded {len(newlist)} materials for texture atlas")
|
||||
else:
|
||||
context.scene.avatar_toolkit.texture_atlas_Has_Mat_List_Shown = False
|
||||
logger.debug("Hiding material list")
|
||||
|
||||
return {'FINISHED'}
|
||||
except Exception as e:
|
||||
logger.error(f"Error loading materials: {str(e)}", exc_info=True)
|
||||
self.report({'ERROR'}, t("TextureAtlas.load_error"))
|
||||
return {'CANCELLED'}
|
||||
|
||||
class AvatarToolKit_UL_MaterialTextureAtlasProperties(UIList):
|
||||
bl_label = t("TextureAtlas.material_list_label")
|
||||
@@ -81,17 +93,30 @@ class AvatarToolKit_UL_MaterialTextureAtlasProperties(UIList):
|
||||
|
||||
def draw_header(self, context):
|
||||
layout = self.layout
|
||||
row = layout.row(align=True)
|
||||
|
||||
row.operator("avatar_toolkit.select_all_materials", text="", icon='CHECKBOX_HLT')
|
||||
row.operator("avatar_toolkit.select_none_materials", text="", icon='CHECKBOX_DEHLT')
|
||||
row.operator("avatar_toolkit.expand_all_materials", text="", icon='DISCLOSURE_TRI_DOWN')
|
||||
row.operator("avatar_toolkit.collapse_all_materials", text="", icon='DISCLOSURE_TRI_RIGHT')
|
||||
row.prop(context.scene.avatar_toolkit, "material_search_filter", text="", icon='VIEWZOOM')
|
||||
row = layout.row(align=True)
|
||||
row.scale_y = 1.2
|
||||
|
||||
row.operator("avatar_toolkit.select_all_materials", text="", icon='CHECKBOX_HLT',
|
||||
emboss=True).tooltip = t("TextureAtlas.select_all_tooltip")
|
||||
row.operator("avatar_toolkit.select_none_materials", text="", icon='CHECKBOX_DEHLT',
|
||||
emboss=True).tooltip = t("TextureAtlas.select_none_tooltip")
|
||||
row.separator(factor=0.5)
|
||||
row.operator("avatar_toolkit.expand_all_materials", text="", icon='DISCLOSURE_TRI_DOWN',
|
||||
emboss=True).tooltip = t("TextureAtlas.expand_all_tooltip")
|
||||
row.operator("avatar_toolkit.collapse_all_materials", text="", icon='DISCLOSURE_TRI_RIGHT',
|
||||
emboss=True).tooltip = t("TextureAtlas.collapse_all_tooltip")
|
||||
|
||||
row.separator(factor=1.0)
|
||||
search_row = row.row()
|
||||
search_row.scale_x = 2.0
|
||||
search_row.prop(context.scene.avatar_toolkit, "material_search_filter", text="", icon='VIEWZOOM')
|
||||
|
||||
box = layout.box()
|
||||
row = box.row()
|
||||
row.label(text=f"Estimated Atlas Size: {self.calculate_atlas_size(context)}px")
|
||||
size_row = box.row()
|
||||
size_row.alignment = 'CENTER'
|
||||
size_text = self.calculate_atlas_size(context)
|
||||
size_row.label(text=f"{t('TextureAtlas.estimated_size')}: {size_text}px", icon='TEXTURE')
|
||||
|
||||
def draw_item(self, context: Context, layout: UILayout, data: Object, item: SceneMatClass, icon, active_data, active_propname, index):
|
||||
if context.scene.avatar_toolkit.texture_atlas_Has_Mat_List_Shown:
|
||||
@@ -99,34 +124,64 @@ class AvatarToolKit_UL_MaterialTextureAtlasProperties(UIList):
|
||||
context.scene.avatar_toolkit.material_search_filter.lower() not in item.mat.name.lower()):
|
||||
return
|
||||
|
||||
# Main material
|
||||
row = layout.row()
|
||||
row.prop(item.mat, "include_in_atlas", text="",
|
||||
icon='CHECKBOX_HLT' if item.mat.include_in_atlas else 'CHECKBOX_DEHLT',
|
||||
emboss=False)
|
||||
|
||||
row.prop(item.mat, "include_in_atlas", text="", icon='CHECKBOX_HLT' if item.mat.include_in_atlas else 'CHECKBOX_DEHLT')
|
||||
|
||||
# Material name
|
||||
row.prop(item.mat, "material_expanded",
|
||||
text=item.mat.name,
|
||||
icon='DOWNARROW_HLT' if item.mat.material_expanded else 'RIGHTARROW',
|
||||
emboss=False)
|
||||
|
||||
if item.mat.material_expanded and item.mat.include_in_atlas:
|
||||
row.label(text="", icon='MATERIAL')
|
||||
|
||||
if item.mat.material_expanded:
|
||||
box = layout.box()
|
||||
col = box.column(align=True)
|
||||
self.draw_texture_row(col, item.mat, "texture_atlas_albedo", "IMAGE_RGB")
|
||||
self.draw_texture_row(col, item.mat, "texture_atlas_normal", "NORMALS_FACE")
|
||||
self.draw_texture_row(col, item.mat, "texture_atlas_emission", "LIGHT")
|
||||
self.draw_texture_row(col, item.mat, "texture_atlas_ambient_occlusion", "SHADING_SOLID")
|
||||
self.draw_texture_row(col, item.mat, "texture_atlas_height", "IMAGE_ZDEPTH")
|
||||
self.draw_texture_row(col, item.mat, "texture_atlas_roughness", "MATERIAL")
|
||||
|
||||
header_row = col.row()
|
||||
header_row.alignment = 'CENTER'
|
||||
header_row.label(text=t("TextureAtlas.texture_maps"), icon='IMAGE')
|
||||
col.separator(factor=0.5)
|
||||
self.draw_texture_row(col, item.mat, "texture_atlas_albedo", "IMAGE_RGB", t("TextureAtlas.albedo"))
|
||||
self.draw_texture_row(col, item.mat, "texture_atlas_normal", "NORMALS_FACE", t("TextureAtlas.normal"))
|
||||
self.draw_texture_row(col, item.mat, "texture_atlas_emission", "LIGHT", t("TextureAtlas.emission"))
|
||||
self.draw_texture_row(col, item.mat, "texture_atlas_ambient_occlusion", "SHADING_SOLID", t("TextureAtlas.ambient_occlusion"))
|
||||
self.draw_texture_row(col, item.mat, "texture_atlas_height", "IMAGE_ZDEPTH", t("TextureAtlas.height"))
|
||||
self.draw_texture_row(col, item.mat, "texture_atlas_roughness", "MATERIAL", t("TextureAtlas.roughness"))
|
||||
|
||||
col.separator(factor=0.5)
|
||||
|
||||
def draw_texture_row(self, layout, material, prop_name, icon):
|
||||
row = layout.row()
|
||||
row.prop(material, prop_name, icon=icon)
|
||||
if getattr(material, prop_name):
|
||||
row.label(text="", icon='CHECKMARK')
|
||||
status_row = col.row()
|
||||
status_row.alignment = 'CENTER'
|
||||
is_ready = self.is_material_ready(item.mat)
|
||||
|
||||
if item.mat.include_in_atlas:
|
||||
status_text = t("TextureAtlas.material_ready") if is_ready else t("TextureAtlas.material_not_ready")
|
||||
status_icon = 'CHECKMARK' if is_ready else 'ERROR'
|
||||
else:
|
||||
row.label(text="", icon='X')
|
||||
status_text = t("TextureAtlas.material_not_included")
|
||||
status_icon = 'INFO'
|
||||
|
||||
status_row.label(text=status_text, icon=status_icon)
|
||||
|
||||
def draw_texture_row(self, layout, material, prop_name, icon, label_text):
|
||||
row = layout.row(align=True)
|
||||
icon_row = row.row()
|
||||
icon_row.scale_x = 0.5
|
||||
icon_row.label(text="", icon=icon)
|
||||
|
||||
# Texture selector
|
||||
row.prop(material, prop_name, text=label_text)
|
||||
status_row = row.row()
|
||||
status_row.scale_x = 0.5
|
||||
if getattr(material, prop_name):
|
||||
status_row.label(text="", icon='CHECKMARK')
|
||||
else:
|
||||
status_row.label(text="", icon='X')
|
||||
|
||||
def is_material_ready(self, material):
|
||||
return bool(material.texture_atlas_albedo or
|
||||
@@ -135,12 +190,21 @@ class AvatarToolKit_UL_MaterialTextureAtlasProperties(UIList):
|
||||
|
||||
def calculate_atlas_size(self, context):
|
||||
total_size = 0
|
||||
selected_count = 0
|
||||
|
||||
for mat in context.scene.avatar_toolkit.materials:
|
||||
if mat.mat.include_in_atlas:
|
||||
selected_count += 1
|
||||
if mat.mat.texture_atlas_albedo:
|
||||
img = bpy.data.images[mat.mat.texture_atlas_albedo]
|
||||
total_size += img.size[0] * img.size[1]
|
||||
return f"{int(sqrt(total_size))}x{int(sqrt(total_size))}"
|
||||
|
||||
if total_size == 0:
|
||||
return f"0x0 ({t('TextureAtlas.no_materials_selected')})"
|
||||
size = int(sqrt(total_size))
|
||||
pot_size = 2 ** (size - 1).bit_length() # Next power of 2
|
||||
|
||||
return f"{pot_size}x{pot_size} ({selected_count} {t('TextureAtlas.materials')})"
|
||||
|
||||
class AvatarToolKit_PT_TextureAtlasPanel(Panel):
|
||||
bl_label = t("TextureAtlas.label")
|
||||
@@ -156,16 +220,26 @@ class AvatarToolKit_PT_TextureAtlasPanel(Panel):
|
||||
armature = get_active_armature(context)
|
||||
|
||||
if armature:
|
||||
layout.label(text=t("TextureAtlas.label"), icon='TEXTURE')
|
||||
header_row = layout.row()
|
||||
header_row.label(text=t("TextureAtlas.label"), icon='TEXTURE')
|
||||
layout.separator(factor=0.5)
|
||||
info_box = layout.box()
|
||||
info_col = info_box.column()
|
||||
info_col.scale_y = 0.9
|
||||
info_col.label(text=t("TextureAtlas.description_1"), icon='INFO')
|
||||
info_col.label(text=t("TextureAtlas.description_2"))
|
||||
|
||||
layout.separator(factor=0.5)
|
||||
box = layout.box()
|
||||
row = box.row()
|
||||
row = box.row(align=True)
|
||||
row.scale_y = 1.2
|
||||
direction_icon = 'RIGHTARROW' if not context.scene.avatar_toolkit.texture_atlas_Has_Mat_List_Shown else 'DOWNARROW_HLT'
|
||||
button_text = t("TextureAtlas.reload_list") if not context.scene.avatar_toolkit.texture_atlas_Has_Mat_List_Shown else t("TextureAtlas.loaded_list")
|
||||
row.operator(AvatarToolKit_OT_ExpandSectionMaterials.bl_idname,
|
||||
text=(t("TextureAtlas.reload_list") if not context.scene.avatar_toolkit.texture_atlas_Has_Mat_List_Shown else t("TextureAtlas.loaded_list")),
|
||||
text=button_text,
|
||||
icon=direction_icon)
|
||||
|
||||
# Material list expanded
|
||||
if context.scene.avatar_toolkit.texture_atlas_Has_Mat_List_Shown:
|
||||
row = box.row()
|
||||
row.template_list(AvatarToolKit_UL_MaterialTextureAtlasProperties.bl_idname,
|
||||
@@ -181,8 +255,29 @@ class AvatarToolKit_PT_TextureAtlasPanel(Panel):
|
||||
|
||||
row = layout.row()
|
||||
row.scale_y = 1.5
|
||||
row.enabled = context.scene.avatar_toolkit.texture_atlas_Has_Mat_List_Shown
|
||||
|
||||
has_selected = False
|
||||
if context.scene.avatar_toolkit.texture_atlas_Has_Mat_List_Shown:
|
||||
for item in context.scene.avatar_toolkit.materials:
|
||||
if item.mat.include_in_atlas:
|
||||
has_selected = True
|
||||
break
|
||||
|
||||
if not has_selected and context.scene.avatar_toolkit.texture_atlas_Has_Mat_List_Shown:
|
||||
row.operator(AvatarToolKit_OT_AtlasMaterials.bl_idname,
|
||||
text=t("TextureAtlas.no_materials_selected"),
|
||||
icon='ERROR')
|
||||
else:
|
||||
row.operator(AvatarToolKit_OT_AtlasMaterials.bl_idname,
|
||||
text=t("TextureAtlas.atlas_materials"),
|
||||
icon='NODE_TEXTURE')
|
||||
else:
|
||||
layout.label(text=t("Tools.select_armature"), icon='ERROR')
|
||||
|
||||
box = layout.box()
|
||||
col = box.column()
|
||||
col.scale_y = 0.9
|
||||
col.label(text=t("TextureAtlas.select_armature_first"), icon='INFO')
|
||||
col.label(text=t("TextureAtlas.how_to_use_1"))
|
||||
col.label(text=t("TextureAtlas.how_to_use_2"))
|
||||
|
||||
Reference in New Issue
Block a user