From b722315c8d17d5605b075c671b9b93c32ad117f3 Mon Sep 17 00:00:00 2001 From: Lila <87947656+Lilaa3@users.noreply.github.com> Date: Tue, 23 Apr 2024 20:56:01 +0100 Subject: [PATCH] fix --- fast64_internal/sm64/animation/panels.py | 14 +----- fast64_internal/sm64/animation/properties.py | 46 ++++++++++++-------- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/fast64_internal/sm64/animation/panels.py b/fast64_internal/sm64/animation/panels.py index f914cc545..6a9c616bc 100644 --- a/fast64_internal/sm64/animation/panels.py +++ b/fast64_internal/sm64/animation/panels.py @@ -1,11 +1,7 @@ from bpy.utils import register_class, unregister_class -from bpy.path import abspath from bpy.types import Context from ...panels import SM64_Panel -from ...utility import multilineLabel -from ..sm64_utility import import_rom_checks - class SM64_ExportAnimPanel(SM64_Panel): bl_idname = "SM64_PT_export_anim" @@ -27,15 +23,7 @@ def draw(self, context: Context): sm64_props = context.scene.fast64.sm64 - binary_col_enabled = True - try: - if sm64_props.anim_import.import_type == "Binary": - import_rom_checks(abspath(sm64_props.import_rom)) - except Exception as exc: - multilineLabel(self.layout.box(), str(exc), "ERROR") - binary_col_enabled = False - - sm64_props.anim_import.draw_props(col, binary_col_enabled) + sm64_props.anim_import.draw_props(col, sm64_props.import_rom) sm64_anim_panels = ( diff --git a/fast64_internal/sm64/animation/properties.py b/fast64_internal/sm64/animation/properties.py index 0ba8b3964..52c6df8cb 100644 --- a/fast64_internal/sm64/animation/properties.py +++ b/fast64_internal/sm64/animation/properties.py @@ -30,6 +30,7 @@ toAlnum, writeBoxExportType, ) +from ..sm64_utility import import_rom_checks from ..sm64_constants import ( MAX_U16, MIN_S16, @@ -1279,8 +1280,14 @@ def draw_c(self, layout: UILayout): col.prop(self, "remove_name_footer") col.prop(self, "use_custom_name") - def draw_binary(self, layout: UILayout): + def draw_binary(self, layout: UILayout, import_rom_path: str): col = layout.column() + try: + import_rom_checks(abspath(import_rom_path)) + except Exception as exc: + multilineLabel(col.box(), str(exc), "ERROR") + col = col.column() + col.enabled = False prop_split(col, self, "binary_import_type", "Binary Type") @@ -1306,18 +1313,24 @@ def draw_binary(self, layout: UILayout): prop_split(col, self, "table_index", "List Index") col.prop(self, "ignore_null") - def draw_insertable_binary(self, layout: UILayout): + def draw_insertable_binary(self, layout: UILayout, import_rom_path: str): col = layout.column() col.label(text="Type will be read from the data type of the files") col.separator() - read_from_rom_box = col.box().column() - read_from_rom_box.prop(self, "insertable_read_from_rom") + from_rom_box = col.box().column() + from_rom_box.prop(self, "insertable_read_from_rom") if self.insertable_read_from_rom: - prop_split(read_from_rom_box, self, "level", "Level") - read_from_rom_box.prop(self, "is_segmented_address") - prop_split(read_from_rom_box, self, "address", "Address") + try: + import_rom_checks(abspath(import_rom_path)) + except Exception as exc: + multilineLabel(from_rom_box.box(), str(exc), "ERROR") + from_rom_box = from_rom_box.column() + from_rom_box.enabled = False + prop_split(from_rom_box, self, "level", "Level") + from_rom_box.prop(self, "is_segmented_address") + prop_split(from_rom_box, self, "address", "Address") table_box = col.box().column() table_box.label(text="Table Imports") @@ -1326,8 +1339,9 @@ def draw_insertable_binary(self, layout: UILayout): prop_split(table_box, self, "table_index", "List Index") table_box.prop(self, "ignore_null") - def draw_props(self, layout: UILayout, binary_col_enabled: bool = True): + def draw_props(self, layout: UILayout, import_rom_path: str): col = layout.column() + prop_split(col, self, "import_type", "Type") col.separator() @@ -1338,15 +1352,13 @@ def draw_props(self, layout: UILayout, binary_col_enabled: bool = True): if self.import_type == "C": self.draw_c(col) - elif self.import_type == "Binary": - binary_col = col.column() - binary_col.enabled = binary_col_enabled - self.draw_binary(binary_col) - elif self.import_type == "Insertable Binary": - self.draw_insertable_binary(col) - - if self.import_type in {"Binary", "Insertable Binary"}: - col.prop(self, "assume_bone_count") + else: + if self.import_type == "Binary": + self.draw_binary(col, import_rom_path) + elif self.import_type == "Insertable Binary": + self.draw_insertable_binary(col, import_rom_path) + + binary_col.prop(self, "assume_bone_count") col.separator() col.operator(SM64_ImportAnim.bl_idname, icon="IMPORT")