diff --git a/__init__.py b/__init__.py index 07e9be425..f122dc0fa 100644 --- a/__init__.py +++ b/__init__.py @@ -24,7 +24,6 @@ from .fast64_internal.z64 import OOT_Properties, oot_register, oot_unregister from .fast64_internal.z64.constants import oot_world_defaults from .fast64_internal.z64.props_panel_main import OOT_ObjectProperties -from .fast64_internal.z64.actor.properties import initOOTActorProperties from .fast64_internal.utility_anim import utility_anim_register, utility_anim_unregister, ArmatureApplyWithMeshOperator from .fast64_internal.mk64 import MK64_Properties, mk64_register, mk64_unregister @@ -435,7 +434,6 @@ def register(): addon_updater_ops.register(bl_info) register_class(Matrix4x4Property) - initOOTActorProperties() utility_anim_register() mat_register() bsdf_conv_register() diff --git a/fast64_internal/data/z64/data.py b/fast64_internal/data/z64/data.py index a7ad5f0c1..aa22f11de 100644 --- a/fast64_internal/data/z64/data.py +++ b/fast64_internal/data/z64/data.py @@ -185,76 +185,6 @@ ("ROOM_TYPE_BOSS", "Boss", "0x05"), ] -oot_enum_floor_property = [ - ("Custom", "Custom", "Custom"), - ("0x00", "Default", "Default"), - ("0x05", "Trigger Respawn", "Trigger Respawn"), - ("0x06", "Grab Wall", "Grab Wall"), - ("0x08", "Stop Air Momentum", "Stop Air Momentum"), - ("0x09", "Fall Instead Of Jumping", "Fall Instead Of Jumping"), - ("0x0B", "Dive Animation", "Dive Animation"), - ("0x0C", "Trigger Void", "Trigger Void"), -] - -mm_enum_floor_property = [ - ("Custom", "Custom", "Custom"), - ("0x00", "Default", "FLOOR_PROPERTY_0"), - ("0x01", "Frontflip Jump Animation", "FLOOR_PROPERTY_1"), - ("0x02", "Sideflip Jump Animation", "FLOOR_PROPERTY_2"), - ("0x05", "Trigger Respawn (sets human no mask)", "FLOOR_PROPERTY_5"), - ("0x06", "Grab Wall", "FLOOR_PROPERTY_6"), - ("0x07", "Unknown (sets speed to 0)", "FLOOR_PROPERTY_7"), - ("0x08", "Stop Air Momentum", "FLOOR_PROPERTY_8"), - ("0x09", "Fall Instead Of Jumping", "FLOOR_PROPERTY_9"), - ("0x0B", "Dive Animation", "FLOOR_PROPERTY_11"), - ("0x0C", "Trigger Void", "FLOOR_PROPERTY_12"), - ("0x0D", "Trigger Void (runs `Player_Action_1`)", "FLOOR_PROPERTY_13"), -] - -oot_enum_floor_type = [ - ("Custom", "Custom", "Custom"), - ("0x00", "Default", "Default"), - ("0x01", "Haunted Wasteland Camera", "Haunted Wasteland Camera"), - ("0x02", "Fire (damages every 6s)", "Fire (damages every 6s)"), - ("0x03", "Fire (damages every 3s)", "Fire (damages every 3s)"), - ("0x04", "Shallow Sand", "Shallow Sand"), - ("0x05", "Slippery", "Slippery"), - ("0x06", "Ignore Fall Damage", "Ignore Fall Damage"), - ("0x07", "Quicksand Crossing (Blocks Epona)", "Quicksand Crossing (Epona Uncrossable)"), - ("0x08", "Jabu Jabu's Belly Floor", "Jabu Jabu's Belly Floor"), - ("0x09", "Trigger Void", "Trigger Void"), - ("0x0A", "Stops Air Momentum", "Stops Air Momentum"), - ("0x0B", "Grotto Exit Animation", "Link Looks Up"), - ("0x0C", "Quicksand Crossing (Epona Crossable)", "Quicksand Crossing (Epona Crossable)"), -] - -mm_enum_floor_type = [ - ("Custom", "Custom", "Custom"), - ("0x00", "Default", "FLOOR_TYPE_0"), - ("0x01", "Unused (?)", "FLOOR_TYPE_1"), - ("0x02", "Fire Damages (burns Player every second)", "FLOOR_TYPE_2"), - ("0x03", "Fire Damages 2 (burns Player every second)", "FLOOR_TYPE_3"), - ("0x04", "Shallow Sand", "FLOOR_TYPE_4"), - ("0x05", "Ice (Slippery)", "FLOOR_TYPE_5"), - ("0x06", "Ignore Fall Damages", "FLOOR_TYPE_6"), - ("0x07", "Quicksand (blocks Epona)", "FLOOR_TYPE_7"), - ("0x08", "Jabu Jabu's Belly Floor (Unused)", "FLOOR_TYPE_8"), - ("0x09", "Triggers Void", "FLOOR_TYPE_9"), - ("0x0A", "Stops Air Momentum", "FLOOR_TYPE_10"), - ("0x0B", "Grotto Exit Animation", "FLOOR_TYPE_11"), - ("0x0C", "Quicksand (doesn't block Epona)", "FLOOR_TYPE_12"), - ("0x0D", "Deeper Shallow Sand", "FLOOR_TYPE_13"), - ("0x0E", "Shallow Snow", "FLOOR_TYPE_14"), - ("0x0F", "Deeper Shallow Snow", "FLOOR_TYPE_15"), -] - -enum_floor_effect = [ - ("Custom", "Custom", "Custom"), - ("0x00", "Default", "FLOOR_EFFECT_0"), - ("0x01", "Steep/Slippery Slope", "FLOOR_EFFECT_1"), - ("0x02", "Walkable (Preserves Exit Flags)", "FLOOR_EFFECT_2"), -] - oot_enum_camera_setting_type = [ ("Custom", "Custom", "Custom"), ("CAM_SET_NONE", "None", "None"), @@ -820,8 +750,6 @@ def __init__(self, game: str): self.is_registering = True self.update(None, game, True) # forcing the update as we're in the init function - self.enum_floor_effect = enum_floor_effect - def is_oot(self): self.update(bpy.context, None) return self.game == "OOT" @@ -877,8 +805,6 @@ def update(self, context: Optional[Context], game: Optional[str], force: bool = self.enum_skybox_config = oot_enum_skybox_config self.enum_environment_type = oot_enum_environment_type self.enum_room_type = oot_enum_room_type - self.enum_floor_property = oot_enum_floor_property - self.enum_floor_type = oot_enum_floor_type self.enum_camera_setting_type = oot_enum_camera_setting_type self.enum_cs_list_type = oot_enum_cs_list_type self.skeleton_dict = oot_skeleton_dict @@ -892,8 +818,6 @@ def update(self, context: Optional[Context], game: Optional[str], force: bool = self.enum_skybox_config = mm_enum_skybox_config self.enum_environment_type = mm_enum_environment_type self.enum_room_type = mm_enum_room_type - self.enum_floor_property = mm_enum_floor_property - self.enum_floor_type = mm_enum_floor_type self.enum_camera_setting_type = mm_enum_camera_setting_type self.enum_cs_list_type = mm_enum_cs_list_type self.skeleton_dict = mm_skeleton_dict @@ -903,25 +827,29 @@ def update(self, context: Optional[Context], game: Optional[str], force: bool = self.enum_map: dict[str, list[tuple[str, str, str]]] = { "globalObject": self.enums.enum_global_object, - "musicSeq": self.enums.enum_seq_id, + "seq_id": self.enums.enum_seq_id, "drawConfig": self.enums.enum_draw_config, - "sound": self.enums.enum_surface_material, - "csDestination": self.enums.enum_cs_destination, - "seqId": self.enums.enum_seq_id, - "playerCueID": self.enums.enum_cs_player_cue_id, - "ocarinaAction": self.enums.enum_ocarina_song_action_id, - "csTextType": self.enums.enum_cs_text_type, - "csSeqPlayer": self.enums.enum_cs_fade_out_seq_player, - "csMiscType": self.enums.enum_cs_misc_type, - "transitionType": self.enums.enum_cs_transition_type, - "actor_cue_list_cmd_type": self.enums.enum_cs_actor_cue_list_cmd_type, + "surface_material": self.enums.enum_surface_material, + "cs_destination": self.enums.enum_cs_destination, + "cs_player_cue_id": self.enums.enum_cs_player_cue_id, + "cs_song_action_id": self.enums.enum_ocarina_song_action_id, + "cs_text_type": self.enums.enum_cs_text_type, + "cs_seq_player": self.enums.enum_cs_fade_out_seq_player, + "cs_misc_type": self.enums.enum_cs_misc_type, + "cs_transition_type": self.enums.enum_cs_transition_type, + "cs_actor_cue_list": self.enums.enum_cs_actor_cue_list_cmd_type, "spline_interp_type": self.enums.enum_cs_spline_interp_type, "spline_rel_to": self.enums.enum_cs_spline_rel, "trans_general": self.enums.enum_cs_transition_general, "blur_type": self.enums.enum_cs_motion_blur_type, "credits_scene_type": self.enums.enum_cs_credits_scene_type, "mod_seq_type": self.enums.enum_cs_modify_seq_type, - "objectKey": self.objects.ootEnumObjectKey, + "wall_type": self.enums.enum_wall_type, + "floor_effect": self.enums.enum_floor_effect, + "floor_property": self.enums.enum_floor_property, + "floor_type": self.enums.enum_floor_type, + "conveyor_speed": self.enums.enum_conveyor_speed, + "object_key": self.objects.ootEnumObjectKey, "actor_id": self.actors.ootEnumActorID, "chest_content": self.actors.ootEnumChestContent, "navi_msg_id": self.actors.ootEnumNaviMessageData, @@ -931,8 +859,6 @@ def update(self, context: Optional[Context], game: Optional[str], force: bool = "nature_id": self.enum_nature_id, "room_type": self.enum_room_type, "environment_type": self.enum_environment_type, - "floor_property": self.enum_floor_property, - "floor_type": self.enum_floor_type, "camera_setting_type": self.enum_camera_setting_type, "cs_list_type": self.enum_cs_list_type, "skeleton_mode": self.enum_skeleton_mode, @@ -941,3 +867,11 @@ def update(self, context: Optional[Context], game: Optional[str], force: bool = def get_enum(self, prop_name: str): self.update(bpy.context, None) return self.enum_map[prop_name] + + def get_enum_value(self, enum_key: str, item_key: str): + enum = self.enums.enumByKey[enum_key] + + if bpy.context.scene.fast64.oot.useDecompFeatures: + return enum.item_by_key[item_key].id + else: + return str(enum.item_by_key[item_key].index) diff --git a/fast64_internal/data/z64/enum_data.py b/fast64_internal/data/z64/enum_data.py index c3d1a5840..481e3db79 100644 --- a/fast64_internal/data/z64/enum_data.py +++ b/fast64_internal/data/z64/enum_data.py @@ -9,6 +9,7 @@ class Z64_ItemElement(Z64_BaseElement): parentKey: str game: str desc: str + enum_index: int def __post_init__(self): # generate the name from the id @@ -35,14 +36,8 @@ def __post_init__(self): "ocarina_song_action_id": "OCARINA_ACTION", "seq_id": "NA_BGM", "draw_config": ("SCENE_DRAW_CFG" if self.game == "MM" else "SDC"), - "surface_material": "SURFACE_MATERIAL", "global_object": "OBJECT", - "floor_type": "", - "wall_type": "", - "floor_property": "", - "surface_sfx_offset": "", - "floor_effect": "", - "conveyor_speed": "", + "surface_sfx_offset": "SURFACE_SFX_OFFSET", } self.name = self.id.removeprefix(f"{keyToPrefix[self.parentKey]}_") @@ -65,6 +60,7 @@ class Z64_EnumElement(Z64_BaseElement): item_by_id: dict[int, Z64_ItemElement] = field(default_factory=dict) def __post_init__(self): + self.items.sort(key=lambda item: item.enum_index) self.item_by_key = {item.key: item for item in self.items} self.item_by_index = {item.index: item for item in self.items} self.item_by_id = {item.id: item for item in self.items} @@ -98,15 +94,14 @@ def __init__(self, game: str): enum.attrib["Key"], game, item.attrib.get("Description", "Unset"), + int(item.attrib.get("EnumIndex", str(i))), ) - for item in enum + for i, item in enumerate(enum) ], ) ) # create list of tuples used by Blender's enum properties - self.deletedEntry = ("None", "(Deleted from the XML)", "None") - self.enum_cs_cmd: list[tuple[str, str, str]] = [] self.enum_cs_misc_type: list[tuple[str, str, str]] = [] self.enum_cs_text_type: list[tuple[str, str, str]] = [] @@ -127,7 +122,6 @@ def __init__(self, game: str): self.enum_ocarina_song_action_id: list[tuple[str, str, str]] = [] self.enum_seq_id: list[tuple[str, str, str]] = [] self.enum_draw_config: list[tuple[str, str, str]] = [] - self.enum_surface_material: list[tuple[str, str, str]] = [] self.enum_global_object: list[tuple[str, str, str]] = [] self.enum_floor_type: list[tuple[str, str, str]] = [] self.enum_wall_type: list[tuple[str, str, str]] = [] @@ -143,27 +137,23 @@ def __init__(self, game: str): for key in self.enumByKey.keys(): setattr(self, f"enum_{key}", self.get_enum_data(key)) + # Note: `CS_CMD_UNIMPLEMENTED_16` is an unused actor cue self.enum_cs_actor_cue_list_cmd_type = [ - item for item in self.enum_cs_cmd if "actor_cue" in item[0] or "player_cue" in item[0] + (item[0], item[1], item[2]) + for item in self.enum_cs_cmd + if "actor_cue" in item[0] or "player_cue" in item[0] or item[0] == "unimplemented_16" ] self.enum_cs_actor_cue_list_cmd_type.sort() self.enum_cs_actor_cue_list_cmd_type.insert(0, ("Custom", "Custom", "Custom")) def get_enum_data(self, enumKey: str): enum = self.enumByKey[enumKey] - firstIndex = min(1, *(item.index for item in enum.items)) - lastIndex = max(1, *(item.index for item in enum.items)) + 1 - enumData = [self.deletedEntry] * lastIndex - custom = ("Custom", "Custom", "Custom") + enumData = [("None", "(Deleted from the XML)", "None", i + 1) for i in range(len(enum.items))] for item in enum.items: - if item.index < lastIndex: + if item.enum_index < len(enum.items): identifier = item.key - enumData[item.index] = (identifier, item.name, item.id) - - if firstIndex > 0: - enumData[0] = custom - else: - enumData.insert(0, custom) + enumData[item.enum_index] = (identifier, item.name, item.id, item.enum_index + 1) + enumData.insert(0, ("Custom", "Custom", "Custom", 0)) return enumData diff --git a/fast64_internal/data/z64/xml/mm_actor_list.xml b/fast64_internal/data/z64/xml/mm_actor_list.xml index 3593921e6..277d8791a 100644 --- a/fast64_internal/data/z64/xml/mm_actor_list.xml +++ b/fast64_internal/data/z64/xml/mm_actor_list.xml @@ -853,7 +853,7 @@ for each sub element (of ) mentioned below: - + diff --git a/fast64_internal/data/z64/xml/mm_enum_data.xml b/fast64_internal/data/z64/xml/mm_enum_data.xml index 604b41431..01db7f3a0 100644 --- a/fast64_internal/data/z64/xml/mm_enum_data.xml +++ b/fast64_internal/data/z64/xml/mm_enum_data.xml @@ -749,6 +749,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fast64_internal/data/z64/xml/oot_enum_data.xml b/fast64_internal/data/z64/xml/oot_enum_data.xml index 088725257..3154f0190 100644 --- a/fast64_internal/data/z64/xml/oot_enum_data.xml +++ b/fast64_internal/data/z64/xml/oot_enum_data.xml @@ -15,6 +15,7 @@ * ID: the actual enum name from decomp, this may change hence the need of the Key parameter * Name: a descriptive name about the current item * Index: the location of the item in the enum (should match decomp) + * EnumIndex: the index this item should be located at in the enum Notes: - Player Cue Ids got their own enum but not regular Actor Cues. @@ -599,44 +600,44 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - - + + + + + + + + @@ -657,31 +658,31 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - + + + - - - - + + + + diff --git a/fast64_internal/utility.py b/fast64_internal/utility.py index 0fb13f902..acdb834a0 100644 --- a/fast64_internal/utility.py +++ b/fast64_internal/utility.py @@ -2061,6 +2061,16 @@ def get_include_data(include: str, strip: bool = False): return data +def get_prop_annotations(cls): + prop_annotations = getattr(cls, "__annotations__", None) + + if prop_annotations is None: + setattr(cls, "__annotations__", dict()) + prop_annotations = getattr(cls, "__annotations__") + + return prop_annotations + + def get_new_object( name: str, data: Optional[Any], diff --git a/fast64_internal/z64/actor/operators.py b/fast64_internal/z64/actor/operators.py index 93d5e8e27..6d5cfddee 100644 --- a/fast64_internal/z64/actor/operators.py +++ b/fast64_internal/z64/actor/operators.py @@ -12,7 +12,7 @@ class OOT_SearchChestContentEnumOperator(Operator): bl_property = "chest_content" bl_options = {"REGISTER", "UNDO"} - chest_content: EnumProperty(items=game_data.z64.actors.ootEnumChestContent, default="item_heart") + chest_content: EnumProperty(items=lambda self, context: game_data.z64.get_enum("chest_content"), default=1) obj_name: StringProperty() prop_name: StringProperty() @@ -33,7 +33,7 @@ class OOT_SearchNaviMsgIDEnumOperator(Operator): bl_property = "navi_msg_id" bl_options = {"REGISTER", "UNDO"} - navi_msg_id: EnumProperty(items=game_data.z64.actors.ootEnumNaviMessageData, default="msg_00") + navi_msg_id: EnumProperty(items=lambda self, context: game_data.z64.get_enum("navi_msg_id"), default=1) obj_name: StringProperty() prop_name: StringProperty() diff --git a/fast64_internal/z64/actor/properties.py b/fast64_internal/z64/actor/properties.py index 967d3763b..6120890a6 100644 --- a/fast64_internal/z64/actor/properties.py +++ b/fast64_internal/z64/actor/properties.py @@ -3,7 +3,8 @@ from bpy.types import Object, PropertyGroup, UILayout from bpy.utils import register_class, unregister_class from bpy.props import EnumProperty, StringProperty, IntProperty, BoolProperty, CollectionProperty, PointerProperty -from ...utility import PluginError, prop_split, label_split + +from ...utility import get_prop_annotations, prop_split, label_split from ...game_data import game_data from ..constants import ootEnumCamTransition from ..upgrade import upgradeActors @@ -33,7 +34,9 @@ ] -def get_prop_name(actor_key: str, param_type: str, param_subtype: str, param_index: int): +def get_prop_name(actor_key: str, param_type: str, param_subtype: str, param_index: int, update: bool = True): + if update: + game_data.z64.update(bpy.context, None) flag_to_prop_suffix = {"Chest": "chestFlag", "Collectible": "collectibleFlag", "Switch": "switchFlag"} param_to_prop_suffix = { "Type": "type", @@ -45,16 +48,14 @@ def get_prop_name(actor_key: str, param_type: str, param_subtype: str, param_ind "Message": "naviMsg", } suffix = param_to_prop_suffix[param_type] if param_type != "Flag" else flag_to_prop_suffix[param_subtype] - return f"{actor_key}.{suffix}{param_index}" # e.g.: ``en_test.props1`` + return f"{game_data.z64.game.lower()}.{actor_key}.{suffix}{param_index}" # e.g.: `oot.en_test.props1` -def initOOTActorProperties(): +def create_game_props(game: str): """This function is used to edit the OOTActorProperty class""" - prop_annotations = getattr(OOTActorProperty, "__annotations__", None) - - if prop_annotations is None: - OOTActorProperty.__annotations__ = prop_annotations = {} + game_data.z64.update(None, game, True) + prop_ats = get_prop_annotations(OOTActorProperty) param_type_to_enum_items = { "ChestContent": game_data.z64.actors.ootEnumChestContent, @@ -64,7 +65,7 @@ def initOOTActorProperties(): for actor in game_data.z64.actors.actorList: for param in actor.params: - prop_name = get_prop_name(actor.key, param.type, param.subType, param.index) + prop_name = get_prop_name(actor.key, param.type, param.subType, param.index, update=False) enum_items = None if len(param.items) > 0: @@ -74,14 +75,14 @@ def initOOTActorProperties(): enum_items = param_type_to_enum_items[param.type] if param.type in {"Property", "Flag"}: - prop_annotations[prop_name] = StringProperty(name="", default="0x0") + prop_ats[prop_name] = StringProperty(name="", default="0x0") elif param.type == "Bool": - prop_annotations[prop_name] = BoolProperty(name="", default=False) + prop_ats[prop_name] = BoolProperty(name="", default=False) elif param.type in {"Type", "Enum", "ChestContent", "Collectible", "Message"} and enum_items is not None: - prop_annotations[prop_name] = EnumProperty(name="", items=enum_items, default=enum_items[1][0]) + prop_ats[prop_name] = EnumProperty(name="", items=enum_items, default=enum_items[1][0]) if param.type in {"Type", "Enum", "ChestContent", "Collectible", "Message"}: - prop_annotations[f"{prop_name}_custom"] = StringProperty(name="", default="0x0") + prop_ats[f"{prop_name}_custom"] = StringProperty(name="", default="0x0") class OOTActorHeaderItemProperty(PropertyGroup): @@ -169,7 +170,7 @@ def draw_props( class OOTActorProperty(PropertyGroup): - actor_id: EnumProperty(name="Actor", items=game_data.z64.actors.ootEnumActorID, default="ACTOR_PLAYER") + actor_id: EnumProperty(name="Actor", items=lambda self, context: game_data.z64.get_enum("actor_id"), default=1) actor_id_custom: StringProperty(name="Actor ID", default="ACTOR_PLAYER") # only used for actors with the id "Custom" @@ -338,7 +339,7 @@ def get_param_value(self, target: str): if "Rot" in target: attr = getattr(self, get_prop_name(actor.key, "Type", None, 1), None) - type_value = getEvalParamsInt(attr) if attr is not None else None + type_value = getEvalParamsInt(attr) if attr is not None and attr != "Custom" else None if type_value is not None and type_value in param.tiedTypes or len(param.tiedTypes) == 0: val = ((param_val if param_val is not None else -1) & param.mask) >> getShiftFromMask(param.mask) @@ -599,6 +600,12 @@ def draw_props(self, layout: UILayout, obj: Object, altSceneProp: OOTAlternateSc def actor_props_register(): + # generate props for OoT + create_game_props("OOT") + + # generate props for MM + create_game_props("MM") + for cls in classes: register_class(cls) diff --git a/fast64_internal/z64/collision/constants.py b/fast64_internal/z64/collision/constants.py index 2c63f362e..4ff94bc54 100644 --- a/fast64_internal/z64/collision/constants.py +++ b/fast64_internal/z64/collision/constants.py @@ -4,52 +4,6 @@ ("Water", "Water", "Water"), ] -ootEnumWallSetting = [ - ("Custom", "Custom", "Custom"), - ("0x00", "None", "None"), - ("0x01", "No Ledge Grab", "No Ledge Grab"), - ("0x02", "Ladder", "Ladder"), - ("0x03", "Ladder Top", "Ladder Top"), - ("0x04", "Vines", "Vines"), - ("0x05", "Crawl Space", "Crawl Space"), - ("0x06", "Crawl Space 2", "Crawl Space 2"), - ("0x07", "Push Block", "Push Block"), -] - -ootEnumCollisionTerrain = [ - ("Custom", "Custom", "Custom"), - ("0x00", "Walkable", "Walkable"), - ("0x01", "Steep", "Steep"), - ("0x02", "Walkable (Preserves Exit Flags)", "Walkable (Preserves Exit Flags)"), - ("0x03", "Walkable (?)", "Walkable (?)"), -] - -ootEnumCollisionSound = [ - ("Custom", "Custom", "Custom"), - ("0x00", "Dirt", "Dirt (aka Earth)"), - ("0x01", "Sand", "Sand"), - ("0x02", "Stone", "Stone"), - ("0x03", "Jabu", "Jabu-Jabu flesh (aka Wet Stone)"), - ("0x04", "Shallow Water", "Shallow Water"), - ("0x05", "Deep Water", "Deep Water"), - ("0x06", "Tall Grass", "Tall Grass"), - ("0x07", "Lava", "Lava (aka Goo)"), - ("0x08", "Grass", "Grass (aka Earth 2)"), - ("0x09", "Bridge", "Bridge (aka Wooden Plank)"), - ("0x0A", "Wood", "Wood (aka Packed Earth)"), - ("0x0B", "Soft Dirt", "Soft Dirt (aka Earth 3)"), - ("0x0C", "Ice", "Ice (aka Ceramic)"), - ("0x0D", "Carpet", "Carpet (aka Loose Earth)"), -] - -enum_conveyor_speed = [ - ("Custom", "Custom", "Custom"), - ("0x00", "None", "None"), - ("0x01", "Slow", "Slow"), - ("0x02", "Medium", "Medium"), - ("0x03", "Fast", "Fast"), -] - ootEnumCameraCrawlspaceSType = [ ("Custom", "Custom", "Custom"), ("CAM_SET_CRAWLSPACE", "Crawlspace", "Crawlspace"), diff --git a/fast64_internal/z64/collision/properties.py b/fast64_internal/z64/collision/properties.py index 47980d2c7..09a941859 100644 --- a/fast64_internal/z64/collision/properties.py +++ b/fast64_internal/z64/collision/properties.py @@ -7,13 +7,7 @@ from ...game_data import game_data from ...utility import prop_split from ..utility import drawEnumWithCustom -from .constants import ( - ootEnumWallSetting, - ootEnumConveyer, - enum_conveyor_speed, - ootEnumCollisionTerrain, - ootEnumCollisionSound, -) +from .constants import ootEnumConveyer class OOTCollisionExportSettings(PropertyGroup): @@ -69,7 +63,7 @@ class OOTMaterialCollisionProperty(PropertyGroup): floorSettingCustom: StringProperty(default="0x00") floorSetting: EnumProperty(items=lambda self, context: game_data.z64.get_enum("floor_property"), default=1) wallSettingCustom: StringProperty(default="0x00") - wallSetting: EnumProperty(items=ootEnumWallSetting, default="0x00") + wallSetting: EnumProperty(items=lambda self, context: game_data.z64.get_enum("wall_type"), default=1) floorPropertyCustom: StringProperty(default="0x00") floorProperty: EnumProperty(items=lambda self, context: game_data.z64.get_enum("floor_type"), default=1) exitID: IntProperty(default=0, min=0) @@ -77,16 +71,16 @@ class OOTMaterialCollisionProperty(PropertyGroup): isWallDamage: BoolProperty() conveyorOption: EnumProperty(items=ootEnumConveyer) conveyorRotation: FloatProperty(min=0, max=2 * math.pi, subtype="ANGLE") - conveyorSpeed: EnumProperty(items=enum_conveyor_speed, default="0x00") + conveyorSpeed: EnumProperty(items=lambda self, context: game_data.z64.get_enum("conveyor_speed"), default=1) conveyorSpeedCustom: StringProperty(default="0x00") conveyorKeepMomentum: BoolProperty() hookshotable: BoolProperty() echo: StringProperty(default="0x00") lightingSetting: IntProperty(default=0, min=0) terrainCustom: StringProperty(default="0x00") - terrain: EnumProperty(items=ootEnumCollisionTerrain, default="0x00") + terrain: EnumProperty(items=lambda self, context: game_data.z64.get_enum("floor_effect"), default=1) soundCustom: StringProperty(default="0x00") - sound: EnumProperty(items=ootEnumCollisionSound, default="0x00") + sound: EnumProperty(items=lambda self, context: game_data.z64.get_enum("surface_material"), default=1) def draw_props(self, layout: UILayout): layout.prop( @@ -100,8 +94,8 @@ def draw_props(self, layout: UILayout): prop_split(layout, self, "cameraID", "Camera ID") prop_split(layout, self, "echo", "Echo") prop_split(layout, self, "lightingSetting", "Lighting") - drawEnumWithCustom(layout, self, "terrain", "Terrain", "") - drawEnumWithCustom(layout, self, "sound", "Sound", "") + drawEnumWithCustom(layout, self, "terrain", "Floor Effect", "") + drawEnumWithCustom(layout, self, "sound", "Surface Material", "") layout.prop(self, "eponaBlock", text="Blocks Epona") layout.prop(self, "decreaseHeight", text="Decrease Height 1 Unit") @@ -109,7 +103,7 @@ def draw_props(self, layout: UILayout): layout.prop(self, "hookshotable", text="Hookshotable") drawEnumWithCustom(layout, self, "floorSetting", "Floor Property", "") - drawEnumWithCustom(layout, self, "wallSetting", "Wall Setting", "") + drawEnumWithCustom(layout, self, "wallSetting", "Wall Type", "") drawEnumWithCustom(layout, self, "floorProperty", "Floor Type", "") layout.prop(self, "ignoreCameraCollision", text="Ignore Camera Collision") diff --git a/fast64_internal/z64/constants.py b/fast64_internal/z64/constants.py index d12ef01ac..120607edf 100644 --- a/fast64_internal/z64/constants.py +++ b/fast64_internal/z64/constants.py @@ -64,127 +64,6 @@ ("0x00", "0x00", "0x00"), ] -ootEnumMusicSeq = [ - # see https://github.com/zeldaret/oot/blob/9f09505d34619883748a7dab05071883281c14fd/include/sequence.h#L4-L118 - ("Custom", "Custom", "Custom"), - ("NA_BGM_GENERAL_SFX", "General Sound Effects", "General Sound Effects"), - ("NA_BGM_NATURE_AMBIENCE", "Nature Ambiance", "Nature Ambiance"), - ("NA_BGM_FIELD_LOGIC", "Hyrule Field", "Hyrule Field"), - ( - "NA_BGM_FIELD_INIT", - "Hyrule Field (Initial Segment From Loading Area)", - "Hyrule Field (Initial Segment From Loading Area)", - ), - ("NA_BGM_FIELD_DEFAULT_1", "Hyrule Field (Moving Segment 1)", "Hyrule Field (Moving Segment 1)"), - ("NA_BGM_FIELD_DEFAULT_2", "Hyrule Field (Moving Segment 2)", "Hyrule Field (Moving Segment 2)"), - ("NA_BGM_FIELD_DEFAULT_3", "Hyrule Field (Moving Segment 3)", "Hyrule Field (Moving Segment 3)"), - ("NA_BGM_FIELD_DEFAULT_4", "Hyrule Field (Moving Segment 4)", "Hyrule Field (Moving Segment 4)"), - ("NA_BGM_FIELD_DEFAULT_5", "Hyrule Field (Moving Segment 5)", "Hyrule Field (Moving Segment 5)"), - ("NA_BGM_FIELD_DEFAULT_6", "Hyrule Field (Moving Segment 6)", "Hyrule Field (Moving Segment 6)"), - ("NA_BGM_FIELD_DEFAULT_7", "Hyrule Field (Moving Segment 7)", "Hyrule Field (Moving Segment 7)"), - ("NA_BGM_FIELD_DEFAULT_8", "Hyrule Field (Moving Segment 8)", "Hyrule Field (Moving Segment 8)"), - ("NA_BGM_FIELD_DEFAULT_9", "Hyrule Field (Moving Segment 9)", "Hyrule Field (Moving Segment 9)"), - ("NA_BGM_FIELD_DEFAULT_A", "Hyrule Field (Moving Segment 10)", "Hyrule Field (Moving Segment 10)"), - ("NA_BGM_FIELD_DEFAULT_B", "Hyrule Field (Moving Segment 11)", "Hyrule Field (Moving Segment 11)"), - ("NA_BGM_FIELD_ENEMY_INIT", "Hyrule Field (Enemy Approaches)", "Hyrule Field (Enemy Approaches)"), - ("NA_BGM_FIELD_ENEMY_1", "Hyrule Field (Enemy Near Segment 1)", "Hyrule Field (Enemy Near Segment 1)"), - ("NA_BGM_FIELD_ENEMY_2", "Hyrule Field (Enemy Near Segment 2)", "Hyrule Field (Enemy Near Segment 2)"), - ("NA_BGM_FIELD_ENEMY_3", "Hyrule Field (Enemy Near Segment 3)", "Hyrule Field (Enemy Near Segment 3)"), - ("NA_BGM_FIELD_ENEMY_4", "Hyrule Field (Enemy Near Segment 4)", "Hyrule Field (Enemy Near Segment 4)"), - ("NA_BGM_FIELD_STILL_1", "Hyrule Field (Standing Still Segment 1)", "Hyrule Field (Standing Still Segment 1)"), - ("NA_BGM_FIELD_STILL_2", "Hyrule Field (Standing Still Segment 2)", "Hyrule Field (Standing Still Segment 2)"), - ("NA_BGM_FIELD_STILL_3", "Hyrule Field (Standing Still Segment 3)", "Hyrule Field (Standing Still Segment 3)"), - ("NA_BGM_FIELD_STILL_4", "Hyrule Field (Standing Still Segment 4)", "Hyrule Field (Standing Still Segment 4)"), - ("NA_BGM_DUNGEON", "Dodongo's Cavern", "Dodongo's Cavern"), - ("NA_BGM_KAKARIKO_ADULT", "Kakariko Village (Adult)", "Kakariko Village (Adult)"), - ("NA_BGM_ENEMY", "Enemy Battle", "Enemy Battle"), - ("NA_BGM_BOSS", "Boss Battle 00", "Boss Battle 00"), - ("NA_BGM_INSIDE_DEKU_TREE", "Inside the Deku Tree", "Inside the Deku Tree"), - ("NA_BGM_MARKET", "Market", "Market"), - ("NA_BGM_TITLE", "Title Theme", "Title Theme"), - ("NA_BGM_LINK_HOUSE", "Link's House", "Link's House"), - ("NA_BGM_GAME_OVER", "Game Over", "Game Over"), - ("NA_BGM_BOSS_CLEAR", "Boss Clear", "Boss Clear"), - ("NA_BGM_ITEM_GET", "Item Get", "Item Get"), - ("NA_BGM_OPENING_GANON", "Opening Ganon", "Opening Ganon"), - ("NA_BGM_HEART_GET", "Heart Get", "Heart Get"), - ("NA_BGM_OCA_LIGHT", "Prelude Of Light", "Prelude Of Light"), - ("NA_BGM_JABU_JABU", "Inside Jabu-Jabu's Belly", "Inside Jabu-Jabu's Belly"), - ("NA_BGM_KAKARIKO_KID", "Kakariko Village (Child)", "Kakariko Village (Child)"), - ("NA_BGM_GREAT_FAIRY", "Great Fairy's Fountain", "Great Fairy's Fountain"), - ("NA_BGM_ZELDA_THEME", "Zelda's Theme", "Zelda's Theme"), - ("NA_BGM_FIRE_TEMPLE", "Fire Temple", "Fire Temple"), - ("NA_BGM_OPEN_TRE_BOX", "Open Treasure Chest", "Open Treasure Chest"), - ("NA_BGM_FOREST_TEMPLE", "Forest Temple", "Forest Temple"), - ("NA_BGM_COURTYARD", "Hyrule Castle Courtyard", "Hyrule Castle Courtyard"), - ("NA_BGM_GANON_TOWER", "Ganondorf's Theme", "Ganondorf's Theme"), - ("NA_BGM_LONLON", "Lon Lon Ranch", "Lon Lon Ranch"), - ("NA_BGM_GORON_CITY", "Goron City", "Goron City"), - ("NA_BGM_FIELD_MORNING", "Hyrule Field Morning Theme", "Hyrule Field Morning Theme"), - ("NA_BGM_SPIRITUAL_STONE", "Spiritual Stone Get", "Spiritual Stone Get"), - ("NA_BGM_OCA_BOLERO", "Bolero of Fire", "Bolero of Fire"), - ("NA_BGM_OCA_MINUET", "Minuet of Woods", "Minuet of Woods"), - ("NA_BGM_OCA_SERENADE", "Serenade of Water", "Serenade of Water"), - ("NA_BGM_OCA_REQUIEM", "Requiem of Spirit", "Requiem of Spirit"), - ("NA_BGM_OCA_NOCTURNE", "Nocturne of Shadow", "Nocturne of Shadow"), - ("NA_BGM_MINI_BOSS", "Mini-Boss Battle", "Mini-Boss Battle"), - ("NA_BGM_SMALL_ITEM_GET", "Obtain Small Item", "Obtain Small Item"), - ("NA_BGM_TEMPLE_OF_TIME", "Temple of Time", "Temple of Time"), - ("NA_BGM_EVENT_CLEAR", "Escape from Lon Lon Ranch", "Escape from Lon Lon Ranch"), - ("NA_BGM_KOKIRI", "Kokiri Forest", "Kokiri Forest"), - ("NA_BGM_OCA_FAIRY_GET", "Obtain Fairy Ocarina", "Obtain Fairy Ocarina"), - ("NA_BGM_SARIA_THEME", "Lost Woods", "Lost Woods"), - ("NA_BGM_SPIRIT_TEMPLE", "Spirit Temple", "Spirit Temple"), - ("NA_BGM_HORSE", "Horse Race", "Horse Race"), - ("NA_BGM_HORSE_GOAL", "Horse Race Goal", "Horse Race Goal"), - ("NA_BGM_INGO", "Ingo's Theme", "Ingo's Theme"), - ("NA_BGM_MEDALLION_GET", "Obtain Medallion", "Obtain Medallion"), - ("NA_BGM_OCA_SARIA", "Ocarina Saria's Song", "Ocarina Saria's Song"), - ("NA_BGM_OCA_EPONA", "Ocarina Epona's Song", "Ocarina Epona's Song"), - ("NA_BGM_OCA_ZELDA", "Ocarina Zelda's Lullaby", "Ocarina Zelda's Lullaby"), - ("NA_BGM_OCA_SUNS", "Sun's Song", "Sun's Song"), - ("NA_BGM_OCA_TIME", "Song of Time", "Song of Time"), - ("NA_BGM_OCA_STORM", "Song of Storms", "Song of Storms"), - ("NA_BGM_NAVI_OPENING", "Fairy Flying", "Fairy Flying"), - ("NA_BGM_DEKU_TREE_CS", "Deku Tree", "Deku Tree"), - ("NA_BGM_WINDMILL", "Windmill Hut", "Windmill Hut"), - ("NA_BGM_HYRULE_CS", "Legend of Hyrule", "Legend of Hyrule"), - ("NA_BGM_MINI_GAME", "Shooting Gallery", "Shooting Gallery"), - ("NA_BGM_SHEIK", "Sheik's Theme", "Sheik's Theme"), - ("NA_BGM_ZORA_DOMAIN", "Zora's Domain", "Zora's Domain"), - ("NA_BGM_APPEAR", "Enter Zelda", "Enter Zelda"), - ("NA_BGM_ADULT_LINK", "Goodbye to Zelda", "Goodbye to Zelda"), - ("NA_BGM_MASTER_SWORD", "Master Sword", "Master Sword"), - ("NA_BGM_INTRO_GANON", "Ganon Intro", "Ganon Intro"), - ("NA_BGM_SHOP", "Shop", "Shop"), - ("NA_BGM_CHAMBER_OF_SAGES", "Chamber of the Sages", "Chamber of the Sages"), - ("NA_BGM_FILE_SELECT", "File Select", "File Select"), - ("NA_BGM_ICE_CAVERN", "Ice Cavern", "Ice Cavern"), - ("NA_BGM_DOOR_OF_TIME", "Open Door of Temple of Time", "Open Door of Temple of Time"), - ("NA_BGM_OWL", "Kaepora Gaebora's Theme", "Kaepora Gaebora's Theme"), - ("NA_BGM_SHADOW_TEMPLE", "Shadow Temple", "Shadow Temple"), - ("NA_BGM_WATER_TEMPLE", "Water Temple", "Water Temple"), - ("NA_BGM_BRIDGE_TO_GANONS", "Ganon's Castle Bridge", "Ganon's Castle Bridge"), - ("NA_BGM_OCARINA_OF_TIME", "Ocarina of Time", "Ocarina of Time"), - ("NA_BGM_GERUDO_VALLEY", "Gerudo Valley", "Gerudo Valley"), - ("NA_BGM_POTION_SHOP", "Potion Shop", "Potion Shop"), - ("NA_BGM_KOTAKE_KOUME", "Kotake & Koume's Theme", "Kotake & Koume's Theme"), - ("NA_BGM_ESCAPE", "Escape from Ganon's Castle", "Escape from Ganon's Castle"), - ("NA_BGM_UNDERGROUND", "Ganon's Castle Under Ground", "Ganon's Castle Under Ground"), - ("NA_BGM_GANONDORF_BOSS", "Ganondorf Battle", "Ganondorf Battle"), - ("NA_BGM_GANON_BOSS", "Ganon Battle", "Ganon Battle"), - ("NA_BGM_END_DEMO", "Seal of Six Sages", "Seal of Six Sages"), - ("NA_BGM_STAFF_1", "End Credits I", "End Credits I"), - ("NA_BGM_STAFF_2", "End Credits II", "End Credits II"), - ("NA_BGM_STAFF_3", "End Credits III", "End Credits III"), - ("NA_BGM_STAFF_4", "End Credits IV", "End Credits IV"), - ("NA_BGM_FIRE_BOSS", "King Dodongo & Volvagia Boss Battle", "King Dodongo & Volvagia Boss Battle"), - ("NA_BGM_TIMED_MINI_GAME", "Mini-Game", "Mini-Game"), - ("NA_BGM_CUTSCENE_EFFECTS", "Various Cutscene Sounds", "Various Cutscene Sounds"), - ("NA_BGM_NO_MUSIC", "No Music", "No Music"), - ("NA_BGM_NATURE_SFX_RAIN", "Nature Ambiance: Rain", "Nature Ambiance: Rain"), -] - ootEnumGlobalObject = [ ("Custom", "Custom", "Custom"), ("OBJECT_INVALID", "None", "None"), diff --git a/fast64_internal/z64/cutscene/constants.py b/fast64_internal/z64/cutscene/constants.py index d07464571..81f0fed9f 100644 --- a/fast64_internal/z64/cutscene/constants.py +++ b/fast64_internal/z64/cutscene/constants.py @@ -109,14 +109,6 @@ ("eyeOrAT", "Eye/AT Point", "Single Eye/AT point (not recommended)"), ] -# Note: `CS_CMD_UNIMPLEMENTED_16` is an unused actor cue -ootEnumCSActorCueListCommandType = [ - item - for item in game_data.z64.enums.enum_cs_cmd - if "actor_cue" in item[0] or "player_cue" in item[0] or item[0] == "unimplemented_16" -] -ootEnumCSActorCueListCommandType.sort() -ootEnumCSActorCueListCommandType.insert(0, ("Custom", "Custom", "Custom")) ootCSLegacyToNewCmdNames = { "CS_CAM_POS_LIST": "CS_CAM_EYE_SPLINE", diff --git a/fast64_internal/z64/cutscene/motion/operators.py b/fast64_internal/z64/cutscene/motion/operators.py index 9a47a513d..b96c8d354 100644 --- a/fast64_internal/z64/cutscene/motion/operators.py +++ b/fast64_internal/z64/cutscene/motion/operators.py @@ -1,14 +1,14 @@ import bpy +import mathutils from bpy.types import Object, Operator, Context, Armature from bpy.utils import register_class, unregister_class from bpy.props import StringProperty, EnumProperty, BoolProperty -import mathutils from dataclasses import dataclass + from ....utility import PluginError from ....game_data import game_data from ..classes import CutsceneObjectFactory -from ..constants import ootEnumCSActorCueListCommandType from ..preview import initFirstFrame, setupCompositorNodes from .utility import ( setupActorCuePreview, @@ -418,7 +418,7 @@ class OOT_SearchActorCueCmdTypeEnumOperator(Operator): bl_property = "commandType" bl_options = {"REGISTER", "UNDO"} - commandType: EnumProperty(items=ootEnumCSActorCueListCommandType, default="actor_cue_0_0") + commandType: EnumProperty(items=lambda self, context: game_data.z64.get_enum("cs_actor_cue_list"), default=1) objName: StringProperty() def execute(self, context): @@ -440,7 +440,7 @@ class OOT_SearchPlayerCueIdEnumOperator(Operator): bl_property = "playerCueID" bl_options = {"REGISTER", "UNDO"} - playerCueID: EnumProperty(items=game_data.z64.enums.enum_cs_player_cue_id, default="cueid_none") + playerCueID: EnumProperty(items=lambda self, context: game_data.z64.get_enum("cs_player_cue_id"), default=1) objName: StringProperty() def execute(self, context): diff --git a/fast64_internal/z64/cutscene/motion/properties.py b/fast64_internal/z64/cutscene/motion/properties.py index fbc0de3ec..d062342b9 100644 --- a/fast64_internal/z64/cutscene/motion/properties.py +++ b/fast64_internal/z64/cutscene/motion/properties.py @@ -6,7 +6,7 @@ from ...upgrade import upgradeCutsceneMotion from ...utility import getEnumName from ....game_data import game_data -from ..constants import ootEnumCSMotionCamMode, ootEnumCSActorCueListCommandType +from ..constants import ootEnumCSMotionCamMode from .operators import ( CutsceneCmdAddActorCue, @@ -33,7 +33,9 @@ def getNextCuesStartFrame(self): class CutsceneCmdActorCueListProperty(PropertyGroup): commandType: EnumProperty( - items=ootEnumCSActorCueListCommandType, name="CS Actor Cue Command Type", default="actor_cue_0_0" + items=lambda self, context: game_data.z64.get_enum("cs_actor_cue_list"), + name="CS Actor Cue Command Type", + default=1, ) commandTypeCustom: StringProperty(name="CS Actor Cue Command Type Custom") actorCueListToPreview: PointerProperty( @@ -58,7 +60,7 @@ def draw_props(self, layout: UILayout, isPreview: bool, labelPrefix: str, objNam OOT_SearchActorCueCmdTypeEnumOperator.bl_idname, icon="VIEWZOOM", text="Command Type:" ) searchOp.objName = objName - searchBox.label(text=getEnumName(ootEnumCSActorCueListCommandType, self.commandType)) + searchBox.label(text=getEnumName(game_data.z64.get_enum("cs_actor_cue_list"), self.commandType)) if self.commandType == "Custom": split = box.split(factor=0.5) @@ -87,7 +89,7 @@ class CutsceneCmdActorCueProperty(PropertyGroup): get=lambda self: getNextCuesStartFrame(self), ) - playerCueID: EnumProperty(items=game_data.z64.enums.enum_cs_player_cue_id, default="cueid_none") + playerCueID: EnumProperty(items=lambda self, context: game_data.z64.get_enum("cs_player_cue_id"), default=1) cueActionID: StringProperty( name="Action ID", default="0x0001", description="Actor action. Meaning is unique for each different actor." ) diff --git a/fast64_internal/z64/cutscene/operators.py b/fast64_internal/z64/cutscene/operators.py index 3e4ddfdc5..257fdf362 100644 --- a/fast64_internal/z64/cutscene/operators.py +++ b/fast64_internal/z64/cutscene/operators.py @@ -135,7 +135,7 @@ class OOT_SearchCSDestinationEnumOperator(Operator): bl_property = "csDestination" bl_options = {"REGISTER", "UNDO"} - csDestination: EnumProperty(items=game_data.z64.enums.enum_cs_destination, default="cutscene_map_ganon_horse") + csDestination: EnumProperty(items=lambda self, context: game_data.z64.get_enum("cs_destination"), default=1) objName: StringProperty() def execute(self, context): @@ -157,7 +157,7 @@ class OOT_SearchCSSeqOperator(Operator): bl_property = "seqId" bl_options = {"REGISTER", "UNDO"} - seqId: EnumProperty(items=game_data.z64.enums.enum_seq_id, default="general_sfx") + seqId: EnumProperty(items=lambda self, context: game_data.z64.get_enum("seq_id"), default=1) itemIndex: IntProperty() listType: StringProperty() diff --git a/fast64_internal/z64/cutscene/properties.py b/fast64_internal/z64/cutscene/properties.py index 86243c78e..bbd4cbf3f 100644 --- a/fast64_internal/z64/cutscene/properties.py +++ b/fast64_internal/z64/cutscene/properties.py @@ -113,13 +113,15 @@ class OOTCSTextProperty(OOTCutsceneCommon, PropertyGroup): # subprops textID: StringProperty(name="", default="0x0000") ocarinaAction: EnumProperty( - name="Ocarina Action", items=game_data.z64.enums.enum_ocarina_song_action_id, default="teach_minuet" + name="Ocarina Action", items=lambda self, context: game_data.z64.get_enum("cs_song_action_id"), default=1 ) ocarinaActionCustom: StringProperty(default="OCARINA_ACTION_CUSTOM") topOptionTextID: StringProperty(name="", default="0x0000") bottomOptionTextID: StringProperty(name="", default="0x0000") ocarinaMessageId: StringProperty(name="", default="0x0000") - csTextType: EnumProperty(name="Text Type", items=game_data.z64.enums.enum_cs_text_type, default="normal") + csTextType: EnumProperty( + name="Text Type", items=lambda self, context: game_data.z64.get_enum("cs_text_type"), default=1 + ) csTextTypeCustom: StringProperty(default="CS_TEXT_CUSTOM") def getName(self): @@ -152,10 +154,10 @@ class OOTCSTimeProperty(OOTCutsceneCommon, PropertyGroup): class OOTCSSeqProperty(OOTCutsceneCommon, PropertyGroup): attrName = "seqList" subprops = ["csSeqID", "startFrame", "endFrame"] - csSeqID: EnumProperty(name="Seq ID", items=game_data.z64.enums.enum_seq_id, default="general_sfx") + csSeqID: EnumProperty(name="Seq ID", items=lambda self, context: game_data.z64.get_enum("seq_id"), default=1) csSeqIDCustom: StringProperty(default="NA_BGM_CUSTOM") csSeqPlayer: EnumProperty( - name="Seq Player", items=game_data.z64.enums.enum_cs_fade_out_seq_player, default="fade_out_fanfare" + name="Seq Player", items=lambda self, context: game_data.z64.get_enum("cs_seq_player"), default=1 ) csSeqPlayerCustom: StringProperty(default="CS_FADE_OUT_CUSTOM") @@ -171,7 +173,7 @@ def filterName(self, name, listProp): class OOTCSMiscProperty(OOTCutsceneCommon, PropertyGroup): attrName = "miscList" subprops = ["csMiscType", "startFrame", "endFrame"] - csMiscType: EnumProperty(name="Type", items=game_data.z64.enums.enum_cs_misc_type, default="rain") + csMiscType: EnumProperty(name="Type", items=lambda self, context: game_data.z64.get_enum("cs_misc_type"), default=1) csMiscTypeCustom: StringProperty(default="CS_MISC_CUSTOM") @@ -197,7 +199,7 @@ class OOTCSListProperty(PropertyGroup): miscList: CollectionProperty(type=OOTCSMiscProperty) rumbleList: CollectionProperty(type=OOTCSRumbleProperty) - transitionType: EnumProperty(items=game_data.z64.enums.enum_cs_transition_type, default="gray_fill_in") + transitionType: EnumProperty(items=lambda self, context: game_data.z64.get_enum("cs_transition_type"), default=1) transitionTypeCustom: StringProperty(default="CS_TRANS_CUSTOM") transitionStartFrame: IntProperty(name="", default=0, min=0) transitionEndFrame: IntProperty(name="", default=1, min=0) @@ -360,7 +362,7 @@ class OOTCutsceneProperty(PropertyGroup): csEndFrame: IntProperty(name="End Frame", min=0, default=100) csUseDestination: BoolProperty(name="Cutscene Destination (Scene Change)") csDestination: EnumProperty( - name="Destination", items=game_data.z64.enums.enum_cs_destination, default="cutscene_map_ganon_horse" + name="Destination", items=lambda self, context: game_data.z64.get_enum("cs_destination"), default=1 ) csDestinationCustom: StringProperty(default="CS_DEST_CUSTOM") csDestinationStartFrame: IntProperty(name="Start Frame", min=0, default=99) diff --git a/fast64_internal/z64/exporter/collision/__init__.py b/fast64_internal/z64/exporter/collision/__init__.py index 7b446dd72..f3e37b4c7 100644 --- a/fast64_internal/z64/exporter/collision/__init__.py +++ b/fast64_internal/z64/exporter/collision/__init__.py @@ -9,6 +9,7 @@ from bpy.ops import object from typing import Optional +from ....game_data import game_data from ....utility import PluginError, CData, toAlnum, unhideAllAndGetHiddenState, restoreHiddenState, indent from ...utility import ( OOTObjectCategorizer, @@ -175,14 +176,14 @@ def getCollisionData(dataHolder: Optional[Object], transform: Matrix, useMacros: surfaceType = SurfaceType( colProp.cameraID, colProp.exitID, - Utility.getPropValue(colProp, "floorProperty"), + game_data.z64.get_enum_value("floor_type", Utility.getPropValue(colProp, "floorProperty")), 0, # unused? - Utility.getPropValue(colProp, "wallSetting"), - Utility.getPropValue(colProp, "floorSetting"), + game_data.z64.get_enum_value("wall_type", Utility.getPropValue(colProp, "wallSetting")), + game_data.z64.get_enum_value("floor_property", Utility.getPropValue(colProp, "floorSetting")), colProp.decreaseHeight, colProp.eponaBlock, - Utility.getPropValue(colProp, "sound"), - Utility.getPropValue(colProp, "terrain"), + game_data.z64.get_enum_value("surface_material", Utility.getPropValue(colProp, "sound")), + game_data.z64.get_enum_value("floor_effect", Utility.getPropValue(colProp, "terrain")), colProp.lightingSetting, int(colProp.echo, base=16), colProp.hookshotable, diff --git a/fast64_internal/z64/exporter/scene/general.py b/fast64_internal/z64/exporter/scene/general.py index 768d1ef41..32da7c5e2 100644 --- a/fast64_internal/z64/exporter/scene/general.py +++ b/fast64_internal/z64/exporter/scene/general.py @@ -4,6 +4,7 @@ from dataclasses import dataclass from bpy.types import Object +from ....game_data import game_data from ....utility import PluginError, CData, exportColor, ootGetBaseOrCustomLight, hexOrDecInt, indent from ...scene.properties import OOTSceneHeaderProperty, OOTLightProperty, OOTLightGroupProperty from ...utility import getEvalParamsInt @@ -258,7 +259,7 @@ def new(props: OOTSceneHeaderProperty, sceneObj: Object): Utility.getPropValue(props, "title_card_name"), Utility.getPropValue(props, "skyboxID"), Utility.getPropValue(props, "skyboxCloudiness"), - Utility.getPropValue(props, "musicSeq"), + game_data.z64.get_enum_value("seq_id", Utility.getPropValue(props, "musicSeq")), Utility.getPropValue(props, "nightSeq"), Utility.getPropValue(props, "audioSessionPreset"), Utility.getPropValue(props, "mapLocation"), diff --git a/fast64_internal/z64/importer/scene_collision.py b/fast64_internal/z64/importer/scene_collision.py index e53936873..367035844 100644 --- a/fast64_internal/z64/importer/scene_collision.py +++ b/fast64_internal/z64/importer/scene_collision.py @@ -12,19 +12,12 @@ from ..exporter.collision.polygons import CollisionPoly from ..exporter.collision.waterbox import WaterBox from ..collision.properties import OOTMaterialCollisionProperty +from ..collision.constants import ootEnumCameraCrawlspaceSType from ..f3d_writer import getColliderMat from ..utility import setCustomProperty, ootParseRotation -from .utility import getDataMatch, getBits, checkBit, createCurveFromPoints, stripName +from .utility import getDataMatch, createCurveFromPoints, stripName from .classes import SharedSceneData -from ..collision.constants import ( - ootEnumWallSetting, - ootEnumCollisionTerrain, - ootEnumCollisionSound, - ootEnumCameraCrawlspaceSType, - enum_conveyor_speed, -) - def parseCrawlSpaceData( setting: str, sceneData: str, posDataName: str, index: int, count: int, objName: str, orderIndex: str @@ -171,14 +164,23 @@ def parseWaterBoxes( parentObject(parent, waterBoxObj) +def set_surface_prop(col_props: OOTMaterialCollisionProperty, prop: str, enum_key: str, value: str): + item = game_data.z64.enums.enumByKey[enum_key].item_by_index.get(int(value, 16)) + + if item is not None: + setattr(col_props, prop, item.key) + else: + setCustomProperty(col_props, prop, value, game_data.z64.get_enum(enum_key)) + + def parseSurfaceParams( surface_type: SurfaceType, collision_poly: CollisionPoly, col_props: OOTMaterialCollisionProperty ): col_props.eponaBlock = surface_type.isHorseBlocked col_props.decreaseHeight = surface_type.isSoft - setCustomProperty(col_props, "floorSetting", surface_type.floorProperty, game_data.z64.get_enum("floor_property")) - setCustomProperty(col_props, "wallSetting", surface_type.wallType, ootEnumWallSetting) - setCustomProperty(col_props, "floorProperty", surface_type.floorType, game_data.z64.get_enum("floor_type")) + set_surface_prop(col_props, "floorSetting", "floor_property", surface_type.floorProperty) + set_surface_prop(col_props, "wallSetting", "wall_type", surface_type.wallType) + set_surface_prop(col_props, "floorProperty", "floor_type", surface_type.floorType) col_props.exitID = surface_type.exitIndex col_props.cameraID = surface_type.bgCamIndex col_props.isWallDamage = surface_type.isWallDamage @@ -186,7 +188,7 @@ def parseSurfaceParams( col_props.conveyorRotation = (surface_type.conveyorDirection / 0x3F) * (2 * math.pi) col_props.conveyorSpeed = "Custom" col_props.conveyorSpeedCustom = str(surface_type.conveyorSpeed) - setCustomProperty(col_props, "conveyorSpeed", surface_type.conveyorSpeed, enum_conveyor_speed) + set_surface_prop(col_props, "conveyorSpeed", "conveyor_speed", surface_type.conveyorSpeed) if isinstance(surface_type.conveyorSpeed, int): speed_int = surface_type.conveyorSpeed @@ -203,8 +205,8 @@ def parseSurfaceParams( col_props.hookshotable = surface_type.canHookshot col_props.echo = str(surface_type.echo) col_props.lightingSetting = surface_type.lightSetting - setCustomProperty(col_props, "terrain", str(surface_type.floorEffect), ootEnumCollisionTerrain) - setCustomProperty(col_props, "sound", str(surface_type.material), ootEnumCollisionSound) + set_surface_prop(col_props, "terrain", "floor_effect", str(surface_type.floorEffect)) + set_surface_prop(col_props, "sound", "surface_material", str(surface_type.material)) col_props.ignoreCameraCollision = collision_poly.ignoreCamera col_props.ignoreActorCollision = collision_poly.ignoreEntity diff --git a/fast64_internal/z64/importer/scene_header.py b/fast64_internal/z64/importer/scene_header.py index 048ebc69a..7c5d3251b 100644 --- a/fast64_internal/z64/importer/scene_header.py +++ b/fast64_internal/z64/importer/scene_header.py @@ -477,7 +477,7 @@ def parseSceneCommands( else: enum_id = game_data.z64.enums.enumByKey["seq_id"].item_by_index[int(args[2])].id - setCustomProperty(sceneHeader, "musicSeq", enum_id, game_data.z64.get_enum("musicSeq")) + setCustomProperty(sceneHeader, "musicSeq", enum_id, game_data.z64.get_enum("seq_id")) command_list.remove(command) elif command == "SCENE_CMD_ROOM_LIST": # Delay until actor cutscenes are processed diff --git a/fast64_internal/z64/room/operators.py b/fast64_internal/z64/room/operators.py index e148ba540..e0f6e2404 100644 --- a/fast64_internal/z64/room/operators.py +++ b/fast64_internal/z64/room/operators.py @@ -12,7 +12,7 @@ class OOT_SearchObjectEnumOperator(Operator): bl_property = "objectKey" bl_options = {"REGISTER", "UNDO"} - objectKey: EnumProperty(items=game_data.z64.objects.ootEnumObjectKey, default="obj_human") + objectKey: EnumProperty(items=lambda self, context: game_data.z64.get_enum("object_key"), default=1) headerIndex: IntProperty(default=0, min=0) index: IntProperty(default=0, min=0) objName: StringProperty() diff --git a/fast64_internal/z64/room/properties.py b/fast64_internal/z64/room/properties.py index 6ad40e269..b4fb9dfe2 100644 --- a/fast64_internal/z64/room/properties.py +++ b/fast64_internal/z64/room/properties.py @@ -37,7 +37,7 @@ class OOTObjectProperty(PropertyGroup): expandTab: BoolProperty(name="Expand Tab") - objectKey: EnumProperty(items=game_data.z64.objects.ootEnumObjectKey, default="obj_human") + objectKey: EnumProperty(items=lambda self, context: game_data.z64.get_enum("object_key"), default=1) objectIDCustom: StringProperty(default="OBJECT_CUSTOM") @staticmethod diff --git a/fast64_internal/z64/scene/operators.py b/fast64_internal/z64/scene/operators.py index 3e4b302bf..43bcc0239 100644 --- a/fast64_internal/z64/scene/operators.py +++ b/fast64_internal/z64/scene/operators.py @@ -6,9 +6,11 @@ from bpy.utils import register_class, unregister_class from bpy.ops import object from mathutils import Matrix, Vector + +from ...game_data import game_data from ...utility import PluginError, raisePluginError, ootGetSceneOrRoomHeader from ..utility import ExportInfo, RemoveInfo, sceneNameFromID -from ..constants import ootEnumMusicSeq, ootEnumSceneID +from ..constants import ootEnumSceneID from ..importer import parseScene from ..exporter import SceneExport, Files @@ -69,7 +71,7 @@ class OOT_SearchMusicSeqEnumOperator(Operator): bl_property = "ootMusicSeq" bl_options = {"REGISTER", "UNDO"} - ootMusicSeq: EnumProperty(items=ootEnumMusicSeq, default="NA_BGM_FIELD_LOGIC") + ootMusicSeq: EnumProperty(items=lambda self, context: game_data.z64.get_enum("seq_id"), default=1) headerIndex: IntProperty(default=0, min=0) objName: StringProperty() diff --git a/fast64_internal/z64/scene/properties.py b/fast64_internal/z64/scene/properties.py index 5338de3cb..33ff44985 100644 --- a/fast64_internal/z64/scene/properties.py +++ b/fast64_internal/z64/scene/properties.py @@ -23,7 +23,6 @@ from ..animated_mats.properties import Z64_AnimatedMaterial from ..constants import ( - ootEnumMusicSeq, ootEnumSceneID, ootEnumGlobalObject, ootEnumNaviHints, @@ -271,7 +270,9 @@ class OOTSceneHeaderProperty(PropertyGroup): expandTab: BoolProperty(name="Expand Tab") usePreviousHeader: BoolProperty(name="Use Previous Header", default=True) - globalObject: EnumProperty(name="Global Object", default="OBJECT_GAMEPLAY_DANGEON_KEEP", items=ootEnumGlobalObject) + globalObject: EnumProperty( + name="Global Object", default=2, items=lambda self, context: game_data.z64.get_enum("globalObject") + ) globalObjectCustom: StringProperty(name="Global Object Custom", default="0x00") naviCup: EnumProperty(name="Navi Hints", default="0x00", items=ootEnumNaviHints) naviCupCustom: StringProperty(name="Navi Hints Custom", default="0x00") @@ -297,7 +298,9 @@ class OOTSceneHeaderProperty(PropertyGroup): cameraMode: EnumProperty(name="Camera Mode", items=ootEnumCameraMode, default="0x00") cameraModeCustom: StringProperty(name="Camera Mode Custom", default="0x00") - musicSeq: EnumProperty(name="Music Sequence", items=ootEnumMusicSeq, default="NA_BGM_FIELD_LOGIC") + musicSeq: EnumProperty( + name="Music Sequence", items=lambda self, context: game_data.z64.get_enum("seq_id"), default=1 + ) musicSeqCustom: StringProperty(name="Music Sequence ID", default="0x00") nightSeq: EnumProperty( name="Nighttime SFX", items=lambda self, context: game_data.z64.get_enum("nature_id"), default=1 diff --git a/fast64_internal/z64/utility.py b/fast64_internal/z64/utility.py index e2a222525..2be790b6d 100644 --- a/fast64_internal/z64/utility.py +++ b/fast64_internal/z64/utility.py @@ -613,6 +613,12 @@ def setCustomProperty( if value in [enumItem[0] for enumItem in enumList]: setattr(data, prop, value) return + elif value in [enumItem[2] for enumItem in enumList]: + for item in enumList: + if value == item[2]: + value = item[0] + setattr(data, prop, value) + return else: try: numberValue = hexOrDecInt(value)