Skip to content

Commit

Permalink
suggested changes and seperate import panel bool
Browse files Browse the repository at this point in the history
  • Loading branch information
Lilaa3 committed Jan 7, 2024
1 parent ee9cb1b commit da2e667
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 41 deletions.
8 changes: 4 additions & 4 deletions fast64_internal/panels.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions fast64_internal/sm64/settings/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
3 changes: 2 additions & 1 deletion fast64_internal/sm64/sm64_anim.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion fast64_internal/sm64/sm64_f3d_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
3 changes: 2 additions & 1 deletion fast64_internal/sm64/sm64_geolayout_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
31 changes: 8 additions & 23 deletions fast64_internal/sm64/sm64_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 0 additions & 8 deletions fast64_internal/sm64/sm64_utility.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
from bpy.path import abspath

from ..utility import PluginError, filepath_checks

Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit da2e667

Please sign in to comment.