Skip to content

Commit

Permalink
quick
Browse files Browse the repository at this point in the history
  • Loading branch information
Lilaa3 committed Apr 7, 2024
1 parent b7401b8 commit 82bc861
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 42 deletions.
16 changes: 8 additions & 8 deletions fast64_internal/sm64/animation/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ def execute_operator(self, context: Context):
def execute(self, context: Context):
try:
return self.execute_operator(context)
except Exception as e:
raisePluginError(self, e)
except Exception as exc:
raisePluginError(self, exc)
return {"CANCELLED"}


Expand Down Expand Up @@ -228,8 +228,8 @@ def execute_operator(self, context):
def execute(self, context):
try:
return self.execute_operator(context)
except Exception as e:
raisePluginError(self, e)
except Exception as exc:
raisePluginError(self, exc)
return {"CANCELLED"}


Expand All @@ -242,8 +242,8 @@ class SM64_ExportAnimTable(Operator):
def execute(self, context: Context):
try:
animation_operator_checks(context)
except Exception as e:
raisePluginError(self, e)
except Exception as exc:
raisePluginError(self, exc)
return {"CANCELLED"}

armature_obj = context.selected_objects[0]
Expand All @@ -257,9 +257,9 @@ def execute(self, context: Context):
result = {"FINISHED"}
try:
self.report({"INFO"}, exportAnimationTable(context, armature_obj))
except Exception as e:
except Exception as exc:
result = {"CANCELLED"}
raisePluginError(self, e)
raisePluginError(self, exc)

bpy.ops.object.mode_set(mode=get_mode_set_from_context_mode(starting_context_mode))
armature_obj.animation_data.action = starting_action
Expand Down
85 changes: 51 additions & 34 deletions fast64_internal/sm64/animation/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,7 @@ def draw_frame_range(self, layout: UILayout):
prop_split(row, self, "loop_end", "Loop End")
prop_split(col, self, "start_frame", "Start")

def draw_names(self, layout: UILayout, action: Action, actor_name: str, generate_enums: bool, export_type: str):
if export_type == "Binary":
return

def draw_names(self, layout: UILayout, action: Action, actor_name: str, generate_enums: bool):
col = layout.column()

