Texture Atlas should require the user to save the blender files before we allow them to atlas
This commit is contained in:
@@ -137,6 +137,10 @@ class AvatarToolKit_OT_AtlasMaterials(Operator):
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context: Context) -> bool:
|
||||
# Only allow operation if the file is saved and materials are selected.
|
||||
if not bpy.data.filepath:
|
||||
cls.poll_message_set(t("TextureAtlas.save_file_first"))
|
||||
return False
|
||||
return context.scene.avatar_toolkit.texture_atlas_Has_Mat_List_Shown
|
||||
|
||||
def execute(self, context: Context) -> set:
|
||||
@@ -208,8 +212,14 @@ class AvatarToolKit_OT_AtlasMaterials(Operator):
|
||||
image_pixels[int(((k*w)+i)*4)+channel]
|
||||
|
||||
canvas.pixels[:] = canvas_pixels[:]
|
||||
canvas.save(filepath=os.path.join(os.path.dirname(bpy.data.filepath),
|
||||
new_image_name+".png"))
|
||||
|
||||
try:
|
||||
save_dir = os.path.dirname(bpy.data.filepath)
|
||||
canvas.save(filepath=os.path.join(save_dir, new_image_name+".png"))
|
||||
except Exception as save_error:
|
||||
logger.error(f"Failed to save atlas texture: {str(save_error)}")
|
||||
self.report({'WARNING'}, f"Could not save texture to disk. Atlas will work in memory only.")
|
||||
|
||||
setattr(atlased_mat, type_name, canvas)
|
||||
progress.step(f"Created {type_name} atlas")
|
||||
|
||||
|
||||
@@ -489,6 +489,10 @@
|
||||
"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",
|
||||
"TextureAtlas.save_file_first": "Please save your Blender file before creating a texture atlas",
|
||||
"TextureAtlas.save_file_instructions": "Use File > Save As... or click the button below:",
|
||||
"TextureAtlas.save_file_button": "Save Blender File",
|
||||
"TextureAtlas.save_file_required": "Save File Required",
|
||||
|
||||
"Settings.label": "Settings",
|
||||
"Settings.language": "Language",
|
||||
|
||||
@@ -489,6 +489,10 @@
|
||||
"TextureAtlas.how_to_use_2": "2. 「マテリアルを読み込む」をクリックして開始",
|
||||
"TextureAtlas.load_error": "マテリアルの読み込みエラー。詳細はコンソールを確認してください。",
|
||||
"TextureAtlas.material_not_included": "マテリアルはアトラスに含まれていません",
|
||||
"TextureAtlas.save_file_first": "テクスチャアトラスを作成する前に、Blenderファイルを保存してください",
|
||||
"TextureAtlas.save_file_instructions": "ファイル > 名前を付けて保存... を使用するか、下のボタンをクリックしてください:",
|
||||
"TextureAtlas.save_file_button": "Blenderファイルを保存",
|
||||
"TextureAtlas.save_file_required": "ファイルの保存が必要です",
|
||||
|
||||
"Settings.label": "設定",
|
||||
"Settings.language": "言語",
|
||||
|
||||
@@ -489,6 +489,10 @@
|
||||
"TextureAtlas.how_to_use_2": "2. '재질 불러오기'를 클릭하여 시작",
|
||||
"TextureAtlas.load_error": "재질 로딩 오류. 자세한 내용은 콘솔을 확인하세요.",
|
||||
"TextureAtlas.material_not_included": "재질이 아틀라스에 포함되지 않았습니다",
|
||||
"TextureAtlas.save_file_first": "텍스처 아틀라스를 만들기 전에 Blender 파일을 저장하세요",
|
||||
"TextureAtlas.save_file_instructions": "파일 > 다른 이름으로 저장... 을 사용하거나 아래 버튼을 클릭하세요:",
|
||||
"TextureAtlas.save_file_button": "Blender 파일 저장",
|
||||
"TextureAtlas.save_file_required": "파일 저장 필요",
|
||||
|
||||
"Settings.label": "설정",
|
||||
"Settings.language": "언어",
|
||||
|
||||
@@ -229,6 +229,16 @@ class AvatarToolKit_PT_TextureAtlasPanel(Panel):
|
||||
info_col.label(text=t("TextureAtlas.description_1"), icon='INFO')
|
||||
info_col.label(text=t("TextureAtlas.description_2"))
|
||||
|
||||
if not bpy.data.filepath:
|
||||
warning_box = layout.box()
|
||||
warning_col = warning_box.column()
|
||||
warning_col.scale_y = 0.9
|
||||
warning_col.alert = True
|
||||
warning_col.label(text=t("TextureAtlas.save_file_first"), icon='ERROR')
|
||||
warning_col.label(text=t("TextureAtlas.save_file_instructions"))
|
||||
warning_col.operator("wm.save_as_mainfile", text=t("TextureAtlas.save_file_button"), icon='FILE_TICK')
|
||||
layout.separator(factor=0.5)
|
||||
|
||||
layout.separator(factor=0.5)
|
||||
box = layout.box()
|
||||
row = box.row(align=True)
|
||||
|
||||
Reference in New Issue
Block a user