Skip to content

Commit

Permalink
I SWEAR TO GOD BLACK
Browse files Browse the repository at this point in the history
  • Loading branch information
Lilaa3 committed Apr 7, 2024
1 parent b6fd0ce commit dbbc73f
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 31 deletions.
2 changes: 1 addition & 1 deletion fast64_internal/sm64/animation/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
(
"DMA",
"DMA (Mario)",
"No headers or includes are genarated and correct order is applied (needed for decomp converter)",
"No headers or includes are genarated. Mario animation converter order is used (headers, indicies, values)",
),
("Custom", "Custom Path", "Exports to a specific path"),
]
Expand Down
28 changes: 14 additions & 14 deletions fast64_internal/sm64/animation/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
import bpy
from bpy.utils import register_class, unregister_class
from bpy.types import Context, Object, Scene
from bpy.types import Context, Object, Scene, Operator
from bpy.path import abspath
from bpy.props import (
EnumProperty,
Expand Down Expand Up @@ -80,7 +80,7 @@ def emulate_no_loop(scene: Scene):
scene.frame_set(loop_start)


class SM64_PreviewAnimOperator(bpy.types.Operator):
class SM64_PreviewAnimOperator(Operator):
bl_idname = "scene.sm64_preview_animation"
bl_label = "Preview Animation"
bl_options = {"REGISTER", "UNDO", "PRESET"}
Expand Down Expand Up @@ -137,7 +137,7 @@ def execute(self, context: Context):
bpy.ops.object.mode_set(mode=get_mode_set_from_context_mode(starting_context_mode))


class SM64_TableOperations(bpy.types.Operator):
class SM64_TableOperations(Operator):
bl_idname = "scene.sm64_table_operations"
bl_label = ""
bl_options = {"UNDO"}
Expand Down Expand Up @@ -176,7 +176,7 @@ def execute(self, context: Context):
return {"CANCELLED"}


class SM64_AnimVariantOperations(bpy.types.Operator):
class SM64_AnimVariantOperations(Operator):
bl_idname = "scene.sm64_header_variant_operations"
bl_label = ""
bl_options = {"UNDO"}
Expand Down Expand Up @@ -225,7 +225,7 @@ def execute(self, context):
return {"CANCELLED"}


class SM64_ExportAnimTable(bpy.types.Operator):
class SM64_ExportAnimTable(Operator):
bl_idname = "scene.sm64_export_anim_table"
bl_label = "Export"
bl_description = "Select an armature with animation data to use"
Expand Down Expand Up @@ -260,13 +260,15 @@ def execute(self, context: Context):
return result


class SM64_ExportAnim(bpy.types.Operator):
class SM64_ExportAnim(Operator):
bl_idname = "scene.sm64_export_anim"
bl_label = "Export"
bl_description = "Exports the selected action, select an armature with animation data to use"
bl_options = {"REGISTER", "UNDO", "PRESET"}

def execute_operator(self, context: Context):
def execute_operator(
self, context: Context
): # TODO: Put this stuff into an exporting.py function again? still nice to have stuff be more independetly callable tho
scene = context.scene
sm64_props = scene.fast64.sm64
anim_export_props = sm64_props.anim_export
Expand All @@ -282,8 +284,6 @@ def execute_operator(self, context: Context):
action, armature_obj, sm64_props.blender_to_sm64_scale, actor_name
)

is_dma_structure = anim_export_props.is_dma_structure(sm64_props)

if sm64_props.export_type == "C":
header_type = anim_export_props.header_type

Expand All @@ -297,7 +297,7 @@ def execute_operator(self, context: Context):
applyBasicTweaks(abspath(sm64_props.decomp_path))

with open(anim_path, "w", newline="\n") as file:
file.write(animation.to_c(is_dma_structure, sm64_props.refresh_version))
file.write(animation.to_c(anim_export_props.is_c_dma_structure, sm64_props.refresh_version))

if header_type != "DMA":
table_name = table_props.get_anim_table_name(actor_name)
Expand Down Expand Up @@ -326,7 +326,7 @@ def execute_operator(self, context: Context):
header_type,
)
elif sm64_props.export_type == "Insertable Binary":
data, ptrs = animation.to_binary(is_dma_structure, 0)
data, ptrs = animation.to_binary(anim_export_props.binary_is_dma, 0)
path = abspath(anim_export_props.insertable_path)
writeInsertableFile(path, 2, ptrs, 0, data)
else:
Expand Down Expand Up @@ -360,7 +360,7 @@ def execute(self, context: Context):