name_split = col.split(factor=0.4)
Expand Down Expand Up @@ -296,7 +293,7 @@ def draw_props(
if export_type == "Binary":
self.draw_binary(col, is_binary_dma)
elif export_type == "C":
self.draw_names(col, action, actor_name, generate_enums, export_type)
self.draw_names(col, action, actor_name, generate_enums)
col.separator()
prop_split(col, self, "trans_divisor", "Translation Divisor")
col.separator()
Expand Down Expand Up @@ -360,10 +357,12 @@ def to_animation_class(
animation = SM64_Anim()
if self.reference_tables:
animation.reference = True
animation.values_reference, animation.indices_reference = self.values_table, self.indices_table
animation.values_reference = self.values_table
animation.indices_reference = self.indices_table
else:
data_name: str = toAlnum(f"anim_{action.name}")
animation.values_reference, animation.indices_reference = f"{data_name}_values", f"{data_name}_indices"
animation.values_reference = f"{data_name}_values"
animation.indices_reference = f"{data_name}_indices"
animation.pairs = get_animation_pairs(blender_to_sm64_scale, action, armature_obj)

for header_props in self.headers:
Expand All @@ -385,20 +384,20 @@ def drawHeaderVariant(
col = layout.column()

op_row = col.row()
removeOp = op_row.operator(SM64_AnimVariantOperations.bl_idname, icon="REMOVE")
removeOp.array_index, removeOp.type, removeOp.action_name = array_index, "REMOVE", action.name
remove_op = op_row.operator(SM64_AnimVariantOperations.bl_idname, icon="REMOVE")
remove_op.array_index, remove_op.type, remove_op.action_name = array_index, "REMOVE", action.name

add_op = op_row.operator(SM64_AnimVariantOperations.bl_idname, icon="ADD")
add_op.array_index, add_op.type, add_op.action_name = array_index, "ADD", action.name

moveUpCol = op_row.column()
moveUpCol.enabled = array_index != 0
moveUp = moveUpCol.operator(SM64_AnimVariantOperations.bl_idname, icon="TRIA_UP")
moveUp.array_index, moveUp.type, moveUp.action_name = array_index, "MOVE_UP", action.name
move_up_col = op_row.column()
move_up_col.enabled = array_index != 0
move_up_op = move_up_col.operator(SM64_AnimVariantOperations.bl_idname, icon="TRIA_UP")
move_up_op.array_index, move_up_op.type, move_up_op.action_name = array_index, "MOVE_UP", action.name

moveDownCol = op_row.column()
moveDownCol.enabled = array_index != len(self.header_variants) - 1
moveDown = moveDownCol.operator(SM64_AnimVariantOperations.bl_idname, icon="TRIA_DOWN")
move_down_col = op_row.column()
move_down_col.enabled = array_index != len(self.header_variants) - 1
moveDown = move_down_col.operator(SM64_AnimVariantOperations.bl_idname, icon="TRIA_DOWN")
moveDown.array_index, moveDown.type, moveDown.action_name = array_index, "MOVE_DOWN", action.name

col.prop(
Expand All @@ -418,8 +417,8 @@ def draw_variants(
action: Action,
actor_name: str,
generate_enums: bool,
is_binary_dma: bool,
export_type: str,
is_binary_dma: bool = False,
):
col = layout.column()

Expand Down Expand Up @@ -501,8 +500,8 @@ def draw_props(

col.separator()
col.label(text="Main Variant")
self.header.draw_props(col, action, actor_name, generate_enums, is_binary_dma, export_type)
self.draw_variants(col, action, actor_name, generate_enums, is_binary_dma, export_type)
self.header.draw_props(col, action, actor_name, generate_enums, export_type, is_binary_dma)
self.draw_variants(col, action, actor_name, generate_enums, export_type, is_binary_dma)


class SM64_TableElement(PropertyGroup):
Expand Down Expand Up @@ -612,15 +611,15 @@ def drawTableElement(self, layout: UILayout, table_index: int, table_element, ac
remove_op = right_row.operator(SM64_TableOperations.bl_idname, icon="REMOVE")
remove_op.array_index, remove_op.type = table_index, "REMOVE"

moveUpCol = right_row.column()
moveUpCol.enabled = table_index != 0
moveUp = moveUpCol.operator(SM64_TableOperations.bl_idname, icon="TRIA_UP")
moveUp.array_index, moveUp.type = table_index, "MOVE_UP"
move_up_col = right_row.column()
move_up_col.enabled = table_index != 0
move_up_op = move_up_col.operator(SM64_TableOperations.bl_idname, icon="TRIA_UP")
move_up_op.array_index, move_up_op.type = table_index, "MOVE_UP"

moveDownCol = right_row.column()
moveDownCol.enabled = table_index != len(self.elements) - 1
moveDown = moveDownCol.operator(SM64_TableOperations.bl_idname, icon="TRIA_DOWN")
moveDown.array_index, moveDown.type = table_index, "MOVE_DOWN"
move_down_col = right_row.column()
move_down_col.enabled = table_index != len(self.elements) - 1
move_down_op = move_down_col.operator(SM64_TableOperations.bl_idname, icon="TRIA_DOWN")
move_down_op.array_index, move_down_op.type = table_index, "MOVE_DOWN"

def draw_props(self, layout: UILayout, actor_name: str, export_type: str):
col = layout.column()
Expand Down Expand Up @@ -691,7 +690,8 @@ class SM64_AnimExportProps(PropertyGroup):
custom_path: StringProperty(name="Directory", subtype="FILE_PATH")
actor_name: StringProperty(name="Name", default="mario")
group_name: StringProperty(
name="Group Name", default="group0"
name="Group Name",
default="group0",
) # Ideally, this pr will be merged after combined exports, so this should be updated to use the group enum there
header_type: EnumProperty(items=enumAnimExportTypes, name="Header Export", default="Actor")
level_name: StringProperty(name="Level", default="bob")
Expand Down Expand Up @@ -729,7 +729,14 @@ def get_animation_paths(self, create_directories: bool = False):
dir_path = ""
geo_dir_path = ""
else:
dir_path = getExportDir(custom_export, export_path, self.header_type, level_name, "", dir_name)[0]
dir_path = getExportDir(
custom_export,
export_path,
self.header_type,
level_name,
"",
dir_name,
)[0]
geo_dir_path = os.path.join(dir_path, dir_name)
anim_dir_path = os.path.join(geo_dir_path, "anims")
if create_directories:
Expand Down Expand Up @@ -838,7 +845,11 @@ class SM64_AnimImportProps(PropertyGroup):

import_type: EnumProperty(items=enumAnimImportTypes, name="Type", default="C")

binary_import_type: EnumProperty(items=enumAnimBinaryImportTypes, name="Type", default="Animation")
binary_import_type: EnumProperty(
items=enumAnimBinaryImportTypes,
name="Type",
default="Animation",
)

address: StringProperty(name="Address", default="0600FC48")
is_segmented_address: BoolProperty(name="Is Segmented Address")
Expand All @@ -853,17 +864,23 @@ class SM64_AnimImportProps(PropertyGroup):
dma_table_address: StringProperty(name="DMA Table Address", default="0x4EC000")
mario_animation: IntProperty(name="Selected Preset Mario Animation", default=0)

c_path: StringProperty(name="Path", subtype="FILE_PATH", default="U:/home/user/sm64/assets/anims/")
c_path: StringProperty(
name="Path",
subtype="FILE_PATH",
default="U:/home/user/sm64/assets/anims/",
)
remove_name_footer: BoolProperty(
name="Remove Name Footers", description='Remove "anim_" from imported animations', default=True
name="Remove Name Footers",
description='Remove "anim_" from imported animations',
default=True,
)

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

def get_table_index(self):
def get_mario_table_index(self):
return (
self.mario_animation
if self.import_type == "Binary" and self.binary_import_type == "DMA" and self.mario_animation != -1
if self.binary_import_type == "DMA" and self.mario_animation != -1
else self.table_index
)

Expand Down

0 comments on commit 82bc861

Please sign in to comment.