From da2e6676d332a9f7dd06264a80b2d3f0197a5458 Mon Sep 17 00:00:00 2001 From: Lilaa3 <87947656+Lilaa3@users.noreply.github.com> Date: Sun, 7 Jan 2024 22:12:14 +0000 Subject: [PATCH] suggested changes and seperate import panel bool --- fast64_internal/panels.py | 8 ++--- fast64_internal/sm64/settings/properties.py | 6 ++-- fast64_internal/sm64/sm64_anim.py | 3 +- fast64_internal/sm64/sm64_f3d_parser.py | 2 +- fast64_internal/sm64/sm64_geolayout_parser.py | 3 +- fast64_internal/sm64/sm64_objects.py | 31 +++++-------------- fast64_internal/sm64/sm64_utility.py | 8 ----- 7 files changed, 20 insertions(+), 41 deletions(-) diff --git a/fast64_internal/panels.py b/fast64_internal/panels.py index 2522d1058..128f0403a 100644 --- a/fast64_internal/panels.py +++ b/fast64_internal/panels.py @@ -6,11 +6,12 @@ class SM64_Panel(bpy.types.Panel): bl_region_type = "UI" bl_category = "SM64" bl_options = {"DEFAULT_CLOSED"} + # goal refers to the selected enum_sm64_goal_type, a different selection than this goal will filter this panel out - # "Import" is not in the enum, as it is a separate UI option goal = None # if this is True, the panel is hidden whenever the scene's export_type is not 'C' decomp_only = False + import_panel = False @classmethod def poll(cls, context): @@ -19,11 +20,10 @@ def poll(cls, context): return False elif not cls.goal: return True # Panel should always be shown - elif cls.goal == "Import": - # Only show if importing is enabled - return sm64_props.show_importing_menus elif cls.decomp_only and sm64_props.export_type != "C": return False + elif cls.import_panel and not sm64_props.show_importing_menus: + return False scene_goal = sm64_props.goal return scene_goal == "All" or scene_goal == cls.goal diff --git a/fast64_internal/sm64/settings/properties.py b/fast64_internal/sm64/settings/properties.py index 92e64b356..e3be7b9ec 100644 --- a/fast64_internal/sm64/settings/properties.py +++ b/fast64_internal/sm64/settings/properties.py @@ -96,21 +96,21 @@ def upgrade_version_1(self, scene: Scene): setattr(self, new, scene.get(old, getattr(self, new))) refresh_version = scene.get("refreshVer", None) - if refresh_version: + if refresh_version is not None: self.refresh_version = enum_refresh_versions[refresh_version][0] self.show_importing_menus = self.get("showImportingMenus", self.show_importing_menus) export_type = self.get("exportType", None) - if export_type: + if export_type is not None: self.export_type = enum_export_type[export_type][0] self.version = 2 @staticmethod def upgrade_changed_props(): - sm64_props: SM64_Properties = bpy.context.scene.fast64.sm64 for scene in bpy.data.scenes: + sm64_props: SM64_Properties = scene.fast64.sm64 if sm64_props.version == 0: sm64_props.export_type = sm64_props.get_legacy_export_type(scene) print("Upgraded global SM64 settings to version 1") diff --git a/fast64_internal/sm64/sm64_anim.py b/fast64_internal/sm64/sm64_anim.py index 74db9e141..3fd8da3e9 100644 --- a/fast64_internal/sm64/sm64_anim.py +++ b/fast64_internal/sm64/sm64_anim.py @@ -1011,7 +1011,8 @@ def execute(self, context): class SM64_ImportAnimPanel(SM64_Panel): bl_idname = "SM64_PT_import_anim" bl_label = "SM64 Animation Importer" - goal = "Import" + goal = "Export Object/Actor/Anim" + import_panel = True # called every frame def draw(self, context): diff --git a/fast64_internal/sm64/sm64_f3d_parser.py b/fast64_internal/sm64/sm64_f3d_parser.py index 0b74b922b..6eaabb21e 100644 --- a/fast64_internal/sm64/sm64_f3d_parser.py +++ b/fast64_internal/sm64/sm64_f3d_parser.py @@ -69,7 +69,7 @@ def execute(self, context): class SM64_ImportDLPanel(SM64_Panel): bl_idname = "SM64_PT_import_dl" bl_label = "SM64 DL Importer" - goal = "Import" + import_panel = True # called every frame def draw(self, context): diff --git a/fast64_internal/sm64/sm64_geolayout_parser.py b/fast64_internal/sm64/sm64_geolayout_parser.py index e3f240ecd..8be765a9f 100644 --- a/fast64_internal/sm64/sm64_geolayout_parser.py +++ b/fast64_internal/sm64/sm64_geolayout_parser.py @@ -1592,7 +1592,8 @@ def execute(self, context): class SM64_ImportGeolayoutPanel(SM64_Panel): bl_idname = "SM64_PT_import_geolayout" bl_label = "SM64 Geolayout Importer" - goal = "Import" + goal = "Export Object/Actor/Anim" + import_panel = True # called every frame def draw(self, context): diff --git a/fast64_internal/sm64/sm64_objects.py b/fast64_internal/sm64/sm64_objects.py index 7dd2e5e79..981c514fe 100644 --- a/fast64_internal/sm64/sm64_objects.py +++ b/fast64_internal/sm64/sm64_objects.py @@ -755,29 +755,14 @@ def handleRefreshDiffModelIDs(modelID): def handleRefreshDiffSpecials(preset): - refresh_version = bpy.context.scene.fast64.sm64.refresh_version - if ( - refresh_version == "Refresh 8" - or refresh_version == "Refresh 7" - or refresh_version == "Refresh 6" - or refresh_version == "Refresh 5" - or refresh_version == "Refresh 4" - or refresh_version == "Refresh 3" - ): - pass - return preset - - -def handleRefreshDiffMacros(preset): - refresh_version = bpy.context.scene.fast64.sm64.refresh_version - if ( - refresh_version == "Refresh 8" - or refresh_version == "Refresh 7" - or refresh_version == "Refresh 6" - or refresh_version == "Refresh 5" - or refresh_version == "Refresh 4" - or refresh_version == "Refresh 3" - ): + if bpy.context.scene.fast64.sm64.refresh_version in { + "Refresh 8", + "Refresh 7", + "Refresh 6", + "Refresh 5", + "Refresh 4", + "Refresh 3", + }: pass return preset diff --git a/fast64_internal/sm64/sm64_utility.py b/fast64_internal/sm64/sm64_utility.py index 7f9beeb21..7e3b22729 100644 --- a/fast64_internal/sm64/sm64_utility.py +++ b/fast64_internal/sm64/sm64_utility.py @@ -1,5 +1,4 @@ import os -from bpy.path import abspath from ..utility import PluginError, filepath_checks @@ -45,13 +44,6 @@ def export_rom_checks(filepath: str): def check_expanded(filepath: str): - filepath_checks( - filepath, - empty_error=f"ROM path is empty.", - doesnt_exist_error=f"ROM path does not exist.", - not_a_file_error=f"ROM path is not a file.", - ) - size = os.path.getsize(filepath) if size < 9000000: # check if 8MB raise PluginError(