# Importing
class SM64_ImportAllMarioAnims(bpy.types.Operator):
class SM64_ImportAllMarioAnims(Operator):
bl_idname = "scene.sm64_import_mario_anims"
bl_label = "Import All Mario Animations"
bl_options = {"REGISTER", "UNDO", "PRESET"}
Expand Down Expand Up @@ -407,7 +407,7 @@ def execute(self, context):
return {"CANCELLED"}


class SM64_ImportAnim(bpy.types.Operator):
class SM64_ImportAnim(Operator):
bl_idname = "scene.sm64_import_anim"
bl_label = "Import Animation"
bl_options = {"REGISTER", "UNDO", "PRESET"}
Expand Down Expand Up @@ -473,7 +473,7 @@ def execute(self, context):
return {"CANCELLED"}


class SM64_SearchMarioAnimEnum(bpy.types.Operator):
class SM64_SearchMarioAnimEnum(Operator):
bl_idname = "scene.search_mario_anim_enum_operator"
bl_label = "Search Mario Animations"
bl_description = "Search Mario Animations"
Expand Down
22 changes: 9 additions & 13 deletions fast64_internal/sm64/animation/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -680,9 +680,9 @@ class SM64_AnimExportProps(PropertyGroup):
dma_folder: StringProperty(name="DMA Folder", default="assets/anims/")

use_dma_structure: BoolProperty(
name="Use Vanilla DMA Structure",
description="Headers before values and index tables and designated initialisers are not available",
default=True,
name="Use DMA Structure",
description="When enabled, the Mario animation converter order is used (headers, indicies, values)",
default=False,
)

custom_path: StringProperty(name="Directory", subtype="FILE_PATH")
Expand All @@ -699,10 +699,11 @@ class SM64_AnimExportProps(PropertyGroup):

insertable_path: StringProperty(name="Insertable Path", subtype="FILE_PATH")

def is_dma_structure(self, sm64_props):
if sm64_props.is_binary_export():
return self.binary_is_dma
elif self.header_type in {"DMA", "Custom"}:
@property
def is_c_dma_structure(self):
if self.header_type == "DMA":
return True
if self.header_type == "Custom":
return self.use_dma_structure
return False

Expand Down Expand Up @@ -764,9 +765,6 @@ def draw_action_properties(self, layout, export_type: str):
export_type,
)

def can_use_dma_structure(self):
return self.header_type == "Custom" or self.header_type == "DMA"

def draw_binary_settings(self, layout: UILayout, export_type: str):
col = layout.column()
col.prop(self, "binary_is_dma")
Expand All @@ -788,10 +786,8 @@ def draw_c_settings(self, layout: UILayout):
if self.header_type != "DMA":
prop_split(col, self, "actor_name", "Name")

if self.can_use_dma_structure():
col.prop(self, "use_dma_structure")

if self.header_type == "Custom":
col.prop(self, "use_dma_structure")
col.prop(self, "custom_path")
customExportWarning(col)
elif self.header_type == "DMA":
Expand Down
1 change: 0 additions & 1 deletion fast64_internal/sm64/settings/panels.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ def draw_repo_settings(scene: Scene, layout: UILayout):

prop_split(col, sm64_props, "compression_format", "Compression Format")
prop_split(col, sm64_props, "refresh_version", "Refresh (Function Map)")
col.prop(sm64_props.anim_export, "use_dma_structure")


class SM64_GeneralSettingsPanel(SM64_Panel):
Expand Down
2 changes: 0 additions & 2 deletions fast64_internal/sm64/settings/repo_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ def save_sm64_repo_settings(scene: Scene):
sm64_props = scene.fast64.sm64
data["refresh_version"] = sm64_props.refresh_version
data["compression_format"] = sm64_props.compression_format
data["use_dma_structure"] = sm64_props.anim_export.use_dma_structure

return data

Expand All @@ -38,4 +37,3 @@ def load_sm64_repo_settings(scene: Scene, data: dict[str, Any]):
sm64_props = scene.fast64.sm64
sm64_props.refresh_version = data.get("refresh_version", sm64_props.refresh_version)
sm64_props.compression_format = data.get("compression_format", sm64_props.compression_format)
sm64_props.anim_export.use_dma_structure = data.get("use_dma_structure", sm64_props.anim_export.use_dma_structure)

0 comments on commit dbbc73f

Please sign in to comment.