From 4a576f45eebbe4195162e916d8da6e342d854045 Mon Sep 17 00:00:00 2001 From: inspectredc <78732756+inspectredc@users.noreply.github.com> Date: Sat, 20 Apr 2024 15:43:35 +0100 Subject: [PATCH 01/59] Fix and Clean Up Swap Age Logic (#4061) * Split and clean up swap age logic * reorganise conditions into one statement --- soh/src/code/z_parameter.c | 262 ++++++++++++++++++++++++------------- 1 file changed, 170 insertions(+), 92 deletions(-) diff --git a/soh/src/code/z_parameter.c b/soh/src/code/z_parameter.c index a4d61f87769..449ee285424 100644 --- a/soh/src/code/z_parameter.c +++ b/soh/src/code/z_parameter.c @@ -1436,64 +1436,62 @@ Gfx* Gfx_TextureI8(Gfx* displayListHead, void* texture, s16 textureWidth, s16 te return displayListHead; } -void Inventory_SwapAgeEquipment(void) { +void Rando_Inventory_SwapAgeEquipment(void) { s16 i; u16 shieldEquipValue; if (LINK_AGE_IN_YEARS == YEARS_CHILD) { - - for (i = 0; i < ARRAY_COUNT(gSaveContext.equips.buttonItems); i++) { if (i != 0) { - gSaveContext.childEquips.buttonItems[i] = gSaveContext.equips.buttonItems[i]; + gSaveContext.childEquips.buttonItems[i] = + gSaveContext.equips.buttonItems[i]; } else { gSaveContext.childEquips.buttonItems[i] = ITEM_SWORD_KOKIRI; } if (i != 0) { - gSaveContext.childEquips.cButtonSlots[i - 1] = gSaveContext.equips.cButtonSlots[i - 1]; + gSaveContext.childEquips.cButtonSlots[i - 1] = + gSaveContext.equips.cButtonSlots[i - 1]; } } - // When becoming adult, remove swordless flag since we'll get master sword - // (Unless Master Sword is shuffled) - // Only in rando to keep swordless link bugs in vanilla - if (IS_RANDO && !Randomizer_GetSettingValue(RSK_SHUFFLE_MASTER_SWORD)) { - Flags_UnsetInfTable(INFTABLE_SWORDLESS); - } - gSaveContext.childEquips.equipment = gSaveContext.equips.equipment; - if (gSaveContext.adultEquips.buttonItems[0] == ITEM_NONE && !(IS_RANDO && Randomizer_GetSettingValue(RSK_SHUFFLE_MASTER_SWORD) && gSaveContext.adultEquips.equipment)) { - if (!IS_RANDO || !Randomizer_GetSettingValue(RSK_SHUFFLE_MASTER_SWORD)) { - gSaveContext.equips.buttonItems[0] = ITEM_SWORD_MASTER; - } else { - gSaveContext.equips.buttonItems[0] = ITEM_NONE; - Flags_SetInfTable(INFTABLE_SWORDLESS); - } + // When becoming adult, remove swordless flag since we'll get master sword + // This gets set back appropriately later in the case of master sword shuffle + Flags_UnsetInfTable(INFTABLE_SWORDLESS); + + // This section sets up the equipment on the first time going adult. + // On master sword shuffle the check for the B button is insufficient, and so checking the equipment is completely zero-ed is needed + // (Could just always use `gSaveContext.adultEquips.equipment == 0` for rando?) + if (gSaveContext.adultEquips.buttonItems[0] == ITEM_NONE && ((IS_RANDO && !Randomizer_GetSettingValue(RSK_SHUFFLE_MASTER_SWORD)) || (gSaveContext.adultEquips.equipment == 0))) { + gSaveContext.equips.buttonItems[0] = ITEM_SWORD_MASTER; if (gSaveContext.inventory.items[SLOT_NUT] != ITEM_NONE) { gSaveContext.equips.buttonItems[1] = ITEM_NUT; gSaveContext.equips.cButtonSlots[0] = SLOT_NUT; } else { - gSaveContext.equips.buttonItems[1] = gSaveContext.equips.cButtonSlots[0] = ITEM_NONE; + gSaveContext.equips.buttonItems[1] = gSaveContext.equips.cButtonSlots[0] = + ITEM_NONE; } gSaveContext.equips.buttonItems[2] = ITEM_BOMB; gSaveContext.equips.buttonItems[3] = gSaveContext.inventory.items[SLOT_OCARINA]; gSaveContext.equips.cButtonSlots[1] = SLOT_BOMB; gSaveContext.equips.cButtonSlots[2] = SLOT_OCARINA; - gSaveContext.equips.equipment = (EQUIP_VALUE_SWORD_MASTER << (EQUIP_TYPE_SWORD * 4)) | - (EQUIP_VALUE_SHIELD_HYLIAN << (EQUIP_TYPE_SHIELD * 4)) | - (EQUIP_VALUE_TUNIC_KOKIRI << (EQUIP_TYPE_TUNIC * 4)) | - (EQUIP_VALUE_BOOTS_KOKIRI << (EQUIP_TYPE_BOOTS * 4)); + (EQUIP_VALUE_SHIELD_HYLIAN << (EQUIP_TYPE_SHIELD * 4)) | + (EQUIP_VALUE_TUNIC_KOKIRI << (EQUIP_TYPE_TUNIC * 4)) | + (EQUIP_VALUE_BOOTS_KOKIRI << (EQUIP_TYPE_BOOTS * 4)); + // In Master Sword Shuffle we want to override the equip of the master sword from the vanilla code + // First check we have the Master sword in our inventory, and if not, then unequip if (IS_RANDO && Randomizer_GetSettingValue(RSK_SHUFFLE_MASTER_SWORD) && - gSaveContext.equips.buttonItems[0] == ITEM_NONE) { + !CHECK_OWNED_EQUIP(EQUIP_TYPE_SWORD, EQUIP_INV_SWORD_MASTER)) { gSaveContext.equips.equipment &= (u16) ~(0xF << (EQUIP_TYPE_SWORD * 4)); + gSaveContext.equips.buttonItems[0] = ITEM_NONE; + Flags_SetInfTable(INFTABLE_SWORDLESS); } - // Set the dpad to nothing gSaveContext.equips.buttonItems[4] = ITEM_NONE; gSaveContext.equips.buttonItems[5] = ITEM_NONE; @@ -1505,25 +1503,25 @@ void Inventory_SwapAgeEquipment(void) { gSaveContext.equips.cButtonSlots[6] = SLOT_NONE; } else { for (i = 0; i < ARRAY_COUNT(gSaveContext.equips.buttonItems); i++) { - gSaveContext.equips.buttonItems[i] = gSaveContext.adultEquips.buttonItems[i]; + gSaveContext.equips.buttonItems[i] = + gSaveContext.adultEquips.buttonItems[i]; if (i != 0) { - gSaveContext.equips.cButtonSlots[i - 1] = gSaveContext.adultEquips.cButtonSlots[i - 1]; + gSaveContext.equips.cButtonSlots[i - 1] = + gSaveContext.adultEquips.cButtonSlots[i - 1]; } if (((gSaveContext.equips.buttonItems[i] >= ITEM_BOTTLE) && (gSaveContext.equips.buttonItems[i] <= ITEM_POE)) || ((gSaveContext.equips.buttonItems[i] >= ITEM_WEIRD_EGG) && (gSaveContext.equips.buttonItems[i] <= ITEM_CLAIM_CHECK))) { - osSyncPrintf("Register_Item_Pt(%d)=%d\n", i, gSaveContext.equips.cButtonSlots[i - 1]); gSaveContext.equips.buttonItems[i] = gSaveContext.inventory.items[gSaveContext.equips.cButtonSlots[i - 1]]; } } - // In Rando, when switching to adult for the second+ time, if a sword was not previously - // equiped in MS shuffle, then we need to set the swordless flag again - if (IS_RANDO && Randomizer_GetSettingValue(RSK_SHUFFLE_MASTER_SWORD) && + // In Master Sword Shuffle we want to set the swordless flag if no item is on the B button + if (IS_RANDO && Randomizer_GetSettingValue(RSK_SHUFFLE_MASTER_SWORD) && gSaveContext.equips.buttonItems[0] == ITEM_NONE) { Flags_SetInfTable(INFTABLE_SWORDLESS); } @@ -1531,42 +1529,32 @@ void Inventory_SwapAgeEquipment(void) { gSaveContext.equips.equipment = gSaveContext.adultEquips.equipment; } } else { - // When becoming child, set swordless flag if player doesn't have kokiri sword - // Only in rando to keep swordless link bugs in vanilla - if (IS_RANDO && CHECK_OWNED_EQUIP(EQUIP_TYPE_SWORD, EQUIP_INV_SWORD_KOKIRI) == 0) { - Flags_SetInfTable(INFTABLE_SWORDLESS); - } - - // When using enhancements, set swordless flag if player doesn't have kokiri sword or hasn't equipped a sword yet. - // Then set the child equips button items to item none to ensure kokiri sword is not equipped - if ((CVarGetInteger("gSwitchAge", 0) || CVarGetInteger("gSwitchTimeline", 0)) && (CHECK_OWNED_EQUIP(EQUIP_TYPE_SWORD, EQUIP_INV_SWORD_KOKIRI) == 0 || Flags_GetInfTable(INFTABLE_SWORDLESS))) { - Flags_SetInfTable(INFTABLE_SWORDLESS); - gSaveContext.childEquips.buttonItems[0] = ITEM_NONE; - } for (i = 0; i < ARRAY_COUNT(gSaveContext.equips.buttonItems); i++) { gSaveContext.adultEquips.buttonItems[i] = gSaveContext.equips.buttonItems[i]; if (i != 0) { - gSaveContext.adultEquips.cButtonSlots[i - 1] = gSaveContext.equips.cButtonSlots[i - 1]; + gSaveContext.adultEquips.cButtonSlots[i - 1] = + gSaveContext.equips.cButtonSlots[i - 1]; } } gSaveContext.adultEquips.equipment = gSaveContext.equips.equipment; - // Switching age using enhancements separated out to make vanilla flow clear - if (CVarGetInteger("gSwitchAge", 0) || CVarGetInteger("gSwitchTimeline", 0)) { + + if (gSaveContext.childEquips.buttonItems[0] != ITEM_NONE) { for (i = 0; i < ARRAY_COUNT(gSaveContext.equips.buttonItems); i++) { - gSaveContext.equips.buttonItems[i] = gSaveContext.childEquips.buttonItems[i]; + gSaveContext.equips.buttonItems[i] = + gSaveContext.childEquips.buttonItems[i]; if (i != 0) { - gSaveContext.equips.cButtonSlots[i - 1] = gSaveContext.childEquips.cButtonSlots[i - 1]; + gSaveContext.equips.cButtonSlots[i - 1] = + gSaveContext.childEquips.cButtonSlots[i - 1]; } if (((gSaveContext.equips.buttonItems[i] >= ITEM_BOTTLE) && (gSaveContext.equips.buttonItems[i] <= ITEM_POE)) || ((gSaveContext.equips.buttonItems[i] >= ITEM_WEIRD_EGG) && (gSaveContext.equips.buttonItems[i] <= ITEM_CLAIM_CHECK))) { - osSyncPrintf("Register_Item_Pt(%d)=%d\n", i, gSaveContext.equips.cButtonSlots[i - 1]); gSaveContext.equips.buttonItems[i] = gSaveContext.inventory.items[gSaveContext.equips.cButtonSlots[i - 1]]; } @@ -1574,16 +1562,111 @@ void Inventory_SwapAgeEquipment(void) { gSaveContext.equips.equipment = gSaveContext.childEquips.equipment; gSaveContext.equips.equipment &= (u16) ~(0xF << (EQUIP_TYPE_SWORD * 4)); - // Equips kokiri sword in the inventory screen only if kokiri sword exists in inventory and a sword has been equipped already - if (!(CHECK_OWNED_EQUIP(EQUIP_TYPE_SWORD, EQUIP_INV_SWORD_KOKIRI) == 0) && !Flags_GetInfTable(INFTABLE_SWORDLESS)) { - gSaveContext.equips.equipment |= EQUIP_VALUE_SWORD_KOKIRI << (EQUIP_TYPE_SWORD * 4); + gSaveContext.equips.equipment |= EQUIP_VALUE_SWORD_KOKIRI << (EQUIP_TYPE_SWORD * 4); + } + // In Rando we need an extra case to handle starting as adult. We can use the fact that the childEquips will be uninitialised (i.e. 0) at this point + else if (gSaveContext.childEquips.equipment == 0) { + + //zero out items + for (i = 0; i < ARRAY_COUNT(gSaveContext.equips.buttonItems); i++) { + gSaveContext.equips.buttonItems[i] = ITEM_NONE; + if (i != 0) { + gSaveContext.equips.cButtonSlots[i-1] = ITEM_NONE; + } } - } else if (gSaveContext.childEquips.buttonItems[0] != ITEM_NONE) { + gSaveContext.equips.equipment = (EQUIP_VALUE_SWORD_KOKIRI << (EQUIP_TYPE_SWORD * 4)) | + (EQUIP_VALUE_SHIELD_DEKU << (EQUIP_TYPE_SHIELD * 4)) | + (EQUIP_VALUE_TUNIC_KOKIRI << (EQUIP_TYPE_TUNIC * 4)) | + (EQUIP_VALUE_BOOTS_KOKIRI << (EQUIP_TYPE_BOOTS * 4)); + } + + // When becoming child in rando, set swordless flag and clear B button if player doesn't have kokiri sword + // Otherwise, equip sword and unset flag + if (!CHECK_OWNED_EQUIP(EQUIP_TYPE_SWORD, EQUIP_INV_SWORD_KOKIRI)) { + gSaveContext.equips.equipment &= (u16) ~(0xF << (EQUIP_TYPE_SWORD * 4)); + gSaveContext.equips.buttonItems[0] = ITEM_NONE; + Flags_SetInfTable(INFTABLE_SWORDLESS); + } else { + gSaveContext.equips.equipment &= (u16) ~(0xF << (EQUIP_TYPE_SWORD * 4)); + gSaveContext.equips.equipment |= (EQUIP_VALUE_SWORD_KOKIRI << (EQUIP_TYPE_SWORD * 4)); + gSaveContext.equips.buttonItems[0] = ITEM_SWORD_KOKIRI; + Flags_UnsetInfTable(INFTABLE_SWORDLESS); + } + } + + shieldEquipValue = gEquipMasks[EQUIP_TYPE_SHIELD] & gSaveContext.equips.equipment; + if (shieldEquipValue) { + shieldEquipValue >>= gEquipShifts[EQUIP_TYPE_SHIELD]; + if (!CHECK_OWNED_EQUIP_ALT(EQUIP_TYPE_SHIELD, shieldEquipValue - 1)) { + gSaveContext.equips.equipment &= gEquipNegMasks[EQUIP_TYPE_SHIELD]; + } + } +} + +void Inventory_SwapAgeEquipment(void) { + s16 i; + u16 shieldEquipValue; + + // Mod Enhancments can utilise the rando flow path + if (IS_RANDO || CVarGetInteger("gSwitchAge", 0) || CVarGetInteger("gSwitchTimeline", 0)) { + Rando_Inventory_SwapAgeEquipment(); + CVarSetInteger("gSwitchTimeline", 0); + return; + } + + if (LINK_AGE_IN_YEARS == YEARS_CHILD) { + for (i = 0; i < ARRAY_COUNT(gSaveContext.equips.buttonItems); i++) { + if (i != 0) { + gSaveContext.childEquips.buttonItems[i] = + gSaveContext.equips.buttonItems[i]; + } else { + gSaveContext.childEquips.buttonItems[i] = ITEM_SWORD_KOKIRI; + } + + if (i != 0) { + gSaveContext.childEquips.cButtonSlots[i - 1] = + gSaveContext.equips.cButtonSlots[i - 1]; + } + } + + gSaveContext.childEquips.equipment = gSaveContext.equips.equipment; + + if (gSaveContext.adultEquips.buttonItems[0] == ITEM_NONE) { + gSaveContext.equips.buttonItems[0] = ITEM_SWORD_MASTER; + + if (gSaveContext.inventory.items[SLOT_NUT] != ITEM_NONE) { + gSaveContext.equips.buttonItems[1] = ITEM_NUT; + gSaveContext.equips.cButtonSlots[0] = SLOT_NUT; + } else { + gSaveContext.equips.buttonItems[1] = gSaveContext.equips.cButtonSlots[0] = + ITEM_NONE; + } + + gSaveContext.equips.buttonItems[2] = ITEM_BOMB; + gSaveContext.equips.buttonItems[3] = gSaveContext.inventory.items[SLOT_OCARINA]; + gSaveContext.equips.cButtonSlots[1] = SLOT_BOMB; + gSaveContext.equips.cButtonSlots[2] = SLOT_OCARINA; + gSaveContext.equips.equipment = (EQUIP_VALUE_SWORD_MASTER << (EQUIP_TYPE_SWORD * 4)) | + (EQUIP_VALUE_SHIELD_HYLIAN << (EQUIP_TYPE_SHIELD * 4)) | + (EQUIP_VALUE_TUNIC_KOKIRI << (EQUIP_TYPE_TUNIC * 4)) | + (EQUIP_VALUE_BOOTS_KOKIRI << (EQUIP_TYPE_BOOTS * 4)); + // Set the dpad to nothing + gSaveContext.equips.buttonItems[4] = ITEM_NONE; + gSaveContext.equips.buttonItems[5] = ITEM_NONE; + gSaveContext.equips.buttonItems[6] = ITEM_NONE; + gSaveContext.equips.buttonItems[7] = ITEM_NONE; + gSaveContext.equips.cButtonSlots[3] = SLOT_NONE; + gSaveContext.equips.cButtonSlots[4] = SLOT_NONE; + gSaveContext.equips.cButtonSlots[5] = SLOT_NONE; + gSaveContext.equips.cButtonSlots[6] = SLOT_NONE; + } else { for (i = 0; i < ARRAY_COUNT(gSaveContext.equips.buttonItems); i++) { - gSaveContext.equips.buttonItems[i] = gSaveContext.childEquips.buttonItems[i]; + gSaveContext.equips.buttonItems[i] = + gSaveContext.adultEquips.buttonItems[i]; if (i != 0) { - gSaveContext.equips.cButtonSlots[i - 1] = gSaveContext.childEquips.cButtonSlots[i - 1]; + gSaveContext.equips.cButtonSlots[i - 1] = + gSaveContext.adultEquips.cButtonSlots[i - 1]; } if (((gSaveContext.equips.buttonItems[i] >= ITEM_BOTTLE) && @@ -1596,53 +1679,48 @@ void Inventory_SwapAgeEquipment(void) { } } - // In Rando, when switching to child from a swordless adult, and child Link previously had a - // sword equiped, then we need to unset the swordless flag to match - if (IS_RANDO && Randomizer_GetSettingValue(RSK_SHUFFLE_MASTER_SWORD) && - gSaveContext.equips.buttonItems[0] != ITEM_NONE) { - Flags_UnsetInfTable(INFTABLE_SWORDLESS); - } + gSaveContext.equips.equipment = gSaveContext.adultEquips.equipment; + } + } else { + for (i = 0; i < ARRAY_COUNT(gSaveContext.equips.buttonItems); i++) { + gSaveContext.adultEquips.buttonItems[i] = gSaveContext.equips.buttonItems[i]; - gSaveContext.equips.equipment = gSaveContext.childEquips.equipment; - gSaveContext.equips.equipment &= (u16) ~(0xF << (EQUIP_TYPE_SWORD * 4)); - gSaveContext.equips.equipment |= EQUIP_VALUE_SWORD_KOKIRI << (EQUIP_TYPE_SWORD * 4); - } else if (IS_RANDO && Randomizer_GetSettingValue(RSK_STARTING_AGE) == RO_AGE_ADULT) { - /*If in rando and starting age is adult, childEquips is not initialized and buttonItems[0] - will be ITEM_NONE. When changing age from adult -> child, reset equips to "default" - (only kokiri tunic/boots equipped, no sword, no C-button items, no D-Pad items). - When becoming child, set swordless flag if player doesn't have kokiri sword - Only in rando to keep swordless link bugs in vanilla*/ - if (CHECK_OWNED_EQUIP(EQUIP_TYPE_SWORD, EQUIP_INV_SWORD_KOKIRI) == 0) { - Flags_SetInfTable(INFTABLE_SWORDLESS); + if (i != 0) { + gSaveContext.adultEquips.cButtonSlots[i - 1] = + gSaveContext.equips.cButtonSlots[i - 1]; } + } - //zero out items + gSaveContext.adultEquips.equipment = gSaveContext.equips.equipment; + + if (gSaveContext.childEquips.buttonItems[0] != ITEM_NONE) { for (i = 0; i < ARRAY_COUNT(gSaveContext.equips.buttonItems); i++) { - gSaveContext.equips.buttonItems[i] = ITEM_NONE; + gSaveContext.equips.buttonItems[i] = + gSaveContext.childEquips.buttonItems[i]; + if (i != 0) { - gSaveContext.equips.cButtonSlots[i-1] = ITEM_NONE; + gSaveContext.equips.cButtonSlots[i - 1] = + gSaveContext.childEquips.cButtonSlots[i - 1]; } - } - gSaveContext.equips.equipment = (EQUIP_VALUE_SWORD_KOKIRI << (EQUIP_TYPE_SWORD * 4)) | - (EQUIP_VALUE_SHIELD_DEKU << (EQUIP_TYPE_SHIELD * 4)) | - (EQUIP_VALUE_TUNIC_KOKIRI << (EQUIP_TYPE_TUNIC * 4)) | - (EQUIP_VALUE_BOOTS_KOKIRI << (EQUIP_TYPE_BOOTS * 4)); - } - if ((CVarGetInteger("gSwitchAge", 0) || CVarGetInteger("gSwitchTimeline", 0)) && - (gSaveContext.equips.buttonItems[0] == ITEM_NONE)) { - Flags_SetInfTable(INFTABLE_SWORDLESS); - if (gSaveContext.childEquips.equipment == 0) { - // force equip kokiri tunic and boots in scenario gSaveContext.childEquips.equipment is uninitialized - gSaveContext.equips.equipment &= (u16) ~(0xF << (EQUIP_TYPE_SWORD * 4)); - gSaveContext.equips.equipment |= (EQUIP_VALUE_TUNIC_KOKIRI << (EQUIP_TYPE_TUNIC * 4)) | - (EQUIP_VALUE_BOOTS_KOKIRI << (EQUIP_TYPE_BOOTS * 4)); + if (((gSaveContext.equips.buttonItems[i] >= ITEM_BOTTLE) && + (gSaveContext.equips.buttonItems[i] <= ITEM_POE)) || + ((gSaveContext.equips.buttonItems[i] >= ITEM_WEIRD_EGG) && + (gSaveContext.equips.buttonItems[i] <= ITEM_CLAIM_CHECK))) { + osSyncPrintf("Register_Item_Pt(%d)=%d\n", i, gSaveContext.equips.cButtonSlots[i - 1]); + gSaveContext.equips.buttonItems[i] = + gSaveContext.inventory.items[gSaveContext.equips.cButtonSlots[i - 1]]; + } } + + gSaveContext.equips.equipment = gSaveContext.childEquips.equipment; + gSaveContext.equips.equipment &= (u16) ~(0xF << (EQUIP_TYPE_SWORD * 4)); + gSaveContext.equips.equipment |= EQUIP_VALUE_SWORD_KOKIRI << (EQUIP_TYPE_SWORD * 4); } } - CVarSetInteger("gSwitchTimeline", 0); + shieldEquipValue = gEquipMasks[EQUIP_TYPE_SHIELD] & gSaveContext.equips.equipment; - if (shieldEquipValue != 0) { + if (shieldEquipValue) { shieldEquipValue >>= gEquipShifts[EQUIP_TYPE_SHIELD]; if (!CHECK_OWNED_EQUIP_ALT(EQUIP_TYPE_SHIELD, shieldEquipValue - 1)) { gSaveContext.equips.equipment &= gEquipNegMasks[EQUIP_TYPE_SHIELD]; From 92467b87b5c8f691874dbd59e03e64b0d4d061f6 Mon Sep 17 00:00:00 2001 From: Pepe20129 <72659707+Pepe20129@users.noreply.github.com> Date: Mon, 29 Apr 2024 02:58:12 +0200 Subject: [PATCH 02/59] Add scene command XML parsers (#4054) * Add scene command parsers * Move logging & add logging cvar * Use new CVAR_DEVELOPER_TOOLS macro * Update soh/soh/resource/logging/SceneCommandLoggers.h --------- Co-authored-by: Garrett Cox --- soh/soh/OTRGlobals.cpp | 1 + soh/soh/SohMenuBar.cpp | 2 + soh/soh/resource/importer/SceneFactory.cpp | 123 ++++ soh/soh/resource/importer/SceneFactory.h | 17 + .../scenecommand/EndMarkerFactory.cpp | 14 + .../importer/scenecommand/EndMarkerFactory.h | 6 + .../scenecommand/SceneCommandFactory.h | 9 + .../scenecommand/SetActorListFactory.cpp | 36 ++ .../scenecommand/SetActorListFactory.h | 6 + .../SetAlternateHeadersFactory.cpp | 34 + .../scenecommand/SetAlternateHeadersFactory.h | 6 + .../scenecommand/SetCameraSettingsFactory.cpp | 17 + .../scenecommand/SetCameraSettingsFactory.h | 6 + .../SetCollisionHeaderFactory.cpp | 17 + .../scenecommand/SetCollisionHeaderFactory.h | 6 + .../scenecommand/SetCsCameraFactory.cpp | 14 + .../scenecommand/SetCsCameraFactory.h | 6 + .../scenecommand/SetCutscenesFactory.cpp | 17 + .../scenecommand/SetCutscenesFactory.h | 6 + .../scenecommand/SetEchoSettingsFactory.cpp | 16 + .../scenecommand/SetEchoSettingsFactory.h | 6 + .../scenecommand/SetEntranceListFactory.cpp | 30 + .../scenecommand/SetEntranceListFactory.h | 6 + .../scenecommand/SetExitListFactory.cpp | 27 + .../scenecommand/SetExitListFactory.h | 6 + .../scenecommand/SetLightListFactory.cpp | 46 ++ .../scenecommand/SetLightListFactory.h | 6 + .../SetLightingSettingsFactory.cpp | 49 ++ .../scenecommand/SetLightingSettingsFactory.h | 6 + .../importer/scenecommand/SetMeshFactory.cpp | 176 +++++ .../importer/scenecommand/SetMeshFactory.h | 6 + .../scenecommand/SetObjectListFactory.cpp | 27 + .../scenecommand/SetObjectListFactory.h | 6 + .../scenecommand/SetPathwaysFactory.cpp | 30 + .../scenecommand/SetPathwaysFactory.h | 6 + .../scenecommand/SetRoomBehaviorFactory.cpp | 17 + .../scenecommand/SetRoomBehaviorFactory.h | 6 + .../scenecommand/SetRoomListFactory.cpp | 35 + .../scenecommand/SetRoomListFactory.h | 6 + .../scenecommand/SetSkyboxModifierFactory.cpp | 17 + .../scenecommand/SetSkyboxModifierFactory.h | 6 + .../scenecommand/SetSkyboxSettingsFactory.cpp | 19 + .../scenecommand/SetSkyboxSettingsFactory.h | 6 + .../scenecommand/SetSoundSettingsFactory.cpp | 18 + .../scenecommand/SetSoundSettingsFactory.h | 6 + .../scenecommand/SetSpecialObjectsFactory.cpp | 17 + .../scenecommand/SetSpecialObjectsFactory.h | 6 + .../SetStartPositionListFactory.cpp | 36 ++ .../SetStartPositionListFactory.h | 6 + .../scenecommand/SetTimeSettingsFactory.cpp | 18 + .../scenecommand/SetTimeSettingsFactory.h | 6 + .../SetTransitionActorListFactory.cpp | 38 ++ .../SetTransitionActorListFactory.h | 6 + .../scenecommand/SetWindSettingsFactory.cpp | 19 + .../scenecommand/SetWindSettingsFactory.h | 6 + .../resource/logging/SceneCommandLoggers.cpp | 603 ++++++++++++++++++ .../resource/logging/SceneCommandLoggers.h | 32 + soh/soh/resource/type/scenecommand/SetMesh.h | 2 + .../resource/type/scenecommand/SetPathways.h | 1 + 59 files changed, 1724 insertions(+) create mode 100644 soh/soh/resource/logging/SceneCommandLoggers.cpp create mode 100644 soh/soh/resource/logging/SceneCommandLoggers.h diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 71b738b96ee..b79b1f9f380 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -334,6 +334,7 @@ OTRGlobals::OTRGlobals() { loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Animation", static_cast(SOH::ResourceType::SOH_Animation), 0); loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "PlayerAnimation", static_cast(SOH::ResourceType::SOH_PlayerAnimation), 0); loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Room", static_cast(SOH::ResourceType::SOH_Room), 0); // Is room scene? maybe? + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_XML, "Room", static_cast(SOH::ResourceType::SOH_Room), 0); // Is room scene? maybe? loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "CollisionHeader", static_cast(SOH::ResourceType::SOH_CollisionHeader), 0); loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_XML, "CollisionHeader", static_cast(SOH::ResourceType::SOH_CollisionHeader), 0); loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Skeleton", static_cast(SOH::ResourceType::SOH_Skeleton), 0); diff --git a/soh/soh/SohMenuBar.cpp b/soh/soh/SohMenuBar.cpp index b577caee59c..20bcc43b816 100644 --- a/soh/soh/SohMenuBar.cpp +++ b/soh/soh/SohMenuBar.cpp @@ -1652,6 +1652,8 @@ void DrawDeveloperToolsMenu() { UIWidgets::Tooltip("Optimized debug warp screen, with the added ability to chose entrances and time of day"); UIWidgets::PaddedEnhancementCheckbox("Debug Warp Screen Translation", CVAR_DEVELOPER_TOOLS("DebugWarpScreenTranslation"), true, false, false, "", UIWidgets::CheckboxGraphics::Cross, true); UIWidgets::Tooltip("Translate the Debug Warp Screen based on the game language"); + UIWidgets::PaddedEnhancementCheckbox("Resource logging", CVAR_DEVELOPER_TOOLS("ResourceLogging"), true, false); + UIWidgets::Tooltip("Logs some resources as XML when they're loaded in binary format"); if (gPlayState != NULL) { UIWidgets::PaddedSeparator(); ImGui::Checkbox("Frame Advance##frameAdvance", (bool*)&gPlayState->frameAdvCtx.enabled); diff --git a/soh/soh/resource/importer/SceneFactory.cpp b/soh/soh/resource/importer/SceneFactory.cpp index 679d574cbac..c537cb31215 100644 --- a/soh/soh/resource/importer/SceneFactory.cpp +++ b/soh/soh/resource/importer/SceneFactory.cpp @@ -105,4 +105,127 @@ std::shared_ptr ResourceFactoryBinarySceneV0::ReadResource(std:: return scene; }; + +ResourceFactoryXMLSceneV0::ResourceFactoryXMLSceneV0() { + sceneCommandFactories[SceneCommandID::SetLightingSettings] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetWind] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetExitList] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetTimeSettings] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetSkyboxModifier] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetEchoSettings] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetSoundSettings] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetSkyboxSettings] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetRoomBehavior] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetCsCamera] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetCameraSettings] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetRoomList] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetCollisionHeader] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetEntranceList] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetSpecialObjects] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetObjectList] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetStartPositionList] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetActorList] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetTransitionActorList] = std::make_shared(); + sceneCommandFactories[SceneCommandID::EndMarker] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetAlternateHeaders] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetPathways] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetCutscenes] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetLightList] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetMesh] = std::make_shared(); +} + +std::vector commandNames = { + "SetStartPositionList", + "SetActorList", + "SetCsCamera", + "SetCollisionHeader", + "SetRoomList", + "SetWind", + "SetEntranceList", + "SetSpecialObjects", + "SetRoomBehavior", + "Unused09", + "SetMesh", + "SetObjectList", + "SetLightList", + "SetPathways", + "SetTransitionActorList", + "SetLightingSettings", + "SetTimeSettings", + "SetSkyboxSettings", + "SetSkyboxModifier", + "SetExitList", + "EndMarker", + "SetSoundSettings", + "SetEchoSettings", + "SetCutscenes", + "SetAlternateHeaders", + "SetCameraSettings", +}; + +SceneCommandID GetCommandID(std::string commandName) { + for (int i = 0; i < commandNames.size(); i++) { + if (commandNames[i] == commandName) { + return (SceneCommandID)i; + } + } + + return SceneCommandID::Error; +} + +void ResourceFactoryXMLSceneV0::ParseSceneCommands(std::shared_ptr scene, std::shared_ptr reader) { + auto child = reader->RootElement()->FirstChildElement(); + + int i = 0; + + while (child != nullptr) { + scene->commands.push_back(ParseSceneCommand(scene, child, i)); + + child = child->NextSiblingElement(); + i += 1; + } +} + +std::shared_ptr ResourceFactoryXMLSceneV0::ParseSceneCommand(std::shared_ptr scene, + tinyxml2::XMLElement* child, uint32_t index) { + std::string commandName = child->Name(); + SceneCommandID cmdID = GetCommandID(commandName); + + if (cmdID == SceneCommandID::Error) { + SPDLOG_ERROR("Failed to load scene command with name {} in scene {}", commandName, scene->GetInitData()->Path); + return nullptr; + } + + std::shared_ptr result = nullptr; + auto commandFactory = ResourceFactoryXMLSceneV0::sceneCommandFactories[cmdID]; + + if (commandFactory != nullptr) { + auto initData = std::make_shared(); + initData->Id = scene->GetInitData()->Id; + initData->Type = static_cast(ResourceType::SOH_SceneCommand); + initData->Path = scene->GetInitData()->Path + "/SceneCommand" + std::to_string(index); + initData->ResourceVersion = scene->GetInitData()->ResourceVersion; + result = std::static_pointer_cast(commandFactory->ReadResource(initData, child)); + // Cache the resource? + } + + if (result == nullptr) { + SPDLOG_ERROR("Failed to load scene command of type {} in scene {}", (uint32_t)cmdID, scene->GetInitData()->Path); + } + + return result; +} + +std::shared_ptr ResourceFactoryXMLSceneV0::ReadResource(std::shared_ptr file) { + if (!FileHasValidFormatAndReader(file)) { + return nullptr; + } + + auto scene = std::make_shared(file->InitData); + auto reader = std::get>(file->Reader); + + ParseSceneCommands(scene, reader); + + return scene; +}; } // namespace SOH diff --git a/soh/soh/resource/importer/SceneFactory.h b/soh/soh/resource/importer/SceneFactory.h index 5dfed273904..a1b345f7de4 100644 --- a/soh/soh/resource/importer/SceneFactory.h +++ b/soh/soh/resource/importer/SceneFactory.h @@ -5,6 +5,7 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" #include "Resource.h" #include "ResourceFactoryBinary.h" +#include "ResourceFactoryXML.h" namespace SOH { class ResourceFactoryBinarySceneV0 : public LUS::ResourceFactoryBinary { @@ -22,4 +23,20 @@ class ResourceFactoryBinarySceneV0 : public LUS::ResourceFactoryBinary { protected: std::shared_ptr ParseSceneCommand(std::shared_ptr scene, std::shared_ptr reader, uint32_t index); }; + +class ResourceFactoryXMLSceneV0 : public LUS::ResourceFactoryXML { + public: + ResourceFactoryXMLSceneV0(); + + std::shared_ptr ReadResource(std::shared_ptr file) override; + void ParseSceneCommands(std::shared_ptr scene, std::shared_ptr reader); + + // Doing something very similar to what we do on the ResourceLoader. + // Eventually, scene commands should be moved up to the ResourceLoader as well. + // They can not right now because the exporter does not give them a proper resource type enum value, + // and the exporter does not export the commands with a proper OTR header. + static inline std::unordered_map> sceneCommandFactories; +protected: + std::shared_ptr ParseSceneCommand(std::shared_ptr scene, tinyxml2::XMLElement* child, uint32_t index); +}; } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/EndMarkerFactory.cpp b/soh/soh/resource/importer/scenecommand/EndMarkerFactory.cpp index ffcf17410ef..debcf7ab166 100644 --- a/soh/soh/resource/importer/scenecommand/EndMarkerFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/EndMarkerFactory.cpp @@ -1,5 +1,6 @@ #include "soh/resource/importer/scenecommand/EndMarkerFactory.h" #include "soh/resource/type/scenecommand/EndMarker.h" +#include "soh/resource/logging/SceneCommandLoggers.h" #include "spdlog/spdlog.h" namespace SOH { @@ -9,6 +10,19 @@ EndMarkerFactory::ReadResource(std::shared_ptr initData, ReadCommandId(endMarker, reader); + if (CVarGetInteger(CVAR_DEVELOPER_TOOLS("ResourceLogging"), 0)) { + LogEndMarkerAsXML(endMarker); + } + + return endMarker; +} + +std::shared_ptr EndMarkerFactoryXML::ReadResource(std::shared_ptr initData, + tinyxml2::XMLElement* reader) { + auto endMarker = std::make_shared(initData); + + endMarker->cmdId = SceneCommandID::EndMarker; + return endMarker; } } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/EndMarkerFactory.h b/soh/soh/resource/importer/scenecommand/EndMarkerFactory.h index 486aaa2fb8d..8e3875ef2f7 100644 --- a/soh/soh/resource/importer/scenecommand/EndMarkerFactory.h +++ b/soh/soh/resource/importer/scenecommand/EndMarkerFactory.h @@ -7,4 +7,10 @@ class EndMarkerFactory : public SceneCommandFactoryBinaryV0 { public: std::shared_ptr ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; + +class EndMarkerFactoryXML : public SceneCommandFactoryXMLV0 { + public: + std::shared_ptr + ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; +}; } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SceneCommandFactory.h b/soh/soh/resource/importer/scenecommand/SceneCommandFactory.h index 4cebc4a64b5..73e5a2e0686 100644 --- a/soh/soh/resource/importer/scenecommand/SceneCommandFactory.h +++ b/soh/soh/resource/importer/scenecommand/SceneCommandFactory.h @@ -4,6 +4,7 @@ #include "Resource.h" #include "ResourceFactory.h" #include "soh/resource/type/scenecommand/SceneCommand.h" +#include "public/bridge/consolevariablebridge.h" namespace SOH { class SceneCommandFactoryBinaryV0 { @@ -13,4 +14,12 @@ class SceneCommandFactoryBinaryV0 { protected: void ReadCommandId(std::shared_ptr command, std::shared_ptr reader); }; + +class SceneCommandFactoryXMLV0 { + public: + virtual std::shared_ptr ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) = 0; + + protected: + void ReadCommandId(std::shared_ptr command, tinyxml2::XMLElement* reader); +}; } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetActorListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetActorListFactory.cpp index 86deea193c2..cf397fcd394 100644 --- a/soh/soh/resource/importer/scenecommand/SetActorListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetActorListFactory.cpp @@ -1,5 +1,6 @@ #include "soh/resource/importer/scenecommand/SetActorListFactory.h" #include "soh/resource/type/scenecommand/SetActorList.h" +#include "soh/resource/logging/SceneCommandLoggers.h" #include "spdlog/spdlog.h" namespace SOH { @@ -26,6 +27,41 @@ SetActorListFactory::ReadResource(std::shared_ptr initDat setActorList->actorList.push_back(entry); } + if (CVarGetInteger(CVAR_DEVELOPER_TOOLS("ResourceLogging"), 0)) { + LogActorListAsXML(setActorList); + } + + return setActorList; +} + +std::shared_ptr SetActorListFactoryXML::ReadResource(std::shared_ptr initData, + tinyxml2::XMLElement* reader) { + auto setActorList = std::make_shared(initData); + + setActorList->cmdId = SceneCommandID::SetActorList; + + auto child = reader->FirstChildElement(); + + while (child != nullptr) { + std::string childName = child->Name(); + if (childName == "ActorEntry") { + ActorEntry entry; + entry.id = child->IntAttribute("Id"); + entry.pos.x = child->IntAttribute("PosX"); + entry.pos.y = child->IntAttribute("PosY"); + entry.pos.z = child->IntAttribute("PosZ"); + entry.rot.x = child->IntAttribute("RotX"); + entry.rot.y = child->IntAttribute("RotY"); + entry.rot.z = child->IntAttribute("RotZ"); + entry.params = child->IntAttribute("Params"); + setActorList->actorList.push_back(entry); + } + + child = child->NextSiblingElement(); + } + + setActorList->numActors = setActorList->actorList.size(); + return setActorList; } } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetActorListFactory.h b/soh/soh/resource/importer/scenecommand/SetActorListFactory.h index 49a269cfe20..5dd872f8ab4 100644 --- a/soh/soh/resource/importer/scenecommand/SetActorListFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetActorListFactory.h @@ -8,4 +8,10 @@ class SetActorListFactory : public SceneCommandFactoryBinaryV0 { std::shared_ptr ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; + +class SetActorListFactoryXML : public SceneCommandFactoryXMLV0 { + public: + std::shared_ptr + ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; +}; } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.cpp b/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.cpp index 833d0af8c72..40e31f0f293 100644 --- a/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.cpp @@ -1,5 +1,6 @@ #include "soh/resource/importer/scenecommand/SetAlternateHeadersFactory.h" #include "soh/resource/type/scenecommand/SetAlternateHeaders.h" +#include "soh/resource/logging/SceneCommandLoggers.h" #include "spdlog/spdlog.h" #include "libultraship/libultraship.h" @@ -21,6 +22,39 @@ std::shared_ptr SetAlternateHeadersFactory::ReadResource(std::sh } } + if (CVarGetInteger(CVAR_DEVELOPER_TOOLS("ResourceLogging"), 0)) { + LogAlternateHeadersAsXML(setAlternateHeaders); + } + + return setAlternateHeaders; +} + +std::shared_ptr SetAlternateHeadersFactoryXML::ReadResource(std::shared_ptr initData, + tinyxml2::XMLElement* reader) { + auto setAlternateHeaders = std::make_shared(initData); + + setAlternateHeaders->cmdId = SceneCommandID::SetAlternateHeaders; + + auto child = reader->FirstChildElement(); + + while (child != nullptr) { + std::string childName = child->Name(); + if (childName == "AlternateHeader") { + for (uint32_t i = 0; i < setAlternateHeaders->numHeaders; i++) { + auto headerName = std::string(child->Attribute("HeaderName")); + if (!headerName.empty()) { + setAlternateHeaders->headers.push_back(std::static_pointer_cast(LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(headerName.c_str()))); + } else { + setAlternateHeaders->headers.push_back(nullptr); + } + } + } + + child = child->NextSiblingElement(); + } + + setAlternateHeaders->numHeaders = setAlternateHeaders->headers.size(); + return setAlternateHeaders; } } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.h b/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.h index 2bc430c0b20..84e730905ea 100644 --- a/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.h @@ -8,4 +8,10 @@ class SetAlternateHeadersFactory : public SceneCommandFactoryBinaryV0 { std::shared_ptr ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; + +class SetAlternateHeadersFactoryXML : public SceneCommandFactoryXMLV0 { + public: + std::shared_ptr + ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; +}; } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetCameraSettingsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetCameraSettingsFactory.cpp index 7e2911a1712..52158626287 100644 --- a/soh/soh/resource/importer/scenecommand/SetCameraSettingsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetCameraSettingsFactory.cpp @@ -1,5 +1,6 @@ #include "soh/resource/importer/scenecommand/SetCameraSettingsFactory.h" #include "soh/resource/type/scenecommand/SetCameraSettings.h" +#include "soh/resource/logging/SceneCommandLoggers.h" #include "spdlog/spdlog.h" namespace SOH { @@ -12,6 +13,22 @@ std::shared_ptr SetCameraSettingsFactory::ReadResource(std::shar setCameraSettings->settings.cameraMovement = reader->ReadInt8(); setCameraSettings->settings.worldMapArea = reader->ReadInt32(); + if (CVarGetInteger(CVAR_DEVELOPER_TOOLS("ResourceLogging"), 0)) { + LogCameraSettingsAsXML(setCameraSettings); + } + + return setCameraSettings; +} + +std::shared_ptr SetCameraSettingsFactoryXML::ReadResource(std::shared_ptr initData, + tinyxml2::XMLElement* reader) { + auto setCameraSettings = std::make_shared(initData); + + setCameraSettings->cmdId = SceneCommandID::SetCameraSettings; + + setCameraSettings->settings.cameraMovement = reader->IntAttribute("CameraMovement"); + setCameraSettings->settings.worldMapArea = reader->IntAttribute("WorldMapArea"); + return setCameraSettings; } } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetCameraSettingsFactory.h b/soh/soh/resource/importer/scenecommand/SetCameraSettingsFactory.h index 2f1db272f9f..a03287b353e 100644 --- a/soh/soh/resource/importer/scenecommand/SetCameraSettingsFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetCameraSettingsFactory.h @@ -8,4 +8,10 @@ class SetCameraSettingsFactory : public SceneCommandFactoryBinaryV0 { std::shared_ptr ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; + +class SetCameraSettingsFactoryXML : public SceneCommandFactoryXMLV0 { + public: + std::shared_ptr + ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; +}; } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.cpp b/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.cpp index bb83dc57b9a..f50ee379011 100644 --- a/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.cpp @@ -1,5 +1,6 @@ #include "soh/resource/importer/scenecommand/SetCollisionHeaderFactory.h" #include "soh/resource/type/scenecommand/SetCollisionHeader.h" +#include "soh/resource/logging/SceneCommandLoggers.h" #include "libultraship/libultraship.h" #include "spdlog/spdlog.h" @@ -13,6 +14,22 @@ std::shared_ptr SetCollisionHeaderFactory::ReadResource(std::sha setCollisionHeader->fileName = reader->ReadString(); setCollisionHeader->collisionHeader = std::static_pointer_cast(LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(setCollisionHeader->fileName.c_str())); + if (CVarGetInteger(CVAR_DEVELOPER_TOOLS("ResourceLogging"), 0)) { + LogSetCollisionHeaderAsXML(setCollisionHeader); + } + + return setCollisionHeader; +} + +std::shared_ptr SetCollisionHeaderFactoryXML::ReadResource(std::shared_ptr initData, + tinyxml2::XMLElement* reader) { + auto setCollisionHeader = std::make_shared(initData); + + setCollisionHeader->cmdId = SceneCommandID::SetCollisionHeader; + + setCollisionHeader->fileName = reader->Attribute("FileName"); + setCollisionHeader->collisionHeader = std::static_pointer_cast(LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(setCollisionHeader->fileName.c_str())); + return setCollisionHeader; } } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.h b/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.h index b80ee34b47f..12b872f3cc8 100644 --- a/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.h @@ -8,4 +8,10 @@ class SetCollisionHeaderFactory : public SceneCommandFactoryBinaryV0 { std::shared_ptr ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; + +class SetCollisionHeaderFactoryXML : public SceneCommandFactoryXMLV0 { + public: + std::shared_ptr + ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; +}; } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetCsCameraFactory.cpp b/soh/soh/resource/importer/scenecommand/SetCsCameraFactory.cpp index 84c27798934..569b8b1d9e4 100644 --- a/soh/soh/resource/importer/scenecommand/SetCsCameraFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetCsCameraFactory.cpp @@ -1,5 +1,6 @@ #include "soh/resource/importer/scenecommand/SetCsCameraFactory.h" #include "soh/resource/type/scenecommand/SetCsCamera.h" +#include "soh/resource/logging/SceneCommandLoggers.h" #include "spdlog/spdlog.h" namespace SOH { @@ -14,6 +15,19 @@ SetCsCameraFactory::ReadResource(std::shared_ptr initData // OTRTODO: FINISH! + if (CVarGetInteger(CVAR_DEVELOPER_TOOLS("ResourceLogging"), 0)) { + LogCsCameraAsXML(setCsCamera); + } + + return setCsCamera; +} + +std::shared_ptr SetCsCameraFactoryXML::ReadResource(std::shared_ptr initData, + tinyxml2::XMLElement* reader) { + auto setCsCamera = std::make_shared(initData); + + setCsCamera->cmdId = SceneCommandID::SetCsCamera; + return setCsCamera; } } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetCsCameraFactory.h b/soh/soh/resource/importer/scenecommand/SetCsCameraFactory.h index 08dc8e3c341..89c92a6990f 100644 --- a/soh/soh/resource/importer/scenecommand/SetCsCameraFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetCsCameraFactory.h @@ -8,4 +8,10 @@ class SetCsCameraFactory : public SceneCommandFactoryBinaryV0 { std::shared_ptr ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; + +class SetCsCameraFactoryXML : public SceneCommandFactoryXMLV0 { + public: + std::shared_ptr + ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; +}; } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.cpp b/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.cpp index 30f72d168fe..7aea7c70d8f 100644 --- a/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.cpp @@ -1,5 +1,6 @@ #include "soh/resource/importer/scenecommand/SetCutscenesFactory.h" #include "soh/resource/type/scenecommand/SetCutscenes.h" +#include "soh/resource/logging/SceneCommandLoggers.h" #include #include "spdlog/spdlog.h" @@ -13,6 +14,22 @@ SetCutscenesFactory::ReadResource(std::shared_ptr initDat setCutscenes->fileName = reader->ReadString(); setCutscenes->cutscene = std::static_pointer_cast(LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(setCutscenes->fileName.c_str())); + if (CVarGetInteger(CVAR_DEVELOPER_TOOLS("ResourceLogging"), 0)) { + LogCutscenesAsXML(setCutscenes); + } + + return setCutscenes; +} + +std::shared_ptr SetCutscenesFactoryXML::ReadResource(std::shared_ptr initData, + tinyxml2::XMLElement* reader) { + auto setCutscenes = std::make_shared(initData); + + setCutscenes->cmdId = SceneCommandID::SetCutscenes; + + setCutscenes->fileName = reader->Attribute("FileName"); + setCutscenes->cutscene = std::static_pointer_cast(LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(setCutscenes->fileName.c_str())); + return setCutscenes; } } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.h b/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.h index bbbe38c98aa..c78bf621cb0 100644 --- a/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.h @@ -8,4 +8,10 @@ class SetCutscenesFactory : public SceneCommandFactoryBinaryV0 { std::shared_ptr ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; + +class SetCutscenesFactoryXML : public SceneCommandFactoryXMLV0 { + public: + std::shared_ptr + ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; +}; } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetEchoSettingsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetEchoSettingsFactory.cpp index e9c3381cb16..d4c6e9a509c 100644 --- a/soh/soh/resource/importer/scenecommand/SetEchoSettingsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetEchoSettingsFactory.cpp @@ -1,5 +1,6 @@ #include "soh/resource/importer/scenecommand/SetEchoSettingsFactory.h" #include "soh/resource/type/scenecommand/SetEchoSettings.h" +#include "soh/resource/logging/SceneCommandLoggers.h" #include "spdlog/spdlog.h" namespace SOH { @@ -11,6 +12,21 @@ SetEchoSettingsFactory::ReadResource(std::shared_ptr init setEchoSettings->settings.echo = reader->ReadInt8(); + if (CVarGetInteger(CVAR_DEVELOPER_TOOLS("ResourceLogging"), 0)) { + LogEchoSettingsAsXML(setEchoSettings); + } + + return setEchoSettings; +} + +std::shared_ptr SetEchoSettingsFactoryXML::ReadResource(std::shared_ptr initData, + tinyxml2::XMLElement* reader) { + auto setEchoSettings = std::make_shared(initData); + + setEchoSettings->cmdId = SceneCommandID::SetEchoSettings; + + setEchoSettings->settings.echo = reader->IntAttribute("Echo"); + return setEchoSettings; } } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetEchoSettingsFactory.h b/soh/soh/resource/importer/scenecommand/SetEchoSettingsFactory.h index 99bda6eaef9..4be1fe399ae 100644 --- a/soh/soh/resource/importer/scenecommand/SetEchoSettingsFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetEchoSettingsFactory.h @@ -8,4 +8,10 @@ class SetEchoSettingsFactory : public SceneCommandFactoryBinaryV0 { std::shared_ptr ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; + +class SetEchoSettingsFactoryXML : public SceneCommandFactoryXMLV0 { + public: + std::shared_ptr + ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; +}; } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetEntranceListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetEntranceListFactory.cpp index 766bb82da0e..f3817c39c90 100644 --- a/soh/soh/resource/importer/scenecommand/SetEntranceListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetEntranceListFactory.cpp @@ -1,5 +1,6 @@ #include "soh/resource/importer/scenecommand/SetEntranceListFactory.h" #include "soh/resource/type/scenecommand/SetEntranceList.h" +#include "soh/resource/logging/SceneCommandLoggers.h" #include "spdlog/spdlog.h" namespace SOH { @@ -20,6 +21,35 @@ SetEntranceListFactory::ReadResource(std::shared_ptr init setEntranceList->entrances.push_back(entranceEntry); } + if (CVarGetInteger(CVAR_DEVELOPER_TOOLS("ResourceLogging"), 0)) { + LogEntranceListAsXML(setEntranceList); + } + + return setEntranceList; +} + +std::shared_ptr SetEntranceListFactoryXML::ReadResource(std::shared_ptr initData, + tinyxml2::XMLElement* reader) { + auto setEntranceList = std::make_shared(initData); + + setEntranceList->cmdId = SceneCommandID::SetEntranceList; + + auto child = reader->FirstChildElement(); + + while (child != nullptr) { + std::string childName = child->Name(); + if (childName == "EntranceEntry") { + EntranceEntry entry; + entry.spawn = child->IntAttribute("Spawn"); + entry.room = child->IntAttribute("Room"); + setEntranceList->entrances.push_back(entry); + } + + child = child->NextSiblingElement(); + } + + setEntranceList->numEntrances = setEntranceList->entrances.size(); + return setEntranceList; } } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetEntranceListFactory.h b/soh/soh/resource/importer/scenecommand/SetEntranceListFactory.h index 35b7fba62d7..a5349cf83b2 100644 --- a/soh/soh/resource/importer/scenecommand/SetEntranceListFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetEntranceListFactory.h @@ -8,4 +8,10 @@ class SetEntranceListFactory : public SceneCommandFactoryBinaryV0 { std::shared_ptr ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; + +class SetEntranceListFactoryXML : public SceneCommandFactoryXMLV0 { + public: + std::shared_ptr + ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; +}; } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetExitListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetExitListFactory.cpp index 5fef9d096da..b6078199bda 100644 --- a/soh/soh/resource/importer/scenecommand/SetExitListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetExitListFactory.cpp @@ -1,5 +1,6 @@ #include "soh/resource/importer/scenecommand/SetExitListFactory.h" #include "soh/resource/type/scenecommand/SetExitList.h" +#include "soh/resource/logging/SceneCommandLoggers.h" #include "spdlog/spdlog.h" namespace SOH { @@ -15,6 +16,32 @@ SetExitListFactory::ReadResource(std::shared_ptr initData setExitList->exits.push_back(reader->ReadUInt16()); } + if (CVarGetInteger(CVAR_DEVELOPER_TOOLS("ResourceLogging"), 0)) { + LogExitListAsXML(setExitList); + } + + return setExitList; +} + +std::shared_ptr SetExitListFactoryXML::ReadResource(std::shared_ptr initData, + tinyxml2::XMLElement* reader) { + auto setExitList = std::make_shared(initData); + + setExitList->cmdId = SceneCommandID::SetExitList; + + auto child = reader->FirstChildElement(); + + while (child != nullptr) { + std::string childName = child->Name(); + if (childName == "ExitEntry") { + setExitList->exits.push_back(child->IntAttribute("Id")); + } + + child = child->NextSiblingElement(); + } + + setExitList->numExits = setExitList->exits.size(); + return setExitList; } } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetExitListFactory.h b/soh/soh/resource/importer/scenecommand/SetExitListFactory.h index d82e8f04a13..fc47b88d0be 100644 --- a/soh/soh/resource/importer/scenecommand/SetExitListFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetExitListFactory.h @@ -8,4 +8,10 @@ class SetExitListFactory : public SceneCommandFactoryBinaryV0 { std::shared_ptr ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; + +class SetExitListFactoryXML : public SceneCommandFactoryXMLV0 { + public: + std::shared_ptr + ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; +}; } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetLightListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetLightListFactory.cpp index 2d05631cdf6..af7f1bb3c47 100644 --- a/soh/soh/resource/importer/scenecommand/SetLightListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetLightListFactory.cpp @@ -1,5 +1,6 @@ #include "soh/resource/importer/scenecommand/SetLightListFactory.h" #include "soh/resource/type/scenecommand/SetLightList.h" +#include "soh/resource/logging/SceneCommandLoggers.h" #include "spdlog/spdlog.h" namespace SOH { @@ -30,6 +31,51 @@ SetLightListFactory::ReadResource(std::shared_ptr initDat setLightList->lightList.push_back(light); } + if (CVarGetInteger(CVAR_DEVELOPER_TOOLS("ResourceLogging"), 0)) { + LogLightListAsXML(setLightList); + } + + return setLightList; +} + +std::shared_ptr SetLightListFactoryXML::ReadResource(std::shared_ptr initData, + tinyxml2::XMLElement* reader) { + auto setLightList = std::make_shared(initData); + + setLightList->cmdId = SceneCommandID::SetLightList; + + auto child = reader->FirstChildElement(); + + while (child != nullptr) { + std::string childName = child->Name(); + if (childName == "LightInfo") { + LightInfo light; + light.type = child->IntAttribute("Type"); + if (false/*light.type == LIGHT_DIRECTIONAL*/) { + light.params.dir.x = child->IntAttribute("X"); + light.params.dir.y = child->IntAttribute("Y"); + light.params.dir.z = child->IntAttribute("Z"); + light.params.dir.color[0] = child->IntAttribute("ColorR"); + light.params.dir.color[1] = child->IntAttribute("ColorG"); + light.params.dir.color[2] = child->IntAttribute("ColorB"); + } else { + light.params.point.x = child->IntAttribute("X"); + light.params.point.y = child->IntAttribute("Y"); + light.params.point.z = child->IntAttribute("Z"); + light.params.point.color[0] = child->IntAttribute("ColorR"); + light.params.point.color[1] = child->IntAttribute("ColorG"); + light.params.point.color[2] = child->IntAttribute("ColorB"); + light.params.point.drawGlow = child->IntAttribute("DrawGlow"); + light.params.point.radius = child->IntAttribute("Radius"); + } + setLightList->lightList.push_back(light); + } + + child = child->NextSiblingElement(); + } + + setLightList->numLights = setLightList->lightList.size(); + return setLightList; } } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetLightListFactory.h b/soh/soh/resource/importer/scenecommand/SetLightListFactory.h index 1c4a6e9dcfb..aae5c8e4a9e 100644 --- a/soh/soh/resource/importer/scenecommand/SetLightListFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetLightListFactory.h @@ -8,4 +8,10 @@ class SetLightListFactory : public SceneCommandFactoryBinaryV0 { std::shared_ptr ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; + +class SetLightListFactoryXML : public SceneCommandFactoryXMLV0 { + public: + std::shared_ptr + ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; +}; } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetLightingSettingsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetLightingSettingsFactory.cpp index d0a7b89d5bd..573998cfade 100644 --- a/soh/soh/resource/importer/scenecommand/SetLightingSettingsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetLightingSettingsFactory.cpp @@ -1,5 +1,6 @@ #include "soh/resource/importer/scenecommand/SetLightingSettingsFactory.h" #include "soh/resource/type/scenecommand/SetLightingSettings.h" +#include "soh/resource/logging/SceneCommandLoggers.h" #include "spdlog/spdlog.h" namespace SOH { @@ -43,6 +44,54 @@ std::shared_ptr SetLightingSettingsFactory::ReadResource(std::sh setLightingSettings->settings.push_back(lightSettings); } + if (CVarGetInteger(CVAR_DEVELOPER_TOOLS("ResourceLogging"), 0)) { + LogLightingSettingsAsXML(setLightingSettings); + } + + return setLightingSettings; +} + +std::shared_ptr SetLightingSettingsFactoryXML::ReadResource(std::shared_ptr initData, + tinyxml2::XMLElement* reader) { + auto setLightingSettings = std::make_shared(initData); + + setLightingSettings->cmdId = SceneCommandID::SetLightingSettings; + + auto child = reader->FirstChildElement(); + + while (child != nullptr) { + std::string childName = child->Name(); + if (childName == "LightingSetting") { + EnvLightSettings lightSettings; + lightSettings.ambientColor[0] = child->IntAttribute("AmbientColorR"); + lightSettings.ambientColor[1] = child->IntAttribute("AmbientColorG"); + lightSettings.ambientColor[2] = child->IntAttribute("AmbientColorB"); + + lightSettings.light1Dir[0] = child->IntAttribute("Light1DirX"); + lightSettings.light1Dir[1] = child->IntAttribute("Light1DirY"); + lightSettings.light1Dir[2] = child->IntAttribute("Light1DirZ"); + lightSettings.light1Color[0] = child->IntAttribute("Light1ColorR"); + lightSettings.light1Color[1] = child->IntAttribute("Light1ColorG"); + lightSettings.light1Color[2] = child->IntAttribute("Light1ColorB"); + + lightSettings.light2Dir[0] = child->IntAttribute("Light2DirX"); + lightSettings.light2Dir[1] = child->IntAttribute("Light2DirY"); + lightSettings.light2Dir[2] = child->IntAttribute("Light2DirZ"); + lightSettings.light2Color[0] = child->IntAttribute("Light2ColorR"); + lightSettings.light2Color[1] = child->IntAttribute("Light2ColorG"); + lightSettings.light2Color[2] = child->IntAttribute("Light2ColorB"); + + lightSettings.fogColor[0] = child->IntAttribute("FogColorR"); + lightSettings.fogColor[1] = child->IntAttribute("FogColorG"); + lightSettings.fogColor[2] = child->IntAttribute("FogColorB"); + lightSettings.fogNear = child->IntAttribute("FogNear"); + lightSettings.fogFar = child->IntAttribute("FogFar"); + setLightingSettings->settings.push_back(lightSettings); + } + + child = child->NextSiblingElement(); + } + return setLightingSettings; } } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetLightingSettingsFactory.h b/soh/soh/resource/importer/scenecommand/SetLightingSettingsFactory.h index df25600e233..39ae6934de9 100644 --- a/soh/soh/resource/importer/scenecommand/SetLightingSettingsFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetLightingSettingsFactory.h @@ -8,4 +8,10 @@ class SetLightingSettingsFactory : public SceneCommandFactoryBinaryV0 { std::shared_ptr ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; + +class SetLightingSettingsFactoryXML : public SceneCommandFactoryXMLV0 { + public: + std::shared_ptr + ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; +}; } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetMeshFactory.cpp b/soh/soh/resource/importer/scenecommand/SetMeshFactory.cpp index 8c17ecc0719..8c4109c5abb 100644 --- a/soh/soh/resource/importer/scenecommand/SetMeshFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetMeshFactory.cpp @@ -1,5 +1,6 @@ #include "soh/resource/importer/scenecommand/SetMeshFactory.h" #include "soh/resource/type/scenecommand/SetMesh.h" +#include "soh/resource/logging/SceneCommandLoggers.h" #include "spdlog/spdlog.h" #include "libultraship/libultraship.h" @@ -45,6 +46,8 @@ SetMeshFactory::ReadResource(std::shared_ptr initData, st dlist.opa = meshOpa != "" ? (Gfx*)(opaRes ? opaRes->GetRawPointer() : nullptr) : 0; dlist.xlu = meshXlu != "" ? (Gfx*)(xluRes ? xluRes->GetRawPointer() : nullptr) : 0; + setMesh->opaPaths.push_back(meshOpa); + setMesh->xluPaths.push_back(meshXlu); setMesh->dlists.push_back(dlist); } else if (setMesh->meshHeader.base.type == 1) { PolygonDlist pType; @@ -106,6 +109,8 @@ SetMeshFactory::ReadResource(std::shared_ptr initData, st pType.opa = meshOpa != "" ? (Gfx*)(opaRes ? opaRes->GetRawPointer() : nullptr) : 0; pType.xlu = meshXlu != "" ? (Gfx*)(xluRes ? xluRes->GetRawPointer() : nullptr) : 0; + setMesh->opaPaths.push_back(meshOpa); + setMesh->xluPaths.push_back(meshXlu); setMesh->dlists.push_back(pType); } else if (setMesh->meshHeader.base.type == 2) { PolygonDlist2 dlist; @@ -124,6 +129,8 @@ SetMeshFactory::ReadResource(std::shared_ptr initData, st dlist.opa = (Gfx*)(opaRes ? opaRes->GetRawPointer() : nullptr); dlist.xlu = (Gfx*)(xluRes ? xluRes->GetRawPointer() : nullptr); + setMesh->opaPaths.push_back(meshOpa); + setMesh->xluPaths.push_back(meshXlu); setMesh->dlists2.push_back(dlist); } else { SPDLOG_ERROR("Tried to load mesh in SetMesh scene header with type that doesn't exist: {}", setMesh->meshHeader.base.type); @@ -141,6 +148,175 @@ SetMeshFactory::ReadResource(std::shared_ptr initData, st SPDLOG_ERROR("Tried to load mesh in SetMesh scene header with type that doesn't exist: {}", setMesh->meshHeader.base.type); } + if (CVarGetInteger(CVAR_DEVELOPER_TOOLS("ResourceLogging"), 0)) { + LogMeshAsXML(setMesh); + } + + return setMesh; +} + +std::shared_ptr SetMeshFactoryXML::ReadResource(std::shared_ptr initData, + tinyxml2::XMLElement* reader) { + auto setMesh = std::make_shared(initData); + + setMesh->cmdId = SceneCommandID::SetMesh; + + setMesh->data = reader->IntAttribute("Data"); + + setMesh->meshHeader.base.type = reader->IntAttribute("MeshHeaderType"); + int32_t polyNum = 1; + + if (setMesh->meshHeader.base.type != 1) { + polyNum = reader->IntAttribute("PolyNum"); + if (setMesh->meshHeader.base.type == 0) { + setMesh->meshHeader.polygon0.num = polyNum; + } else if (setMesh->meshHeader.base.type == 2) { + setMesh->meshHeader.polygon2.num = polyNum; + } else { + SPDLOG_ERROR("Tried to load mesh in SetMesh scene header with type that doesn't exist: {}", setMesh->meshHeader.base.type); + } + } + + if (setMesh->meshHeader.base.type == 2) { + setMesh->dlists2.reserve(polyNum); + } else { + setMesh->dlists.reserve(setMesh->meshHeader.polygon0.num); + } + + auto child = reader->FirstChildElement(); + + while (child != nullptr) { + std::string childName = child->Name(); + if (childName != "Polygon") { + child = child->NextSiblingElement(); + continue; + } + + if (setMesh->meshHeader.base.type == 0) { + PolygonDlist dlist; + + int32_t polyType = child->IntAttribute("PolyType"); // Unused + std::string meshOpa = child->Attribute("MeshOpa"); + std::string meshXlu = child->Attribute("MeshXlu"); + + auto opaRes = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshOpa.c_str()); + auto xluRes = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshXlu.c_str()); + dlist.opa = meshOpa != "" ? (Gfx*)(opaRes ? opaRes->GetRawPointer() : nullptr) : 0; + dlist.xlu = meshXlu != "" ? (Gfx*)(xluRes ? xluRes->GetRawPointer() : nullptr) : 0; + + setMesh->opaPaths.push_back(meshOpa); + setMesh->xluPaths.push_back(meshXlu); + setMesh->dlists.push_back(dlist); + } else if (setMesh->meshHeader.base.type == 1) { + PolygonDlist pType; + + setMesh->meshHeader.polygon1.format = child->IntAttribute("Format"); + std::string imgOpa = child->Attribute("ImgOpa"); + std::string imgXlu = child->Attribute("ImgXlu"); + + auto opaRes = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(imgOpa.c_str()); + auto xluRes = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(imgXlu.c_str()); + pType.opa = imgOpa != "" ? (Gfx*)(opaRes ? opaRes->GetRawPointer() : nullptr) : 0; + pType.xlu = imgXlu != "" ? (Gfx*)(xluRes ? xluRes->GetRawPointer() : nullptr) : 0; + + int32_t bgImageCount = child->IntAttribute("BgImageCount"); + setMesh->images.reserve(bgImageCount); + + auto grandChild = child->FirstChildElement(); + + while (grandChild != nullptr) { + std::string grandChildName = grandChild->Name(); + if (grandChildName != "BgImage") { + grandChild = grandChild->NextSiblingElement(); + continue; + } + BgImage image; + image.unk_00 = grandChild->IntAttribute("Unknown_00"); + image.id = grandChild->IntAttribute("Id"); + std::string imagePath = "__OTR__" + std::string(grandChild->Attribute("ImagePath")); + setMesh->imagePaths.push_back(imagePath); + image.source = (void*)setMesh->imagePaths.back().c_str(); + image.unk_0C = grandChild->IntAttribute("Unknown_0C"); + image.tlut = grandChild->IntAttribute("TLUT"); + image.width = grandChild->IntAttribute("Width"); + image.height = grandChild->IntAttribute("Height"); + image.fmt = grandChild->IntAttribute("Fmt"); + image.siz = grandChild->IntAttribute("Siz"); + image.mode0 = grandChild->IntAttribute("Mode0"); + image.tlutCount = grandChild->IntAttribute("TLUTCount"); + + if (setMesh->meshHeader.polygon1.format == 1) { + setMesh->meshHeader.polygon1.single.source = image.source; + setMesh->meshHeader.polygon1.single.unk_0C = image.unk_0C; + setMesh->meshHeader.polygon1.single.tlut = (void*)image.tlut; // OTRTODO: type of bgimage.tlut should be uintptr_t + setMesh->meshHeader.polygon1.single.width = image.width; + setMesh->meshHeader.polygon1.single.height = image.height; + setMesh->meshHeader.polygon1.single.fmt = image.fmt; + setMesh->meshHeader.polygon1.single.siz = image.siz; + setMesh->meshHeader.polygon1.single.mode0 = image.mode0; + setMesh->meshHeader.polygon1.single.tlutCount = image.tlutCount; + } else { + setMesh->images.push_back(image); + } + + grandChild = grandChild->NextSiblingElement(); + } + + if (setMesh->meshHeader.polygon1.format != 1) { + setMesh->meshHeader.polygon1.multi.count = bgImageCount; + } + + int32_t polyType = child->IntAttribute("PolyType"); // Unused?? + + std::string meshOpa = child->Attribute("MeshOpa"); + std::string meshXlu = child->Attribute("MeshXlu"); + + opaRes = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshOpa.c_str()); + xluRes = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshXlu.c_str()); + pType.opa = meshOpa != "" ? (Gfx*)(opaRes ? opaRes->GetRawPointer() : nullptr) : 0; + pType.xlu = meshXlu != "" ? (Gfx*)(xluRes ? xluRes->GetRawPointer() : nullptr) : 0; + + setMesh->opaPaths.push_back(meshOpa); + setMesh->xluPaths.push_back(meshXlu); + setMesh->dlists.push_back(pType); + } else if (setMesh->meshHeader.base.type == 2) { + PolygonDlist2 dlist; + + int32_t polyType = child->IntAttribute("PolyType"); // Unused + dlist.pos.x = child->IntAttribute("PosX"); + dlist.pos.y = child->IntAttribute("PosY"); + dlist.pos.z = child->IntAttribute("PosZ"); + dlist.unk_06 = child->IntAttribute("Unknown"); + + std::string meshOpa = child->Attribute("MeshOpa"); + std::string meshXlu = child->Attribute("MeshXlu"); + + auto opaRes = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshOpa.c_str()); + auto xluRes = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshXlu.c_str()); + dlist.opa = meshOpa != "" ? (Gfx*)(opaRes ? opaRes->GetRawPointer() : nullptr) : 0; + dlist.xlu = meshXlu != "" ? (Gfx*)(xluRes ? xluRes->GetRawPointer() : nullptr) : 0; + + setMesh->opaPaths.push_back(meshOpa); + setMesh->xluPaths.push_back(meshXlu); + setMesh->dlists2.push_back(dlist); + } else { + SPDLOG_ERROR("Tried to load mesh in SetMesh scene header with type that doesn't exist: {}", setMesh->meshHeader.base.type); + } + + child = child->NextSiblingElement(); + } + + if (setMesh->meshHeader.base.type == 2) { + setMesh->meshHeader.polygon2.start = setMesh->dlists2.data(); + } else if (setMesh->meshHeader.base.type == 0) { + setMesh->meshHeader.polygon0.start = setMesh->dlists.data(); + } else if (setMesh->meshHeader.base.type == 1) { + setMesh->meshHeader.polygon1.multi.list = setMesh->images.data(); + setMesh->meshHeader.polygon1.dlist = (Gfx*)setMesh->dlists.data(); + } else { + SPDLOG_ERROR("Tried to load mesh in SetMesh scene header with type that doesn't exist: {}", setMesh->meshHeader.base.type); + } + return setMesh; } } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetMeshFactory.h b/soh/soh/resource/importer/scenecommand/SetMeshFactory.h index a912bdd37a4..f64b55d7251 100644 --- a/soh/soh/resource/importer/scenecommand/SetMeshFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetMeshFactory.h @@ -8,4 +8,10 @@ class SetMeshFactory : public SceneCommandFactoryBinaryV0 { std::shared_ptr ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; + +class SetMeshFactoryXML : public SceneCommandFactoryXMLV0 { + public: + std::shared_ptr + ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; +}; } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetObjectListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetObjectListFactory.cpp index b84befb3bad..1d64a9aecdc 100644 --- a/soh/soh/resource/importer/scenecommand/SetObjectListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetObjectListFactory.cpp @@ -1,5 +1,6 @@ #include "soh/resource/importer/scenecommand/SetObjectListFactory.h" #include "soh/resource/type/scenecommand/SetObjectList.h" +#include "soh/resource/logging/SceneCommandLoggers.h" #include "spdlog/spdlog.h" namespace SOH { @@ -15,6 +16,32 @@ SetObjectListFactory::ReadResource(std::shared_ptr initDa setObjectList->objects.push_back(reader->ReadUInt16()); } + if (CVarGetInteger(CVAR_DEVELOPER_TOOLS("ResourceLogging"), 0)) { + LogObjectListAsXML(setObjectList); + } + + return setObjectList; +} + +std::shared_ptr SetObjectListFactoryXML::ReadResource(std::shared_ptr initData, + tinyxml2::XMLElement* reader) { + auto setObjectList = std::make_shared(initData); + + setObjectList->cmdId = SceneCommandID::SetObjectList; + + auto child = reader->FirstChildElement(); + + while (child != nullptr) { + std::string childName = child->Name(); + if (childName == "ObjectEntry") { + setObjectList->objects.push_back(child->IntAttribute("Id")); + } + + child = child->NextSiblingElement(); + } + + setObjectList->numObjects = setObjectList->objects.size(); + return setObjectList; } } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetObjectListFactory.h b/soh/soh/resource/importer/scenecommand/SetObjectListFactory.h index 4c2f002c07d..094c30a92f4 100644 --- a/soh/soh/resource/importer/scenecommand/SetObjectListFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetObjectListFactory.h @@ -8,4 +8,10 @@ class SetObjectListFactory : public SceneCommandFactoryBinaryV0 { std::shared_ptr ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; + +class SetObjectListFactoryXML : public SceneCommandFactoryXMLV0 { + public: + std::shared_ptr + ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; +}; } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.cpp b/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.cpp index 61534ba48ad..0e26e96e49e 100644 --- a/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.cpp @@ -1,5 +1,6 @@ #include "soh/resource/importer/scenecommand/SetPathwaysFactory.h" #include "soh/resource/type/scenecommand/SetPathways.h" +#include "soh/resource/logging/SceneCommandLoggers.h" #include "spdlog/spdlog.h" #include @@ -18,6 +19,35 @@ SetPathwaysFactory::ReadResource(std::shared_ptr initData setPathways->paths.push_back(path->GetPointer()); } + if (CVarGetInteger(CVAR_DEVELOPER_TOOLS("ResourceLogging"), 0)) { + LogPathwaysAsXML(setPathways); + } + + return setPathways; +} + +std::shared_ptr SetPathwaysFactoryXML::ReadResource(std::shared_ptr initData, + tinyxml2::XMLElement* reader) { + auto setPathways = std::make_shared(initData); + + setPathways->cmdId = SceneCommandID::SetPathways; + + auto child = reader->FirstChildElement(); + + while (child != nullptr) { + std::string childName = child->Name(); + if (childName == "Pathway") { + std::string pathFileName = child->Attribute("FilePath"); + auto path = std::static_pointer_cast(LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(pathFileName.c_str())); + setPathways->paths.push_back(path->GetPointer()); + setPathways->pathFileNames.push_back(pathFileName); + } + + child = child->NextSiblingElement(); + } + + setPathways->numPaths = setPathways->paths.size(); + return setPathways; } } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.h b/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.h index c622c820dca..2e334c7a5e1 100644 --- a/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.h @@ -8,4 +8,10 @@ class SetPathwaysFactory : public SceneCommandFactoryBinaryV0 { std::shared_ptr ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; + +class SetPathwaysFactoryXML : public SceneCommandFactoryXMLV0 { + public: + std::shared_ptr + ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; +}; } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetRoomBehaviorFactory.cpp b/soh/soh/resource/importer/scenecommand/SetRoomBehaviorFactory.cpp index e4601e59cec..25a3bf93151 100644 --- a/soh/soh/resource/importer/scenecommand/SetRoomBehaviorFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetRoomBehaviorFactory.cpp @@ -1,5 +1,6 @@ #include "soh/resource/importer/scenecommand/SetRoomBehaviorFactory.h" #include "soh/resource/type/scenecommand/SetRoomBehavior.h" +#include "soh/resource/logging/SceneCommandLoggers.h" #include "spdlog/spdlog.h" namespace SOH { @@ -12,6 +13,22 @@ SetRoomBehaviorFactory::ReadResource(std::shared_ptr init setRoomBehavior->roomBehavior.gameplayFlags = reader->ReadInt8(); setRoomBehavior->roomBehavior.gameplayFlags2 = reader->ReadInt32(); + if (CVarGetInteger(CVAR_DEVELOPER_TOOLS("ResourceLogging"), 0)) { + LogRoomBehaviorAsXML(setRoomBehavior); + } + + return setRoomBehavior; +} + +std::shared_ptr SetRoomBehaviorFactoryXML::ReadResource(std::shared_ptr initData, + tinyxml2::XMLElement* reader) { + auto setRoomBehavior = std::make_shared(initData); + + setRoomBehavior->cmdId = SceneCommandID::SetRoomBehavior; + + setRoomBehavior->roomBehavior.gameplayFlags = reader->IntAttribute("GameplayFlags1"); + setRoomBehavior->roomBehavior.gameplayFlags2 = reader->IntAttribute("GameplayFlags2"); + return setRoomBehavior; } } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetRoomBehaviorFactory.h b/soh/soh/resource/importer/scenecommand/SetRoomBehaviorFactory.h index 70a53ba1ed3..97c5c7bb48e 100644 --- a/soh/soh/resource/importer/scenecommand/SetRoomBehaviorFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetRoomBehaviorFactory.h @@ -8,4 +8,10 @@ class SetRoomBehaviorFactory : public SceneCommandFactoryBinaryV0 { std::shared_ptr ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; + +class SetRoomBehaviorFactoryXML : public SceneCommandFactoryXMLV0 { + public: + std::shared_ptr + ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; +}; } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetRoomListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetRoomListFactory.cpp index 7726877a1ab..67c3afd0f1c 100644 --- a/soh/soh/resource/importer/scenecommand/SetRoomListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetRoomListFactory.cpp @@ -1,5 +1,6 @@ #include "soh/resource/importer/scenecommand/SetRoomListFactory.h" #include "soh/resource/type/scenecommand/SetRoomList.h" +#include "soh/resource/logging/SceneCommandLoggers.h" #include "spdlog/spdlog.h" namespace SOH { @@ -23,6 +24,40 @@ SetRoomListFactory::ReadResource(std::shared_ptr initData setRoomList->rooms.push_back(room); } + if (CVarGetInteger(CVAR_DEVELOPER_TOOLS("ResourceLogging"), 0)) { + LogRoomListAsXML(setRoomList); + } + + return setRoomList; +} + +std::shared_ptr SetRoomListFactoryXML::ReadResource(std::shared_ptr initData, + tinyxml2::XMLElement* reader) { + auto setRoomList = std::make_shared(initData); + + setRoomList->cmdId = SceneCommandID::SetRoomList; + + auto child = reader->FirstChildElement(); + + while (child != nullptr) { + std::string childName = child->Name(); + if (childName == "RoomEntry") { + RomFile room; + + setRoomList->fileNames.push_back(child->Attribute("Path")); + + room.fileName = (char*)setRoomList->fileNames.back().c_str(); + room.vromStart = child->IntAttribute("VromStart"); + room.vromEnd = child->IntAttribute("VromEnd"); + + setRoomList->rooms.push_back(room); + } + + child = child->NextSiblingElement(); + } + + setRoomList->numRooms = setRoomList->rooms.size(); + return setRoomList; } } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetRoomListFactory.h b/soh/soh/resource/importer/scenecommand/SetRoomListFactory.h index 6bf9eaa5c9d..c6e82dfa932 100644 --- a/soh/soh/resource/importer/scenecommand/SetRoomListFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetRoomListFactory.h @@ -8,4 +8,10 @@ class SetRoomListFactory : public SceneCommandFactoryBinaryV0 { std::shared_ptr ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; + +class SetRoomListFactoryXML : public SceneCommandFactoryXMLV0 { + public: + std::shared_ptr + ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; +}; } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetSkyboxModifierFactory.cpp b/soh/soh/resource/importer/scenecommand/SetSkyboxModifierFactory.cpp index 291ae578cef..9147989dd0f 100644 --- a/soh/soh/resource/importer/scenecommand/SetSkyboxModifierFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetSkyboxModifierFactory.cpp @@ -1,5 +1,6 @@ #include "soh/resource/importer/scenecommand/SetSkyboxModifierFactory.h" #include "soh/resource/type/scenecommand/SetSkyboxModifier.h" +#include "soh/resource/logging/SceneCommandLoggers.h" #include "spdlog/spdlog.h" namespace SOH { @@ -12,6 +13,22 @@ std::shared_ptr SetSkyboxModifierFactory::ReadResource(std::shar setSkyboxModifier->modifier.skyboxDisabled = reader->ReadInt8(); setSkyboxModifier->modifier.sunMoonDisabled = reader->ReadInt8(); + if (CVarGetInteger(CVAR_DEVELOPER_TOOLS("ResourceLogging"), 0)) { + LogSkyboxModifierAsXML(setSkyboxModifier); + } + + return setSkyboxModifier; +} + +std::shared_ptr SetSkyboxModifierFactoryXML::ReadResource(std::shared_ptr initData, + tinyxml2::XMLElement* reader) { + auto setSkyboxModifier = std::make_shared(initData); + + setSkyboxModifier->cmdId = SceneCommandID::SetSkyboxModifier; + + setSkyboxModifier->modifier.skyboxDisabled = reader->IntAttribute("SkyboxDisabled"); + setSkyboxModifier->modifier.sunMoonDisabled = reader->IntAttribute("SunMoonDisabled"); + return setSkyboxModifier; } } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetSkyboxModifierFactory.h b/soh/soh/resource/importer/scenecommand/SetSkyboxModifierFactory.h index d467cc73d7d..cbd260ecc43 100644 --- a/soh/soh/resource/importer/scenecommand/SetSkyboxModifierFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetSkyboxModifierFactory.h @@ -8,4 +8,10 @@ class SetSkyboxModifierFactory : public SceneCommandFactoryBinaryV0 { std::shared_ptr ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; + +class SetSkyboxModifierFactoryXML : public SceneCommandFactoryXMLV0 { + public: + std::shared_ptr + ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; +}; } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetSkyboxSettingsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetSkyboxSettingsFactory.cpp index f3e726b07fb..7f9f4d3d0e9 100644 --- a/soh/soh/resource/importer/scenecommand/SetSkyboxSettingsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetSkyboxSettingsFactory.cpp @@ -1,5 +1,6 @@ #include "soh/resource/importer/scenecommand/SetSkyboxSettingsFactory.h" #include "soh/resource/type/scenecommand/SetSkyboxSettings.h" +#include "soh/resource/logging/SceneCommandLoggers.h" #include "spdlog/spdlog.h" namespace SOH { @@ -14,6 +15,24 @@ std::shared_ptr SetSkyboxSettingsFactory::ReadResource(std::shar setSkyboxSettings->settings.weather = reader->ReadInt8(); setSkyboxSettings->settings.indoors = reader->ReadInt8(); + if (CVarGetInteger(CVAR_DEVELOPER_TOOLS("ResourceLogging"), 0)) { + LogSkyboxSettingsAsXML(setSkyboxSettings); + } + + return setSkyboxSettings; +} + +std::shared_ptr SetSkyboxSettingsFactoryXML::ReadResource(std::shared_ptr initData, + tinyxml2::XMLElement* reader) { + auto setSkyboxSettings = std::make_shared(initData); + + setSkyboxSettings->cmdId = SceneCommandID::SetSkyboxSettings; + + setSkyboxSettings->settings.unk = reader->IntAttribute("Unknown"); + setSkyboxSettings->settings.skyboxId = reader->IntAttribute("SkyboxId"); + setSkyboxSettings->settings.weather = reader->IntAttribute("Weather"); + setSkyboxSettings->settings.indoors = reader->IntAttribute("Indoors"); + return setSkyboxSettings; } } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetSkyboxSettingsFactory.h b/soh/soh/resource/importer/scenecommand/SetSkyboxSettingsFactory.h index 581e561220f..6bc6686672d 100644 --- a/soh/soh/resource/importer/scenecommand/SetSkyboxSettingsFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetSkyboxSettingsFactory.h @@ -8,4 +8,10 @@ class SetSkyboxSettingsFactory : public SceneCommandFactoryBinaryV0 { std::shared_ptr ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; + +class SetSkyboxSettingsFactoryXML : public SceneCommandFactoryXMLV0 { + public: + std::shared_ptr + ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; +}; } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetSoundSettingsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetSoundSettingsFactory.cpp index f85178e22f1..46d81c0748a 100644 --- a/soh/soh/resource/importer/scenecommand/SetSoundSettingsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetSoundSettingsFactory.cpp @@ -1,5 +1,6 @@ #include "soh/resource/importer/scenecommand/SetSoundSettingsFactory.h" #include "soh/resource/type/scenecommand/SetSoundSettings.h" +#include "soh/resource/logging/SceneCommandLoggers.h" #include "spdlog/spdlog.h" namespace SOH { @@ -13,6 +14,23 @@ std::shared_ptr SetSoundSettingsFactory::ReadResource(std::share setSoundSettings->settings.natureAmbienceId = reader->ReadInt8(); setSoundSettings->settings.seqId = reader->ReadInt8(); + if (CVarGetInteger(CVAR_DEVELOPER_TOOLS("ResourceLogging"), 0)) { + LogSoundSettingsAsXML(setSoundSettings); + } + + return setSoundSettings; +} + +std::shared_ptr SetSoundSettingsFactoryXML::ReadResource(std::shared_ptr initData, + tinyxml2::XMLElement* reader) { + auto setSoundSettings = std::make_shared(initData); + + setSoundSettings->cmdId = SceneCommandID::SetSoundSettings; + + setSoundSettings->settings.reverb = reader->IntAttribute("Reverb"); + setSoundSettings->settings.natureAmbienceId = reader->IntAttribute("NatureAmbienceId"); + setSoundSettings->settings.seqId = reader->IntAttribute("SeqId"); + return setSoundSettings; } } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetSoundSettingsFactory.h b/soh/soh/resource/importer/scenecommand/SetSoundSettingsFactory.h index e1c4efb038f..fa6f0ac2faa 100644 --- a/soh/soh/resource/importer/scenecommand/SetSoundSettingsFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetSoundSettingsFactory.h @@ -8,4 +8,10 @@ class SetSoundSettingsFactory : public SceneCommandFactoryBinaryV0 { std::shared_ptr ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; + +class SetSoundSettingsFactoryXML : public SceneCommandFactoryXMLV0 { + public: + std::shared_ptr + ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; +}; } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetSpecialObjectsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetSpecialObjectsFactory.cpp index b7fd21aa4d2..b90aa9c9d64 100644 --- a/soh/soh/resource/importer/scenecommand/SetSpecialObjectsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetSpecialObjectsFactory.cpp @@ -1,5 +1,6 @@ #include "soh/resource/importer/scenecommand/SetSpecialObjectsFactory.h" #include "soh/resource/type/scenecommand/SetSpecialObjects.h" +#include "soh/resource/logging/SceneCommandLoggers.h" #include "spdlog/spdlog.h" namespace SOH { @@ -12,6 +13,22 @@ std::shared_ptr SetSpecialObjectsFactory::ReadResource(std::shar setSpecialObjects->specialObjects.elfMessage = reader->ReadInt8(); setSpecialObjects->specialObjects.globalObject = reader->ReadInt16(); + if (CVarGetInteger(CVAR_DEVELOPER_TOOLS("ResourceLogging"), 0)) { + LogSpecialObjectsAsXML(setSpecialObjects); + } + + return setSpecialObjects; +} + +std::shared_ptr SetSpecialObjectsFactoryXML::ReadResource(std::shared_ptr initData, + tinyxml2::XMLElement* reader) { + auto setSpecialObjects = std::make_shared(initData); + + setSpecialObjects->cmdId = SceneCommandID::SetSpecialObjects; + + setSpecialObjects->specialObjects.elfMessage = reader->IntAttribute("ElfMessage"); + setSpecialObjects->specialObjects.globalObject = reader->IntAttribute("GlobalObject"); + return setSpecialObjects; } } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetSpecialObjectsFactory.h b/soh/soh/resource/importer/scenecommand/SetSpecialObjectsFactory.h index 503cfb61f59..47b30bafc3e 100644 --- a/soh/soh/resource/importer/scenecommand/SetSpecialObjectsFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetSpecialObjectsFactory.h @@ -8,4 +8,10 @@ class SetSpecialObjectsFactory : public SceneCommandFactoryBinaryV0 { std::shared_ptr ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; + +class SetSpecialObjectsFactoryXML : public SceneCommandFactoryXMLV0 { + public: + std::shared_ptr + ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; +}; } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetStartPositionListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetStartPositionListFactory.cpp index 3165b43618c..abfa6f8072c 100644 --- a/soh/soh/resource/importer/scenecommand/SetStartPositionListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetStartPositionListFactory.cpp @@ -1,5 +1,6 @@ #include "soh/resource/importer/scenecommand/SetStartPositionListFactory.h" #include "soh/resource/type/scenecommand/SetStartPositionList.h" +#include "soh/resource/logging/SceneCommandLoggers.h" #include "spdlog/spdlog.h" namespace SOH { @@ -26,6 +27,41 @@ std::shared_ptr SetStartPositionListFactory::ReadResource(std::s setStartPositionList->startPositions.push_back(entry); } + if (CVarGetInteger(CVAR_DEVELOPER_TOOLS("ResourceLogging"), 0)) { + LogStartPositionListAsXML(setStartPositionList); + } + + return setStartPositionList; +} + +std::shared_ptr SetStartPositionListFactoryXML::ReadResource(std::shared_ptr initData, + tinyxml2::XMLElement* reader) { + auto setStartPositionList = std::make_shared(initData); + + setStartPositionList->cmdId = SceneCommandID::SetStartPositionList; + + auto child = reader->FirstChildElement(); + + while (child != nullptr) { + std::string childName = child->Name(); + if (childName == "StartPositionEntry") { + ActorEntry entry; + entry.id = child->IntAttribute("Id"); + entry.pos.x = child->IntAttribute("PosX"); + entry.pos.y = child->IntAttribute("PosY"); + entry.pos.z = child->IntAttribute("PosZ"); + entry.rot.x = child->IntAttribute("RotX"); + entry.rot.y = child->IntAttribute("RotY"); + entry.rot.z = child->IntAttribute("RotZ"); + entry.params = child->IntAttribute("Params"); + setStartPositionList->startPositions.push_back(entry); + } + + child = child->NextSiblingElement(); + } + + setStartPositionList->numStartPositions = setStartPositionList->startPositions.size(); + return setStartPositionList; } } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetStartPositionListFactory.h b/soh/soh/resource/importer/scenecommand/SetStartPositionListFactory.h index b07901f0568..4e381036aa4 100644 --- a/soh/soh/resource/importer/scenecommand/SetStartPositionListFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetStartPositionListFactory.h @@ -8,4 +8,10 @@ class SetStartPositionListFactory : public SceneCommandFactoryBinaryV0 { std::shared_ptr ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; + +class SetStartPositionListFactoryXML : public SceneCommandFactoryXMLV0 { + public: + std::shared_ptr + ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; +}; } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetTimeSettingsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetTimeSettingsFactory.cpp index d83b2458394..8e54e4573fe 100644 --- a/soh/soh/resource/importer/scenecommand/SetTimeSettingsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetTimeSettingsFactory.cpp @@ -1,5 +1,6 @@ #include "soh/resource/importer/scenecommand/SetTimeSettingsFactory.h" #include "soh/resource/type/scenecommand/SetTimeSettings.h" +#include "soh/resource/logging/SceneCommandLoggers.h" #include "spdlog/spdlog.h" namespace SOH { @@ -13,6 +14,23 @@ SetTimeSettingsFactory::ReadResource(std::shared_ptr init setTimeSettings->settings.minute = reader->ReadInt8(); setTimeSettings->settings.timeIncrement = reader->ReadInt8(); + if (CVarGetInteger(CVAR_DEVELOPER_TOOLS("ResourceLogging"), 0)) { + LogTimeSettingsAsXML(setTimeSettings); + } + + return setTimeSettings; +} + +std::shared_ptr SetTimeSettingsFactoryXML::ReadResource(std::shared_ptr initData, + tinyxml2::XMLElement* reader) { + auto setTimeSettings = std::make_shared(initData); + + setTimeSettings->cmdId = SceneCommandID::SetTimeSettings; + + setTimeSettings->settings.hour = reader->IntAttribute("Hour"); + setTimeSettings->settings.minute = reader->IntAttribute("Minute"); + setTimeSettings->settings.timeIncrement = reader->IntAttribute("TimeIncrement"); + return setTimeSettings; } } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetTimeSettingsFactory.h b/soh/soh/resource/importer/scenecommand/SetTimeSettingsFactory.h index d1336f788fe..ff3fdda379e 100644 --- a/soh/soh/resource/importer/scenecommand/SetTimeSettingsFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetTimeSettingsFactory.h @@ -8,4 +8,10 @@ class SetTimeSettingsFactory : public SceneCommandFactoryBinaryV0 { std::shared_ptr ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; + +class SetTimeSettingsFactoryXML : public SceneCommandFactoryXMLV0 { + public: + std::shared_ptr + ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; +}; } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetTransitionActorListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetTransitionActorListFactory.cpp index c751ad611aa..5bf1a114d1d 100644 --- a/soh/soh/resource/importer/scenecommand/SetTransitionActorListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetTransitionActorListFactory.cpp @@ -1,5 +1,6 @@ #include "soh/resource/importer/scenecommand/SetTransitionActorListFactory.h" #include "soh/resource/type/scenecommand/SetTransitionActorList.h" +#include "soh/resource/logging/SceneCommandLoggers.h" #include "spdlog/spdlog.h" namespace SOH { @@ -28,6 +29,43 @@ std::shared_ptr SetTransitionActorListFactory::ReadResource(std: setTransitionActorList->transitionActorList.push_back(entry); } + if (CVarGetInteger(CVAR_DEVELOPER_TOOLS("ResourceLogging"), 0)) { + LogTransitionActorListAsXML(setTransitionActorList); + } + + return setTransitionActorList; +} + +std::shared_ptr SetTransitionActorListFactoryXML::ReadResource(std::shared_ptr initData, + tinyxml2::XMLElement* reader) { + auto setTransitionActorList = std::make_shared(initData); + + setTransitionActorList->cmdId = SceneCommandID::SetTransitionActorList; + + auto child = reader->FirstChildElement(); + + while (child != nullptr) { + std::string childName = child->Name(); + if (childName == "TransitionActorEntry") { + TransitionActorEntry entry; + entry.sides[0].room = child->IntAttribute("FrontSideRoom"); + entry.sides[0].effects = child->IntAttribute("FrontSideEffects"); + entry.sides[1].room = child->IntAttribute("BackSideRoom"); + entry.sides[1].effects = child->IntAttribute("BackSideEffects"); + entry.id = child->IntAttribute("Id"); + entry.pos.x = child->IntAttribute("PosX"); + entry.pos.y = child->IntAttribute("PosY"); + entry.pos.z = child->IntAttribute("PosZ"); + entry.rotY = child->IntAttribute("RotY"); + entry.params = child->IntAttribute("Params"); + setTransitionActorList->transitionActorList.push_back(entry); + } + + child = child->NextSiblingElement(); + } + + setTransitionActorList->numTransitionActors = setTransitionActorList->transitionActorList.size(); + return setTransitionActorList; } } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetTransitionActorListFactory.h b/soh/soh/resource/importer/scenecommand/SetTransitionActorListFactory.h index c8fb65f9af6..eaeb2b5ec74 100644 --- a/soh/soh/resource/importer/scenecommand/SetTransitionActorListFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetTransitionActorListFactory.h @@ -8,4 +8,10 @@ class SetTransitionActorListFactory : public SceneCommandFactoryBinaryV0 { std::shared_ptr ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; + +class SetTransitionActorListFactoryXML : public SceneCommandFactoryXMLV0 { + public: + std::shared_ptr + ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; +}; } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetWindSettingsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetWindSettingsFactory.cpp index 3208004ce5a..77991b12c2b 100644 --- a/soh/soh/resource/importer/scenecommand/SetWindSettingsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetWindSettingsFactory.cpp @@ -1,5 +1,6 @@ #include "soh/resource/importer/scenecommand/SetWindSettingsFactory.h" #include "soh/resource/type/scenecommand/SetWindSettings.h" +#include "soh/resource/logging/SceneCommandLoggers.h" #include "spdlog/spdlog.h" namespace SOH { @@ -14,6 +15,24 @@ SetWindSettingsFactory::ReadResource(std::shared_ptr init setWind->settings.windSouth = reader->ReadInt8(); setWind->settings.windSpeed = reader->ReadUByte(); + if (CVarGetInteger(CVAR_DEVELOPER_TOOLS("ResourceLogging"), 0)) { + LogWindSettingsAsXML(setWind); + } + + return setWind; +} + +std::shared_ptr SetWindSettingsFactoryXML::ReadResource(std::shared_ptr initData, + tinyxml2::XMLElement* reader) { + auto setWind = std::make_shared(initData); + + setWind->cmdId = SceneCommandID::SetWind; + + setWind->settings.windWest = reader->IntAttribute("WindWest"); + setWind->settings.windVertical = reader->IntAttribute("WindVertical"); + setWind->settings.windSouth = reader->IntAttribute("WindSouth"); + setWind->settings.windSpeed = reader->IntAttribute("WindSpeed"); + return setWind; } } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetWindSettingsFactory.h b/soh/soh/resource/importer/scenecommand/SetWindSettingsFactory.h index 6cc9fbc1bc9..bab55dbd953 100644 --- a/soh/soh/resource/importer/scenecommand/SetWindSettingsFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetWindSettingsFactory.h @@ -8,4 +8,10 @@ class SetWindSettingsFactory : public SceneCommandFactoryBinaryV0 { std::shared_ptr ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; + +class SetWindSettingsFactoryXML : public SceneCommandFactoryXMLV0 { + public: + std::shared_ptr + ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; +}; } // namespace SOH diff --git a/soh/soh/resource/logging/SceneCommandLoggers.cpp b/soh/soh/resource/logging/SceneCommandLoggers.cpp new file mode 100644 index 00000000000..b1eeb554daf --- /dev/null +++ b/soh/soh/resource/logging/SceneCommandLoggers.cpp @@ -0,0 +1,603 @@ +#include "soh/resource/type/scenecommand/EndMarker.h" +#include "soh/resource/type/scenecommand/SetActorList.h" +#include "soh/resource/type/scenecommand/SetAlternateHeaders.h" +#include "soh/resource/type/scenecommand/SetCameraSettings.h" +#include "soh/resource/type/scenecommand/SetCollisionHeader.h" +#include "soh/resource/type/scenecommand/SetCsCamera.h" +#include "soh/resource/type/scenecommand/SetCutscenes.h" +#include "soh/resource/type/scenecommand/SetEchoSettings.h" +#include "soh/resource/type/scenecommand/SetEntranceList.h" +#include "soh/resource/type/scenecommand/SetExitList.h" +#include "soh/resource/type/scenecommand/SetLightingSettings.h" +#include "soh/resource/type/scenecommand/SetLightList.h" +#include "soh/resource/type/scenecommand/SetMesh.h" +#include "soh/resource/type/scenecommand/SetObjectList.h" +#include "soh/resource/type/scenecommand/SetPathways.h" +#include "soh/resource/type/scenecommand/SetRoomBehavior.h" +#include "soh/resource/type/scenecommand/SetRoomList.h" +#include "soh/resource/type/scenecommand/SetSkyboxModifier.h" +#include "soh/resource/type/scenecommand/SetSkyboxSettings.h" +#include "soh/resource/type/scenecommand/SetSoundSettings.h" +#include "soh/resource/type/scenecommand/SetSpecialObjects.h" +#include "soh/resource/type/scenecommand/SetStartPositionList.h" +#include "soh/resource/type/scenecommand/SetTimeSettings.h" +#include "soh/resource/type/scenecommand/SetTransitionActorList.h" +#include "soh/resource/type/scenecommand/SetWindSettings.h" +#include "spdlog/spdlog.h" + +namespace SOH { + +void LogEndMarkerAsXML(std::shared_ptr resource) { + std::shared_ptr endMarker = std::static_pointer_cast(resource); + + tinyxml2::XMLDocument doc; + tinyxml2::XMLElement* root = doc.NewElement("EndMarker"); + doc.InsertFirstChild(root); + + tinyxml2::XMLPrinter printer; + doc.Accept(&printer); + + SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr()); +} + +void LogActorListAsXML(std::shared_ptr resource) { + std::shared_ptr setActorList = std::static_pointer_cast(resource); + + tinyxml2::XMLDocument doc; + tinyxml2::XMLElement* root = doc.NewElement("SetActorList"); + doc.InsertFirstChild(root); + + for (size_t i = 0; i < setActorList->numActors; i++) { + tinyxml2::XMLElement* entry = doc.NewElement("ActorEntry"); + entry->SetAttribute("Id", setActorList->actorList[i].id); + entry->SetAttribute("PosX", setActorList->actorList[i].pos.x); + entry->SetAttribute("PosY", setActorList->actorList[i].pos.y); + entry->SetAttribute("PosZ", setActorList->actorList[i].pos.z); + entry->SetAttribute("RotX", setActorList->actorList[i].rot.x); + entry->SetAttribute("RotY", setActorList->actorList[i].rot.y); + entry->SetAttribute("RotZ", setActorList->actorList[i].rot.z); + entry->SetAttribute("Params", setActorList->actorList[i].params); + root->InsertEndChild(entry); + } + + tinyxml2::XMLPrinter printer; + doc.Accept(&printer); + + SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr()); +} + +void LogAlternateHeadersAsXML(std::shared_ptr resource) { + std::shared_ptr setAlternateHeaders = std::static_pointer_cast(resource); + + tinyxml2::XMLDocument doc; + tinyxml2::XMLElement* root = doc.NewElement("SetAlternateHeaders"); + doc.InsertFirstChild(root); + + tinyxml2::XMLPrinter printer; + doc.Accept(&printer); + + SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr()); +} + +void LogCameraSettingsAsXML(std::shared_ptr resource) { + std::shared_ptr setCameraSettings = std::static_pointer_cast(resource); + + tinyxml2::XMLDocument doc; + tinyxml2::XMLElement* root = doc.NewElement("SetCameraSettings"); + doc.InsertFirstChild(root); + + root->SetAttribute("CameraMovement", setCameraSettings->settings.cameraMovement); + root->SetAttribute("WorldMapArea", setCameraSettings->settings.worldMapArea); + + tinyxml2::XMLPrinter printer; + doc.Accept(&printer); + + SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr()); +} + +void LogSetCollisionHeaderAsXML(std::shared_ptr resource) { + std::shared_ptr setCollisionHeader = std::static_pointer_cast(resource); + + tinyxml2::XMLDocument doc; + tinyxml2::XMLElement* root = doc.NewElement("SetCollisionHeader"); + doc.InsertFirstChild(root); + + root->SetAttribute("FileName", setCollisionHeader->fileName.c_str()); + + tinyxml2::XMLPrinter printer; + doc.Accept(&printer); + + SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr()); +} + +void LogCsCameraAsXML(std::shared_ptr resource) { + std::shared_ptr setCsCamera = std::static_pointer_cast(resource); + + tinyxml2::XMLDocument doc; + tinyxml2::XMLElement* root = doc.NewElement("SetCsCamera"); + doc.InsertFirstChild(root); + + tinyxml2::XMLPrinter printer; + doc.Accept(&printer); + + SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr()); +} + +void LogCutscenesAsXML(std::shared_ptr resource) { + std::shared_ptr setCutscenes = std::static_pointer_cast(resource); + + tinyxml2::XMLDocument doc; + tinyxml2::XMLElement* root = doc.NewElement("SetCutscenes"); + doc.InsertFirstChild(root); + + root->SetAttribute("FileName", setCutscenes->fileName.c_str()); + + tinyxml2::XMLPrinter printer; + doc.Accept(&printer); + + SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr()); +} + +void LogEchoSettingsAsXML(std::shared_ptr resource) { + std::shared_ptr setEchoSettings = std::static_pointer_cast(resource); + + tinyxml2::XMLDocument doc; + tinyxml2::XMLElement* root = doc.NewElement("SetEchoSettings"); + doc.InsertFirstChild(root); + + root->SetAttribute("Echo", setEchoSettings->settings.echo); + + tinyxml2::XMLPrinter printer; + doc.Accept(&printer); + + SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr()); +} + +void LogEntranceListAsXML(std::shared_ptr resource) { + std::shared_ptr setEntranceList = std::static_pointer_cast(resource); + + tinyxml2::XMLDocument doc; + tinyxml2::XMLElement* root = doc.NewElement("SetEntranceList"); + doc.InsertFirstChild(root); + + for (size_t i = 0; i < setEntranceList->numEntrances; i++) { + tinyxml2::XMLElement* entry = doc.NewElement("EntranceEntry"); + entry->SetAttribute("Spawn", setEntranceList->entrances[i].spawn); + entry->SetAttribute("Room", setEntranceList->entrances[i].room); + root->InsertEndChild(entry); + } + + tinyxml2::XMLPrinter printer; + doc.Accept(&printer); + + SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr()); +} + +void LogExitListAsXML(std::shared_ptr resource) { + std::shared_ptr setExitList = std::static_pointer_cast(resource); + + tinyxml2::XMLDocument doc; + tinyxml2::XMLElement* root = doc.NewElement("SetExitList"); + doc.InsertFirstChild(root); + + for (size_t i = 0; i < setExitList->numExits; i++) { + tinyxml2::XMLElement* entry = doc.NewElement("ExitEntry"); + entry->SetAttribute("Id", setExitList->exits[i]); + root->InsertEndChild(entry); + } + + tinyxml2::XMLPrinter printer; + doc.Accept(&printer); + + SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr()); +} + +void LogLightingSettingsAsXML(std::shared_ptr resource) { + std::shared_ptr setLightingSettings = std::static_pointer_cast(resource); + + tinyxml2::XMLDocument doc; + tinyxml2::XMLElement* root = doc.NewElement("SetLightingSettings"); + doc.InsertFirstChild(root); + + for (size_t i = 0; i < setLightingSettings->settings.size(); i++) { + tinyxml2::XMLElement* entry = doc.NewElement("LightingSetting"); + entry->SetAttribute("AmbientColorR", setLightingSettings->settings[i].ambientColor[0]); + entry->SetAttribute("AmbientColorG", setLightingSettings->settings[i].ambientColor[1]); + entry->SetAttribute("AmbientColorB", setLightingSettings->settings[i].ambientColor[2]); + + entry->SetAttribute("Light1DirX", setLightingSettings->settings[i].light1Dir[0]); + entry->SetAttribute("Light1DirY", setLightingSettings->settings[i].light1Dir[1]); + entry->SetAttribute("Light1DirZ", setLightingSettings->settings[i].light1Dir[2]); + entry->SetAttribute("Light1ColorR", setLightingSettings->settings[i].light1Color[0]); + entry->SetAttribute("Light1ColorG", setLightingSettings->settings[i].light1Color[1]); + entry->SetAttribute("Light1ColorB", setLightingSettings->settings[i].light1Color[2]); + + entry->SetAttribute("Light2DirX", setLightingSettings->settings[i].light2Dir[0]); + entry->SetAttribute("Light2DirY", setLightingSettings->settings[i].light2Dir[1]); + entry->SetAttribute("Light2DirZ", setLightingSettings->settings[i].light2Dir[2]); + entry->SetAttribute("Light2ColorR", setLightingSettings->settings[i].light2Color[0]); + entry->SetAttribute("Light2ColorG", setLightingSettings->settings[i].light2Color[1]); + entry->SetAttribute("Light2ColorB", setLightingSettings->settings[i].light2Color[2]); + + entry->SetAttribute("FogColorR", setLightingSettings->settings[i].fogColor[0]); + entry->SetAttribute("FogColorG", setLightingSettings->settings[i].fogColor[1]); + entry->SetAttribute("FogColorB", setLightingSettings->settings[i].fogColor[2]); + entry->SetAttribute("FogNear", setLightingSettings->settings[i].fogNear); + entry->SetAttribute("FogFar", setLightingSettings->settings[i].fogFar); + + root->InsertEndChild(entry); + } + + tinyxml2::XMLPrinter printer; + doc.Accept(&printer); + + SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr()); +} + +void LogLightListAsXML(std::shared_ptr resource) { + std::shared_ptr setLightList = std::static_pointer_cast(resource); + + tinyxml2::XMLDocument doc; + tinyxml2::XMLElement* root = doc.NewElement("SetLightList"); + doc.InsertFirstChild(root); + + for (size_t i = 0; i < setLightList->numLights; i++) { + tinyxml2::XMLElement* light = doc.NewElement("LightInfo"); + light->SetAttribute("Type", setLightList->lightList[i].type); + if (false/*setLightList->lightList[i].type == LIGHT_DIRECTIONAL*/) { + light->SetAttribute("X", setLightList->lightList[i].params.dir.x); + light->SetAttribute("Y", setLightList->lightList[i].params.dir.y); + light->SetAttribute("Z", setLightList->lightList[i].params.dir.z); + light->SetAttribute("ColorR", setLightList->lightList[i].params.dir.color[0]); + light->SetAttribute("ColorG", setLightList->lightList[i].params.dir.color[1]); + light->SetAttribute("ColorB", setLightList->lightList[i].params.dir.color[2]); + } else { + light->SetAttribute("X", setLightList->lightList[i].params.point.x); + light->SetAttribute("Y", setLightList->lightList[i].params.point.y); + light->SetAttribute("Z", setLightList->lightList[i].params.point.z); + light->SetAttribute("ColorR", setLightList->lightList[i].params.point.color[0]); + light->SetAttribute("ColorG", setLightList->lightList[i].params.point.color[1]); + light->SetAttribute("ColorB", setLightList->lightList[i].params.point.color[2]); + light->SetAttribute("DrawGlow", setLightList->lightList[i].params.point.drawGlow); + light->SetAttribute("Radius", setLightList->lightList[i].params.point.radius); + } + root->InsertEndChild(light); + } + + tinyxml2::XMLPrinter printer; + doc.Accept(&printer); + + SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr()); +} + +void LogMeshAsXML(std::shared_ptr resource) { + std::shared_ptr setMesh = std::static_pointer_cast(resource); + + tinyxml2::XMLDocument doc; + tinyxml2::XMLElement* root = doc.NewElement("SetMesh"); + doc.InsertFirstChild(root); + + root->SetAttribute("Data", setMesh->data); + root->SetAttribute("MeshHeaderType", setMesh->meshHeader.base.type); + + if (setMesh->meshHeader.base.type == 0) { + root->SetAttribute("PolyNum", setMesh->meshHeader.polygon0.num); + PolygonDlist* dlist = (PolygonDlist*)setMesh->meshHeader.polygon0.start; + for (int i = 0; i < setMesh->meshHeader.polygon0.num; i += 1) { + tinyxml2::XMLElement* polygon = doc.NewElement("Polygon"); + polygon->SetAttribute("PolyType", "0"); + polygon->SetAttribute("MeshOpa", setMesh->opaPaths[i].c_str()); + polygon->SetAttribute("MeshXlu", setMesh->xluPaths[i].c_str()); + + root->InsertEndChild(polygon); + } + dlist += 1; + } else if (setMesh->meshHeader.base.type == 1) { + root->SetAttribute("PolyNum", "1"); + tinyxml2::XMLElement* polygon = doc.NewElement("Polygon"); + polygon->SetAttribute("Format", setMesh->meshHeader.polygon1.format); + polygon->SetAttribute("ImgOpa", ""); + polygon->SetAttribute("ImgXlu", ""); + + if (setMesh->meshHeader.polygon1.format == 1) { + polygon->SetAttribute("BgImageCount", "0"); + } else { + polygon->SetAttribute("BgImageCount", setMesh->meshHeader.polygon1.multi.count); + } + + polygon->SetAttribute("PolyType", "0"); + + polygon->SetAttribute("MeshOpa", setMesh->opaPaths[0].c_str()); + polygon->SetAttribute("MeshXlu", setMesh->xluPaths[0].c_str()); + + root->InsertEndChild(polygon); + + BgImage* image = setMesh->meshHeader.polygon1.multi.list; + int count = setMesh->meshHeader.polygon1.format == 1 ? 1 : setMesh->meshHeader.polygon1.multi.count; + for (int i = 0; i < count; i += 1) { + tinyxml2::XMLElement* bgImage = doc.NewElement("BgImage"); + if (setMesh->meshHeader.polygon1.format == 1) { + bgImage->SetAttribute("Unknown_00", image->unk_00); + bgImage->SetAttribute("Id", image->id); + bgImage->SetAttribute("ImagePath", setMesh->imagePaths[i].c_str()); + bgImage->SetAttribute("Unknown_0C", setMesh->meshHeader.polygon1.single.unk_0C); + bgImage->SetAttribute("TLUT", setMesh->meshHeader.polygon1.single.tlut); + bgImage->SetAttribute("Width", setMesh->meshHeader.polygon1.single.width); + bgImage->SetAttribute("Height", setMesh->meshHeader.polygon1.single.height); + bgImage->SetAttribute("Fmt", setMesh->meshHeader.polygon1.single.fmt); + bgImage->SetAttribute("Siz", setMesh->meshHeader.polygon1.single.siz); + bgImage->SetAttribute("Mode0", setMesh->meshHeader.polygon1.single.mode0); + bgImage->SetAttribute("TLUTCount", setMesh->meshHeader.polygon1.single.tlutCount); + } else { + bgImage->SetAttribute("Unknown_00", image->unk_00); + bgImage->SetAttribute("Id", image->id); + bgImage->SetAttribute("ImagePath", setMesh->imagePaths[i].c_str()); + bgImage->SetAttribute("Unknown_0C", image->unk_0C); + bgImage->SetAttribute("TLUT", image->tlut); + bgImage->SetAttribute("Width", image->width); + bgImage->SetAttribute("Height", image->height); + bgImage->SetAttribute("Fmt", image->fmt); + bgImage->SetAttribute("Siz", image->siz); + bgImage->SetAttribute("Mode0", image->mode0); + bgImage->SetAttribute("TLUTCount", image->tlutCount); + } + polygon->InsertEndChild(bgImage); + + image += 1; + } + } else if (setMesh->meshHeader.base.type == 2) { + root->SetAttribute("PolyNum", setMesh->meshHeader.polygon2.num); + PolygonDlist2* dlist = (PolygonDlist2*)setMesh->meshHeader.polygon2.start; + for (int i = 0; i < setMesh->meshHeader.polygon2.num; i += 1) { + tinyxml2::XMLElement* polygon = doc.NewElement("Polygon"); + polygon->SetAttribute("PolyType", "0"); + + polygon->SetAttribute("PosX", dlist->pos.x); + polygon->SetAttribute("PosY", dlist->pos.y); + polygon->SetAttribute("PosZ", dlist->pos.z); + polygon->SetAttribute("Unknown", dlist->unk_06); + + polygon->SetAttribute("MeshOpa", setMesh->opaPaths[i].c_str()); + polygon->SetAttribute("MeshXlu", setMesh->xluPaths[i].c_str()); + + root->InsertEndChild(polygon); + dlist += 1; + } + } + + tinyxml2::XMLPrinter printer; + doc.Accept(&printer); + + SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr()); +} + +void LogObjectListAsXML(std::shared_ptr resource) { + std::shared_ptr setObjectList = std::static_pointer_cast(resource); + + tinyxml2::XMLDocument doc; + tinyxml2::XMLElement* root = doc.NewElement("SetObjectList"); + doc.InsertFirstChild(root); + + for (size_t i = 0; i < setObjectList->numObjects; i++) { + tinyxml2::XMLElement* entry = doc.NewElement("ObjectEntry"); + entry->SetAttribute("Id", setObjectList->objects[i]); + root->InsertEndChild(entry); + } + + tinyxml2::XMLPrinter printer; + doc.Accept(&printer); + + SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr()); +} + +void LogPathwaysAsXML(std::shared_ptr resource) { + std::shared_ptr setPathways = std::static_pointer_cast(resource); + + tinyxml2::XMLDocument doc; + tinyxml2::XMLElement* root = doc.NewElement("SetPathways"); + doc.InsertFirstChild(root); + + for (size_t i = 0; i < setPathways->pathFileNames.size(); i++) { + tinyxml2::XMLElement* pathway = doc.NewElement("Pathway"); + pathway->SetAttribute("FilePath", setPathways->pathFileNames[i].c_str()); + root->InsertEndChild(pathway); + } + + tinyxml2::XMLPrinter printer; + doc.Accept(&printer); + + SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr()); +} + +void LogRoomBehaviorAsXML(std::shared_ptr resource) { + std::shared_ptr setRoomBehavior = std::static_pointer_cast(resource); + + tinyxml2::XMLDocument doc; + tinyxml2::XMLElement* root = doc.NewElement("SetRoomBehavior"); + doc.InsertFirstChild(root); + + root->SetAttribute("GameplayFlags1", setRoomBehavior->roomBehavior.gameplayFlags); + root->SetAttribute("GameplayFlags2", setRoomBehavior->roomBehavior.gameplayFlags2); + + tinyxml2::XMLPrinter printer; + doc.Accept(&printer); + + SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr()); +} + +void LogRoomListAsXML(std::shared_ptr resource) { + std::shared_ptr setRoomList = std::static_pointer_cast(resource); + + tinyxml2::XMLDocument doc; + tinyxml2::XMLElement* root = doc.NewElement("SetRoomList"); + doc.InsertFirstChild(root); + + for (size_t i = 0; i < setRoomList->numRooms; i++) { + tinyxml2::XMLElement* entry = doc.NewElement("RoomEntry"); + entry->SetAttribute("Path", setRoomList->fileNames[i].c_str()); + root->InsertEndChild(entry); + } + + tinyxml2::XMLPrinter printer; + doc.Accept(&printer); + + SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr()); +} + +void LogSkyboxModifierAsXML(std::shared_ptr resource) { + std::shared_ptr setSkyboxModifier = std::static_pointer_cast(resource); + + tinyxml2::XMLDocument doc; + tinyxml2::XMLElement* root = doc.NewElement("SetSkyboxModifier"); + doc.InsertFirstChild(root); + + root->SetAttribute("SkyboxDisabled", setSkyboxModifier->modifier.skyboxDisabled); + root->SetAttribute("SunMoonDisabled", setSkyboxModifier->modifier.sunMoonDisabled); + + tinyxml2::XMLPrinter printer; + doc.Accept(&printer); + + SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr()); +} + +void LogSkyboxSettingsAsXML(std::shared_ptr resource) { + std::shared_ptr setSkyboxSettings = std::static_pointer_cast(resource); + + tinyxml2::XMLDocument doc; + tinyxml2::XMLElement* root = doc.NewElement("SetSkyboxSettings"); + doc.InsertFirstChild(root); + + root->SetAttribute("Unknown", setSkyboxSettings->settings.unk); + root->SetAttribute("SkyboxId", setSkyboxSettings->settings.skyboxId); + root->SetAttribute("Weather", setSkyboxSettings->settings.weather); + root->SetAttribute("Indoors", setSkyboxSettings->settings.indoors); + + tinyxml2::XMLPrinter printer; + doc.Accept(&printer); + + SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr()); +} + +void LogSoundSettingsAsXML(std::shared_ptr resource) { + std::shared_ptr setSoundSettings = std::static_pointer_cast(resource); + + tinyxml2::XMLDocument doc; + tinyxml2::XMLElement* root = doc.NewElement("SetSoundSettings"); + doc.InsertFirstChild(root); + + root->SetAttribute("Reverb", setSoundSettings->settings.reverb); + root->SetAttribute("NatureAmbienceId", setSoundSettings->settings.natureAmbienceId); + root->SetAttribute("SeqId", setSoundSettings->settings.seqId); + + tinyxml2::XMLPrinter printer; + doc.Accept(&printer); + + SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr()); +} + +void LogSpecialObjectsAsXML(std::shared_ptr resource) { + std::shared_ptr setSpecialObjects = std::static_pointer_cast(resource); + + tinyxml2::XMLDocument doc; + tinyxml2::XMLElement* root = doc.NewElement("SetSpecialObjects"); + doc.InsertFirstChild(root); + + root->SetAttribute("ElfMessage", setSpecialObjects->specialObjects.elfMessage); + root->SetAttribute("GlobalObject", setSpecialObjects->specialObjects.globalObject); + + tinyxml2::XMLPrinter printer; + doc.Accept(&printer); + + SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr()); +} + +void LogStartPositionListAsXML(std::shared_ptr resource) { + std::shared_ptr setStartPositionList = std::static_pointer_cast(resource); + + tinyxml2::XMLDocument doc; + tinyxml2::XMLElement* root = doc.NewElement("SetStartPositionList"); + doc.InsertFirstChild(root); + + for (size_t i = 0; i < setStartPositionList->numStartPositions; i++) { + tinyxml2::XMLElement* entry = doc.NewElement("StartPositionEntry"); + entry->SetAttribute("Id", setStartPositionList->startPositions[i].id); + entry->SetAttribute("PosX", setStartPositionList->startPositions[i].pos.x); + entry->SetAttribute("PosY", setStartPositionList->startPositions[i].pos.y); + entry->SetAttribute("PosZ", setStartPositionList->startPositions[i].pos.z); + entry->SetAttribute("RotX", setStartPositionList->startPositions[i].rot.x); + entry->SetAttribute("RotY", setStartPositionList->startPositions[i].rot.y); + entry->SetAttribute("RotZ", setStartPositionList->startPositions[i].rot.z); + entry->SetAttribute("Params", setStartPositionList->startPositions[i].params); + root->InsertEndChild(entry); + } + + tinyxml2::XMLPrinter printer; + doc.Accept(&printer); + + SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr()); +} + +void LogTimeSettingsAsXML(std::shared_ptr resource) { + std::shared_ptr setTimeSettings = std::static_pointer_cast(resource); + + tinyxml2::XMLDocument doc; + tinyxml2::XMLElement* root = doc.NewElement("SetTimeSettings"); + doc.InsertFirstChild(root); + + root->SetAttribute("Hour", setTimeSettings->settings.hour); + root->SetAttribute("Minute", setTimeSettings->settings.minute); + root->SetAttribute("TimeIncrement", setTimeSettings->settings.timeIncrement); + + tinyxml2::XMLPrinter printer; + doc.Accept(&printer); + + SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr()); +} + +void LogTransitionActorListAsXML(std::shared_ptr resource) { + std::shared_ptr setTransitionActorList = std::static_pointer_cast(resource); + + tinyxml2::XMLDocument doc; + tinyxml2::XMLElement* root = doc.NewElement("SetTransitionActorList"); + doc.InsertFirstChild(root); + + for (size_t i = 0; i < setTransitionActorList->numTransitionActors; i++) { + tinyxml2::XMLElement* entry = doc.NewElement("TransitionActorEntry"); + entry->SetAttribute("FrontSideRoom", setTransitionActorList->transitionActorList[i].sides[0].room); + entry->SetAttribute("FrontSideEffects", setTransitionActorList->transitionActorList[i].sides[0].effects); + entry->SetAttribute("BackSideRoom", setTransitionActorList->transitionActorList[i].sides[1].room); + entry->SetAttribute("BackSideEffects", setTransitionActorList->transitionActorList[i].sides[1].effects); + entry->SetAttribute("Id", setTransitionActorList->transitionActorList[i].id); + entry->SetAttribute("PosX", setTransitionActorList->transitionActorList[i].pos.x); + entry->SetAttribute("PosY", setTransitionActorList->transitionActorList[i].pos.y); + entry->SetAttribute("PosZ", setTransitionActorList->transitionActorList[i].pos.z); + entry->SetAttribute("RotY", setTransitionActorList->transitionActorList[i].rotY); + entry->SetAttribute("Params", setTransitionActorList->transitionActorList[i].params); + root->InsertEndChild(entry); + } + + tinyxml2::XMLPrinter printer; + doc.Accept(&printer); + + SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr()); +} + +void LogWindSettingsAsXML(std::shared_ptr resource) { + std::shared_ptr setWindSettings = std::static_pointer_cast(resource); + + tinyxml2::XMLDocument doc; + tinyxml2::XMLElement* root = doc.NewElement("SetWindSettings"); + doc.InsertFirstChild(root); + + root->SetAttribute("WindWest", setWindSettings->settings.windWest); + root->SetAttribute("WindVertical", setWindSettings->settings.windVertical); + root->SetAttribute("WindSouth", setWindSettings->settings.windSouth); + root->SetAttribute("WindSpeed", setWindSettings->settings.windSpeed); + + tinyxml2::XMLPrinter printer; + doc.Accept(&printer); + + SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr()); +} + +} //namespace SOH \ No newline at end of file diff --git a/soh/soh/resource/logging/SceneCommandLoggers.h b/soh/soh/resource/logging/SceneCommandLoggers.h new file mode 100644 index 00000000000..1351a5c7787 --- /dev/null +++ b/soh/soh/resource/logging/SceneCommandLoggers.h @@ -0,0 +1,32 @@ +#include "Resource.h" +#include "soh/OTRGlobals.h" + +namespace SOH { + +void LogEndMarkerAsXML(std::shared_ptr resource); +void LogActorListAsXML(std::shared_ptr resource); +void LogAlternateHeadersAsXML(std::shared_ptr resource); +void LogCameraSettingsAsXML(std::shared_ptr resource); +void LogSetCollisionHeaderAsXML(std::shared_ptr resource); +void LogCsCameraAsXML(std::shared_ptr resource); +void LogCutscenesAsXML(std::shared_ptr resource); +void LogEchoSettingsAsXML(std::shared_ptr resource); +void LogEntranceListAsXML(std::shared_ptr resource); +void LogExitListAsXML(std::shared_ptr resource); +void LogLightingSettingsAsXML(std::shared_ptr resource); +void LogLightListAsXML(std::shared_ptr resource); +void LogMeshAsXML(std::shared_ptr resource); +void LogObjectListAsXML(std::shared_ptr resource); +void LogPathwaysAsXML(std::shared_ptr resource); +void LogRoomBehaviorAsXML(std::shared_ptr resource); +void LogRoomListAsXML(std::shared_ptr resource); +void LogSkyboxModifierAsXML(std::shared_ptr resource); +void LogSkyboxSettingsAsXML(std::shared_ptr resource); +void LogSoundSettingsAsXML(std::shared_ptr resource); +void LogSpecialObjectsAsXML(std::shared_ptr resource); +void LogStartPositionListAsXML(std::shared_ptr resource); +void LogTimeSettingsAsXML(std::shared_ptr resource); +void LogTransitionActorListAsXML(std::shared_ptr resource); +void LogWindSettingsAsXML(std::shared_ptr resource); + +} //namespace SOH \ No newline at end of file diff --git a/soh/soh/resource/type/scenecommand/SetMesh.h b/soh/soh/resource/type/scenecommand/SetMesh.h index 33ab24202d4..5d4f99c6b61 100644 --- a/soh/soh/resource/type/scenecommand/SetMesh.h +++ b/soh/soh/resource/type/scenecommand/SetMesh.h @@ -94,6 +94,8 @@ class SetMesh : public SceneCommand { uint8_t data; uint8_t meshHeaderType; + std::vector opaPaths; + std::vector xluPaths; std::vector dlists; std::vector dlists2; std::vector imagePaths; diff --git a/soh/soh/resource/type/scenecommand/SetPathways.h b/soh/soh/resource/type/scenecommand/SetPathways.h index cf875cf5e8a..9f22130a623 100644 --- a/soh/soh/resource/type/scenecommand/SetPathways.h +++ b/soh/soh/resource/type/scenecommand/SetPathways.h @@ -18,6 +18,7 @@ class SetPathways : public SceneCommand { size_t GetPointerSize(); uint32_t numPaths; + std::vector pathFileNames; std::vector paths; }; }; // namespace LUS From 552bb2886f79aa602250a947b52b1d56c3b33262 Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Sun, 28 Apr 2024 21:36:44 -0400 Subject: [PATCH 03/59] support lus renamespacing (#4075) --- libultraship | 2 +- .../Enhancements/audio/AudioCollection.cpp | 4 +- soh/soh/Enhancements/audio/AudioEditor.cpp | 30 +- soh/soh/Enhancements/audio/AudioEditor.h | 4 +- soh/soh/Enhancements/controls/InputViewer.cpp | 84 ++--- soh/soh/Enhancements/controls/InputViewer.h | 8 +- .../controls/SohInputEditorWindow.cpp | 322 +++++++++--------- .../controls/SohInputEditorWindow.h | 16 +- .../cosmetics/CosmeticsEditor.cpp | 46 +-- .../Enhancements/cosmetics/CosmeticsEditor.h | 2 +- soh/soh/Enhancements/debugconsole.cpp | 218 ++++++------ soh/soh/Enhancements/debugger/MessageViewer.h | 2 +- soh/soh/Enhancements/debugger/actorViewer.h | 2 +- soh/soh/Enhancements/debugger/colViewer.h | 2 +- .../Enhancements/debugger/debugSaveEditor.cpp | 46 +-- .../Enhancements/debugger/debugSaveEditor.h | 2 +- soh/soh/Enhancements/debugger/dlViewer.cpp | 4 +- soh/soh/Enhancements/debugger/dlViewer.h | 2 +- soh/soh/Enhancements/debugger/valueViewer.h | 2 +- .../GameInteractor_RawAction.cpp | 2 +- .../game-interactor/GameInteractor_Sail.cpp | 4 +- soh/soh/Enhancements/gameplaystatswindow.h | 2 +- soh/soh/Enhancements/mods.cpp | 2 +- soh/soh/Enhancements/presets.cpp | 2 +- .../randomizer/3drando/rando_main.cpp | 2 +- .../randomizer/3drando/spoiler_log.cpp | 6 +- .../Enhancements/randomizer/randomizer.cpp | 16 +- .../randomizer/randomizer_check_tracker.cpp | 2 +- .../randomizer/randomizer_check_tracker.h | 8 +- .../randomizer/randomizer_entrance_tracker.h | 2 +- .../randomizer/randomizer_item_tracker.cpp | 18 +- .../randomizer/randomizer_item_tracker.h | 4 +- .../randomizer/randomizer_settings_window.h | 2 +- .../resolution-editor/ResolutionEditor.cpp | 4 +- .../resolution-editor/ResolutionEditor.h | 4 +- soh/soh/Enhancements/savestates.cpp | 10 +- soh/soh/Enhancements/tts/tts.cpp | 20 +- soh/soh/OTRGlobals.cpp | 140 ++++---- soh/soh/OTRGlobals.h | 2 +- soh/soh/SaveManager.cpp | 14 +- soh/soh/SohGui.cpp | 10 +- soh/soh/SohMenuBar.cpp | 126 +++---- soh/soh/SohMenuBar.h | 4 +- soh/soh/SohModals.h | 4 +- soh/soh/UIWidgets.cpp | 20 +- soh/soh/config/ConfigUpdaters.cpp | 10 +- soh/soh/config/ConfigUpdaters.h | 10 +- .../resource/importer/AnimationFactory.cpp | 4 +- soh/soh/resource/importer/AnimationFactory.h | 4 +- .../resource/importer/AudioSampleFactory.cpp | 6 +- .../resource/importer/AudioSampleFactory.h | 4 +- .../importer/AudioSequenceFactory.cpp | 4 +- .../resource/importer/AudioSequenceFactory.h | 4 +- .../importer/AudioSoundFontFactory.cpp | 14 +- .../resource/importer/AudioSoundFontFactory.h | 4 +- .../resource/importer/BackgroundFactory.cpp | 4 +- soh/soh/resource/importer/BackgroundFactory.h | 4 +- .../importer/CollisionHeaderFactory.cpp | 6 +- .../importer/CollisionHeaderFactory.h | 8 +- soh/soh/resource/importer/CutsceneFactory.cpp | 18 +- soh/soh/resource/importer/CutsceneFactory.h | 4 +- soh/soh/resource/importer/PathFactory.cpp | 4 +- soh/soh/resource/importer/PathFactory.h | 4 +- .../importer/PlayerAnimationFactory.cpp | 4 +- .../importer/PlayerAnimationFactory.h | 4 +- soh/soh/resource/importer/SceneFactory.cpp | 16 +- soh/soh/resource/importer/SceneFactory.h | 12 +- soh/soh/resource/importer/SkeletonFactory.cpp | 10 +- soh/soh/resource/importer/SkeletonFactory.h | 8 +- .../resource/importer/SkeletonLimbFactory.cpp | 6 +- .../resource/importer/SkeletonLimbFactory.h | 8 +- soh/soh/resource/importer/TextFactory.cpp | 6 +- soh/soh/resource/importer/TextFactory.h | 8 +- .../scenecommand/EndMarkerFactory.cpp | 6 +- .../importer/scenecommand/EndMarkerFactory.h | 6 +- .../scenecommand/SceneCommandFactory.cpp | 2 +- .../scenecommand/SceneCommandFactory.h | 6 +- .../scenecommand/SetActorListFactory.cpp | 6 +- .../scenecommand/SetActorListFactory.h | 8 +- .../SetAlternateHeadersFactory.cpp | 10 +- .../scenecommand/SetAlternateHeadersFactory.h | 8 +- .../scenecommand/SetCameraSettingsFactory.cpp | 6 +- .../scenecommand/SetCameraSettingsFactory.h | 8 +- .../SetCollisionHeaderFactory.cpp | 10 +- .../scenecommand/SetCollisionHeaderFactory.h | 8 +- .../scenecommand/SetCsCameraFactory.cpp | 6 +- .../scenecommand/SetCsCameraFactory.h | 8 +- .../scenecommand/SetCutscenesFactory.cpp | 10 +- .../scenecommand/SetCutscenesFactory.h | 8 +- .../scenecommand/SetEchoSettingsFactory.cpp | 6 +- .../scenecommand/SetEchoSettingsFactory.h | 8 +- .../scenecommand/SetEntranceListFactory.cpp | 6 +- .../scenecommand/SetEntranceListFactory.h | 8 +- .../scenecommand/SetExitListFactory.cpp | 6 +- .../scenecommand/SetExitListFactory.h | 8 +- .../scenecommand/SetLightListFactory.cpp | 6 +- .../scenecommand/SetLightListFactory.h | 8 +- .../SetLightingSettingsFactory.cpp | 6 +- .../scenecommand/SetLightingSettingsFactory.h | 8 +- .../importer/scenecommand/SetMeshFactory.cpp | 38 +-- .../importer/scenecommand/SetMeshFactory.h | 8 +- .../scenecommand/SetObjectListFactory.cpp | 6 +- .../scenecommand/SetObjectListFactory.h | 8 +- .../scenecommand/SetPathwaysFactory.cpp | 10 +- .../scenecommand/SetPathwaysFactory.h | 8 +- .../scenecommand/SetRoomBehaviorFactory.cpp | 6 +- .../scenecommand/SetRoomBehaviorFactory.h | 8 +- .../scenecommand/SetRoomListFactory.cpp | 6 +- .../scenecommand/SetRoomListFactory.h | 8 +- .../scenecommand/SetSkyboxModifierFactory.cpp | 6 +- .../scenecommand/SetSkyboxModifierFactory.h | 8 +- .../scenecommand/SetSkyboxSettingsFactory.cpp | 6 +- .../scenecommand/SetSkyboxSettingsFactory.h | 8 +- .../scenecommand/SetSoundSettingsFactory.cpp | 6 +- .../scenecommand/SetSoundSettingsFactory.h | 8 +- .../scenecommand/SetSpecialObjectsFactory.cpp | 6 +- .../scenecommand/SetSpecialObjectsFactory.h | 8 +- .../SetStartPositionListFactory.cpp | 6 +- .../SetStartPositionListFactory.h | 8 +- .../scenecommand/SetTimeSettingsFactory.cpp | 6 +- .../scenecommand/SetTimeSettingsFactory.h | 8 +- .../SetTransitionActorListFactory.cpp | 6 +- .../SetTransitionActorListFactory.h | 8 +- .../scenecommand/SetWindSettingsFactory.cpp | 6 +- .../scenecommand/SetWindSettingsFactory.h | 8 +- .../resource/logging/SceneCommandLoggers.cpp | 50 +-- .../resource/logging/SceneCommandLoggers.h | 50 +-- soh/soh/resource/type/Animation.h | 4 +- soh/soh/resource/type/AudioSample.h | 4 +- soh/soh/resource/type/AudioSequence.h | 4 +- soh/soh/resource/type/AudioSoundFont.h | 4 +- soh/soh/resource/type/Background.h | 4 +- soh/soh/resource/type/CollisionHeader.h | 4 +- soh/soh/resource/type/Cutscene.h | 4 +- soh/soh/resource/type/Path.h | 4 +- soh/soh/resource/type/PlayerAnimation.h | 4 +- soh/soh/resource/type/Scene.h | 4 +- soh/soh/resource/type/Skeleton.cpp | 10 +- soh/soh/resource/type/Skeleton.h | 4 +- soh/soh/resource/type/SkeletonLimb.h | 4 +- soh/soh/resource/type/Text.h | 4 +- .../resource/type/scenecommand/SceneCommand.h | 4 +- soh/soh/z_message_OTR.cpp | 8 +- soh/soh/z_play_otr.cpp | 6 +- soh/soh/z_scene_otr.cpp | 4 +- 145 files changed, 1007 insertions(+), 1007 deletions(-) diff --git a/libultraship b/libultraship index 85f6de497f6..6f978e0d237 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit 85f6de497f6d375390cc3b4ba55eae5ef9c1b153 +Subproject commit 6f978e0d237530f304ba2018bbdc539b175c184a diff --git a/soh/soh/Enhancements/audio/AudioCollection.cpp b/soh/soh/Enhancements/audio/AudioCollection.cpp index d637758a822..8f9c01d0afa 100644 --- a/soh/soh/Enhancements/audio/AudioCollection.cpp +++ b/soh/soh/Enhancements/audio/AudioCollection.cpp @@ -388,7 +388,7 @@ void AudioCollection::RemoveFromShufflePool(SequenceInfo* seqInfo) { excludedSequences.insert(seqInfo); includedSequences.erase(seqInfo); CVarSetInteger(cvarKey.c_str(), 1); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } void AudioCollection::AddToShufflePool(SequenceInfo* seqInfo) { @@ -396,7 +396,7 @@ void AudioCollection::AddToShufflePool(SequenceInfo* seqInfo) { includedSequences.insert(seqInfo); excludedSequences.erase(seqInfo); CVarClear(cvarKey.c_str()); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } void AudioCollection::InitializeShufflePool() { diff --git a/soh/soh/Enhancements/audio/AudioEditor.cpp b/soh/soh/Enhancements/audio/AudioEditor.cpp index e27de6b5686..f33f73b3d5d 100644 --- a/soh/soh/Enhancements/audio/AudioEditor.cpp +++ b/soh/soh/Enhancements/audio/AudioEditor.cpp @@ -203,7 +203,7 @@ void Draw_SfxTab(const std::string& tabId, SeqType type) { auto currentBGM = func_800FA0B4(SEQ_PLAYER_BGM_MAIN); auto prevReplacement = AudioCollection::Instance->GetReplacementSequence(currentBGM); ResetGroup(map, type); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); auto curReplacement = AudioCollection::Instance->GetReplacementSequence(currentBGM); if (type == SEQ_BGM_WORLD && prevReplacement != curReplacement) { ReplayCurrentBGM(); @@ -214,7 +214,7 @@ void Draw_SfxTab(const std::string& tabId, SeqType type) { auto currentBGM = func_800FA0B4(SEQ_PLAYER_BGM_MAIN); auto prevReplacement = AudioCollection::Instance->GetReplacementSequence(currentBGM); RandomizeGroup(type); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); auto curReplacement = AudioCollection::Instance->GetReplacementSequence(currentBGM); if (type == SEQ_BGM_WORLD && prevReplacement != curReplacement) { ReplayCurrentBGM(); @@ -225,7 +225,7 @@ void Draw_SfxTab(const std::string& tabId, SeqType type) { auto currentBGM = func_800FA0B4(SEQ_PLAYER_BGM_MAIN); auto prevReplacement = AudioCollection::Instance->GetReplacementSequence(currentBGM); LockGroup(map, type); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); auto curReplacement = AudioCollection::Instance->GetReplacementSequence(currentBGM); if (type == SEQ_BGM_WORLD && prevReplacement != curReplacement) { ReplayCurrentBGM(); @@ -236,7 +236,7 @@ void Draw_SfxTab(const std::string& tabId, SeqType type) { auto currentBGM = func_800FA0B4(SEQ_PLAYER_BGM_MAIN); auto prevReplacement = AudioCollection::Instance->GetReplacementSequence(currentBGM); UnlockGroup(map, type); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); auto curReplacement = AudioCollection::Instance->GetReplacementSequence(currentBGM); if (type == SEQ_BGM_WORLD && prevReplacement != curReplacement) { ReplayCurrentBGM(); @@ -281,7 +281,7 @@ void Draw_SfxTab(const std::string& tabId, SeqType type) { if (ImGui::Selectable(seqData.label.c_str())) { CVarSetInteger(cvarKey.c_str(), value); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); UpdateCurrentBGM(defaultValue, type); } @@ -301,7 +301,7 @@ void Draw_SfxTab(const std::string& tabId, SeqType type) { if (ImGui::Button(resetButton.c_str())) { CVarClear(cvarKey.c_str()); CVarClear(cvarLockKey.c_str()); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); UpdateCurrentBGM(defaultValue, seqData.category); } UIWidgets::Tooltip("Reset to default"); @@ -322,7 +322,7 @@ void Draw_SfxTab(const std::string& tabId, SeqType type) { if (locked) { CVarClear(cvarLockKey.c_str()); } - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); UpdateCurrentBGM(defaultValue, type); } } @@ -335,7 +335,7 @@ void Draw_SfxTab(const std::string& tabId, SeqType type) { } else { CVarSetInteger(cvarLockKey.c_str(), 1); } - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } UIWidgets::Tooltip(locked ? "Sound locked" : "Sound unlocked"); } @@ -521,7 +521,7 @@ void AudioEditor::DrawElement() { const std::string resetButton = "Reset##linkVoiceFreqMultiplier"; if (ImGui::Button(resetButton.c_str())) { CVarSetFloat(CVAR_AUDIO("LinkVoiceFreqMultiplier"), 1.0f); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } ImGui::NewLine(); @@ -710,14 +710,14 @@ void AudioEditor_RandomizeAll() { RandomizeGroup(type); } - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); ReplayCurrentBGM(); } void AudioEditor_RandomizeGroup(SeqType group) { RandomizeGroup(group); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); ReplayCurrentBGM(); } @@ -726,14 +726,14 @@ void AudioEditor_ResetAll() { ResetGroup(AudioCollection::Instance->GetAllSequences(), type); } - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); ReplayCurrentBGM(); } void AudioEditor_ResetGroup(SeqType group) { ResetGroup(AudioCollection::Instance->GetAllSequences(), group); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); ReplayCurrentBGM(); } @@ -742,7 +742,7 @@ void AudioEditor_LockAll() { LockGroup(AudioCollection::Instance->GetAllSequences(), type); } - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } void AudioEditor_UnlockAll() { @@ -750,5 +750,5 @@ void AudioEditor_UnlockAll() { UnlockGroup(AudioCollection::Instance->GetAllSequences(), type); } - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } diff --git a/soh/soh/Enhancements/audio/AudioEditor.h b/soh/soh/Enhancements/audio/AudioEditor.h index 38a68153940..45c2654e56d 100644 --- a/soh/soh/Enhancements/audio/AudioEditor.h +++ b/soh/soh/Enhancements/audio/AudioEditor.h @@ -10,9 +10,9 @@ #include #include "AudioCollection.h" -class AudioEditor : public LUS::GuiWindow { +class AudioEditor : public Ship::GuiWindow { public: - using LUS::GuiWindow::GuiWindow; + using GuiWindow::GuiWindow; void DrawElement() override; void InitElement() override; diff --git a/soh/soh/Enhancements/controls/InputViewer.cpp b/soh/soh/Enhancements/controls/InputViewer.cpp index fb476e9aac7..52b3527cc64 100644 --- a/soh/soh/Enhancements/controls/InputViewer.cpp +++ b/soh/soh/Enhancements/controls/InputViewer.cpp @@ -47,14 +47,14 @@ void InputViewer::RenderButton(std::string btnTexture, std::string btnOutlineTex // Render Outline based on settings if (outlineMode == BUTTON_OUTLINE_ALWAYS_SHOWN || (outlineMode == BUTTON_OUTLINE_NOT_PRESSED && !state) || (outlineMode == BUTTON_OUTLINE_PRESSED && state)) { - ImGui::Image(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(btnOutlineTexture), size, + ImGui::Image(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(btnOutlineTexture), size, ImVec2(0, 0), ImVec2(1.0f, 1.0f), ImVec4(255, 255, 255, 255)); } // Render button if pressed if (state) { ImGui::SetCursorPos(pos); ImGui::SetNextItemAllowOverlap(); - ImGui::Image(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(btnTexture), size, + ImGui::Image(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(btnTexture), size, ImVec2(0, 0), ImVec2(1.0f, 1.0f), ImVec4(255, 255, 255, 255)); } } @@ -63,61 +63,61 @@ void InputViewer::DrawElement() { if (CVarGetInteger(CVAR_WINDOW("InputViewer"), 0)) { static bool sButtonTexturesLoaded = false; if (!sButtonTexturesLoaded) { - LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage( + Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage( "Input-Viewer-Background", "textures/buttons/InputViewerBackground.png"); - LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("A-Btn", "textures/buttons/ABtn.png"); - LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("B-Btn", "textures/buttons/BBtn.png"); - LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("L-Btn", "textures/buttons/LBtn.png"); - LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("R-Btn", "textures/buttons/RBtn.png"); - LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Z-Btn", "textures/buttons/ZBtn.png"); - LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Start-Btn", + Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("A-Btn", "textures/buttons/ABtn.png"); + Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("B-Btn", "textures/buttons/BBtn.png"); + Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("L-Btn", "textures/buttons/LBtn.png"); + Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("R-Btn", "textures/buttons/RBtn.png"); + Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Z-Btn", "textures/buttons/ZBtn.png"); + Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Start-Btn", "textures/buttons/StartBtn.png"); - LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("C-Left", "textures/buttons/CLeft.png"); - LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("C-Right", "textures/buttons/CRight.png"); - LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("C-Up", "textures/buttons/CUp.png"); - LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("C-Down", "textures/buttons/CDown.png"); - LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Analog-Stick", + Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("C-Left", "textures/buttons/CLeft.png"); + Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("C-Right", "textures/buttons/CRight.png"); + Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("C-Up", "textures/buttons/CUp.png"); + Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("C-Down", "textures/buttons/CDown.png"); + Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Analog-Stick", "textures/buttons/AnalogStick.png"); - LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Dpad-Left", + Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Dpad-Left", "textures/buttons/DPadLeft.png"); - LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Dpad-Right", + Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Dpad-Right", "textures/buttons/DPadRight.png"); - LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Dpad-Up", "textures/buttons/DPadUp.png"); - LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Dpad-Down", + Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Dpad-Up", "textures/buttons/DPadUp.png"); + Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Dpad-Down", "textures/buttons/DPadDown.png"); - LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Right-Stick", + Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Right-Stick", "textures/buttons/RightStick.png"); - LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("A-Btn Outline", + Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("A-Btn Outline", "textures/buttons/ABtnOutline.png"); - LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("B-Btn Outline", + Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("B-Btn Outline", "textures/buttons/BBtnOutline.png"); - LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("L-Btn Outline", + Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("L-Btn Outline", "textures/buttons/LBtnOutline.png"); - LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("R-Btn Outline", + Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("R-Btn Outline", "textures/buttons/RBtnOutline.png"); - LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Z-Btn Outline", + Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Z-Btn Outline", "textures/buttons/ZBtnOutline.png"); - LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Start-Btn Outline", + Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Start-Btn Outline", "textures/buttons/StartBtnOutline.png"); - LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("C-Left Outline", + Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("C-Left Outline", "textures/buttons/CLeftOutline.png"); - LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("C-Right Outline", + Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("C-Right Outline", "textures/buttons/CRightOutline.png"); - LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("C-Up Outline", + Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("C-Up Outline", "textures/buttons/CUpOutline.png"); - LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("C-Down Outline", + Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("C-Down Outline", "textures/buttons/CDownOutline.png"); - LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Analog-Stick Outline", + Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Analog-Stick Outline", "textures/buttons/AnalogStickOutline.png"); - LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Dpad-Left Outline", + Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Dpad-Left Outline", "textures/buttons/DPadLeftOutline.png"); - LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Dpad-Right Outline", + Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Dpad-Right Outline", "textures/buttons/DPadRightOutline.png"); - LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Dpad-Up Outline", + Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Dpad-Up Outline", "textures/buttons/DPadUpOutline.png"); - LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Dpad-Down Outline", + Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Dpad-Down Outline", "textures/buttons/DPadDownOutline.png"); - LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Right-Stick Outline", + Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Right-Stick Outline", "textures/buttons/RightStickOutline.png"); sButtonTexturesLoaded = true; } @@ -133,7 +133,7 @@ void InputViewer::DrawElement() { const int showAnalogAngles = CVarGetInteger("gInputViewer.AnalogAngles.Enabled", 0); const int buttonOutlineMode = CVarGetInteger("gInputViewer.ButtonOutlineMode", BUTTON_OUTLINE_NOT_PRESSED); - ImVec2 bgSize = LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureSize("Input-Viewer-Background"); + ImVec2 bgSize = Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureSize("Input-Viewer-Background"); ImVec2 scaledBGSize = ImVec2(bgSize.x * scale, bgSize.y * scale); ImGui::SetNextWindowSize(ImVec2( @@ -150,7 +150,7 @@ void InputViewer::DrawElement() { ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0, 0, 0, 0)); ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0.0f, 0.0f)); - OSContPad* pads = LUS::Context::GetInstance()->GetControlDeck()->GetPads(); + OSContPad* pads = Ship::Context::GetInstance()->GetControlDeck()->GetPads(); ImGuiWindowFlags windowFlags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoBackground | @@ -168,7 +168,7 @@ void InputViewer::DrawElement() { ImGui::SetNextItemAllowOverlap(); // Background ImGui::Image( - LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Input-Viewer-Background"), + Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Input-Viewer-Background"), scaledBGSize, ImVec2(0, 0), ImVec2(1.0f, 1.0f), ImVec4(255, 255, 255, 255)); } @@ -263,7 +263,7 @@ void InputViewer::DrawElement() { ImGui::SetNextItemAllowOverlap(); ImGui::SetCursorPos(aPos); ImGui::Image( - LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Analog-Stick Outline"), + Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Analog-Stick Outline"), scaledBGSize, ImVec2(0, 0), ImVec2(1.0f, 1.0f), ImVec4(255, 255, 255, 255)); } const int analogStickMode = @@ -274,7 +274,7 @@ void InputViewer::DrawElement() { ImGui::SetCursorPos( ImVec2(aPos.x + maxStickDistance * ((float)(pads[0].stick_x) / MAX_AXIS_RANGE) * scale, aPos.y - maxStickDistance * ((float)(pads[0].stick_y) / MAX_AXIS_RANGE) * scale)); - ImGui::Image(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Analog-Stick"), + ImGui::Image(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Analog-Stick"), scaledBGSize, ImVec2(0, 0), ImVec2(1.0f, 1.0f), ImVec4(255, 255, 255, 255)); } @@ -287,7 +287,7 @@ void InputViewer::DrawElement() { ImGui::SetNextItemAllowOverlap(); ImGui::SetCursorPos(aPos); ImGui::Image( - LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Right-Stick Outline"), + Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Right-Stick Outline"), scaledBGSize, ImVec2(0, 0), ImVec2(1.0f, 1.0f), ImVec4(255, 255, 255, 255)); } const int rightStickMode = @@ -298,7 +298,7 @@ void InputViewer::DrawElement() { ImGui::SetCursorPos( ImVec2(aPos.x + maxRightStickDistance * ((float)(pads[0].right_stick_x) / MAX_AXIS_RANGE) * scale, aPos.y - maxRightStickDistance * ((float)(pads[0].right_stick_y) / MAX_AXIS_RANGE) * scale)); - ImGui::Image(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Right-Stick"), + ImGui::Image(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Right-Stick"), scaledBGSize, ImVec2(0, 0), ImVec2(1.0f, 1.0f), ImVec4(255, 255, 255, 255)); } diff --git a/soh/soh/Enhancements/controls/InputViewer.h b/soh/soh/Enhancements/controls/InputViewer.h index 6f2e2c58720..4d528ead484 100644 --- a/soh/soh/Enhancements/controls/InputViewer.h +++ b/soh/soh/Enhancements/controls/InputViewer.h @@ -15,9 +15,9 @@ typedef enum { STICK_MODE_ALWAYS_HIDDEN, } StickMode; -class InputViewer : public LUS::GuiWindow { +class InputViewer : public Ship::GuiWindow { public: - using LUS::GuiWindow::GuiWindow; + using GuiWindow::GuiWindow; void InitElement() override {}; void DrawElement() override; @@ -32,9 +32,9 @@ class InputViewer : public LUS::GuiWindow { void RenderButton(std::string btn, std::string btnOutline, int state, ImVec2 size, int outlineMode); }; -class InputViewerSettingsWindow : public LUS::GuiWindow { +class InputViewerSettingsWindow : public Ship::GuiWindow { public: - using LUS::GuiWindow::GuiWindow; + using GuiWindow::GuiWindow; void InitElement() override {}; void DrawElement() override; diff --git a/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp b/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp index 02781bf049a..be71c7de157 100644 --- a/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp +++ b/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp @@ -57,7 +57,7 @@ void SohInputEditorWindow::UpdateElement() { } if (mInputEditorPopupOpen && ImGui::IsPopupOpen("", ImGuiPopupFlags_AnyPopupId)) { - LUS::Context::GetInstance()->GetControlDeck()->BlockGameInput(INPUT_EDITOR_WINDOW_GAME_INPUT_BLOCK_ID); + Ship::Context::GetInstance()->GetControlDeck()->BlockGameInput(INPUT_EDITOR_WINDOW_GAME_INPUT_BLOCK_ID); // continue to block input for a third of a second after getting the mapping mGameInputBlockTimer = ImGui::GetIO().Framerate / 3; @@ -69,24 +69,24 @@ void SohInputEditorWindow::UpdateElement() { } } - LUS::Context::GetInstance()->GetWindow()->GetGui()->BlockImGuiGamepadNavigation(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->BlockImGuiGamepadNavigation(); } else { if (mGameInputBlockTimer != INT32_MAX) { mGameInputBlockTimer--; if (mGameInputBlockTimer <= 0) { - LUS::Context::GetInstance()->GetControlDeck()->UnblockGameInput( + Ship::Context::GetInstance()->GetControlDeck()->UnblockGameInput( INPUT_EDITOR_WINDOW_GAME_INPUT_BLOCK_ID); mGameInputBlockTimer = INT32_MAX; } } - if (LUS::Context::GetInstance()->GetWindow()->GetGui()->ImGuiGamepadNavigationEnabled()) { + if (Ship::Context::GetInstance()->GetWindow()->GetGui()->ImGuiGamepadNavigationEnabled()) { mMappingInputBlockTimer = ImGui::GetIO().Framerate / 3; } else { mMappingInputBlockTimer = INT32_MAX; } - LUS::Context::GetInstance()->GetWindow()->GetGui()->UnblockImGuiGamepadNavigation(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->UnblockImGuiGamepadNavigation(); } } @@ -176,26 +176,26 @@ void SohInputEditorWindow::DrawAnalogPreview(const char* label, ImVec2 stick, fl #define BUTTON_COLOR_GAMEPAD_PURPLE ImVec4(0.431f, 0.369f, 0.706f, 0.5f) #define BUTTON_COLOR_GAMEPAD_PURPLE_HOVERED ImVec4(0.431f, 0.369f, 0.706f, 1.0f) -void SohInputEditorWindow::GetButtonColorsForLUSDeviceIndex(LUS::LUSDeviceIndex lusIndex, ImVec4& buttonColor, +void SohInputEditorWindow::GetButtonColorsForLUSDeviceIndex(Ship::ShipDeviceIndex lusIndex, ImVec4& buttonColor, ImVec4& buttonHoveredColor) { switch (lusIndex) { - case LUS::LUSDeviceIndex::Keyboard: + case Ship::ShipDeviceIndex::Keyboard: buttonColor = BUTTON_COLOR_KEYBOARD_BEIGE; buttonHoveredColor = BUTTON_COLOR_KEYBOARD_BEIGE_HOVERED; break; - case LUS::LUSDeviceIndex::Blue: + case Ship::ShipDeviceIndex::Blue: buttonColor = BUTTON_COLOR_GAMEPAD_BLUE; buttonHoveredColor = BUTTON_COLOR_GAMEPAD_BLUE_HOVERED; break; - case LUS::LUSDeviceIndex::Red: + case Ship::ShipDeviceIndex::Red: buttonColor = BUTTON_COLOR_GAMEPAD_RED; buttonHoveredColor = BUTTON_COLOR_GAMEPAD_RED_HOVERED; break; - case LUS::LUSDeviceIndex::Orange: + case Ship::ShipDeviceIndex::Orange: buttonColor = BUTTON_COLOR_GAMEPAD_ORANGE; buttonHoveredColor = BUTTON_COLOR_GAMEPAD_ORANGE_HOVERED; break; - case LUS::LUSDeviceIndex::Green: + case Ship::ShipDeviceIndex::Green: buttonColor = BUTTON_COLOR_GAMEPAD_GREEN; buttonHoveredColor = BUTTON_COLOR_GAMEPAD_GREEN_HOVERED; break; @@ -230,7 +230,7 @@ void SohInputEditorWindow::DrawButtonLineAddMappingButton(uint8_t port, uint16_t ImGui::CloseCurrentPopup(); } // todo: figure out why optional params (using id = "" in the definition) wasn't working - if (mMappingInputBlockTimer == INT32_MAX && LUS::Context::GetInstance() + if (mMappingInputBlockTimer == INT32_MAX && Ship::Context::GetInstance() ->GetControlDeck() ->GetControllerByPort(port) ->GetButton(bitmask) @@ -243,7 +243,7 @@ void SohInputEditorWindow::DrawButtonLineAddMappingButton(uint8_t port, uint16_t } void SohInputEditorWindow::DrawButtonLineEditMappingButton(uint8_t port, uint16_t bitmask, std::string id) { - auto mapping = LUS::Context::GetInstance() + auto mapping = Ship::Context::GetInstance() ->GetControlDeck() ->GetControllerByPort(port) ->GetButton(bitmask) @@ -269,7 +269,7 @@ void SohInputEditorWindow::DrawButtonLineEditMappingButton(uint8_t port, uint16_ auto buttonHoveredColor = ImGui::GetStyleColorVec4(ImGuiCol_ButtonHovered); auto physicalInputDisplayName = StringHelper::Sprintf("%s %s", icon.c_str(), mapping->GetPhysicalInputName().c_str()); - GetButtonColorsForLUSDeviceIndex(mapping->GetLUSDeviceIndex(), buttonColor, buttonHoveredColor); + GetButtonColorsForLUSDeviceIndex(mapping->GetShipDeviceIndex(), buttonColor, buttonHoveredColor); ImGui::PushStyleColor(ImGuiCol_Button, buttonColor); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, buttonHoveredColor); auto popupId = StringHelper::Sprintf("editButtonMappingPopup##%s", id.c_str()); @@ -292,7 +292,7 @@ void SohInputEditorWindow::DrawButtonLineEditMappingButton(uint8_t port, uint16_ mInputEditorPopupOpen = false; ImGui::CloseCurrentPopup(); } - if (mMappingInputBlockTimer == INT32_MAX && LUS::Context::GetInstance() + if (mMappingInputBlockTimer == INT32_MAX && Ship::Context::GetInstance() ->GetControlDeck() ->GetControllerByPort(port) ->GetButton(bitmask) @@ -307,18 +307,18 @@ void SohInputEditorWindow::DrawButtonLineEditMappingButton(uint8_t port, uint16_ ImGui::SameLine(0, 0); #ifndef __WIIU__ - auto sdlAxisDirectionToButtonMapping = std::dynamic_pointer_cast(mapping); - auto indexMapping = LUS::Context::GetInstance() + auto sdlAxisDirectionToButtonMapping = std::dynamic_pointer_cast(mapping); + auto indexMapping = Ship::Context::GetInstance() ->GetControlDeck() ->GetDeviceIndexMappingManager() - ->GetDeviceIndexMappingFromLUSDeviceIndex(mapping->GetLUSDeviceIndex()); - auto sdlIndexMapping = std::dynamic_pointer_cast(indexMapping); + ->GetDeviceIndexMappingFromShipDeviceIndex(mapping->GetShipDeviceIndex()); + auto sdlIndexMapping = std::dynamic_pointer_cast(indexMapping); if (sdlIndexMapping != nullptr && sdlAxisDirectionToButtonMapping != nullptr) { ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0.0f, 0.5f)); auto buttonColor = ImGui::GetStyleColorVec4(ImGuiCol_Button); auto buttonHoveredColor = ImGui::GetStyleColorVec4(ImGuiCol_ButtonHovered); - GetButtonColorsForLUSDeviceIndex(mapping->GetLUSDeviceIndex(), buttonColor, buttonHoveredColor); + GetButtonColorsForLUSDeviceIndex(mapping->GetShipDeviceIndex(), buttonColor, buttonHoveredColor); ImGui::PushStyleColor(ImGuiCol_Button, buttonColor); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, buttonHoveredColor); ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(1.0f, 0.5f)); @@ -433,7 +433,7 @@ void SohInputEditorWindow::DrawButtonLineEditMappingButton(uint8_t port, uint16_ ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(1.0f, 0.5f)); if (ImGui::Button(StringHelper::Sprintf("%s###removeButtonMappingButton%s", ICON_FA_TIMES, id.c_str()).c_str(), ImVec2(ImGui::CalcTextSize(ICON_FA_TIMES).x + SCALE_IMGUI_SIZE(10.0f), 0.0f))) { - LUS::Context::GetInstance() + Ship::Context::GetInstance() ->GetControlDeck() ->GetControllerByPort(port) ->GetButton(bitmask) @@ -459,7 +459,7 @@ void SohInputEditorWindow::DrawButtonLine(const char* buttonName, uint8_t port, } void SohInputEditorWindow::DrawStickDirectionLineAddMappingButton(uint8_t port, uint8_t stick, - LUS::Direction direction) { + Ship::Direction direction) { ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(1.0f, 0.5f)); auto popupId = StringHelper::Sprintf("addStickDirectionMappingPopup##%d-%d-%d", port, stick, direction); if (ImGui::Button( @@ -477,9 +477,9 @@ void SohInputEditorWindow::DrawStickDirectionLineAddMappingButton(uint8_t port, mInputEditorPopupOpen = false; ImGui::CloseCurrentPopup(); } - if (stick == LUS::LEFT) { + if (stick == Ship::LEFT) { if (mMappingInputBlockTimer == INT32_MAX && - LUS::Context::GetInstance() + Ship::Context::GetInstance() ->GetControlDeck() ->GetControllerByPort(port) ->GetLeftStick() @@ -489,7 +489,7 @@ void SohInputEditorWindow::DrawStickDirectionLineAddMappingButton(uint8_t port, } } else { if (mMappingInputBlockTimer == INT32_MAX && - LUS::Context::GetInstance() + Ship::Context::GetInstance() ->GetControlDeck() ->GetControllerByPort(port) ->GetRightStick() @@ -502,16 +502,16 @@ void SohInputEditorWindow::DrawStickDirectionLineAddMappingButton(uint8_t port, } void SohInputEditorWindow::DrawStickDirectionLineEditMappingButton(uint8_t port, uint8_t stick, - LUS::Direction direction, std::string id) { - std::shared_ptr mapping = nullptr; - if (stick == LUS::LEFT) { - mapping = LUS::Context::GetInstance() + Ship::Direction direction, std::string id) { + std::shared_ptr mapping = nullptr; + if (stick == Ship::LEFT) { + mapping = Ship::Context::GetInstance() ->GetControlDeck() ->GetControllerByPort(port) ->GetLeftStick() ->GetAxisDirectionMappingById(direction, id); } else { - mapping = LUS::Context::GetInstance() + mapping = Ship::Context::GetInstance() ->GetControlDeck() ->GetControllerByPort(port) ->GetRightStick() @@ -539,7 +539,7 @@ void SohInputEditorWindow::DrawStickDirectionLineEditMappingButton(uint8_t port, auto buttonHoveredColor = ImGui::GetStyleColorVec4(ImGuiCol_ButtonHovered); auto physicalInputDisplayName = StringHelper::Sprintf("%s %s", icon.c_str(), mapping->GetPhysicalInputName().c_str()); - GetButtonColorsForLUSDeviceIndex(mapping->GetLUSDeviceIndex(), buttonColor, buttonHoveredColor); + GetButtonColorsForLUSDeviceIndex(mapping->GetShipDeviceIndex(), buttonColor, buttonHoveredColor); ImGui::PushStyleColor(ImGuiCol_Button, buttonColor); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, buttonHoveredColor); auto popupId = StringHelper::Sprintf("editStickDirectionMappingPopup##%s", id.c_str()); @@ -564,9 +564,9 @@ void SohInputEditorWindow::DrawStickDirectionLineEditMappingButton(uint8_t port, ImGui::CloseCurrentPopup(); } - if (stick == LUS::LEFT) { + if (stick == Ship::LEFT) { if (mMappingInputBlockTimer == INT32_MAX && - LUS::Context::GetInstance() + Ship::Context::GetInstance() ->GetControlDeck() ->GetControllerByPort(port) ->GetLeftStick() @@ -576,7 +576,7 @@ void SohInputEditorWindow::DrawStickDirectionLineEditMappingButton(uint8_t port, } } else { if (mMappingInputBlockTimer == INT32_MAX && - LUS::Context::GetInstance() + Ship::Context::GetInstance() ->GetControlDeck() ->GetControllerByPort(port) ->GetRightStick() @@ -595,14 +595,14 @@ void SohInputEditorWindow::DrawStickDirectionLineEditMappingButton(uint8_t port, if (ImGui::Button( StringHelper::Sprintf("%s###removeStickDirectionMappingButton%s", ICON_FA_TIMES, id.c_str()).c_str(), ImVec2(ImGui::CalcTextSize(ICON_FA_TIMES).x + SCALE_IMGUI_SIZE(10.0f), 0.0f))) { - if (stick == LUS::LEFT) { - LUS::Context::GetInstance() + if (stick == Ship::LEFT) { + Ship::Context::GetInstance() ->GetControlDeck() ->GetControllerByPort(port) ->GetLeftStick() ->ClearAxisDirectionMapping(direction, id); } else { - LUS::Context::GetInstance() + Ship::Context::GetInstance() ->GetControlDeck() ->GetControllerByPort(port) ->GetRightStick() @@ -616,7 +616,7 @@ void SohInputEditorWindow::DrawStickDirectionLineEditMappingButton(uint8_t port, } void SohInputEditorWindow::DrawStickDirectionLine(const char* axisDirectionName, uint8_t port, uint8_t stick, - LUS::Direction direction, ImVec4 color = CHIP_COLOR_N64_GREY) { + Ship::Direction direction, ImVec4 color = CHIP_COLOR_N64_GREY) { ImGui::NewLine(); ImGui::SameLine(); ImGui::BeginDisabled(); @@ -634,21 +634,21 @@ void SohInputEditorWindow::DrawStickDirectionLine(const char* axisDirectionName, void SohInputEditorWindow::DrawStickSection(uint8_t port, uint8_t stick, int32_t id, ImVec4 color = CHIP_COLOR_N64_GREY) { static int8_t sX, sY; - std::shared_ptr controllerStick = nullptr; - if (stick == LUS::LEFT) { - controllerStick = LUS::Context::GetInstance()->GetControlDeck()->GetControllerByPort(port)->GetLeftStick(); + std::shared_ptr controllerStick = nullptr; + if (stick == Ship::LEFT) { + controllerStick = Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(port)->GetLeftStick(); } else { - controllerStick = LUS::Context::GetInstance()->GetControlDeck()->GetControllerByPort(port)->GetRightStick(); + controllerStick = Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(port)->GetRightStick(); } controllerStick->Process(sX, sY); DrawAnalogPreview(StringHelper::Sprintf("##AnalogPreview%d", id).c_str(), ImVec2(sX, sY)); ImGui::SameLine(); ImGui::BeginGroup(); - DrawStickDirectionLine(ICON_FA_ARROW_UP, port, stick, LUS::UP, color); - DrawStickDirectionLine(ICON_FA_ARROW_DOWN, port, stick, LUS::DOWN, color); - DrawStickDirectionLine(ICON_FA_ARROW_LEFT, port, stick, LUS::LEFT, color); - DrawStickDirectionLine(ICON_FA_ARROW_RIGHT, port, stick, LUS::RIGHT, color); + DrawStickDirectionLine(ICON_FA_ARROW_UP, port, stick, Ship::UP, color); + DrawStickDirectionLine(ICON_FA_ARROW_DOWN, port, stick, Ship::DOWN, color); + DrawStickDirectionLine(ICON_FA_ARROW_LEFT, port, stick, Ship::LEFT, color); + DrawStickDirectionLine(ICON_FA_ARROW_RIGHT, port, stick, Ship::RIGHT, color); ImGui::EndGroup(); ImGui::SetNextItemOpen(true, ImGuiCond_Once); if (ImGui::TreeNode(StringHelper::Sprintf("Analog Stick Options##%d", id).c_str())) { @@ -776,7 +776,7 @@ void SohInputEditorWindow::UpdateBitmaskToMappingIds(uint8_t port) { // todo: do we need this now that ControllerButton exists? for (auto [bitmask, button] : - LUS::Context::GetInstance()->GetControlDeck()->GetControllerByPort(port)->GetAllButtons()) { + Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(port)->GetAllButtons()) { for (auto [id, mapping] : button->GetAllButtonMappings()) { // using a vector here instead of a set because i want newly added mappings // to go to the end of the list instead of autosorting @@ -791,12 +791,12 @@ void SohInputEditorWindow::UpdateBitmaskToMappingIds(uint8_t port) { void SohInputEditorWindow::UpdateStickDirectionToMappingIds(uint8_t port) { // todo: do we need this? for (auto stick : - { std::make_pair>( - LUS::LEFT, LUS::Context::GetInstance()->GetControlDeck()->GetControllerByPort(port)->GetLeftStick()), - std::make_pair>( - LUS::RIGHT, - LUS::Context::GetInstance()->GetControlDeck()->GetControllerByPort(port)->GetRightStick()) }) { - for (auto direction : { LUS::LEFT, LUS::RIGHT, LUS::UP, LUS::DOWN }) { + { std::make_pair>( + Ship::LEFT, Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(port)->GetLeftStick()), + std::make_pair>( + Ship::RIGHT, + Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(port)->GetRightStick()) }) { + for (auto direction : { Ship::LEFT, Ship::RIGHT, Ship::UP, Ship::DOWN }) { for (auto [id, mapping] : stick.second->GetAllAxisDirectionMappingByDirection(direction)) { // using a vector here instead of a set because i want newly added mappings // to go to the end of the list instead of autosorting @@ -815,7 +815,7 @@ void SohInputEditorWindow::DrawRemoveRumbleMappingButton(uint8_t port, std::stri ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(1.0f, 0.5f)); if (ImGui::Button(StringHelper::Sprintf("%s###removeRumbleMapping%s", ICON_FA_TIMES, id.c_str()).c_str(), ImVec2(SCALE_IMGUI_SIZE(20.0f), SCALE_IMGUI_SIZE(20.0f)))) { - LUS::Context::GetInstance()->GetControlDeck()->GetControllerByPort(port)->GetRumble()->ClearRumbleMapping(id); + Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(port)->GetRumble()->ClearRumbleMapping(id); } ImGui::PopStyleVar(); } @@ -838,7 +838,7 @@ void SohInputEditorWindow::DrawAddRumbleMappingButton(uint8_t port) { ImGui::CloseCurrentPopup(); } - if (mMappingInputBlockTimer == INT32_MAX && LUS::Context::GetInstance() + if (mMappingInputBlockTimer == INT32_MAX && Ship::Context::GetInstance() ->GetControlDeck() ->GetControllerByPort(port) ->GetRumble() @@ -855,7 +855,7 @@ bool SohInputEditorWindow::TestingRumble() { } void SohInputEditorWindow::DrawRumbleSection(uint8_t port) { - for (auto [id, mapping] : LUS::Context::GetInstance() + for (auto [id, mapping] : Ship::Context::GetInstance() ->GetControlDeck() ->GetControllerByPort(port) ->GetRumble() @@ -864,7 +864,7 @@ void SohInputEditorWindow::DrawRumbleSection(uint8_t port) { ImGui::SetNextItemOpen(true, ImGuiCond_Once); auto buttonColor = ImGui::GetStyleColorVec4(ImGuiCol_Button); auto buttonHoveredColor = ImGui::GetStyleColorVec4(ImGuiCol_ButtonHovered); - GetButtonColorsForLUSDeviceIndex(mapping->GetLUSDeviceIndex(), buttonColor, buttonHoveredColor); + GetButtonColorsForLUSDeviceIndex(mapping->GetShipDeviceIndex(), buttonColor, buttonHoveredColor); // begin hackaround https://github.com/ocornut/imgui/issues/282#issuecomment-123763192 // spaces to have background color for text in a tree node std::string spaces = ""; @@ -998,7 +998,7 @@ void SohInputEditorWindow::DrawRemoveLEDMappingButton(uint8_t port, std::string ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(1.0f, 0.5f)); if (ImGui::Button(StringHelper::Sprintf("%s###removeLEDMapping%s", ICON_FA_TIMES, id.c_str()).c_str(), ImVec2(SCALE_IMGUI_SIZE(20.0f), SCALE_IMGUI_SIZE(20.0f)))) { - LUS::Context::GetInstance()->GetControlDeck()->GetControllerByPort(port)->GetLED()->ClearLEDMapping(id); + Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(port)->GetLED()->ClearLEDMapping(id); } ImGui::PopStyleVar(); } @@ -1021,7 +1021,7 @@ void SohInputEditorWindow::DrawAddLEDMappingButton(uint8_t port) { ImGui::CloseCurrentPopup(); } - if (mMappingInputBlockTimer == INT32_MAX && LUS::Context::GetInstance() + if (mMappingInputBlockTimer == INT32_MAX && Ship::Context::GetInstance() ->GetControlDeck() ->GetControllerByPort(port) ->GetLED() @@ -1035,7 +1035,7 @@ void SohInputEditorWindow::DrawAddLEDMappingButton(uint8_t port) { void SohInputEditorWindow::DrawLEDSection(uint8_t port) { for (auto [id, mapping] : - LUS::Context::GetInstance()->GetControlDeck()->GetControllerByPort(port)->GetLED()->GetAllLEDMappings()) { + Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(port)->GetLED()->GetAllLEDMappings()) { ImGui::AlignTextToFramePadding(); ImGui::SetNextItemOpen(true, ImGuiCond_Once); auto open = ImGui::TreeNode( @@ -1088,7 +1088,7 @@ void SohInputEditorWindow::DrawLEDSection(uint8_t port) { color.b = colorVec.z * 255.0; CVarSetColor24("gLedPort1Color", color); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } ImGui::SameLine(); ImGui::Text("Custom Color"); @@ -1116,7 +1116,7 @@ void SohInputEditorWindow::DrawRemoveGyroMappingButton(uint8_t port, std::string ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(1.0f, 0.5f)); if (ImGui::Button(StringHelper::Sprintf("%s###removeGyroMapping%s", ICON_FA_TIMES, id.c_str()).c_str(), ImVec2(SCALE_IMGUI_SIZE(20.0f), SCALE_IMGUI_SIZE(20.0f)))) { - LUS::Context::GetInstance()->GetControlDeck()->GetControllerByPort(port)->GetGyro()->ClearGyroMapping(); + Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(port)->GetGyro()->ClearGyroMapping(); } ImGui::PopStyleVar(); } @@ -1139,7 +1139,7 @@ void SohInputEditorWindow::DrawAddGyroMappingButton(uint8_t port) { ImGui::CloseCurrentPopup(); } - if (mMappingInputBlockTimer == INT32_MAX && LUS::Context::GetInstance() + if (mMappingInputBlockTimer == INT32_MAX && Ship::Context::GetInstance() ->GetControlDeck() ->GetControllerByPort(port) ->GetGyro() @@ -1153,7 +1153,7 @@ void SohInputEditorWindow::DrawAddGyroMappingButton(uint8_t port) { void SohInputEditorWindow::DrawGyroSection(uint8_t port) { auto mapping = - LUS::Context::GetInstance()->GetControlDeck()->GetControllerByPort(port)->GetGyro()->GetGyroMapping(); + Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(port)->GetGyro()->GetGyroMapping(); if (mapping != nullptr) { auto id = mapping->GetGyroMappingId(); ImGui::AlignTextToFramePadding(); @@ -1236,28 +1236,28 @@ void SohInputEditorWindow::DrawGyroSection(uint8_t port) { } void SohInputEditorWindow::DrawButtonDeviceIcons(uint8_t portIndex, std::set bitmasks) { - std::set allLusDeviceIndices; - allLusDeviceIndices.insert(LUS::LUSDeviceIndex::Keyboard); - for (auto [lusIndex, mapping] : LUS::Context::GetInstance() + std::set allLusDeviceIndices; + allLusDeviceIndices.insert(Ship::ShipDeviceIndex::Keyboard); + for (auto [lusIndex, mapping] : Ship::Context::GetInstance() ->GetControlDeck() ->GetDeviceIndexMappingManager() ->GetAllDeviceIndexMappingsFromConfig()) { allLusDeviceIndices.insert(lusIndex); } - std::vector> lusDeviceIndiciesWithMappings; + std::vector> lusDeviceIndiciesWithMappings; for (auto lusIndex : allLusDeviceIndices) { for (auto [bitmask, button] : - LUS::Context::GetInstance()->GetControlDeck()->GetControllerByPort(portIndex)->GetAllButtons()) { + Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(portIndex)->GetAllButtons()) { if (!bitmasks.contains(bitmask)) { continue; } - if (button->HasMappingsForLUSDeviceIndex(lusIndex)) { + if (button->HasMappingsForShipDeviceIndex(lusIndex)) { for (auto [id, mapping] : button->GetAllButtonMappings()) { - if (mapping->GetLUSDeviceIndex() == lusIndex) { + if (mapping->GetShipDeviceIndex() == lusIndex) { lusDeviceIndiciesWithMappings.push_back( - std::pair(lusIndex, mapping->PhysicalDeviceIsConnected())); + std::pair(lusIndex, mapping->PhysicalDeviceIsConnected())); break; } } @@ -1273,7 +1273,7 @@ void SohInputEditorWindow::DrawButtonDeviceIcons(uint8_t portIndex, std::set allLusDeviceIndices; - allLusDeviceIndices.insert(LUS::LUSDeviceIndex::Keyboard); - for (auto [lusIndex, mapping] : LUS::Context::GetInstance() +void SohInputEditorWindow::DrawAnalogStickDeviceIcons(uint8_t portIndex, Ship::Stick stick) { + std::set allLusDeviceIndices; + allLusDeviceIndices.insert(Ship::ShipDeviceIndex::Keyboard); + for (auto [lusIndex, mapping] : Ship::Context::GetInstance() ->GetControlDeck() ->GetDeviceIndexMappingManager() ->GetAllDeviceIndexMappingsFromConfig()) { allLusDeviceIndices.insert(lusIndex); } - std::vector> lusDeviceIndiciesWithMappings; + std::vector> lusDeviceIndiciesWithMappings; for (auto lusIndex : allLusDeviceIndices) { auto controllerStick = - stick == LUS::Stick::LEFT_STICK - ? LUS::Context::GetInstance()->GetControlDeck()->GetControllerByPort(portIndex)->GetLeftStick() - : LUS::Context::GetInstance()->GetControlDeck()->GetControllerByPort(portIndex)->GetRightStick(); - if (controllerStick->HasMappingsForLUSDeviceIndex(lusIndex)) { + stick == Ship::Stick::LEFT_STICK + ? Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(portIndex)->GetLeftStick() + : Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(portIndex)->GetRightStick(); + if (controllerStick->HasMappingsForShipDeviceIndex(lusIndex)) { for (auto [direction, mappings] : controllerStick->GetAllAxisDirectionMappings()) { bool foundMapping = false; for (auto [id, mapping] : mappings) { - if (mapping->GetLUSDeviceIndex() == lusIndex) { + if (mapping->GetShipDeviceIndex() == lusIndex) { foundMapping = true; lusDeviceIndiciesWithMappings.push_back( - std::pair(lusIndex, mapping->PhysicalDeviceIsConnected())); + std::pair(lusIndex, mapping->PhysicalDeviceIsConnected())); break; } } @@ -1324,7 +1324,7 @@ void SohInputEditorWindow::DrawAnalogStickDeviceIcons(uint8_t portIndex, LUS::St ImGui::PushStyleColor(ImGuiCol_Button, buttonColor); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, buttonHoveredColor); ImGui::SameLine(); - if (lusIndex == LUS::LUSDeviceIndex::Keyboard) { + if (lusIndex == Ship::ShipDeviceIndex::Keyboard) { ImGui::SmallButton(ICON_FA_KEYBOARD_O); } else { ImGui::SmallButton(connected ? ICON_FA_GAMEPAD : ICON_FA_CHAIN_BROKEN); @@ -1335,29 +1335,29 @@ void SohInputEditorWindow::DrawAnalogStickDeviceIcons(uint8_t portIndex, LUS::St } void SohInputEditorWindow::DrawRumbleDeviceIcons(uint8_t portIndex) { - std::set allLusDeviceIndices; - for (auto [lusIndex, mapping] : LUS::Context::GetInstance() + std::set allLusDeviceIndices; + for (auto [lusIndex, mapping] : Ship::Context::GetInstance() ->GetControlDeck() ->GetDeviceIndexMappingManager() ->GetAllDeviceIndexMappingsFromConfig()) { allLusDeviceIndices.insert(lusIndex); } - std::vector> lusDeviceIndiciesWithMappings; + std::vector> lusDeviceIndiciesWithMappings; for (auto lusIndex : allLusDeviceIndices) { - if (LUS::Context::GetInstance() + if (Ship::Context::GetInstance() ->GetControlDeck() ->GetControllerByPort(portIndex) ->GetRumble() - ->HasMappingsForLUSDeviceIndex(lusIndex)) { - for (auto [id, mapping] : LUS::Context::GetInstance() + ->HasMappingsForShipDeviceIndex(lusIndex)) { + for (auto [id, mapping] : Ship::Context::GetInstance() ->GetControlDeck() ->GetControllerByPort(portIndex) ->GetRumble() ->GetAllRumbleMappings()) { - if (mapping->GetLUSDeviceIndex() == lusIndex) { + if (mapping->GetShipDeviceIndex() == lusIndex) { lusDeviceIndiciesWithMappings.push_back( - std::pair(lusIndex, mapping->PhysicalDeviceIsConnected())); + std::pair(lusIndex, mapping->PhysicalDeviceIsConnected())); break; } } @@ -1379,14 +1379,14 @@ void SohInputEditorWindow::DrawRumbleDeviceIcons(uint8_t portIndex) { void SohInputEditorWindow::DrawGyroDeviceIcons(uint8_t portIndex) { auto mapping = - LUS::Context::GetInstance()->GetControlDeck()->GetControllerByPort(portIndex)->GetGyro()->GetGyroMapping(); + Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(portIndex)->GetGyro()->GetGyroMapping(); if (mapping == nullptr) { return; } auto buttonColor = ImGui::GetStyleColorVec4(ImGuiCol_Button); auto buttonHoveredColor = ImGui::GetStyleColorVec4(ImGuiCol_ButtonHovered); - GetButtonColorsForLUSDeviceIndex(mapping->GetLUSDeviceIndex(), buttonColor, buttonHoveredColor); + GetButtonColorsForLUSDeviceIndex(mapping->GetShipDeviceIndex(), buttonColor, buttonHoveredColor); ImGui::PushStyleColor(ImGuiCol_Button, buttonColor); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, buttonHoveredColor); ImGui::SameLine(); @@ -1396,29 +1396,29 @@ void SohInputEditorWindow::DrawGyroDeviceIcons(uint8_t portIndex) { } void SohInputEditorWindow::DrawLEDDeviceIcons(uint8_t portIndex) { - std::set allLusDeviceIndices; - for (auto [lusIndex, mapping] : LUS::Context::GetInstance() + std::set allLusDeviceIndices; + for (auto [lusIndex, mapping] : Ship::Context::GetInstance() ->GetControlDeck() ->GetDeviceIndexMappingManager() ->GetAllDeviceIndexMappingsFromConfig()) { allLusDeviceIndices.insert(lusIndex); } - std::vector> lusDeviceIndiciesWithMappings; + std::vector> lusDeviceIndiciesWithMappings; for (auto lusIndex : allLusDeviceIndices) { - if (LUS::Context::GetInstance() + if (Ship::Context::GetInstance() ->GetControlDeck() ->GetControllerByPort(portIndex) ->GetRumble() - ->HasMappingsForLUSDeviceIndex(lusIndex)) { - for (auto [id, mapping] : LUS::Context::GetInstance() + ->HasMappingsForShipDeviceIndex(lusIndex)) { + for (auto [id, mapping] : Ship::Context::GetInstance() ->GetControlDeck() ->GetControllerByPort(portIndex) ->GetLED() ->GetAllLEDMappings()) { - if (mapping->GetLUSDeviceIndex() == lusIndex) { + if (mapping->GetShipDeviceIndex() == lusIndex) { lusDeviceIndiciesWithMappings.push_back( - std::pair(lusIndex, mapping->PhysicalDeviceIsConnected())); + std::pair(lusIndex, mapping->PhysicalDeviceIsConnected())); break; } } @@ -1516,7 +1516,7 @@ void SohInputEditorWindow::DrawMapping(CustomButtonMap& mapping, float labelWidt } if (ImGui::Selectable(i->second, i->first == currentButton)) { CVarSetInteger(mapping.cVarName, i->first); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } } ImGui::EndCombo(); @@ -1548,7 +1548,7 @@ void SohInputEditorWindow::DrawOcarinaControlPanel() { ImGui::TableSetupColumn("Modifiers##CustomOcaranaModifiers", PANEL_TABLE_COLUMN_FLAGS); TableHelper::InitHeader(false); - LUS::GuiWindow::BeginGroupPanel("Notes", ImGui::GetContentRegionAvail()); + Ship::GuiWindow::BeginGroupPanel("Notes", ImGui::GetContentRegionAvail()); labelWidth = ImGui::CalcTextSize("D5").x + 10; DrawMapping(ocarinaD5, labelWidth, disableMask); DrawMapping(ocarinaB4, labelWidth, disableMask); @@ -1557,16 +1557,16 @@ void SohInputEditorWindow::DrawOcarinaControlPanel() { DrawMapping(ocarinaD4, labelWidth, disableMask); ImGui::Dummy(ImVec2(0, 5)); float cursorY = ImGui::GetCursorPosY(); - LUS::GuiWindow::EndGroupPanel(0); + Ship::GuiWindow::EndGroupPanel(0); TableHelper::NextCol(); - LUS::GuiWindow::BeginGroupPanel("Modifiers", ImGui::GetContentRegionAvail()); + Ship::GuiWindow::BeginGroupPanel("Modifiers", ImGui::GetContentRegionAvail()); labelWidth = ImGui::CalcTextSize(ocarinaSongDisable.label).x + 10; DrawMapping(ocarinaSongDisable, labelWidth, disableMask); DrawMapping(ocarinaSharp, labelWidth, disableMask); DrawMapping(ocarinaFlat, labelWidth, disableMask); - LUS::GuiWindow::EndGroupPanel(cursorY - ImGui::GetCursorPosY() + 2); + Ship::GuiWindow::EndGroupPanel(cursorY - ImGui::GetCursorPosY() + 2); ImGui::EndTable(); } @@ -1577,7 +1577,7 @@ void SohInputEditorWindow::DrawOcarinaControlPanel() { UIWidgets::Spacer(0); } - LUS::GuiWindow::BeginGroupPanel("Alternate controls", ImGui::GetContentRegionAvail()); + Ship::GuiWindow::BeginGroupPanel("Alternate controls", ImGui::GetContentRegionAvail()); if (ImGui::BeginTable("tableOcarinaAlternateControls", 2, ImGuiTableFlags_SizingFixedSame)) { ImGui::TableSetupColumn("D-pad", PANEL_TABLE_COLUMN_FLAGS); ImGui::TableSetupColumn("Right stick", PANEL_TABLE_COLUMN_FLAGS); @@ -1589,7 +1589,7 @@ void SohInputEditorWindow::DrawOcarinaControlPanel() { UIWidgets::Spacer(0); ImGui::EndTable(); } - LUS::GuiWindow::EndGroupPanel(0); + Ship::GuiWindow::EndGroupPanel(0); ImGui::EndTable(); } @@ -1597,7 +1597,7 @@ void SohInputEditorWindow::DrawOcarinaControlPanel() { void SohInputEditorWindow::DrawCameraControlPanel() { ImVec2 cursor = ImGui::GetCursorPos(); ImGui::SetCursorPos(ImVec2(cursor.x + 5, cursor.y + 5)); - LUS::GuiWindow::BeginGroupPanel("Aiming/First-Person Camera", ImGui::GetContentRegionAvail()); + Ship::GuiWindow::BeginGroupPanel("Aiming/First-Person Camera", ImGui::GetContentRegionAvail()); UIWidgets::PaddedEnhancementCheckbox("Right Stick Aiming", "gRightStickAiming"); UIWidgets::Tooltip("Allows for aiming with the right stick in:\n-First-Person/C-Up view\n-Weapon Aiming"); if (CVarGetInteger("gRightStickAiming", 0)) { @@ -1629,12 +1629,12 @@ void SohInputEditorWindow::DrawCameraControlPanel() { "gFirstPersonCameraSensitivityY", 0.01f, 5.0f, "", 1.0f, true); } UIWidgets::Spacer(0); - LUS::GuiWindow::EndGroupPanel(0); + Ship::GuiWindow::EndGroupPanel(0); UIWidgets::Spacer(0); cursor = ImGui::GetCursorPos(); ImGui::SetCursorPos(ImVec2(cursor.x + 5, cursor.y + 5)); - LUS::GuiWindow::BeginGroupPanel("Third-Person Camera", ImGui::GetContentRegionAvail()); + Ship::GuiWindow::BeginGroupPanel("Third-Person Camera", ImGui::GetContentRegionAvail()); UIWidgets::PaddedEnhancementCheckbox("Free Camera", "gFreeCamera"); UIWidgets::Tooltip("Enables free camera control\nNote: You must remap C buttons off of the right stick in the " @@ -1652,13 +1652,13 @@ void SohInputEditorWindow::DrawCameraControlPanel() { "gFreeCameraDistMax", 100, 900, "", 185, true, false, true); UIWidgets::PaddedEnhancementSliderInt("Camera Transition Speed: %d", "##CamTranSpeed", "gFreeCameraTransitionSpeed", 0, 900, "", 25, true, false, true); - LUS::GuiWindow::EndGroupPanel(0); + Ship::GuiWindow::EndGroupPanel(0); } void SohInputEditorWindow::DrawDpadControlPanel() { ImVec2 cursor = ImGui::GetCursorPos(); ImGui::SetCursorPos(ImVec2(cursor.x + 5, cursor.y + 5)); - LUS::GuiWindow::BeginGroupPanel("D-Pad Options", ImGui::GetContentRegionAvail()); + Ship::GuiWindow::BeginGroupPanel("D-Pad Options", ImGui::GetContentRegionAvail()); UIWidgets::PaddedEnhancementCheckbox("D-pad Support on Pause Screen", "gDpadPause"); UIWidgets::Tooltip("Navigate Pause with the D-pad\nIf used with D-pad as Equip Items, you must hold C-Up to equip instead of navigate\n" "To make the cursor only move a single space no matter how long a direction is held, manually set gDpadHoldChange to 0"); @@ -1667,13 +1667,13 @@ void SohInputEditorWindow::DrawDpadControlPanel() { "To make the cursor only move a single space during name entry no matter how long a direction is held, manually set gDpadHoldChange to 0"); UIWidgets::PaddedEnhancementCheckbox("D-pad as Equip Items", "gDpadEquips"); UIWidgets::Tooltip("Equip items and equipment on the D-pad\nIf used with D-pad on Pause Screen, you must hold C-Up to equip instead of navigate"); - LUS::GuiWindow::EndGroupPanel(0); + Ship::GuiWindow::EndGroupPanel(0); } void SohInputEditorWindow::DrawMiscControlPanel() { ImVec2 cursor = ImGui::GetCursorPos(); ImGui::SetCursorPos(ImVec2(cursor.x + 5, cursor.y + 5)); - LUS::GuiWindow::BeginGroupPanel("Misc Controls", ImGui::GetContentRegionAvail()); + Ship::GuiWindow::BeginGroupPanel("Misc Controls", ImGui::GetContentRegionAvail()); UIWidgets::PaddedText("Allow the cursor to be on any slot"); static const char* cursorOnAnySlot[3] = { "Only in Rando", "Always", "Never" }; UIWidgets::EnhancementCombobox("gPauseAnyCursor", cursorOnAnySlot, PAUSE_ANY_CURSOR_RANDO_ONLY); @@ -1685,24 +1685,24 @@ void SohInputEditorWindow::DrawMiscControlPanel() { UIWidgets::Tooltip("Hold the assigned button to change the maximum walking or swimming speed"); if (CVarGetInteger("gEnableWalkModify", 0)) { UIWidgets::Spacer(5); - LUS::GuiWindow::BeginGroupPanel("Speed Modifier", ImGui::GetContentRegionAvail()); + Ship::GuiWindow::BeginGroupPanel("Speed Modifier", ImGui::GetContentRegionAvail()); UIWidgets::PaddedEnhancementCheckbox("Toggle modifier instead of holding", "gWalkSpeedToggle", true, false); - LUS::GuiWindow::BeginGroupPanel("Walk Modifier", ImGui::GetContentRegionAvail()); + Ship::GuiWindow::BeginGroupPanel("Walk Modifier", ImGui::GetContentRegionAvail()); UIWidgets::PaddedEnhancementCheckbox("Don't affect jump distance/velocity", "gWalkModifierDoesntChangeJump", true, false); UIWidgets::PaddedEnhancementSliderFloat("Walk Modifier 1: %.0f %%", "##WalkMod1", "gWalkModifierOne", 0.0f, 5.0f, "", 1.0f, true, true, false, true); UIWidgets::PaddedEnhancementSliderFloat("Walk Modifier 2: %.0f %%", "##WalkMod2", "gWalkModifierTwo", 0.0f, 5.0f, "", 1.0f, true, true, false, true); - LUS::GuiWindow::EndGroupPanel(0); - LUS::GuiWindow::BeginGroupPanel("Swim Modifier", ImGui::GetContentRegionAvail()); + Ship::GuiWindow::EndGroupPanel(0); + Ship::GuiWindow::BeginGroupPanel("Swim Modifier", ImGui::GetContentRegionAvail()); UIWidgets::PaddedEnhancementSliderFloat("Swim Modifier 1: %.0f %%", "##SwimMod1", "gSwimModifierOne", 0.0f, 5.0f, "", 1.0f, true, true, false, true); UIWidgets::PaddedEnhancementSliderFloat("Swim Modifier 2: %.0f %%", "##SwimMod2", "gSwimModifierTwo", 0.0f, 5.0f, "", 1.0f, true, true, false, true); - LUS::GuiWindow::EndGroupPanel(0); - LUS::GuiWindow::EndGroupPanel(0); + Ship::GuiWindow::EndGroupPanel(0); + Ship::GuiWindow::EndGroupPanel(0); } ImGui::EndDisabled(); UIWidgets::Spacer(0); UIWidgets::PaddedEnhancementCheckbox("Answer Navi Prompt with L Button", "gNaviOnL"); UIWidgets::Tooltip("Speak to Navi with L but enter first-person camera with C-Up"); - LUS::GuiWindow::EndGroupPanel(0); + Ship::GuiWindow::EndGroupPanel(0); } void SohInputEditorWindow::DrawLinkTab() { @@ -1749,17 +1749,17 @@ void SohInputEditorWindow::DrawLinkTab() { } if (ImGui::CollapsingHeader("Analog Stick", NULL, ImGuiTreeNodeFlags_DefaultOpen)) { - DrawAnalogStickDeviceIcons(portIndex, LUS::LEFT_STICK); - DrawStickSection(portIndex, LUS::LEFT, 0); + DrawAnalogStickDeviceIcons(portIndex, Ship::LEFT_STICK); + DrawStickSection(portIndex, Ship::LEFT, 0); } else { - DrawAnalogStickDeviceIcons(portIndex, LUS::LEFT_STICK); + DrawAnalogStickDeviceIcons(portIndex, Ship::LEFT_STICK); } if (ImGui::CollapsingHeader("Additional (\"Right\") Stick")) { - DrawAnalogStickDeviceIcons(portIndex, LUS::RIGHT_STICK); - DrawStickSection(portIndex, LUS::RIGHT, 1, CHIP_COLOR_N64_YELLOW); + DrawAnalogStickDeviceIcons(portIndex, Ship::RIGHT_STICK); + DrawStickSection(portIndex, Ship::RIGHT, 1, CHIP_COLOR_N64_YELLOW); } else { - DrawAnalogStickDeviceIcons(portIndex, LUS::RIGHT_STICK); + DrawAnalogStickDeviceIcons(portIndex, Ship::RIGHT_STICK); } if (ImGui::CollapsingHeader("Rumble")) { @@ -1884,10 +1884,10 @@ void SohInputEditorWindow::DrawIvanTab() { } if (ImGui::CollapsingHeader("Analog Stick", NULL, ImGuiTreeNodeFlags_DefaultOpen)) { - DrawAnalogStickDeviceIcons(portIndex, LUS::LEFT_STICK); - DrawStickSection(portIndex, LUS::LEFT, 0); + DrawAnalogStickDeviceIcons(portIndex, Ship::LEFT_STICK); + DrawStickSection(portIndex, Ship::LEFT, 0); } else { - DrawAnalogStickDeviceIcons(portIndex, LUS::LEFT_STICK); + DrawAnalogStickDeviceIcons(portIndex, Ship::LEFT_STICK); } ImGui::PopStyleColor(); @@ -1942,10 +1942,10 @@ void SohInputEditorWindow::DrawDebugPortTab(uint8_t portIndex, std::string custo } if (ImGui::CollapsingHeader("Analog Stick", NULL, ImGuiTreeNodeFlags_DefaultOpen)) { - DrawAnalogStickDeviceIcons(portIndex, LUS::LEFT_STICK); - DrawStickSection(portIndex, LUS::LEFT, 0); + DrawAnalogStickDeviceIcons(portIndex, Ship::LEFT_STICK); + DrawStickSection(portIndex, Ship::LEFT, 0); } else { - DrawAnalogStickDeviceIcons(portIndex, LUS::LEFT_STICK); + DrawAnalogStickDeviceIcons(portIndex, Ship::LEFT_STICK); } ImGui::PopStyleColor(); @@ -1965,7 +1965,7 @@ void SohInputEditorWindow::DrawClearAllButton(uint8_t portIndex) { ImGui::CloseCurrentPopup(); } if (ImGui::Button("Clear All")) { - LUS::Context::GetInstance()->GetControlDeck()->GetControllerByPort(portIndex)->ClearAllMappings(); + Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(portIndex)->ClearAllMappings(); ImGui::CloseCurrentPopup(); } ImGui::EndPopup(); @@ -1983,12 +1983,12 @@ void SohInputEditorWindow::DrawSetDefaultsButton(uint8_t portIndex) { ImGui::PopStyleVar(); if (ImGui::BeginPopup(popupId.c_str())) { - std::map> indexMappings; - for (auto [lusIndex, mapping] : LUS::Context::GetInstance() + std::map> indexMappings; + for (auto [lusIndex, mapping] : Ship::Context::GetInstance() ->GetControlDeck() ->GetDeviceIndexMappingManager() ->GetAllDeviceIndexMappings()) { - auto wiiuIndexMapping = std::static_pointer_cast(mapping); + auto wiiuIndexMapping = std::static_pointer_cast(mapping); if (wiiuIndexMapping == nullptr) { continue; } @@ -2025,11 +2025,11 @@ void SohInputEditorWindow::DrawSetDefaultsButton(uint8_t portIndex) { ImGui::CloseCurrentPopup(); } if (ImGui::Button("Set defaults")) { - LUS::Context::GetInstance() + Ship::Context::GetInstance() ->GetControlDeck() ->GetControllerByPort(portIndex) ->ClearAllMappingsForDevice(lusIndex); - LUS::Context::GetInstance()->GetControlDeck()->GetControllerByPort(portIndex)->AddDefaultMappings( + Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(portIndex)->AddDefaultMappings( lusIndex); shouldClose = true; ImGui::CloseCurrentPopup(); @@ -2048,12 +2048,12 @@ void SohInputEditorWindow::DrawSetDefaultsButton(uint8_t portIndex) { void SohInputEditorWindow::DrawDevicesTab() { if (ImGui::BeginTabItem("Devices")) { - std::map> indexMappings; - for (auto [lusIndex, mapping] : LUS::Context::GetInstance() + std::map> indexMappings; + for (auto [lusIndex, mapping] : Ship::Context::GetInstance() ->GetControlDeck() ->GetDeviceIndexMappingManager() ->GetAllDeviceIndexMappingsFromConfig()) { - auto wiiuIndexMapping = std::static_pointer_cast(mapping); + auto wiiuIndexMapping = std::static_pointer_cast(mapping); if (wiiuIndexMapping == nullptr) { continue; } @@ -2061,11 +2061,11 @@ void SohInputEditorWindow::DrawDevicesTab() { indexMappings[lusIndex] = { wiiuIndexMapping->GetWiiUControllerName(), -1 }; } - for (auto [lusIndex, mapping] : LUS::Context::GetInstance() + for (auto [lusIndex, mapping] : Ship::Context::GetInstance() ->GetControlDeck() ->GetDeviceIndexMappingManager() ->GetAllDeviceIndexMappings()) { - auto wiiuIndexMapping = std::static_pointer_cast(mapping); + auto wiiuIndexMapping = std::static_pointer_cast(mapping); if (wiiuIndexMapping == nullptr) { continue; } @@ -2108,12 +2108,12 @@ void SohInputEditorWindow::DrawSetDefaultsButton(uint8_t portIndex) { } if (ImGui::BeginPopup(popupId.c_str())) { - std::map> indexMappings; - for (auto [lusIndex, mapping] : LUS::Context::GetInstance() + std::map> indexMappings; + for (auto [lusIndex, mapping] : Ship::Context::GetInstance() ->GetControlDeck() ->GetDeviceIndexMappingManager() ->GetAllDeviceIndexMappings()) { - auto sdlIndexMapping = std::static_pointer_cast(mapping); + auto sdlIndexMapping = std::static_pointer_cast(mapping); if (sdlIndexMapping == nullptr) { continue; } @@ -2136,12 +2136,12 @@ void SohInputEditorWindow::DrawSetDefaultsButton(uint8_t portIndex) { ImGui::CloseCurrentPopup(); } if (ImGui::Button("Set defaults")) { - LUS::Context::GetInstance() + Ship::Context::GetInstance() ->GetControlDeck() ->GetControllerByPort(portIndex) - ->ClearAllMappingsForDevice(LUS::LUSDeviceIndex::Keyboard); - LUS::Context::GetInstance()->GetControlDeck()->GetControllerByPort(portIndex)->AddDefaultMappings( - LUS::LUSDeviceIndex::Keyboard); + ->ClearAllMappingsForDevice(Ship::ShipDeviceIndex::Keyboard); + Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(portIndex)->AddDefaultMappings( + Ship::ShipDeviceIndex::Keyboard); shouldClose = true; ImGui::CloseCurrentPopup(); } @@ -2171,11 +2171,11 @@ void SohInputEditorWindow::DrawSetDefaultsButton(uint8_t portIndex) { ImGui::CloseCurrentPopup(); } if (ImGui::Button("Set defaults")) { - LUS::Context::GetInstance() + Ship::Context::GetInstance() ->GetControlDeck() ->GetControllerByPort(portIndex) ->ClearAllMappingsForDevice(lusIndex); - LUS::Context::GetInstance()->GetControlDeck()->GetControllerByPort(portIndex)->AddDefaultMappings( + Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(portIndex)->AddDefaultMappings( lusIndex); shouldClose = true; ImGui::CloseCurrentPopup(); @@ -2194,12 +2194,12 @@ void SohInputEditorWindow::DrawSetDefaultsButton(uint8_t portIndex) { void SohInputEditorWindow::DrawDevicesTab() { if (ImGui::BeginTabItem("Devices")) { - std::map> indexMappings; - for (auto [lusIndex, mapping] : LUS::Context::GetInstance() + std::map> indexMappings; + for (auto [lusIndex, mapping] : Ship::Context::GetInstance() ->GetControlDeck() ->GetDeviceIndexMappingManager() ->GetAllDeviceIndexMappingsFromConfig()) { - auto sdlIndexMapping = std::static_pointer_cast(mapping); + auto sdlIndexMapping = std::static_pointer_cast(mapping); if (sdlIndexMapping == nullptr) { continue; } @@ -2207,11 +2207,11 @@ void SohInputEditorWindow::DrawDevicesTab() { indexMappings[lusIndex] = { sdlIndexMapping->GetSDLControllerName(), -1 }; } - for (auto [lusIndex, mapping] : LUS::Context::GetInstance() + for (auto [lusIndex, mapping] : Ship::Context::GetInstance() ->GetControlDeck() ->GetDeviceIndexMappingManager() ->GetAllDeviceIndexMappings()) { - auto sdlIndexMapping = std::static_pointer_cast(mapping); + auto sdlIndexMapping = std::static_pointer_cast(mapping); if (sdlIndexMapping == nullptr) { continue; } diff --git a/soh/soh/Enhancements/controls/SohInputEditorWindow.h b/soh/soh/Enhancements/controls/SohInputEditorWindow.h index e96b5b09afe..079aa805b89 100644 --- a/soh/soh/Enhancements/controls/SohInputEditorWindow.h +++ b/soh/soh/Enhancements/controls/SohInputEditorWindow.h @@ -20,7 +20,7 @@ typedef struct { N64ButtonMask defaultBtn; } CustomButtonMap; -class SohInputEditorWindow : public LUS::GuiWindow { +class SohInputEditorWindow : public Ship::GuiWindow { public: using GuiWindow::GuiWindow; ~SohInputEditorWindow(); @@ -38,14 +38,14 @@ class SohInputEditorWindow : public LUS::GuiWindow { void UpdateElement() override; private: - void DrawStickDirectionLine(const char* axisDirectionName, uint8_t port, uint8_t stick, LUS::Direction direction, + void DrawStickDirectionLine(const char* axisDirectionName, uint8_t port, uint8_t stick, Ship::Direction direction, ImVec4 color); void DrawButtonLine(const char* buttonName, uint8_t port, uint16_t bitmask, ImVec4 color); void DrawButtonLineEditMappingButton(uint8_t port, uint16_t bitmask, std::string id); void DrawButtonLineAddMappingButton(uint8_t port, uint16_t bitmask); - void DrawStickDirectionLineEditMappingButton(uint8_t port, uint8_t stick, LUS::Direction direction, std::string id); - void DrawStickDirectionLineAddMappingButton(uint8_t port, uint8_t stick, LUS::Direction direction); + void DrawStickDirectionLineEditMappingButton(uint8_t port, uint8_t stick, Ship::Direction direction, std::string id); + void DrawStickDirectionLineAddMappingButton(uint8_t port, uint8_t stick, Ship::Direction direction); void DrawStickSection(uint8_t port, uint8_t stick, int32_t id, ImVec4 color); void DrawRumbleSection(uint8_t port); @@ -74,20 +74,20 @@ class SohInputEditorWindow : public LUS::GuiWindow { int32_t mGameInputBlockTimer; int32_t mMappingInputBlockTimer; int32_t mRumbleTimer; - std::shared_ptr mRumbleMappingToTest; + std::shared_ptr mRumbleMappingToTest; // mBitmaskToMappingIds[port][bitmask] = { id0, id1, ... } std::unordered_map>> mBitmaskToMappingIds; // mStickDirectionToMappingIds[port][stick][direction] = { id0, id1, ... } std::unordered_map>>> + std::unordered_map>>> mStickDirectionToMappingIds; void UpdateBitmaskToMappingIds(uint8_t port); void UpdateStickDirectionToMappingIds(uint8_t port); - void GetButtonColorsForLUSDeviceIndex(LUS::LUSDeviceIndex lusIndex, ImVec4& buttonColor, + void GetButtonColorsForLUSDeviceIndex(Ship::ShipDeviceIndex lusIndex, ImVec4& buttonColor, ImVec4& buttonHoveredColor); void DrawLinkTab(); void DrawIvanTab(); @@ -97,7 +97,7 @@ class SohInputEditorWindow : public LUS::GuiWindow { std::set mDpadBitmasks; std::set mModifierButtonsBitmasks; void DrawButtonDeviceIcons(uint8_t portIndex, std::set bitmasks); - void DrawAnalogStickDeviceIcons(uint8_t portIndex, LUS::Stick stick); + void DrawAnalogStickDeviceIcons(uint8_t portIndex, Ship::Stick stick); void DrawRumbleDeviceIcons(uint8_t portIndex); void DrawGyroDeviceIcons(uint8_t portIndex); void DrawLEDDeviceIcons(uint8_t portIndex); diff --git a/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp b/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp index 65659a80f74..51eabd08d56 100644 --- a/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp +++ b/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp @@ -1322,7 +1322,7 @@ void Draw_Placements(){ if (ImGui::Button("Reset##EnemyHealthBarWidth")) { CVarClear(CVAR_COSMETIC("HUD.EnemyHealthBarWidth.Value")); CVarClear(CVAR_COSMETIC("HUD.EnemyHealthBarWidth.Changed")); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } ImGui::NewLine(); ImGui::EndTable(); @@ -1333,7 +1333,7 @@ void Reset_Option_Single(const char* Button_Title, const char* name) { ImGui::SameLine(); if (ImGui::Button(Button_Title)) { CVarClear(name); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } } void Reset_Option_Double(const char* Button_Title, const char* name) { @@ -1341,14 +1341,14 @@ void Reset_Option_Double(const char* Button_Title, const char* name) { if (ImGui::Button(Button_Title)) { CVarClear((std::string(name) + ".Value").c_str()); CVarClear((std::string(name) + ".Changed").c_str()); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } } void DrawSillyTab() { ImGui::BeginDisabled(CVarGetInteger(CVAR_SETTING("DisableChanges"), 0)); if (CVarGetInteger("gLetItSnow", 0)) { if (UIWidgets::EnhancementCheckbox("Let It Snow", "gLetItSnow")) { - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } } if (UIWidgets::EnhancementSliderFloat("Link Body Scale: %.3fx", "##Link_BodyScale", CVAR_COSMETIC("Link.BodyScale.Value"), 0.001f, 0.025f, "", 0.01f, true)) { @@ -1358,7 +1358,7 @@ void DrawSillyTab() { if (ImGui::Button("Reset##Link_BodyScale")) { CVarClear(CVAR_COSMETIC("Link.BodyScale.Value")); CVarClear(CVAR_COSMETIC("Link.BodyScale.Changed")); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); if (gPlayState != nullptr) { static Player* player = GET_PLAYER(gPlayState); player->actor.scale.x = 0.01f; @@ -1612,7 +1612,7 @@ void DrawCosmeticRow(CosmeticOption& cosmeticOption) { CVarSetInteger((cosmeticOption.changedCvar), 1); ApplySideEffects(cosmeticOption); ApplyOrResetCustomGfxPatches(); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } ImGui::SameLine(); ImGui::Text("%s", cosmeticOption.label.c_str()); @@ -1620,7 +1620,7 @@ void DrawCosmeticRow(CosmeticOption& cosmeticOption) { if (ImGui::Button(("Random##" + cosmeticOption.label).c_str())) { RandomizeColor(cosmeticOption); ApplyOrResetCustomGfxPatches(); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } if (cosmeticOption.supportsRainbow) { ImGui::SameLine(); @@ -1630,21 +1630,21 @@ void DrawCosmeticRow(CosmeticOption& cosmeticOption) { CVarSetInteger((cosmeticOption.changedCvar), 1); ApplySideEffects(cosmeticOption); ApplyOrResetCustomGfxPatches(); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } } ImGui::SameLine(); bool isLocked = (bool)CVarGetInteger((cosmeticOption.lockedCvar), 0); if (ImGui::Checkbox(("Locked##" + cosmeticOption.label).c_str(), &isLocked)) { CVarSetInteger((cosmeticOption.lockedCvar), isLocked); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } if (CVarGetInteger((cosmeticOption.changedCvar), 0)) { ImGui::SameLine(); if (ImGui::Button(("Reset##" + cosmeticOption.label).c_str())) { ResetColor(cosmeticOption); ApplyOrResetCustomGfxPatches(); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } } } @@ -1660,7 +1660,7 @@ void DrawCosmeticGroup(CosmeticGroup cosmeticGroup) { } } ApplyOrResetCustomGfxPatches(); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } ImGui::SameLine(); if (ImGui::Button(("Reset##" + label).c_str())) { @@ -1670,7 +1670,7 @@ void DrawCosmeticGroup(CosmeticGroup cosmeticGroup) { } } ApplyOrResetCustomGfxPatches(); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } for (auto& [id, cosmeticOption] : cosmeticOptions) { if (cosmeticOption.group == cosmeticGroup && (!cosmeticOption.advancedOption || CVarGetInteger(CVAR_COSMETIC("AdvancedMode"), 0))) { @@ -1706,7 +1706,7 @@ void CosmeticsEditorWindow::DrawElement() { CVarSetInteger(cosmeticOption.lockedCvar, 1); } } - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } ImGui::SameLine(); if (ImGui::Button("Unlock All Advanced", ImVec2(ImGui::GetContentRegionAvail().x, 30.0f))) { @@ -1715,7 +1715,7 @@ void CosmeticsEditorWindow::DrawElement() { CVarSetInteger(cosmeticOption.lockedCvar, 0); } } - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } } UIWidgets::EnhancementCheckbox("Sync Rainbow colors", CVAR_COSMETIC("RainbowSync")); @@ -1734,7 +1734,7 @@ void CosmeticsEditorWindow::DrawElement() { } } ApplyOrResetCustomGfxPatches(); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } if (ImGui::Button("Lock All", ImVec2(ImGui::GetContentRegionAvail().x / 2, 30.0f))) { @@ -1743,7 +1743,7 @@ void CosmeticsEditorWindow::DrawElement() { CVarSetInteger(cosmeticOption.lockedCvar, 1); } } - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } ImGui::SameLine(); if (ImGui::Button("Unlock All", ImVec2(ImGui::GetContentRegionAvail().x, 30.0f))) { @@ -1752,7 +1752,7 @@ void CosmeticsEditorWindow::DrawElement() { CVarSetInteger(cosmeticOption.lockedCvar, 0); } } - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } if (ImGui::BeginTabBar("CosmeticsContextTabBar", ImGuiTabBarFlags_NoCloseWithMiddleMouseButton)) { @@ -1777,7 +1777,7 @@ void CosmeticsEditorWindow::DrawElement() { if (ImGui::Button("Reset##Trails_Duration")) { CVarClear(CVAR_COSMETIC("Trails.Duration.Value")); CVarClear(CVAR_COSMETIC("Trails.Duration.Changed")); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } ImGui::EndTabItem(); } @@ -1843,7 +1843,7 @@ void CosmeticsEditorWindow::InitElement() { cosmeticOption.currentColor.z = cvarColor.b / 255.0; cosmeticOption.currentColor.w = cvarColor.a / 255.0; } - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); ApplyOrResetCustomGfxPatches(); ApplyAuthenticGfxPatches(); @@ -1860,7 +1860,7 @@ void CosmeticsEditor_RandomizeAll() { } } - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); ApplyOrResetCustomGfxPatches(); } @@ -1873,7 +1873,7 @@ void CosmeticsEditor_RandomizeGroup(CosmeticGroup group) { } } - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); ApplyOrResetCustomGfxPatches(); } @@ -1884,7 +1884,7 @@ void CosmeticsEditor_ResetAll() { } } - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); ApplyOrResetCustomGfxPatches(); } @@ -1895,6 +1895,6 @@ void CosmeticsEditor_ResetGroup(CosmeticGroup group) { } } - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); ApplyOrResetCustomGfxPatches(); } diff --git a/soh/soh/Enhancements/cosmetics/CosmeticsEditor.h b/soh/soh/Enhancements/cosmetics/CosmeticsEditor.h index 9599a521f81..88f60c76cbd 100644 --- a/soh/soh/Enhancements/cosmetics/CosmeticsEditor.h +++ b/soh/soh/Enhancements/cosmetics/CosmeticsEditor.h @@ -54,7 +54,7 @@ void CosmeticsEditor_ResetAll(); void CosmeticsEditor_ResetGroup(CosmeticGroup group); void ApplyOrResetCustomGfxPatches(bool manualChange = true); -class CosmeticsEditorWindow : public LUS::GuiWindow { +class CosmeticsEditorWindow : public Ship::GuiWindow { public: using GuiWindow::GuiWindow; diff --git a/soh/soh/Enhancements/debugconsole.cpp b/soh/soh/Enhancements/debugconsole.cpp index e75450c7c42..7c73ea61e4e 100644 --- a/soh/soh/Enhancements/debugconsole.cpp +++ b/soh/soh/Enhancements/debugconsole.cpp @@ -36,12 +36,12 @@ extern PlayState* gPlayState; #include #include -#define CMD_REGISTER LUS::Context::GetInstance()->GetConsole()->AddCommand +#define CMD_REGISTER Ship::Context::GetInstance()->GetConsole()->AddCommand // TODO: Commands should be using the output passed in. -#define ERROR_MESSAGE std::reinterpret_pointer_cast(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Console"))->SendErrorMessage -#define INFO_MESSAGE std::reinterpret_pointer_cast(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Console"))->SendInfoMessage +#define ERROR_MESSAGE std::reinterpret_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Console"))->SendErrorMessage +#define INFO_MESSAGE std::reinterpret_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Console"))->SendInfoMessage -static bool ActorSpawnHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { +static bool ActorSpawnHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { if ((args.size() != 9) && (args.size() != 3) && (args.size() != 6)) { ERROR_MESSAGE("Not enough arguments passed to actorspawn"); return 1; @@ -101,7 +101,7 @@ static bool ActorSpawnHandler(std::shared_ptr Console, const std:: return 0; } -static bool KillPlayerHandler(std::shared_ptr Console, const std::vector&, std::string* output) { +static bool KillPlayerHandler(std::shared_ptr Console, const std::vector&, std::string* output) { GameInteractionEffectBase* effect = new GameInteractionEffect::SetPlayerHealth(); dynamic_cast(effect)->parameters[0] = 0; GameInteractionEffectQueryResult result = GameInteractor::ApplyEffect(effect); @@ -114,7 +114,7 @@ static bool KillPlayerHandler(std::shared_ptr Console, const std:: } } -static bool SetPlayerHealthHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { +static bool SetPlayerHealthHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { if (args.size() < 2) { ERROR_MESSAGE("[SOH] Unexpected arguments passed"); return 1; @@ -145,7 +145,7 @@ static bool SetPlayerHealthHandler(std::shared_ptr Console, const } } -static bool LoadSceneHandler(std::shared_ptr Console, const std::vector&, std::string* output) { +static bool LoadSceneHandler(std::shared_ptr Console, const std::vector&, std::string* output) { gSaveContext.respawnFlag = 0; gSaveContext.seqId = 0xFF; gSaveContext.gameMode = 0; @@ -153,7 +153,7 @@ static bool LoadSceneHandler(std::shared_ptr Console, const std::v return 0; } -static bool RupeeHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { +static bool RupeeHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { if (args.size() < 2) { return 1; } @@ -178,7 +178,7 @@ static bool RupeeHandler(std::shared_ptr Console, const std::vecto return 0; } -static bool SetPosHandler(std::shared_ptr Console, const std::vector args, std::string* output) { +static bool SetPosHandler(std::shared_ptr Console, const std::vector args, std::string* output) { if (gPlayState == nullptr) { ERROR_MESSAGE("PlayState == nullptr"); return 1; @@ -205,7 +205,7 @@ static bool SetPosHandler(std::shared_ptr Console, const std::vect return 0; } -static bool ResetHandler(std::shared_ptr Console, std::vector args, std::string* output) { +static bool ResetHandler(std::shared_ptr Console, std::vector args, std::string* output) { if (gPlayState == nullptr) { ERROR_MESSAGE("PlayState == nullptr"); return 1; @@ -225,7 +225,7 @@ const static std::map ammoItems{ { "beans", ITEM_BEAN } }; -static bool AddAmmoHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { +static bool AddAmmoHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { if (args.size() < 3) { ERROR_MESSAGE("[SOH] Unexpected arguments passed"); return 1; @@ -264,7 +264,7 @@ static bool AddAmmoHandler(std::shared_ptr Console, const std::vec } } -static bool TakeAmmoHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { +static bool TakeAmmoHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { if (args.size() < 3) { ERROR_MESSAGE("[SOH] Unexpected arguments passed"); return 1; @@ -311,7 +311,7 @@ const static std::map bottleItems{ { "big_poe", ITEM_BIG_POE }, { "blue_fire", ITEM_BLUE_FIRE }, { "rutos_letter", ITEM_LETTER_RUTO }, }; -static bool BottleHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { +static bool BottleHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { if (args.size() < 3) { ERROR_MESSAGE("[SOH] Unexpected arguments passed"); return 1; @@ -343,7 +343,7 @@ static bool BottleHandler(std::shared_ptr Console, const std::vect return 0; } -static bool BHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { +static bool BHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { if (args.size() < 2) { ERROR_MESSAGE("[SOH] Unexpected arguments passed"); return 1; @@ -353,7 +353,7 @@ static bool BHandler(std::shared_ptr Console, const std::vector Console, const std::vector& args, std::string* output) { +static bool ItemHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { if (args.size() < 3) { ERROR_MESSAGE("[SOH] Unexpected arguments passed"); return 1; @@ -364,7 +364,7 @@ static bool ItemHandler(std::shared_ptr Console, const std::vector return 0; } -static bool GiveItemHandler(std::shared_ptr Console, const std::vector args, std::string* output) { +static bool GiveItemHandler(std::shared_ptr Console, const std::vector args, std::string* output) { if (args.size() < 3) { ERROR_MESSAGE("[SOH] Unexpected arguments passed"); return 1; @@ -385,7 +385,7 @@ static bool GiveItemHandler(std::shared_ptr Console, const std::ve return 0; } -static bool EntranceHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { +static bool EntranceHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { if (args.size() < 2) { ERROR_MESSAGE("[SOH] Unexpected arguments passed"); return 1; @@ -406,7 +406,7 @@ static bool EntranceHandler(std::shared_ptr Console, const std::ve gSaveContext.nextTransitionType = TRANS_TYPE_INSTANT; } -static bool VoidHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { +static bool VoidHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { if (gPlayState != nullptr) { gSaveContext.respawn[RESPAWN_MODE_DOWN].tempSwchFlags = gPlayState->actorCtx.flags.tempSwch; gSaveContext.respawn[RESPAWN_MODE_DOWN].tempCollectFlags = gPlayState->actorCtx.flags.tempCollect; @@ -422,7 +422,7 @@ static bool VoidHandler(std::shared_ptr Console, const std::vector return 0; } -static bool ReloadHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { +static bool ReloadHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { if (gPlayState != nullptr) { gPlayState->nextEntranceIndex = gSaveContext.entranceIndex; gPlayState->transitionTrigger = TRANS_TRIGGER_START; @@ -439,7 +439,7 @@ const static std::map fw_options { { "clear", 0}, {"warp", 1}, {"backup", 2} }; -static bool FWHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { +static bool FWHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { if (args.size() < 2) { ERROR_MESSAGE("[SOH] Unexpected arguments passed"); return 1; @@ -491,7 +491,7 @@ static bool FWHandler(std::shared_ptr Console, const std::vector Console, const std::vector& args, std::string* output) { +static bool FileSelectHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { if (gPlayState != nullptr) { SET_NEXT_GAMESTATE(&gPlayState->state, FileChoose_Init, FileChooseContext); gPlayState->state.running = 0; @@ -502,12 +502,12 @@ static bool FileSelectHandler(std::shared_ptr Console, const std:: return 0; } -static bool QuitHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { - LUS::Context::GetInstance()->GetWindow()->Close(); +static bool QuitHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { + Ship::Context::GetInstance()->GetWindow()->Close(); return 0; } -static bool SaveStateHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { +static bool SaveStateHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { unsigned int slot = OTRGlobals::Instance->gSaveStateMgr->GetCurrentSlot(); const SaveStateReturn rtn = OTRGlobals::Instance->gSaveStateMgr->AddRequest({ slot, RequestType::SAVE }); @@ -521,7 +521,7 @@ static bool SaveStateHandler(std::shared_ptr Console, const std::v } } -static bool LoadStateHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { +static bool LoadStateHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { unsigned int slot = OTRGlobals::Instance->gSaveStateMgr->GetCurrentSlot(); const SaveStateReturn rtn = OTRGlobals::Instance->gSaveStateMgr->AddRequest({ slot, RequestType::LOAD }); @@ -542,7 +542,7 @@ static bool LoadStateHandler(std::shared_ptr Console, const std::v } -static bool StateSlotSelectHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { +static bool StateSlotSelectHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { if (args.size() < 2) { ERROR_MESSAGE("[SOH] Unexpected arguments passed"); return 1; @@ -567,7 +567,7 @@ static bool StateSlotSelectHandler(std::shared_ptr Console, const return 0; } -static bool InvisibleHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { +static bool InvisibleHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { if (args.size() < 2) { ERROR_MESSAGE("[SOH] Unexpected arguments passed"); return 1; @@ -594,7 +594,7 @@ static bool InvisibleHandler(std::shared_ptr Console, const std::v } } -static bool GiantLinkHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { +static bool GiantLinkHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { if (args.size() < 2) { ERROR_MESSAGE("[SOH] Unexpected arguments passed"); return 1; @@ -622,7 +622,7 @@ static bool GiantLinkHandler(std::shared_ptr Console, const std::v } } -static bool MinishLinkHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { +static bool MinishLinkHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { if (args.size() < 2) { ERROR_MESSAGE("[SOH] Unexpected arguments passed"); return 1; @@ -650,7 +650,7 @@ static bool MinishLinkHandler(std::shared_ptr Console, const std:: } } -static bool AddHeartContainerHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { +static bool AddHeartContainerHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { if (args.size() < 2) { ERROR_MESSAGE("[SOH] Unexpected arguments passed"); return 1; @@ -681,7 +681,7 @@ static bool AddHeartContainerHandler(std::shared_ptr Console, cons } } -static bool RemoveHeartContainerHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { +static bool RemoveHeartContainerHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { if (args.size() < 2) { ERROR_MESSAGE("[SOH] Unexpected arguments passed"); return 1; @@ -712,7 +712,7 @@ static bool RemoveHeartContainerHandler(std::shared_ptr Console, c } } -static bool GravityHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { +static bool GravityHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { if (args.size() < 2) { ERROR_MESSAGE("[SOH] Unexpected arguments passed"); return 1; @@ -721,7 +721,7 @@ static bool GravityHandler(std::shared_ptr Console, const std::vec GameInteractionEffectBase* effect = new GameInteractionEffect::ModifyGravity(); try { - dynamic_cast(effect)->parameters[0] = LUS::Math::clamp(std::stoi(args[1], nullptr, 10), GI_GRAVITY_LEVEL_LIGHT, GI_GRAVITY_LEVEL_HEAVY); + dynamic_cast(effect)->parameters[0] = Ship::Math::clamp(std::stoi(args[1], nullptr, 10), GI_GRAVITY_LEVEL_LIGHT, GI_GRAVITY_LEVEL_HEAVY); } catch (std::invalid_argument const& ex) { ERROR_MESSAGE("[SOH] Gravity value must be a number."); return 1; @@ -737,7 +737,7 @@ static bool GravityHandler(std::shared_ptr Console, const std::vec } } -static bool NoUIHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { +static bool NoUIHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { if (args.size() < 2) { ERROR_MESSAGE("[SOH] Unexpected arguments passed"); return 1; @@ -765,7 +765,7 @@ static bool NoUIHandler(std::shared_ptr Console, const std::vector } } -static bool FreezeHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { +static bool FreezeHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { GameInteractionEffectBase* effect = new GameInteractionEffect::FreezePlayer(); GameInteractionEffectQueryResult result = GameInteractor::ApplyEffect(effect); @@ -778,7 +778,7 @@ static bool FreezeHandler(std::shared_ptr Console, const std::vect } } -static bool DefenseModifierHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { +static bool DefenseModifierHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { if (args.size() < 2) { ERROR_MESSAGE("[SOH] Unexpected arguments passed"); return 1; @@ -802,7 +802,7 @@ static bool DefenseModifierHandler(std::shared_ptr Console, const } } -static bool DamageHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { +static bool DamageHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { if (args.size() < 2) { ERROR_MESSAGE("[SOH] Unexpected arguments passed"); return 1; @@ -832,7 +832,7 @@ static bool DamageHandler(std::shared_ptr Console, const std::vect } } -static bool HealHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { +static bool HealHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { if (args.size() < 2) { ERROR_MESSAGE("[SOH] Unexpected arguments passed"); return 1; @@ -862,7 +862,7 @@ static bool HealHandler(std::shared_ptr Console, const std::vector } } -static bool FillMagicHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { +static bool FillMagicHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { GameInteractionEffectBase* effect = new GameInteractionEffect::FillMagic(); GameInteractionEffectQueryResult result = GameInteractor::ApplyEffect(effect); @@ -875,7 +875,7 @@ static bool FillMagicHandler(std::shared_ptr Console, const std::v } } -static bool EmptyMagicHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { +static bool EmptyMagicHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { GameInteractionEffectBase* effect = new GameInteractionEffect::EmptyMagic(); GameInteractionEffectQueryResult result = GameInteractor::ApplyEffect(effect); @@ -888,7 +888,7 @@ static bool EmptyMagicHandler(std::shared_ptr Console, const std:: } } -static bool NoZHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { +static bool NoZHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { if (args.size() < 2) { ERROR_MESSAGE("[SOH] Unexpected arguments passed"); return 1; @@ -916,7 +916,7 @@ static bool NoZHandler(std::shared_ptr Console, const std::vector< } } -static bool OneHitKOHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { +static bool OneHitKOHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { if (args.size() < 2) { ERROR_MESSAGE("[SOH] Unexpected arguments passed"); return 1; @@ -944,7 +944,7 @@ static bool OneHitKOHandler(std::shared_ptr Console, const std::ve } } -static bool PacifistHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { +static bool PacifistHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { if (args.size() < 2) { ERROR_MESSAGE("[SOH] Unexpected arguments passed"); return 1; @@ -972,7 +972,7 @@ static bool PacifistHandler(std::shared_ptr Console, const std::ve } } -static bool PaperLinkHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { +static bool PaperLinkHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { if (args.size() < 2) { ERROR_MESSAGE("[SOH] Unexpected arguments passed"); return 1; @@ -1001,7 +1001,7 @@ static bool PaperLinkHandler(std::shared_ptr Console, const std::v } } -static bool RainstormHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { +static bool RainstormHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { if (args.size() < 2) { ERROR_MESSAGE("[SOH] Unexpected arguments passed"); return 1; @@ -1029,7 +1029,7 @@ static bool RainstormHandler(std::shared_ptr Console, const std::v } } -static bool ReverseControlsHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { +static bool ReverseControlsHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { if (args.size() < 2) { ERROR_MESSAGE("[SOH] Unexpected arguments passed"); return 1; @@ -1058,7 +1058,7 @@ static bool ReverseControlsHandler(std::shared_ptr Console, const } } -static bool UpdateRupeesHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { +static bool UpdateRupeesHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { if (args.size() < 2) { ERROR_MESSAGE("[SOH] Unexpected arguments passed"); return 1; @@ -1082,7 +1082,7 @@ static bool UpdateRupeesHandler(std::shared_ptr Console, const std } } -static bool SpeedModifierHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { +static bool SpeedModifierHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { if (args.size() < 2) { ERROR_MESSAGE("[SOH] Unexpected arguments passed"); return 1; @@ -1112,7 +1112,7 @@ const static std::map boots { { "hover", EQUIP_VALUE_BOOTS_HOVER }, }; -static bool BootsHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { +static bool BootsHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { if (args.size() < 2) { ERROR_MESSAGE("[SOH] Unexpected arguments passed"); return 1; @@ -1143,7 +1143,7 @@ const static std::map shields { { "mirror", ITEM_SHIELD_MIRROR }, }; -static bool GiveShieldHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { +static bool GiveShieldHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { if (args.size() < 2) { ERROR_MESSAGE("[SOH] Unexpected arguments passed"); return 1; @@ -1168,7 +1168,7 @@ static bool GiveShieldHandler(std::shared_ptr Console, const std:: } } -static bool TakeShieldHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { +static bool TakeShieldHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { if (args.size() < 2) { ERROR_MESSAGE("[SOH] Unexpected arguments passed"); return 1; @@ -1193,7 +1193,7 @@ static bool TakeShieldHandler(std::shared_ptr Console, const std:: } } -static bool KnockbackHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { +static bool KnockbackHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { if (args.size() < 2) { ERROR_MESSAGE("[SOH] Unexpected arguments passed"); return 1; @@ -1223,7 +1223,7 @@ static bool KnockbackHandler(std::shared_ptr Console, const std::v } } -static bool ElectrocuteHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { +static bool ElectrocuteHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { GameInteractionEffectBase* effect = new GameInteractionEffect::ElectrocutePlayer(); GameInteractionEffectQueryResult result = GameInteractor::ApplyEffect(effect); @@ -1236,7 +1236,7 @@ static bool ElectrocuteHandler(std::shared_ptr Console, const std: } } -static bool BurnHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { +static bool BurnHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { GameInteractionEffectBase* effect = new GameInteractionEffect::BurnPlayer(); GameInteractionEffectQueryResult result = GameInteractor::ApplyEffect(effect); @@ -1249,7 +1249,7 @@ static bool BurnHandler(std::shared_ptr Console, const std::vector } } -static bool CuccoStormHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { +static bool CuccoStormHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { GameInteractionEffectQueryResult result = GameInteractor::RawAction::SpawnActor(ACTOR_EN_NIW, 0); if (result == GameInteractionEffectQueryResult::Possible) { @@ -1261,7 +1261,7 @@ static bool CuccoStormHandler(std::shared_ptr Console, const std:: } } -static bool GenerateRandoHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { +static bool GenerateRandoHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { if (args.size() == 1) { if (GenerateRandomizer()) { return 0; @@ -1309,7 +1309,7 @@ static constexpr std::array, COSMETICS_GRO {"ivan", COSMETICS_GROUP_IVAN}, }}; -static bool CosmeticsHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { +static bool CosmeticsHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { if (args.size() < 2) { ERROR_MESSAGE("[SOH] Unexpected arguments passed"); return 1; @@ -1361,7 +1361,7 @@ static std::map sfx_groups = { {"custom", SEQ_BGM_CUSTOM}, }; -static bool SfxHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { +static bool SfxHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { if (args.size() < 2) { ERROR_MESSAGE("[SOH] Unexpected arguments passed"); return 1; @@ -1411,17 +1411,17 @@ void DebugConsole_Init(void) { CMD_REGISTER("save_state", {SaveStateHandler, "Save a state."}); CMD_REGISTER("load_state", {LoadStateHandler, "Load a state."}); CMD_REGISTER("set_slot", {StateSlotSelectHandler, "Selects a SaveState slot", { - {"Slot number", LUS::ArgumentType::NUMBER,} + {"Slot number", Ship::ArgumentType::NUMBER,} }}); // Map & Location CMD_REGISTER("void", {VoidHandler, "Voids out of the current map."}); CMD_REGISTER("reload", {ReloadHandler, "Reloads the current map."}); CMD_REGISTER("fw", {FWHandler, "Spawns the player where Farore's Wind is set.", { - {"clear|warp|backup", LUS::ArgumentType::TEXT} + {"clear|warp|backup", Ship::ArgumentType::TEXT} }}); CMD_REGISTER("entrance", {EntranceHandler, "Sends player to the entered entrance (hex)", { - {"entrance", LUS::ArgumentType::NUMBER} + {"entrance", Ship::ArgumentType::NUMBER} }}); // Gameplay @@ -1430,64 +1430,64 @@ void DebugConsole_Init(void) { CMD_REGISTER("map", {LoadSceneHandler, "Load up kak?"}); CMD_REGISTER("rupee", {RupeeHandler, "Set your rupee counter.", { - {"amount", LUS::ArgumentType::NUMBER} + {"amount", Ship::ArgumentType::NUMBER} }}); CMD_REGISTER("bItem", {BHandler, "Set an item to the B button.", { - {"Item ID", LUS::ArgumentType::NUMBER} + {"Item ID", Ship::ArgumentType::NUMBER} }}); - CMD_REGISTER("spawn", { ActorSpawnHandler, "Spawn an actor.", { { "actor name/id", LUS::ArgumentType::NUMBER }, // TODO there should be an actor_id arg type - {"data", LUS::ArgumentType::NUMBER}, - {"x", LUS::ArgumentType::NUMBER, true}, - {"y", LUS::ArgumentType::NUMBER, true}, - {"z", LUS::ArgumentType::NUMBER, true}, - {"rx", LUS::ArgumentType::NUMBER, true}, - {"ry", LUS::ArgumentType::NUMBER, true}, - {"rz", LUS::ArgumentType::NUMBER, true} + CMD_REGISTER("spawn", { ActorSpawnHandler, "Spawn an actor.", { { "actor name/id", Ship::ArgumentType::NUMBER }, // TODO there should be an actor_id arg type + {"data", Ship::ArgumentType::NUMBER}, + {"x", Ship::ArgumentType::NUMBER, true}, + {"y", Ship::ArgumentType::NUMBER, true}, + {"z", Ship::ArgumentType::NUMBER, true}, + {"rx", Ship::ArgumentType::NUMBER, true}, + {"ry", Ship::ArgumentType::NUMBER, true}, + {"rz", Ship::ArgumentType::NUMBER, true} }}); CMD_REGISTER("pos", {SetPosHandler, "Sets the position of the player.", { - {"x", LUS::ArgumentType::NUMBER, true}, - {"y", LUS::ArgumentType::NUMBER, true}, - {"z", LUS::ArgumentType::NUMBER, true} + {"x", Ship::ArgumentType::NUMBER, true}, + {"y", Ship::ArgumentType::NUMBER, true}, + {"z", Ship::ArgumentType::NUMBER, true} }}); CMD_REGISTER("addammo", {AddAmmoHandler, "Adds ammo of an item.", { - {"sticks|nuts|bombs|seeds|arrows|bombchus|beans", LUS::ArgumentType::TEXT}, - {"count", LUS::ArgumentType::NUMBER} + {"sticks|nuts|bombs|seeds|arrows|bombchus|beans", Ship::ArgumentType::TEXT}, + {"count", Ship::ArgumentType::NUMBER} }}); CMD_REGISTER("takeammo", {TakeAmmoHandler, "Removes ammo of an item.", { - {"sticks|nuts|bombs|seeds|arrows|bombchus|beans", LUS::ArgumentType::TEXT}, - {"count", LUS::ArgumentType::NUMBER} + {"sticks|nuts|bombs|seeds|arrows|bombchus|beans", Ship::ArgumentType::TEXT}, + {"count", Ship::ArgumentType::NUMBER} }}); CMD_REGISTER("bottle", {BottleHandler, "Changes item in a bottle slot.", { - {"item", LUS::ArgumentType::TEXT}, - {"slot", LUS::ArgumentType::NUMBER} + {"item", Ship::ArgumentType::TEXT}, + {"slot", Ship::ArgumentType::NUMBER} }}); CMD_REGISTER("give_item", {GiveItemHandler, "Gives an item to the player as if it was given from an actor", { - {"vanilla|randomizer", LUS::ArgumentType::TEXT}, - {"giveItemID", LUS::ArgumentType::NUMBER} + {"vanilla|randomizer", Ship::ArgumentType::TEXT}, + {"giveItemID", Ship::ArgumentType::NUMBER} }}); CMD_REGISTER("item", {ItemHandler, "Sets item ID in arg 1 into slot arg 2. No boundary checks. Use with caution.", { - {"slot", LUS::ArgumentType::NUMBER}, - {"item id", LUS::ArgumentType::NUMBER} + {"slot", Ship::ArgumentType::NUMBER}, + {"item id", Ship::ArgumentType::NUMBER} }}); CMD_REGISTER("invisible", {InvisibleHandler, "Activate Link's Elvish cloak, making him appear invisible.", { - {"value", LUS::ArgumentType::NUMBER} + {"value", Ship::ArgumentType::NUMBER} }}); CMD_REGISTER("giant_link", {GiantLinkHandler, "Turn Link into a giant Lonky boi.", { - {"value", LUS::ArgumentType::NUMBER} + {"value", Ship::ArgumentType::NUMBER} }}); CMD_REGISTER("minish_link", {MinishLinkHandler, "Turn Link into a minish boi.", { - {"value", LUS::ArgumentType::NUMBER} + {"value", Ship::ArgumentType::NUMBER} }}); CMD_REGISTER("add_heart_container", @@ -1497,25 +1497,25 @@ void DebugConsole_Init(void) { {RemoveHeartContainerHandler, "Remove a heart from Link. The minimal amount of hearts is 3."}); CMD_REGISTER("gravity", {GravityHandler, "Set gravity level.", { - {"value", LUS::ArgumentType::NUMBER} + {"value", Ship::ArgumentType::NUMBER} }}); CMD_REGISTER("no_ui", {NoUIHandler, "Disables the UI.", { - {"value", LUS::ArgumentType::NUMBER} + {"value", Ship::ArgumentType::NUMBER} }}); CMD_REGISTER("freeze", {FreezeHandler, "Freezes Link in place"}); CMD_REGISTER("defense_modifier", {DefenseModifierHandler, "Sets the defense modifier.", { - {"value", LUS::ArgumentType::NUMBER} + {"value", Ship::ArgumentType::NUMBER} }}); CMD_REGISTER("damage", {DamageHandler, "Deal damage to Link.", { - {"value", LUS::ArgumentType::NUMBER} + {"value", Ship::ArgumentType::NUMBER} }}); CMD_REGISTER("heal", {HealHandler, "Heals Link.", { - {"value", LUS::ArgumentType::NUMBER} + {"value", Ship::ArgumentType::NUMBER} }}); CMD_REGISTER("fill_magic", {FillMagicHandler, "Fills magic."}); @@ -1523,50 +1523,50 @@ void DebugConsole_Init(void) { CMD_REGISTER("empty_magic", {EmptyMagicHandler, "Empties magic."}); CMD_REGISTER("no_z", {NoZHandler, "Disables Z-button presses.", { - {"value", LUS::ArgumentType::NUMBER} + {"value", Ship::ArgumentType::NUMBER} }}); CMD_REGISTER("ohko", {OneHitKOHandler, "Activates one hit KO. Any damage kills Link and he cannot gain health in this mode.", { - {"value", LUS::ArgumentType::NUMBER} + {"value", Ship::ArgumentType::NUMBER} }}); CMD_REGISTER("pacifist", {PacifistHandler, "Activates pacifist mode. Prevents Link from using his weapon.", { - {"value", LUS::ArgumentType::NUMBER} + {"value", Ship::ArgumentType::NUMBER} }}); CMD_REGISTER("paper_link", {PaperLinkHandler, "Link but made out of paper.", { - {"value", LUS::ArgumentType::NUMBER} + {"value", Ship::ArgumentType::NUMBER} }}); CMD_REGISTER("rainstorm", {RainstormHandler, "Activates rainstorm."}); CMD_REGISTER("reverse_controls", {ReverseControlsHandler, "Reverses the controls.", { - {"value", LUS::ArgumentType::NUMBER} + {"value", Ship::ArgumentType::NUMBER} }}); CMD_REGISTER("update_rupees", {UpdateRupeesHandler, "Adds rupees.", { - {"value", LUS::ArgumentType::NUMBER} + {"value", Ship::ArgumentType::NUMBER} }}); CMD_REGISTER("speed_modifier", {SpeedModifierHandler, "Sets the speed modifier.", { - {"value", LUS::ArgumentType::NUMBER} + {"value", Ship::ArgumentType::NUMBER} }}); CMD_REGISTER("boots", {BootsHandler, "Activates boots.", { - {"kokiri|iron|hover", LUS::ArgumentType::TEXT}, + {"kokiri|iron|hover", Ship::ArgumentType::TEXT}, }}); CMD_REGISTER("giveshield", {GiveShieldHandler, "Gives a shield and equips it when Link is the right age for it.", { - {"deku|hylian|mirror", LUS::ArgumentType::TEXT}, + {"deku|hylian|mirror", Ship::ArgumentType::TEXT}, }}); CMD_REGISTER("takeshield", {TakeShieldHandler, "Takes a shield and unequips it if Link is wearing it.", { - {"deku|hylian|mirror", LUS::ArgumentType::TEXT}, + {"deku|hylian|mirror", Ship::ArgumentType::TEXT}, }}); CMD_REGISTER("knockback", {KnockbackHandler, "Knocks Link back.", { - {"value", LUS::ArgumentType::NUMBER} + {"value", Ship::ArgumentType::NUMBER} }}); CMD_REGISTER("electrocute", {ElectrocuteHandler, "Electrocutes Link."}); @@ -1576,18 +1576,18 @@ void DebugConsole_Init(void) { CMD_REGISTER("cucco_storm", {CuccoStormHandler, "Cucco Storm"}); CMD_REGISTER("gen_rando", {GenerateRandoHandler, "Generate a randomizer seed", { - {"seed|count", LUS::ArgumentType::NUMBER, true}, - {"testing", LUS::ArgumentType::NUMBER, true}, + {"seed|count", Ship::ArgumentType::NUMBER, true}, + {"testing", Ship::ArgumentType::NUMBER, true}, }}); CMD_REGISTER("cosmetics", {CosmeticsHandler, "Change cosmetics.", { - {"reset|randomize", LUS::ArgumentType::TEXT}, - {"group name", LUS::ArgumentType::TEXT, true}, + {"reset|randomize", Ship::ArgumentType::TEXT}, + {"group name", Ship::ArgumentType::TEXT, true}, }}); CMD_REGISTER("sfx", {SfxHandler, "Change SFX.", { - {"reset|randomize", LUS::ArgumentType::TEXT}, - {"group_name", LUS::ArgumentType::TEXT, true}, + {"reset|randomize", Ship::ArgumentType::TEXT}, + {"group_name", Ship::ArgumentType::TEXT, true}, }}); CVarSave(); diff --git a/soh/soh/Enhancements/debugger/MessageViewer.h b/soh/soh/Enhancements/debugger/MessageViewer.h index 702693793cb..43ae55aa760 100644 --- a/soh/soh/Enhancements/debugger/MessageViewer.h +++ b/soh/soh/Enhancements/debugger/MessageViewer.h @@ -26,7 +26,7 @@ void MessageDebug_DisplayCustomMessage(const char* customMessage); } -class MessageViewer : public LUS::GuiWindow { +class MessageViewer : public Ship::GuiWindow { public: static inline const char* TABLE_ID = "MessageViewer"; using GuiWindow::GuiWindow; diff --git a/soh/soh/Enhancements/debugger/actorViewer.h b/soh/soh/Enhancements/debugger/actorViewer.h index 6eceaa92d23..2f4ca680a1d 100644 --- a/soh/soh/Enhancements/debugger/actorViewer.h +++ b/soh/soh/Enhancements/debugger/actorViewer.h @@ -2,7 +2,7 @@ #include -class ActorViewerWindow : public LUS::GuiWindow { +class ActorViewerWindow : public Ship::GuiWindow { public: using GuiWindow::GuiWindow; diff --git a/soh/soh/Enhancements/debugger/colViewer.h b/soh/soh/Enhancements/debugger/colViewer.h index 98f0b6f0af4..5252bc950e6 100644 --- a/soh/soh/Enhancements/debugger/colViewer.h +++ b/soh/soh/Enhancements/debugger/colViewer.h @@ -14,7 +14,7 @@ typedef enum { } ColViewerRenderSetting; #ifdef __cplusplus -class ColViewerWindow : public LUS::GuiWindow { +class ColViewerWindow : public Ship::GuiWindow { public: using GuiWindow::GuiWindow; diff --git a/soh/soh/Enhancements/debugger/debugSaveEditor.cpp b/soh/soh/Enhancements/debugger/debugSaveEditor.cpp index f90ab739cfb..f7b85251cd4 100644 --- a/soh/soh/Enhancements/debugger/debugSaveEditor.cpp +++ b/soh/soh/Enhancements/debugger/debugSaveEditor.cpp @@ -614,7 +614,7 @@ void DrawInfoTab() { void DrawBGSItemFlag(uint8_t itemID) { const ItemMapEntry& slotEntry = itemMapping[itemID]; - ImGui::Image(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(slotEntry.name), ImVec2(32.0f, 32.0f), ImVec2(0, 0), ImVec2(1, 1)); + ImGui::Image(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(slotEntry.name), ImVec2(32.0f, 32.0f), ImVec2(0, 0), ImVec2(1, 1)); ImGui::SameLine(); int tradeIndex = itemID - ITEM_POCKET_EGG; bool hasItem = (gSaveContext.adultTradeItems & (1 << tradeIndex)) != 0; @@ -656,7 +656,7 @@ void DrawInventoryTab() { uint8_t item = gSaveContext.inventory.items[index]; if (item != ITEM_NONE) { const ItemMapEntry& slotEntry = itemMapping.find(item)->second; - if (ImGui::ImageButton(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(slotEntry.name), ImVec2(32.0f, 32.0f), ImVec2(0, 0), + if (ImGui::ImageButton(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(slotEntry.name), ImVec2(32.0f, 32.0f), ImVec2(0, 0), ImVec2(1, 1), 0)) { selectedIndex = index; ImGui::OpenPopup(itemPopupPicker); @@ -704,7 +704,7 @@ void DrawInventoryTab() { ImGui::SameLine(); } const ItemMapEntry& slotEntry = possibleItems[pickerIndex]; - if (ImGui::ImageButton(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(slotEntry.name), ImVec2(32.0f, 32.0f), + if (ImGui::ImageButton(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(slotEntry.name), ImVec2(32.0f, 32.0f), ImVec2(0, 0), ImVec2(1, 1), 0)) { gSaveContext.inventory.items[selectedIndex] = slotEntry.id; // Set adult trade item flag if you're playing adult trade shuffle in rando @@ -742,7 +742,7 @@ void DrawInventoryTab() { ImGui::PushItemWidth(32.0f); ImGui::BeginGroup(); - ImGui::Image(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(itemMapping[item].name), ImVec2(32.0f, 32.0f)); + ImGui::Image(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(itemMapping[item].name), ImVec2(32.0f, 32.0f)); ImGui::InputScalar("##ammoInput", ImGuiDataType_S8, &AMMO(item)); ImGui::EndGroup(); @@ -1157,7 +1157,7 @@ void DrawUpgradeIcon(const std::string& categoryName, int32_t categoryId, const uint8_t item = items[CUR_UPG_VALUE(categoryId)]; if (item != ITEM_NONE) { const ItemMapEntry& slotEntry = itemMapping[item]; - if (ImGui::ImageButton(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(slotEntry.name), ImVec2(32.0f, 32.0f), ImVec2(0, 0), + if (ImGui::ImageButton(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(slotEntry.name), ImVec2(32.0f, 32.0f), ImVec2(0, 0), ImVec2(1, 1), 0)) { ImGui::OpenPopup(upgradePopupPicker); } @@ -1185,7 +1185,7 @@ void DrawUpgradeIcon(const std::string& categoryName, int32_t categoryId, const UIWidgets::SetLastItemHoverText("None"); } else { const ItemMapEntry& slotEntry = itemMapping[items[pickerIndex]]; - if (ImGui::ImageButton(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(slotEntry.name), ImVec2(32.0f, 32.0f), ImVec2(0, 0), + if (ImGui::ImageButton(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(slotEntry.name), ImVec2(32.0f, 32.0f), ImVec2(0, 0), ImVec2(1, 1), 0)) { Inventory_ChangeUpgrade(categoryId, pickerIndex); ImGui::CloseCurrentPopup(); @@ -1222,7 +1222,7 @@ void DrawEquipmentTab() { bool hasEquip = (bitMask & gSaveContext.inventory.equipment) != 0; const ItemMapEntry& entry = itemMapping[equipmentValues[i]]; ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0)); - if (ImGui::ImageButton(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(hasEquip ? entry.name : entry.nameFaded), + if (ImGui::ImageButton(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(hasEquip ? entry.name : entry.nameFaded), ImVec2(32.0f, 32.0f), ImVec2(0, 0), ImVec2(1, 1), 0)) { if (hasEquip) { gSaveContext.inventory.equipment &= ~bitMask; @@ -1321,7 +1321,7 @@ void DrawQuestItemButton(uint32_t item) { uint32_t bitMask = 1 << entry.id; bool hasQuestItem = (bitMask & gSaveContext.inventory.questItems) != 0; ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0)); - if (ImGui::ImageButton(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(hasQuestItem ? entry.name : entry.nameFaded), + if (ImGui::ImageButton(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(hasQuestItem ? entry.name : entry.nameFaded), ImVec2(32.0f, 32.0f), ImVec2(0, 0), ImVec2(1, 1), 0)) { if (hasQuestItem) { gSaveContext.inventory.questItems &= ~bitMask; @@ -1339,7 +1339,7 @@ void DrawDungeonItemButton(uint32_t item, uint32_t scene) { uint32_t bitMask = 1 << (entry.id - ITEM_KEY_BOSS); // Bitset starts at ITEM_KEY_BOSS == 0. the rest are sequential bool hasItem = (bitMask & gSaveContext.inventory.dungeonItems[scene]) != 0; ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0)); - if (ImGui::ImageButton(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(hasItem ? entry.name : entry.nameFaded), + if (ImGui::ImageButton(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(hasItem ? entry.name : entry.nameFaded), ImVec2(32.0f, 32.0f), ImVec2(0, 0), ImVec2(1, 1), 0)) { if (hasItem) { gSaveContext.inventory.dungeonItems[scene] &= ~bitMask; @@ -1386,7 +1386,7 @@ void DrawQuestStatusTab() { uint32_t bitMask = 1 << entry.id; bool hasQuestItem = (bitMask & gSaveContext.inventory.questItems) != 0; ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0)); - if (ImGui::ImageButton(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(hasQuestItem ? entry.name : entry.nameFaded), + if (ImGui::ImageButton(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(hasQuestItem ? entry.name : entry.nameFaded), ImVec2(16.0f, 24.0f), ImVec2(0, 0), ImVec2(1, 1), 0)) { if (hasQuestItem) { gSaveContext.inventory.questItems &= ~bitMask; @@ -1449,7 +1449,7 @@ void DrawQuestStatusTab() { if (dungeonItemsScene != SCENE_JABU_JABU_BOSS) { float lineHeight = ImGui::GetTextLineHeightWithSpacing(); - ImGui::Image(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(itemMapping[ITEM_KEY_SMALL].name), ImVec2(lineHeight, lineHeight)); + ImGui::Image(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(itemMapping[ITEM_KEY_SMALL].name), ImVec2(lineHeight, lineHeight)); ImGui::SameLine(); if (ImGui::InputScalar("##Keys", ImGuiDataType_S8, gSaveContext.inventory.dungeonKeys + dungeonItemsScene)) { gSaveContext.sohStats.dungeonKeys[dungeonItemsScene] = gSaveContext.inventory.dungeonKeys[dungeonItemsScene]; @@ -1793,34 +1793,34 @@ void SaveEditorWindow::DrawElement() { void SaveEditorWindow::InitElement() { // Load item icons into ImGui for (const auto& entry : itemMapping) { - LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.second.name, entry.second.texturePath, ImVec4(1, 1, 1, 1)); - LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.second.nameFaded, entry.second.texturePath, ImVec4(1, 1, 1, 0.3f)); + Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.second.name, entry.second.texturePath, ImVec4(1, 1, 1, 1)); + Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.second.nameFaded, entry.second.texturePath, ImVec4(1, 1, 1, 0.3f)); } for (const auto& entry : gregMapping) { ImVec4 gregGreen = ImVec4(42.0f / 255.0f, 169.0f / 255.0f, 40.0f / 255.0f, 1.0f); ImVec4 gregFadedGreen = gregGreen; gregFadedGreen.w = 0.3f; - LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.second.name, entry.second.texturePath, gregGreen); - LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.second.nameFaded, entry.second.texturePath, gregFadedGreen); + Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.second.name, entry.second.texturePath, gregGreen); + Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.second.nameFaded, entry.second.texturePath, gregFadedGreen); } for (const auto& entry : triforcePieceMapping) { - LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.second.name, entry.second.texturePath, ImVec4(1, 1, 1, 1)); - LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.second.nameFaded, entry.second.texturePath, ImVec4(1, 1, 1, 0.3f)); + Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.second.name, entry.second.texturePath, ImVec4(1, 1, 1, 1)); + Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.second.nameFaded, entry.second.texturePath, ImVec4(1, 1, 1, 0.3f)); } for (const auto& entry : questMapping) { - LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.second.name, entry.second.texturePath, ImVec4(1, 1, 1, 1)); - LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.second.nameFaded, entry.second.texturePath, ImVec4(1, 1, 1, 0.3f)); + Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.second.name, entry.second.texturePath, ImVec4(1, 1, 1, 1)); + Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.second.nameFaded, entry.second.texturePath, ImVec4(1, 1, 1, 0.3f)); } for (const auto& entry : songMapping) { - LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.name, gSongNoteTex, entry.color); + Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.name, gSongNoteTex, entry.color); ImVec4 fadedCol = entry.color; fadedCol.w = 0.3f; - LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.nameFaded, gSongNoteTex, fadedCol); + Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.nameFaded, gSongNoteTex, fadedCol); } for (const auto& entry : vanillaSongMapping) { - LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.name, gSongNoteTex, entry.color); + Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.name, gSongNoteTex, entry.color); ImVec4 fadedCol = entry.color; fadedCol.w = 0.3f; - LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.nameFaded, gSongNoteTex, fadedCol); + Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.nameFaded, gSongNoteTex, fadedCol); } } diff --git a/soh/soh/Enhancements/debugger/debugSaveEditor.h b/soh/soh/Enhancements/debugger/debugSaveEditor.h index 01557efefe0..1de852e3560 100644 --- a/soh/soh/Enhancements/debugger/debugSaveEditor.h +++ b/soh/soh/Enhancements/debugger/debugSaveEditor.h @@ -590,7 +590,7 @@ const std::vector state3 = { "Travelling to Hook Target" }; -class SaveEditorWindow : public LUS::GuiWindow { +class SaveEditorWindow : public Ship::GuiWindow { public: using GuiWindow::GuiWindow; diff --git a/soh/soh/Enhancements/debugger/dlViewer.cpp b/soh/soh/Enhancements/debugger/dlViewer.cpp index 028234fc189..790f426dfb6 100644 --- a/soh/soh/Enhancements/debugger/dlViewer.cpp +++ b/soh/soh/Enhancements/debugger/dlViewer.cpp @@ -65,7 +65,7 @@ std::map cmdMap = { }; void PerformDisplayListSearch() { - auto result = LUS::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->ListFiles("*" + std::string(searchString) + "*DL*"); + auto result = Ship::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->ListFiles("*" + std::string(searchString) + "*DL*"); displayListSearchResults.clear(); @@ -127,7 +127,7 @@ void DLViewerWindow::DrawElement() { } try { - auto res = std::static_pointer_cast(LUS::Context::GetInstance()->GetResourceManager()->LoadResource(activeDisplayList)); + auto res = std::static_pointer_cast(Ship::Context::GetInstance()->GetResourceManager()->LoadResource(activeDisplayList)); if (res->GetInitData()->Type != static_cast(LUS::ResourceType::DisplayList)) { ImGui::Text("Resource type is not a Display List. Please choose another."); diff --git a/soh/soh/Enhancements/debugger/dlViewer.h b/soh/soh/Enhancements/debugger/dlViewer.h index 348372a4940..9d278545663 100644 --- a/soh/soh/Enhancements/debugger/dlViewer.h +++ b/soh/soh/Enhancements/debugger/dlViewer.h @@ -2,7 +2,7 @@ #include -class DLViewerWindow : public LUS::GuiWindow { +class DLViewerWindow : public Ship::GuiWindow { public: using GuiWindow::GuiWindow; diff --git a/soh/soh/Enhancements/debugger/valueViewer.h b/soh/soh/Enhancements/debugger/valueViewer.h index 7631b8c3fb2..747d39018dc 100644 --- a/soh/soh/Enhancements/debugger/valueViewer.h +++ b/soh/soh/Enhancements/debugger/valueViewer.h @@ -33,7 +33,7 @@ typedef struct { uint32_t y; } ValueTableElement; -class ValueViewerWindow : public LUS::GuiWindow { +class ValueViewerWindow : public Ship::GuiWindow { public: using GuiWindow::GuiWindow; diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor_RawAction.cpp b/soh/soh/Enhancements/game-interactor/GameInteractor_RawAction.cpp index 229f76cbb96..cf098bda313 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor_RawAction.cpp +++ b/soh/soh/Enhancements/game-interactor/GameInteractor_RawAction.cpp @@ -459,7 +459,7 @@ void GameInteractor::RawAction::SetCosmeticsColor(uint8_t cosmeticCategory, uint break; } - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); ApplyOrResetCustomGfxPatches(); } diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor_Sail.cpp b/soh/soh/Enhancements/game-interactor/GameInteractor_Sail.cpp index a209d8c5019..77d48dc807c 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor_Sail.cpp +++ b/soh/soh/Enhancements/game-interactor/GameInteractor_Sail.cpp @@ -66,7 +66,7 @@ void GameInteractorSail::HandleRemoteJson(nlohmann::json payload) { } std::string command = payload["command"].get(); - std::reinterpret_pointer_cast(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Console"))->Dispatch(command); + std::reinterpret_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Console"))->Dispatch(command); responsePayload["status"] = "success"; GameInteractor::Instance->TransmitJsonToRemote(responsePayload); return; @@ -88,7 +88,7 @@ void GameInteractorSail::HandleRemoteJson(nlohmann::json payload) { } std::string command = payload["effect"]["command"].get(); - std::reinterpret_pointer_cast(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Console"))->Dispatch(command); + std::reinterpret_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Console"))->Dispatch(command); responsePayload["status"] = "success"; GameInteractor::Instance->TransmitJsonToRemote(responsePayload); return; diff --git a/soh/soh/Enhancements/gameplaystatswindow.h b/soh/soh/Enhancements/gameplaystatswindow.h index 2a3786415ea..453b24559c7 100644 --- a/soh/soh/Enhancements/gameplaystatswindow.h +++ b/soh/soh/Enhancements/gameplaystatswindow.h @@ -1,7 +1,7 @@ #include #include "gameplaystats.h" -class GameplayStatsWindow : public LUS::GuiWindow { +class GameplayStatsWindow : public Ship::GuiWindow { public: using GuiWindow::GuiWindow; diff --git a/soh/soh/Enhancements/mods.cpp b/soh/soh/Enhancements/mods.cpp index a10dd559bbe..8f9819f0857 100644 --- a/soh/soh/Enhancements/mods.cpp +++ b/soh/soh/Enhancements/mods.cpp @@ -462,7 +462,7 @@ void RegisterDeleteFileOnDeath() { if (gPlayState->gameOverCtx.state == GAMEOVER_DEATH_MENU && gPlayState->pauseCtx.state == 9) { SaveManager::Instance->DeleteZeldaFile(gSaveContext.fileNum); hasAffectedHealth = false; - std::reinterpret_pointer_cast(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Console"))->Dispatch("reset"); + std::reinterpret_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Console"))->Dispatch("reset"); } }); } diff --git a/soh/soh/Enhancements/presets.cpp b/soh/soh/Enhancements/presets.cpp index 726863e0550..ea51502e3ad 100644 --- a/soh/soh/Enhancements/presets.cpp +++ b/soh/soh/Enhancements/presets.cpp @@ -70,7 +70,7 @@ void DrawPresetSelector(PresetType presetTypeId) { if (selectedPresetId != 0) { applyPreset(selectedPresetDef.entries); } - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } ImGui::PopStyleVar(1); } diff --git a/soh/soh/Enhancements/randomizer/3drando/rando_main.cpp b/soh/soh/Enhancements/randomizer/3drando/rando_main.cpp index 167e12667de..e53caeef21c 100644 --- a/soh/soh/Enhancements/randomizer/3drando/rando_main.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/rando_main.cpp @@ -18,7 +18,7 @@ void RandoMain::GenerateRando(std::unordered_map cvarS // std::string settingsFileName = "./randomizer/latest_settings.json"; // CVarSetString("gLoadedPreset", settingsFileName.c_str()); - std::string fileName = LUS::Context::GetPathRelativeToAppDirectory(GenerateRandomizer(cvarSettings, excludedLocations, enabledTricks, seedString).c_str()); + std::string fileName = Ship::Context::GetPathRelativeToAppDirectory(GenerateRandomizer(cvarSettings, excludedLocations, enabledTricks, seedString).c_str()); CVarSetString("gSpoilerLog", fileName.c_str()); CVarSave(); diff --git a/soh/soh/Enhancements/randomizer/3drando/spoiler_log.cpp b/soh/soh/Enhancements/randomizer/3drando/spoiler_log.cpp index ce885aec5b0..23599627336 100644 --- a/soh/soh/Enhancements/randomizer/3drando/spoiler_log.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/spoiler_log.cpp @@ -895,8 +895,8 @@ const char* SpoilerLog_Write(int language) { WriteAllLocations(language); //WriteHintData(language); - if (!std::filesystem::exists(LUS::Context::GetPathRelativeToAppDirectory("Randomizer"))) { - std::filesystem::create_directory(LUS::Context::GetPathRelativeToAppDirectory("Randomizer")); + if (!std::filesystem::exists(Ship::Context::GetPathRelativeToAppDirectory("Randomizer"))) { + std::filesystem::create_directory(Ship::Context::GetPathRelativeToAppDirectory("Randomizer")); } std::string jsonString = jsonData.dump(4); @@ -911,7 +911,7 @@ const char* SpoilerLog_Write(int language) { fileNameStream << std::to_string(Settings::hashIconIndexes[i]); } std::string fileName = fileNameStream.str(); - std::ofstream jsonFile(LUS::Context::GetPathRelativeToAppDirectory( + std::ofstream jsonFile(Ship::Context::GetPathRelativeToAppDirectory( (std::string("Randomizer/") + fileName + std::string(".json")).c_str())); jsonFile << std::setw(4) << jsonString << std::endl; jsonFile.close(); diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index 40b3daaf3f4..0c7f30e0f70 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -4683,7 +4683,7 @@ void RandomizerSettingsWindow::DrawElement() { excludedLocationString += ","; } CVarSetString(CVAR_RANDOMIZER_SETTING("ExcludedLocations"), excludedLocationString.c_str()); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } ImGui::SameLine(); ImGui::Text("%s", rcObject->rcShortName.c_str()); @@ -4728,7 +4728,7 @@ void RandomizerSettingsWindow::DrawElement() { } else { CVarSetString(CVAR_RANDOMIZER_SETTING("ExcludedLocations"), excludedLocationString.c_str()); } - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } ImGui::SameLine(); ImGui::Text("%s", rcObject->rcShortName.c_str()); @@ -4914,7 +4914,7 @@ void RandomizerSettingsWindow::DrawElement() { enabledTrickString += ","; } CVarClear(CVAR_RANDOMIZER_SETTING("EnabledTricks")); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } ImGui::SameLine(); if (ImGui::Button("Enable All")) { @@ -4931,7 +4931,7 @@ void RandomizerSettingsWindow::DrawElement() { enabledTrickString += ","; } CVarSetString(CVAR_RANDOMIZER_SETTING("EnabledTricks"), enabledTrickString.c_str()); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } } if (ImGui::BeginTable("trickTags", showTag.size(), ImGuiTableFlags_Resizable | ImGuiTableFlags_NoSavedSettings | ImGuiTableFlags_Borders)) { @@ -5008,7 +5008,7 @@ void RandomizerSettingsWindow::DrawElement() { enabledTrickString += ","; } CVarSetString(CVAR_RANDOMIZER_SETTING("EnabledTricks"), enabledTrickString.c_str()); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } ImGui::BeginChild("ChildTricksDisabled", ImVec2(0, -8), false, ImGuiWindowFlags_HorizontalScrollbar); @@ -5044,7 +5044,7 @@ void RandomizerSettingsWindow::DrawElement() { enabledTrickString += ","; } CVarSetString(CVAR_RANDOMIZER_SETTING("EnabledTricks"), enabledTrickString.c_str()); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } DrawTagChips(*rtObject.rtTags); ImGui::SameLine(); @@ -5118,7 +5118,7 @@ void RandomizerSettingsWindow::DrawElement() { enabledTrickString += ","; } CVarClear(CVAR_RANDOMIZER_SETTING("EnabledTricks")); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } ImGui::BeginChild("ChildTricksEnabled", ImVec2(0, -8), false, ImGuiWindowFlags_HorizontalScrollbar); @@ -5160,7 +5160,7 @@ void RandomizerSettingsWindow::DrawElement() { } else { CVarSetString(CVAR_RANDOMIZER_SETTING("EnabledTricks"), enabledTrickString.c_str()); } - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } DrawTagChips(*rtObject.rtTags); ImGui::SameLine(); diff --git a/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp b/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp index 1123cba7243..20b5c333dc2 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp @@ -877,7 +877,7 @@ void CheckTrackerWindow::DrawElement() { if (CVarGetInteger(CVAR_TRACKER_CHECK("DisplayType"), TRACKER_DISPLAY_ALWAYS) == TRACKER_DISPLAY_COMBO_BUTTON) { int comboButton1Mask = buttons[CVarGetInteger(CVAR_TRACKER_CHECK("ComboButton1"), TRACKER_COMBO_BUTTON_L)]; int comboButton2Mask = buttons[CVarGetInteger(CVAR_TRACKER_CHECK("ComboButton2"), TRACKER_COMBO_BUTTON_R)]; - OSContPad* trackerButtonsPressed = LUS::Context::GetInstance()->GetControlDeck()->GetPads(); + OSContPad* trackerButtonsPressed = Ship::Context::GetInstance()->GetControlDeck()->GetPads(); bool comboButtonsHeld = trackerButtonsPressed != nullptr && trackerButtonsPressed[0].button & comboButton1Mask && trackerButtonsPressed[0].button & comboButton2Mask; diff --git a/soh/soh/Enhancements/randomizer/randomizer_check_tracker.h b/soh/soh/Enhancements/randomizer/randomizer_check_tracker.h index 85a4f1d9eb6..216da367fc2 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_check_tracker.h +++ b/soh/soh/Enhancements/randomizer/randomizer_check_tracker.h @@ -7,9 +7,9 @@ namespace CheckTracker { -class CheckTrackerSettingsWindow : public LUS::GuiWindow { +class CheckTrackerSettingsWindow : public Ship::GuiWindow { public: - using LUS::GuiWindow::GuiWindow; + using GuiWindow::GuiWindow; ~CheckTrackerSettingsWindow() {}; protected: @@ -18,9 +18,9 @@ class CheckTrackerSettingsWindow : public LUS::GuiWindow { void UpdateElement() override {}; }; -class CheckTrackerWindow : public LUS::GuiWindow { +class CheckTrackerWindow : public Ship::GuiWindow { public: - using LUS::GuiWindow::GuiWindow; + using GuiWindow::GuiWindow; ~CheckTrackerWindow() {}; protected: diff --git a/soh/soh/Enhancements/randomizer/randomizer_entrance_tracker.h b/soh/soh/Enhancements/randomizer/randomizer_entrance_tracker.h index fc5346aa30f..87d73605833 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_entrance_tracker.h +++ b/soh/soh/Enhancements/randomizer/randomizer_entrance_tracker.h @@ -85,7 +85,7 @@ s16 GetLastEntranceOverride(); s16 GetCurrentGrottoId(); const EntranceData* GetEntranceData(s16); -class EntranceTrackerWindow : public LUS::GuiWindow { +class EntranceTrackerWindow : public Ship::GuiWindow { public: using GuiWindow::GuiWindow; diff --git a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp index 5ae80b5e738..5fd158d8f66 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp @@ -560,7 +560,7 @@ void DrawItemCount(ItemTrackerItem item, bool hideMax) { void DrawEquip(ItemTrackerItem item) { bool hasEquip = HasEquipment(item); int iconSize = CVarGetInteger(CVAR_TRACKER_ITEM("IconSize"), 36); - ImGui::Image(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(hasEquip && IsValidSaveFile() ? item.name : item.nameFaded), + ImGui::Image(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(hasEquip && IsValidSaveFile() ? item.name : item.nameFaded), ImVec2(iconSize, iconSize), ImVec2(0, 0), ImVec2(1, 1)); UIWidgets::SetLastItemHoverText(SohUtils::GetItemName(item.id)); @@ -570,7 +570,7 @@ void DrawQuest(ItemTrackerItem item) { bool hasQuestItem = HasQuestItem(item); int iconSize = CVarGetInteger(CVAR_TRACKER_ITEM("IconSize"), 36); ImGui::BeginGroup(); - ImGui::Image(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(hasQuestItem && IsValidSaveFile() ? item.name : item.nameFaded), + ImGui::Image(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(hasQuestItem && IsValidSaveFile() ? item.name : item.nameFaded), ImVec2(iconSize, iconSize), ImVec2(0, 0), ImVec2(1, 1)); if (item.id == QUEST_SKULL_TOKEN) { @@ -640,7 +640,7 @@ void DrawItem(ItemTrackerItem item) { ImGui::BeginGroup(); - ImGui::Image(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(hasItem && IsValidSaveFile() ? item.name : item.nameFaded), + ImGui::Image(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(hasItem && IsValidSaveFile() ? item.name : item.nameFaded), ImVec2(iconSize, iconSize), ImVec2(0, 0), ImVec2(1, 1)); DrawItemCount(item, false); @@ -662,7 +662,7 @@ void DrawBottle(ItemTrackerItem item) { } int iconSize = CVarGetInteger(CVAR_TRACKER_ITEM("IconSize"), 36); - ImGui::Image(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(hasItem && IsValidSaveFile() ? item.name : item.nameFaded), + ImGui::Image(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(hasItem && IsValidSaveFile() ? item.name : item.nameFaded), ImVec2(iconSize, iconSize), ImVec2(0, 0), ImVec2(1, 1)); UIWidgets::SetLastItemHoverText(SohUtils::GetItemName(item.id)); @@ -677,11 +677,11 @@ void DrawDungeonItem(ItemTrackerItem item) { bool hasSmallKey = GameInteractor::IsSaveLoaded() ? ((gSaveContext.inventory.dungeonKeys[item.data]) >= 0) : false; ImGui::BeginGroup(); if (itemId == ITEM_KEY_SMALL) { - ImGui::Image(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(hasSmallKey && IsValidSaveFile() ? item.name : item.nameFaded), + ImGui::Image(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(hasSmallKey && IsValidSaveFile() ? item.name : item.nameFaded), ImVec2(iconSize, iconSize), ImVec2(0, 0), ImVec2(1, 1)); } else { - ImGui::Image(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(hasItem && IsValidSaveFile() ? item.name : item.nameFaded), + ImGui::Image(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(hasItem && IsValidSaveFile() ? item.name : item.nameFaded), ImVec2(iconSize, iconSize), ImVec2(0, 0), ImVec2(1, 1)); } @@ -722,7 +722,7 @@ void DrawSong(ItemTrackerItem item) { ImVec2 p = ImGui::GetCursorScreenPos(); bool hasSong = HasSong(item); ImGui::SetCursorScreenPos(ImVec2(p.x + 6, p.y)); - ImGui::Image(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(hasSong && IsValidSaveFile() ? item.name : item.nameFaded), + ImGui::Image(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(hasSong && IsValidSaveFile() ? item.name : item.nameFaded), ImVec2(iconSize / 1.5, iconSize), ImVec2(0, 0), ImVec2(1, 1)); UIWidgets::SetLastItemHoverText(SohUtils::GetQuestItemName(item.id)); } @@ -1013,7 +1013,7 @@ void ItemTrackerWindow::DrawElement() { int iconSpacing = CVarGetInteger(CVAR_TRACKER_ITEM("IconSpacing"), 12); int comboButton1Mask = buttonMap[CVarGetInteger(CVAR_TRACKER_ITEM("ComboButton1"), TRACKER_COMBO_BUTTON_L)]; int comboButton2Mask = buttonMap[CVarGetInteger(CVAR_TRACKER_ITEM("ComboButton2"), TRACKER_COMBO_BUTTON_R)]; - OSContPad* buttonsPressed = LUS::Context::GetInstance()->GetControlDeck()->GetPads(); + OSContPad* buttonsPressed = Ship::Context::GetInstance()->GetControlDeck()->GetPads(); bool comboButtonsHeld = buttonsPressed != nullptr && buttonsPressed[0].button & comboButton1Mask && buttonsPressed[0].button & comboButton2Mask; bool isPaused = CVarGetInteger(CVAR_TRACKER_ITEM("ShowOnlyPaused"), 0) == 0 || gPlayState != nullptr && gPlayState->pauseCtx.state > 0; @@ -1144,7 +1144,7 @@ void ItemTrackerSettingsWindow::DrawElement() { CVarSetFloat(CVAR_TRACKER_ITEM("BgColorG"), ChromaKeyBackground.y); CVarSetFloat(CVAR_TRACKER_ITEM("BgColorB"), ChromaKeyBackground.z); CVarSetFloat(CVAR_TRACKER_ITEM("BgColorA"), ChromaKeyBackground.w); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } ImGui::PopItemWidth(); diff --git a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.h b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.h index 1fb4e1063be..cae869c5438 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.h +++ b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.h @@ -29,7 +29,7 @@ typedef struct ItemTrackerDungeon { std::vector items; } ItemTrackerDungeon; -class ItemTrackerSettingsWindow : public LUS::GuiWindow { +class ItemTrackerSettingsWindow : public Ship::GuiWindow { public: using GuiWindow::GuiWindow; @@ -39,7 +39,7 @@ class ItemTrackerSettingsWindow : public LUS::GuiWindow { void UpdateElement() override {}; }; -class ItemTrackerWindow : public LUS::GuiWindow { +class ItemTrackerWindow : public Ship::GuiWindow { public: using GuiWindow::GuiWindow; diff --git a/soh/soh/Enhancements/randomizer/randomizer_settings_window.h b/soh/soh/Enhancements/randomizer/randomizer_settings_window.h index bbb55ca3c87..566baeaa3ff 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_settings_window.h +++ b/soh/soh/Enhancements/randomizer/randomizer_settings_window.h @@ -1,6 +1,6 @@ #include -class RandomizerSettingsWindow : public LUS::GuiWindow { +class RandomizerSettingsWindow : public Ship::GuiWindow { public: using GuiWindow::GuiWindow; diff --git a/soh/soh/Enhancements/resolution-editor/ResolutionEditor.cpp b/soh/soh/Enhancements/resolution-editor/ResolutionEditor.cpp index 892b5798a29..69dec46bc18 100644 --- a/soh/soh/Enhancements/resolution-editor/ResolutionEditor.cpp +++ b/soh/soh/Enhancements/resolution-editor/ResolutionEditor.cpp @@ -117,7 +117,7 @@ void AdvancedResolutionSettingsWindow::DrawElement() { CVarGetInteger("gLowResMode", 0); if (UIWidgets::EnhancementSliderFloat("Internal Resolution: %.1f%%", "##IMul", "gInternalResolution", 0.5f, 2.0f, "", 1.0f, true, true, disabled_resolutionSlider)) { - LUS::Context::GetInstance()->GetWindow()->SetResolutionMultiplier( + Ship::Context::GetInstance()->GetWindow()->SetResolutionMultiplier( CVarGetFloat("gInternalResolution", 1)); } UIWidgets::Tooltip("Multiplies your output resolution by the value entered."); @@ -126,7 +126,7 @@ void AdvancedResolutionSettingsWindow::DrawElement() { #ifndef __WIIU__ if (UIWidgets::PaddedEnhancementSliderInt("MSAA: %d", "##IMSAA", "gMSAAValue", 1, 8, "", 1, true, true, false)) { - LUS::Context::GetInstance()->GetWindow()->SetMsaaLevel(CVarGetInteger("gMSAAValue", 1)); + Ship::Context::GetInstance()->GetWindow()->SetMsaaLevel(CVarGetInteger("gMSAAValue", 1)); }; UIWidgets::Tooltip( "Activates multi-sample anti-aliasing when above 1x, up to 8x for 8 samples for every pixel.\n\n" diff --git a/soh/soh/Enhancements/resolution-editor/ResolutionEditor.h b/soh/soh/Enhancements/resolution-editor/ResolutionEditor.h index 68680c8244e..f7593145111 100644 --- a/soh/soh/Enhancements/resolution-editor/ResolutionEditor.h +++ b/soh/soh/Enhancements/resolution-editor/ResolutionEditor.h @@ -2,12 +2,12 @@ #include namespace AdvancedResolutionSettings { -class AdvancedResolutionSettingsWindow : public LUS::GuiWindow { +class AdvancedResolutionSettingsWindow : public Ship::GuiWindow { private: bool IsDroppingFrames(); public: - using LUS::GuiWindow::GuiWindow; + using GuiWindow::GuiWindow; void InitElement() override; void DrawElement() override; diff --git a/soh/soh/Enhancements/savestates.cpp b/soh/soh/Enhancements/savestates.cpp index 54dd56860f6..4d051911e2a 100644 --- a/soh/soh/Enhancements/savestates.cpp +++ b/soh/soh/Enhancements/savestates.cpp @@ -837,7 +837,7 @@ extern "C" void ProcessSaveStateRequests(void) { } void SaveStateMgr::SetCurrentSlot(unsigned int slot) { - LUS::Context::GetInstance()->GetWindow()->GetGui()->GetGameOverlay()->TextDrawNotification(1.0f, true, "slot %u set", slot); + Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGameOverlay()->TextDrawNotification(1.0f, true, "slot %u set", slot); this->currentSlot = slot; } @@ -855,12 +855,12 @@ void SaveStateMgr::ProcessSaveStateRequests(void) { this->states[request.slot] = std::make_shared(OTRGlobals::Instance->gSaveStateMgr, request.slot); } this->states[request.slot]->Save(); - LUS::Context::GetInstance()->GetWindow()->GetGui()->GetGameOverlay()->TextDrawNotification(1.0f, true, "saved state %u", request.slot); + Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGameOverlay()->TextDrawNotification(1.0f, true, "saved state %u", request.slot); break; case RequestType::LOAD: if (this->states.contains(request.slot)) { this->states[request.slot]->Load(); - LUS::Context::GetInstance()->GetWindow()->GetGui()->GetGameOverlay()->TextDrawNotification(1.0f, true, "loaded state %u", request.slot); + Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGameOverlay()->TextDrawNotification(1.0f, true, "loaded state %u", request.slot); } else { SPDLOG_ERROR("Invalid SaveState slot: {}", request.type); } @@ -876,7 +876,7 @@ void SaveStateMgr::ProcessSaveStateRequests(void) { SaveStateReturn SaveStateMgr::AddRequest(const SaveStateRequest request) { if (gPlayState == nullptr) { SPDLOG_ERROR("[SOH] Can not save or load a state outside of \"GamePlay\""); - LUS::Context::GetInstance()->GetWindow()->GetGui()->GetGameOverlay()->TextDrawNotification(1.0f, true, "states not available here", request.slot); + Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGameOverlay()->TextDrawNotification(1.0f, true, "states not available here", request.slot); return SaveStateReturn::FAIL_WRONG_GAMESTATE; } @@ -890,7 +890,7 @@ SaveStateReturn SaveStateMgr::AddRequest(const SaveStateRequest request) { return SaveStateReturn::SUCCESS; } else { SPDLOG_ERROR("Invalid SaveState slot: {}", request.type); - LUS::Context::GetInstance()->GetWindow()->GetGui()->GetGameOverlay()->TextDrawNotification(1.0f, true, "state slot %u empty", request.slot); + Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGameOverlay()->TextDrawNotification(1.0f, true, "state slot %u empty", request.slot); return SaveStateReturn::FAIL_INVALID_SLOT; } [[unlikely]] default: diff --git a/soh/soh/Enhancements/tts/tts.cpp b/soh/soh/Enhancements/tts/tts.cpp index 3a375230f35..abdcda0eeeb 100644 --- a/soh/soh/Enhancements/tts/tts.cpp +++ b/soh/soh/Enhancements/tts/tts.cpp @@ -1039,22 +1039,22 @@ void InitTTSBank() { break; } - auto initData = std::make_shared(); + auto initData = std::make_shared(); initData->Format = RESOURCE_FORMAT_BINARY; - initData->Type = static_cast(LUS::ResourceType::Json); + initData->Type = static_cast(Ship::ResourceType::Json); initData->ResourceVersion = 0; - sceneMap = std::static_pointer_cast( - LUS::Context::GetInstance()->GetResourceManager()->LoadResource("accessibility/texts/scenes" + languageSuffix, true, initData))->Data; + sceneMap = std::static_pointer_cast( + Ship::Context::GetInstance()->GetResourceManager()->LoadResource("accessibility/texts/scenes" + languageSuffix, true, initData))->Data; - miscMap = std::static_pointer_cast( - LUS::Context::GetInstance()->GetResourceManager()->LoadResource("accessibility/texts/misc" + languageSuffix, true, initData))->Data; + miscMap = std::static_pointer_cast( + Ship::Context::GetInstance()->GetResourceManager()->LoadResource("accessibility/texts/misc" + languageSuffix, true, initData))->Data; - kaleidoMap = std::static_pointer_cast( - LUS::Context::GetInstance()->GetResourceManager()->LoadResource("accessibility/texts/kaleidoscope" + languageSuffix, true, initData))->Data; + kaleidoMap = std::static_pointer_cast( + Ship::Context::GetInstance()->GetResourceManager()->LoadResource("accessibility/texts/kaleidoscope" + languageSuffix, true, initData))->Data; - fileChooseMap = std::static_pointer_cast( - LUS::Context::GetInstance()->GetResourceManager()->LoadResource("accessibility/texts/filechoose" + languageSuffix, true, initData))->Data; + fileChooseMap = std::static_pointer_cast( + Ship::Context::GetInstance()->GetResourceManager()->LoadResource("accessibility/texts/filechoose" + languageSuffix, true, initData))->Data; } void RegisterOnSetGameLanguageHook() { diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index b79b1f9f380..e796d9f961c 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -248,19 +248,19 @@ const char* constCameraStrings[] = { OTRGlobals::OTRGlobals() { std::vector OTRFiles; - std::string mqPath = LUS::Context::LocateFileAcrossAppDirs("oot-mq.otr", appShortName); + std::string mqPath = Ship::Context::LocateFileAcrossAppDirs("oot-mq.otr", appShortName); if (std::filesystem::exists(mqPath)) { OTRFiles.push_back(mqPath); } - std::string ootPath = LUS::Context::LocateFileAcrossAppDirs("oot.otr", appShortName); + std::string ootPath = Ship::Context::LocateFileAcrossAppDirs("oot.otr", appShortName); if (std::filesystem::exists(ootPath)) { OTRFiles.push_back(ootPath); } - std::string sohOtrPath = LUS::Context::GetPathRelativeToAppBundle("soh.otr"); + std::string sohOtrPath = Ship::Context::GetPathRelativeToAppBundle("soh.otr"); if (std::filesystem::exists(sohOtrPath)) { OTRFiles.push_back(sohOtrPath); } - std::string patchesPath = LUS::Context::LocateFileAcrossAppDirs("mods", appShortName); + std::string patchesPath = Ship::Context::LocateFileAcrossAppDirs("mods", appShortName); std::vector patchOTRs = {}; if (patchesPath.length() > 0 && std::filesystem::exists(patchesPath)) { if (std::filesystem::is_directory(patchesPath)) { @@ -302,7 +302,7 @@ OTRGlobals::OTRGlobals() { OOT_PAL_GC_DBG2 }; - context = LUS::Context::CreateUninitializedInstance("Ship of Harkinian", appShortName, "shipofharkinian.json"); + context = Ship::Context::CreateUninitializedInstance("Ship of Harkinian", appShortName, "shipofharkinian.json"); context->InitLogging(); context->InitGfxDebugger(); @@ -378,7 +378,7 @@ OTRGlobals::OTRGlobals() { #if defined(__SWITCH__) SPDLOG_ERROR("Invalid OTR File!"); #elif defined(__WIIU__) - LUS::WiiU::ThrowInvalidOTR(); + Ship::WiiU::ThrowInvalidOTR(); #else SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Invalid OTR File", "Attempted to load an invalid OTR file. Try regenerating.", nullptr); @@ -450,15 +450,15 @@ bool OTRGlobals::HasOriginal() { } uint32_t OTRGlobals::GetInterpolationFPS() { - if (LUS::Context::GetInstance()->GetWindow()->GetWindowBackend() == LUS::WindowBackend::DX11) { + if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::DX11) { return CVarGetInteger("gInterpolationFPS", 20); } if (CVarGetInteger("gMatchRefreshRate", 0)) { - return LUS::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(); + return Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(); } - return std::min(LUS::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(), CVarGetInteger("gInterpolationFPS", 20)); + return std::min(Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(), CVarGetInteger("gInterpolationFPS", 20)); } struct ExtensionEntry { @@ -853,7 +853,7 @@ extern "C" RandomizerGet RetrieveRandomizerGetFromItemID(ItemID itemID) { } extern "C" void OTRExtScanner() { - auto lst = *LUS::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->ListFiles().get(); + auto lst = *Ship::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->ListFiles().get(); for (auto& rPath : lst) { std::vector raw = StringHelper::Split(rPath, "."); @@ -876,13 +876,13 @@ OTRVersion ReadPortVersionFromOTR(std::string otrPath) { OTRVersion version = {}; // Use a temporary archive instance to load the otr and read the version file - auto archive = LUS::OtrArchive(otrPath); + auto archive = Ship::OtrArchive(otrPath); if (archive.Open()) { - auto t = archive.LoadFile("portVersion", std::make_shared()); + auto t = archive.LoadFile("portVersion", std::make_shared()); if (t != nullptr && t->IsLoaded) { - auto stream = std::make_shared(t->Buffer->data(), t->Buffer->size()); - auto reader = std::make_shared(stream); - LUS::Endianness endianness = (LUS::Endianness)reader->ReadUByte(); + auto stream = std::make_shared(t->Buffer->data(), t->Buffer->size()); + auto reader = std::make_shared(stream); + Ship::Endianness endianness = (Ship::Endianness)reader->ReadUByte(); reader->SetEndianness(endianness); version.major = reader->ReadUInt16(); version.minor = reader->ReadUInt16(); @@ -913,7 +913,7 @@ void CheckSoHOTRVersion(std::string otrPath) { Extractor::ShowErrorBox("soh.otr file is missing", msg.c_str()); exit(1); #elif defined(__SWITCH__) - LUS::Switch::PrintErrorMessageToScreen(("\x1b[2;2HYou are missing the soh.otr file." + msg).c_str()); + Ship::Switch::PrintErrorMessageToScreen(("\x1b[2;2HYou are missing the soh.otr file." + msg).c_str()); #elif defined(__WIIU__) OSFatal(("You are missing the soh.otr file\n\n" + msg).c_str()); #endif @@ -926,7 +926,7 @@ void CheckSoHOTRVersion(std::string otrPath) { Extractor::ShowErrorBox("soh.otr file version does not match", msg.c_str()); exit(1); #elif defined(__SWITCH__) - LUS::Switch::PrintErrorMessageToScreen(("\x1b[2;2HYou have an old soh.otr file." + msg).c_str()); + Ship::Switch::PrintErrorMessageToScreen(("\x1b[2;2HYou have an old soh.otr file." + msg).c_str()); #elif defined(__WIIU__) OSFatal(("You have an old soh.otr file\n\n" + msg).c_str()); #endif @@ -937,7 +937,7 @@ void CheckSoHOTRVersion(std::string otrPath) { // For Windows/Mac/Linux if the version doesn't match, offer to void DetectOTRVersion(std::string fileName, bool isMQ) { bool isOtrOld = false; - std::string otrPath = LUS::Context::LocateFileAcrossAppDirs(fileName, appShortName); + std::string otrPath = Ship::Context::LocateFileAcrossAppDirs(fileName, appShortName); // Doesn't exist so nothing to do here if (!std::filesystem::exists(otrPath)) { @@ -967,7 +967,7 @@ void DetectOTRVersion(std::string fileName, bool isMQ) { fileName.c_str(), version); if (Extractor::ShowYesNoBox("Old OTR File Found", msgBuf) == IDYES) { - std::string installPath = LUS::Context::GetAppBundlePath(); + std::string installPath = Ship::Context::GetAppBundlePath(); if (!std::filesystem::exists(installPath + "/assets/extractor")) { Extractor::ShowErrorBox("Extractor assets not found", "Unable to regenerate. Missing assets/extractor folder needed to generate OTR file.\n\nExiting..."); @@ -975,17 +975,17 @@ void DetectOTRVersion(std::string fileName, bool isMQ) { } Extractor extract; - if (!extract.Run(LUS::Context::GetAppDirectoryPath(appShortName), isMQ ? RomSearchMode::MQ : RomSearchMode::Vanilla)) { + if (!extract.Run(Ship::Context::GetAppDirectoryPath(appShortName), isMQ ? RomSearchMode::MQ : RomSearchMode::Vanilla)) { Extractor::ShowErrorBox("Error", "An error occured, no OTR file was generated.\n\nExiting..."); exit(1); } - extract.CallZapd(installPath, LUS::Context::GetAppDirectoryPath(appShortName)); + extract.CallZapd(installPath, Ship::Context::GetAppDirectoryPath(appShortName)); } else { exit(1); } #elif defined(__SWITCH__) - LUS::Switch::PrintErrorMessageToScreen("\x1b[2;2HYou've launched the Ship with an old game OTR file." + Ship::Switch::PrintErrorMessageToScreen("\x1b[2;2HYou've launched the Ship with an old game OTR file." "\x1b[4;2HPlease regenerate a new game OTR and relaunch." "\x1b[6;2HPress the Home button to exit..."); #elif defined(__WIIU__) @@ -1013,9 +1013,9 @@ bool PathTestCleanup(FILE* tfile) { extern "C" void InitOTR() { #ifdef __SWITCH__ - LUS::Switch::Init(LUS::PreInitPhase); + Ship::Switch::Init(Ship::PreInitPhase); #elif defined(__WIIU__) - LUS::WiiU::Init(appShortName); + Ship::WiiU::Init(appShortName); #endif #ifdef _WIN32 @@ -1055,13 +1055,13 @@ extern "C" void InitOTR() { } #endif - CheckSoHOTRVersion(LUS::Context::GetPathRelativeToAppBundle("soh.otr")); + CheckSoHOTRVersion(Ship::Context::GetPathRelativeToAppBundle("soh.otr")); - if (!std::filesystem::exists(LUS::Context::LocateFileAcrossAppDirs("oot-mq.otr", appShortName)) && - !std::filesystem::exists(LUS::Context::LocateFileAcrossAppDirs("oot.otr", appShortName))){ + if (!std::filesystem::exists(Ship::Context::LocateFileAcrossAppDirs("oot-mq.otr", appShortName)) && + !std::filesystem::exists(Ship::Context::LocateFileAcrossAppDirs("oot.otr", appShortName))){ #if not defined(__SWITCH__) && not defined(__WIIU__) - std::string installPath = LUS::Context::GetAppBundlePath(); + std::string installPath = Ship::Context::GetAppBundlePath(); if (!std::filesystem::exists(installPath + "/assets/extractor")) { Extractor::ShowErrorBox("Extractor assets not found", "No OTR files found. Missing assets/extractor folder needed to generate OTR file.\n\nExiting..."); @@ -1071,26 +1071,26 @@ extern "C" void InitOTR() { bool generatedOtrIsMQ = false; if (Extractor::ShowYesNoBox("No OTR Files", "No OTR files found. Generate one now?") == IDYES) { Extractor extract; - if (!extract.Run(LUS::Context::GetAppDirectoryPath(appShortName))) { + if (!extract.Run(Ship::Context::GetAppDirectoryPath(appShortName))) { Extractor::ShowErrorBox("Error", "An error occured, no OTR file was generated.\n\nExiting..."); exit(1); } - extract.CallZapd(installPath, LUS::Context::GetAppDirectoryPath(appShortName)); + extract.CallZapd(installPath, Ship::Context::GetAppDirectoryPath(appShortName)); generatedOtrIsMQ = extract.IsMasterQuest(); } else { exit(1); } if (Extractor::ShowYesNoBox("Extraction Complete", "ROM Extracted. Extract another?") == IDYES) { Extractor extract; - if (!extract.Run(LUS::Context::GetAppDirectoryPath(appShortName), generatedOtrIsMQ ? RomSearchMode::Vanilla : RomSearchMode::MQ)) { + if (!extract.Run(Ship::Context::GetAppDirectoryPath(appShortName), generatedOtrIsMQ ? RomSearchMode::Vanilla : RomSearchMode::MQ)) { Extractor::ShowErrorBox("Error", "An error occured, an OTR file may have been generated by a different step.\n\nContinuing..."); } else { - extract.CallZapd(installPath, LUS::Context::GetAppDirectoryPath(appShortName)); + extract.CallZapd(installPath, Ship::Context::GetAppDirectoryPath(appShortName)); } } #elif defined(__SWITCH__) - LUS::Switch::PrintErrorMessageToScreen("\x1b[2;2HYou've launched the Ship without a game OTR file." + Ship::Switch::PrintErrorMessageToScreen("\x1b[2;2HYou've launched the Ship without a game OTR file." "\x1b[4;2HPlease generate a game OTR and relaunch." "\x1b[6;2HPress the Home button to exit..."); #elif defined(__WIIU__) @@ -1165,9 +1165,9 @@ extern "C" void InitOTR() { } #endif - std::shared_ptr conf = OTRGlobals::Instance->context->GetConfig(); - conf->RegisterConfigVersionUpdater(std::make_shared()); - conf->RegisterConfigVersionUpdater(std::make_shared()); + std::shared_ptr conf = OTRGlobals::Instance->context->GetConfig(); + conf->RegisterConfigVersionUpdater(std::make_shared()); + conf->RegisterConfigVersionUpdater(std::make_shared()); conf->RunVersionUpdates(); } @@ -1245,14 +1245,14 @@ extern bool ToggleAltAssetsAtEndOfFrame; extern "C" void Graph_StartFrame() { #ifndef __WIIU__ - using LUS::KbScancode; + using Ship::KbScancode; int32_t dwScancode = OTRGlobals::Instance->context->GetWindow()->GetLastScancode(); OTRGlobals::Instance->context->GetWindow()->SetLastScancode(-1); switch (dwScancode) { case KbScancode::LUS_KB_F5: { if (CVarGetInteger(CVAR_CHEAT("SaveStatesEnabled"), 0) == 0) { - LUS::Context::GetInstance()->GetWindow()->GetGui()->GetGameOverlay()-> + Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGameOverlay()-> TextDrawNotification(6.0f, true, "Save states not enabled. Check Cheats Menu."); return; } @@ -1274,7 +1274,7 @@ extern "C" void Graph_StartFrame() { } case KbScancode::LUS_KB_F6: { if (CVarGetInteger(CVAR_CHEAT("SaveStatesEnabled"), 0) == 0) { - LUS::Context::GetInstance()->GetWindow()->GetGui()->GetGameOverlay()-> + Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGameOverlay()-> TextDrawNotification(6.0f, true, "Save states not enabled. Check Cheats Menu."); return; } @@ -1289,7 +1289,7 @@ extern "C" void Graph_StartFrame() { } case KbScancode::LUS_KB_F7: { if (CVarGetInteger(CVAR_CHEAT("SaveStatesEnabled"), 0) == 0) { - LUS::Context::GetInstance()->GetWindow()->GetGui()->GetGameOverlay()-> + Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGameOverlay()-> TextDrawNotification(6.0f, true, "Save states not enabled. Check Cheats Menu."); return; } @@ -1431,15 +1431,15 @@ extern "C" uint16_t OTRGetPixelDepth(float x, float y) { } extern "C" uint32_t ResourceMgr_GetNumGameVersions() { - return LUS::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->GetGameVersions().size(); + return Ship::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->GetGameVersions().size(); } extern "C" uint32_t ResourceMgr_GetGameVersion(int index) { - return LUS::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->GetGameVersions()[index]; + return Ship::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->GetGameVersions()[index]; } extern "C" uint32_t ResourceMgr_GetGamePlatform(int index) { - uint32_t version = LUS::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->GetGameVersions()[index]; + uint32_t version = Ship::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->GetGameVersions()[index]; switch (version) { case OOT_NTSC_US_10: @@ -1462,7 +1462,7 @@ extern "C" uint32_t ResourceMgr_GetGamePlatform(int index) { } extern "C" uint32_t ResourceMgr_GetGameRegion(int index) { - uint32_t version = LUS::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->GetGameVersions()[index]; + uint32_t version = Ship::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->GetGameVersions()[index]; switch (version) { case OOT_NTSC_US_10: @@ -1531,10 +1531,10 @@ extern "C" uint32_t ResourceMgr_IsGameMasterQuest() { } extern "C" void ResourceMgr_LoadDirectory(const char* resName) { - LUS::Context::GetInstance()->GetResourceManager()->LoadDirectory(resName); + Ship::Context::GetInstance()->GetResourceManager()->LoadDirectory(resName); } extern "C" void ResourceMgr_DirtyDirectory(const char* resName) { - LUS::Context::GetInstance()->GetResourceManager()->DirtyDirectory(resName); + Ship::Context::GetInstance()->GetResourceManager()->DirtyDirectory(resName); } extern "C" void ResourceMgr_UnloadResource(const char* resName) { @@ -1542,13 +1542,13 @@ extern "C" void ResourceMgr_UnloadResource(const char* resName) { if (path.substr(0, 7) == "__OTR__") { path = path.substr(7); } - auto res = LUS::Context::GetInstance()->GetResourceManager()->UnloadResource(path); + auto res = Ship::Context::GetInstance()->GetResourceManager()->UnloadResource(path); } // OTRTODO: There is probably a more elegant way to go about this... // Kenix: This is definitely leaking memory when it's called. extern "C" char** ResourceMgr_ListFiles(const char* searchMask, int* resultSize) { - auto lst = LUS::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->ListFiles(searchMask); + auto lst = Ship::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->ListFiles(searchMask); char** result = (char**)malloc(lst->size() * sizeof(char*)); for (size_t i = 0; i < lst->size(); i++) { @@ -1592,7 +1592,7 @@ extern "C" void ResourceMgr_UnloadOriginalWhenAltExists(const char* resName) { } } -std::shared_ptr GetResourceByNameHandlingMQ(const char* path) { +std::shared_ptr GetResourceByNameHandlingMQ(const char* path) { std::string Path = path; if (ResourceMgr_IsGameMasterQuest()) { size_t pos = 0; @@ -1600,7 +1600,7 @@ std::shared_ptr GetResourceByNameHandlingMQ(const char* path) { Path.replace(pos, 7, "/mq/"); } } - return LUS::Context::GetInstance()->GetResourceManager()->LoadResource(Path.c_str()); + return Ship::Context::GetInstance()->GetResourceManager()->LoadResource(Path.c_str()); } extern "C" char* GetResourceDataByNameHandlingMQ(const char* path) { @@ -1728,7 +1728,7 @@ std::unordered_map> origi // instead (When that is available). Index can be found using the commented out section below. extern "C" void ResourceMgr_PatchGfxByName(const char* path, const char* patchName, int index, Gfx instruction) { auto res = std::static_pointer_cast( - LUS::Context::GetInstance()->GetResourceManager()->LoadResource(path)); + Ship::Context::GetInstance()->GetResourceManager()->LoadResource(path)); // Leaving this here for people attempting to find the correct Dlist index to patch /*if (strcmp("__OTR__objects/object_gi_longsword/gGiBiggoronSwordDL", path) == 0) { @@ -1767,7 +1767,7 @@ extern "C" void ResourceMgr_PatchGfxByName(const char* path, const char* patchNa extern "C" void ResourceMgr_PatchGfxCopyCommandByName(const char* path, const char* patchName, int destinationIndex, int sourceIndex) { auto res = std::static_pointer_cast( - LUS::Context::GetInstance()->GetResourceManager()->LoadResource(path)); + Ship::Context::GetInstance()->GetResourceManager()->LoadResource(path)); // Do not patch custom assets as they most likely do not have the same instructions as authentic assets if (res->GetInitData()->IsCustom) { @@ -1790,7 +1790,7 @@ extern "C" void ResourceMgr_PatchGfxCopyCommandByName(const char* path, const ch extern "C" void ResourceMgr_UnpatchGfxByName(const char* path, const char* patchName) { if (originalGfx.contains(path) && originalGfx[path].contains(patchName)) { auto res = std::static_pointer_cast( - LUS::Context::GetInstance()->GetResourceManager()->LoadResource(path)); + Ship::Context::GetInstance()->GetResourceManager()->LoadResource(path)); Gfx* gfx = (Gfx*)&res->Instructions[originalGfx[path][patchName].index]; *gfx = originalGfx[path][patchName].instruction; @@ -1850,7 +1850,7 @@ extern "C" SoundFontSample* ReadCustomSample(const char* path) { ExtensionEntry entry = ExtensionCache[path]; - auto sampleRaw = LUS::Context::GetInstance()->GetResourceManager()->LoadFile(entry.path); + auto sampleRaw = Ship::Context::GetInstance()->GetResourceManager()->LoadFile(entry.path); uint32_t* strem = (uint32_t*)sampleRaw->Buffer.get(); uint8_t* strem2 = (uint8_t*)strem; @@ -1941,7 +1941,7 @@ extern "C" SkeletonHeader* ResourceMgr_LoadSkeletonByName(const char* path, Skel bool isAlt = CVarGetInteger("gAltAssets", 0); if (isAlt) { - pathStr = LUS::IResource::gAltAssetPrefix + pathStr; + pathStr = Ship::IResource::gAltAssetPrefix + pathStr; } SkeletonHeader* skelHeader = (SkeletonHeader*) ResourceGetDataByName(pathStr.c_str()); @@ -1975,8 +1975,8 @@ extern "C" s32* ResourceMgr_LoadCSByName(const char* path) { return (s32*)GetResourceDataByNameHandlingMQ(path); } -std::filesystem::path GetSaveFile(std::shared_ptr Conf) { - const std::string fileName = Conf->GetString("Game.SaveName", LUS::Context::GetPathRelativeToAppDirectory("oot_save.sav")); +std::filesystem::path GetSaveFile(std::shared_ptr Conf) { + const std::string fileName = Conf->GetString("Game.SaveName", Ship::Context::GetPathRelativeToAppDirectory("oot_save.sav")); std::filesystem::path saveFile = std::filesystem::absolute(fileName); if (!exists(saveFile.parent_path())) { @@ -1987,13 +1987,13 @@ std::filesystem::path GetSaveFile(std::shared_ptr Conf) { } std::filesystem::path GetSaveFile() { - const std::shared_ptr pConf = OTRGlobals::Instance->context->GetConfig(); + const std::shared_ptr pConf = OTRGlobals::Instance->context->GetConfig(); return GetSaveFile(pConf); } void OTRGlobals::CheckSaveFile(size_t sramSize) const { - const std::shared_ptr pConf = Instance->context->GetConfig(); + const std::shared_ptr pConf = Instance->context->GetConfig(); std::filesystem::path savePath = GetSaveFile(pConf); std::fstream saveFile(savePath, std::fstream::in | std::fstream::out | std::fstream::binary); @@ -2210,19 +2210,19 @@ Color_RGB8 GetColorForControllerLED() { extern "C" void OTRControllerCallback(uint8_t rumble) { // We call this every tick, SDL accounts for this use and prevents driver spam // https://github.com/libsdl-org/SDL/blob/f17058b562c8a1090c0c996b42982721ace90903/src/joystick/SDL_joystick.c#L1114-L1144 - LUS::Context::GetInstance()->GetControlDeck()->GetControllerByPort(0)->GetLED()->SetLEDColor(GetColorForControllerLED()); + Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(0)->GetLED()->SetLEDColor(GetColorForControllerLED()); static std::shared_ptr controllerConfigWindow = nullptr; if (controllerConfigWindow == nullptr) { - controllerConfigWindow = std::dynamic_pointer_cast(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Input Editor")); + controllerConfigWindow = std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Input Editor")); } else if (controllerConfigWindow->TestingRumble()) { return; } if (rumble) { - LUS::Context::GetInstance()->GetControlDeck()->GetControllerByPort(0)->GetRumble()->StartRumble(); + Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(0)->GetRumble()->StartRumble(); } else { - LUS::Context::GetInstance()->GetControlDeck()->GetControllerByPort(0)->GetRumble()->StopRumble(); + Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(0)->GetRumble()->StopRumble(); } } @@ -2262,7 +2262,7 @@ extern "C" void AudioPlayer_Play(const uint8_t* buf, uint32_t len) { } extern "C" int Controller_ShouldRumble(size_t slot) { - for (auto [id, mapping] : LUS::Context::GetInstance() + for (auto [id, mapping] : Ship::Context::GetInstance() ->GetControlDeck() ->GetControllerByPort(static_cast(slot)) ->GetRumble() @@ -2650,12 +2650,12 @@ extern "C" int CustomMessage_RetrieveIfExists(PlayState* play) { } extern "C" void Overlay_DisplayText(float duration, const char* text) { - LUS::Context::GetInstance()->GetWindow()->GetGui()->GetGameOverlay()->TextDrawNotification(duration, true, text); + Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGameOverlay()->TextDrawNotification(duration, true, text); } extern "C" void Overlay_DisplayText_Seconds(int seconds, const char* text) { float duration = seconds * OTRGlobals::Instance->GetInterpolationFPS() * 0.05; - LUS::Context::GetInstance()->GetWindow()->GetGui()->GetGameOverlay()->TextDrawNotification(duration, true, text); + Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGameOverlay()->TextDrawNotification(duration, true, text); } extern "C" void Entrance_ClearEntranceTrackingData(void) { @@ -2741,14 +2741,14 @@ void SoH_ProcessDroppedFiles(std::string filePath) { } } - auto gui = LUS::Context::GetInstance()->GetWindow()->GetGui(); + auto gui = Ship::Context::GetInstance()->GetWindow()->GetGui(); gui->GetGuiWindow("Console")->Hide(); gui->GetGuiWindow("Actor Viewer")->Hide(); gui->GetGuiWindow("Collision Viewer")->Hide(); gui->GetGuiWindow("Save Editor")->Hide(); gui->GetGuiWindow("Display List Viewer")->Hide(); gui->GetGuiWindow("Stats")->Hide(); - std::dynamic_pointer_cast(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Console"))->ClearBindings(); + std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Console"))->ClearBindings(); gui->SaveConsoleVariablesOnNextTick(); @@ -2756,12 +2756,12 @@ void SoH_ProcessDroppedFiles(std::string filePath) { gui->GetGameOverlay()->TextDrawNotification(30.0f, true, "Configuration Loaded. Hash: %d", finalHash); } catch (std::exception& e) { SPDLOG_ERROR("Failed to load config file: {}", e.what()); - auto gui = LUS::Context::GetInstance()->GetWindow()->GetGui(); + auto gui = Ship::Context::GetInstance()->GetWindow()->GetGui(); gui->GetGameOverlay()->TextDrawNotification(30.0f, true, "Failed to load config file"); return; } catch (...) { SPDLOG_ERROR("Failed to load config file"); - auto gui = LUS::Context::GetInstance()->GetWindow()->GetGui(); + auto gui = Ship::Context::GetInstance()->GetWindow()->GetGui(); gui->GetGameOverlay()->TextDrawNotification(30.0f, true, "Failed to load config file"); return; } diff --git a/soh/soh/OTRGlobals.h b/soh/soh/OTRGlobals.h index 49b41ce867a..3a1b3e1f60c 100644 --- a/soh/soh/OTRGlobals.h +++ b/soh/soh/OTRGlobals.h @@ -37,7 +37,7 @@ class OTRGlobals public: static OTRGlobals* Instance; - std::shared_ptr context; + std::shared_ptr context; std::shared_ptr gSaveStateMgr; std::shared_ptr gRandomizer; diff --git a/soh/soh/SaveManager.cpp b/soh/soh/SaveManager.cpp index eadfb75de8a..484a9e1b170 100644 --- a/soh/soh/SaveManager.cpp +++ b/soh/soh/SaveManager.cpp @@ -44,12 +44,12 @@ void SaveManager::ReadSaveFile(std::filesystem::path savePath, uintptr_t addr, v } std::filesystem::path SaveManager::GetFileName(int fileNum) { - const std::filesystem::path sSavePath(LUS::Context::GetPathRelativeToAppDirectory("Save")); + const std::filesystem::path sSavePath(Ship::Context::GetPathRelativeToAppDirectory("Save")); return sSavePath / ("file" + std::to_string(fileNum + 1) + ".sav"); } std::filesystem::path SaveManager::GetFileTempName(int fileNum) { - const std::filesystem::path sSavePath(LUS::Context::GetPathRelativeToAppDirectory("Save")); + const std::filesystem::path sSavePath(Ship::Context::GetPathRelativeToAppDirectory("Save")); return sSavePath / ("file" + std::to_string(fileNum + 1) + ".temp"); } @@ -371,10 +371,10 @@ void SaveManager::SaveRandomizer(SaveContext* saveContext, int sectionID, bool f void SaveManager::Init() { // Wait on saves that snuck through the Wait in OnExitGame ThreadPoolWait(); - const std::filesystem::path sSavePath(LUS::Context::GetPathRelativeToAppDirectory("Save")); + const std::filesystem::path sSavePath(Ship::Context::GetPathRelativeToAppDirectory("Save")); const std::filesystem::path sGlobalPath = sSavePath / std::string("global.sav"); - auto sOldSavePath = LUS::Context::GetPathRelativeToAppDirectory("oot_save.sav"); - auto sOldBackupSavePath = LUS::Context::GetPathRelativeToAppDirectory("oot_save.bak"); + auto sOldSavePath = Ship::Context::GetPathRelativeToAppDirectory("oot_save.sav"); + auto sOldBackupSavePath = Ship::Context::GetPathRelativeToAppDirectory("oot_save.bak"); // If the save directory does not exist, create it if (!std::filesystem::exists(sSavePath)) { @@ -1017,7 +1017,7 @@ void SaveManager::SaveGlobal() { globalBlock["zTargetSetting"] = gSaveContext.zTargetSetting; globalBlock["language"] = gSaveContext.language; - const std::filesystem::path sSavePath(LUS::Context::GetPathRelativeToAppDirectory("Save")); + const std::filesystem::path sSavePath(Ship::Context::GetPathRelativeToAppDirectory("Save")); const std::filesystem::path sGlobalPath = sSavePath / std::string("global.sav"); std::ofstream output(sGlobalPath); @@ -1076,7 +1076,7 @@ void SaveManager::LoadFile(int fileNum) { GameInteractor::Instance->ExecuteHooks(fileNum); } catch (const std::exception& e) { input.close(); - std::filesystem::path newFile(LUS::Context::GetPathRelativeToAppDirectory("Save") + ("/file" + std::to_string(fileNum + 1) + "-" + std::to_string(GetUnixTimestamp()) + ".bak")); + std::filesystem::path newFile(Ship::Context::GetPathRelativeToAppDirectory("Save") + ("/file" + std::to_string(fileNum + 1) + "-" + std::to_string(GetUnixTimestamp()) + ".bak")); #if defined(__SWITCH__) || defined(__WIIU__) copy_file(fileName.c_str(), newFile.c_str()); #else diff --git a/soh/soh/SohGui.cpp b/soh/soh/SohGui.cpp index 28366a6687d..9055087bdab 100644 --- a/soh/soh/SohGui.cpp +++ b/soh/soh/SohGui.cpp @@ -112,9 +112,9 @@ namespace SohGui { std::shared_ptr mSohMenuBar; - std::shared_ptr mConsoleWindow; - std::shared_ptr mStatsWindow; - std::shared_ptr mInputEditorWindow; + std::shared_ptr mConsoleWindow; + std::shared_ptr mStatsWindow; + std::shared_ptr mInputEditorWindow; std::shared_ptr mAudioEditorWindow; std::shared_ptr mInputViewer; @@ -137,10 +137,10 @@ namespace SohGui { std::shared_ptr mModalWindow; void SetupGuiElements() { - auto gui = LUS::Context::GetInstance()->GetWindow()->GetGui(); + auto gui = Ship::Context::GetInstance()->GetWindow()->GetGui(); mSohMenuBar = std::make_shared("gOpenMenuBar", CVarGetInteger("gOpenMenuBar", 0)); - gui->SetMenuBar(std::reinterpret_pointer_cast(mSohMenuBar)); + gui->SetMenuBar(std::reinterpret_pointer_cast(mSohMenuBar)); if (gui->GetMenuBar() && !gui->GetMenuBar()->IsVisible()) { #if defined(__SWITCH__) || defined(__WIIU__) diff --git a/soh/soh/SohMenuBar.cpp b/soh/soh/SohMenuBar.cpp index 20bcc43b816..e7a99b39f6d 100644 --- a/soh/soh/SohMenuBar.cpp +++ b/soh/soh/SohMenuBar.cpp @@ -106,11 +106,11 @@ namespace SohGui { void DrawMenuBarIcon() { static bool gameIconLoaded = false; if (!gameIconLoaded) { - LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Game_Icon", "textures/icons/gIcon.png"); + Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Game_Icon", "textures/icons/gIcon.png"); gameIconLoaded = true; } - if (LUS::Context::GetInstance()->GetWindow()->GetGui()->HasTextureByName("Game_Icon")) { + if (Ship::Context::GetInstance()->GetWindow()->GetGui()->HasTextureByName("Game_Icon")) { #ifdef __SWITCH__ ImVec2 iconSize = ImVec2(20.0f, 20.0f); float posScale = 1.0f; @@ -122,7 +122,7 @@ void DrawMenuBarIcon() { float posScale = 1.0f; #endif ImGui::SetCursorPos(ImVec2(5, 2.5f) * posScale); - ImGui::Image(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Game_Icon"), iconSize); + ImGui::Image(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Game_Icon"), iconSize); ImGui::SameLine(); ImGui::SetCursorPos(ImVec2(25, 0) * posScale); } @@ -137,12 +137,12 @@ void DrawShipMenu() { "[-]" #endif )) { - LUS::Context::GetInstance()->GetWindow()->GetGui()->GetMenuBar()->ToggleVisibility(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->GetMenuBar()->ToggleVisibility(); } UIWidgets::Spacer(0); #if !defined(__SWITCH__) && !defined(__WIIU__) if (ImGui::MenuItem("Toggle Fullscreen", "F11")) { - LUS::Context::GetInstance()->GetWindow()->ToggleFullscreen(); + Ship::Context::GetInstance()->GetWindow()->ToggleFullscreen(); } UIWidgets::Spacer(0); #endif @@ -155,25 +155,25 @@ void DrawShipMenu() { "" #endif )) { - std::reinterpret_pointer_cast(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Console"))->Dispatch("reset"); + std::reinterpret_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Console"))->Dispatch("reset"); } #if !defined(__SWITCH__) && !defined(__WIIU__) UIWidgets::Spacer(0); if (ImGui::MenuItem("Open App Files Folder")) { - std::string filesPath = LUS::Context::GetInstance()->GetAppDirectoryPath(); + std::string filesPath = Ship::Context::GetInstance()->GetAppDirectoryPath(); SDL_OpenURL(std::string("file:///" + std::filesystem::absolute(filesPath).string()).c_str()); } UIWidgets::Spacer(0); if (ImGui::MenuItem("Quit")) { - LUS::Context::GetInstance()->GetWindow()->Close(); + Ship::Context::GetInstance()->GetWindow()->Close(); } #endif ImGui::EndMenu(); } } -extern std::shared_ptr mInputEditorWindow; +extern std::shared_ptr mInputEditorWindow; extern std::shared_ptr mInputViewer; extern std::shared_ptr mInputViewerSettings; extern std::shared_ptr mAdvancedResolutionSettingsWindow; @@ -196,27 +196,27 @@ void DrawSettingsMenu() { Audio_SetGameVolume(SEQ_PLAYER_FANFARE, CVarGetFloat("gFanfareVolume", 1.0f)); } - static std::unordered_map audioBackendNames = { - { LUS::AudioBackend::WASAPI, "Windows Audio Session API" }, - { LUS::AudioBackend::SDL, "SDL" } + static std::unordered_map audioBackendNames = { + { Ship::AudioBackend::WASAPI, "Windows Audio Session API" }, + { Ship::AudioBackend::SDL, "SDL" } }; ImGui::Text("Audio API (Needs reload)"); - auto currentAudioBackend = LUS::Context::GetInstance()->GetAudio()->GetAudioBackend(); + auto currentAudioBackend = Ship::Context::GetInstance()->GetAudio()->GetAudioBackend(); - if (LUS::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size() <= 1) { + if (Ship::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size() <= 1) { UIWidgets::DisableComponent(ImGui::GetStyle().Alpha * 0.5f); } if (ImGui::BeginCombo("##AApi", audioBackendNames[currentAudioBackend])) { - for (uint8_t i = 0; i < LUS::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size(); i++) { - auto backend = LUS::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->data()[i]; + for (uint8_t i = 0; i < Ship::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size(); i++) { + auto backend = Ship::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->data()[i]; if (ImGui::Selectable(audioBackendNames[backend], backend == currentAudioBackend)) { - LUS::Context::GetInstance()->GetAudio()->SetAudioBackend(backend); + Ship::Context::GetInstance()->GetAudio()->SetAudioBackend(backend); } } ImGui::EndCombo(); } - if (LUS::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size() <= 1) { + if (Ship::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size() <= 1) { UIWidgets::ReEnableComponent(""); } @@ -274,7 +274,7 @@ void DrawSettingsMenu() { CVarGetInteger("gAdvancedResolution.Enabled", 0); if (UIWidgets::EnhancementSliderFloat("Internal Resolution: %.1f %%", "##IMul", "gInternalResolution", 0.5f, 2.0f, "", 1.0f, true, true, disabled_resolutionSlider)) { - LUS::Context::GetInstance()->GetWindow()->SetResolutionMultiplier(CVarGetFloat("gInternalResolution", 1)); + Ship::Context::GetInstance()->GetWindow()->SetResolutionMultiplier(CVarGetFloat("gInternalResolution", 1)); } UIWidgets::Tooltip("Resolution scale. Multiplies output resolution by this value, on each axis relative to window size.\n" "Lower values may improve performance.\n" @@ -307,7 +307,7 @@ void DrawSettingsMenu() { if (UIWidgets::PaddedEnhancementSliderInt( (CVarGetInteger("gMSAAValue", 1) == 1) ? "Anti-aliasing (MSAA): Off" : "Anti-aliasing (MSAA): %d", "##IMSAA", "gMSAAValue", 1, 8, "", 1, true, true, false)) { - LUS::Context::GetInstance()->GetWindow()->SetMsaaLevel(CVarGetInteger("gMSAAValue", 1)); + Ship::Context::GetInstance()->GetWindow()->SetMsaaLevel(CVarGetInteger("gMSAAValue", 1)); } UIWidgets::Tooltip("Activates MSAA (multi-sample anti-aliasing) from 2x up to 8x, to smooth the edges of rendered geometry.\n" "Higher sample count will result in smoother edges on models, but may reduce performance.\n\n" @@ -318,10 +318,10 @@ void DrawSettingsMenu() { { // FPS Slider const int minFps = 20; static int maxFps; - if (LUS::Context::GetInstance()->GetWindow()->GetWindowBackend() == LUS::WindowBackend::DX11) { + if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::DX11) { maxFps = 360; } else { - maxFps = LUS::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(); + maxFps = Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(); } int currentFps = fmax(fmin(OTRGlobals::Instance->GetInterpolationFPS(), maxFps), minFps); #ifdef __WIIU__ @@ -383,15 +383,15 @@ void DrawSettingsMenu() { currentFps = 60; } CVarSetInteger("gInterpolationFPS", currentFps); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); #else bool matchingRefreshRate = - CVarGetInteger("gMatchRefreshRate", 0) && LUS::Context::GetInstance()->GetWindow()->GetWindowBackend() != LUS::WindowBackend::DX11; + CVarGetInteger("gMatchRefreshRate", 0) && Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() != Ship::WindowBackend::DX11; UIWidgets::PaddedEnhancementSliderInt( (currentFps == 20) ? "Frame Rate: Original (20 fps)" : "Frame Rate: %d fps", "##FPSInterpolation", "gInterpolationFPS", minFps, maxFps, "", 20, true, true, false, matchingRefreshRate); #endif - if (LUS::Context::GetInstance()->GetWindow()->GetWindowBackend() == LUS::WindowBackend::DX11) { + if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::DX11) { UIWidgets::Tooltip( "Uses Matrix Interpolation to create extra frames, resulting in smoother graphics.\n" "This is purely visual and does not impact game logic, execution of glitches etc.\n" @@ -406,13 +406,13 @@ void DrawSettingsMenu() { } } // END FPS Slider - if (LUS::Context::GetInstance()->GetWindow()->GetWindowBackend() == LUS::WindowBackend::DX11) { + if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::DX11) { UIWidgets::Spacer(0); if (ImGui::Button("Match Frame Rate to Refresh Rate")) { - int hz = LUS::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(); + int hz = Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(); if (hz >= 20 && hz <= 360) { CVarSetInteger("gInterpolationFPS", hz); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } } } else { @@ -420,7 +420,7 @@ void DrawSettingsMenu() { } UIWidgets::Tooltip("Matches interpolation value to the game window's current refresh rate."); - if (LUS::Context::GetInstance()->GetWindow()->GetWindowBackend() == LUS::WindowBackend::DX11) { + if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::DX11) { UIWidgets::PaddedEnhancementSliderInt(CVarGetInteger("gExtraLatencyThreshold", 80) == 0 ? "Jitter fix: Off" : "Jitter fix: >= %d FPS", "##ExtraLatencyThreshold", "gExtraLatencyThreshold", 0, 360, "", 80, true, true, false); UIWidgets::Tooltip( @@ -442,52 +442,52 @@ void DrawSettingsMenu() { UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); - static std::unordered_map windowBackendNames = { - { LUS::WindowBackend::DX11, "DirectX" }, - { LUS::WindowBackend::SDL_OPENGL, "OpenGL"}, - { LUS::WindowBackend::SDL_METAL, "Metal" }, - { LUS::WindowBackend::GX2, "GX2"} + static std::unordered_map windowBackendNames = { + { Ship::WindowBackend::DX11, "DirectX" }, + { Ship::WindowBackend::SDL_OPENGL, "OpenGL"}, + { Ship::WindowBackend::SDL_METAL, "Metal" }, + { Ship::WindowBackend::GX2, "GX2"} }; ImGui::Text("Renderer API (Needs reload)"); - LUS::WindowBackend runningWindowBackend = LUS::Context::GetInstance()->GetWindow()->GetWindowBackend(); - LUS::WindowBackend configWindowBackend; - int configWindowBackendId = LUS::Context::GetInstance()->GetConfig()->GetInt("Window.Backend.Id", -1); - if (configWindowBackendId != -1 && configWindowBackendId < static_cast(LUS::WindowBackend::BACKEND_COUNT)) { - configWindowBackend = static_cast(configWindowBackendId); + Ship::WindowBackend runningWindowBackend = Ship::Context::GetInstance()->GetWindow()->GetWindowBackend(); + Ship::WindowBackend configWindowBackend; + int configWindowBackendId = Ship::Context::GetInstance()->GetConfig()->GetInt("Window.Backend.Id", -1); + if (configWindowBackendId != -1 && configWindowBackendId < static_cast(Ship::WindowBackend::BACKEND_COUNT)) { + configWindowBackend = static_cast(configWindowBackendId); } else { configWindowBackend = runningWindowBackend; } - if (LUS::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends()->size() <= 1) { + if (Ship::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends()->size() <= 1) { UIWidgets::DisableComponent(ImGui::GetStyle().Alpha * 0.5f); } if (ImGui::BeginCombo("##RApi", windowBackendNames[configWindowBackend])) { - for (size_t i = 0; i < LUS::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends()->size(); i++) { - auto backend = LUS::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends()->data()[i]; + for (size_t i = 0; i < Ship::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends()->size(); i++) { + auto backend = Ship::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends()->data()[i]; if (ImGui::Selectable(windowBackendNames[backend], backend == configWindowBackend)) { - LUS::Context::GetInstance()->GetConfig()->SetInt("Window.Backend.Id", static_cast(backend)); - LUS::Context::GetInstance()->GetConfig()->SetString("Window.Backend.Name", + Ship::Context::GetInstance()->GetConfig()->SetInt("Window.Backend.Id", static_cast(backend)); + Ship::Context::GetInstance()->GetConfig()->SetString("Window.Backend.Name", windowBackendNames[backend]); - LUS::Context::GetInstance()->GetConfig()->Save(); + Ship::Context::GetInstance()->GetConfig()->Save(); } } ImGui::EndCombo(); } - if (LUS::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends()->size() <= 1) { + if (Ship::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends()->size() <= 1) { UIWidgets::ReEnableComponent(""); } - if (LUS::Context::GetInstance()->GetWindow()->CanDisableVerticalSync()) { + if (Ship::Context::GetInstance()->GetWindow()->CanDisableVerticalSync()) { UIWidgets::PaddedEnhancementCheckbox("Enable Vsync", "gVsyncEnabled", true, false); UIWidgets::Tooltip("Activate vertical sync, to prevent screen tearing."); } - if (LUS::Context::GetInstance()->GetWindow()->SupportsWindowedFullscreen()) { + if (Ship::Context::GetInstance()->GetWindow()->SupportsWindowedFullscreen()) { UIWidgets::PaddedEnhancementCheckbox("Windowed fullscreen", "gSdlWindowedFullscreen", true, false); } - if (LUS::Context::GetInstance()->GetWindow()->GetGui()->SupportsViewports()) { + if (Ship::Context::GetInstance()->GetWindow()->GetGui()->SupportsViewports()) { UIWidgets::PaddedEnhancementCheckbox("Allow multi-windows (Needs reload)", "gEnableMultiViewports", true, false, false, "", UIWidgets::CheckboxGraphics::Cross, true); UIWidgets::Tooltip("Allows windows to be able to be dragged off of the main game window. Requires a reload to take effect."); } @@ -503,7 +503,7 @@ void DrawSettingsMenu() { UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); // Draw LUS settings menu (such as Overlays Text Font) - LUS::Context::GetInstance()->GetWindow()->GetGui()->GetGameOverlay()->DrawSettings(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGameOverlay()->DrawSettings(); ImGui::EndMenu(); } @@ -1417,9 +1417,9 @@ void DrawEnhancementsMenu() { #ifdef __SWITCH__ UIWidgets::Spacer(0); ImGui::Text("Switch performance mode"); - if (UIWidgets::EnhancementCombobox(CVAR_ENHANCEMENT("SwitchPerfMode"), SWITCH_CPU_PROFILES, (int)LUS::SwitchProfiles::STOCK)) { - SPDLOG_INFO("Profile:: %s", SWITCH_CPU_PROFILES[CVarGetInteger(CVAR_ENHANCEMENT("SwitchPerfMode"), (int)LUS::SwitchProfiles::STOCK)]); - LUS::Switch::ApplyOverclock(); + if (UIWidgets::EnhancementCombobox(CVAR_ENHANCEMENT("SwitchPerfMode"), SWITCH_CPU_PROFILES, (int)Ship::SwitchProfiles::STOCK)) { + SPDLOG_INFO("Profile:: %s", SWITCH_CPU_PROFILES[CVarGetInteger(CVAR_ENHANCEMENT("SwitchPerfMode"), (int)Ship::SwitchProfiles::STOCK)]); + Ship::Switch::ApplyOverclock(); } #endif @@ -1504,7 +1504,7 @@ void DrawCheatsMenu() { if (UIWidgets::PaddedEnhancementCheckbox("I promise I have read the warning", CVAR_CHEAT("SaveStatePromise"), true, false)) { CVarSetInteger(CVAR_CHEAT("SaveStatesEnabled"), 0); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } if (CVarGetInteger(CVAR_CHEAT("SaveStatePromise"), 0) == 1) { UIWidgets::PaddedEnhancementCheckbox("I understand, enable save states", CVAR_CHEAT("SaveStatesEnabled"), true, @@ -1598,8 +1598,8 @@ void DrawCheatsMenu() { CVarSetInteger(CVAR_CHEAT("EnableBetaQuest"), betaQuestEnabled); CVarSetInteger(CVAR_CHEAT("BetaQuestWorld"), betaQuestWorld); - std::reinterpret_pointer_cast(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Console"))->Dispatch("reset"); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + std::reinterpret_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Console"))->Dispatch("reset"); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } if (!isBetaQuestEnabled) { @@ -1613,8 +1613,8 @@ void DrawCheatsMenu() { } } -extern std::shared_ptr mStatsWindow; -extern std::shared_ptr mConsoleWindow; +extern std::shared_ptr mStatsWindow; +extern std::shared_ptr mConsoleWindow; extern std::shared_ptr mSaveEditorWindow; extern std::shared_ptr mColViewerWindow; extern std::shared_ptr mActorViewerWindow; @@ -1772,7 +1772,7 @@ void DrawRemoteControlMenu() { port = 43384; break; } - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } switch (CVarGetInteger(CVAR_REMOTE("Scheme"), GI_SCHEME_SAIL)) { case GI_SCHEME_SAIL: @@ -1808,14 +1808,14 @@ void DrawRemoteControlMenu() { ImGui::Text("Remote IP & Port"); if (ImGui::InputText("##gRemote.IP", (char*)ip.c_str(), ip.capacity() + 1)) { CVarSetString(CVAR_REMOTE("IP"), ip.c_str()); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } ImGui::SameLine(); ImGui::PushItemWidth(ImGui::GetFontSize() * 5); if (ImGui::InputScalar("##gRemote.Port", ImGuiDataType_U16, &port)) { CVarSetInteger(CVAR_REMOTE("Port"), port); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } ImGui::PopItemWidth(); @@ -1828,7 +1828,7 @@ void DrawRemoteControlMenu() { if (ImGui::Button(buttonLabel, ImVec2(-1.0f, 0.0f))) { if (GameInteractor::Instance->isRemoteInteractorEnabled) { CVarSetInteger(CVAR_REMOTE("Enabled"), 0); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); switch (CVarGetInteger(CVAR_REMOTE("Scheme"), GI_SCHEME_SAIL)) { case GI_SCHEME_SAIL: GameInteractorSail::Instance->Disable(); @@ -1839,7 +1839,7 @@ void DrawRemoteControlMenu() { } } else { CVarSetInteger(CVAR_REMOTE("Enabled"), 1); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); switch (CVarGetInteger(CVAR_REMOTE("Scheme"), GI_SCHEME_SAIL)) { case GI_SCHEME_SAIL: GameInteractorSail::Instance->Enable(); diff --git a/soh/soh/SohMenuBar.h b/soh/soh/SohMenuBar.h index ce62344addf..99fb8a0ae16 100644 --- a/soh/soh/SohMenuBar.h +++ b/soh/soh/SohMenuBar.h @@ -5,9 +5,9 @@ #include "window/gui/GuiElement.h" namespace SohGui { -class SohMenuBar : public LUS::GuiMenuBar { +class SohMenuBar : public Ship::GuiMenuBar { public: - using LUS::GuiMenuBar::GuiMenuBar; + using Ship::GuiMenuBar::GuiMenuBar; protected: void DrawElement() override; void InitElement() override {}; diff --git a/soh/soh/SohModals.h b/soh/soh/SohModals.h index 6f5acb2c0be..b64e180b688 100644 --- a/soh/soh/SohModals.h +++ b/soh/soh/SohModals.h @@ -4,9 +4,9 @@ #include "window/gui/GuiMenuBar.h" #include "window/gui/GuiElement.h" -class SohModalWindow : public LUS::GuiWindow { +class SohModalWindow : public Ship::GuiWindow { public: - using LUS::GuiWindow::GuiWindow; + using GuiWindow::GuiWindow; void InitElement() override {}; void DrawElement() override; diff --git a/soh/soh/UIWidgets.cpp b/soh/soh/UIWidgets.cpp index 4817e85fc00..5bf2e7b7329 100644 --- a/soh/soh/UIWidgets.cpp +++ b/soh/soh/UIWidgets.cpp @@ -208,7 +208,7 @@ namespace UIWidgets { bool val = (bool)CVarGetInteger(cvarName, defaultValue); if (CustomCheckbox(text, &val, disabled, disabledGraphic)) { CVarSetInteger(cvarName, val); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); changed = true; } @@ -248,7 +248,7 @@ namespace UIWidgets { CVarSetInteger(cvarName, i); selected = i; changed = true; - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } } } @@ -261,7 +261,7 @@ namespace UIWidgets { if (disabledValue >= 0 && selected != disabledValue) { CVarSetInteger(cvarName, disabledValue); changed = true; - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } } @@ -351,7 +351,7 @@ namespace UIWidgets { if (changed && (oldVal != val)) { CVarSetInteger(cvarName, val); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } else { changed = false; } @@ -452,7 +452,7 @@ namespace UIWidgets { ss << std::setprecision(ticks + 1) << std::setiosflags(std::ios_base::fixed) << val; val = std::stof(ss.str()); CVarSetFloat(cvarName, val); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } else { changed = false; } @@ -501,7 +501,7 @@ namespace UIWidgets { int val = CVarGetInteger(cvarName, 0); if (ImGui::RadioButton(make_invisible.c_str(), id == val)) { CVarSetInteger(cvarName, id); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); ret = true; } ImGui::SameLine(); @@ -528,7 +528,7 @@ namespace UIWidgets { CVarSetColor(cvarName, colorsRGBA); CVarSetInteger(Cvar_RBM.c_str(), 0); //On click disable rainbow mode. - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); changed = true; } Tooltip("Revert colors to the game's original colors (GameCube version)\nOverwrites previously chosen color"); @@ -553,7 +553,7 @@ namespace UIWidgets { NewColors.b = fmin(fmax(colors->z * 255, 0), 255); CVarSetColor(cvarName, NewColors); CVarSetInteger(Cvar_RBM.c_str(), 0); // On click disable rainbow mode. - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); changed = true; } Tooltip("Chooses a random color\nOverwrites previously chosen color"); @@ -614,7 +614,7 @@ namespace UIWidgets { colors.a = 255.0; CVarSetColor(cvarName, colors); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); changed = true; } } @@ -630,7 +630,7 @@ namespace UIWidgets { colors.a = ColorRGBA.w * 255.0; CVarSetColor(cvarName, colors); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); changed = true; } } diff --git a/soh/soh/config/ConfigUpdaters.cpp b/soh/soh/config/ConfigUpdaters.cpp index 1951e78e158..994505dd676 100644 --- a/soh/soh/config/ConfigUpdaters.cpp +++ b/soh/soh/config/ConfigUpdaters.cpp @@ -1,11 +1,11 @@ #include "ConfigUpdaters.h" #include "soh/Enhancements/audio/AudioCollection.h" -namespace LUS { +namespace SOH { ConfigVersion1Updater::ConfigVersion1Updater() : ConfigVersionUpdater(1) {} ConfigVersion2Updater::ConfigVersion2Updater() : ConfigVersionUpdater(2) {} - void ConfigVersion1Updater::Update(Config* conf) { + void ConfigVersion1Updater::Update(Ship::Config* conf) { if (conf->GetInt("Window.Width", 640) == 640) { conf->Erase("Window.Width"); } @@ -36,10 +36,10 @@ namespace LUS { if (conf->GetInt("Window.Fullscreen.Height", 1080) == 1080) { conf->Erase("Window.Fullscreen.Height"); } - if (conf->GetInt("Shortcuts.Fullscreen", KbScancode::LUS_KB_F11) == KbScancode::LUS_KB_F10) { + if (conf->GetInt("Shortcuts.Fullscreen", Ship::KbScancode::LUS_KB_F11) == Ship::KbScancode::LUS_KB_F10) { conf->Erase("Shortcuts.Fullscreen"); } - if (conf->GetInt("Shortcuts.Console", KbScancode::LUS_KB_OEM_3) == KbScancode::LUS_KB_OEM_3) { + if (conf->GetInt("Shortcuts.Console", Ship::KbScancode::LUS_KB_OEM_3) == Ship::KbScancode::LUS_KB_OEM_3) { conf->Erase("Shortcuts.Console"); } if (conf->GetString("Game.SaveName", "") == "") { @@ -63,7 +63,7 @@ namespace LUS { CVarClear("gSeededRandomizedEnemies"); } - void ConfigVersion2Updater::Update(Config* conf) { + void ConfigVersion2Updater::Update(Ship::Config* conf) { for (auto seq : AudioCollection::Instance->GetAllSequences()) { CVarClear(std::string("gAudioEditor.ReplacedSequences." + seq.second.sfxKey).c_str()); } diff --git a/soh/soh/config/ConfigUpdaters.h b/soh/soh/config/ConfigUpdaters.h index cc8f6109a93..4c9234476b2 100644 --- a/soh/soh/config/ConfigUpdaters.h +++ b/soh/soh/config/ConfigUpdaters.h @@ -1,15 +1,15 @@ #include "libultraship/libultraship.h" -namespace LUS { - class ConfigVersion1Updater : public ConfigVersionUpdater { +namespace SOH { + class ConfigVersion1Updater : public Ship::ConfigVersionUpdater { public: ConfigVersion1Updater(); - void Update(Config* conf); + void Update(Ship::Config* conf); }; - class ConfigVersion2Updater : public ConfigVersionUpdater { + class ConfigVersion2Updater : public Ship::ConfigVersionUpdater { public: ConfigVersion2Updater(); - void Update(Config* conf); + void Update(Ship::Config* conf); }; } \ No newline at end of file diff --git a/soh/soh/resource/importer/AnimationFactory.cpp b/soh/soh/resource/importer/AnimationFactory.cpp index 8e1aca9b752..13aa71c86aa 100644 --- a/soh/soh/resource/importer/AnimationFactory.cpp +++ b/soh/soh/resource/importer/AnimationFactory.cpp @@ -3,13 +3,13 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr ResourceFactoryBinaryAnimationV0::ReadResource(std::shared_ptr file) { +std::shared_ptr ResourceFactoryBinaryAnimationV0::ReadResource(std::shared_ptr file) { if (!FileHasValidFormatAndReader(file)) { return nullptr; } auto animation = std::make_shared(file->InitData); - auto reader = std::get>(file->Reader); + auto reader = std::get>(file->Reader); AnimationType animType = (AnimationType)reader->ReadUInt32(); animation->type = animType; diff --git a/soh/soh/resource/importer/AnimationFactory.h b/soh/soh/resource/importer/AnimationFactory.h index 36dfceaae2a..ae27832b6a2 100644 --- a/soh/soh/resource/importer/AnimationFactory.h +++ b/soh/soh/resource/importer/AnimationFactory.h @@ -4,8 +4,8 @@ #include "ResourceFactoryBinary.h" namespace SOH { -class ResourceFactoryBinaryAnimationV0 : public LUS::ResourceFactoryBinary { +class ResourceFactoryBinaryAnimationV0 : public Ship::ResourceFactoryBinary { public: - std::shared_ptr ReadResource(std::shared_ptr file) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; } // namespace SOH diff --git a/soh/soh/resource/importer/AudioSampleFactory.cpp b/soh/soh/resource/importer/AudioSampleFactory.cpp index b45e698e537..0ec3f526018 100644 --- a/soh/soh/resource/importer/AudioSampleFactory.cpp +++ b/soh/soh/resource/importer/AudioSampleFactory.cpp @@ -3,13 +3,13 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr ResourceFactoryBinaryAudioSampleV2::ReadResource(std::shared_ptr file) { +std::shared_ptr ResourceFactoryBinaryAudioSampleV2::ReadResource(std::shared_ptr file) { if (!FileHasValidFormatAndReader(file)) { return nullptr; } auto audioSample = std::make_shared(file->InitData); - auto reader = std::get>(file->Reader); + auto reader = std::get>(file->Reader); audioSample->sample.codec = reader->ReadUByte(); audioSample->sample.medium = reader->ReadUByte(); @@ -71,7 +71,7 @@ extern "C" SoundFontSample* ReadCustomSample(const char* path) { ExtensionEntry entry = ExtensionCache[path]; - auto sampleRaw = LUS::Context::GetInstance()->GetResourceManager()->LoadFile(entry.path); + auto sampleRaw = Ship::Context::GetInstance()->GetResourceManager()->LoadFile(entry.path); uint32_t* strem = (uint32_t*)sampleRaw->Buffer.get(); uint8_t* strem2 = (uint8_t*)strem; diff --git a/soh/soh/resource/importer/AudioSampleFactory.h b/soh/soh/resource/importer/AudioSampleFactory.h index 2680ccdc2a0..372e8a31041 100644 --- a/soh/soh/resource/importer/AudioSampleFactory.h +++ b/soh/soh/resource/importer/AudioSampleFactory.h @@ -4,8 +4,8 @@ #include "ResourceFactoryBinary.h" namespace SOH { -class ResourceFactoryBinaryAudioSampleV2 : public LUS::ResourceFactoryBinary { +class ResourceFactoryBinaryAudioSampleV2 : public Ship::ResourceFactoryBinary { public: - std::shared_ptr ReadResource(std::shared_ptr file) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; } // namespace SOH diff --git a/soh/soh/resource/importer/AudioSequenceFactory.cpp b/soh/soh/resource/importer/AudioSequenceFactory.cpp index ba2a36697a5..35da7f798db 100644 --- a/soh/soh/resource/importer/AudioSequenceFactory.cpp +++ b/soh/soh/resource/importer/AudioSequenceFactory.cpp @@ -3,13 +3,13 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr ResourceFactoryBinaryAudioSequenceV2::ReadResource(std::shared_ptr file) { +std::shared_ptr ResourceFactoryBinaryAudioSequenceV2::ReadResource(std::shared_ptr file) { if (!FileHasValidFormatAndReader(file)) { return nullptr; } auto audioSequence = std::make_shared(file->InitData); - auto reader = std::get>(file->Reader); + auto reader = std::get>(file->Reader); audioSequence->sequence.seqDataSize = reader->ReadInt32(); audioSequence->sequenceData.reserve(audioSequence->sequence.seqDataSize); diff --git a/soh/soh/resource/importer/AudioSequenceFactory.h b/soh/soh/resource/importer/AudioSequenceFactory.h index fb4391d6174..35fd1ebef54 100644 --- a/soh/soh/resource/importer/AudioSequenceFactory.h +++ b/soh/soh/resource/importer/AudioSequenceFactory.h @@ -4,8 +4,8 @@ #include "ResourceFactoryBinary.h" namespace SOH { -class ResourceFactoryBinaryAudioSequenceV2 : public LUS::ResourceFactoryBinary { +class ResourceFactoryBinaryAudioSequenceV2 : public Ship::ResourceFactoryBinary { public: - std::shared_ptr ReadResource(std::shared_ptr file) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; } // namespace SOH diff --git a/soh/soh/resource/importer/AudioSoundFontFactory.cpp b/soh/soh/resource/importer/AudioSoundFontFactory.cpp index 6d7efc58ccf..534a7914c85 100644 --- a/soh/soh/resource/importer/AudioSoundFontFactory.cpp +++ b/soh/soh/resource/importer/AudioSoundFontFactory.cpp @@ -4,13 +4,13 @@ #include "libultraship/libultraship.h" namespace SOH { -std::shared_ptr ResourceFactoryBinaryAudioSoundFontV2::ReadResource(std::shared_ptr file) { +std::shared_ptr ResourceFactoryBinaryAudioSoundFontV2::ReadResource(std::shared_ptr file) { if (!FileHasValidFormatAndReader(file)) { return nullptr; } auto audioSoundFont = std::make_shared(file->InitData); - auto reader = std::get>(file->Reader); + auto reader = std::get>(file->Reader); audioSoundFont->soundFont.fntIndex = reader->ReadInt32(); audioSoundFont->medium = reader->ReadInt8(); @@ -67,7 +67,7 @@ std::shared_ptr ResourceFactoryBinaryAudioSoundFontV2::ReadResou if (sampleFileName.empty()) { drum.sound.sample = nullptr; } else { - auto res = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(sampleFileName.c_str()); + auto res = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(sampleFileName.c_str()); drum.sound.sample = static_cast(res ? res->GetRawPointer() : nullptr); } @@ -111,7 +111,7 @@ std::shared_ptr ResourceFactoryBinaryAudioSoundFontV2::ReadResou bool hasSampleRef = reader->ReadInt8(); std::string sampleFileName = reader->ReadString(); instrument.lowNotesSound.tuning = reader->ReadFloat(); - auto res = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(sampleFileName.c_str()); + auto res = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(sampleFileName.c_str()); instrument.lowNotesSound.sample = static_cast(res ? res->GetRawPointer() : nullptr); } else { instrument.lowNotesSound.sample = nullptr; @@ -123,7 +123,7 @@ std::shared_ptr ResourceFactoryBinaryAudioSoundFontV2::ReadResou bool hasSampleRef = reader->ReadInt8(); std::string sampleFileName = reader->ReadString(); instrument.normalNotesSound.tuning = reader->ReadFloat(); - auto res = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(sampleFileName.c_str()); + auto res = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(sampleFileName.c_str()); instrument.normalNotesSound.sample = static_cast(res ? res->GetRawPointer() : nullptr); } else { instrument.normalNotesSound.sample = nullptr; @@ -135,7 +135,7 @@ std::shared_ptr ResourceFactoryBinaryAudioSoundFontV2::ReadResou bool hasSampleRef = reader->ReadInt8(); std::string sampleFileName = reader->ReadString(); instrument.highNotesSound.tuning = reader->ReadFloat(); - auto res = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(sampleFileName.c_str()); + auto res = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(sampleFileName.c_str()); instrument.highNotesSound.sample = static_cast(res ? res->GetRawPointer() : nullptr); } else { instrument.highNotesSound.sample = nullptr; @@ -160,7 +160,7 @@ std::shared_ptr ResourceFactoryBinaryAudioSoundFontV2::ReadResou bool hasSampleRef = reader->ReadInt8(); std::string sampleFileName = reader->ReadString(); soundEffect.tuning = reader->ReadFloat(); - auto res = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(sampleFileName.c_str()); + auto res = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(sampleFileName.c_str()); soundEffect.sample = static_cast(res ? res->GetRawPointer() : nullptr); } diff --git a/soh/soh/resource/importer/AudioSoundFontFactory.h b/soh/soh/resource/importer/AudioSoundFontFactory.h index a63533db90f..a80b8fe9726 100644 --- a/soh/soh/resource/importer/AudioSoundFontFactory.h +++ b/soh/soh/resource/importer/AudioSoundFontFactory.h @@ -4,8 +4,8 @@ #include "ResourceFactoryBinary.h" namespace SOH { -class ResourceFactoryBinaryAudioSoundFontV2 : public LUS::ResourceFactoryBinary { +class ResourceFactoryBinaryAudioSoundFontV2 : public Ship::ResourceFactoryBinary { public: - std::shared_ptr ReadResource(std::shared_ptr file) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; } // namespace SOH diff --git a/soh/soh/resource/importer/BackgroundFactory.cpp b/soh/soh/resource/importer/BackgroundFactory.cpp index 07c47cbe9c9..6be48469827 100644 --- a/soh/soh/resource/importer/BackgroundFactory.cpp +++ b/soh/soh/resource/importer/BackgroundFactory.cpp @@ -3,13 +3,13 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr ResourceFactoryBinaryBackgroundV0::ReadResource(std::shared_ptr file) { +std::shared_ptr ResourceFactoryBinaryBackgroundV0::ReadResource(std::shared_ptr file) { if (!FileHasValidFormatAndReader(file)) { return nullptr; } auto background = std::make_shared(file->InitData); - auto reader = std::get>(file->Reader); + auto reader = std::get>(file->Reader); uint32_t dataSize = reader->ReadUInt32(); diff --git a/soh/soh/resource/importer/BackgroundFactory.h b/soh/soh/resource/importer/BackgroundFactory.h index 787ee509cf4..e74e897e9de 100644 --- a/soh/soh/resource/importer/BackgroundFactory.h +++ b/soh/soh/resource/importer/BackgroundFactory.h @@ -4,8 +4,8 @@ #include "resource/ResourceFactoryBinary.h" namespace SOH { -class ResourceFactoryBinaryBackgroundV0 : public LUS::ResourceFactoryBinary { +class ResourceFactoryBinaryBackgroundV0 : public Ship::ResourceFactoryBinary { public: - std::shared_ptr ReadResource(std::shared_ptr file) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; } // namespace SOH diff --git a/soh/soh/resource/importer/CollisionHeaderFactory.cpp b/soh/soh/resource/importer/CollisionHeaderFactory.cpp index c5372f24967..4636d80c768 100644 --- a/soh/soh/resource/importer/CollisionHeaderFactory.cpp +++ b/soh/soh/resource/importer/CollisionHeaderFactory.cpp @@ -3,13 +3,13 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr ResourceFactoryBinaryCollisionHeaderV0::ReadResource(std::shared_ptr file) { +std::shared_ptr ResourceFactoryBinaryCollisionHeaderV0::ReadResource(std::shared_ptr file) { if (!FileHasValidFormatAndReader(file)) { return nullptr; } auto collisionHeader = std::make_shared(file->InitData); - auto reader = std::get>(file->Reader); + auto reader = std::get>(file->Reader); collisionHeader->collisionHeaderData.minBounds.x = reader->ReadInt16(); collisionHeader->collisionHeaderData.minBounds.y = reader->ReadInt16(); @@ -123,7 +123,7 @@ std::shared_ptr ResourceFactoryBinaryCollisionHeaderV0::ReadReso return collisionHeader; } -std::shared_ptr ResourceFactoryXMLCollisionHeaderV0::ReadResource(std::shared_ptr file) { +std::shared_ptr ResourceFactoryXMLCollisionHeaderV0::ReadResource(std::shared_ptr file) { if (!FileHasValidFormatAndReader(file)) { return nullptr; } diff --git a/soh/soh/resource/importer/CollisionHeaderFactory.h b/soh/soh/resource/importer/CollisionHeaderFactory.h index abd87890996..dd438f9c35a 100644 --- a/soh/soh/resource/importer/CollisionHeaderFactory.h +++ b/soh/soh/resource/importer/CollisionHeaderFactory.h @@ -5,13 +5,13 @@ #include "ResourceFactoryXML.h" namespace SOH { -class ResourceFactoryBinaryCollisionHeaderV0 : public LUS::ResourceFactoryBinary { +class ResourceFactoryBinaryCollisionHeaderV0 : public Ship::ResourceFactoryBinary { public: - std::shared_ptr ReadResource(std::shared_ptr file) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; -class ResourceFactoryXMLCollisionHeaderV0 : public LUS::ResourceFactoryXML { +class ResourceFactoryXMLCollisionHeaderV0 : public Ship::ResourceFactoryXML { public: - std::shared_ptr ReadResource(std::shared_ptr file) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; } // namespace SOH diff --git a/soh/soh/resource/importer/CutsceneFactory.cpp b/soh/soh/resource/importer/CutsceneFactory.cpp index 28f5e642bcc..49e44680ce4 100644 --- a/soh/soh/resource/importer/CutsceneFactory.cpp +++ b/soh/soh/resource/importer/CutsceneFactory.cpp @@ -2,19 +2,19 @@ #include "soh/resource/type/Cutscene.h" #include "spdlog/spdlog.h" -static inline uint32_t read_CMD_BBBB(std::shared_ptr reader) { +static inline uint32_t read_CMD_BBBB(std::shared_ptr reader) { uint32_t v; reader->Read((char*)&v, sizeof(uint32_t)); return v; } -static inline uint32_t read_CMD_BBH(std::shared_ptr reader) { +static inline uint32_t read_CMD_BBH(std::shared_ptr reader) { uint32_t v; reader->Read((char*)&v, sizeof(uint32_t)); // swap the half word to match endianness - if (reader->GetEndianness() != LUS::Endianness::Native) { + if (reader->GetEndianness() != Ship::Endianness::Native) { uint8_t* b = (uint8_t*)&v; uint8_t tmp = b[2]; b[2] = b[3]; @@ -24,12 +24,12 @@ static inline uint32_t read_CMD_BBH(std::shared_ptr reader) { return v; } -static inline uint32_t read_CMD_HBB(std::shared_ptr reader) { +static inline uint32_t read_CMD_HBB(std::shared_ptr reader) { uint32_t v; reader->Read((char*)&v, sizeof(uint32_t)); // swap the half word to match endianness - if (reader->GetEndianness() != LUS::Endianness::Native) { + if (reader->GetEndianness() != Ship::Endianness::Native) { uint8_t* b = (uint8_t*)&v; uint8_t tmp = b[0]; b[0] = b[1]; @@ -39,12 +39,12 @@ static inline uint32_t read_CMD_HBB(std::shared_ptr reader) { return v; } -static inline uint32_t read_CMD_HH(std::shared_ptr reader) { +static inline uint32_t read_CMD_HH(std::shared_ptr reader) { uint32_t v; reader->Read((char*)&v, sizeof(uint32_t)); // swap the half words to match endianness - if (reader->GetEndianness() != LUS::Endianness::Native) { + if (reader->GetEndianness() != Ship::Endianness::Native) { uint8_t* b = (uint8_t*)&v; uint8_t tmp = b[0]; b[0] = b[1]; @@ -58,13 +58,13 @@ static inline uint32_t read_CMD_HH(std::shared_ptr reader) { } namespace SOH { -std::shared_ptr ResourceFactoryBinaryCutsceneV0::ReadResource(std::shared_ptr file) { +std::shared_ptr ResourceFactoryBinaryCutsceneV0::ReadResource(std::shared_ptr file) { if (!FileHasValidFormatAndReader(file)) { return nullptr; } auto cutscene = std::make_shared(file->InitData); - auto reader = std::get>(file->Reader); + auto reader = std::get>(file->Reader); uint32_t numEntries = reader->ReadUInt32(); cutscene->commands.reserve(numEntries); diff --git a/soh/soh/resource/importer/CutsceneFactory.h b/soh/soh/resource/importer/CutsceneFactory.h index 8194615afe3..8afe98bb8a9 100644 --- a/soh/soh/resource/importer/CutsceneFactory.h +++ b/soh/soh/resource/importer/CutsceneFactory.h @@ -4,8 +4,8 @@ #include "ResourceFactoryBinary.h" namespace SOH { -class ResourceFactoryBinaryCutsceneV0 : public LUS::ResourceFactoryBinary { +class ResourceFactoryBinaryCutsceneV0 : public Ship::ResourceFactoryBinary { public: - std::shared_ptr ReadResource(std::shared_ptr file) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; } // namespace SOH diff --git a/soh/soh/resource/importer/PathFactory.cpp b/soh/soh/resource/importer/PathFactory.cpp index 07fc86f4095..00807b75afa 100644 --- a/soh/soh/resource/importer/PathFactory.cpp +++ b/soh/soh/resource/importer/PathFactory.cpp @@ -3,13 +3,13 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr ResourceFactoryBinaryPathV0::ReadResource(std::shared_ptr file) { +std::shared_ptr ResourceFactoryBinaryPathV0::ReadResource(std::shared_ptr file) { if (!FileHasValidFormatAndReader(file)) { return nullptr; } auto path = std::make_shared(file->InitData); - auto reader = std::get>(file->Reader); + auto reader = std::get>(file->Reader); path->numPaths = reader->ReadUInt32(); path->paths.reserve(path->numPaths); diff --git a/soh/soh/resource/importer/PathFactory.h b/soh/soh/resource/importer/PathFactory.h index aa8ae747ce2..ddbee772df4 100644 --- a/soh/soh/resource/importer/PathFactory.h +++ b/soh/soh/resource/importer/PathFactory.h @@ -4,8 +4,8 @@ #include "ResourceFactoryBinary.h" namespace SOH { -class ResourceFactoryBinaryPathV0 : public LUS::ResourceFactoryBinary { +class ResourceFactoryBinaryPathV0 : public Ship::ResourceFactoryBinary { public: - std::shared_ptr ReadResource(std::shared_ptr file) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; } // namespace SOH diff --git a/soh/soh/resource/importer/PlayerAnimationFactory.cpp b/soh/soh/resource/importer/PlayerAnimationFactory.cpp index 4c25d5e80e6..59610da46fa 100644 --- a/soh/soh/resource/importer/PlayerAnimationFactory.cpp +++ b/soh/soh/resource/importer/PlayerAnimationFactory.cpp @@ -3,13 +3,13 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr ResourceFactoryBinaryPlayerAnimationV0::ReadResource(std::shared_ptr file) { +std::shared_ptr ResourceFactoryBinaryPlayerAnimationV0::ReadResource(std::shared_ptr file) { if (!FileHasValidFormatAndReader(file)) { return nullptr; } auto playerAnimation = std::make_shared(file->InitData); - auto reader = std::get>(file->Reader); + auto reader = std::get>(file->Reader); uint32_t numEntries = reader->ReadUInt32(); playerAnimation->limbRotData.reserve(numEntries); diff --git a/soh/soh/resource/importer/PlayerAnimationFactory.h b/soh/soh/resource/importer/PlayerAnimationFactory.h index 8b459a38b61..3ee8b1d3a28 100644 --- a/soh/soh/resource/importer/PlayerAnimationFactory.h +++ b/soh/soh/resource/importer/PlayerAnimationFactory.h @@ -4,8 +4,8 @@ #include "ResourceFactoryBinary.h" namespace SOH { -class ResourceFactoryBinaryPlayerAnimationV0 : public LUS::ResourceFactoryBinary { +class ResourceFactoryBinaryPlayerAnimationV0 : public Ship::ResourceFactoryBinary { public: - std::shared_ptr ReadResource(std::shared_ptr file) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; } // namespace SOH diff --git a/soh/soh/resource/importer/SceneFactory.cpp b/soh/soh/resource/importer/SceneFactory.cpp index c537cb31215..1bcf92e1c97 100644 --- a/soh/soh/resource/importer/SceneFactory.cpp +++ b/soh/soh/resource/importer/SceneFactory.cpp @@ -58,7 +58,7 @@ ResourceFactoryBinarySceneV0::ResourceFactoryBinarySceneV0() { sceneCommandFactories[SceneCommandID::SetMesh] = std::make_shared(); } -void ResourceFactoryBinarySceneV0::ParseSceneCommands(std::shared_ptr scene, std::shared_ptr reader) { +void ResourceFactoryBinarySceneV0::ParseSceneCommands(std::shared_ptr scene, std::shared_ptr reader) { uint32_t commandCount = reader->ReadUInt32(); scene->commands.reserve(commandCount); @@ -68,16 +68,16 @@ void ResourceFactoryBinarySceneV0::ParseSceneCommands(std::shared_ptr sce } std::shared_ptr ResourceFactoryBinarySceneV0::ParseSceneCommand(std::shared_ptr scene, - std::shared_ptr reader, uint32_t index) { + std::shared_ptr reader, uint32_t index) { SceneCommandID cmdID = (SceneCommandID)reader->ReadInt32(); - reader->Seek(-sizeof(int32_t), LUS::SeekOffsetType::Current); + reader->Seek(-sizeof(int32_t), Ship::SeekOffsetType::Current); std::shared_ptr result = nullptr; auto commandFactory = ResourceFactoryBinarySceneV0::sceneCommandFactories[cmdID]; if (commandFactory != nullptr) { - auto initData = std::make_shared(); + auto initData = std::make_shared(); initData->Id = scene->GetInitData()->Id; initData->Type = static_cast(SOH::ResourceType::SOH_SceneCommand); initData->Path = scene->GetInitData()->Path + "/SceneCommand" + std::to_string(index); @@ -93,13 +93,13 @@ std::shared_ptr ResourceFactoryBinarySceneV0::ParseSceneCommand(s return result; } -std::shared_ptr ResourceFactoryBinarySceneV0::ReadResource(std::shared_ptr file) { +std::shared_ptr ResourceFactoryBinarySceneV0::ReadResource(std::shared_ptr file) { if (!FileHasValidFormatAndReader(file)) { return nullptr; } auto scene = std::make_shared(file->InitData); - auto reader = std::get>(file->Reader); + auto reader = std::get>(file->Reader); ParseSceneCommands(scene, reader); @@ -200,7 +200,7 @@ std::shared_ptr ResourceFactoryXMLSceneV0::ParseSceneCommand(std: auto commandFactory = ResourceFactoryXMLSceneV0::sceneCommandFactories[cmdID]; if (commandFactory != nullptr) { - auto initData = std::make_shared(); + auto initData = std::make_shared(); initData->Id = scene->GetInitData()->Id; initData->Type = static_cast(ResourceType::SOH_SceneCommand); initData->Path = scene->GetInitData()->Path + "/SceneCommand" + std::to_string(index); @@ -216,7 +216,7 @@ std::shared_ptr ResourceFactoryXMLSceneV0::ParseSceneCommand(std: return result; } -std::shared_ptr ResourceFactoryXMLSceneV0::ReadResource(std::shared_ptr file) { +std::shared_ptr ResourceFactoryXMLSceneV0::ReadResource(std::shared_ptr file) { if (!FileHasValidFormatAndReader(file)) { return nullptr; } diff --git a/soh/soh/resource/importer/SceneFactory.h b/soh/soh/resource/importer/SceneFactory.h index a1b345f7de4..115c3f3f5a4 100644 --- a/soh/soh/resource/importer/SceneFactory.h +++ b/soh/soh/resource/importer/SceneFactory.h @@ -8,12 +8,12 @@ #include "ResourceFactoryXML.h" namespace SOH { -class ResourceFactoryBinarySceneV0 : public LUS::ResourceFactoryBinary { +class ResourceFactoryBinarySceneV0 : public Ship::ResourceFactoryBinary { public: ResourceFactoryBinarySceneV0(); - std::shared_ptr ReadResource(std::shared_ptr file) override; - void ParseSceneCommands(std::shared_ptr scene, std::shared_ptr reader); + std::shared_ptr ReadResource(std::shared_ptr file) override; + void ParseSceneCommands(std::shared_ptr scene, std::shared_ptr reader); // Doing something very similar to what we do on the ResourceLoader. // Eventually, scene commands should be moved up to the ResourceLoader as well. @@ -21,14 +21,14 @@ class ResourceFactoryBinarySceneV0 : public LUS::ResourceFactoryBinary { // and the exporter does not export the commands with a proper OTR header. static inline std::unordered_map> sceneCommandFactories; protected: - std::shared_ptr ParseSceneCommand(std::shared_ptr scene, std::shared_ptr reader, uint32_t index); + std::shared_ptr ParseSceneCommand(std::shared_ptr scene, std::shared_ptr reader, uint32_t index); }; -class ResourceFactoryXMLSceneV0 : public LUS::ResourceFactoryXML { +class ResourceFactoryXMLSceneV0 : public Ship::ResourceFactoryXML { public: ResourceFactoryXMLSceneV0(); - std::shared_ptr ReadResource(std::shared_ptr file) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; void ParseSceneCommands(std::shared_ptr scene, std::shared_ptr reader); // Doing something very similar to what we do on the ResourceLoader. diff --git a/soh/soh/resource/importer/SkeletonFactory.cpp b/soh/soh/resource/importer/SkeletonFactory.cpp index fedfda40034..d4cb965bf3b 100644 --- a/soh/soh/resource/importer/SkeletonFactory.cpp +++ b/soh/soh/resource/importer/SkeletonFactory.cpp @@ -4,13 +4,13 @@ #include namespace SOH { -std::shared_ptr ResourceFactoryBinarySkeletonV0::ReadResource(std::shared_ptr file) { +std::shared_ptr ResourceFactoryBinarySkeletonV0::ReadResource(std::shared_ptr file) { if (!FileHasValidFormatAndReader(file)) { return nullptr; } auto skeleton = std::make_shared(file->InitData); - auto reader = std::get>(file->Reader); + auto reader = std::get>(file->Reader); skeleton->type = (SkeletonType)reader->ReadInt8(); skeleton->limbType = (LimbType)reader->ReadInt8(); @@ -43,7 +43,7 @@ std::shared_ptr ResourceFactoryBinarySkeletonV0::ReadResource(st for (size_t i = 0; i < skeleton->limbTable.size(); i++) { std::string limbStr = skeleton->limbTable[i]; - auto limb = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(limbStr.c_str()); + auto limb = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(limbStr.c_str()); skeleton->skeletonHeaderSegments.push_back(limb ? limb->GetRawPointer() : nullptr); } @@ -62,7 +62,7 @@ std::shared_ptr ResourceFactoryBinarySkeletonV0::ReadResource(st return skeleton; } -std::shared_ptr ResourceFactoryXMLSkeletonV0::ReadResource(std::shared_ptr file) { +std::shared_ptr ResourceFactoryXMLSkeletonV0::ReadResource(std::shared_ptr file) { if (!FileHasValidFormatAndReader(file)) { return nullptr; } @@ -112,7 +112,7 @@ std::shared_ptr ResourceFactoryXMLSkeletonV0::ReadResource(std:: std::string limbName = child->Attribute("Path"); skel->limbTable.push_back(limbName); - auto limb = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(limbName.c_str()); + auto limb = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(limbName.c_str()); skel->skeletonHeaderSegments.push_back(limb ? limb->GetRawPointer() : nullptr); } diff --git a/soh/soh/resource/importer/SkeletonFactory.h b/soh/soh/resource/importer/SkeletonFactory.h index 5de02175f03..24f92720af3 100644 --- a/soh/soh/resource/importer/SkeletonFactory.h +++ b/soh/soh/resource/importer/SkeletonFactory.h @@ -5,13 +5,13 @@ #include "ResourceFactoryXML.h" namespace SOH { -class ResourceFactoryBinarySkeletonV0 : public LUS::ResourceFactoryBinary { +class ResourceFactoryBinarySkeletonV0 : public Ship::ResourceFactoryBinary { public: - std::shared_ptr ReadResource(std::shared_ptr file) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; -class ResourceFactoryXMLSkeletonV0 : public LUS::ResourceFactoryXML { +class ResourceFactoryXMLSkeletonV0 : public Ship::ResourceFactoryXML { public: - std::shared_ptr ReadResource(std::shared_ptr file) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; } // namespace SOH diff --git a/soh/soh/resource/importer/SkeletonLimbFactory.cpp b/soh/soh/resource/importer/SkeletonLimbFactory.cpp index 15ba9228107..3f780e6d4b1 100644 --- a/soh/soh/resource/importer/SkeletonLimbFactory.cpp +++ b/soh/soh/resource/importer/SkeletonLimbFactory.cpp @@ -4,13 +4,13 @@ #include "libultraship/libultraship.h" namespace SOH { -std::shared_ptr ResourceFactoryBinarySkeletonLimbV0::ReadResource(std::shared_ptr file) { +std::shared_ptr ResourceFactoryBinarySkeletonLimbV0::ReadResource(std::shared_ptr file) { if (!FileHasValidFormatAndReader(file)) { return nullptr; } auto skeletonLimb = std::make_shared(file->InitData); - auto reader = std::get>(file->Reader); + auto reader = std::get>(file->Reader); skeletonLimb->limbType = (LimbType)reader->ReadInt8(); skeletonLimb->skinSegmentType = (ZLimbSkinType)reader->ReadInt8(); @@ -184,7 +184,7 @@ std::shared_ptr ResourceFactoryBinarySkeletonLimbV0::ReadResourc return skeletonLimb; } -std::shared_ptr ResourceFactoryXMLSkeletonLimbV0::ReadResource(std::shared_ptr file) { +std::shared_ptr ResourceFactoryXMLSkeletonLimbV0::ReadResource(std::shared_ptr file) { if (!FileHasValidFormatAndReader(file)) { return nullptr; } diff --git a/soh/soh/resource/importer/SkeletonLimbFactory.h b/soh/soh/resource/importer/SkeletonLimbFactory.h index 125dde2b80d..222cefa2cea 100644 --- a/soh/soh/resource/importer/SkeletonLimbFactory.h +++ b/soh/soh/resource/importer/SkeletonLimbFactory.h @@ -5,13 +5,13 @@ #include "ResourceFactoryXML.h" namespace SOH { -class ResourceFactoryBinarySkeletonLimbV0 : public LUS::ResourceFactoryBinary { +class ResourceFactoryBinarySkeletonLimbV0 : public Ship::ResourceFactoryBinary { public: - std::shared_ptr ReadResource(std::shared_ptr file) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; -class ResourceFactoryXMLSkeletonLimbV0 : public LUS::ResourceFactoryXML { +class ResourceFactoryXMLSkeletonLimbV0 : public Ship::ResourceFactoryXML { public: - std::shared_ptr ReadResource(std::shared_ptr file) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; } // namespace SOH diff --git a/soh/soh/resource/importer/TextFactory.cpp b/soh/soh/resource/importer/TextFactory.cpp index 89d229f8051..1da1d50db1f 100644 --- a/soh/soh/resource/importer/TextFactory.cpp +++ b/soh/soh/resource/importer/TextFactory.cpp @@ -3,13 +3,13 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr ResourceFactoryBinaryTextV0::ReadResource(std::shared_ptr file) { +std::shared_ptr ResourceFactoryBinaryTextV0::ReadResource(std::shared_ptr file) { if (!FileHasValidFormatAndReader(file)) { return nullptr; } auto text = std::make_shared(file->InitData); - auto reader = std::get>(file->Reader); + auto reader = std::get>(file->Reader); uint32_t msgCount = reader->ReadUInt32(); text->messages.reserve(msgCount); @@ -27,7 +27,7 @@ std::shared_ptr ResourceFactoryBinaryTextV0::ReadResource(std::s return text; } -std::shared_ptr ResourceFactoryXMLTextV0::ReadResource(std::shared_ptr file) { +std::shared_ptr ResourceFactoryXMLTextV0::ReadResource(std::shared_ptr file) { if (!FileHasValidFormatAndReader(file)) { return nullptr; } diff --git a/soh/soh/resource/importer/TextFactory.h b/soh/soh/resource/importer/TextFactory.h index cb466204b69..55a5693662e 100644 --- a/soh/soh/resource/importer/TextFactory.h +++ b/soh/soh/resource/importer/TextFactory.h @@ -5,13 +5,13 @@ #include "ResourceFactoryXML.h" namespace SOH { -class ResourceFactoryBinaryTextV0 : public LUS::ResourceFactoryBinary { +class ResourceFactoryBinaryTextV0 : public Ship::ResourceFactoryBinary { public: - std::shared_ptr ReadResource(std::shared_ptr file) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; -class ResourceFactoryXMLTextV0 : public LUS::ResourceFactoryXML { +class ResourceFactoryXMLTextV0 : public Ship::ResourceFactoryXML { public: - std::shared_ptr ReadResource(std::shared_ptr file) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/EndMarkerFactory.cpp b/soh/soh/resource/importer/scenecommand/EndMarkerFactory.cpp index debcf7ab166..6932117f1ad 100644 --- a/soh/soh/resource/importer/scenecommand/EndMarkerFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/EndMarkerFactory.cpp @@ -4,8 +4,8 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr -EndMarkerFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { +std::shared_ptr +EndMarkerFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { auto endMarker = std::make_shared(initData); ReadCommandId(endMarker, reader); @@ -17,7 +17,7 @@ EndMarkerFactory::ReadResource(std::shared_ptr initData, return endMarker; } -std::shared_ptr EndMarkerFactoryXML::ReadResource(std::shared_ptr initData, +std::shared_ptr EndMarkerFactoryXML::ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) { auto endMarker = std::make_shared(initData); diff --git a/soh/soh/resource/importer/scenecommand/EndMarkerFactory.h b/soh/soh/resource/importer/scenecommand/EndMarkerFactory.h index 8e3875ef2f7..62dfcd7c4ff 100644 --- a/soh/soh/resource/importer/scenecommand/EndMarkerFactory.h +++ b/soh/soh/resource/importer/scenecommand/EndMarkerFactory.h @@ -5,12 +5,12 @@ namespace SOH { class EndMarkerFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; class EndMarkerFactoryXML : public SceneCommandFactoryXMLV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; }; } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SceneCommandFactory.cpp b/soh/soh/resource/importer/scenecommand/SceneCommandFactory.cpp index 9ab5d16115d..8d7de50218e 100644 --- a/soh/soh/resource/importer/scenecommand/SceneCommandFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SceneCommandFactory.cpp @@ -3,7 +3,7 @@ #include "spdlog/spdlog.h" namespace SOH { -void SceneCommandFactoryBinaryV0::ReadCommandId(std::shared_ptr command, std::shared_ptr reader) { +void SceneCommandFactoryBinaryV0::ReadCommandId(std::shared_ptr command, std::shared_ptr reader) { command->cmdId = (SceneCommandID)reader->ReadInt32(); } } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SceneCommandFactory.h b/soh/soh/resource/importer/scenecommand/SceneCommandFactory.h index 73e5a2e0686..601996ea466 100644 --- a/soh/soh/resource/importer/scenecommand/SceneCommandFactory.h +++ b/soh/soh/resource/importer/scenecommand/SceneCommandFactory.h @@ -9,15 +9,15 @@ namespace SOH { class SceneCommandFactoryBinaryV0 { public: - virtual std::shared_ptr ReadResource(std::shared_ptr initData, std::shared_ptr reader) = 0; + virtual std::shared_ptr ReadResource(std::shared_ptr initData, std::shared_ptr reader) = 0; protected: - void ReadCommandId(std::shared_ptr command, std::shared_ptr reader); + void ReadCommandId(std::shared_ptr command, std::shared_ptr reader); }; class SceneCommandFactoryXMLV0 { public: - virtual std::shared_ptr ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) = 0; + virtual std::shared_ptr ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) = 0; protected: void ReadCommandId(std::shared_ptr command, tinyxml2::XMLElement* reader); diff --git a/soh/soh/resource/importer/scenecommand/SetActorListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetActorListFactory.cpp index cf397fcd394..6c262e7afcd 100644 --- a/soh/soh/resource/importer/scenecommand/SetActorListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetActorListFactory.cpp @@ -4,8 +4,8 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr -SetActorListFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { +std::shared_ptr +SetActorListFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { auto setActorList = std::make_shared(initData); ReadCommandId(setActorList, reader); @@ -34,7 +34,7 @@ SetActorListFactory::ReadResource(std::shared_ptr initDat return setActorList; } -std::shared_ptr SetActorListFactoryXML::ReadResource(std::shared_ptr initData, +std::shared_ptr SetActorListFactoryXML::ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) { auto setActorList = std::make_shared(initData); diff --git a/soh/soh/resource/importer/scenecommand/SetActorListFactory.h b/soh/soh/resource/importer/scenecommand/SetActorListFactory.h index 5dd872f8ab4..703181c9a04 100644 --- a/soh/soh/resource/importer/scenecommand/SetActorListFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetActorListFactory.h @@ -5,13 +5,13 @@ namespace SOH { class SetActorListFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; class SetActorListFactoryXML : public SceneCommandFactoryXMLV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; }; } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.cpp b/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.cpp index 40e31f0f293..c04f717c379 100644 --- a/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.cpp @@ -5,8 +5,8 @@ #include "libultraship/libultraship.h" namespace SOH { -std::shared_ptr SetAlternateHeadersFactory::ReadResource(std::shared_ptr initData, - std::shared_ptr reader) { +std::shared_ptr SetAlternateHeadersFactory::ReadResource(std::shared_ptr initData, + std::shared_ptr reader) { auto setAlternateHeaders = std::make_shared(initData); ReadCommandId(setAlternateHeaders, reader); @@ -16,7 +16,7 @@ std::shared_ptr SetAlternateHeadersFactory::ReadResource(std::sh for (uint32_t i = 0; i < setAlternateHeaders->numHeaders; i++) { auto headerName = reader->ReadString(); if (!headerName.empty()) { - setAlternateHeaders->headers.push_back(std::static_pointer_cast(LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(headerName.c_str()))); + setAlternateHeaders->headers.push_back(std::static_pointer_cast(Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(headerName.c_str()))); } else { setAlternateHeaders->headers.push_back(nullptr); } @@ -29,7 +29,7 @@ std::shared_ptr SetAlternateHeadersFactory::ReadResource(std::sh return setAlternateHeaders; } -std::shared_ptr SetAlternateHeadersFactoryXML::ReadResource(std::shared_ptr initData, +std::shared_ptr SetAlternateHeadersFactoryXML::ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) { auto setAlternateHeaders = std::make_shared(initData); @@ -43,7 +43,7 @@ std::shared_ptr SetAlternateHeadersFactoryXML::ReadResource(std: for (uint32_t i = 0; i < setAlternateHeaders->numHeaders; i++) { auto headerName = std::string(child->Attribute("HeaderName")); if (!headerName.empty()) { - setAlternateHeaders->headers.push_back(std::static_pointer_cast(LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(headerName.c_str()))); + setAlternateHeaders->headers.push_back(std::static_pointer_cast(Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(headerName.c_str()))); } else { setAlternateHeaders->headers.push_back(nullptr); } diff --git a/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.h b/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.h index 84e730905ea..7b1324a603f 100644 --- a/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.h @@ -5,13 +5,13 @@ namespace SOH { class SetAlternateHeadersFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; class SetAlternateHeadersFactoryXML : public SceneCommandFactoryXMLV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; }; } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetCameraSettingsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetCameraSettingsFactory.cpp index 52158626287..58c6ab4e36d 100644 --- a/soh/soh/resource/importer/scenecommand/SetCameraSettingsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetCameraSettingsFactory.cpp @@ -4,8 +4,8 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr SetCameraSettingsFactory::ReadResource(std::shared_ptr initData, - std::shared_ptr reader) { +std::shared_ptr SetCameraSettingsFactory::ReadResource(std::shared_ptr initData, + std::shared_ptr reader) { auto setCameraSettings = std::make_shared(initData); ReadCommandId(setCameraSettings, reader); @@ -20,7 +20,7 @@ std::shared_ptr SetCameraSettingsFactory::ReadResource(std::shar return setCameraSettings; } -std::shared_ptr SetCameraSettingsFactoryXML::ReadResource(std::shared_ptr initData, +std::shared_ptr SetCameraSettingsFactoryXML::ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) { auto setCameraSettings = std::make_shared(initData); diff --git a/soh/soh/resource/importer/scenecommand/SetCameraSettingsFactory.h b/soh/soh/resource/importer/scenecommand/SetCameraSettingsFactory.h index a03287b353e..a8c21f77661 100644 --- a/soh/soh/resource/importer/scenecommand/SetCameraSettingsFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetCameraSettingsFactory.h @@ -5,13 +5,13 @@ namespace SOH { class SetCameraSettingsFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; class SetCameraSettingsFactoryXML : public SceneCommandFactoryXMLV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; }; } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.cpp b/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.cpp index f50ee379011..a67778f63ba 100644 --- a/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.cpp @@ -5,14 +5,14 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr SetCollisionHeaderFactory::ReadResource(std::shared_ptr initData, - std::shared_ptr reader) { +std::shared_ptr SetCollisionHeaderFactory::ReadResource(std::shared_ptr initData, + std::shared_ptr reader) { auto setCollisionHeader = std::make_shared(initData); ReadCommandId(setCollisionHeader, reader); setCollisionHeader->fileName = reader->ReadString(); - setCollisionHeader->collisionHeader = std::static_pointer_cast(LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(setCollisionHeader->fileName.c_str())); + setCollisionHeader->collisionHeader = std::static_pointer_cast(Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(setCollisionHeader->fileName.c_str())); if (CVarGetInteger(CVAR_DEVELOPER_TOOLS("ResourceLogging"), 0)) { LogSetCollisionHeaderAsXML(setCollisionHeader); @@ -21,14 +21,14 @@ std::shared_ptr SetCollisionHeaderFactory::ReadResource(std::sha return setCollisionHeader; } -std::shared_ptr SetCollisionHeaderFactoryXML::ReadResource(std::shared_ptr initData, +std::shared_ptr SetCollisionHeaderFactoryXML::ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) { auto setCollisionHeader = std::make_shared(initData); setCollisionHeader->cmdId = SceneCommandID::SetCollisionHeader; setCollisionHeader->fileName = reader->Attribute("FileName"); - setCollisionHeader->collisionHeader = std::static_pointer_cast(LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(setCollisionHeader->fileName.c_str())); + setCollisionHeader->collisionHeader = std::static_pointer_cast(Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(setCollisionHeader->fileName.c_str())); return setCollisionHeader; } diff --git a/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.h b/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.h index 12b872f3cc8..35902e7cb48 100644 --- a/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.h @@ -5,13 +5,13 @@ namespace SOH { class SetCollisionHeaderFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; class SetCollisionHeaderFactoryXML : public SceneCommandFactoryXMLV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; }; } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetCsCameraFactory.cpp b/soh/soh/resource/importer/scenecommand/SetCsCameraFactory.cpp index 569b8b1d9e4..7ae8237bfbf 100644 --- a/soh/soh/resource/importer/scenecommand/SetCsCameraFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetCsCameraFactory.cpp @@ -4,8 +4,8 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr -SetCsCameraFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { +std::shared_ptr +SetCsCameraFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { auto setCsCamera = std::make_shared(initData); ReadCommandId(setCsCamera, reader); @@ -22,7 +22,7 @@ SetCsCameraFactory::ReadResource(std::shared_ptr initData return setCsCamera; } -std::shared_ptr SetCsCameraFactoryXML::ReadResource(std::shared_ptr initData, +std::shared_ptr SetCsCameraFactoryXML::ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) { auto setCsCamera = std::make_shared(initData); diff --git a/soh/soh/resource/importer/scenecommand/SetCsCameraFactory.h b/soh/soh/resource/importer/scenecommand/SetCsCameraFactory.h index 89c92a6990f..ad232a11dab 100644 --- a/soh/soh/resource/importer/scenecommand/SetCsCameraFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetCsCameraFactory.h @@ -5,13 +5,13 @@ namespace SOH { class SetCsCameraFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; class SetCsCameraFactoryXML : public SceneCommandFactoryXMLV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; }; } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.cpp b/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.cpp index 7aea7c70d8f..7ca657403ca 100644 --- a/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.cpp @@ -5,14 +5,14 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr -SetCutscenesFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { +std::shared_ptr +SetCutscenesFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { auto setCutscenes = std::make_shared(initData); ReadCommandId(setCutscenes, reader); setCutscenes->fileName = reader->ReadString(); - setCutscenes->cutscene = std::static_pointer_cast(LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(setCutscenes->fileName.c_str())); + setCutscenes->cutscene = std::static_pointer_cast(Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(setCutscenes->fileName.c_str())); if (CVarGetInteger(CVAR_DEVELOPER_TOOLS("ResourceLogging"), 0)) { LogCutscenesAsXML(setCutscenes); @@ -21,14 +21,14 @@ SetCutscenesFactory::ReadResource(std::shared_ptr initDat return setCutscenes; } -std::shared_ptr SetCutscenesFactoryXML::ReadResource(std::shared_ptr initData, +std::shared_ptr SetCutscenesFactoryXML::ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) { auto setCutscenes = std::make_shared(initData); setCutscenes->cmdId = SceneCommandID::SetCutscenes; setCutscenes->fileName = reader->Attribute("FileName"); - setCutscenes->cutscene = std::static_pointer_cast(LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(setCutscenes->fileName.c_str())); + setCutscenes->cutscene = std::static_pointer_cast(Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(setCutscenes->fileName.c_str())); return setCutscenes; } diff --git a/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.h b/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.h index c78bf621cb0..4bd76b56364 100644 --- a/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.h @@ -5,13 +5,13 @@ namespace SOH { class SetCutscenesFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; class SetCutscenesFactoryXML : public SceneCommandFactoryXMLV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; }; } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetEchoSettingsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetEchoSettingsFactory.cpp index d4c6e9a509c..4038ea82540 100644 --- a/soh/soh/resource/importer/scenecommand/SetEchoSettingsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetEchoSettingsFactory.cpp @@ -4,8 +4,8 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr -SetEchoSettingsFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { +std::shared_ptr +SetEchoSettingsFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { auto setEchoSettings = std::make_shared(initData); ReadCommandId(setEchoSettings, reader); @@ -19,7 +19,7 @@ SetEchoSettingsFactory::ReadResource(std::shared_ptr init return setEchoSettings; } -std::shared_ptr SetEchoSettingsFactoryXML::ReadResource(std::shared_ptr initData, +std::shared_ptr SetEchoSettingsFactoryXML::ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) { auto setEchoSettings = std::make_shared(initData); diff --git a/soh/soh/resource/importer/scenecommand/SetEchoSettingsFactory.h b/soh/soh/resource/importer/scenecommand/SetEchoSettingsFactory.h index 4be1fe399ae..c76885cf929 100644 --- a/soh/soh/resource/importer/scenecommand/SetEchoSettingsFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetEchoSettingsFactory.h @@ -5,13 +5,13 @@ namespace SOH { class SetEchoSettingsFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; class SetEchoSettingsFactoryXML : public SceneCommandFactoryXMLV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; }; } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetEntranceListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetEntranceListFactory.cpp index f3817c39c90..0590bfeb7b7 100644 --- a/soh/soh/resource/importer/scenecommand/SetEntranceListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetEntranceListFactory.cpp @@ -4,8 +4,8 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr -SetEntranceListFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { +std::shared_ptr +SetEntranceListFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { auto setEntranceList = std::make_shared(initData); ReadCommandId(setEntranceList, reader); @@ -28,7 +28,7 @@ SetEntranceListFactory::ReadResource(std::shared_ptr init return setEntranceList; } -std::shared_ptr SetEntranceListFactoryXML::ReadResource(std::shared_ptr initData, +std::shared_ptr SetEntranceListFactoryXML::ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) { auto setEntranceList = std::make_shared(initData); diff --git a/soh/soh/resource/importer/scenecommand/SetEntranceListFactory.h b/soh/soh/resource/importer/scenecommand/SetEntranceListFactory.h index a5349cf83b2..207e9f050cf 100644 --- a/soh/soh/resource/importer/scenecommand/SetEntranceListFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetEntranceListFactory.h @@ -5,13 +5,13 @@ namespace SOH { class SetEntranceListFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; class SetEntranceListFactoryXML : public SceneCommandFactoryXMLV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; }; } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetExitListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetExitListFactory.cpp index b6078199bda..328b41d8aff 100644 --- a/soh/soh/resource/importer/scenecommand/SetExitListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetExitListFactory.cpp @@ -4,8 +4,8 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr -SetExitListFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { +std::shared_ptr +SetExitListFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { auto setExitList = std::make_shared( initData); ReadCommandId(setExitList, reader); @@ -23,7 +23,7 @@ SetExitListFactory::ReadResource(std::shared_ptr initData return setExitList; } -std::shared_ptr SetExitListFactoryXML::ReadResource(std::shared_ptr initData, +std::shared_ptr SetExitListFactoryXML::ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) { auto setExitList = std::make_shared(initData); diff --git a/soh/soh/resource/importer/scenecommand/SetExitListFactory.h b/soh/soh/resource/importer/scenecommand/SetExitListFactory.h index fc47b88d0be..4b050f46f2c 100644 --- a/soh/soh/resource/importer/scenecommand/SetExitListFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetExitListFactory.h @@ -5,13 +5,13 @@ namespace SOH { class SetExitListFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; class SetExitListFactoryXML : public SceneCommandFactoryXMLV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; }; } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetLightListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetLightListFactory.cpp index af7f1bb3c47..e1cbd212258 100644 --- a/soh/soh/resource/importer/scenecommand/SetLightListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetLightListFactory.cpp @@ -4,8 +4,8 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr -SetLightListFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { +std::shared_ptr +SetLightListFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { auto setLightList = std::make_shared(initData); ReadCommandId(setLightList, reader); @@ -38,7 +38,7 @@ SetLightListFactory::ReadResource(std::shared_ptr initDat return setLightList; } -std::shared_ptr SetLightListFactoryXML::ReadResource(std::shared_ptr initData, +std::shared_ptr SetLightListFactoryXML::ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) { auto setLightList = std::make_shared(initData); diff --git a/soh/soh/resource/importer/scenecommand/SetLightListFactory.h b/soh/soh/resource/importer/scenecommand/SetLightListFactory.h index aae5c8e4a9e..0af868d176e 100644 --- a/soh/soh/resource/importer/scenecommand/SetLightListFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetLightListFactory.h @@ -5,13 +5,13 @@ namespace SOH { class SetLightListFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; class SetLightListFactoryXML : public SceneCommandFactoryXMLV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; }; } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetLightingSettingsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetLightingSettingsFactory.cpp index 573998cfade..7e35a7ac09e 100644 --- a/soh/soh/resource/importer/scenecommand/SetLightingSettingsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetLightingSettingsFactory.cpp @@ -4,8 +4,8 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr SetLightingSettingsFactory::ReadResource(std::shared_ptr initData, - std::shared_ptr reader) { +std::shared_ptr SetLightingSettingsFactory::ReadResource(std::shared_ptr initData, + std::shared_ptr reader) { auto setLightingSettings = std::make_shared(initData); ReadCommandId(setLightingSettings, reader); @@ -51,7 +51,7 @@ std::shared_ptr SetLightingSettingsFactory::ReadResource(std::sh return setLightingSettings; } -std::shared_ptr SetLightingSettingsFactoryXML::ReadResource(std::shared_ptr initData, +std::shared_ptr SetLightingSettingsFactoryXML::ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) { auto setLightingSettings = std::make_shared(initData); diff --git a/soh/soh/resource/importer/scenecommand/SetLightingSettingsFactory.h b/soh/soh/resource/importer/scenecommand/SetLightingSettingsFactory.h index 39ae6934de9..d5b3be279ea 100644 --- a/soh/soh/resource/importer/scenecommand/SetLightingSettingsFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetLightingSettingsFactory.h @@ -5,13 +5,13 @@ namespace SOH { class SetLightingSettingsFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; class SetLightingSettingsFactoryXML : public SceneCommandFactoryXMLV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; }; } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetMeshFactory.cpp b/soh/soh/resource/importer/scenecommand/SetMeshFactory.cpp index 8c4109c5abb..bdc5a010679 100644 --- a/soh/soh/resource/importer/scenecommand/SetMeshFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetMeshFactory.cpp @@ -5,8 +5,8 @@ #include "libultraship/libultraship.h" namespace SOH { -std::shared_ptr -SetMeshFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { +std::shared_ptr +SetMeshFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { auto setMesh = std::make_shared(initData); ReadCommandId(setMesh, reader); @@ -41,8 +41,8 @@ SetMeshFactory::ReadResource(std::shared_ptr initData, st std::string meshOpa = reader->ReadString(); std::string meshXlu = reader->ReadString(); - auto opaRes = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshOpa.c_str()); - auto xluRes = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshXlu.c_str()); + auto opaRes = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshOpa.c_str()); + auto xluRes = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshXlu.c_str()); dlist.opa = meshOpa != "" ? (Gfx*)(opaRes ? opaRes->GetRawPointer() : nullptr) : 0; dlist.xlu = meshXlu != "" ? (Gfx*)(xluRes ? xluRes->GetRawPointer() : nullptr) : 0; @@ -56,8 +56,8 @@ SetMeshFactory::ReadResource(std::shared_ptr initData, st std::string imgOpa = reader->ReadString(); std::string imgXlu = reader->ReadString(); - auto opaRes = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(imgOpa.c_str()); - auto xluRes = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(imgXlu.c_str()); + auto opaRes = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(imgOpa.c_str()); + auto xluRes = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(imgXlu.c_str()); pType.opa = imgOpa != "" ? (Gfx*)(opaRes ? opaRes->GetRawPointer() : nullptr) : 0; pType.xlu = imgXlu != "" ? (Gfx*)(xluRes ? xluRes->GetRawPointer() : nullptr) : 0; @@ -104,8 +104,8 @@ SetMeshFactory::ReadResource(std::shared_ptr initData, st std::string meshOpa = reader->ReadString(); std::string meshXlu = reader->ReadString(); - opaRes = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshOpa.c_str()); - xluRes = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshXlu.c_str()); + opaRes = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshOpa.c_str()); + xluRes = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshXlu.c_str()); pType.opa = meshOpa != "" ? (Gfx*)(opaRes ? opaRes->GetRawPointer() : nullptr) : 0; pType.xlu = meshXlu != "" ? (Gfx*)(xluRes ? xluRes->GetRawPointer() : nullptr) : 0; @@ -124,8 +124,8 @@ SetMeshFactory::ReadResource(std::shared_ptr initData, st std::string meshOpa = reader->ReadString(); std::string meshXlu = reader->ReadString(); - auto opaRes = meshOpa != "" ? LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshOpa.c_str()) : nullptr; - auto xluRes = meshXlu != "" ? LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshXlu.c_str()) : nullptr; + auto opaRes = meshOpa != "" ? Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshOpa.c_str()) : nullptr; + auto xluRes = meshXlu != "" ? Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshXlu.c_str()) : nullptr; dlist.opa = (Gfx*)(opaRes ? opaRes->GetRawPointer() : nullptr); dlist.xlu = (Gfx*)(xluRes ? xluRes->GetRawPointer() : nullptr); @@ -155,7 +155,7 @@ SetMeshFactory::ReadResource(std::shared_ptr initData, st return setMesh; } -std::shared_ptr SetMeshFactoryXML::ReadResource(std::shared_ptr initData, +std::shared_ptr SetMeshFactoryXML::ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) { auto setMesh = std::make_shared(initData); @@ -199,8 +199,8 @@ std::shared_ptr SetMeshFactoryXML::ReadResource(std::shared_ptr< std::string meshOpa = child->Attribute("MeshOpa"); std::string meshXlu = child->Attribute("MeshXlu"); - auto opaRes = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshOpa.c_str()); - auto xluRes = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshXlu.c_str()); + auto opaRes = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshOpa.c_str()); + auto xluRes = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshXlu.c_str()); dlist.opa = meshOpa != "" ? (Gfx*)(opaRes ? opaRes->GetRawPointer() : nullptr) : 0; dlist.xlu = meshXlu != "" ? (Gfx*)(xluRes ? xluRes->GetRawPointer() : nullptr) : 0; @@ -214,8 +214,8 @@ std::shared_ptr SetMeshFactoryXML::ReadResource(std::shared_ptr< std::string imgOpa = child->Attribute("ImgOpa"); std::string imgXlu = child->Attribute("ImgXlu"); - auto opaRes = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(imgOpa.c_str()); - auto xluRes = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(imgXlu.c_str()); + auto opaRes = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(imgOpa.c_str()); + auto xluRes = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(imgXlu.c_str()); pType.opa = imgOpa != "" ? (Gfx*)(opaRes ? opaRes->GetRawPointer() : nullptr) : 0; pType.xlu = imgXlu != "" ? (Gfx*)(xluRes ? xluRes->GetRawPointer() : nullptr) : 0; @@ -271,8 +271,8 @@ std::shared_ptr SetMeshFactoryXML::ReadResource(std::shared_ptr< std::string meshOpa = child->Attribute("MeshOpa"); std::string meshXlu = child->Attribute("MeshXlu"); - opaRes = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshOpa.c_str()); - xluRes = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshXlu.c_str()); + opaRes = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshOpa.c_str()); + xluRes = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshXlu.c_str()); pType.opa = meshOpa != "" ? (Gfx*)(opaRes ? opaRes->GetRawPointer() : nullptr) : 0; pType.xlu = meshXlu != "" ? (Gfx*)(xluRes ? xluRes->GetRawPointer() : nullptr) : 0; @@ -291,8 +291,8 @@ std::shared_ptr SetMeshFactoryXML::ReadResource(std::shared_ptr< std::string meshOpa = child->Attribute("MeshOpa"); std::string meshXlu = child->Attribute("MeshXlu"); - auto opaRes = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshOpa.c_str()); - auto xluRes = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshXlu.c_str()); + auto opaRes = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshOpa.c_str()); + auto xluRes = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshXlu.c_str()); dlist.opa = meshOpa != "" ? (Gfx*)(opaRes ? opaRes->GetRawPointer() : nullptr) : 0; dlist.xlu = meshXlu != "" ? (Gfx*)(xluRes ? xluRes->GetRawPointer() : nullptr) : 0; diff --git a/soh/soh/resource/importer/scenecommand/SetMeshFactory.h b/soh/soh/resource/importer/scenecommand/SetMeshFactory.h index f64b55d7251..c87123174b0 100644 --- a/soh/soh/resource/importer/scenecommand/SetMeshFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetMeshFactory.h @@ -5,13 +5,13 @@ namespace SOH { class SetMeshFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; class SetMeshFactoryXML : public SceneCommandFactoryXMLV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; }; } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetObjectListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetObjectListFactory.cpp index 1d64a9aecdc..0ba356f7b24 100644 --- a/soh/soh/resource/importer/scenecommand/SetObjectListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetObjectListFactory.cpp @@ -4,8 +4,8 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr -SetObjectListFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { +std::shared_ptr +SetObjectListFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { auto setObjectList = std::make_shared(initData); ReadCommandId(setObjectList, reader); @@ -23,7 +23,7 @@ SetObjectListFactory::ReadResource(std::shared_ptr initDa return setObjectList; } -std::shared_ptr SetObjectListFactoryXML::ReadResource(std::shared_ptr initData, +std::shared_ptr SetObjectListFactoryXML::ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) { auto setObjectList = std::make_shared(initData); diff --git a/soh/soh/resource/importer/scenecommand/SetObjectListFactory.h b/soh/soh/resource/importer/scenecommand/SetObjectListFactory.h index 094c30a92f4..663ef230402 100644 --- a/soh/soh/resource/importer/scenecommand/SetObjectListFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetObjectListFactory.h @@ -5,13 +5,13 @@ namespace SOH { class SetObjectListFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; class SetObjectListFactoryXML : public SceneCommandFactoryXMLV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; }; } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.cpp b/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.cpp index 0e26e96e49e..65af2e0de31 100644 --- a/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.cpp @@ -5,8 +5,8 @@ #include namespace SOH { -std::shared_ptr -SetPathwaysFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { +std::shared_ptr +SetPathwaysFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { auto setPathways = std::make_shared(initData); ReadCommandId(setPathways, reader); @@ -15,7 +15,7 @@ SetPathwaysFactory::ReadResource(std::shared_ptr initData setPathways->paths.reserve(setPathways->numPaths); for (uint32_t i = 0; i < setPathways->numPaths; i++) { std::string pathFileName = reader->ReadString(); - auto path = std::static_pointer_cast(LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(pathFileName.c_str())); + auto path = std::static_pointer_cast(Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(pathFileName.c_str())); setPathways->paths.push_back(path->GetPointer()); } @@ -26,7 +26,7 @@ SetPathwaysFactory::ReadResource(std::shared_ptr initData return setPathways; } -std::shared_ptr SetPathwaysFactoryXML::ReadResource(std::shared_ptr initData, +std::shared_ptr SetPathwaysFactoryXML::ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) { auto setPathways = std::make_shared(initData); @@ -38,7 +38,7 @@ std::shared_ptr SetPathwaysFactoryXML::ReadResource(std::shared_ std::string childName = child->Name(); if (childName == "Pathway") { std::string pathFileName = child->Attribute("FilePath"); - auto path = std::static_pointer_cast(LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(pathFileName.c_str())); + auto path = std::static_pointer_cast(Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(pathFileName.c_str())); setPathways->paths.push_back(path->GetPointer()); setPathways->pathFileNames.push_back(pathFileName); } diff --git a/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.h b/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.h index 2e334c7a5e1..783c9f45c23 100644 --- a/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.h @@ -5,13 +5,13 @@ namespace SOH { class SetPathwaysFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; class SetPathwaysFactoryXML : public SceneCommandFactoryXMLV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; }; } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetRoomBehaviorFactory.cpp b/soh/soh/resource/importer/scenecommand/SetRoomBehaviorFactory.cpp index 25a3bf93151..14bb787ed42 100644 --- a/soh/soh/resource/importer/scenecommand/SetRoomBehaviorFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetRoomBehaviorFactory.cpp @@ -4,8 +4,8 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr -SetRoomBehaviorFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { +std::shared_ptr +SetRoomBehaviorFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { auto setRoomBehavior = std::make_shared(initData); ReadCommandId(setRoomBehavior, reader); @@ -20,7 +20,7 @@ SetRoomBehaviorFactory::ReadResource(std::shared_ptr init return setRoomBehavior; } -std::shared_ptr SetRoomBehaviorFactoryXML::ReadResource(std::shared_ptr initData, +std::shared_ptr SetRoomBehaviorFactoryXML::ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) { auto setRoomBehavior = std::make_shared(initData); diff --git a/soh/soh/resource/importer/scenecommand/SetRoomBehaviorFactory.h b/soh/soh/resource/importer/scenecommand/SetRoomBehaviorFactory.h index 97c5c7bb48e..87e55194d85 100644 --- a/soh/soh/resource/importer/scenecommand/SetRoomBehaviorFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetRoomBehaviorFactory.h @@ -5,13 +5,13 @@ namespace SOH { class SetRoomBehaviorFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; class SetRoomBehaviorFactoryXML : public SceneCommandFactoryXMLV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; }; } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetRoomListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetRoomListFactory.cpp index 67c3afd0f1c..b19ac98d779 100644 --- a/soh/soh/resource/importer/scenecommand/SetRoomListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetRoomListFactory.cpp @@ -4,8 +4,8 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr -SetRoomListFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { +std::shared_ptr +SetRoomListFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { auto setRoomList = std::make_shared(initData); ReadCommandId(setRoomList, reader); @@ -31,7 +31,7 @@ SetRoomListFactory::ReadResource(std::shared_ptr initData return setRoomList; } -std::shared_ptr SetRoomListFactoryXML::ReadResource(std::shared_ptr initData, +std::shared_ptr SetRoomListFactoryXML::ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) { auto setRoomList = std::make_shared(initData); diff --git a/soh/soh/resource/importer/scenecommand/SetRoomListFactory.h b/soh/soh/resource/importer/scenecommand/SetRoomListFactory.h index c6e82dfa932..1e05c7e031f 100644 --- a/soh/soh/resource/importer/scenecommand/SetRoomListFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetRoomListFactory.h @@ -5,13 +5,13 @@ namespace SOH { class SetRoomListFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; class SetRoomListFactoryXML : public SceneCommandFactoryXMLV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; }; } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetSkyboxModifierFactory.cpp b/soh/soh/resource/importer/scenecommand/SetSkyboxModifierFactory.cpp index 9147989dd0f..6c0ee140075 100644 --- a/soh/soh/resource/importer/scenecommand/SetSkyboxModifierFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetSkyboxModifierFactory.cpp @@ -4,8 +4,8 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr SetSkyboxModifierFactory::ReadResource(std::shared_ptr initData, - std::shared_ptr reader) { +std::shared_ptr SetSkyboxModifierFactory::ReadResource(std::shared_ptr initData, + std::shared_ptr reader) { auto setSkyboxModifier = std::make_shared(initData); ReadCommandId(setSkyboxModifier, reader); @@ -20,7 +20,7 @@ std::shared_ptr SetSkyboxModifierFactory::ReadResource(std::shar return setSkyboxModifier; } -std::shared_ptr SetSkyboxModifierFactoryXML::ReadResource(std::shared_ptr initData, +std::shared_ptr SetSkyboxModifierFactoryXML::ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) { auto setSkyboxModifier = std::make_shared(initData); diff --git a/soh/soh/resource/importer/scenecommand/SetSkyboxModifierFactory.h b/soh/soh/resource/importer/scenecommand/SetSkyboxModifierFactory.h index cbd260ecc43..a4ef5815089 100644 --- a/soh/soh/resource/importer/scenecommand/SetSkyboxModifierFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetSkyboxModifierFactory.h @@ -5,13 +5,13 @@ namespace SOH { class SetSkyboxModifierFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; class SetSkyboxModifierFactoryXML : public SceneCommandFactoryXMLV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; }; } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetSkyboxSettingsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetSkyboxSettingsFactory.cpp index 7f9f4d3d0e9..607909d654c 100644 --- a/soh/soh/resource/importer/scenecommand/SetSkyboxSettingsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetSkyboxSettingsFactory.cpp @@ -4,8 +4,8 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr SetSkyboxSettingsFactory::ReadResource(std::shared_ptr initData, - std::shared_ptr reader) { +std::shared_ptr SetSkyboxSettingsFactory::ReadResource(std::shared_ptr initData, + std::shared_ptr reader) { auto setSkyboxSettings = std::make_shared(initData); ReadCommandId(setSkyboxSettings, reader); @@ -22,7 +22,7 @@ std::shared_ptr SetSkyboxSettingsFactory::ReadResource(std::shar return setSkyboxSettings; } -std::shared_ptr SetSkyboxSettingsFactoryXML::ReadResource(std::shared_ptr initData, +std::shared_ptr SetSkyboxSettingsFactoryXML::ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) { auto setSkyboxSettings = std::make_shared(initData); diff --git a/soh/soh/resource/importer/scenecommand/SetSkyboxSettingsFactory.h b/soh/soh/resource/importer/scenecommand/SetSkyboxSettingsFactory.h index 6bc6686672d..352275b584d 100644 --- a/soh/soh/resource/importer/scenecommand/SetSkyboxSettingsFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetSkyboxSettingsFactory.h @@ -5,13 +5,13 @@ namespace SOH { class SetSkyboxSettingsFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; class SetSkyboxSettingsFactoryXML : public SceneCommandFactoryXMLV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; }; } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetSoundSettingsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetSoundSettingsFactory.cpp index 46d81c0748a..61c1892ddf8 100644 --- a/soh/soh/resource/importer/scenecommand/SetSoundSettingsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetSoundSettingsFactory.cpp @@ -4,8 +4,8 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr SetSoundSettingsFactory::ReadResource(std::shared_ptr initData, - std::shared_ptr reader) { +std::shared_ptr SetSoundSettingsFactory::ReadResource(std::shared_ptr initData, + std::shared_ptr reader) { auto setSoundSettings = std::make_shared(initData); ReadCommandId(setSoundSettings, reader); @@ -21,7 +21,7 @@ std::shared_ptr SetSoundSettingsFactory::ReadResource(std::share return setSoundSettings; } -std::shared_ptr SetSoundSettingsFactoryXML::ReadResource(std::shared_ptr initData, +std::shared_ptr SetSoundSettingsFactoryXML::ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) { auto setSoundSettings = std::make_shared(initData); diff --git a/soh/soh/resource/importer/scenecommand/SetSoundSettingsFactory.h b/soh/soh/resource/importer/scenecommand/SetSoundSettingsFactory.h index fa6f0ac2faa..14d1ebe8441 100644 --- a/soh/soh/resource/importer/scenecommand/SetSoundSettingsFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetSoundSettingsFactory.h @@ -5,13 +5,13 @@ namespace SOH { class SetSoundSettingsFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; class SetSoundSettingsFactoryXML : public SceneCommandFactoryXMLV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; }; } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetSpecialObjectsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetSpecialObjectsFactory.cpp index b90aa9c9d64..f28393134c8 100644 --- a/soh/soh/resource/importer/scenecommand/SetSpecialObjectsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetSpecialObjectsFactory.cpp @@ -4,8 +4,8 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr SetSpecialObjectsFactory::ReadResource(std::shared_ptr initData, - std::shared_ptr reader) { +std::shared_ptr SetSpecialObjectsFactory::ReadResource(std::shared_ptr initData, + std::shared_ptr reader) { auto setSpecialObjects = std::make_shared(initData); ReadCommandId(setSpecialObjects, reader); @@ -20,7 +20,7 @@ std::shared_ptr SetSpecialObjectsFactory::ReadResource(std::shar return setSpecialObjects; } -std::shared_ptr SetSpecialObjectsFactoryXML::ReadResource(std::shared_ptr initData, +std::shared_ptr SetSpecialObjectsFactoryXML::ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) { auto setSpecialObjects = std::make_shared(initData); diff --git a/soh/soh/resource/importer/scenecommand/SetSpecialObjectsFactory.h b/soh/soh/resource/importer/scenecommand/SetSpecialObjectsFactory.h index 47b30bafc3e..38b1ea51160 100644 --- a/soh/soh/resource/importer/scenecommand/SetSpecialObjectsFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetSpecialObjectsFactory.h @@ -5,13 +5,13 @@ namespace SOH { class SetSpecialObjectsFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; class SetSpecialObjectsFactoryXML : public SceneCommandFactoryXMLV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; }; } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetStartPositionListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetStartPositionListFactory.cpp index abfa6f8072c..3dee5d9925c 100644 --- a/soh/soh/resource/importer/scenecommand/SetStartPositionListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetStartPositionListFactory.cpp @@ -4,8 +4,8 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr SetStartPositionListFactory::ReadResource(std::shared_ptr initData, - std::shared_ptr reader) { +std::shared_ptr SetStartPositionListFactory::ReadResource(std::shared_ptr initData, + std::shared_ptr reader) { auto setStartPositionList = std::make_shared(initData); ReadCommandId(setStartPositionList, reader); @@ -34,7 +34,7 @@ std::shared_ptr SetStartPositionListFactory::ReadResource(std::s return setStartPositionList; } -std::shared_ptr SetStartPositionListFactoryXML::ReadResource(std::shared_ptr initData, +std::shared_ptr SetStartPositionListFactoryXML::ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) { auto setStartPositionList = std::make_shared(initData); diff --git a/soh/soh/resource/importer/scenecommand/SetStartPositionListFactory.h b/soh/soh/resource/importer/scenecommand/SetStartPositionListFactory.h index 4e381036aa4..b4894207ec8 100644 --- a/soh/soh/resource/importer/scenecommand/SetStartPositionListFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetStartPositionListFactory.h @@ -5,13 +5,13 @@ namespace SOH { class SetStartPositionListFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; class SetStartPositionListFactoryXML : public SceneCommandFactoryXMLV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; }; } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetTimeSettingsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetTimeSettingsFactory.cpp index 8e54e4573fe..739da533029 100644 --- a/soh/soh/resource/importer/scenecommand/SetTimeSettingsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetTimeSettingsFactory.cpp @@ -4,8 +4,8 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr -SetTimeSettingsFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { +std::shared_ptr +SetTimeSettingsFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { auto setTimeSettings = std::make_shared(initData); ReadCommandId(setTimeSettings, reader); @@ -21,7 +21,7 @@ SetTimeSettingsFactory::ReadResource(std::shared_ptr init return setTimeSettings; } -std::shared_ptr SetTimeSettingsFactoryXML::ReadResource(std::shared_ptr initData, +std::shared_ptr SetTimeSettingsFactoryXML::ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) { auto setTimeSettings = std::make_shared(initData); diff --git a/soh/soh/resource/importer/scenecommand/SetTimeSettingsFactory.h b/soh/soh/resource/importer/scenecommand/SetTimeSettingsFactory.h index ff3fdda379e..4b7b5c90f5c 100644 --- a/soh/soh/resource/importer/scenecommand/SetTimeSettingsFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetTimeSettingsFactory.h @@ -5,13 +5,13 @@ namespace SOH { class SetTimeSettingsFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; class SetTimeSettingsFactoryXML : public SceneCommandFactoryXMLV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; }; } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetTransitionActorListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetTransitionActorListFactory.cpp index 5bf1a114d1d..4289ef46ee8 100644 --- a/soh/soh/resource/importer/scenecommand/SetTransitionActorListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetTransitionActorListFactory.cpp @@ -4,8 +4,8 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr SetTransitionActorListFactory::ReadResource(std::shared_ptr initData, - std::shared_ptr reader) { +std::shared_ptr SetTransitionActorListFactory::ReadResource(std::shared_ptr initData, + std::shared_ptr reader) { auto setTransitionActorList = std::make_shared(initData); ReadCommandId(setTransitionActorList, reader); @@ -36,7 +36,7 @@ std::shared_ptr SetTransitionActorListFactory::ReadResource(std: return setTransitionActorList; } -std::shared_ptr SetTransitionActorListFactoryXML::ReadResource(std::shared_ptr initData, +std::shared_ptr SetTransitionActorListFactoryXML::ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) { auto setTransitionActorList = std::make_shared(initData); diff --git a/soh/soh/resource/importer/scenecommand/SetTransitionActorListFactory.h b/soh/soh/resource/importer/scenecommand/SetTransitionActorListFactory.h index eaeb2b5ec74..a3fc42f4160 100644 --- a/soh/soh/resource/importer/scenecommand/SetTransitionActorListFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetTransitionActorListFactory.h @@ -5,13 +5,13 @@ namespace SOH { class SetTransitionActorListFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; class SetTransitionActorListFactoryXML : public SceneCommandFactoryXMLV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; }; } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetWindSettingsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetWindSettingsFactory.cpp index 77991b12c2b..587e9dcc779 100644 --- a/soh/soh/resource/importer/scenecommand/SetWindSettingsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetWindSettingsFactory.cpp @@ -4,8 +4,8 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr -SetWindSettingsFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { +std::shared_ptr +SetWindSettingsFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { auto setWind = std::make_shared(initData); ReadCommandId(setWind, reader); @@ -22,7 +22,7 @@ SetWindSettingsFactory::ReadResource(std::shared_ptr init return setWind; } -std::shared_ptr SetWindSettingsFactoryXML::ReadResource(std::shared_ptr initData, +std::shared_ptr SetWindSettingsFactoryXML::ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) { auto setWind = std::make_shared(initData); diff --git a/soh/soh/resource/importer/scenecommand/SetWindSettingsFactory.h b/soh/soh/resource/importer/scenecommand/SetWindSettingsFactory.h index bab55dbd953..85381e5179d 100644 --- a/soh/soh/resource/importer/scenecommand/SetWindSettingsFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetWindSettingsFactory.h @@ -5,13 +5,13 @@ namespace SOH { class SetWindSettingsFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; class SetWindSettingsFactoryXML : public SceneCommandFactoryXMLV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, tinyxml2::XMLElement* reader) override; }; } // namespace SOH diff --git a/soh/soh/resource/logging/SceneCommandLoggers.cpp b/soh/soh/resource/logging/SceneCommandLoggers.cpp index b1eeb554daf..7c55bcaf057 100644 --- a/soh/soh/resource/logging/SceneCommandLoggers.cpp +++ b/soh/soh/resource/logging/SceneCommandLoggers.cpp @@ -27,7 +27,7 @@ namespace SOH { -void LogEndMarkerAsXML(std::shared_ptr resource) { +void LogEndMarkerAsXML(std::shared_ptr resource) { std::shared_ptr endMarker = std::static_pointer_cast(resource); tinyxml2::XMLDocument doc; @@ -40,7 +40,7 @@ void LogEndMarkerAsXML(std::shared_ptr resource) { SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr()); } -void LogActorListAsXML(std::shared_ptr resource) { +void LogActorListAsXML(std::shared_ptr resource) { std::shared_ptr setActorList = std::static_pointer_cast(resource); tinyxml2::XMLDocument doc; @@ -66,7 +66,7 @@ void LogActorListAsXML(std::shared_ptr resource) { SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr()); } -void LogAlternateHeadersAsXML(std::shared_ptr resource) { +void LogAlternateHeadersAsXML(std::shared_ptr resource) { std::shared_ptr setAlternateHeaders = std::static_pointer_cast(resource); tinyxml2::XMLDocument doc; @@ -79,7 +79,7 @@ void LogAlternateHeadersAsXML(std::shared_ptr resource) { SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr()); } -void LogCameraSettingsAsXML(std::shared_ptr resource) { +void LogCameraSettingsAsXML(std::shared_ptr resource) { std::shared_ptr setCameraSettings = std::static_pointer_cast(resource); tinyxml2::XMLDocument doc; @@ -95,7 +95,7 @@ void LogCameraSettingsAsXML(std::shared_ptr resource) { SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr()); } -void LogSetCollisionHeaderAsXML(std::shared_ptr resource) { +void LogSetCollisionHeaderAsXML(std::shared_ptr resource) { std::shared_ptr setCollisionHeader = std::static_pointer_cast(resource); tinyxml2::XMLDocument doc; @@ -110,7 +110,7 @@ void LogSetCollisionHeaderAsXML(std::shared_ptr resource) { SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr()); } -void LogCsCameraAsXML(std::shared_ptr resource) { +void LogCsCameraAsXML(std::shared_ptr resource) { std::shared_ptr setCsCamera = std::static_pointer_cast(resource); tinyxml2::XMLDocument doc; @@ -123,7 +123,7 @@ void LogCsCameraAsXML(std::shared_ptr resource) { SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr()); } -void LogCutscenesAsXML(std::shared_ptr resource) { +void LogCutscenesAsXML(std::shared_ptr resource) { std::shared_ptr setCutscenes = std::static_pointer_cast(resource); tinyxml2::XMLDocument doc; @@ -138,7 +138,7 @@ void LogCutscenesAsXML(std::shared_ptr resource) { SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr()); } -void LogEchoSettingsAsXML(std::shared_ptr resource) { +void LogEchoSettingsAsXML(std::shared_ptr resource) { std::shared_ptr setEchoSettings = std::static_pointer_cast(resource); tinyxml2::XMLDocument doc; @@ -153,7 +153,7 @@ void LogEchoSettingsAsXML(std::shared_ptr resource) { SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr()); } -void LogEntranceListAsXML(std::shared_ptr resource) { +void LogEntranceListAsXML(std::shared_ptr resource) { std::shared_ptr setEntranceList = std::static_pointer_cast(resource); tinyxml2::XMLDocument doc; @@ -173,7 +173,7 @@ void LogEntranceListAsXML(std::shared_ptr resource) { SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr()); } -void LogExitListAsXML(std::shared_ptr resource) { +void LogExitListAsXML(std::shared_ptr resource) { std::shared_ptr setExitList = std::static_pointer_cast(resource); tinyxml2::XMLDocument doc; @@ -192,7 +192,7 @@ void LogExitListAsXML(std::shared_ptr resource) { SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr()); } -void LogLightingSettingsAsXML(std::shared_ptr resource) { +void LogLightingSettingsAsXML(std::shared_ptr resource) { std::shared_ptr setLightingSettings = std::static_pointer_cast(resource); tinyxml2::XMLDocument doc; @@ -234,7 +234,7 @@ void LogLightingSettingsAsXML(std::shared_ptr resource) { SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr()); } -void LogLightListAsXML(std::shared_ptr resource) { +void LogLightListAsXML(std::shared_ptr resource) { std::shared_ptr setLightList = std::static_pointer_cast(resource); tinyxml2::XMLDocument doc; @@ -270,7 +270,7 @@ void LogLightListAsXML(std::shared_ptr resource) { SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr()); } -void LogMeshAsXML(std::shared_ptr resource) { +void LogMeshAsXML(std::shared_ptr resource) { std::shared_ptr setMesh = std::static_pointer_cast(resource); tinyxml2::XMLDocument doc; @@ -371,7 +371,7 @@ void LogMeshAsXML(std::shared_ptr resource) { SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr()); } -void LogObjectListAsXML(std::shared_ptr resource) { +void LogObjectListAsXML(std::shared_ptr resource) { std::shared_ptr setObjectList = std::static_pointer_cast(resource); tinyxml2::XMLDocument doc; @@ -390,7 +390,7 @@ void LogObjectListAsXML(std::shared_ptr resource) { SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr()); } -void LogPathwaysAsXML(std::shared_ptr resource) { +void LogPathwaysAsXML(std::shared_ptr resource) { std::shared_ptr setPathways = std::static_pointer_cast(resource); tinyxml2::XMLDocument doc; @@ -409,7 +409,7 @@ void LogPathwaysAsXML(std::shared_ptr resource) { SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr()); } -void LogRoomBehaviorAsXML(std::shared_ptr resource) { +void LogRoomBehaviorAsXML(std::shared_ptr resource) { std::shared_ptr setRoomBehavior = std::static_pointer_cast(resource); tinyxml2::XMLDocument doc; @@ -425,7 +425,7 @@ void LogRoomBehaviorAsXML(std::shared_ptr resource) { SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr()); } -void LogRoomListAsXML(std::shared_ptr resource) { +void LogRoomListAsXML(std::shared_ptr resource) { std::shared_ptr setRoomList = std::static_pointer_cast(resource); tinyxml2::XMLDocument doc; @@ -444,7 +444,7 @@ void LogRoomListAsXML(std::shared_ptr resource) { SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr()); } -void LogSkyboxModifierAsXML(std::shared_ptr resource) { +void LogSkyboxModifierAsXML(std::shared_ptr resource) { std::shared_ptr setSkyboxModifier = std::static_pointer_cast(resource); tinyxml2::XMLDocument doc; @@ -460,7 +460,7 @@ void LogSkyboxModifierAsXML(std::shared_ptr resource) { SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr()); } -void LogSkyboxSettingsAsXML(std::shared_ptr resource) { +void LogSkyboxSettingsAsXML(std::shared_ptr resource) { std::shared_ptr setSkyboxSettings = std::static_pointer_cast(resource); tinyxml2::XMLDocument doc; @@ -478,7 +478,7 @@ void LogSkyboxSettingsAsXML(std::shared_ptr resource) { SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr()); } -void LogSoundSettingsAsXML(std::shared_ptr resource) { +void LogSoundSettingsAsXML(std::shared_ptr resource) { std::shared_ptr setSoundSettings = std::static_pointer_cast(resource); tinyxml2::XMLDocument doc; @@ -495,7 +495,7 @@ void LogSoundSettingsAsXML(std::shared_ptr resource) { SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr()); } -void LogSpecialObjectsAsXML(std::shared_ptr resource) { +void LogSpecialObjectsAsXML(std::shared_ptr resource) { std::shared_ptr setSpecialObjects = std::static_pointer_cast(resource); tinyxml2::XMLDocument doc; @@ -511,7 +511,7 @@ void LogSpecialObjectsAsXML(std::shared_ptr resource) { SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr()); } -void LogStartPositionListAsXML(std::shared_ptr resource) { +void LogStartPositionListAsXML(std::shared_ptr resource) { std::shared_ptr setStartPositionList = std::static_pointer_cast(resource); tinyxml2::XMLDocument doc; @@ -537,7 +537,7 @@ void LogStartPositionListAsXML(std::shared_ptr resource) { SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr()); } -void LogTimeSettingsAsXML(std::shared_ptr resource) { +void LogTimeSettingsAsXML(std::shared_ptr resource) { std::shared_ptr setTimeSettings = std::static_pointer_cast(resource); tinyxml2::XMLDocument doc; @@ -554,7 +554,7 @@ void LogTimeSettingsAsXML(std::shared_ptr resource) { SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr()); } -void LogTransitionActorListAsXML(std::shared_ptr resource) { +void LogTransitionActorListAsXML(std::shared_ptr resource) { std::shared_ptr setTransitionActorList = std::static_pointer_cast(resource); tinyxml2::XMLDocument doc; @@ -582,7 +582,7 @@ void LogTransitionActorListAsXML(std::shared_ptr resource) { SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr()); } -void LogWindSettingsAsXML(std::shared_ptr resource) { +void LogWindSettingsAsXML(std::shared_ptr resource) { std::shared_ptr setWindSettings = std::static_pointer_cast(resource); tinyxml2::XMLDocument doc; diff --git a/soh/soh/resource/logging/SceneCommandLoggers.h b/soh/soh/resource/logging/SceneCommandLoggers.h index 1351a5c7787..f952ac766bd 100644 --- a/soh/soh/resource/logging/SceneCommandLoggers.h +++ b/soh/soh/resource/logging/SceneCommandLoggers.h @@ -3,30 +3,30 @@ namespace SOH { -void LogEndMarkerAsXML(std::shared_ptr resource); -void LogActorListAsXML(std::shared_ptr resource); -void LogAlternateHeadersAsXML(std::shared_ptr resource); -void LogCameraSettingsAsXML(std::shared_ptr resource); -void LogSetCollisionHeaderAsXML(std::shared_ptr resource); -void LogCsCameraAsXML(std::shared_ptr resource); -void LogCutscenesAsXML(std::shared_ptr resource); -void LogEchoSettingsAsXML(std::shared_ptr resource); -void LogEntranceListAsXML(std::shared_ptr resource); -void LogExitListAsXML(std::shared_ptr resource); -void LogLightingSettingsAsXML(std::shared_ptr resource); -void LogLightListAsXML(std::shared_ptr resource); -void LogMeshAsXML(std::shared_ptr resource); -void LogObjectListAsXML(std::shared_ptr resource); -void LogPathwaysAsXML(std::shared_ptr resource); -void LogRoomBehaviorAsXML(std::shared_ptr resource); -void LogRoomListAsXML(std::shared_ptr resource); -void LogSkyboxModifierAsXML(std::shared_ptr resource); -void LogSkyboxSettingsAsXML(std::shared_ptr resource); -void LogSoundSettingsAsXML(std::shared_ptr resource); -void LogSpecialObjectsAsXML(std::shared_ptr resource); -void LogStartPositionListAsXML(std::shared_ptr resource); -void LogTimeSettingsAsXML(std::shared_ptr resource); -void LogTransitionActorListAsXML(std::shared_ptr resource); -void LogWindSettingsAsXML(std::shared_ptr resource); +void LogEndMarkerAsXML(std::shared_ptr resource); +void LogActorListAsXML(std::shared_ptr resource); +void LogAlternateHeadersAsXML(std::shared_ptr resource); +void LogCameraSettingsAsXML(std::shared_ptr resource); +void LogSetCollisionHeaderAsXML(std::shared_ptr resource); +void LogCsCameraAsXML(std::shared_ptr resource); +void LogCutscenesAsXML(std::shared_ptr resource); +void LogEchoSettingsAsXML(std::shared_ptr resource); +void LogEntranceListAsXML(std::shared_ptr resource); +void LogExitListAsXML(std::shared_ptr resource); +void LogLightingSettingsAsXML(std::shared_ptr resource); +void LogLightListAsXML(std::shared_ptr resource); +void LogMeshAsXML(std::shared_ptr resource); +void LogObjectListAsXML(std::shared_ptr resource); +void LogPathwaysAsXML(std::shared_ptr resource); +void LogRoomBehaviorAsXML(std::shared_ptr resource); +void LogRoomListAsXML(std::shared_ptr resource); +void LogSkyboxModifierAsXML(std::shared_ptr resource); +void LogSkyboxSettingsAsXML(std::shared_ptr resource); +void LogSoundSettingsAsXML(std::shared_ptr resource); +void LogSpecialObjectsAsXML(std::shared_ptr resource); +void LogStartPositionListAsXML(std::shared_ptr resource); +void LogTimeSettingsAsXML(std::shared_ptr resource); +void LogTransitionActorListAsXML(std::shared_ptr resource); +void LogWindSettingsAsXML(std::shared_ptr resource); } //namespace SOH \ No newline at end of file diff --git a/soh/soh/resource/type/Animation.h b/soh/soh/resource/type/Animation.h index abd319d970e..bf249710790 100644 --- a/soh/soh/resource/type/Animation.h +++ b/soh/soh/resource/type/Animation.h @@ -63,11 +63,11 @@ LinkAnimationHeader linkAnimationHeader; TransformUpdateIndex transformUpdateIndex; }; -class Animation : public LUS::Resource { +class Animation : public Ship::Resource { public: using Resource::Resource; - Animation() : Resource(std::shared_ptr()) {} + Animation() : Resource(std::shared_ptr()) {} AnimationData* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/AudioSample.h b/soh/soh/resource/type/AudioSample.h index 4d6929c59f9..f3765909128 100644 --- a/soh/soh/resource/type/AudioSample.h +++ b/soh/soh/resource/type/AudioSample.h @@ -39,11 +39,11 @@ namespace SOH { s32 sampleRate; // For wav samples only... } Sample; // size = 0x10 - class AudioSample : public LUS::Resource { + class AudioSample : public Ship::Resource { public: using Resource::Resource; - AudioSample() : Resource(std::shared_ptr()) {} + AudioSample() : Resource(std::shared_ptr()) {} Sample* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/AudioSequence.h b/soh/soh/resource/type/AudioSequence.h index 457db624366..d7a8820a398 100644 --- a/soh/soh/resource/type/AudioSequence.h +++ b/soh/soh/resource/type/AudioSequence.h @@ -17,11 +17,11 @@ typedef struct { uint8_t fonts[16]; } Sequence; -class AudioSequence : public LUS::Resource { +class AudioSequence : public Ship::Resource { public: using Resource::Resource; - AudioSequence() : Resource(std::shared_ptr()) {} + AudioSequence() : Resource(std::shared_ptr()) {} Sequence* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/AudioSoundFont.h b/soh/soh/resource/type/AudioSoundFont.h index 11b899d3e53..12d66b2d244 100644 --- a/soh/soh/resource/type/AudioSoundFont.h +++ b/soh/soh/resource/type/AudioSoundFont.h @@ -52,11 +52,11 @@ typedef struct { s32 fntIndex; } SoundFont; // size = 0x14 -class AudioSoundFont : public LUS::Resource { +class AudioSoundFont : public Ship::Resource { public: using Resource::Resource; - AudioSoundFont() : Resource(std::shared_ptr()) {} + AudioSoundFont() : Resource(std::shared_ptr()) {} SoundFont* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/Background.h b/soh/soh/resource/type/Background.h index 9edc4b0d601..aa81edde4e9 100644 --- a/soh/soh/resource/type/Background.h +++ b/soh/soh/resource/type/Background.h @@ -3,11 +3,11 @@ #include "resource/Resource.h" namespace SOH { -class Background : public LUS::Resource { +class Background : public Ship::Resource { public: using Resource::Resource; - Background() : Resource(std::shared_ptr()) {} + Background() : Resource(std::shared_ptr()) {} uint8_t* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/CollisionHeader.h b/soh/soh/resource/type/CollisionHeader.h index e2ddf3f7a00..dba5994ce2f 100644 --- a/soh/soh/resource/type/CollisionHeader.h +++ b/soh/soh/resource/type/CollisionHeader.h @@ -67,11 +67,11 @@ typedef struct { size_t cameraDataListLen; // OTRTODO: Added to allow for bounds checking the cameraDataList. } CollisionHeaderData; // original name: BGDataInfo -class CollisionHeader : public LUS::Resource { +class CollisionHeader : public Ship::Resource { public: using Resource::Resource; - CollisionHeader() : Resource(std::shared_ptr()) {} + CollisionHeader() : Resource(std::shared_ptr()) {} CollisionHeaderData* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/Cutscene.h b/soh/soh/resource/type/Cutscene.h index c4d5fb0d505..664413d2dbf 100644 --- a/soh/soh/resource/type/Cutscene.h +++ b/soh/soh/resource/type/Cutscene.h @@ -41,11 +41,11 @@ enum class CutsceneCommands { Error = 0xFEAF, }; -class Cutscene : public LUS::Resource { +class Cutscene : public Ship::Resource { public: using Resource::Resource; - Cutscene() : Resource(std::shared_ptr()) {} + Cutscene() : Resource(std::shared_ptr()) {} uint32_t* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/Path.h b/soh/soh/resource/type/Path.h index c4078bed3f4..5adf683d32a 100644 --- a/soh/soh/resource/type/Path.h +++ b/soh/soh/resource/type/Path.h @@ -13,11 +13,11 @@ typedef struct { /* 0x04 */ Vec3s* points; // Segment Address to the array of points } PathData; // size = 0x8 -class Path : public LUS::Resource { +class Path : public Ship::Resource { public: using Resource::Resource; - Path() : Resource(std::shared_ptr()) {} + Path() : Resource(std::shared_ptr()) {} PathData* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/PlayerAnimation.h b/soh/soh/resource/type/PlayerAnimation.h index 416b3928c23..e44d30b1b47 100644 --- a/soh/soh/resource/type/PlayerAnimation.h +++ b/soh/soh/resource/type/PlayerAnimation.h @@ -5,11 +5,11 @@ #include "Resource.h" namespace SOH { -class PlayerAnimation : public LUS::Resource { +class PlayerAnimation : public Ship::Resource { public: using Resource::Resource; - PlayerAnimation() : Resource(std::shared_ptr()) {} + PlayerAnimation() : Resource(std::shared_ptr()) {} int16_t* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/Scene.h b/soh/soh/resource/type/Scene.h index 79ff69392e1..722c5184583 100644 --- a/soh/soh/resource/type/Scene.h +++ b/soh/soh/resource/type/Scene.h @@ -9,11 +9,11 @@ namespace SOH { -class Scene : public LUS::Resource { +class Scene : public Ship::Resource { public: using Resource::Resource; - Scene() : Resource(std::shared_ptr()) {} + Scene() : Resource(std::shared_ptr()) {} void* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/Skeleton.cpp b/soh/soh/resource/type/Skeleton.cpp index 39c28f53311..8abce78db80 100644 --- a/soh/soh/resource/type/Skeleton.cpp +++ b/soh/soh/resource/type/Skeleton.cpp @@ -36,9 +36,9 @@ void SkeletonPatcher::RegisterSkeleton(std::string& path, SkelAnime* skelAnime) } // Determine if we're using an alternate skeleton - if (path.starts_with(LUS::IResource::gAltAssetPrefix)) { - info.vanillaSkeletonPath = path.substr(LUS::IResource::gAltAssetPrefix.length(), - path.size() - LUS::IResource::gAltAssetPrefix.length()); + if (path.starts_with(Ship::IResource::gAltAssetPrefix)) { + info.vanillaSkeletonPath = path.substr(Ship::IResource::gAltAssetPrefix.length(), + path.size() - Ship::IResource::gAltAssetPrefix.length()); } else { info.vanillaSkeletonPath = path; } @@ -68,8 +68,8 @@ void SkeletonPatcher::UpdateSkeletons() { bool isHD = CVarGetInteger("gAltAssets", 0); for (auto skel : skeletons) { Skeleton* newSkel = - (Skeleton*)LUS::Context::GetInstance()->GetResourceManager() - ->LoadResource((isHD ? LUS::IResource::gAltAssetPrefix : "") + skel.vanillaSkeletonPath, true) + (Skeleton*)Ship::Context::GetInstance()->GetResourceManager() + ->LoadResource((isHD ? Ship::IResource::gAltAssetPrefix : "") + skel.vanillaSkeletonPath, true) .get(); if (newSkel != nullptr) { diff --git a/soh/soh/resource/type/Skeleton.h b/soh/soh/resource/type/Skeleton.h index 81aa90c6839..72d81c5a5aa 100644 --- a/soh/soh/resource/type/Skeleton.h +++ b/soh/soh/resource/type/Skeleton.h @@ -50,11 +50,11 @@ union SkeletonData { SkelCurveLimbList skelCurveLimbList; }; -class Skeleton : public LUS::Resource { +class Skeleton : public Ship::Resource { public: using Resource::Resource; - Skeleton() : Resource(std::shared_ptr()) {} + Skeleton() : Resource(std::shared_ptr()) {} SkeletonData* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/SkeletonLimb.h b/soh/soh/resource/type/SkeletonLimb.h index bae04092c35..04b815f05a3 100644 --- a/soh/soh/resource/type/SkeletonLimb.h +++ b/soh/soh/resource/type/SkeletonLimb.h @@ -97,11 +97,11 @@ union SkeletonLimbData { SkinLimb skinLimb; }; -class SkeletonLimb : public LUS::Resource { +class SkeletonLimb : public Ship::Resource { public: using Resource::Resource; - SkeletonLimb() : Resource(std::shared_ptr()) {} + SkeletonLimb() : Resource(std::shared_ptr()) {} SkeletonLimbData* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/Text.h b/soh/soh/resource/type/Text.h index 03cf7340b5e..1ad8c96634b 100644 --- a/soh/soh/resource/type/Text.h +++ b/soh/soh/resource/type/Text.h @@ -16,11 +16,11 @@ class MessageEntry std::string msg; }; -class Text : public LUS::Resource { +class Text : public Ship::Resource { public: using Resource::Resource; - Text() : Resource(std::shared_ptr()) {} + Text() : Resource(std::shared_ptr()) {} MessageEntry* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/scenecommand/SceneCommand.h b/soh/soh/resource/type/scenecommand/SceneCommand.h index 5eb44ae9da2..04216e09b6c 100644 --- a/soh/soh/resource/type/scenecommand/SceneCommand.h +++ b/soh/soh/resource/type/scenecommand/SceneCommand.h @@ -47,10 +47,10 @@ enum class SceneCommandID : uint8_t { Error = 0xFF }; -class ISceneCommand : public LUS::IResource { +class ISceneCommand : public Ship::IResource { public: using IResource::IResource; - ISceneCommand() : IResource(std::shared_ptr()) {} + ISceneCommand() : IResource(std::shared_ptr()) {} SceneCommandID cmdId; }; diff --git a/soh/soh/z_message_OTR.cpp b/soh/soh/z_message_OTR.cpp index 05432fc53d6..49e1e91c483 100644 --- a/soh/soh/z_message_OTR.cpp +++ b/soh/soh/z_message_OTR.cpp @@ -23,10 +23,10 @@ static void SetMessageEntry(MessageTableEntry& entry, const SOH::MessageEntry& m } static void OTRMessage_LoadCustom(const std::string& folderPath, MessageTableEntry*& table, size_t tableSize) { - auto lst = *LUS::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->ListFiles(folderPath).get(); + auto lst = *Ship::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->ListFiles(folderPath).get(); for (auto& tPath : lst) { - auto file = std::static_pointer_cast(LUS::Context::GetInstance()->GetResourceManager()->LoadResource(tPath)); + auto file = std::static_pointer_cast(Ship::Context::GetInstance()->GetResourceManager()->LoadResource(tPath)); for (size_t j = 0; j < file->messages.size(); ++j) { // Check if same text ID exists already @@ -43,7 +43,7 @@ static void OTRMessage_LoadCustom(const std::string& folderPath, MessageTableEnt } MessageTableEntry* OTRMessage_LoadTable(const std::string& filePath, bool isNES) { - auto file = std::static_pointer_cast(LUS::Context::GetInstance()->GetResourceManager()->LoadResource(filePath)); + auto file = std::static_pointer_cast(Ship::Context::GetInstance()->GetResourceManager()->LoadResource(filePath)); if (file == nullptr) return nullptr; @@ -120,7 +120,7 @@ extern "C" void OTRMessage_Init() if (sStaffMessageEntryTablePtr == NULL) { auto file2 = - std::static_pointer_cast(LUS::Context::GetInstance()->GetResourceManager()->LoadResource( + std::static_pointer_cast(Ship::Context::GetInstance()->GetResourceManager()->LoadResource( "text/staff_message_data_static/staff_message_data_static")); // OTRTODO: Should not be malloc'ing here. It's fine for now since we check that the message table is already null. sStaffMessageEntryTablePtr = (MessageTableEntry*)malloc(sizeof(MessageTableEntry) * file2->messages.size()); diff --git a/soh/soh/z_play_otr.cpp b/soh/soh/z_play_otr.cpp index 522a24eb836..ff485664d5c 100644 --- a/soh/soh/z_play_otr.cpp +++ b/soh/soh/z_play_otr.cpp @@ -13,9 +13,9 @@ void OTRPlay_InitScene(PlayState* play, s32 spawn); s32 OTRScene_ExecuteCommands(PlayState* play, SOH::Scene* scene); //LUS::OTRResource* OTRPlay_LoadFile(PlayState* play, RomFile* file) { -LUS::IResource* OTRPlay_LoadFile(PlayState* play, const char* fileName) +Ship::IResource* OTRPlay_LoadFile(PlayState* play, const char* fileName) { - auto res = LUS::Context::GetInstance()->GetResourceManager()->LoadResource(fileName); + auto res = Ship::Context::GetInstance()->GetResourceManager()->LoadResource(fileName); return res.get(); } @@ -81,7 +81,7 @@ void OTRPlay_InitScene(PlayState* play, s32 spawn) { if (IS_BOSS_RUSH && play->sceneNum != SCENE_CHAMBER_OF_THE_SAGES) { gSaveContext.isBossRushPaused = 0; } - /* auto data = static_cast(LUS::Context::GetInstance() + /* auto data = static_cast(Ship::Context::GetInstance() ->GetResourceManager() ->ResourceLoad("object_link_child\\object_link_childVtx_01FE08") .get()); diff --git a/soh/soh/z_scene_otr.cpp b/soh/soh/z_scene_otr.cpp index 0b9ba98f915..6c5ba67df2c 100644 --- a/soh/soh/z_scene_otr.cpp +++ b/soh/soh/z_scene_otr.cpp @@ -34,13 +34,13 @@ #include "soh/resource/type/scenecommand/SetEchoSettings.h" #include "soh/resource/type/scenecommand/SetAlternateHeaders.h" -extern LUS::IResource* OTRPlay_LoadFile(PlayState* play, const char* fileName); +extern Ship::IResource* OTRPlay_LoadFile(PlayState* play, const char* fileName); extern "C" s32 Object_Spawn(ObjectContext* objectCtx, s16 objectId); extern "C" RomFile sNaviMsgFiles[]; s32 OTRScene_ExecuteCommands(PlayState* play, SOH::Scene* scene); // Forward Declaration of function declared in OTRGlobals.cpp -std::shared_ptr GetResourceByNameHandlingMQ(const char* path); +std::shared_ptr GetResourceByNameHandlingMQ(const char* path); bool Scene_CommandSpawnList(PlayState* play, SOH::ISceneCommand* cmd) { // SOH::SetStartPositionList* cmdStartPos = std::static_pointer_cast(cmd); From 8b3f1f186859e01d24ef825c29cafd602ed83cc8 Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Mon, 29 Apr 2024 20:26:03 -0400 Subject: [PATCH 04/59] bump LUS, remove switch and wii u from CI (#4087) --- .github/workflows/generate-builds.yml | 130 -------------------------- libultraship | 2 +- 2 files changed, 1 insertion(+), 131 deletions(-) diff --git a/.github/workflows/generate-builds.yml b/.github/workflows/generate-builds.yml index 4b8153a077d..46e0abf53f2 100644 --- a/.github/workflows/generate-builds.yml +++ b/.github/workflows/generate-builds.yml @@ -241,136 +241,6 @@ jobs: path: | soh.appimage readme.txt - build-switch: - needs: generate-soh-otr - runs-on: ${{ (vars.LINUX_RUNNER && fromJSON(vars.LINUX_RUNNER)) || 'ubuntu-latest' }} - container: - image: devkitpro/devkita64:20240120 - steps: - - name: Install dependencies - run: | - sudo apt-get update - sudo apt-get install -y ninja-build - sudo apt-get remove -y cmake - wget https://github.com/Kitware/CMake/releases/download/v3.28.3/cmake-3.28.3-linux-x86_64.sh -O /tmp/cmake.sh - sudo sh /tmp/cmake.sh --prefix=/usr/local/ --exclude-subdir - wget https://libzip.org/download/libzip-1.10.1.tar.gz - tar -xzvf libzip-1.10.1.tar.gz - cd libzip-1.10.1 - mkdir build - cd build - cmake -H.. -B. -DCMAKE_TOOLCHAIN_FILE=/opt/devkitpro/cmake/Switch.cmake - make - make install - cd ../.. - wget https://github.com/nlohmann/json/archive/refs/tags/v3.11.3.tar.gz - tar -xzvf v3.11.3.tar.gz - cd json-3.11.3 - mkdir build - cd build - cmake -H.. -B. -DJSON_BuildTests=OFF -DCMAKE_TOOLCHAIN_FILE=/opt/devkitpro/cmake/Switch.cmake - make - make install - cd ../.. - - - name: Fix dubious ownership error - if: ${{ vars.LINUX_RUNNER }} - run: git config --global --add safe.directory '*' - - uses: actions/checkout@v3 - with: - submodules: true - - name: ccache - uses: hendrikmuhs/ccache-action@v1.2.11 - with: - key: ${{ runner.os }}-switch-ccache-${{ github.ref }}-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-switch-ccache-${{ github.ref }} - ${{ runner.os }}-switch-ccache- - - name: Build SoH - run: | - cmake -H. -Bbuild-switch -GNinja -DCMAKE_TOOLCHAIN_FILE=/opt/devkitpro/cmake/Switch.cmake -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_C_COMPILER_LAUNCHER=ccache - cmake --build build-switch --target soh_nro -j3 - - mv build-switch/soh/*.nro soh.nro - mv README.md readme.txt - - name: Download soh.otr - uses: actions/download-artifact@v4 - with: - name: soh.otr - - name: Upload build - uses: actions/upload-artifact@v4 - with: - name: soh-switch - path: | - soh.nro - soh.otr - readme.txt - build-wiiu: - needs: generate-soh-otr - runs-on: ${{ (vars.LINUX_RUNNER && fromJSON(vars.LINUX_RUNNER)) || 'ubuntu-latest' }} - container: - image: devkitpro/devkitppc:20230110 - steps: - - name: Install dependencies - if: ${{ !vars.LINUX_RUNNER }} - run: | - sudo apt-get install -y ninja-build - sudo apt-get remove -y cmake - wget https://github.com/Kitware/CMake/releases/download/v3.28.3/cmake-3.28.3-linux-x86_64.sh -O /tmp/cmake.sh - sudo sh /tmp/cmake.sh --prefix=/usr/local/ --exclude-subdir - wget https://libzip.org/download/libzip-1.10.1.tar.gz - tar -xzvf libzip-1.10.1.tar.gz - cd libzip-1.10.1 - mkdir build - cd build - cmake -H.. -B. -DCMAKE_TOOLCHAIN_FILE=/opt/devkitpro/cmake/WiiU.cmake - make - make install - cd ../.. - wget https://github.com/nlohmann/json/archive/refs/tags/v3.11.3.tar.gz - tar -xzvf v3.11.3.tar.gz - cd json-3.11.3 - mkdir build - cd build - cmake -H.. -B. -DJSON_BuildTests=OFF -DCMAKE_TOOLCHAIN_FILE=/opt/devkitpro/cmake/WiiU.cmake - make - make install - cd ../.. - - - uses: actions/checkout@v3 - with: - submodules: true - - name: ccache - uses: hendrikmuhs/ccache-action@v1.2.11 - with: - key: ${{ runner.os }}-wiiu-ccache-${{ github.ref }}-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-wiiu-ccache-${{ github.ref }} - ${{ runner.os }}-wiiu-ccache- - - name: Build SoH - run: | - cmake -H. -Bbuild-wiiu -GNinja -DCMAKE_TOOLCHAIN_FILE=/opt/devkitpro/cmake/WiiU.cmake -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_C_COMPILER_LAUNCHER=ccache - cmake --build build-wiiu --target soh_wuhb --config Release -j3 - - mv build-wiiu/soh/*.rpx soh.rpx - mv build-wiiu/soh/*.wuhb soh.wuhb - mv README.md readme.txt - env: - DEVKITPRO: /opt/devkitpro - DEVKITPPC: /opt/devkitpro/devkitPPC - - name: Download soh.otr - uses: actions/download-artifact@v4 - with: - name: soh.otr - - name: Upload build - uses: actions/upload-artifact@v4 - with: - name: soh-wiiu - path: | - soh.rpx - soh.wuhb - soh.otr - readme.txt build-windows: needs: generate-soh-otr runs-on: ${{ (vars.WINDOWS_RUNNER && fromJSON(vars.WINDOWS_RUNNER)) || 'windows-latest' }} diff --git a/libultraship b/libultraship index 6f978e0d237..3d2e6bc128a 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit 6f978e0d237530f304ba2018bbdc539b175c184a +Subproject commit 3d2e6bc128a105f0cba9109573a2401a8ba43f49 From 4ecb76b117ae135ea1487dc3cfd2a6898c8c2490 Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Tue, 30 Apr 2024 01:19:02 -0400 Subject: [PATCH 05/59] tinyxml from package manager (#4073) --- .github/workflows/apt-deps.txt | 2 +- .github/workflows/generate-builds.yml | 29 + .github/workflows/macports-deps.txt | 2 +- .github/workflows/test-builds-on-distros.yml | 1 + CMakeLists.txt | 2 +- libultraship | 2 +- .../randomizer/3drando/tinyxml2.cpp | 2956 ----------------- .../randomizer/3drando/tinyxml2.h | 2365 ------------- 8 files changed, 34 insertions(+), 5325 deletions(-) delete mode 100644 soh/soh/Enhancements/randomizer/3drando/tinyxml2.cpp delete mode 100644 soh/soh/Enhancements/randomizer/3drando/tinyxml2.h diff --git a/.github/workflows/apt-deps.txt b/.github/workflows/apt-deps.txt index af6f8aabd6a..62eba03865c 100644 --- a/.github/workflows/apt-deps.txt +++ b/.github/workflows/apt-deps.txt @@ -1 +1 @@ -libusb-dev libusb-1.0-0-dev libsdl2-dev libsdl2-net-dev libpng-dev libglew-dev libzip-dev zipcmp zipmerge ziptool nlohmann-json3-dev ninja-build +libusb-dev libusb-1.0-0-dev libsdl2-dev libsdl2-net-dev libpng-dev libglew-dev libzip-dev zipcmp zipmerge ziptool nlohmann-json3-dev libtinyxml2-dev ninja-build diff --git a/.github/workflows/generate-builds.yml b/.github/workflows/generate-builds.yml index 46e0abf53f2..5c1930ede5c 100644 --- a/.github/workflows/generate-builds.yml +++ b/.github/workflows/generate-builds.yml @@ -47,6 +47,20 @@ jobs: make -j 10 sudo make install sudo cp -av /usr/local/lib/libSDL* /lib/x86_64-linux-gnu/ + - name: Install latest tinyxml2 + run: | + sudo apt-get remove libtinyxml2-dev + export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" + if [ ! -d "tinyxml2-10.0.0" ]; then + wget https://github.com/leethomason/tinyxml2/archive/refs/tags/10.0.0.tar.gz + tar -xzf 10.0.0.tar.gz + fi + cd tinyxml2-10.0.0 + mkdir build + cd build + cmake .. + make + sudo make install - name: Generate soh.otr run: | export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" @@ -205,6 +219,21 @@ jobs: cmake .. make sudo make install + - name: Install latest tinyxml2 + if: ${{ (matrix.os == 'ubuntu-20.04' && !vars.LINUX_COMPATIBILITY_RUNNER) || (matrix.os == 'ubuntu-22.04' && !vars.LINUX_PERFORMANCE_RUNNER) }} + run: | + sudo apt-get remove libtinyxml2-dev + export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" + if [ ! -d "tinyxml2-10.0.0" ]; then + wget https://github.com/leethomason/tinyxml2/archive/refs/tags/10.0.0.tar.gz + tar -xzf 10.0.0.tar.gz + fi + cd tinyxml2-10.0.0 + mkdir build + cd build + cmake .. + make + sudo make install - name: Install latest SDL_net if: ${{ (matrix.os == 'ubuntu-20.04' && !vars.LINUX_COMPATIBILITY_RUNNER) || (matrix.os == 'ubuntu-22.04' && !vars.LINUX_PERFORMANCE_RUNNER) }} run: | diff --git a/.github/workflows/macports-deps.txt b/.github/workflows/macports-deps.txt index 96bb9d40a73..d150390781c 100644 --- a/.github/workflows/macports-deps.txt +++ b/.github/workflows/macports-deps.txt @@ -1 +1 @@ -libsdl2 +universal libsdl2_net +universal libpng +universal glew +universal libzip +universal nlohmann-json +universal \ No newline at end of file +libsdl2 +universal libsdl2_net +universal libpng +universal glew +universal libzip +universal nlohmann-json +universal tinyxml2 +universal \ No newline at end of file diff --git a/.github/workflows/test-builds-on-distros.yml b/.github/workflows/test-builds-on-distros.yml index 82709d1af10..683e07b240f 100644 --- a/.github/workflows/test-builds-on-distros.yml +++ b/.github/workflows/test-builds-on-distros.yml @@ -1,5 +1,6 @@ # todo: # nlohmann +# tinyxml2 name: test-builds-on-distros on: diff --git a/CMakeLists.txt b/CMakeLists.txt index 386142065c0..34fe61b6548 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,7 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Windows") set(VCPKG_TARGET_TRIPLET x64-windows-static) vcpkg_bootstrap() - vcpkg_install_packages(zlib bzip2 libzip libpng sdl2 sdl2-net glew glfw3 nlohmann-json) + vcpkg_install_packages(zlib bzip2 libzip libpng sdl2 sdl2-net glew glfw3 nlohmann-json tinyxml2) if (CMAKE_C_COMPILER_LAUNCHER MATCHES "ccache|sccache") set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT Embedded) diff --git a/libultraship b/libultraship index 3d2e6bc128a..6c375a8b5eb 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit 3d2e6bc128a105f0cba9109573a2401a8ba43f49 +Subproject commit 6c375a8b5eb8c44088b5bb2b472d40c50ad36d1f diff --git a/soh/soh/Enhancements/randomizer/3drando/tinyxml2.cpp b/soh/soh/Enhancements/randomizer/3drando/tinyxml2.cpp deleted file mode 100644 index 3187ad558f9..00000000000 --- a/soh/soh/Enhancements/randomizer/3drando/tinyxml2.cpp +++ /dev/null @@ -1,2956 +0,0 @@ -/* -Original code by Lee Thomason (www.grinninglizard.com) - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any -damages arising from the use of this software. - -Permission is granted to anyone to use this software for any -purpose, including commercial applications, and to alter it and -redistribute it freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must -not claim that you wrote the original software. If you use this -software in a product, an acknowledgment in the product documentation -would be appreciated but is not required. - -2. Altered source versions must be plainly marked as such, and -must not be misrepresented as being the original software. - -3. This notice may not be removed or altered from any source -distribution. -*/ - -#include "tinyxml2.h" - -#include // yes, this one new style header, is in the Android SDK. -#if defined(ANDROID_NDK) || defined(__BORLANDC__) || defined(__QNXNTO__) -# include -# include -#else -# include -# include -#endif - -#if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (!defined WINCE) - // Microsoft Visual Studio, version 2005 and higher. Not WinCE. - /*int _snprintf_s( - char *buffer, - size_t sizeOfBuffer, - size_t count, - const char *format [, - argument] ... - );*/ - static inline int TIXML_SNPRINTF( char* buffer, size_t size, const char* format, ... ) - { - va_list va; - va_start( va, format ); - const int result = vsnprintf_s( buffer, size, _TRUNCATE, format, va ); - va_end( va ); - return result; - } - - static inline int TIXML_VSNPRINTF( char* buffer, size_t size, const char* format, va_list va ) - { - const int result = vsnprintf_s( buffer, size, _TRUNCATE, format, va ); - return result; - } - - #define TIXML_VSCPRINTF _vscprintf - #define TIXML_SSCANF sscanf_s -#elif defined _MSC_VER - // Microsoft Visual Studio 2003 and earlier or WinCE - #define TIXML_SNPRINTF _snprintf - #define TIXML_VSNPRINTF _vsnprintf - #define TIXML_SSCANF sscanf - #if (_MSC_VER < 1400 ) && (!defined WINCE) - // Microsoft Visual Studio 2003 and not WinCE. - #define TIXML_VSCPRINTF _vscprintf // VS2003's C runtime has this, but VC6 C runtime or WinCE SDK doesn't have. - #else - // Microsoft Visual Studio 2003 and earlier or WinCE. - static inline int TIXML_VSCPRINTF( const char* format, va_list va ) - { - int len = 512; - for (;;) { - len = len*2; - char* str = new char[len](); - const int required = _vsnprintf(str, len, format, va); - delete[] str; - if ( required != -1 ) { - TIXMLASSERT( required >= 0 ); - len = required; - break; - } - } - TIXMLASSERT( len >= 0 ); - return len; - } - #endif -#else - // GCC version 3 and higher - //#warning( "Using sn* functions." ) - #define TIXML_SNPRINTF snprintf - #define TIXML_VSNPRINTF vsnprintf - static inline int TIXML_VSCPRINTF( const char* format, va_list va ) - { - int len = vsnprintf( 0, 0, format, va ); - TIXMLASSERT( len >= 0 ); - return len; - } - #define TIXML_SSCANF sscanf -#endif - - -static const char LINE_FEED = static_cast(0x0a); // all line endings are normalized to LF -static const char LF = LINE_FEED; -static const char CARRIAGE_RETURN = static_cast(0x0d); // CR gets filtered out -static const char CR = CARRIAGE_RETURN; -static const char SINGLE_QUOTE = '\''; -static const char DOUBLE_QUOTE = '\"'; - -// Bunch of unicode info at: -// http://www.unicode.org/faq/utf_bom.html -// ef bb bf (Microsoft "lead bytes") - designates UTF-8 - -static const unsigned char TIXML_UTF_LEAD_0 = 0xefU; -static const unsigned char TIXML_UTF_LEAD_1 = 0xbbU; -static const unsigned char TIXML_UTF_LEAD_2 = 0xbfU; - -namespace tinyxml2 -{ - -struct Entity { - const char* pattern; - int length; - char value; -}; - -static const int NUM_ENTITIES = 5; -static const Entity entities[NUM_ENTITIES] = { - { "quot", 4, DOUBLE_QUOTE }, - { "amp", 3, '&' }, - { "apos", 4, SINGLE_QUOTE }, - { "lt", 2, '<' }, - { "gt", 2, '>' } -}; - - -StrPair::~StrPair() -{ - Reset(); -} - - -void StrPair::TransferTo( StrPair* other ) -{ - if ( this == other ) { - return; - } - // This in effect implements the assignment operator by "moving" - // ownership (as in auto_ptr). - - TIXMLASSERT( other != 0 ); - TIXMLASSERT( other->_flags == 0 ); - TIXMLASSERT( other->_start == 0 ); - TIXMLASSERT( other->_end == 0 ); - - other->Reset(); - - other->_flags = _flags; - other->_start = _start; - other->_end = _end; - - _flags = 0; - _start = 0; - _end = 0; -} - - -void StrPair::Reset() -{ - if ( _flags & NEEDS_DELETE ) { - delete [] _start; - } - _flags = 0; - _start = 0; - _end = 0; -} - - -void StrPair::SetStr( const char* str, int flags ) -{ - TIXMLASSERT( str ); - Reset(); - size_t len = strlen( str ); - TIXMLASSERT( _start == 0 ); - _start = new char[ len+1 ]; - memcpy( _start, str, len+1 ); - _end = _start + len; - _flags = flags | NEEDS_DELETE; -} - - -char* StrPair::ParseText( char* p, const char* endTag, int strFlags, int* curLineNumPtr ) -{ - TIXMLASSERT( p ); - TIXMLASSERT( endTag && *endTag ); - TIXMLASSERT(curLineNumPtr); - - char* start = p; - const char endChar = *endTag; - size_t length = strlen( endTag ); - - // Inner loop of text parsing. - while ( *p ) { - if ( *p == endChar && strncmp( p, endTag, length ) == 0 ) { - Set( start, p, strFlags ); - return p + length; - } else if (*p == '\n') { - ++(*curLineNumPtr); - } - ++p; - TIXMLASSERT( p ); - } - return 0; -} - - -char* StrPair::ParseName( char* p ) -{ - if ( !p || !(*p) ) { - return 0; - } - if ( !XMLUtil::IsNameStartChar( *p ) ) { - return 0; - } - - char* const start = p; - ++p; - while ( *p && XMLUtil::IsNameChar( *p ) ) { - ++p; - } - - Set( start, p, 0 ); - return p; -} - - -void StrPair::CollapseWhitespace() -{ - // Adjusting _start would cause undefined behavior on delete[] - TIXMLASSERT( ( _flags & NEEDS_DELETE ) == 0 ); - // Trim leading space. - _start = XMLUtil::SkipWhiteSpace( _start, 0 ); - - if ( *_start ) { - const char* p = _start; // the read pointer - char* q = _start; // the write pointer - - while( *p ) { - if ( XMLUtil::IsWhiteSpace( *p )) { - p = XMLUtil::SkipWhiteSpace( p, 0 ); - if ( *p == 0 ) { - break; // don't write to q; this trims the trailing space. - } - *q = ' '; - ++q; - } - *q = *p; - ++q; - ++p; - } - *q = 0; - } -} - - -const char* StrPair::GetStr() -{ - TIXMLASSERT( _start ); - TIXMLASSERT( _end ); - if ( _flags & NEEDS_FLUSH ) { - *_end = 0; - _flags ^= NEEDS_FLUSH; - - if ( _flags ) { - const char* p = _start; // the read pointer - char* q = _start; // the write pointer - - while( p < _end ) { - if ( (_flags & NEEDS_NEWLINE_NORMALIZATION) && *p == CR ) { - // CR-LF pair becomes LF - // CR alone becomes LF - // LF-CR becomes LF - if ( *(p+1) == LF ) { - p += 2; - } - else { - ++p; - } - *q = LF; - ++q; - } - else if ( (_flags & NEEDS_NEWLINE_NORMALIZATION) && *p == LF ) { - if ( *(p+1) == CR ) { - p += 2; - } - else { - ++p; - } - *q = LF; - ++q; - } - else if ( (_flags & NEEDS_ENTITY_PROCESSING) && *p == '&' ) { - // Entities handled by tinyXML2: - // - special entities in the entity table [in/out] - // - numeric character reference [in] - // 中 or 中 - - if ( *(p+1) == '#' ) { - const int buflen = 10; - char buf[buflen] = { 0 }; - int len = 0; - const char* adjusted = const_cast( XMLUtil::GetCharacterRef( p, buf, &len ) ); - if ( adjusted == 0 ) { - *q = *p; - ++p; - ++q; - } - else { - TIXMLASSERT( 0 <= len && len <= buflen ); - TIXMLASSERT( q + len <= adjusted ); - p = adjusted; - memcpy( q, buf, len ); - q += len; - } - } - else { - bool entityFound = false; - for( int i = 0; i < NUM_ENTITIES; ++i ) { - const Entity& entity = entities[i]; - if ( strncmp( p + 1, entity.pattern, entity.length ) == 0 - && *( p + entity.length + 1 ) == ';' ) { - // Found an entity - convert. - *q = entity.value; - ++q; - p += entity.length + 2; - entityFound = true; - break; - } - } - if ( !entityFound ) { - // fixme: treat as error? - ++p; - ++q; - } - } - } - else { - *q = *p; - ++p; - ++q; - } - } - *q = 0; - } - // The loop below has plenty going on, and this - // is a less useful mode. Break it out. - if ( _flags & NEEDS_WHITESPACE_COLLAPSING ) { - CollapseWhitespace(); - } - _flags = (_flags & NEEDS_DELETE); - } - TIXMLASSERT( _start ); - return _start; -} - - - - -// --------- XMLUtil ----------- // - -const char* XMLUtil::writeBoolTrue = "true"; -const char* XMLUtil::writeBoolFalse = "false"; - -void XMLUtil::SetBoolSerialization(const char* writeTrue, const char* writeFalse) -{ - static const char* defTrue = "true"; - static const char* defFalse = "false"; - - writeBoolTrue = (writeTrue) ? writeTrue : defTrue; - writeBoolFalse = (writeFalse) ? writeFalse : defFalse; -} - - -const char* XMLUtil::ReadBOM( const char* p, bool* bom ) -{ - TIXMLASSERT( p ); - TIXMLASSERT( bom ); - *bom = false; - const unsigned char* pu = reinterpret_cast(p); - // Check for BOM: - if ( *(pu+0) == TIXML_UTF_LEAD_0 - && *(pu+1) == TIXML_UTF_LEAD_1 - && *(pu+2) == TIXML_UTF_LEAD_2 ) { - *bom = true; - p += 3; - } - TIXMLASSERT( p ); - return p; -} - - -void XMLUtil::ConvertUTF32ToUTF8( unsigned long input, char* output, int* length ) -{ - const unsigned long BYTE_MASK = 0xBF; - const unsigned long BYTE_MARK = 0x80; - const unsigned long FIRST_BYTE_MARK[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; - - if (input < 0x80) { - *length = 1; - } - else if ( input < 0x800 ) { - *length = 2; - } - else if ( input < 0x10000 ) { - *length = 3; - } - else if ( input < 0x200000 ) { - *length = 4; - } - else { - *length = 0; // This code won't convert this correctly anyway. - return; - } - - output += *length; - - // Scary scary fall throughs are annotated with carefully designed comments - // to suppress compiler warnings such as -Wimplicit-fallthrough in gcc - switch (*length) { - case 4: - --output; - *output = static_cast((input | BYTE_MARK) & BYTE_MASK); - input >>= 6; - //fall through - case 3: - --output; - *output = static_cast((input | BYTE_MARK) & BYTE_MASK); - input >>= 6; - //fall through - case 2: - --output; - *output = static_cast((input | BYTE_MARK) & BYTE_MASK); - input >>= 6; - //fall through - case 1: - --output; - *output = static_cast(input | FIRST_BYTE_MARK[*length]); - break; - default: - TIXMLASSERT( false ); - } -} - - -const char* XMLUtil::GetCharacterRef( const char* p, char* value, int* length ) -{ - // Presume an entity, and pull it out. - *length = 0; - - if ( *(p+1) == '#' && *(p+2) ) { - unsigned long ucs = 0; - TIXMLASSERT( sizeof( ucs ) >= 4 ); - ptrdiff_t delta = 0; - unsigned mult = 1; - static const char SEMICOLON = ';'; - - if ( *(p+2) == 'x' ) { - // Hexadecimal. - const char* q = p+3; - if ( !(*q) ) { - return 0; - } - - q = strchr( q, SEMICOLON ); - - if ( !q ) { - return 0; - } - TIXMLASSERT( *q == SEMICOLON ); - - delta = q-p; - --q; - - while ( *q != 'x' ) { - unsigned int digit = 0; - - if ( *q >= '0' && *q <= '9' ) { - digit = *q - '0'; - } - else if ( *q >= 'a' && *q <= 'f' ) { - digit = *q - 'a' + 10; - } - else if ( *q >= 'A' && *q <= 'F' ) { - digit = *q - 'A' + 10; - } - else { - return 0; - } - TIXMLASSERT( digit < 16 ); - TIXMLASSERT( digit == 0 || mult <= UINT_MAX / digit ); - const unsigned int digitScaled = mult * digit; - TIXMLASSERT( ucs <= ULONG_MAX - digitScaled ); - ucs += digitScaled; - TIXMLASSERT( mult <= UINT_MAX / 16 ); - mult *= 16; - --q; - } - } - else { - // Decimal. - const char* q = p+2; - if ( !(*q) ) { - return 0; - } - - q = strchr( q, SEMICOLON ); - - if ( !q ) { - return 0; - } - TIXMLASSERT( *q == SEMICOLON ); - - delta = q-p; - --q; - - while ( *q != '#' ) { - if ( *q >= '0' && *q <= '9' ) { - const unsigned int digit = *q - '0'; - TIXMLASSERT( digit < 10 ); - TIXMLASSERT( digit == 0 || mult <= UINT_MAX / digit ); - const unsigned int digitScaled = mult * digit; - TIXMLASSERT( ucs <= ULONG_MAX - digitScaled ); - ucs += digitScaled; - } - else { - return 0; - } - TIXMLASSERT( mult <= UINT_MAX / 10 ); - mult *= 10; - --q; - } - } - // convert the UCS to UTF-8 - ConvertUTF32ToUTF8( ucs, value, length ); - return p + delta + 1; - } - return p+1; -} - - -void XMLUtil::ToStr( int v, char* buffer, int bufferSize ) -{ - TIXML_SNPRINTF( buffer, bufferSize, "%d", v ); -} - - -void XMLUtil::ToStr( unsigned v, char* buffer, int bufferSize ) -{ - TIXML_SNPRINTF( buffer, bufferSize, "%u", v ); -} - - -void XMLUtil::ToStr( bool v, char* buffer, int bufferSize ) -{ - TIXML_SNPRINTF( buffer, bufferSize, "%s", v ? writeBoolTrue : writeBoolFalse); -} - -/* - ToStr() of a number is a very tricky topic. - https://github.com/leethomason/tinyxml2/issues/106 -*/ -void XMLUtil::ToStr( float v, char* buffer, int bufferSize ) -{ - TIXML_SNPRINTF( buffer, bufferSize, "%.8g", v ); -} - - -void XMLUtil::ToStr( double v, char* buffer, int bufferSize ) -{ - TIXML_SNPRINTF( buffer, bufferSize, "%.17g", v ); -} - - -void XMLUtil::ToStr( int64_t v, char* buffer, int bufferSize ) -{ - // horrible syntax trick to make the compiler happy about %lld - TIXML_SNPRINTF(buffer, bufferSize, "%lld", static_cast(v)); -} - -void XMLUtil::ToStr( uint64_t v, char* buffer, int bufferSize ) -{ - // horrible syntax trick to make the compiler happy about %llu - TIXML_SNPRINTF(buffer, bufferSize, "%llu", (long long)v); -} - -bool XMLUtil::ToInt( const char* str, int* value ) -{ - if ( TIXML_SSCANF( str, "%d", value ) == 1 ) { - return true; - } - return false; -} - -bool XMLUtil::ToUnsigned( const char* str, unsigned *value ) -{ - if ( TIXML_SSCANF( str, "%u", value ) == 1 ) { - return true; - } - return false; -} - -bool XMLUtil::ToBool( const char* str, bool* value ) -{ - int ival = 0; - if ( ToInt( str, &ival )) { - *value = (ival==0) ? false : true; - return true; - } - static const char* TRUE_VALS[] = { "true", "True", "TRUE", 0 }; - static const char* FALSE_VALS[] = { "false", "False", "FALSE", 0 }; - - for (int i = 0; TRUE_VALS[i]; ++i) { - if (StringEqual(str, TRUE_VALS[i])) { - *value = true; - return true; - } - } - for (int i = 0; FALSE_VALS[i]; ++i) { - if (StringEqual(str, FALSE_VALS[i])) { - *value = false; - return true; - } - } - return false; -} - - -bool XMLUtil::ToFloat( const char* str, float* value ) -{ - if ( TIXML_SSCANF( str, "%f", value ) == 1 ) { - return true; - } - return false; -} - - -bool XMLUtil::ToDouble( const char* str, double* value ) -{ - if ( TIXML_SSCANF( str, "%lf", value ) == 1 ) { - return true; - } - return false; -} - - -bool XMLUtil::ToInt64(const char* str, int64_t* value) -{ - long long v = 0; // horrible syntax trick to make the compiler happy about %lld - if (TIXML_SSCANF(str, "%lld", &v) == 1) { - *value = static_cast(v); - return true; - } - return false; -} - - -bool XMLUtil::ToUnsigned64(const char* str, uint64_t* value) { - unsigned long long v = 0; // horrible syntax trick to make the compiler happy about %llu - if(TIXML_SSCANF(str, "%llu", &v) == 1) { - *value = (uint64_t)v; - return true; - } - return false; -} - - -char* XMLDocument::Identify( char* p, XMLNode** node ) -{ - TIXMLASSERT( node ); - TIXMLASSERT( p ); - char* const start = p; - int const startLine = _parseCurLineNum; - p = XMLUtil::SkipWhiteSpace( p, &_parseCurLineNum ); - if( !*p ) { - *node = 0; - TIXMLASSERT( p ); - return p; - } - - // These strings define the matching patterns: - static const char* xmlHeader = { "( _commentPool ); - returnNode->_parseLineNum = _parseCurLineNum; - p += xmlHeaderLen; - } - else if ( XMLUtil::StringEqual( p, commentHeader, commentHeaderLen ) ) { - returnNode = CreateUnlinkedNode( _commentPool ); - returnNode->_parseLineNum = _parseCurLineNum; - p += commentHeaderLen; - } - else if ( XMLUtil::StringEqual( p, cdataHeader, cdataHeaderLen ) ) { - XMLText* text = CreateUnlinkedNode( _textPool ); - returnNode = text; - returnNode->_parseLineNum = _parseCurLineNum; - p += cdataHeaderLen; - text->SetCData( true ); - } - else if ( XMLUtil::StringEqual( p, dtdHeader, dtdHeaderLen ) ) { - returnNode = CreateUnlinkedNode( _commentPool ); - returnNode->_parseLineNum = _parseCurLineNum; - p += dtdHeaderLen; - } - else if ( XMLUtil::StringEqual( p, elementHeader, elementHeaderLen ) ) { - returnNode = CreateUnlinkedNode( _elementPool ); - returnNode->_parseLineNum = _parseCurLineNum; - p += elementHeaderLen; - } - else { - returnNode = CreateUnlinkedNode( _textPool ); - returnNode->_parseLineNum = _parseCurLineNum; // Report line of first non-whitespace character - p = start; // Back it up, all the text counts. - _parseCurLineNum = startLine; - } - - TIXMLASSERT( returnNode ); - TIXMLASSERT( p ); - *node = returnNode; - return p; -} - - -bool XMLDocument::Accept( XMLVisitor* visitor ) const -{ - TIXMLASSERT( visitor ); - if ( visitor->VisitEnter( *this ) ) { - for ( const XMLNode* node=FirstChild(); node; node=node->NextSibling() ) { - if ( !node->Accept( visitor ) ) { - break; - } - } - } - return visitor->VisitExit( *this ); -} - - -// --------- XMLNode ----------- // - -XMLNode::XMLNode( XMLDocument* doc ) : - _document( doc ), - _parent( 0 ), - _value(), - _parseLineNum( 0 ), - _firstChild( 0 ), _lastChild( 0 ), - _prev( 0 ), _next( 0 ), - _userData( 0 ), - _memPool( 0 ) -{ -} - - -XMLNode::~XMLNode() -{ - DeleteChildren(); - if ( _parent ) { - _parent->Unlink( this ); - } -} - -const char* XMLNode::Value() const -{ - // Edge case: XMLDocuments don't have a Value. Return null. - if ( this->ToDocument() ) - return 0; - return _value.GetStr(); -} - -void XMLNode::SetValue( const char* str, bool staticMem ) -{ - if ( staticMem ) { - _value.SetInternedStr( str ); - } - else { - _value.SetStr( str ); - } -} - -XMLNode* XMLNode::DeepClone(XMLDocument* target) const -{ - XMLNode* clone = this->ShallowClone(target); - if (!clone) return 0; - - for (const XMLNode* child = this->FirstChild(); child; child = child->NextSibling()) { - XMLNode* childClone = child->DeepClone(target); - TIXMLASSERT(childClone); - clone->InsertEndChild(childClone); - } - return clone; -} - -void XMLNode::DeleteChildren() -{ - while( _firstChild ) { - TIXMLASSERT( _lastChild ); - DeleteChild( _firstChild ); - } - _firstChild = _lastChild = 0; -} - - -void XMLNode::Unlink( XMLNode* child ) -{ - TIXMLASSERT( child ); - TIXMLASSERT( child->_document == _document ); - TIXMLASSERT( child->_parent == this ); - if ( child == _firstChild ) { - _firstChild = _firstChild->_next; - } - if ( child == _lastChild ) { - _lastChild = _lastChild->_prev; - } - - if ( child->_prev ) { - child->_prev->_next = child->_next; - } - if ( child->_next ) { - child->_next->_prev = child->_prev; - } - child->_next = 0; - child->_prev = 0; - child->_parent = 0; -} - - -void XMLNode::DeleteChild( XMLNode* node ) -{ - TIXMLASSERT( node ); - TIXMLASSERT( node->_document == _document ); - TIXMLASSERT( node->_parent == this ); - Unlink( node ); - TIXMLASSERT(node->_prev == 0); - TIXMLASSERT(node->_next == 0); - TIXMLASSERT(node->_parent == 0); - DeleteNode( node ); -} - - -XMLNode* XMLNode::InsertEndChild( XMLNode* addThis ) -{ - TIXMLASSERT( addThis ); - if ( addThis->_document != _document ) { - TIXMLASSERT( false ); - return 0; - } - InsertChildPreamble( addThis ); - - if ( _lastChild ) { - TIXMLASSERT( _firstChild ); - TIXMLASSERT( _lastChild->_next == 0 ); - _lastChild->_next = addThis; - addThis->_prev = _lastChild; - _lastChild = addThis; - - addThis->_next = 0; - } - else { - TIXMLASSERT( _firstChild == 0 ); - _firstChild = _lastChild = addThis; - - addThis->_prev = 0; - addThis->_next = 0; - } - addThis->_parent = this; - return addThis; -} - - -XMLNode* XMLNode::InsertFirstChild( XMLNode* addThis ) -{ - TIXMLASSERT( addThis ); - if ( addThis->_document != _document ) { - TIXMLASSERT( false ); - return 0; - } - InsertChildPreamble( addThis ); - - if ( _firstChild ) { - TIXMLASSERT( _lastChild ); - TIXMLASSERT( _firstChild->_prev == 0 ); - - _firstChild->_prev = addThis; - addThis->_next = _firstChild; - _firstChild = addThis; - - addThis->_prev = 0; - } - else { - TIXMLASSERT( _lastChild == 0 ); - _firstChild = _lastChild = addThis; - - addThis->_prev = 0; - addThis->_next = 0; - } - addThis->_parent = this; - return addThis; -} - - -XMLNode* XMLNode::InsertAfterChild( XMLNode* afterThis, XMLNode* addThis ) -{ - TIXMLASSERT( addThis ); - if ( addThis->_document != _document ) { - TIXMLASSERT( false ); - return 0; - } - - TIXMLASSERT( afterThis ); - - if ( afterThis->_parent != this ) { - TIXMLASSERT( false ); - return 0; - } - if ( afterThis == addThis ) { - // Current state: BeforeThis -> AddThis -> OneAfterAddThis - // Now AddThis must disappear from it's location and then - // reappear between BeforeThis and OneAfterAddThis. - // So just leave it where it is. - return addThis; - } - - if ( afterThis->_next == 0 ) { - // The last node or the only node. - return InsertEndChild( addThis ); - } - InsertChildPreamble( addThis ); - addThis->_prev = afterThis; - addThis->_next = afterThis->_next; - afterThis->_next->_prev = addThis; - afterThis->_next = addThis; - addThis->_parent = this; - return addThis; -} - - - - -const XMLElement* XMLNode::FirstChildElement( const char* name ) const -{ - for( const XMLNode* node = _firstChild; node; node = node->_next ) { - const XMLElement* element = node->ToElementWithName( name ); - if ( element ) { - return element; - } - } - return 0; -} - - -const XMLElement* XMLNode::LastChildElement( const char* name ) const -{ - for( const XMLNode* node = _lastChild; node; node = node->_prev ) { - const XMLElement* element = node->ToElementWithName( name ); - if ( element ) { - return element; - } - } - return 0; -} - - -const XMLElement* XMLNode::NextSiblingElement( const char* name ) const -{ - for( const XMLNode* node = _next; node; node = node->_next ) { - const XMLElement* element = node->ToElementWithName( name ); - if ( element ) { - return element; - } - } - return 0; -} - - -const XMLElement* XMLNode::PreviousSiblingElement( const char* name ) const -{ - for( const XMLNode* node = _prev; node; node = node->_prev ) { - const XMLElement* element = node->ToElementWithName( name ); - if ( element ) { - return element; - } - } - return 0; -} - - -char* XMLNode::ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr ) -{ - // This is a recursive method, but thinking about it "at the current level" - // it is a pretty simple flat list: - // - // - // - // With a special case: - // - // - // - // - // Where the closing element (/foo) *must* be the next thing after the opening - // element, and the names must match. BUT the tricky bit is that the closing - // element will be read by the child. - // - // 'endTag' is the end tag for this node, it is returned by a call to a child. - // 'parentEnd' is the end tag for the parent, which is filled in and returned. - - XMLDocument::DepthTracker tracker(_document); - if (_document->Error()) - return 0; - - while( p && *p ) { - XMLNode* node = 0; - - p = _document->Identify( p, &node ); - TIXMLASSERT( p ); - if ( node == 0 ) { - break; - } - - const int initialLineNum = node->_parseLineNum; - - StrPair endTag; - p = node->ParseDeep( p, &endTag, curLineNumPtr ); - if ( !p ) { - DeleteNode( node ); - if ( !_document->Error() ) { - _document->SetError( XML_ERROR_PARSING, initialLineNum, 0); - } - break; - } - - const XMLDeclaration* const decl = node->ToDeclaration(); - if ( decl ) { - // Declarations are only allowed at document level - // - // Multiple declarations are allowed but all declarations - // must occur before anything else. - // - // Optimized due to a security test case. If the first node is - // a declaration, and the last node is a declaration, then only - // declarations have so far been added. - bool wellLocated = false; - - if (ToDocument()) { - if (FirstChild()) { - wellLocated = - FirstChild() && - FirstChild()->ToDeclaration() && - LastChild() && - LastChild()->ToDeclaration(); - } - else { - wellLocated = true; - } - } - if ( !wellLocated ) { - _document->SetError( XML_ERROR_PARSING_DECLARATION, initialLineNum, "XMLDeclaration value=%s", decl->Value()); - DeleteNode( node ); - break; - } - } - - XMLElement* ele = node->ToElement(); - if ( ele ) { - // We read the end tag. Return it to the parent. - if ( ele->ClosingType() == XMLElement::CLOSING ) { - if ( parentEndTag ) { - ele->_value.TransferTo( parentEndTag ); - } - node->_memPool->SetTracked(); // created and then immediately deleted. - DeleteNode( node ); - return p; - } - - // Handle an end tag returned to this level. - // And handle a bunch of annoying errors. - bool mismatch = false; - if ( endTag.Empty() ) { - if ( ele->ClosingType() == XMLElement::OPEN ) { - mismatch = true; - } - } - else { - if ( ele->ClosingType() != XMLElement::OPEN ) { - mismatch = true; - } - else if ( !XMLUtil::StringEqual( endTag.GetStr(), ele->Name() ) ) { - mismatch = true; - } - } - if ( mismatch ) { - _document->SetError( XML_ERROR_MISMATCHED_ELEMENT, initialLineNum, "XMLElement name=%s", ele->Name()); - DeleteNode( node ); - break; - } - } - InsertEndChild( node ); - } - return 0; -} - -/*static*/ void XMLNode::DeleteNode( XMLNode* node ) -{ - if ( node == 0 ) { - return; - } - TIXMLASSERT(node->_document); - if (!node->ToDocument()) { - node->_document->MarkInUse(node); - } - - MemPool* pool = node->_memPool; - node->~XMLNode(); - pool->Free( node ); -} - -void XMLNode::InsertChildPreamble( XMLNode* insertThis ) const -{ - TIXMLASSERT( insertThis ); - TIXMLASSERT( insertThis->_document == _document ); - - if (insertThis->_parent) { - insertThis->_parent->Unlink( insertThis ); - } - else { - insertThis->_document->MarkInUse(insertThis); - insertThis->_memPool->SetTracked(); - } -} - -const XMLElement* XMLNode::ToElementWithName( const char* name ) const -{ - const XMLElement* element = this->ToElement(); - if ( element == 0 ) { - return 0; - } - if ( name == 0 ) { - return element; - } - if ( XMLUtil::StringEqual( element->Name(), name ) ) { - return element; - } - return 0; -} - -// --------- XMLText ---------- // -char* XMLText::ParseDeep( char* p, StrPair*, int* curLineNumPtr ) -{ - if ( this->CData() ) { - p = _value.ParseText( p, "]]>", StrPair::NEEDS_NEWLINE_NORMALIZATION, curLineNumPtr ); - if ( !p ) { - _document->SetError( XML_ERROR_PARSING_CDATA, _parseLineNum, 0 ); - } - return p; - } - else { - int flags = _document->ProcessEntities() ? StrPair::TEXT_ELEMENT : StrPair::TEXT_ELEMENT_LEAVE_ENTITIES; - if ( _document->WhitespaceMode() == COLLAPSE_WHITESPACE ) { - flags |= StrPair::NEEDS_WHITESPACE_COLLAPSING; - } - - p = _value.ParseText( p, "<", flags, curLineNumPtr ); - if ( p && *p ) { - return p-1; - } - if ( !p ) { - _document->SetError( XML_ERROR_PARSING_TEXT, _parseLineNum, 0 ); - } - } - return 0; -} - - -XMLNode* XMLText::ShallowClone( XMLDocument* doc ) const -{ - if ( !doc ) { - doc = _document; - } - XMLText* text = doc->NewText( Value() ); // fixme: this will always allocate memory. Intern? - text->SetCData( this->CData() ); - return text; -} - - -bool XMLText::ShallowEqual( const XMLNode* compare ) const -{ - TIXMLASSERT( compare ); - const XMLText* text = compare->ToText(); - return ( text && XMLUtil::StringEqual( text->Value(), Value() ) ); -} - - -bool XMLText::Accept( XMLVisitor* visitor ) const -{ - TIXMLASSERT( visitor ); - return visitor->Visit( *this ); -} - - -// --------- XMLComment ---------- // - -XMLComment::XMLComment( XMLDocument* doc ) : XMLNode( doc ) -{ -} - - -XMLComment::~XMLComment() -{ -} - - -char* XMLComment::ParseDeep( char* p, StrPair*, int* curLineNumPtr ) -{ - // Comment parses as text. - p = _value.ParseText( p, "-->", StrPair::COMMENT, curLineNumPtr ); - if ( p == 0 ) { - _document->SetError( XML_ERROR_PARSING_COMMENT, _parseLineNum, 0 ); - } - return p; -} - - -XMLNode* XMLComment::ShallowClone( XMLDocument* doc ) const -{ - if ( !doc ) { - doc = _document; - } - XMLComment* comment = doc->NewComment( Value() ); // fixme: this will always allocate memory. Intern? - return comment; -} - - -bool XMLComment::ShallowEqual( const XMLNode* compare ) const -{ - TIXMLASSERT( compare ); - const XMLComment* comment = compare->ToComment(); - return ( comment && XMLUtil::StringEqual( comment->Value(), Value() )); -} - - -bool XMLComment::Accept( XMLVisitor* visitor ) const -{ - TIXMLASSERT( visitor ); - return visitor->Visit( *this ); -} - - -// --------- XMLDeclaration ---------- // - -XMLDeclaration::XMLDeclaration( XMLDocument* doc ) : XMLNode( doc ) -{ -} - - -XMLDeclaration::~XMLDeclaration() -{ - //printf( "~XMLDeclaration\n" ); -} - - -char* XMLDeclaration::ParseDeep( char* p, StrPair*, int* curLineNumPtr ) -{ - // Declaration parses as text. - p = _value.ParseText( p, "?>", StrPair::NEEDS_NEWLINE_NORMALIZATION, curLineNumPtr ); - if ( p == 0 ) { - _document->SetError( XML_ERROR_PARSING_DECLARATION, _parseLineNum, 0 ); - } - return p; -} - - -XMLNode* XMLDeclaration::ShallowClone( XMLDocument* doc ) const -{ - if ( !doc ) { - doc = _document; - } - XMLDeclaration* dec = doc->NewDeclaration( Value() ); // fixme: this will always allocate memory. Intern? - return dec; -} - - -bool XMLDeclaration::ShallowEqual( const XMLNode* compare ) const -{ - TIXMLASSERT( compare ); - const XMLDeclaration* declaration = compare->ToDeclaration(); - return ( declaration && XMLUtil::StringEqual( declaration->Value(), Value() )); -} - - - -bool XMLDeclaration::Accept( XMLVisitor* visitor ) const -{ - TIXMLASSERT( visitor ); - return visitor->Visit( *this ); -} - -// --------- XMLUnknown ---------- // - -XMLUnknown::XMLUnknown( XMLDocument* doc ) : XMLNode( doc ) -{ -} - - -XMLUnknown::~XMLUnknown() -{ -} - - -char* XMLUnknown::ParseDeep( char* p, StrPair*, int* curLineNumPtr ) -{ - // Unknown parses as text. - p = _value.ParseText( p, ">", StrPair::NEEDS_NEWLINE_NORMALIZATION, curLineNumPtr ); - if ( !p ) { - _document->SetError( XML_ERROR_PARSING_UNKNOWN, _parseLineNum, 0 ); - } - return p; -} - - -XMLNode* XMLUnknown::ShallowClone( XMLDocument* doc ) const -{ - if ( !doc ) { - doc = _document; - } - XMLUnknown* text = doc->NewUnknown( Value() ); // fixme: this will always allocate memory. Intern? - return text; -} - - -bool XMLUnknown::ShallowEqual( const XMLNode* compare ) const -{ - TIXMLASSERT( compare ); - const XMLUnknown* unknown = compare->ToUnknown(); - return ( unknown && XMLUtil::StringEqual( unknown->Value(), Value() )); -} - - -bool XMLUnknown::Accept( XMLVisitor* visitor ) const -{ - TIXMLASSERT( visitor ); - return visitor->Visit( *this ); -} - -// --------- XMLAttribute ---------- // - -const char* XMLAttribute::Name() const -{ - return _name.GetStr(); -} - -const char* XMLAttribute::Value() const -{ - return _value.GetStr(); -} - -char* XMLAttribute::ParseDeep( char* p, bool processEntities, int* curLineNumPtr ) -{ - // Parse using the name rules: bug fix, was using ParseText before - p = _name.ParseName( p ); - if ( !p || !*p ) { - return 0; - } - - // Skip white space before = - p = XMLUtil::SkipWhiteSpace( p, curLineNumPtr ); - if ( *p != '=' ) { - return 0; - } - - ++p; // move up to opening quote - p = XMLUtil::SkipWhiteSpace( p, curLineNumPtr ); - if ( *p != '\"' && *p != '\'' ) { - return 0; - } - - const char endTag[2] = { *p, 0 }; - ++p; // move past opening quote - - p = _value.ParseText( p, endTag, processEntities ? StrPair::ATTRIBUTE_VALUE : StrPair::ATTRIBUTE_VALUE_LEAVE_ENTITIES, curLineNumPtr ); - return p; -} - - -void XMLAttribute::SetName( const char* n ) -{ - _name.SetStr( n ); -} - - -XMLError XMLAttribute::QueryIntValue( int* value ) const -{ - if ( XMLUtil::ToInt( Value(), value )) { - return XML_SUCCESS; - } - return XML_WRONG_ATTRIBUTE_TYPE; -} - - -XMLError XMLAttribute::QueryUnsignedValue( unsigned int* value ) const -{ - if ( XMLUtil::ToUnsigned( Value(), value )) { - return XML_SUCCESS; - } - return XML_WRONG_ATTRIBUTE_TYPE; -} - - -XMLError XMLAttribute::QueryInt64Value(int64_t* value) const -{ - if (XMLUtil::ToInt64(Value(), value)) { - return XML_SUCCESS; - } - return XML_WRONG_ATTRIBUTE_TYPE; -} - - -XMLError XMLAttribute::QueryUnsigned64Value(uint64_t* value) const -{ - if(XMLUtil::ToUnsigned64(Value(), value)) { - return XML_SUCCESS; - } - return XML_WRONG_ATTRIBUTE_TYPE; -} - - -XMLError XMLAttribute::QueryBoolValue( bool* value ) const -{ - if ( XMLUtil::ToBool( Value(), value )) { - return XML_SUCCESS; - } - return XML_WRONG_ATTRIBUTE_TYPE; -} - - -XMLError XMLAttribute::QueryFloatValue( float* value ) const -{ - if ( XMLUtil::ToFloat( Value(), value )) { - return XML_SUCCESS; - } - return XML_WRONG_ATTRIBUTE_TYPE; -} - - -XMLError XMLAttribute::QueryDoubleValue( double* value ) const -{ - if ( XMLUtil::ToDouble( Value(), value )) { - return XML_SUCCESS; - } - return XML_WRONG_ATTRIBUTE_TYPE; -} - - -void XMLAttribute::SetAttribute( const char* v ) -{ - _value.SetStr( v ); -} - - -void XMLAttribute::SetAttribute( int v ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( v, buf, BUF_SIZE ); - _value.SetStr( buf ); -} - - -void XMLAttribute::SetAttribute( unsigned v ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( v, buf, BUF_SIZE ); - _value.SetStr( buf ); -} - - -void XMLAttribute::SetAttribute(int64_t v) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr(v, buf, BUF_SIZE); - _value.SetStr(buf); -} - -void XMLAttribute::SetAttribute(uint64_t v) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr(v, buf, BUF_SIZE); - _value.SetStr(buf); -} - - -void XMLAttribute::SetAttribute( bool v ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( v, buf, BUF_SIZE ); - _value.SetStr( buf ); -} - -void XMLAttribute::SetAttribute( double v ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( v, buf, BUF_SIZE ); - _value.SetStr( buf ); -} - -void XMLAttribute::SetAttribute( float v ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( v, buf, BUF_SIZE ); - _value.SetStr( buf ); -} - - -// --------- XMLElement ---------- // -XMLElement::XMLElement( XMLDocument* doc ) : XMLNode( doc ), - _closingType( OPEN ), - _rootAttribute( 0 ) -{ -} - - -XMLElement::~XMLElement() -{ - while( _rootAttribute ) { - XMLAttribute* next = _rootAttribute->_next; - DeleteAttribute( _rootAttribute ); - _rootAttribute = next; - } -} - - -const XMLAttribute* XMLElement::FindAttribute( const char* name ) const -{ - for( XMLAttribute* a = _rootAttribute; a; a = a->_next ) { - if ( XMLUtil::StringEqual( a->Name(), name ) ) { - return a; - } - } - return 0; -} - - -const char* XMLElement::Attribute( const char* name, const char* value ) const -{ - const XMLAttribute* a = FindAttribute( name ); - if ( !a ) { - return 0; - } - if ( !value || XMLUtil::StringEqual( a->Value(), value )) { - return a->Value(); - } - return 0; -} - -int XMLElement::IntAttribute(const char* name, int defaultValue) const -{ - int i = defaultValue; - QueryIntAttribute(name, &i); - return i; -} - -unsigned XMLElement::UnsignedAttribute(const char* name, unsigned defaultValue) const -{ - unsigned i = defaultValue; - QueryUnsignedAttribute(name, &i); - return i; -} - -int64_t XMLElement::Int64Attribute(const char* name, int64_t defaultValue) const -{ - int64_t i = defaultValue; - QueryInt64Attribute(name, &i); - return i; -} - -uint64_t XMLElement::Unsigned64Attribute(const char* name, uint64_t defaultValue) const -{ - uint64_t i = defaultValue; - QueryUnsigned64Attribute(name, &i); - return i; -} - -bool XMLElement::BoolAttribute(const char* name, bool defaultValue) const -{ - bool b = defaultValue; - QueryBoolAttribute(name, &b); - return b; -} - -double XMLElement::DoubleAttribute(const char* name, double defaultValue) const -{ - double d = defaultValue; - QueryDoubleAttribute(name, &d); - return d; -} - -float XMLElement::FloatAttribute(const char* name, float defaultValue) const -{ - float f = defaultValue; - QueryFloatAttribute(name, &f); - return f; -} - -const char* XMLElement::GetText() const -{ - if ( FirstChild() && FirstChild()->ToText() ) { - return FirstChild()->Value(); - } - return 0; -} - - -void XMLElement::SetText( const char* inText ) -{ - if ( FirstChild() && FirstChild()->ToText() ) - FirstChild()->SetValue( inText ); - else { - XMLText* theText = GetDocument()->NewText( inText ); - InsertFirstChild( theText ); - } -} - - -void XMLElement::SetText( int v ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( v, buf, BUF_SIZE ); - SetText( buf ); -} - - -void XMLElement::SetText( unsigned v ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( v, buf, BUF_SIZE ); - SetText( buf ); -} - - -void XMLElement::SetText(int64_t v) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr(v, buf, BUF_SIZE); - SetText(buf); -} - -void XMLElement::SetText(uint64_t v) { - char buf[BUF_SIZE]; - XMLUtil::ToStr(v, buf, BUF_SIZE); - SetText(buf); -} - - -void XMLElement::SetText( bool v ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( v, buf, BUF_SIZE ); - SetText( buf ); -} - - -void XMLElement::SetText( float v ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( v, buf, BUF_SIZE ); - SetText( buf ); -} - - -void XMLElement::SetText( double v ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( v, buf, BUF_SIZE ); - SetText( buf ); -} - - -XMLError XMLElement::QueryIntText( int* ival ) const -{ - if ( FirstChild() && FirstChild()->ToText() ) { - const char* t = FirstChild()->Value(); - if ( XMLUtil::ToInt( t, ival ) ) { - return XML_SUCCESS; - } - return XML_CAN_NOT_CONVERT_TEXT; - } - return XML_NO_TEXT_NODE; -} - - -XMLError XMLElement::QueryUnsignedText( unsigned* uval ) const -{ - if ( FirstChild() && FirstChild()->ToText() ) { - const char* t = FirstChild()->Value(); - if ( XMLUtil::ToUnsigned( t, uval ) ) { - return XML_SUCCESS; - } - return XML_CAN_NOT_CONVERT_TEXT; - } - return XML_NO_TEXT_NODE; -} - - -XMLError XMLElement::QueryInt64Text(int64_t* ival) const -{ - if (FirstChild() && FirstChild()->ToText()) { - const char* t = FirstChild()->Value(); - if (XMLUtil::ToInt64(t, ival)) { - return XML_SUCCESS; - } - return XML_CAN_NOT_CONVERT_TEXT; - } - return XML_NO_TEXT_NODE; -} - - -XMLError XMLElement::QueryUnsigned64Text(uint64_t* ival) const -{ - if(FirstChild() && FirstChild()->ToText()) { - const char* t = FirstChild()->Value(); - if(XMLUtil::ToUnsigned64(t, ival)) { - return XML_SUCCESS; - } - return XML_CAN_NOT_CONVERT_TEXT; - } - return XML_NO_TEXT_NODE; -} - - -XMLError XMLElement::QueryBoolText( bool* bval ) const -{ - if ( FirstChild() && FirstChild()->ToText() ) { - const char* t = FirstChild()->Value(); - if ( XMLUtil::ToBool( t, bval ) ) { - return XML_SUCCESS; - } - return XML_CAN_NOT_CONVERT_TEXT; - } - return XML_NO_TEXT_NODE; -} - - -XMLError XMLElement::QueryDoubleText( double* dval ) const -{ - if ( FirstChild() && FirstChild()->ToText() ) { - const char* t = FirstChild()->Value(); - if ( XMLUtil::ToDouble( t, dval ) ) { - return XML_SUCCESS; - } - return XML_CAN_NOT_CONVERT_TEXT; - } - return XML_NO_TEXT_NODE; -} - - -XMLError XMLElement::QueryFloatText( float* fval ) const -{ - if ( FirstChild() && FirstChild()->ToText() ) { - const char* t = FirstChild()->Value(); - if ( XMLUtil::ToFloat( t, fval ) ) { - return XML_SUCCESS; - } - return XML_CAN_NOT_CONVERT_TEXT; - } - return XML_NO_TEXT_NODE; -} - -int XMLElement::IntText(int defaultValue) const -{ - int i = defaultValue; - QueryIntText(&i); - return i; -} - -unsigned XMLElement::UnsignedText(unsigned defaultValue) const -{ - unsigned i = defaultValue; - QueryUnsignedText(&i); - return i; -} - -int64_t XMLElement::Int64Text(int64_t defaultValue) const -{ - int64_t i = defaultValue; - QueryInt64Text(&i); - return i; -} - -uint64_t XMLElement::Unsigned64Text(uint64_t defaultValue) const -{ - uint64_t i = defaultValue; - QueryUnsigned64Text(&i); - return i; -} - -bool XMLElement::BoolText(bool defaultValue) const -{ - bool b = defaultValue; - QueryBoolText(&b); - return b; -} - -double XMLElement::DoubleText(double defaultValue) const -{ - double d = defaultValue; - QueryDoubleText(&d); - return d; -} - -float XMLElement::FloatText(float defaultValue) const -{ - float f = defaultValue; - QueryFloatText(&f); - return f; -} - - -XMLAttribute* XMLElement::FindOrCreateAttribute( const char* name ) -{ - XMLAttribute* last = 0; - XMLAttribute* attrib = 0; - for( attrib = _rootAttribute; - attrib; - last = attrib, attrib = attrib->_next ) { - if ( XMLUtil::StringEqual( attrib->Name(), name ) ) { - break; - } - } - if ( !attrib ) { - attrib = CreateAttribute(); - TIXMLASSERT( attrib ); - if ( last ) { - TIXMLASSERT( last->_next == 0 ); - last->_next = attrib; - } - else { - TIXMLASSERT( _rootAttribute == 0 ); - _rootAttribute = attrib; - } - attrib->SetName( name ); - } - return attrib; -} - - -void XMLElement::DeleteAttribute( const char* name ) -{ - XMLAttribute* prev = 0; - for( XMLAttribute* a=_rootAttribute; a; a=a->_next ) { - if ( XMLUtil::StringEqual( name, a->Name() ) ) { - if ( prev ) { - prev->_next = a->_next; - } - else { - _rootAttribute = a->_next; - } - DeleteAttribute( a ); - break; - } - prev = a; - } -} - - -char* XMLElement::ParseAttributes( char* p, int* curLineNumPtr ) -{ - XMLAttribute* prevAttribute = 0; - - // Read the attributes. - while( p ) { - p = XMLUtil::SkipWhiteSpace( p, curLineNumPtr ); - if ( !(*p) ) { - _document->SetError( XML_ERROR_PARSING_ELEMENT, _parseLineNum, "XMLElement name=%s", Name() ); - return 0; - } - - // attribute. - if (XMLUtil::IsNameStartChar( *p ) ) { - XMLAttribute* attrib = CreateAttribute(); - TIXMLASSERT( attrib ); - attrib->_parseLineNum = _document->_parseCurLineNum; - - const int attrLineNum = attrib->_parseLineNum; - - p = attrib->ParseDeep( p, _document->ProcessEntities(), curLineNumPtr ); - if ( !p || Attribute( attrib->Name() ) ) { - DeleteAttribute( attrib ); - _document->SetError( XML_ERROR_PARSING_ATTRIBUTE, attrLineNum, "XMLElement name=%s", Name() ); - return 0; - } - // There is a minor bug here: if the attribute in the source xml - // document is duplicated, it will not be detected and the - // attribute will be doubly added. However, tracking the 'prevAttribute' - // avoids re-scanning the attribute list. Preferring performance for - // now, may reconsider in the future. - if ( prevAttribute ) { - TIXMLASSERT( prevAttribute->_next == 0 ); - prevAttribute->_next = attrib; - } - else { - TIXMLASSERT( _rootAttribute == 0 ); - _rootAttribute = attrib; - } - prevAttribute = attrib; - } - // end of the tag - else if ( *p == '>' ) { - ++p; - break; - } - // end of the tag - else if ( *p == '/' && *(p+1) == '>' ) { - _closingType = CLOSED; - return p+2; // done; sealed element. - } - else { - _document->SetError( XML_ERROR_PARSING_ELEMENT, _parseLineNum, 0 ); - return 0; - } - } - return p; -} - -void XMLElement::DeleteAttribute( XMLAttribute* attribute ) -{ - if ( attribute == 0 ) { - return; - } - MemPool* pool = attribute->_memPool; - attribute->~XMLAttribute(); - pool->Free( attribute ); -} - -XMLAttribute* XMLElement::CreateAttribute() -{ - TIXMLASSERT( sizeof( XMLAttribute ) == _document->_attributePool.ItemSize() ); - XMLAttribute* attrib = new (_document->_attributePool.Alloc() ) XMLAttribute(); - TIXMLASSERT( attrib ); - attrib->_memPool = &_document->_attributePool; - attrib->_memPool->SetTracked(); - return attrib; -} - - -XMLElement* XMLElement::InsertNewChildElement(const char* name) -{ - XMLElement* node = _document->NewElement(name); - return InsertEndChild(node) ? node : 0; -} - -XMLComment* XMLElement::InsertNewComment(const char* comment) -{ - XMLComment* node = _document->NewComment(comment); - return InsertEndChild(node) ? node : 0; -} - -XMLText* XMLElement::InsertNewText(const char* text) -{ - XMLText* node = _document->NewText(text); - return InsertEndChild(node) ? node : 0; -} - -XMLDeclaration* XMLElement::InsertNewDeclaration(const char* text) -{ - XMLDeclaration* node = _document->NewDeclaration(text); - return InsertEndChild(node) ? node : 0; -} - -XMLUnknown* XMLElement::InsertNewUnknown(const char* text) -{ - XMLUnknown* node = _document->NewUnknown(text); - return InsertEndChild(node) ? node : 0; -} - - - -// -// -// foobar -// -char* XMLElement::ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr ) -{ - // Read the element name. - p = XMLUtil::SkipWhiteSpace( p, curLineNumPtr ); - - // The closing element is the form. It is - // parsed just like a regular element then deleted from - // the DOM. - if ( *p == '/' ) { - _closingType = CLOSING; - ++p; - } - - p = _value.ParseName( p ); - if ( _value.Empty() ) { - return 0; - } - - p = ParseAttributes( p, curLineNumPtr ); - if ( !p || !*p || _closingType != OPEN ) { - return p; - } - - p = XMLNode::ParseDeep( p, parentEndTag, curLineNumPtr ); - return p; -} - - - -XMLNode* XMLElement::ShallowClone( XMLDocument* doc ) const -{ - if ( !doc ) { - doc = _document; - } - XMLElement* element = doc->NewElement( Value() ); // fixme: this will always allocate memory. Intern? - for( const XMLAttribute* a=FirstAttribute(); a; a=a->Next() ) { - element->SetAttribute( a->Name(), a->Value() ); // fixme: this will always allocate memory. Intern? - } - return element; -} - - -bool XMLElement::ShallowEqual( const XMLNode* compare ) const -{ - TIXMLASSERT( compare ); - const XMLElement* other = compare->ToElement(); - if ( other && XMLUtil::StringEqual( other->Name(), Name() )) { - - const XMLAttribute* a=FirstAttribute(); - const XMLAttribute* b=other->FirstAttribute(); - - while ( a && b ) { - if ( !XMLUtil::StringEqual( a->Value(), b->Value() ) ) { - return false; - } - a = a->Next(); - b = b->Next(); - } - if ( a || b ) { - // different count - return false; - } - return true; - } - return false; -} - - -bool XMLElement::Accept( XMLVisitor* visitor ) const -{ - TIXMLASSERT( visitor ); - if ( visitor->VisitEnter( *this, _rootAttribute ) ) { - for ( const XMLNode* node=FirstChild(); node; node=node->NextSibling() ) { - if ( !node->Accept( visitor ) ) { - break; - } - } - } - return visitor->VisitExit( *this ); -} - - -// --------- XMLDocument ----------- // - -// Warning: List must match 'enum XMLError' -const char* XMLDocument::_errorNames[XML_ERROR_COUNT] = { - "XML_SUCCESS", - "XML_NO_ATTRIBUTE", - "XML_WRONG_ATTRIBUTE_TYPE", - "XML_ERROR_FILE_NOT_FOUND", - "XML_ERROR_FILE_COULD_NOT_BE_OPENED", - "XML_ERROR_FILE_READ_ERROR", - "XML_ERROR_PARSING_ELEMENT", - "XML_ERROR_PARSING_ATTRIBUTE", - "XML_ERROR_PARSING_TEXT", - "XML_ERROR_PARSING_CDATA", - "XML_ERROR_PARSING_COMMENT", - "XML_ERROR_PARSING_DECLARATION", - "XML_ERROR_PARSING_UNKNOWN", - "XML_ERROR_EMPTY_DOCUMENT", - "XML_ERROR_MISMATCHED_ELEMENT", - "XML_ERROR_PARSING", - "XML_CAN_NOT_CONVERT_TEXT", - "XML_NO_TEXT_NODE", - "XML_ELEMENT_DEPTH_EXCEEDED" -}; - - -XMLDocument::XMLDocument( bool processEntities, Whitespace whitespaceMode ) : - XMLNode( 0 ), - _writeBOM( false ), - _processEntities( processEntities ), - _errorID(XML_SUCCESS), - _whitespaceMode( whitespaceMode ), - _errorStr(), - _errorLineNum( 0 ), - _charBuffer( 0 ), - _parseCurLineNum( 0 ), - _parsingDepth(0), - _unlinked(), - _elementPool(), - _attributePool(), - _textPool(), - _commentPool() -{ - // avoid VC++ C4355 warning about 'this' in initializer list (C4355 is off by default in VS2012+) - _document = this; -} - - -XMLDocument::~XMLDocument() -{ - Clear(); -} - - -void XMLDocument::MarkInUse(const XMLNode* const node) -{ - TIXMLASSERT(node); - TIXMLASSERT(node->_parent == 0); - - for (int i = 0; i < _unlinked.Size(); ++i) { - if (node == _unlinked[i]) { - _unlinked.SwapRemove(i); - break; - } - } -} - -void XMLDocument::Clear() -{ - DeleteChildren(); - while( _unlinked.Size()) { - DeleteNode(_unlinked[0]); // Will remove from _unlinked as part of delete. - } - -#ifdef TINYXML2_DEBUG - const bool hadError = Error(); -#endif - ClearError(); - - delete [] _charBuffer; - _charBuffer = 0; - _parsingDepth = 0; - -#if 0 - _textPool.Trace( "text" ); - _elementPool.Trace( "element" ); - _commentPool.Trace( "comment" ); - _attributePool.Trace( "attribute" ); -#endif - -#ifdef TINYXML2_DEBUG - if ( !hadError ) { - TIXMLASSERT( _elementPool.CurrentAllocs() == _elementPool.Untracked() ); - TIXMLASSERT( _attributePool.CurrentAllocs() == _attributePool.Untracked() ); - TIXMLASSERT( _textPool.CurrentAllocs() == _textPool.Untracked() ); - TIXMLASSERT( _commentPool.CurrentAllocs() == _commentPool.Untracked() ); - } -#endif -} - - -void XMLDocument::DeepCopy(XMLDocument* target) const -{ - TIXMLASSERT(target); - if (target == this) { - return; // technically success - a no-op. - } - - target->Clear(); - for (const XMLNode* node = this->FirstChild(); node; node = node->NextSibling()) { - target->InsertEndChild(node->DeepClone(target)); - } -} - -XMLElement* XMLDocument::NewElement( const char* name ) -{ - XMLElement* ele = CreateUnlinkedNode( _elementPool ); - ele->SetName( name ); - return ele; -} - - -XMLComment* XMLDocument::NewComment( const char* str ) -{ - XMLComment* comment = CreateUnlinkedNode( _commentPool ); - comment->SetValue( str ); - return comment; -} - - -XMLText* XMLDocument::NewText( const char* str ) -{ - XMLText* text = CreateUnlinkedNode( _textPool ); - text->SetValue( str ); - return text; -} - - -XMLDeclaration* XMLDocument::NewDeclaration( const char* str ) -{ - XMLDeclaration* dec = CreateUnlinkedNode( _commentPool ); - dec->SetValue( str ? str : "xml version=\"1.0\" encoding=\"UTF-8\"" ); - return dec; -} - - -XMLUnknown* XMLDocument::NewUnknown( const char* str ) -{ - XMLUnknown* unk = CreateUnlinkedNode( _commentPool ); - unk->SetValue( str ); - return unk; -} - -static FILE* callfopen( const char* filepath, const char* mode ) -{ - TIXMLASSERT( filepath ); - TIXMLASSERT( mode ); -#if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (!defined WINCE) - FILE* fp = 0; - const errno_t err = fopen_s( &fp, filepath, mode ); - if ( err ) { - return 0; - } -#else - FILE* fp = fopen( filepath, mode ); -#endif - return fp; -} - -void XMLDocument::DeleteNode( XMLNode* node ) { - TIXMLASSERT( node ); - TIXMLASSERT(node->_document == this ); - if (node->_parent) { - node->_parent->DeleteChild( node ); - } - else { - // Isn't in the tree. - // Use the parent delete. - // Also, we need to mark it tracked: we 'know' - // it was never used. - node->_memPool->SetTracked(); - // Call the static XMLNode version: - XMLNode::DeleteNode(node); - } -} - - -XMLError XMLDocument::LoadFile( const char* filename ) -{ - if ( !filename ) { - TIXMLASSERT( false ); - SetError( XML_ERROR_FILE_COULD_NOT_BE_OPENED, 0, "filename=" ); - return _errorID; - } - - Clear(); - FILE* fp = callfopen( filename, "rb" ); - if ( !fp ) { - SetError( XML_ERROR_FILE_NOT_FOUND, 0, "filename=%s", filename ); - return _errorID; - } - LoadFile( fp ); - fclose( fp ); - return _errorID; -} - -// This is likely overengineered template art to have a check that unsigned long value incremented -// by one still fits into size_t. If size_t type is larger than unsigned long type -// (x86_64-w64-mingw32 target) then the check is redundant and gcc and clang emit -// -Wtype-limits warning. This piece makes the compiler select code with a check when a check -// is useful and code with no check when a check is redundant depending on how size_t and unsigned long -// types sizes relate to each other. -template -= sizeof(size_t))> -struct LongFitsIntoSizeTMinusOne { - static bool Fits( unsigned long value ) - { - return value < static_cast(-1); - } -}; - -template <> -struct LongFitsIntoSizeTMinusOne { - static bool Fits( unsigned long ) - { - return true; - } -}; - -XMLError XMLDocument::LoadFile( FILE* fp ) -{ - Clear(); - - fseek( fp, 0, SEEK_SET ); - if ( fgetc( fp ) == EOF && ferror( fp ) != 0 ) { - SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 ); - return _errorID; - } - - fseek( fp, 0, SEEK_END ); - const long filelength = ftell( fp ); - fseek( fp, 0, SEEK_SET ); - if ( filelength == -1L ) { - SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 ); - return _errorID; - } - TIXMLASSERT( filelength >= 0 ); - - if ( !LongFitsIntoSizeTMinusOne<>::Fits( filelength ) ) { - // Cannot handle files which won't fit in buffer together with null terminator - SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 ); - return _errorID; - } - - if ( filelength == 0 ) { - SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 ); - return _errorID; - } - - const size_t size = filelength; - TIXMLASSERT( _charBuffer == 0 ); - _charBuffer = new char[size+1]; - const size_t read = fread( _charBuffer, 1, size, fp ); - if ( read != size ) { - SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 ); - return _errorID; - } - - _charBuffer[size] = 0; - - Parse(); - return _errorID; -} - - -XMLError XMLDocument::SaveFile( const char* filename, bool compact ) -{ - if ( !filename ) { - TIXMLASSERT( false ); - SetError( XML_ERROR_FILE_COULD_NOT_BE_OPENED, 0, "filename=" ); - return _errorID; - } - - FILE* fp = callfopen( filename, "w" ); - if ( !fp ) { - SetError( XML_ERROR_FILE_COULD_NOT_BE_OPENED, 0, "filename=%s", filename ); - return _errorID; - } - SaveFile(fp, compact); - fclose( fp ); - return _errorID; -} - - -XMLError XMLDocument::SaveFile( FILE* fp, bool compact ) -{ - // Clear any error from the last save, otherwise it will get reported - // for *this* call. - ClearError(); - XMLPrinter stream( fp, compact ); - Print( &stream ); - return _errorID; -} - - -XMLError XMLDocument::Parse( const char* p, size_t len ) -{ - Clear(); - - if ( len == 0 || !p || !*p ) { - SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 ); - return _errorID; - } - if ( len == static_cast(-1) ) { - len = strlen( p ); - } - TIXMLASSERT( _charBuffer == 0 ); - _charBuffer = new char[ len+1 ]; - memcpy( _charBuffer, p, len ); - _charBuffer[len] = 0; - - Parse(); - if ( Error() ) { - // clean up now essentially dangling memory. - // and the parse fail can put objects in the - // pools that are dead and inaccessible. - DeleteChildren(); - _elementPool.Clear(); - _attributePool.Clear(); - _textPool.Clear(); - _commentPool.Clear(); - } - return _errorID; -} - - -void XMLDocument::Print( XMLPrinter* streamer ) const -{ - if ( streamer ) { - Accept( streamer ); - } - else { - XMLPrinter stdoutStreamer( stdout ); - Accept( &stdoutStreamer ); - } -} - - -void XMLDocument::SetError( XMLError error, int lineNum, const char* format, ... ) -{ - TIXMLASSERT( error >= 0 && error < XML_ERROR_COUNT ); - _errorID = error; - _errorLineNum = lineNum; - _errorStr.Reset(); - - const size_t BUFFER_SIZE = 1000; - char* buffer = new char[BUFFER_SIZE]; - - TIXMLASSERT(sizeof(error) <= sizeof(int)); - TIXML_SNPRINTF(buffer, BUFFER_SIZE, "Error=%s ErrorID=%d (0x%x) Line number=%d", ErrorIDToName(error), int(error), int(error), lineNum); - - if (format) { - size_t len = strlen(buffer); - TIXML_SNPRINTF(buffer + len, BUFFER_SIZE - len, ": "); - len = strlen(buffer); - - va_list va; - va_start(va, format); - TIXML_VSNPRINTF(buffer + len, BUFFER_SIZE - len, format, va); - va_end(va); - } - _errorStr.SetStr(buffer); - delete[] buffer; -} - - -/*static*/ const char* XMLDocument::ErrorIDToName(XMLError errorID) -{ - TIXMLASSERT( errorID >= 0 && errorID < XML_ERROR_COUNT ); - const char* errorName = _errorNames[errorID]; - TIXMLASSERT( errorName && errorName[0] ); - return errorName; -} - -const char* XMLDocument::ErrorStr() const -{ - return _errorStr.Empty() ? "" : _errorStr.GetStr(); -} - - -void XMLDocument::PrintError() const -{ - printf("%s\n", ErrorStr()); -} - -const char* XMLDocument::ErrorName() const -{ - return ErrorIDToName(_errorID); -} - -void XMLDocument::Parse() -{ - TIXMLASSERT( NoChildren() ); // Clear() must have been called previously - TIXMLASSERT( _charBuffer ); - _parseCurLineNum = 1; - _parseLineNum = 1; - char* p = _charBuffer; - p = XMLUtil::SkipWhiteSpace( p, &_parseCurLineNum ); - p = const_cast( XMLUtil::ReadBOM( p, &_writeBOM ) ); - if ( !*p ) { - SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 ); - return; - } - ParseDeep(p, 0, &_parseCurLineNum ); -} - -void XMLDocument::PushDepth() -{ - _parsingDepth++; - if (_parsingDepth == TINYXML2_MAX_ELEMENT_DEPTH) { - SetError(XML_ELEMENT_DEPTH_EXCEEDED, _parseCurLineNum, "Element nesting is too deep." ); - } -} - -void XMLDocument::PopDepth() -{ - TIXMLASSERT(_parsingDepth > 0); - --_parsingDepth; -} - -XMLPrinter::XMLPrinter( FILE* file, bool compact, int depth ) : - _elementJustOpened( false ), - _stack(), - _firstElement( true ), - _fp( file ), - _depth( depth ), - _textDepth( -1 ), - _processEntities( true ), - _compactMode( compact ), - _buffer() -{ - for( int i=0; i(entityValue); - TIXMLASSERT( flagIndex < ENTITY_RANGE ); - _entityFlag[flagIndex] = true; - } - _restrictedEntityFlag[static_cast('&')] = true; - _restrictedEntityFlag[static_cast('<')] = true; - _restrictedEntityFlag[static_cast('>')] = true; // not required, but consistency is nice - _buffer.Push( 0 ); -} - - -void XMLPrinter::Print( const char* format, ... ) -{ - va_list va; - va_start( va, format ); - - if ( _fp ) { - vfprintf( _fp, format, va ); - } - else { - const int len = TIXML_VSCPRINTF( format, va ); - // Close out and re-start the va-args - va_end( va ); - TIXMLASSERT( len >= 0 ); - va_start( va, format ); - TIXMLASSERT( _buffer.Size() > 0 && _buffer[_buffer.Size() - 1] == 0 ); - char* p = _buffer.PushArr( len ) - 1; // back up over the null terminator. - TIXML_VSNPRINTF( p, len+1, format, va ); - } - va_end( va ); -} - - -void XMLPrinter::Write( const char* data, size_t size ) -{ - if ( _fp ) { - fwrite ( data , sizeof(char), size, _fp); - } - else { - char* p = _buffer.PushArr( static_cast(size) ) - 1; // back up over the null terminator. - memcpy( p, data, size ); - p[size] = 0; - } -} - - -void XMLPrinter::Putc( char ch ) -{ - if ( _fp ) { - fputc ( ch, _fp); - } - else { - char* p = _buffer.PushArr( sizeof(char) ) - 1; // back up over the null terminator. - p[0] = ch; - p[1] = 0; - } -} - - -void XMLPrinter::PrintSpace( int depth ) -{ - for( int i=0; i 0 && *q < ENTITY_RANGE ) { - // Check for entities. If one is found, flush - // the stream up until the entity, write the - // entity, and keep looking. - if ( flag[static_cast(*q)] ) { - while ( p < q ) { - const size_t delta = q - p; - const int toPrint = ( INT_MAX < delta ) ? INT_MAX : static_cast(delta); - Write( p, toPrint ); - p += toPrint; - } - bool entityPatternPrinted = false; - for( int i=0; i(delta); - Write( p, toPrint ); - } - } - else { - Write( p ); - } -} - - -void XMLPrinter::PushHeader( bool writeBOM, bool writeDec ) -{ - if ( writeBOM ) { - static const unsigned char bom[] = { TIXML_UTF_LEAD_0, TIXML_UTF_LEAD_1, TIXML_UTF_LEAD_2, 0 }; - Write( reinterpret_cast< const char* >( bom ) ); - } - if ( writeDec ) { - PushDeclaration( "xml version=\"1.0\"" ); - } -} - - -void XMLPrinter::OpenElement( const char* name, bool compactMode ) -{ - SealElementIfJustOpened(); - _stack.Push( name ); - - if ( _textDepth < 0 && !_firstElement && !compactMode ) { - Putc( '\n' ); - PrintSpace( _depth ); - } - - Write ( "<" ); - Write ( name ); - - _elementJustOpened = true; - _firstElement = false; - ++_depth; -} - - -void XMLPrinter::PushAttribute( const char* name, const char* value ) -{ - TIXMLASSERT( _elementJustOpened ); - Putc ( ' ' ); - Write( name ); - Write( "=\"" ); - PrintString( value, false ); - Putc ( '\"' ); -} - - -void XMLPrinter::PushAttribute( const char* name, int v ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( v, buf, BUF_SIZE ); - PushAttribute( name, buf ); -} - - -void XMLPrinter::PushAttribute( const char* name, unsigned v ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( v, buf, BUF_SIZE ); - PushAttribute( name, buf ); -} - - -void XMLPrinter::PushAttribute(const char* name, int64_t v) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr(v, buf, BUF_SIZE); - PushAttribute(name, buf); -} - - -void XMLPrinter::PushAttribute(const char* name, uint64_t v) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr(v, buf, BUF_SIZE); - PushAttribute(name, buf); -} - - -void XMLPrinter::PushAttribute( const char* name, bool v ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( v, buf, BUF_SIZE ); - PushAttribute( name, buf ); -} - - -void XMLPrinter::PushAttribute( const char* name, double v ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( v, buf, BUF_SIZE ); - PushAttribute( name, buf ); -} - - -void XMLPrinter::CloseElement( bool compactMode ) -{ - --_depth; - const char* name = _stack.Pop(); - - if ( _elementJustOpened ) { - Write( "/>" ); - } - else { - if ( _textDepth < 0 && !compactMode) { - Putc( '\n' ); - PrintSpace( _depth ); - } - Write ( "" ); - } - - if ( _textDepth == _depth ) { - _textDepth = -1; - } - if ( _depth == 0 && !compactMode) { - Putc( '\n' ); - } - _elementJustOpened = false; -} - - -void XMLPrinter::SealElementIfJustOpened() -{ - if ( !_elementJustOpened ) { - return; - } - _elementJustOpened = false; - Putc( '>' ); -} - - -void XMLPrinter::PushText( const char* text, bool cdata ) -{ - _textDepth = _depth-1; - - SealElementIfJustOpened(); - if ( cdata ) { - Write( "" ); - } - else { - PrintString( text, true ); - } -} - - -void XMLPrinter::PushText( int64_t value ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( value, buf, BUF_SIZE ); - PushText( buf, false ); -} - - -void XMLPrinter::PushText( uint64_t value ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr(value, buf, BUF_SIZE); - PushText(buf, false); -} - - -void XMLPrinter::PushText( int value ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( value, buf, BUF_SIZE ); - PushText( buf, false ); -} - - -void XMLPrinter::PushText( unsigned value ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( value, buf, BUF_SIZE ); - PushText( buf, false ); -} - - -void XMLPrinter::PushText( bool value ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( value, buf, BUF_SIZE ); - PushText( buf, false ); -} - - -void XMLPrinter::PushText( float value ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( value, buf, BUF_SIZE ); - PushText( buf, false ); -} - - -void XMLPrinter::PushText( double value ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( value, buf, BUF_SIZE ); - PushText( buf, false ); -} - - -void XMLPrinter::PushComment( const char* comment ) -{ - SealElementIfJustOpened(); - if ( _textDepth < 0 && !_firstElement && !_compactMode) { - Putc( '\n' ); - PrintSpace( _depth ); - } - _firstElement = false; - - Write( "" ); -} - - -void XMLPrinter::PushDeclaration( const char* value ) -{ - SealElementIfJustOpened(); - if ( _textDepth < 0 && !_firstElement && !_compactMode) { - Putc( '\n' ); - PrintSpace( _depth ); - } - _firstElement = false; - - Write( "" ); -} - - -void XMLPrinter::PushUnknown( const char* value ) -{ - SealElementIfJustOpened(); - if ( _textDepth < 0 && !_firstElement && !_compactMode) { - Putc( '\n' ); - PrintSpace( _depth ); - } - _firstElement = false; - - Write( "' ); -} - - -bool XMLPrinter::VisitEnter( const XMLDocument& doc ) -{ - _processEntities = doc.ProcessEntities(); - if ( doc.HasBOM() ) { - PushHeader( true, false ); - } - return true; -} - - -bool XMLPrinter::VisitEnter( const XMLElement& element, const XMLAttribute* attribute ) -{ - const XMLElement* parentElem = 0; - if ( element.Parent() ) { - parentElem = element.Parent()->ToElement(); - } - const bool compactMode = parentElem ? CompactMode( *parentElem ) : _compactMode; - OpenElement( element.Name(), compactMode ); - while ( attribute ) { - PushAttribute( attribute->Name(), attribute->Value() ); - attribute = attribute->Next(); - } - return true; -} - - -bool XMLPrinter::VisitExit( const XMLElement& element ) -{ - CloseElement( CompactMode(element) ); - return true; -} - - -bool XMLPrinter::Visit( const XMLText& text ) -{ - PushText( text.Value(), text.CData() ); - return true; -} - - -bool XMLPrinter::Visit( const XMLComment& comment ) -{ - PushComment( comment.Value() ); - return true; -} - -bool XMLPrinter::Visit( const XMLDeclaration& declaration ) -{ - PushDeclaration( declaration.Value() ); - return true; -} - - -bool XMLPrinter::Visit( const XMLUnknown& unknown ) -{ - PushUnknown( unknown.Value() ); - return true; -} - -} // namespace tinyxml2 diff --git a/soh/soh/Enhancements/randomizer/3drando/tinyxml2.h b/soh/soh/Enhancements/randomizer/3drando/tinyxml2.h deleted file mode 100644 index 093de69bf0d..00000000000 --- a/soh/soh/Enhancements/randomizer/3drando/tinyxml2.h +++ /dev/null @@ -1,2365 +0,0 @@ -/* -Original code by Lee Thomason (www.grinninglizard.com) - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any -damages arising from the use of this software. - -Permission is granted to anyone to use this software for any -purpose, including commercial applications, and to alter it and -redistribute it freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must -not claim that you wrote the original software. If you use this -software in a product, an acknowledgment in the product documentation -would be appreciated but is not required. - -2. Altered source versions must be plainly marked as such, and -must not be misrepresented as being the original software. - -3. This notice may not be removed or altered from any source -distribution. -*/ - -#ifndef TINYXML2_INCLUDED -#define TINYXML2_INCLUDED - -#if defined(ANDROID_NDK) || defined(__BORLANDC__) || defined(__QNXNTO__) -# include -# include -# include -# include -# include -# if defined(__PS3__) -# include -# endif -#else -# include -# include -# include -# include -# include -#endif -#include - -/* - TODO: intern strings instead of allocation. -*/ -/* - gcc: - g++ -Wall -DTINYXML2_DEBUG tinyxml2.cpp xmltest.cpp -o gccxmltest.exe - - Formatting, Artistic Style: - AStyle.exe --style=1tbs --indent-switches --break-closing-brackets --indent-preprocessor tinyxml2.cpp tinyxml2.h -*/ - -#if defined( _DEBUG ) || defined (__DEBUG__) -# ifndef TINYXML2_DEBUG -# define TINYXML2_DEBUG -# endif -#endif - -#ifdef _MSC_VER -# pragma warning(push) -# pragma warning(disable: 4251) -#endif - -#ifdef _WIN32 -# ifdef TINYXML2_EXPORT -# define TINYXML2_LIB __declspec(dllexport) -# elif defined(TINYXML2_IMPORT) -# define TINYXML2_LIB __declspec(dllimport) -# else -# define TINYXML2_LIB -# endif -#elif __GNUC__ >= 4 -# define TINYXML2_LIB __attribute__((visibility("default"))) -#else -# define TINYXML2_LIB -#endif - - -#if defined(TINYXML2_DEBUG) -# if defined(_MSC_VER) -# // "(void)0," is for suppressing C4127 warning in "assert(false)", "assert(true)" and the like -# define TIXMLASSERT( x ) if ( !((void)0,(x))) { __debugbreak(); } -# elif defined (ANDROID_NDK) -# include -# define TIXMLASSERT( x ) if ( !(x)) { __android_log_assert( "assert", "grinliz", "ASSERT in '%s' at %d.", __FILE__, __LINE__ ); } -# else -# include -# define TIXMLASSERT assert -# endif -#else -# define TIXMLASSERT( x ) {} -#endif - - -/* Versioning, past 1.0.14: - http://semver.org/ -*/ -static const int TIXML2_MAJOR_VERSION = 8; -static const int TIXML2_MINOR_VERSION = 0; -static const int TIXML2_PATCH_VERSION = 0; - -#define TINYXML2_MAJOR_VERSION 8 -#define TINYXML2_MINOR_VERSION 0 -#define TINYXML2_PATCH_VERSION 0 - -// A fixed element depth limit is problematic. There needs to be a -// limit to avoid a stack overflow. However, that limit varies per -// system, and the capacity of the stack. On the other hand, it's a trivial -// attack that can result from ill, malicious, or even correctly formed XML, -// so there needs to be a limit in place. -static const int TINYXML2_MAX_ELEMENT_DEPTH = 100; - -namespace tinyxml2 -{ -class XMLDocument; -class XMLElement; -class XMLAttribute; -class XMLComment; -class XMLText; -class XMLDeclaration; -class XMLUnknown; -class XMLPrinter; - -/* - A class that wraps strings. Normally stores the start and end - pointers into the XML file itself, and will apply normalization - and entity translation if actually read. Can also store (and memory - manage) a traditional char[] - - Isn't clear why TINYXML2_LIB is needed; but seems to fix #719 -*/ -class TINYXML2_LIB StrPair -{ -public: - enum { - NEEDS_ENTITY_PROCESSING = 0x01, - NEEDS_NEWLINE_NORMALIZATION = 0x02, - NEEDS_WHITESPACE_COLLAPSING = 0x04, - - TEXT_ELEMENT = NEEDS_ENTITY_PROCESSING | NEEDS_NEWLINE_NORMALIZATION, - TEXT_ELEMENT_LEAVE_ENTITIES = NEEDS_NEWLINE_NORMALIZATION, - ATTRIBUTE_NAME = 0, - ATTRIBUTE_VALUE = NEEDS_ENTITY_PROCESSING | NEEDS_NEWLINE_NORMALIZATION, - ATTRIBUTE_VALUE_LEAVE_ENTITIES = NEEDS_NEWLINE_NORMALIZATION, - COMMENT = NEEDS_NEWLINE_NORMALIZATION - }; - - StrPair() : _flags( 0 ), _start( 0 ), _end( 0 ) {} - ~StrPair(); - - void Set( char* start, char* end, int flags ) { - TIXMLASSERT( start ); - TIXMLASSERT( end ); - Reset(); - _start = start; - _end = end; - _flags = flags | NEEDS_FLUSH; - } - - const char* GetStr(); - - bool Empty() const { - return _start == _end; - } - - void SetInternedStr( const char* str ) { - Reset(); - _start = const_cast(str); - } - - void SetStr( const char* str, int flags=0 ); - - char* ParseText( char* in, const char* endTag, int strFlags, int* curLineNumPtr ); - char* ParseName( char* in ); - - void TransferTo( StrPair* other ); - void Reset(); - -private: - void CollapseWhitespace(); - - enum { - NEEDS_FLUSH = 0x100, - NEEDS_DELETE = 0x200 - }; - - int _flags; - char* _start; - char* _end; - - StrPair( const StrPair& other ); // not supported - void operator=( const StrPair& other ); // not supported, use TransferTo() -}; - - -/* - A dynamic array of Plain Old Data. Doesn't support constructors, etc. - Has a small initial memory pool, so that low or no usage will not - cause a call to new/delete -*/ -template -class DynArray -{ -public: - DynArray() : - _mem( _pool ), - _allocated( INITIAL_SIZE ), - _size( 0 ) - { - } - - ~DynArray() { - if ( _mem != _pool ) { - delete [] _mem; - } - } - - void Clear() { - _size = 0; - } - - void Push( T t ) { - TIXMLASSERT( _size < INT_MAX ); - EnsureCapacity( _size+1 ); - _mem[_size] = t; - ++_size; - } - - T* PushArr( int count ) { - TIXMLASSERT( count >= 0 ); - TIXMLASSERT( _size <= INT_MAX - count ); - EnsureCapacity( _size+count ); - T* ret = &_mem[_size]; - _size += count; - return ret; - } - - T Pop() { - TIXMLASSERT( _size > 0 ); - --_size; - return _mem[_size]; - } - - void PopArr( int count ) { - TIXMLASSERT( _size >= count ); - _size -= count; - } - - bool Empty() const { - return _size == 0; - } - - T& operator[](int i) { - TIXMLASSERT( i>= 0 && i < _size ); - return _mem[i]; - } - - const T& operator[](int i) const { - TIXMLASSERT( i>= 0 && i < _size ); - return _mem[i]; - } - - const T& PeekTop() const { - TIXMLASSERT( _size > 0 ); - return _mem[ _size - 1]; - } - - int Size() const { - TIXMLASSERT( _size >= 0 ); - return _size; - } - - int Capacity() const { - TIXMLASSERT( _allocated >= INITIAL_SIZE ); - return _allocated; - } - - void SwapRemove(int i) { - TIXMLASSERT(i >= 0 && i < _size); - TIXMLASSERT(_size > 0); - _mem[i] = _mem[_size - 1]; - --_size; - } - - const T* Mem() const { - TIXMLASSERT( _mem ); - return _mem; - } - - T* Mem() { - TIXMLASSERT( _mem ); - return _mem; - } - -private: - DynArray( const DynArray& ); // not supported - void operator=( const DynArray& ); // not supported - - void EnsureCapacity( int cap ) { - TIXMLASSERT( cap > 0 ); - if ( cap > _allocated ) { - TIXMLASSERT( cap <= INT_MAX / 2 ); - const int newAllocated = cap * 2; - T* newMem = new T[newAllocated]; - TIXMLASSERT( newAllocated >= _size ); - memcpy( newMem, _mem, sizeof(T)*_size ); // warning: not using constructors, only works for PODs - if ( _mem != _pool ) { - delete [] _mem; - } - _mem = newMem; - _allocated = newAllocated; - } - } - - T* _mem; - T _pool[INITIAL_SIZE]; - int _allocated; // objects allocated - int _size; // number objects in use -}; - - -/* - Parent virtual class of a pool for fast allocation - and deallocation of objects. -*/ -class MemPool -{ -public: - MemPool() {} - virtual ~MemPool() {} - - virtual int ItemSize() const = 0; - virtual void* Alloc() = 0; - virtual void Free( void* ) = 0; - virtual void SetTracked() = 0; -}; - - -/* - Template child class to create pools of the correct type. -*/ -template< int ITEM_SIZE > -class MemPoolT : public MemPool -{ -public: - MemPoolT() : _blockPtrs(), _root(0), _currentAllocs(0), _nAllocs(0), _maxAllocs(0), _nUntracked(0) {} - ~MemPoolT() { - MemPoolT< ITEM_SIZE >::Clear(); - } - - void Clear() { - // Delete the blocks. - while( !_blockPtrs.Empty()) { - Block* lastBlock = _blockPtrs.Pop(); - delete lastBlock; - } - _root = 0; - _currentAllocs = 0; - _nAllocs = 0; - _maxAllocs = 0; - _nUntracked = 0; - } - - virtual int ItemSize() const { - return ITEM_SIZE; - } - int CurrentAllocs() const { - return _currentAllocs; - } - - virtual void* Alloc() { - if ( !_root ) { - // Need a new block. - Block* block = new Block(); - _blockPtrs.Push( block ); - - Item* blockItems = block->items; - for( int i = 0; i < ITEMS_PER_BLOCK - 1; ++i ) { - blockItems[i].next = &(blockItems[i + 1]); - } - blockItems[ITEMS_PER_BLOCK - 1].next = 0; - _root = blockItems; - } - Item* const result = _root; - TIXMLASSERT( result != 0 ); - _root = _root->next; - - ++_currentAllocs; - if ( _currentAllocs > _maxAllocs ) { - _maxAllocs = _currentAllocs; - } - ++_nAllocs; - ++_nUntracked; - return result; - } - - virtual void Free( void* mem ) { - if ( !mem ) { - return; - } - --_currentAllocs; - Item* item = static_cast( mem ); -#ifdef TINYXML2_DEBUG - memset( item, 0xfe, sizeof( *item ) ); -#endif - item->next = _root; - _root = item; - } - void Trace( const char* name ) { - printf( "Mempool %s watermark=%d [%dk] current=%d size=%d nAlloc=%d blocks=%d\n", - name, _maxAllocs, _maxAllocs * ITEM_SIZE / 1024, _currentAllocs, - ITEM_SIZE, _nAllocs, _blockPtrs.Size() ); - } - - void SetTracked() { - --_nUntracked; - } - - int Untracked() const { - return _nUntracked; - } - - // This number is perf sensitive. 4k seems like a good tradeoff on my machine. - // The test file is large, 170k. - // Release: VS2010 gcc(no opt) - // 1k: 4000 - // 2k: 4000 - // 4k: 3900 21000 - // 16k: 5200 - // 32k: 4300 - // 64k: 4000 21000 - // Declared public because some compilers do not accept to use ITEMS_PER_BLOCK - // in private part if ITEMS_PER_BLOCK is private - enum { ITEMS_PER_BLOCK = (4 * 1024) / ITEM_SIZE }; - -private: - MemPoolT( const MemPoolT& ); // not supported - void operator=( const MemPoolT& ); // not supported - - union Item { - Item* next; - char itemData[ITEM_SIZE]; - }; - struct Block { - Item items[ITEMS_PER_BLOCK]; - }; - DynArray< Block*, 10 > _blockPtrs; - Item* _root; - - int _currentAllocs; - int _nAllocs; - int _maxAllocs; - int _nUntracked; -}; - - - -/** - Implements the interface to the "Visitor pattern" (see the Accept() method.) - If you call the Accept() method, it requires being passed a XMLVisitor - class to handle callbacks. For nodes that contain other nodes (Document, Element) - you will get called with a VisitEnter/VisitExit pair. Nodes that are always leafs - are simply called with Visit(). - - If you return 'true' from a Visit method, recursive parsing will continue. If you return - false, no children of this node or its siblings will be visited. - - All flavors of Visit methods have a default implementation that returns 'true' (continue - visiting). You need to only override methods that are interesting to you. - - Generally Accept() is called on the XMLDocument, although all nodes support visiting. - - You should never change the document from a callback. - - @sa XMLNode::Accept() -*/ -class TINYXML2_LIB XMLVisitor -{ -public: - virtual ~XMLVisitor() {} - - /// Visit a document. - virtual bool VisitEnter( const XMLDocument& /*doc*/ ) { - return true; - } - /// Visit a document. - virtual bool VisitExit( const XMLDocument& /*doc*/ ) { - return true; - } - - /// Visit an element. - virtual bool VisitEnter( const XMLElement& /*element*/, const XMLAttribute* /*firstAttribute*/ ) { - return true; - } - /// Visit an element. - virtual bool VisitExit( const XMLElement& /*element*/ ) { - return true; - } - - /// Visit a declaration. - virtual bool Visit( const XMLDeclaration& /*declaration*/ ) { - return true; - } - /// Visit a text node. - virtual bool Visit( const XMLText& /*text*/ ) { - return true; - } - /// Visit a comment node. - virtual bool Visit( const XMLComment& /*comment*/ ) { - return true; - } - /// Visit an unknown node. - virtual bool Visit( const XMLUnknown& /*unknown*/ ) { - return true; - } -}; - -// WARNING: must match XMLDocument::_errorNames[] -enum XMLError { - XML_SUCCESS = 0, - XML_NO_ATTRIBUTE, - XML_WRONG_ATTRIBUTE_TYPE, - XML_ERROR_FILE_NOT_FOUND, - XML_ERROR_FILE_COULD_NOT_BE_OPENED, - XML_ERROR_FILE_READ_ERROR, - XML_ERROR_PARSING_ELEMENT, - XML_ERROR_PARSING_ATTRIBUTE, - XML_ERROR_PARSING_TEXT, - XML_ERROR_PARSING_CDATA, - XML_ERROR_PARSING_COMMENT, - XML_ERROR_PARSING_DECLARATION, - XML_ERROR_PARSING_UNKNOWN, - XML_ERROR_EMPTY_DOCUMENT, - XML_ERROR_MISMATCHED_ELEMENT, - XML_ERROR_PARSING, - XML_CAN_NOT_CONVERT_TEXT, - XML_NO_TEXT_NODE, - XML_ELEMENT_DEPTH_EXCEEDED, - - XML_ERROR_COUNT -}; - - -/* - Utility functionality. -*/ -class TINYXML2_LIB XMLUtil -{ -public: - static const char* SkipWhiteSpace( const char* p, int* curLineNumPtr ) { - TIXMLASSERT( p ); - - while( IsWhiteSpace(*p) ) { - if (curLineNumPtr && *p == '\n') { - ++(*curLineNumPtr); - } - ++p; - } - TIXMLASSERT( p ); - return p; - } - static char* SkipWhiteSpace( char* const p, int* curLineNumPtr ) { - return const_cast( SkipWhiteSpace( const_cast(p), curLineNumPtr ) ); - } - - // Anything in the high order range of UTF-8 is assumed to not be whitespace. This isn't - // correct, but simple, and usually works. - static bool IsWhiteSpace( char p ) { - return !IsUTF8Continuation(p) && isspace( static_cast(p) ); - } - - inline static bool IsNameStartChar( unsigned char ch ) { - if ( ch >= 128 ) { - // This is a heuristic guess in attempt to not implement Unicode-aware isalpha() - return true; - } - if ( isalpha( ch ) ) { - return true; - } - return ch == ':' || ch == '_'; - } - - inline static bool IsNameChar( unsigned char ch ) { - return IsNameStartChar( ch ) - || isdigit( ch ) - || ch == '.' - || ch == '-'; - } - - inline static bool StringEqual( const char* p, const char* q, int nChar=INT_MAX ) { - if ( p == q ) { - return true; - } - TIXMLASSERT( p ); - TIXMLASSERT( q ); - TIXMLASSERT( nChar >= 0 ); - return strncmp( p, q, nChar ) == 0; - } - - inline static bool IsUTF8Continuation( const char p ) { - return ( p & 0x80 ) != 0; - } - - static const char* ReadBOM( const char* p, bool* hasBOM ); - // p is the starting location, - // the UTF-8 value of the entity will be placed in value, and length filled in. - static const char* GetCharacterRef( const char* p, char* value, int* length ); - static void ConvertUTF32ToUTF8( unsigned long input, char* output, int* length ); - - // converts primitive types to strings - static void ToStr( int v, char* buffer, int bufferSize ); - static void ToStr( unsigned v, char* buffer, int bufferSize ); - static void ToStr( bool v, char* buffer, int bufferSize ); - static void ToStr( float v, char* buffer, int bufferSize ); - static void ToStr( double v, char* buffer, int bufferSize ); - static void ToStr(int64_t v, char* buffer, int bufferSize); - static void ToStr(uint64_t v, char* buffer, int bufferSize); - - // converts strings to primitive types - static bool ToInt( const char* str, int* value ); - static bool ToUnsigned( const char* str, unsigned* value ); - static bool ToBool( const char* str, bool* value ); - static bool ToFloat( const char* str, float* value ); - static bool ToDouble( const char* str, double* value ); - static bool ToInt64(const char* str, int64_t* value); - static bool ToUnsigned64(const char* str, uint64_t* value); - // Changes what is serialized for a boolean value. - // Default to "true" and "false". Shouldn't be changed - // unless you have a special testing or compatibility need. - // Be careful: static, global, & not thread safe. - // Be sure to set static const memory as parameters. - static void SetBoolSerialization(const char* writeTrue, const char* writeFalse); - -private: - static const char* writeBoolTrue; - static const char* writeBoolFalse; -}; - - -/** XMLNode is a base class for every object that is in the - XML Document Object Model (DOM), except XMLAttributes. - Nodes have siblings, a parent, and children which can - be navigated. A node is always in a XMLDocument. - The type of a XMLNode can be queried, and it can - be cast to its more defined type. - - A XMLDocument allocates memory for all its Nodes. - When the XMLDocument gets deleted, all its Nodes - will also be deleted. - - @verbatim - A Document can contain: Element (container or leaf) - Comment (leaf) - Unknown (leaf) - Declaration( leaf ) - - An Element can contain: Element (container or leaf) - Text (leaf) - Attributes (not on tree) - Comment (leaf) - Unknown (leaf) - - @endverbatim -*/ -class TINYXML2_LIB XMLNode -{ - friend class XMLDocument; - friend class XMLElement; -public: - - /// Get the XMLDocument that owns this XMLNode. - const XMLDocument* GetDocument() const { - TIXMLASSERT( _document ); - return _document; - } - /// Get the XMLDocument that owns this XMLNode. - XMLDocument* GetDocument() { - TIXMLASSERT( _document ); - return _document; - } - - /// Safely cast to an Element, or null. - virtual XMLElement* ToElement() { - return 0; - } - /// Safely cast to Text, or null. - virtual XMLText* ToText() { - return 0; - } - /// Safely cast to a Comment, or null. - virtual XMLComment* ToComment() { - return 0; - } - /// Safely cast to a Document, or null. - virtual XMLDocument* ToDocument() { - return 0; - } - /// Safely cast to a Declaration, or null. - virtual XMLDeclaration* ToDeclaration() { - return 0; - } - /// Safely cast to an Unknown, or null. - virtual XMLUnknown* ToUnknown() { - return 0; - } - - virtual const XMLElement* ToElement() const { - return 0; - } - virtual const XMLText* ToText() const { - return 0; - } - virtual const XMLComment* ToComment() const { - return 0; - } - virtual const XMLDocument* ToDocument() const { - return 0; - } - virtual const XMLDeclaration* ToDeclaration() const { - return 0; - } - virtual const XMLUnknown* ToUnknown() const { - return 0; - } - - /** The meaning of 'value' changes for the specific type. - @verbatim - Document: empty (NULL is returned, not an empty string) - Element: name of the element - Comment: the comment text - Unknown: the tag contents - Text: the text string - @endverbatim - */ - const char* Value() const; - - /** Set the Value of an XML node. - @sa Value() - */ - void SetValue( const char* val, bool staticMem=false ); - - /// Gets the line number the node is in, if the document was parsed from a file. - int GetLineNum() const { return _parseLineNum; } - - /// Get the parent of this node on the DOM. - const XMLNode* Parent() const { - return _parent; - } - - XMLNode* Parent() { - return _parent; - } - - /// Returns true if this node has no children. - bool NoChildren() const { - return !_firstChild; - } - - /// Get the first child node, or null if none exists. - const XMLNode* FirstChild() const { - return _firstChild; - } - - XMLNode* FirstChild() { - return _firstChild; - } - - /** Get the first child element, or optionally the first child - element with the specified name. - */ - const XMLElement* FirstChildElement( const char* name = 0 ) const; - - XMLElement* FirstChildElement( const char* name = 0 ) { - return const_cast(const_cast(this)->FirstChildElement( name )); - } - - /// Get the last child node, or null if none exists. - const XMLNode* LastChild() const { - return _lastChild; - } - - XMLNode* LastChild() { - return _lastChild; - } - - /** Get the last child element or optionally the last child - element with the specified name. - */ - const XMLElement* LastChildElement( const char* name = 0 ) const; - - XMLElement* LastChildElement( const char* name = 0 ) { - return const_cast(const_cast(this)->LastChildElement(name) ); - } - - /// Get the previous (left) sibling node of this node. - const XMLNode* PreviousSibling() const { - return _prev; - } - - XMLNode* PreviousSibling() { - return _prev; - } - - /// Get the previous (left) sibling element of this node, with an optionally supplied name. - const XMLElement* PreviousSiblingElement( const char* name = 0 ) const ; - - XMLElement* PreviousSiblingElement( const char* name = 0 ) { - return const_cast(const_cast(this)->PreviousSiblingElement( name ) ); - } - - /// Get the next (right) sibling node of this node. - const XMLNode* NextSibling() const { - return _next; - } - - XMLNode* NextSibling() { - return _next; - } - - /// Get the next (right) sibling element of this node, with an optionally supplied name. - const XMLElement* NextSiblingElement( const char* name = 0 ) const; - - XMLElement* NextSiblingElement( const char* name = 0 ) { - return const_cast(const_cast(this)->NextSiblingElement( name ) ); - } - - /** - Add a child node as the last (right) child. - If the child node is already part of the document, - it is moved from its old location to the new location. - Returns the addThis argument or 0 if the node does not - belong to the same document. - */ - XMLNode* InsertEndChild( XMLNode* addThis ); - - XMLNode* LinkEndChild( XMLNode* addThis ) { - return InsertEndChild( addThis ); - } - /** - Add a child node as the first (left) child. - If the child node is already part of the document, - it is moved from its old location to the new location. - Returns the addThis argument or 0 if the node does not - belong to the same document. - */ - XMLNode* InsertFirstChild( XMLNode* addThis ); - /** - Add a node after the specified child node. - If the child node is already part of the document, - it is moved from its old location to the new location. - Returns the addThis argument or 0 if the afterThis node - is not a child of this node, or if the node does not - belong to the same document. - */ - XMLNode* InsertAfterChild( XMLNode* afterThis, XMLNode* addThis ); - - /** - Delete all the children of this node. - */ - void DeleteChildren(); - - /** - Delete a child of this node. - */ - void DeleteChild( XMLNode* node ); - - /** - Make a copy of this node, but not its children. - You may pass in a Document pointer that will be - the owner of the new Node. If the 'document' is - null, then the node returned will be allocated - from the current Document. (this->GetDocument()) - - Note: if called on a XMLDocument, this will return null. - */ - virtual XMLNode* ShallowClone( XMLDocument* document ) const = 0; - - /** - Make a copy of this node and all its children. - - If the 'target' is null, then the nodes will - be allocated in the current document. If 'target' - is specified, the memory will be allocated is the - specified XMLDocument. - - NOTE: This is probably not the correct tool to - copy a document, since XMLDocuments can have multiple - top level XMLNodes. You probably want to use - XMLDocument::DeepCopy() - */ - XMLNode* DeepClone( XMLDocument* target ) const; - - /** - Test if 2 nodes are the same, but don't test children. - The 2 nodes do not need to be in the same Document. - - Note: if called on a XMLDocument, this will return false. - */ - virtual bool ShallowEqual( const XMLNode* compare ) const = 0; - - /** Accept a hierarchical visit of the nodes in the TinyXML-2 DOM. Every node in the - XML tree will be conditionally visited and the host will be called back - via the XMLVisitor interface. - - This is essentially a SAX interface for TinyXML-2. (Note however it doesn't re-parse - the XML for the callbacks, so the performance of TinyXML-2 is unchanged by using this - interface versus any other.) - - The interface has been based on ideas from: - - - http://www.saxproject.org/ - - http://c2.com/cgi/wiki?HierarchicalVisitorPattern - - Which are both good references for "visiting". - - An example of using Accept(): - @verbatim - XMLPrinter printer; - tinyxmlDoc.Accept( &printer ); - const char* xmlcstr = printer.CStr(); - @endverbatim - */ - virtual bool Accept( XMLVisitor* visitor ) const = 0; - - /** - Set user data into the XMLNode. TinyXML-2 in - no way processes or interprets user data. - It is initially 0. - */ - void SetUserData(void* userData) { _userData = userData; } - - /** - Get user data set into the XMLNode. TinyXML-2 in - no way processes or interprets user data. - It is initially 0. - */ - void* GetUserData() const { return _userData; } - -protected: - explicit XMLNode( XMLDocument* ); - virtual ~XMLNode(); - - virtual char* ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr); - - XMLDocument* _document; - XMLNode* _parent; - mutable StrPair _value; - int _parseLineNum; - - XMLNode* _firstChild; - XMLNode* _lastChild; - - XMLNode* _prev; - XMLNode* _next; - - void* _userData; - -private: - MemPool* _memPool; - void Unlink( XMLNode* child ); - static void DeleteNode( XMLNode* node ); - void InsertChildPreamble( XMLNode* insertThis ) const; - const XMLElement* ToElementWithName( const char* name ) const; - - XMLNode( const XMLNode& ); // not supported - XMLNode& operator=( const XMLNode& ); // not supported -}; - - -/** XML text. - - Note that a text node can have child element nodes, for example: - @verbatim - This is bold - @endverbatim - - A text node can have 2 ways to output the next. "normal" output - and CDATA. It will default to the mode it was parsed from the XML file and - you generally want to leave it alone, but you can change the output mode with - SetCData() and query it with CData(). -*/ -class TINYXML2_LIB XMLText : public XMLNode -{ - friend class XMLDocument; -public: - virtual bool Accept( XMLVisitor* visitor ) const; - - virtual XMLText* ToText() { - return this; - } - virtual const XMLText* ToText() const { - return this; - } - - /// Declare whether this should be CDATA or standard text. - void SetCData( bool isCData ) { - _isCData = isCData; - } - /// Returns true if this is a CDATA text element. - bool CData() const { - return _isCData; - } - - virtual XMLNode* ShallowClone( XMLDocument* document ) const; - virtual bool ShallowEqual( const XMLNode* compare ) const; - -protected: - explicit XMLText( XMLDocument* doc ) : XMLNode( doc ), _isCData( false ) {} - virtual ~XMLText() {} - - char* ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr ); - -private: - bool _isCData; - - XMLText( const XMLText& ); // not supported - XMLText& operator=( const XMLText& ); // not supported -}; - - -/** An XML Comment. */ -class TINYXML2_LIB XMLComment : public XMLNode -{ - friend class XMLDocument; -public: - virtual XMLComment* ToComment() { - return this; - } - virtual const XMLComment* ToComment() const { - return this; - } - - virtual bool Accept( XMLVisitor* visitor ) const; - - virtual XMLNode* ShallowClone( XMLDocument* document ) const; - virtual bool ShallowEqual( const XMLNode* compare ) const; - -protected: - explicit XMLComment( XMLDocument* doc ); - virtual ~XMLComment(); - - char* ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr); - -private: - XMLComment( const XMLComment& ); // not supported - XMLComment& operator=( const XMLComment& ); // not supported -}; - - -/** In correct XML the declaration is the first entry in the file. - @verbatim - - @endverbatim - - TinyXML-2 will happily read or write files without a declaration, - however. - - The text of the declaration isn't interpreted. It is parsed - and written as a string. -*/ -class TINYXML2_LIB XMLDeclaration : public XMLNode -{ - friend class XMLDocument; -public: - virtual XMLDeclaration* ToDeclaration() { - return this; - } - virtual const XMLDeclaration* ToDeclaration() const { - return this; - } - - virtual bool Accept( XMLVisitor* visitor ) const; - - virtual XMLNode* ShallowClone( XMLDocument* document ) const; - virtual bool ShallowEqual( const XMLNode* compare ) const; - -protected: - explicit XMLDeclaration( XMLDocument* doc ); - virtual ~XMLDeclaration(); - - char* ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr ); - -private: - XMLDeclaration( const XMLDeclaration& ); // not supported - XMLDeclaration& operator=( const XMLDeclaration& ); // not supported -}; - - -/** Any tag that TinyXML-2 doesn't recognize is saved as an - unknown. It is a tag of text, but should not be modified. - It will be written back to the XML, unchanged, when the file - is saved. - - DTD tags get thrown into XMLUnknowns. -*/ -class TINYXML2_LIB XMLUnknown : public XMLNode -{ - friend class XMLDocument; -public: - virtual XMLUnknown* ToUnknown() { - return this; - } - virtual const XMLUnknown* ToUnknown() const { - return this; - } - - virtual bool Accept( XMLVisitor* visitor ) const; - - virtual XMLNode* ShallowClone( XMLDocument* document ) const; - virtual bool ShallowEqual( const XMLNode* compare ) const; - -protected: - explicit XMLUnknown( XMLDocument* doc ); - virtual ~XMLUnknown(); - - char* ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr ); - -private: - XMLUnknown( const XMLUnknown& ); // not supported - XMLUnknown& operator=( const XMLUnknown& ); // not supported -}; - - - -/** An attribute is a name-value pair. Elements have an arbitrary - number of attributes, each with a unique name. - - @note The attributes are not XMLNodes. You may only query the - Next() attribute in a list. -*/ -class TINYXML2_LIB XMLAttribute -{ - friend class XMLElement; -public: - /// The name of the attribute. - const char* Name() const; - - /// The value of the attribute. - const char* Value() const; - - /// Gets the line number the attribute is in, if the document was parsed from a file. - int GetLineNum() const { return _parseLineNum; } - - /// The next attribute in the list. - const XMLAttribute* Next() const { - return _next; - } - - /** IntValue interprets the attribute as an integer, and returns the value. - If the value isn't an integer, 0 will be returned. There is no error checking; - use QueryIntValue() if you need error checking. - */ - int IntValue() const { - int i = 0; - QueryIntValue(&i); - return i; - } - - int64_t Int64Value() const { - int64_t i = 0; - QueryInt64Value(&i); - return i; - } - - uint64_t Unsigned64Value() const { - uint64_t i = 0; - QueryUnsigned64Value(&i); - return i; - } - - /// Query as an unsigned integer. See IntValue() - unsigned UnsignedValue() const { - unsigned i=0; - QueryUnsignedValue( &i ); - return i; - } - /// Query as a boolean. See IntValue() - bool BoolValue() const { - bool b=false; - QueryBoolValue( &b ); - return b; - } - /// Query as a double. See IntValue() - double DoubleValue() const { - double d=0; - QueryDoubleValue( &d ); - return d; - } - /// Query as a float. See IntValue() - float FloatValue() const { - float f=0; - QueryFloatValue( &f ); - return f; - } - - /** QueryIntValue interprets the attribute as an integer, and returns the value - in the provided parameter. The function will return XML_SUCCESS on success, - and XML_WRONG_ATTRIBUTE_TYPE if the conversion is not successful. - */ - XMLError QueryIntValue( int* value ) const; - /// See QueryIntValue - XMLError QueryUnsignedValue( unsigned int* value ) const; - /// See QueryIntValue - XMLError QueryInt64Value(int64_t* value) const; - /// See QueryIntValue - XMLError QueryUnsigned64Value(uint64_t* value) const; - /// See QueryIntValue - XMLError QueryBoolValue( bool* value ) const; - /// See QueryIntValue - XMLError QueryDoubleValue( double* value ) const; - /// See QueryIntValue - XMLError QueryFloatValue( float* value ) const; - - /// Set the attribute to a string value. - void SetAttribute( const char* value ); - /// Set the attribute to value. - void SetAttribute( int value ); - /// Set the attribute to value. - void SetAttribute( unsigned value ); - /// Set the attribute to value. - void SetAttribute(int64_t value); - /// Set the attribute to value. - void SetAttribute(uint64_t value); - /// Set the attribute to value. - void SetAttribute( bool value ); - /// Set the attribute to value. - void SetAttribute( double value ); - /// Set the attribute to value. - void SetAttribute( float value ); - -private: - enum { BUF_SIZE = 200 }; - - XMLAttribute() : _name(), _value(),_parseLineNum( 0 ), _next( 0 ), _memPool( 0 ) {} - virtual ~XMLAttribute() {} - - XMLAttribute( const XMLAttribute& ); // not supported - void operator=( const XMLAttribute& ); // not supported - void SetName( const char* name ); - - char* ParseDeep( char* p, bool processEntities, int* curLineNumPtr ); - - mutable StrPair _name; - mutable StrPair _value; - int _parseLineNum; - XMLAttribute* _next; - MemPool* _memPool; -}; - - -/** The element is a container class. It has a value, the element name, - and can contain other elements, text, comments, and unknowns. - Elements also contain an arbitrary number of attributes. -*/ -class TINYXML2_LIB XMLElement : public XMLNode -{ - friend class XMLDocument; -public: - /// Get the name of an element (which is the Value() of the node.) - const char* Name() const { - return Value(); - } - /// Set the name of the element. - void SetName( const char* str, bool staticMem=false ) { - SetValue( str, staticMem ); - } - - virtual XMLElement* ToElement() { - return this; - } - virtual const XMLElement* ToElement() const { - return this; - } - virtual bool Accept( XMLVisitor* visitor ) const; - - /** Given an attribute name, Attribute() returns the value - for the attribute of that name, or null if none - exists. For example: - - @verbatim - const char* value = ele->Attribute( "foo" ); - @endverbatim - - The 'value' parameter is normally null. However, if specified, - the attribute will only be returned if the 'name' and 'value' - match. This allow you to write code: - - @verbatim - if ( ele->Attribute( "foo", "bar" ) ) callFooIsBar(); - @endverbatim - - rather than: - @verbatim - if ( ele->Attribute( "foo" ) ) { - if ( strcmp( ele->Attribute( "foo" ), "bar" ) == 0 ) callFooIsBar(); - } - @endverbatim - */ - const char* Attribute( const char* name, const char* value=0 ) const; - - /** Given an attribute name, IntAttribute() returns the value - of the attribute interpreted as an integer. The default - value will be returned if the attribute isn't present, - or if there is an error. (For a method with error - checking, see QueryIntAttribute()). - */ - int IntAttribute(const char* name, int defaultValue = 0) const; - /// See IntAttribute() - unsigned UnsignedAttribute(const char* name, unsigned defaultValue = 0) const; - /// See IntAttribute() - int64_t Int64Attribute(const char* name, int64_t defaultValue = 0) const; - /// See IntAttribute() - uint64_t Unsigned64Attribute(const char* name, uint64_t defaultValue = 0) const; - /// See IntAttribute() - bool BoolAttribute(const char* name, bool defaultValue = false) const; - /// See IntAttribute() - double DoubleAttribute(const char* name, double defaultValue = 0) const; - /// See IntAttribute() - float FloatAttribute(const char* name, float defaultValue = 0) const; - - /** Given an attribute name, QueryIntAttribute() returns - XML_SUCCESS, XML_WRONG_ATTRIBUTE_TYPE if the conversion - can't be performed, or XML_NO_ATTRIBUTE if the attribute - doesn't exist. If successful, the result of the conversion - will be written to 'value'. If not successful, nothing will - be written to 'value'. This allows you to provide default - value: - - @verbatim - int value = 10; - QueryIntAttribute( "foo", &value ); // if "foo" isn't found, value will still be 10 - @endverbatim - */ - XMLError QueryIntAttribute( const char* name, int* value ) const { - const XMLAttribute* a = FindAttribute( name ); - if ( !a ) { - return XML_NO_ATTRIBUTE; - } - return a->QueryIntValue( value ); - } - - /// See QueryIntAttribute() - XMLError QueryUnsignedAttribute( const char* name, unsigned int* value ) const { - const XMLAttribute* a = FindAttribute( name ); - if ( !a ) { - return XML_NO_ATTRIBUTE; - } - return a->QueryUnsignedValue( value ); - } - - /// See QueryIntAttribute() - XMLError QueryInt64Attribute(const char* name, int64_t* value) const { - const XMLAttribute* a = FindAttribute(name); - if (!a) { - return XML_NO_ATTRIBUTE; - } - return a->QueryInt64Value(value); - } - - /// See QueryIntAttribute() - XMLError QueryUnsigned64Attribute(const char* name, uint64_t* value) const { - const XMLAttribute* a = FindAttribute(name); - if(!a) { - return XML_NO_ATTRIBUTE; - } - return a->QueryUnsigned64Value(value); - } - - /// See QueryIntAttribute() - XMLError QueryBoolAttribute( const char* name, bool* value ) const { - const XMLAttribute* a = FindAttribute( name ); - if ( !a ) { - return XML_NO_ATTRIBUTE; - } - return a->QueryBoolValue( value ); - } - /// See QueryIntAttribute() - XMLError QueryDoubleAttribute( const char* name, double* value ) const { - const XMLAttribute* a = FindAttribute( name ); - if ( !a ) { - return XML_NO_ATTRIBUTE; - } - return a->QueryDoubleValue( value ); - } - /// See QueryIntAttribute() - XMLError QueryFloatAttribute( const char* name, float* value ) const { - const XMLAttribute* a = FindAttribute( name ); - if ( !a ) { - return XML_NO_ATTRIBUTE; - } - return a->QueryFloatValue( value ); - } - - /// See QueryIntAttribute() - XMLError QueryStringAttribute(const char* name, const char** value) const { - const XMLAttribute* a = FindAttribute(name); - if (!a) { - return XML_NO_ATTRIBUTE; - } - *value = a->Value(); - return XML_SUCCESS; - } - - - - /** Given an attribute name, QueryAttribute() returns - XML_SUCCESS, XML_WRONG_ATTRIBUTE_TYPE if the conversion - can't be performed, or XML_NO_ATTRIBUTE if the attribute - doesn't exist. It is overloaded for the primitive types, - and is a generally more convenient replacement of - QueryIntAttribute() and related functions. - - If successful, the result of the conversion - will be written to 'value'. If not successful, nothing will - be written to 'value'. This allows you to provide default - value: - - @verbatim - int value = 10; - QueryAttribute( "foo", &value ); // if "foo" isn't found, value will still be 10 - @endverbatim - */ - XMLError QueryAttribute( const char* name, int* value ) const { - return QueryIntAttribute( name, value ); - } - - XMLError QueryAttribute( const char* name, unsigned int* value ) const { - return QueryUnsignedAttribute( name, value ); - } - - XMLError QueryAttribute(const char* name, int64_t* value) const { - return QueryInt64Attribute(name, value); - } - - XMLError QueryAttribute(const char* name, uint64_t* value) const { - return QueryUnsigned64Attribute(name, value); - } - - XMLError QueryAttribute( const char* name, bool* value ) const { - return QueryBoolAttribute( name, value ); - } - - XMLError QueryAttribute( const char* name, double* value ) const { - return QueryDoubleAttribute( name, value ); - } - - XMLError QueryAttribute( const char* name, float* value ) const { - return QueryFloatAttribute( name, value ); - } - - /// Sets the named attribute to value. - void SetAttribute( const char* name, const char* value ) { - XMLAttribute* a = FindOrCreateAttribute( name ); - a->SetAttribute( value ); - } - /// Sets the named attribute to value. - void SetAttribute( const char* name, int value ) { - XMLAttribute* a = FindOrCreateAttribute( name ); - a->SetAttribute( value ); - } - /// Sets the named attribute to value. - void SetAttribute( const char* name, unsigned value ) { - XMLAttribute* a = FindOrCreateAttribute( name ); - a->SetAttribute( value ); - } - - /// Sets the named attribute to value. - void SetAttribute(const char* name, int64_t value) { - XMLAttribute* a = FindOrCreateAttribute(name); - a->SetAttribute(value); - } - - /// Sets the named attribute to value. - void SetAttribute(const char* name, uint64_t value) { - XMLAttribute* a = FindOrCreateAttribute(name); - a->SetAttribute(value); - } - - /// Sets the named attribute to value. - void SetAttribute( const char* name, bool value ) { - XMLAttribute* a = FindOrCreateAttribute( name ); - a->SetAttribute( value ); - } - /// Sets the named attribute to value. - void SetAttribute( const char* name, double value ) { - XMLAttribute* a = FindOrCreateAttribute( name ); - a->SetAttribute( value ); - } - /// Sets the named attribute to value. - void SetAttribute( const char* name, float value ) { - XMLAttribute* a = FindOrCreateAttribute( name ); - a->SetAttribute( value ); - } - - /** - Delete an attribute. - */ - void DeleteAttribute( const char* name ); - - /// Return the first attribute in the list. - const XMLAttribute* FirstAttribute() const { - return _rootAttribute; - } - /// Query a specific attribute in the list. - const XMLAttribute* FindAttribute( const char* name ) const; - - /** Convenience function for easy access to the text inside an element. Although easy - and concise, GetText() is limited compared to getting the XMLText child - and accessing it directly. - - If the first child of 'this' is a XMLText, the GetText() - returns the character string of the Text node, else null is returned. - - This is a convenient method for getting the text of simple contained text: - @verbatim - This is text - const char* str = fooElement->GetText(); - @endverbatim - - 'str' will be a pointer to "This is text". - - Note that this function can be misleading. If the element foo was created from - this XML: - @verbatim - This is text - @endverbatim - - then the value of str would be null. The first child node isn't a text node, it is - another element. From this XML: - @verbatim - This is text - @endverbatim - GetText() will return "This is ". - */ - const char* GetText() const; - - /** Convenience function for easy access to the text inside an element. Although easy - and concise, SetText() is limited compared to creating an XMLText child - and mutating it directly. - - If the first child of 'this' is a XMLText, SetText() sets its value to - the given string, otherwise it will create a first child that is an XMLText. - - This is a convenient method for setting the text of simple contained text: - @verbatim - This is text - fooElement->SetText( "Hullaballoo!" ); - Hullaballoo! - @endverbatim - - Note that this function can be misleading. If the element foo was created from - this XML: - @verbatim - This is text - @endverbatim - - then it will not change "This is text", but rather prefix it with a text element: - @verbatim - Hullaballoo!This is text - @endverbatim - - For this XML: - @verbatim - - @endverbatim - SetText() will generate - @verbatim - Hullaballoo! - @endverbatim - */ - void SetText( const char* inText ); - /// Convenience method for setting text inside an element. See SetText() for important limitations. - void SetText( int value ); - /// Convenience method for setting text inside an element. See SetText() for important limitations. - void SetText( unsigned value ); - /// Convenience method for setting text inside an element. See SetText() for important limitations. - void SetText(int64_t value); - /// Convenience method for setting text inside an element. See SetText() for important limitations. - void SetText(uint64_t value); - /// Convenience method for setting text inside an element. See SetText() for important limitations. - void SetText( bool value ); - /// Convenience method for setting text inside an element. See SetText() for important limitations. - void SetText( double value ); - /// Convenience method for setting text inside an element. See SetText() for important limitations. - void SetText( float value ); - - /** - Convenience method to query the value of a child text node. This is probably best - shown by example. Given you have a document is this form: - @verbatim - - 1 - 1.4 - - @endverbatim - - The QueryIntText() and similar functions provide a safe and easier way to get to the - "value" of x and y. - - @verbatim - int x = 0; - float y = 0; // types of x and y are contrived for example - const XMLElement* xElement = pointElement->FirstChildElement( "x" ); - const XMLElement* yElement = pointElement->FirstChildElement( "y" ); - xElement->QueryIntText( &x ); - yElement->QueryFloatText( &y ); - @endverbatim - - @returns XML_SUCCESS (0) on success, XML_CAN_NOT_CONVERT_TEXT if the text cannot be converted - to the requested type, and XML_NO_TEXT_NODE if there is no child text to query. - - */ - XMLError QueryIntText( int* ival ) const; - /// See QueryIntText() - XMLError QueryUnsignedText( unsigned* uval ) const; - /// See QueryIntText() - XMLError QueryInt64Text(int64_t* uval) const; - /// See QueryIntText() - XMLError QueryUnsigned64Text(uint64_t* uval) const; - /// See QueryIntText() - XMLError QueryBoolText( bool* bval ) const; - /// See QueryIntText() - XMLError QueryDoubleText( double* dval ) const; - /// See QueryIntText() - XMLError QueryFloatText( float* fval ) const; - - int IntText(int defaultValue = 0) const; - - /// See QueryIntText() - unsigned UnsignedText(unsigned defaultValue = 0) const; - /// See QueryIntText() - int64_t Int64Text(int64_t defaultValue = 0) const; - /// See QueryIntText() - uint64_t Unsigned64Text(uint64_t defaultValue = 0) const; - /// See QueryIntText() - bool BoolText(bool defaultValue = false) const; - /// See QueryIntText() - double DoubleText(double defaultValue = 0) const; - /// See QueryIntText() - float FloatText(float defaultValue = 0) const; - - /** - Convenience method to create a new XMLElement and add it as last (right) - child of this node. Returns the created and inserted element. - */ - XMLElement* InsertNewChildElement(const char* name); - /// See InsertNewChildElement() - XMLComment* InsertNewComment(const char* comment); - /// See InsertNewChildElement() - XMLText* InsertNewText(const char* text); - /// See InsertNewChildElement() - XMLDeclaration* InsertNewDeclaration(const char* text); - /// See InsertNewChildElement() - XMLUnknown* InsertNewUnknown(const char* text); - - - // internal: - enum ElementClosingType { - OPEN, // - CLOSED, // - CLOSING // - }; - ElementClosingType ClosingType() const { - return _closingType; - } - virtual XMLNode* ShallowClone( XMLDocument* document ) const; - virtual bool ShallowEqual( const XMLNode* compare ) const; - -protected: - char* ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr ); - -private: - XMLElement( XMLDocument* doc ); - virtual ~XMLElement(); - XMLElement( const XMLElement& ); // not supported - void operator=( const XMLElement& ); // not supported - - XMLAttribute* FindOrCreateAttribute( const char* name ); - char* ParseAttributes( char* p, int* curLineNumPtr ); - static void DeleteAttribute( XMLAttribute* attribute ); - XMLAttribute* CreateAttribute(); - - enum { BUF_SIZE = 200 }; - ElementClosingType _closingType; - // The attribute list is ordered; there is no 'lastAttribute' - // because the list needs to be scanned for dupes before adding - // a new attribute. - XMLAttribute* _rootAttribute; -}; - - -enum Whitespace { - PRESERVE_WHITESPACE, - COLLAPSE_WHITESPACE -}; - - -/** A Document binds together all the functionality. - It can be saved, loaded, and printed to the screen. - All Nodes are connected and allocated to a Document. - If the Document is deleted, all its Nodes are also deleted. -*/ -class TINYXML2_LIB XMLDocument : public XMLNode -{ - friend class XMLElement; - // Gives access to SetError and Push/PopDepth, but over-access for everything else. - // Wishing C++ had "internal" scope. - friend class XMLNode; - friend class XMLText; - friend class XMLComment; - friend class XMLDeclaration; - friend class XMLUnknown; -public: - /// constructor - XMLDocument( bool processEntities = true, Whitespace whitespaceMode = PRESERVE_WHITESPACE ); - ~XMLDocument(); - - virtual XMLDocument* ToDocument() { - TIXMLASSERT( this == _document ); - return this; - } - virtual const XMLDocument* ToDocument() const { - TIXMLASSERT( this == _document ); - return this; - } - - /** - Parse an XML file from a character string. - Returns XML_SUCCESS (0) on success, or - an errorID. - - You may optionally pass in the 'nBytes', which is - the number of bytes which will be parsed. If not - specified, TinyXML-2 will assume 'xml' points to a - null terminated string. - */ - XMLError Parse( const char* xml, size_t nBytes=static_cast(-1) ); - - /** - Load an XML file from disk. - Returns XML_SUCCESS (0) on success, or - an errorID. - */ - XMLError LoadFile( const char* filename ); - - /** - Load an XML file from disk. You are responsible - for providing and closing the FILE*. - - NOTE: The file should be opened as binary ("rb") - not text in order for TinyXML-2 to correctly - do newline normalization. - - Returns XML_SUCCESS (0) on success, or - an errorID. - */ - XMLError LoadFile( FILE* ); - - /** - Save the XML file to disk. - Returns XML_SUCCESS (0) on success, or - an errorID. - */ - XMLError SaveFile( const char* filename, bool compact = false ); - - /** - Save the XML file to disk. You are responsible - for providing and closing the FILE*. - - Returns XML_SUCCESS (0) on success, or - an errorID. - */ - XMLError SaveFile( FILE* fp, bool compact = false ); - - bool ProcessEntities() const { - return _processEntities; - } - Whitespace WhitespaceMode() const { - return _whitespaceMode; - } - - /** - Returns true if this document has a leading Byte Order Mark of UTF8. - */ - bool HasBOM() const { - return _writeBOM; - } - /** Sets whether to write the BOM when writing the file. - */ - void SetBOM( bool useBOM ) { - _writeBOM = useBOM; - } - - /** Return the root element of DOM. Equivalent to FirstChildElement(). - To get the first node, use FirstChild(). - */ - XMLElement* RootElement() { - return FirstChildElement(); - } - const XMLElement* RootElement() const { - return FirstChildElement(); - } - - /** Print the Document. If the Printer is not provided, it will - print to stdout. If you provide Printer, this can print to a file: - @verbatim - XMLPrinter printer( fp ); - doc.Print( &printer ); - @endverbatim - - Or you can use a printer to print to memory: - @verbatim - XMLPrinter printer; - doc.Print( &printer ); - // printer.CStr() has a const char* to the XML - @endverbatim - */ - void Print( XMLPrinter* streamer=0 ) const; - virtual bool Accept( XMLVisitor* visitor ) const; - - /** - Create a new Element associated with - this Document. The memory for the Element - is managed by the Document. - */ - XMLElement* NewElement( const char* name ); - /** - Create a new Comment associated with - this Document. The memory for the Comment - is managed by the Document. - */ - XMLComment* NewComment( const char* comment ); - /** - Create a new Text associated with - this Document. The memory for the Text - is managed by the Document. - */ - XMLText* NewText( const char* text ); - /** - Create a new Declaration associated with - this Document. The memory for the object - is managed by the Document. - - If the 'text' param is null, the standard - declaration is used.: - @verbatim - - @endverbatim - */ - XMLDeclaration* NewDeclaration( const char* text=0 ); - /** - Create a new Unknown associated with - this Document. The memory for the object - is managed by the Document. - */ - XMLUnknown* NewUnknown( const char* text ); - - /** - Delete a node associated with this document. - It will be unlinked from the DOM. - */ - void DeleteNode( XMLNode* node ); - - void ClearError() { - SetError(XML_SUCCESS, 0, 0); - } - - /// Return true if there was an error parsing the document. - bool Error() const { - return _errorID != XML_SUCCESS; - } - /// Return the errorID. - XMLError ErrorID() const { - return _errorID; - } - const char* ErrorName() const; - static const char* ErrorIDToName(XMLError errorID); - - /** Returns a "long form" error description. A hopefully helpful - diagnostic with location, line number, and/or additional info. - */ - const char* ErrorStr() const; - - /// A (trivial) utility function that prints the ErrorStr() to stdout. - void PrintError() const; - - /// Return the line where the error occurred, or zero if unknown. - int ErrorLineNum() const - { - return _errorLineNum; - } - - /// Clear the document, resetting it to the initial state. - void Clear(); - - /** - Copies this document to a target document. - The target will be completely cleared before the copy. - If you want to copy a sub-tree, see XMLNode::DeepClone(). - - NOTE: that the 'target' must be non-null. - */ - void DeepCopy(XMLDocument* target) const; - - // internal - char* Identify( char* p, XMLNode** node ); - - // internal - void MarkInUse(const XMLNode* const); - - virtual XMLNode* ShallowClone( XMLDocument* /*document*/ ) const { - return 0; - } - virtual bool ShallowEqual( const XMLNode* /*compare*/ ) const { - return false; - } - -private: - XMLDocument( const XMLDocument& ); // not supported - void operator=( const XMLDocument& ); // not supported - - bool _writeBOM; - bool _processEntities; - XMLError _errorID; - Whitespace _whitespaceMode; - mutable StrPair _errorStr; - int _errorLineNum; - char* _charBuffer; - int _parseCurLineNum; - int _parsingDepth; - // Memory tracking does add some overhead. - // However, the code assumes that you don't - // have a bunch of unlinked nodes around. - // Therefore it takes less memory to track - // in the document vs. a linked list in the XMLNode, - // and the performance is the same. - DynArray _unlinked; - - MemPoolT< sizeof(XMLElement) > _elementPool; - MemPoolT< sizeof(XMLAttribute) > _attributePool; - MemPoolT< sizeof(XMLText) > _textPool; - MemPoolT< sizeof(XMLComment) > _commentPool; - - static const char* _errorNames[XML_ERROR_COUNT]; - - void Parse(); - - void SetError( XMLError error, int lineNum, const char* format, ... ); - - // Something of an obvious security hole, once it was discovered. - // Either an ill-formed XML or an excessively deep one can overflow - // the stack. Track stack depth, and error out if needed. - class DepthTracker { - public: - explicit DepthTracker(XMLDocument * document) { - this->_document = document; - document->PushDepth(); - } - ~DepthTracker() { - _document->PopDepth(); - } - private: - XMLDocument * _document; - }; - void PushDepth(); - void PopDepth(); - - template - NodeType* CreateUnlinkedNode( MemPoolT& pool ); -}; - -template -inline NodeType* XMLDocument::CreateUnlinkedNode( MemPoolT& pool ) -{ - TIXMLASSERT( sizeof( NodeType ) == PoolElementSize ); - TIXMLASSERT( sizeof( NodeType ) == pool.ItemSize() ); - NodeType* returnNode = new (pool.Alloc()) NodeType( this ); - TIXMLASSERT( returnNode ); - returnNode->_memPool = &pool; - - _unlinked.Push(returnNode); - return returnNode; -} - -/** - A XMLHandle is a class that wraps a node pointer with null checks; this is - an incredibly useful thing. Note that XMLHandle is not part of the TinyXML-2 - DOM structure. It is a separate utility class. - - Take an example: - @verbatim - - - - - - - @endverbatim - - Assuming you want the value of "attributeB" in the 2nd "Child" element, it's very - easy to write a *lot* of code that looks like: - - @verbatim - XMLElement* root = document.FirstChildElement( "Document" ); - if ( root ) - { - XMLElement* element = root->FirstChildElement( "Element" ); - if ( element ) - { - XMLElement* child = element->FirstChildElement( "Child" ); - if ( child ) - { - XMLElement* child2 = child->NextSiblingElement( "Child" ); - if ( child2 ) - { - // Finally do something useful. - @endverbatim - - And that doesn't even cover "else" cases. XMLHandle addresses the verbosity - of such code. A XMLHandle checks for null pointers so it is perfectly safe - and correct to use: - - @verbatim - XMLHandle docHandle( &document ); - XMLElement* child2 = docHandle.FirstChildElement( "Document" ).FirstChildElement( "Element" ).FirstChildElement().NextSiblingElement(); - if ( child2 ) - { - // do something useful - @endverbatim - - Which is MUCH more concise and useful. - - It is also safe to copy handles - internally they are nothing more than node pointers. - @verbatim - XMLHandle handleCopy = handle; - @endverbatim - - See also XMLConstHandle, which is the same as XMLHandle, but operates on const objects. -*/ -class TINYXML2_LIB XMLHandle -{ -public: - /// Create a handle from any node (at any depth of the tree.) This can be a null pointer. - explicit XMLHandle( XMLNode* node ) : _node( node ) { - } - /// Create a handle from a node. - explicit XMLHandle( XMLNode& node ) : _node( &node ) { - } - /// Copy constructor - XMLHandle( const XMLHandle& ref ) : _node( ref._node ) { - } - /// Assignment - XMLHandle& operator=( const XMLHandle& ref ) { - _node = ref._node; - return *this; - } - - /// Get the first child of this handle. - XMLHandle FirstChild() { - return XMLHandle( _node ? _node->FirstChild() : 0 ); - } - /// Get the first child element of this handle. - XMLHandle FirstChildElement( const char* name = 0 ) { - return XMLHandle( _node ? _node->FirstChildElement( name ) : 0 ); - } - /// Get the last child of this handle. - XMLHandle LastChild() { - return XMLHandle( _node ? _node->LastChild() : 0 ); - } - /// Get the last child element of this handle. - XMLHandle LastChildElement( const char* name = 0 ) { - return XMLHandle( _node ? _node->LastChildElement( name ) : 0 ); - } - /// Get the previous sibling of this handle. - XMLHandle PreviousSibling() { - return XMLHandle( _node ? _node->PreviousSibling() : 0 ); - } - /// Get the previous sibling element of this handle. - XMLHandle PreviousSiblingElement( const char* name = 0 ) { - return XMLHandle( _node ? _node->PreviousSiblingElement( name ) : 0 ); - } - /// Get the next sibling of this handle. - XMLHandle NextSibling() { - return XMLHandle( _node ? _node->NextSibling() : 0 ); - } - /// Get the next sibling element of this handle. - XMLHandle NextSiblingElement( const char* name = 0 ) { - return XMLHandle( _node ? _node->NextSiblingElement( name ) : 0 ); - } - - /// Safe cast to XMLNode. This can return null. - XMLNode* ToNode() { - return _node; - } - /// Safe cast to XMLElement. This can return null. - XMLElement* ToElement() { - return ( _node ? _node->ToElement() : 0 ); - } - /// Safe cast to XMLText. This can return null. - XMLText* ToText() { - return ( _node ? _node->ToText() : 0 ); - } - /// Safe cast to XMLUnknown. This can return null. - XMLUnknown* ToUnknown() { - return ( _node ? _node->ToUnknown() : 0 ); - } - /// Safe cast to XMLDeclaration. This can return null. - XMLDeclaration* ToDeclaration() { - return ( _node ? _node->ToDeclaration() : 0 ); - } - -private: - XMLNode* _node; -}; - - -/** - A variant of the XMLHandle class for working with const XMLNodes and Documents. It is the - same in all regards, except for the 'const' qualifiers. See XMLHandle for API. -*/ -class TINYXML2_LIB XMLConstHandle -{ -public: - explicit XMLConstHandle( const XMLNode* node ) : _node( node ) { - } - explicit XMLConstHandle( const XMLNode& node ) : _node( &node ) { - } - XMLConstHandle( const XMLConstHandle& ref ) : _node( ref._node ) { - } - - XMLConstHandle& operator=( const XMLConstHandle& ref ) { - _node = ref._node; - return *this; - } - - const XMLConstHandle FirstChild() const { - return XMLConstHandle( _node ? _node->FirstChild() : 0 ); - } - const XMLConstHandle FirstChildElement( const char* name = 0 ) const { - return XMLConstHandle( _node ? _node->FirstChildElement( name ) : 0 ); - } - const XMLConstHandle LastChild() const { - return XMLConstHandle( _node ? _node->LastChild() : 0 ); - } - const XMLConstHandle LastChildElement( const char* name = 0 ) const { - return XMLConstHandle( _node ? _node->LastChildElement( name ) : 0 ); - } - const XMLConstHandle PreviousSibling() const { - return XMLConstHandle( _node ? _node->PreviousSibling() : 0 ); - } - const XMLConstHandle PreviousSiblingElement( const char* name = 0 ) const { - return XMLConstHandle( _node ? _node->PreviousSiblingElement( name ) : 0 ); - } - const XMLConstHandle NextSibling() const { - return XMLConstHandle( _node ? _node->NextSibling() : 0 ); - } - const XMLConstHandle NextSiblingElement( const char* name = 0 ) const { - return XMLConstHandle( _node ? _node->NextSiblingElement( name ) : 0 ); - } - - - const XMLNode* ToNode() const { - return _node; - } - const XMLElement* ToElement() const { - return ( _node ? _node->ToElement() : 0 ); - } - const XMLText* ToText() const { - return ( _node ? _node->ToText() : 0 ); - } - const XMLUnknown* ToUnknown() const { - return ( _node ? _node->ToUnknown() : 0 ); - } - const XMLDeclaration* ToDeclaration() const { - return ( _node ? _node->ToDeclaration() : 0 ); - } - -private: - const XMLNode* _node; -}; - - -/** - Printing functionality. The XMLPrinter gives you more - options than the XMLDocument::Print() method. - - It can: - -# Print to memory. - -# Print to a file you provide. - -# Print XML without a XMLDocument. - - Print to Memory - - @verbatim - XMLPrinter printer; - doc.Print( &printer ); - SomeFunction( printer.CStr() ); - @endverbatim - - Print to a File - - You provide the file pointer. - @verbatim - XMLPrinter printer( fp ); - doc.Print( &printer ); - @endverbatim - - Print without a XMLDocument - - When loading, an XML parser is very useful. However, sometimes - when saving, it just gets in the way. The code is often set up - for streaming, and constructing the DOM is just overhead. - - The Printer supports the streaming case. The following code - prints out a trivially simple XML file without ever creating - an XML document. - - @verbatim - XMLPrinter printer( fp ); - printer.OpenElement( "foo" ); - printer.PushAttribute( "foo", "bar" ); - printer.CloseElement(); - @endverbatim -*/ -class TINYXML2_LIB XMLPrinter : public XMLVisitor -{ -public: - /** Construct the printer. If the FILE* is specified, - this will print to the FILE. Else it will print - to memory, and the result is available in CStr(). - If 'compact' is set to true, then output is created - with only required whitespace and newlines. - */ - XMLPrinter( FILE* file=0, bool compact = false, int depth = 0 ); - virtual ~XMLPrinter() {} - - /** If streaming, write the BOM and declaration. */ - void PushHeader( bool writeBOM, bool writeDeclaration ); - /** If streaming, start writing an element. - The element must be closed with CloseElement() - */ - void OpenElement( const char* name, bool compactMode=false ); - /// If streaming, add an attribute to an open element. - void PushAttribute( const char* name, const char* value ); - void PushAttribute( const char* name, int value ); - void PushAttribute( const char* name, unsigned value ); - void PushAttribute( const char* name, int64_t value ); - void PushAttribute( const char* name, uint64_t value ); - void PushAttribute( const char* name, bool value ); - void PushAttribute( const char* name, double value ); - /// If streaming, close the Element. - virtual void CloseElement( bool compactMode=false ); - - /// Add a text node. - void PushText( const char* text, bool cdata=false ); - /// Add a text node from an integer. - void PushText( int value ); - /// Add a text node from an unsigned. - void PushText( unsigned value ); - /// Add a text node from a signed 64bit integer. - void PushText( int64_t value ); - /// Add a text node from an unsigned 64bit integer. - void PushText( uint64_t value ); - /// Add a text node from a bool. - void PushText( bool value ); - /// Add a text node from a float. - void PushText( float value ); - /// Add a text node from a double. - void PushText( double value ); - - /// Add a comment - void PushComment( const char* comment ); - - void PushDeclaration( const char* value ); - void PushUnknown( const char* value ); - - virtual bool VisitEnter( const XMLDocument& /*doc*/ ); - virtual bool VisitExit( const XMLDocument& /*doc*/ ) { - return true; - } - - virtual bool VisitEnter( const XMLElement& element, const XMLAttribute* attribute ); - virtual bool VisitExit( const XMLElement& element ); - - virtual bool Visit( const XMLText& text ); - virtual bool Visit( const XMLComment& comment ); - virtual bool Visit( const XMLDeclaration& declaration ); - virtual bool Visit( const XMLUnknown& unknown ); - - /** - If in print to memory mode, return a pointer to - the XML file in memory. - */ - const char* CStr() const { - return _buffer.Mem(); - } - /** - If in print to memory mode, return the size - of the XML file in memory. (Note the size returned - includes the terminating null.) - */ - int CStrSize() const { - return _buffer.Size(); - } - /** - If in print to memory mode, reset the buffer to the - beginning. - */ - void ClearBuffer( bool resetToFirstElement = true ) { - _buffer.Clear(); - _buffer.Push(0); - _firstElement = resetToFirstElement; - } - -protected: - virtual bool CompactMode( const XMLElement& ) { return _compactMode; } - - /** Prints out the space before an element. You may override to change - the space and tabs used. A PrintSpace() override should call Print(). - */ - virtual void PrintSpace( int depth ); - void Print( const char* format, ... ); - void Write( const char* data, size_t size ); - inline void Write( const char* data ) { Write( data, strlen( data ) ); } - void Putc( char ch ); - - void SealElementIfJustOpened(); - bool _elementJustOpened; - DynArray< const char*, 10 > _stack; - -private: - void PrintString( const char*, bool restrictedEntitySet ); // prints out, after detecting entities. - - bool _firstElement; - FILE* _fp; - int _depth; - int _textDepth; - bool _processEntities; - bool _compactMode; - - enum { - ENTITY_RANGE = 64, - BUF_SIZE = 200 - }; - bool _entityFlag[ENTITY_RANGE]; - bool _restrictedEntityFlag[ENTITY_RANGE]; - - DynArray< char, 20 > _buffer; - - // Prohibit cloning, intentionally not implemented - XMLPrinter( const XMLPrinter& ); - XMLPrinter& operator=( const XMLPrinter& ); -}; - - -} // tinyxml2 - -#if defined(_MSC_VER) -# pragma warning(pop) -#endif - -#endif // TINYXML2_INCLUDED From c70e6d280a139f7e3f6e6e9fdcc8d17c96c1d6d4 Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Tue, 30 Apr 2024 18:50:06 -0400 Subject: [PATCH 06/59] spdlog from package managers (#4088) --- .github/workflows/apt-deps.txt | 2 +- .github/workflows/test-builds-on-distros.yml | 1 + CMakeLists.txt | 2 +- OTRExporter | 2 +- libultraship | 2 +- soh/CMakeLists.txt | 3 ++- soh/soh/Enhancements/crowd-control/CrowdControl.cpp | 2 +- soh/soh/OTRGlobals.cpp | 2 +- 8 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/apt-deps.txt b/.github/workflows/apt-deps.txt index 62eba03865c..c06068ab467 100644 --- a/.github/workflows/apt-deps.txt +++ b/.github/workflows/apt-deps.txt @@ -1 +1 @@ -libusb-dev libusb-1.0-0-dev libsdl2-dev libsdl2-net-dev libpng-dev libglew-dev libzip-dev zipcmp zipmerge ziptool nlohmann-json3-dev libtinyxml2-dev ninja-build +libusb-dev libusb-1.0-0-dev libsdl2-dev libsdl2-net-dev libpng-dev libglew-dev libzip-dev zipcmp zipmerge ziptool nlohmann-json3-dev libtinyxml2-dev libspdlog-dev ninja-build diff --git a/.github/workflows/test-builds-on-distros.yml b/.github/workflows/test-builds-on-distros.yml index 683e07b240f..36bbc67a92f 100644 --- a/.github/workflows/test-builds-on-distros.yml +++ b/.github/workflows/test-builds-on-distros.yml @@ -1,6 +1,7 @@ # todo: # nlohmann # tinyxml2 +# spdlog name: test-builds-on-distros on: diff --git a/CMakeLists.txt b/CMakeLists.txt index 34fe61b6548..7c1f3dbed57 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,7 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Windows") set(VCPKG_TARGET_TRIPLET x64-windows-static) vcpkg_bootstrap() - vcpkg_install_packages(zlib bzip2 libzip libpng sdl2 sdl2-net glew glfw3 nlohmann-json tinyxml2) + vcpkg_install_packages(zlib bzip2 libzip libpng sdl2 sdl2-net glew glfw3 nlohmann-json tinyxml2 spdlog) if (CMAKE_C_COMPILER_LAUNCHER MATCHES "ccache|sccache") set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT Embedded) diff --git a/OTRExporter b/OTRExporter index 467434c5666..ac64c159b62 160000 --- a/OTRExporter +++ b/OTRExporter @@ -1 +1 @@ -Subproject commit 467434c5666e11a3a7b756ff04401cd54da5c3f2 +Subproject commit ac64c159b62361301f48f7fd05bfd3db931ebc9c diff --git a/libultraship b/libultraship index 6c375a8b5eb..5b67a45fc47 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit 6c375a8b5eb8c44088b5bb2b472d40c50ad36d1f +Subproject commit 5b67a45fc47d8d6e86d104651d83d0939d807ae4 diff --git a/soh/CMakeLists.txt b/soh/CMakeLists.txt index 4ed9fec726e..a32c0ac4fa6 100644 --- a/soh/CMakeLists.txt +++ b/soh/CMakeLists.txt @@ -388,7 +388,6 @@ target_include_directories(${PROJECT_NAME} PRIVATE assets ${CMAKE_CURRENT_SOURCE_DIR}/../libultraship/extern/tinyxml2 ${CMAKE_CURRENT_SOURCE_DIR}/../libultraship/libultraship/Lib/ ${CMAKE_CURRENT_SOURCE_DIR}/../libultraship/libultraship/Lib/libjpeg/include/ - ${CMAKE_CURRENT_SOURCE_DIR}/../libultraship/libultraship/Lib/spdlog/include/ ${CMAKE_CURRENT_SOURCE_DIR}/../libultraship/src/graphic/Fast3D/U64/PR ${CMAKE_CURRENT_SOURCE_DIR}/../libultraship/src/graphic ${CMAKE_CURRENT_SOURCE_DIR}/../ZAPDTR/ZAPDUtils @@ -417,6 +416,7 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Windows") "_UNICODE" STORMLIB_NO_AUTO_LINK "_CRT_SECURE_NO_WARNINGS;" + NOMINMAX ) elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "Win32") target_compile_definitions(${PROJECT_NAME} PRIVATE @@ -434,6 +434,7 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Windows") "UNICODE;" "_UNICODE" STORMLIB_NO_AUTO_LINK + NOMINMAX ) endif() elseif (CMAKE_SYSTEM_NAME STREQUAL "CafeOS") diff --git a/soh/soh/Enhancements/crowd-control/CrowdControl.cpp b/soh/soh/Enhancements/crowd-control/CrowdControl.cpp index 9c0d5cb2df5..6443a7ff3c5 100644 --- a/soh/soh/Enhancements/crowd-control/CrowdControl.cpp +++ b/soh/soh/Enhancements/crowd-control/CrowdControl.cpp @@ -179,7 +179,7 @@ CrowdControl::EffectResult CrowdControl::TranslateGiEnum(GameInteractionEffectQu CrowdControl::Effect* CrowdControl::ParseMessage(nlohmann::json dataReceived) { if (!dataReceived.contains("id") || !dataReceived.contains("type")) { - SPDLOG_ERROR("[CrowdControl] Invalid payload received:\n{}", dataReceived); + SPDLOG_ERROR("[CrowdControl] Invalid payload received:\n{}", dataReceived.dump()); return nullptr; } diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index e796d9f961c..a848d92476d 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -324,7 +324,7 @@ OTRGlobals::OTRGlobals() { auto overlay = context->GetInstance()->GetWindow()->GetGui()->GetGameOverlay(); overlay->LoadFont("Press Start 2P", "fonts/PressStart2P-Regular.ttf", 12.0f); overlay->LoadFont("Fipps", "fonts/Fipps-Regular.otf", 32.0f); - overlay->SetCurrentFont(CVarGetString(CVAR_GAME_OVERLAY_FONT, "Press Start 2P")); + overlay->SetCurrentFont(CVarGetString("gOverlayFont", "Press Start 2P")); context->InitAudio(); From 8480f37f77c7db798ce80bb4c71fc942187babaf Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Tue, 30 Apr 2024 22:49:54 -0400 Subject: [PATCH 07/59] fetch imgui (#4094) --- libultraship | 2 +- soh/soh/Enhancements/audio/AudioEditor.h | 2 +- soh/soh/Enhancements/controls/InputViewer.cpp | 2 +- soh/soh/Enhancements/controls/SohInputEditorWindow.h | 2 +- soh/soh/Enhancements/debugconsole.cpp | 4 ++-- .../Enhancements/game-interactor/GameInteractor_Remote.cpp | 4 ++-- soh/soh/Enhancements/randomizer/randomizer.cpp | 4 ++-- soh/soh/Enhancements/resolution-editor/ResolutionEditor.cpp | 2 +- soh/soh/OTRGlobals.cpp | 2 +- soh/soh/SohGui.cpp | 4 ++-- soh/soh/SohMenuBar.cpp | 2 +- soh/soh/SohModals.cpp | 2 +- soh/soh/UIWidgets.cpp | 4 ++-- soh/soh/UIWidgets.hpp | 2 +- 14 files changed, 19 insertions(+), 19 deletions(-) diff --git a/libultraship b/libultraship index 5b67a45fc47..8b4a7a627b3 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit 5b67a45fc47d8d6e86d104651d83d0939d807ae4 +Subproject commit 8b4a7a627b36abbc21955bed8adc59eaf9385fcb diff --git a/soh/soh/Enhancements/audio/AudioEditor.h b/soh/soh/Enhancements/audio/AudioEditor.h index 45c2654e56d..93ae3c44066 100644 --- a/soh/soh/Enhancements/audio/AudioEditor.h +++ b/soh/soh/Enhancements/audio/AudioEditor.h @@ -7,7 +7,7 @@ #ifndef IMGUI_DEFINE_MATH_OPERATORS #define IMGUI_DEFINE_MATH_OPERATORS #endif -#include +#include #include "AudioCollection.h" class AudioEditor : public Ship::GuiWindow { diff --git a/soh/soh/Enhancements/controls/InputViewer.cpp b/soh/soh/Enhancements/controls/InputViewer.cpp index 52b3527cc64..c9b85c607c4 100644 --- a/soh/soh/Enhancements/controls/InputViewer.cpp +++ b/soh/soh/Enhancements/controls/InputViewer.cpp @@ -7,7 +7,7 @@ #ifndef IMGUI_DEFINE_MATH_OPERATORS #define IMGUI_DEFINE_MATH_OPERATORS #endif -#include +#include #include #include diff --git a/soh/soh/Enhancements/controls/SohInputEditorWindow.h b/soh/soh/Enhancements/controls/SohInputEditorWindow.h index 079aa805b89..b418a041ea0 100644 --- a/soh/soh/Enhancements/controls/SohInputEditorWindow.h +++ b/soh/soh/Enhancements/controls/SohInputEditorWindow.h @@ -5,7 +5,7 @@ #ifndef IMGUI_DEFINE_MATH_OPERATORS #define IMGUI_DEFINE_MATH_OPERATORS #endif -#include +#include #include #include #include diff --git a/soh/soh/Enhancements/debugconsole.cpp b/soh/soh/Enhancements/debugconsole.cpp index 7c73ea61e4e..470785f7b53 100644 --- a/soh/soh/Enhancements/debugconsole.cpp +++ b/soh/soh/Enhancements/debugconsole.cpp @@ -20,8 +20,8 @@ #ifndef IMGUI_DEFINE_MATH_OPERATORS #define IMGUI_DEFINE_MATH_OPERATORS #endif -#include -#include +#include +#include #undef PATH_HACK #undef Path diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor_Remote.cpp b/soh/soh/Enhancements/game-interactor/GameInteractor_Remote.cpp index 1d933d8d277..662d2ea78ca 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor_Remote.cpp +++ b/soh/soh/Enhancements/game-interactor/GameInteractor_Remote.cpp @@ -2,8 +2,8 @@ #include "GameInteractor.h" #include -#include -#include +#include +#include #include #include #include diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index 0c7f30e0f70..187e50eab60 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -15,8 +15,8 @@ #ifndef IMGUI_DEFINE_MATH_OPERATORS #define IMGUI_DEFINE_MATH_OPERATORS #endif -#include -#include +#include +#include #include "../custom-message/CustomMessageTypes.h" #include "../item-tables/ItemTableManager.h" #include "../presets.h" diff --git a/soh/soh/Enhancements/resolution-editor/ResolutionEditor.cpp b/soh/soh/Enhancements/resolution-editor/ResolutionEditor.cpp index 69dec46bc18..e20f469396a 100644 --- a/soh/soh/Enhancements/resolution-editor/ResolutionEditor.cpp +++ b/soh/soh/Enhancements/resolution-editor/ResolutionEditor.cpp @@ -1,5 +1,5 @@ #include "ResolutionEditor.h" -#include +#include #include #include diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index a848d92476d..a6ea015dad3 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -319,7 +319,7 @@ OTRGlobals::OTRGlobals() { context->InitConsole(); auto sohInputEditorWindow = std::make_shared("gControllerConfigurationEnabled", "Input Editor"); - context->InitWindow(sohInputEditorWindow); + context->InitWindow({ sohInputEditorWindow }); auto overlay = context->GetInstance()->GetWindow()->GetGui()->GetGameOverlay(); overlay->LoadFont("Press Start 2P", "fonts/PressStart2P-Regular.ttf", 12.0f); diff --git a/soh/soh/SohGui.cpp b/soh/soh/SohGui.cpp index 9055087bdab..0ac185706c0 100644 --- a/soh/soh/SohGui.cpp +++ b/soh/soh/SohGui.cpp @@ -11,8 +11,8 @@ #ifndef IMGUI_DEFINE_MATH_OPERATORS #define IMGUI_DEFINE_MATH_OPERATORS #endif -#include -#include +#include +#include #include #include diff --git a/soh/soh/SohMenuBar.cpp b/soh/soh/SohMenuBar.cpp index e7a99b39f6d..6639f7a8a2e 100644 --- a/soh/soh/SohMenuBar.cpp +++ b/soh/soh/SohMenuBar.cpp @@ -2,7 +2,7 @@ #ifndef IMGUI_DEFINE_MATH_OPERATORS #define IMGUI_DEFINE_MATH_OPERATORS #endif -#include "ImGui/imgui.h" +#include #include "regex" #include "public/bridge/consolevariablebridge.h" #include diff --git a/soh/soh/SohModals.cpp b/soh/soh/SohModals.cpp index 087bc8ab12b..44dc93d743e 100644 --- a/soh/soh/SohModals.cpp +++ b/soh/soh/SohModals.cpp @@ -1,5 +1,5 @@ #include "SohModals.h" -#include "ImGui/imgui.h" +#include #include #include #include diff --git a/soh/soh/UIWidgets.cpp b/soh/soh/UIWidgets.cpp index 5bf2e7b7329..bd0843e960b 100644 --- a/soh/soh/UIWidgets.cpp +++ b/soh/soh/UIWidgets.cpp @@ -10,8 +10,8 @@ #ifndef IMGUI_DEFINE_MATH_OPERATORS #define IMGUI_DEFINE_MATH_OPERATORS #endif -#include -#include +#include +#include #include #include diff --git a/soh/soh/UIWidgets.hpp b/soh/soh/UIWidgets.hpp index f1086a94499..70580340c90 100644 --- a/soh/soh/UIWidgets.hpp +++ b/soh/soh/UIWidgets.hpp @@ -16,7 +16,7 @@ #ifndef IMGUI_DEFINE_MATH_OPERATORS #define IMGUI_DEFINE_MATH_OPERATORS #endif -#include +#include namespace UIWidgets { From 56fe44968996b88a412885c8b978ef881455d763 Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Wed, 1 May 2024 12:53:33 -0400 Subject: [PATCH 08/59] fetchcontent stormlib (#4095) --- OTRExporter | 2 +- libultraship | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/OTRExporter b/OTRExporter index ac64c159b62..8815dd98f25 160000 --- a/OTRExporter +++ b/OTRExporter @@ -1 +1 @@ -Subproject commit ac64c159b62361301f48f7fd05bfd3db931ebc9c +Subproject commit 8815dd98f25d5f4c7a80f162e9ee1ec0a3f7dd4e diff --git a/libultraship b/libultraship index 8b4a7a627b3..fd603a40e0c 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit 8b4a7a627b36abbc21955bed8adc59eaf9385fcb +Subproject commit fd603a40e0c847092d142d77f144ec44c386f323 From 715bf39d4373ef22dea3ca6a229db7bb2e2d5e95 Mon Sep 17 00:00:00 2001 From: Malkierian Date: Wed, 1 May 2024 11:48:51 -0700 Subject: [PATCH 09/59] Incorporate LUS CMake CVar system (#4093) * Incorporate LUS CMake CVar system. Customize all LUS CMake CVars to align with plans for preset system. Swap "gOverlayFont" usage back to LUS CVar macro. * Change CMake sets to use the cache to allow for including LUS's file for the add_compile_defines and remove the duplication on SoH's side. * Move SoH CMake CVars to `soh-cvars.cmake` for clarity. --- CMake/lus-cvars.cmake | 24 +++++++++++++ CMake/soh-cvars.cmake | 26 ++++++++++++++ CMakeLists.txt | 2 ++ soh/soh/Enhancements/bootcommands.c | 2 +- soh/soh/Enhancements/mods.cpp | 4 +-- soh/soh/Enhancements/presets.h | 8 ++--- .../resolution-editor/ResolutionEditor.cpp | 16 ++++----- soh/soh/OTRGlobals.cpp | 18 +++++----- soh/soh/OTRGlobals.h | 30 ++++++++-------- soh/soh/SohGui.cpp | 2 +- soh/soh/SohMenuBar.cpp | 34 +++++++++---------- soh/soh/config/ConfigUpdaters.cpp | 2 +- soh/soh/resource/type/Skeleton.cpp | 2 +- soh/src/code/game.c | 2 +- soh/src/code/gfxprint.c | 2 +- 15 files changed, 113 insertions(+), 61 deletions(-) create mode 100644 CMake/lus-cvars.cmake create mode 100644 CMake/soh-cvars.cmake diff --git a/CMake/lus-cvars.cmake b/CMake/lus-cvars.cmake new file mode 100644 index 00000000000..e7376cfe28d --- /dev/null +++ b/CMake/lus-cvars.cmake @@ -0,0 +1,24 @@ +set(CVAR_VSYNC_ENABLED "${CVAR_PREFIX_SETTING}.VsyncEnabled" CACHE STRING "") +set(CVAR_Z_FIGHTING_MODE "${CVAR_PREFIX_SETTING}.ZFightingMode" CACHE STRING "") +set(CVAR_NEW_FILE_DROPPED "${CVAR_PREFIX_GENERAL}.NewFileDropped" CACHE STRING "") +set(CVAR_DROPPED_FILE "${CVAR_PREFIX_GENERAL}.DroppedFile" CACHE STRING "") +set(CVAR_INTERNAL_RESOLUTION "${CVAR_PREFIX_SETTING}.InternalResolution" CACHE STRING "") +set(CVAR_MSAA_VALUE "${CVAR_PREFIX_SETTING}.MSAAValue" CACHE STRING "") +set(CVAR_SDL_WINDOWED_FULLSCREEN "${CVAR_PREFIX_SETTING}.SdlWindowedFullscreen" CACHE STRING "") +set(CVAR_TEXTURE_FILTER "${CVAR_PREFIX_SETTING}.TextureFilter" CACHE STRING "") +set(CVAR_IMGUI_CONTROLLER_NAV "${CVAR_PREFIX_SETTING}.ControlNav" CACHE STRING "") +set(CVAR_CONSOLE_WINDOW_OPEN "${CVAR_PREFIX_WINDOW}.Console" CACHE STRING "") +set(CVAR_CONTROLLER_CONFIGURATION_WINDOW_OPEN "${CVAR_PREFIX_WINDOW}.ControllerConfiguration" CACHE STRING "") +set(CVAR_CONTROLLER_DISCONNECTED_WINDOW_OPEN "${CVAR_PREFIX_WINDOW}.ControllerDisconnected" CACHE STRING "") +set(CVAR_CONTROLLER_REORDERING_WINDOW_OPEN "${CVAR_PREFIX_WINDOW}.ControllerReordering" CACHE STRING "") +set(CVAR_GFX_DEBUGGER_WINDOW_OPEN "${CVAR_PREFIX_WINDOW}.GfxDebugger" CACHE STRING "") +set(CVAR_STATS_WINDOW_OPEN "${CVAR_PREFIX_WINDOW}.Stats" CACHE STRING "") +set(CVAR_ENABLE_MULTI_VIEWPORTS "${CVAR_PREFIX_SETTING}.EnableMultiViewports" CACHE STRING "") +set(CVAR_LOW_RES_MODE "${CVAR_PREFIX_SETTING}.LowResMode" CACHE STRING "") +set(CVAR_SIMULATED_INPUT_LAG "${CVAR_PREFIX_SETTING}.SimulatedInputLag" CACHE STRING "") +set(CVAR_ALT_ASSETS "${CVAR_PREFIX_ENHANCEMENT}.AltAssets" CACHE STRING "") +set(CVAR_GAME_OVERLAY_FONT "${CVAR_PREFIX_SETTING}.OverlayFont" CACHE STRING "") +set(CVAR_MENU_BAR_OPEN "${CVAR_PREFIX_SETTING}.OpenMenuBar" CACHE STRING "") +set(CVAR_PREFIX_CONTROLLERS "${CVAR_PREFIX_SETTING}.Controllers" CACHE STRING "") +set(CVAR_PREFIX_ADVANCED_RESOLUTION "${CVAR_PREFIX_SETTING}.AdvancedResolution" CACHE STRING "") +include("libultraship/cmake/cvars.cmake") \ No newline at end of file diff --git a/CMake/soh-cvars.cmake b/CMake/soh-cvars.cmake new file mode 100644 index 00000000000..e5ff8a38418 --- /dev/null +++ b/CMake/soh-cvars.cmake @@ -0,0 +1,26 @@ +set(CVAR_PREFIX_RANDOMIZER_ENHANCEMENT "gRandoEnhancements") +set(CVAR_PREFIX_RANDOMIZER_SETTING "gRandoSettings") +set(CVAR_PREFIX_COSMETIC "gCosmetics") +set(CVAR_PREFIX_AUDIO "gAudioEditor") +set(CVAR_PREFIX_CHEAT "gCheats") +set(CVAR_PREFIX_ENHANCEMENT "gEnhancements") +set(CVAR_PREFIX_SETTING "gSettings") +set(CVAR_PREFIX_WINDOW "gOpenWindows") +set(CVAR_PREFIX_TRACKER "gTrackers") +set(CVAR_PREFIX_DEVELOPER_TOOLS "gDeveloperTools") +set(CVAR_PREFIX_GENERAL "gGeneral") +set(CVAR_PREFIX_REMOTE "gRemote") +add_compile_definitions( + CVAR_PREFIX_RANDOMIZER_ENHANCEMENT="${CVAR_PREFIX_RANDOMIZER_ENHANCEMENT}" + CVAR_PREFIX_RANDOMIZER_SETTING="${CVAR_PREFIX_RANDOMIZER_SETTING}" + CVAR_PREFIX_COSMETIC="${CVAR_PREFIX_COSMETIC}" + CVAR_PREFIX_AUDIO="${CVAR_PREFIX_AUDIO}" + CVAR_PREFIX_CHEAT="${CVAR_PREFIX_CHEAT}" + CVAR_PREFIX_ENHANCEMENT="${CVAR_PREFIX_ENHANCEMENT}" + CVAR_PREFIX_SETTING="${CVAR_PREFIX_SETTING}" + CVAR_PREFIX_WINDOW="${CVAR_PREFIX_WINDOW}" + CVAR_PREFIX_TRACKER="${CVAR_PREFIX_TRACKER}" + CVAR_PREFIX_DEVELOPER_TOOLS="${CVAR_PREFIX_DEVELOPER_TOOLS}" + CVAR_PREFIX_GENERAL="${CVAR_PREFIX_GENERAL}" + CVAR_PREFIX_REMOTE="${CVAR_PREFIX_REMOTE}" +) \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c1f3dbed57..891d6ad26cd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,8 @@ set(CMAKE_CXX_STANDARD 20 CACHE STRING "The C++ standard to use") set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X deployment version") project(Ship VERSION 8.0.5 LANGUAGES C CXX) +include(CMake/soh-cvars.cmake) +include(CMake/lus-cvars.cmake) set(PROJECT_BUILD_NAME "MacReady Foxtrot" CACHE STRING "") set(PROJECT_TEAM "github.com/harbourmasters" CACHE STRING "") diff --git a/soh/soh/Enhancements/bootcommands.c b/soh/soh/Enhancements/bootcommands.c index 385a544a608..be3a766dc28 100644 --- a/soh/soh/Enhancements/bootcommands.c +++ b/soh/soh/Enhancements/bootcommands.c @@ -29,7 +29,7 @@ void BootCommands_Init() CVarClear("gCheatEasyPauseBufferLastInputs"); CVarClear("gCheatEasyPauseBufferTimer"); #if defined(__SWITCH__) || defined(__WIIU__) - CVarRegisterInteger("gControlNav", 1); // always enable controller nav on switch/wii u + CVarRegisterInteger(CVAR_IMGUI_CONTROLLER_NAV, 1); // always enable controller nav on switch/wii u #endif } diff --git a/soh/soh/Enhancements/mods.cpp b/soh/soh/Enhancements/mods.cpp index 8f9819f0857..8ddd59cef98 100644 --- a/soh/soh/Enhancements/mods.cpp +++ b/soh/soh/Enhancements/mods.cpp @@ -660,10 +660,10 @@ void UpdateDirtPathFixState(int32_t sceneNum) { case SCENE_HYRULE_FIELD: case SCENE_KOKIRI_FOREST: case SCENE_HYRULE_CASTLE: - CVarSetInteger("gZFightingMode", CVarGetInteger(CVAR_ENHANCEMENT("SceneSpecificDirtPathFix"), ZFIGHT_FIX_DISABLED)); + CVarSetInteger(CVAR_Z_FIGHTING_MODE, CVarGetInteger(CVAR_ENHANCEMENT("SceneSpecificDirtPathFix"), ZFIGHT_FIX_DISABLED)); return; default: - CVarClear("gZFightingMode"); + CVarClear(CVAR_Z_FIGHTING_MODE); } } diff --git a/soh/soh/Enhancements/presets.h b/soh/soh/Enhancements/presets.h index 8064fc66ca7..1392691df06 100644 --- a/soh/soh/Enhancements/presets.h +++ b/soh/soh/Enhancements/presets.h @@ -223,12 +223,12 @@ const std::vector enhancementsCvars = { CVAR_ENHANCEMENT("DisableLOD"), CVAR_ENHANCEMENT("DisableDrawDistance"), CVAR_ENHANCEMENT("DisableKokiriDrawDistance"), - "gLowResMode", + CVAR_LOW_RES_MODE, CVAR_ENHANCEMENT("DrawLineupTick"), CVAR_ENHANCEMENT("QuickBongoKill"), CVAR_ENHANCEMENT("FirstPersonGauntlets"), CVAR_ENHANCEMENT("SceneSpecificDirtPathFix"), - "gZFightingMode", + CVAR_Z_FIGHTING_MODE, CVAR_ENHANCEMENT("AuthenticLogo"), CVAR_ENHANCEMENT("PauseLiveLinkRotationSpeed"), CVAR_ENHANCEMENT("BowReticle"), @@ -282,7 +282,7 @@ const std::vector enhancementsCvars = { }; const std::vector cheatCvars = { - "gConsoleEnabled", + CVAR_CONSOLE_WINDOW_OPEN, CVAR_WINDOW("ActorViewer"), CVAR_WINDOW("CollisionViewer"), CVAR_WINDOW("DLViewer"), @@ -336,7 +336,7 @@ const std::vector cheatCvars = { CVAR_CHEAT("NoFishDespawn"), CVAR_CHEAT("NoBugsDespawn"), "gWalkModifierDoesntChangeJump", - "gStatsEnabled", + CVAR_STATS_WINDOW_OPEN, CVAR_CHEAT("SaveStatesEnabled"), CVAR_CHEAT("SaveStatePromise"), CVAR_DEVELOPER_TOOLS("RegEditEnabled"), diff --git a/soh/soh/Enhancements/resolution-editor/ResolutionEditor.cpp b/soh/soh/Enhancements/resolution-editor/ResolutionEditor.cpp index e20f469396a..b522879cb12 100644 --- a/soh/soh/Enhancements/resolution-editor/ResolutionEditor.cpp +++ b/soh/soh/Enhancements/resolution-editor/ResolutionEditor.cpp @@ -114,19 +114,19 @@ void AdvancedResolutionSettingsWindow::DrawElement() { // The original resolution slider (for convenience) const bool disabled_resolutionSlider = (CVarGetInteger("gAdvancedResolution.VerticalResolutionToggle", 0) && CVarGetInteger("gAdvancedResolution.Enabled", 0)) || - CVarGetInteger("gLowResMode", 0); - if (UIWidgets::EnhancementSliderFloat("Internal Resolution: %.1f%%", "##IMul", "gInternalResolution", 0.5f, + CVarGetInteger(CVAR_LOW_RES_MODE, 0); + if (UIWidgets::EnhancementSliderFloat("Internal Resolution: %.1f%%", "##IMul", CVAR_INTERNAL_RESOLUTION, 0.5f, 2.0f, "", 1.0f, true, true, disabled_resolutionSlider)) { Ship::Context::GetInstance()->GetWindow()->SetResolutionMultiplier( - CVarGetFloat("gInternalResolution", 1)); + CVarGetFloat(CVAR_INTERNAL_RESOLUTION, 1)); } UIWidgets::Tooltip("Multiplies your output resolution by the value entered."); // The original MSAA slider (also for convenience) #ifndef __WIIU__ - if (UIWidgets::PaddedEnhancementSliderInt("MSAA: %d", "##IMSAA", "gMSAAValue", 1, 8, "", 1, true, true, + if (UIWidgets::PaddedEnhancementSliderInt("MSAA: %d", "##IMSAA", CVAR_MSAA_VALUE, 1, 8, "", 1, true, true, false)) { - Ship::Context::GetInstance()->GetWindow()->SetMsaaLevel(CVarGetInteger("gMSAAValue", 1)); + Ship::Context::GetInstance()->GetWindow()->SetMsaaLevel(CVarGetInteger(CVAR_MSAA_VALUE, 1)); }; UIWidgets::Tooltip( "Activates multi-sample anti-aliasing when above 1x, up to 8x for 8 samples for every pixel.\n\n" @@ -135,7 +135,7 @@ void AdvancedResolutionSettingsWindow::DrawElement() { #endif // N64 Mode toggle (again for convenience) - // UIWidgets::PaddedEnhancementCheckbox("(Enhancements>Graphics) N64 Mode", "gLowResMode", false, false, false, "", UIWidgets::CheckboxGraphics::Cross, false); + // UIWidgets::PaddedEnhancementCheckbox("(Enhancements>Graphics) N64 Mode", CVAR_LOW_RES_MODE, false, false, false, "", UIWidgets::CheckboxGraphics::Cross, false); } UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); @@ -143,7 +143,7 @@ void AdvancedResolutionSettingsWindow::DrawElement() { UIWidgets::PaddedEnhancementCheckbox("Enable advanced settings.", "gAdvancedResolution.Enabled", false, false, false, "", UIWidgets::CheckboxGraphics::Cross, false); // Error/Warning display - if (!CVarGetInteger("gLowResMode", 0)) { + if (!CVarGetInteger(CVAR_LOW_RES_MODE, 0)) { if (IsDroppingFrames()) { // Significant frame drop warning ImGui::TextColored(messageColor[MESSAGE_WARNING], ICON_FA_EXCLAMATION_TRIANGLE " Significant frame rate (FPS) drops may be occuring."); @@ -156,7 +156,7 @@ void AdvancedResolutionSettingsWindow::DrawElement() { ICON_FA_QUESTION_CIRCLE " \"N64 Mode\" is overriding these settings."); ImGui::SameLine(); if (ImGui::Button("Click to disable")) { - CVarSetInteger("gLowResMode", 0); + CVarSetInteger(CVAR_LOW_RES_MODE, 0); CVarSave(); } } diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index a6ea015dad3..744db9561e7 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -318,13 +318,13 @@ OTRGlobals::OTRGlobals() { context->InitCrashHandler(); context->InitConsole(); - auto sohInputEditorWindow = std::make_shared("gControllerConfigurationEnabled", "Input Editor"); + auto sohInputEditorWindow = std::make_shared(CVAR_CONTROLLER_CONFIGURATION_WINDOW_OPEN, "Input Editor"); context->InitWindow({ sohInputEditorWindow }); auto overlay = context->GetInstance()->GetWindow()->GetGui()->GetGameOverlay(); overlay->LoadFont("Press Start 2P", "fonts/PressStart2P-Regular.ttf", 12.0f); overlay->LoadFont("Fipps", "fonts/Fipps-Regular.otf", 32.0f); - overlay->SetCurrentFont(CVarGetString("gOverlayFont", "Press Start 2P")); + overlay->SetCurrentFont(CVarGetString(CVAR_GAME_OVERLAY_FONT, "Press Start 2P")); context->InitAudio(); @@ -1330,13 +1330,13 @@ extern "C" void Graph_StartFrame() { } #endif - if (CVarGetInteger("gNewFileDropped", 0)) { - std::string filePath = SohUtils::Sanitize(CVarGetString("gDroppedFile", "")); + if (CVarGetInteger(CVAR_NEW_FILE_DROPPED, 0)) { + std::string filePath = SohUtils::Sanitize(CVarGetString(CVAR_DROPPED_FILE, "")); if (!filePath.empty()) { GameInteractor::Instance->ExecuteHooks(filePath); } - CVarClear("gNewFileDropped"); - CVarClear("gDroppedFile"); + CVarClear(CVAR_NEW_FILE_DROPPED); + CVarClear(CVAR_DROPPED_FILE); } OTRGlobals::Instance->context->GetWindow()->StartFrame(); @@ -1408,7 +1408,7 @@ extern "C" void Graph_ProcessGfxCommands(Gfx* commands) { ToggleAltAssetsAtEndOfFrame = false; // Actually update the CVar now before runing the alt asset update listeners - CVarSetInteger("gAltAssets", !CVarGetInteger("gAltAssets", 0)); + CVarSetInteger(CVAR_ALT_ASSETS, !CVarGetInteger(CVAR_ALT_ASSETS, 0)); gfx_texture_cache_clear(); SOH::SkeletonPatcher::UpdateSkeletons(); GameInteractor::Instance->ExecuteHooks(); @@ -1587,7 +1587,7 @@ extern "C" uint8_t ResourceMgr_FileAltExists(const char* filePath) { // Unloads a resource if an alternate version exists when alt assets are enabled // The resource is only removed from the internal cache to prevent it from used in the next resource lookup extern "C" void ResourceMgr_UnloadOriginalWhenAltExists(const char* resName) { - if (CVarGetInteger("gAltAssets", 0) && ResourceMgr_FileAltExists((char*) resName)) { + if (CVarGetInteger(CVAR_ALT_ASSETS, 0) && ResourceMgr_FileAltExists((char*) resName)) { ResourceMgr_UnloadResource((char*) resName); } } @@ -1938,7 +1938,7 @@ extern "C" SkeletonHeader* ResourceMgr_LoadSkeletonByName(const char* path, Skel pathStr = pathStr.substr(sOtr.length()); } - bool isAlt = CVarGetInteger("gAltAssets", 0); + bool isAlt = CVarGetInteger(CVAR_ALT_ASSETS, 0); if (isAlt) { pathStr = Ship::IResource::gAltAssetPrefix + pathStr; diff --git a/soh/soh/OTRGlobals.h b/soh/soh/OTRGlobals.h index 3a1b3e1f60c..73cb58d9764 100644 --- a/soh/soh/OTRGlobals.h +++ b/soh/soh/OTRGlobals.h @@ -65,21 +65,21 @@ class OTRGlobals uint32_t IsGameMasterQuest(); #endif -#define CVAR_RANDOMIZER_ENHANCEMENT(var) "gRandoEnhancements." var -#define CVAR_RANDOMIZER_SETTING(var) "gRandoSettings." var -#define CVAR_COSMETIC(var) "gCosmetics." var -#define CVAR_AUDIO(var) "gAudioEditor." var -#define CVAR_CHEAT(var) "gCheats." var -#define CVAR_ENHANCEMENT(var) "gEnhancements." var -#define CVAR_SETTING(var) "gSettings." var -#define CVAR_WINDOW(var) "gOpenWindows." var -#define CVAR_TRACKER(var) "gTrackers." var -#define CVAR_TRACKER_ITEM(var) CVAR_TRACKER("ItemTracker." var) -#define CVAR_TRACKER_CHECK(var) CVAR_TRACKER("CheckTracker." var) -#define CVAR_TRACKER_ENTRANCE(var) CVAR_TRACKER("EntranceTracker." var) -#define CVAR_DEVELOPER_TOOLS(var) "gDeveloperTools." var -#define CVAR_GENERAL(var) "gGeneral." var -#define CVAR_REMOTE(var) "gRemote." var +#define CVAR_RANDOMIZER_ENHANCEMENT(var) CVAR_PREFIX_RANDOMIZER_ENHANCEMENT "." var +#define CVAR_RANDOMIZER_SETTING(var) CVAR_PREFIX_RANDOMIZER_SETTING "." var +#define CVAR_COSMETIC(var) CVAR_PREFIX_COSMETIC "." var +#define CVAR_AUDIO(var) CVAR_PREFIX_AUDIO "." var +#define CVAR_CHEAT(var) CVAR_PREFIX_CHEAT "." var +#define CVAR_ENHANCEMENT(var) CVAR_PREFIX_ENHANCEMENT "." var +#define CVAR_SETTING(var) CVAR_PREFIX_SETTING "." var +#define CVAR_WINDOW(var) CVAR_PREFIX_WINDOW "." var +#define CVAR_TRACKER(var) CVAR_PREFIX_TRACKER "." var +#define CVAR_TRACKER_ITEM(var) CVAR_TRACKER(".ItemTracker." var) +#define CVAR_TRACKER_CHECK(var) CVAR_TRACKER(".CheckTracker." var) +#define CVAR_TRACKER_ENTRANCE(var) CVAR_TRACKER(".EntranceTracker." var) +#define CVAR_DEVELOPER_TOOLS(var) CVAR_PREFIX_DEVELOPER_TOOLS "." var +#define CVAR_GENERAL(var) CVAR_PREFIX_GENERAL "." var +#define CVAR_REMOTE(var) CVAR_PREFIX_REMOTE "." var #ifndef __cplusplus void InitOTR(void); diff --git a/soh/soh/SohGui.cpp b/soh/soh/SohGui.cpp index 0ac185706c0..e7eb998dd63 100644 --- a/soh/soh/SohGui.cpp +++ b/soh/soh/SohGui.cpp @@ -139,7 +139,7 @@ namespace SohGui { void SetupGuiElements() { auto gui = Ship::Context::GetInstance()->GetWindow()->GetGui(); - mSohMenuBar = std::make_shared("gOpenMenuBar", CVarGetInteger("gOpenMenuBar", 0)); + mSohMenuBar = std::make_shared(CVAR_MENU_BAR_OPEN, CVarGetInteger(CVAR_MENU_BAR_OPEN, 0)); gui->SetMenuBar(std::reinterpret_pointer_cast(mSohMenuBar)); if (gui->GetMenuBar() && !gui->GetMenuBar()->IsVisible()) { diff --git a/soh/soh/SohMenuBar.cpp b/soh/soh/SohMenuBar.cpp index 6639f7a8a2e..fbcf2496a4f 100644 --- a/soh/soh/SohMenuBar.cpp +++ b/soh/soh/SohMenuBar.cpp @@ -231,7 +231,7 @@ void DrawSettingsMenu() { ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f); ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.22f, 0.38f, 0.56f, 1.0f)); if (mInputEditorWindow) { - if (ImGui::Button(GetWindowButtonText("Controller Mapping", CVarGetInteger("gControllerConfigurationEnabled", 0)).c_str(), ImVec2 (-1.0f, 0.0f))) { + if (ImGui::Button(GetWindowButtonText("Controller Mapping", CVarGetInteger(CVAR_CONTROLLER_CONFIGURATION_WINDOW_OPEN, 0)).c_str(), ImVec2 (-1.0f, 0.0f))) { mInputEditorWindow->ToggleVisibility(); } } @@ -239,7 +239,7 @@ void DrawSettingsMenu() { ImGui::PopStyleColor(1); ImGui::PopStyleVar(3); #ifndef __SWITCH__ - UIWidgets::EnhancementCheckbox("Menubar Controller Navigation", "gControlNav"); + UIWidgets::EnhancementCheckbox("Menubar Controller Navigation", CVAR_IMGUI_CONTROLLER_NAV); UIWidgets::Tooltip("Allows controller navigation of the SOH menu bar (Settings, Enhancements,...)\nCAUTION: This will disable game inputs while the menubar is visible.\n\nD-pad to move between items, A to select, and X to grab focus on the menu bar"); UIWidgets::PaddedSeparator(); #endif @@ -260,7 +260,7 @@ void DrawSettingsMenu() { ImGui::PopStyleColor(1); ImGui::PopStyleVar(3); - UIWidgets::PaddedEnhancementSliderInt("Simulated Input Lag: %d frames", "##SimulatedInputLag", "gSimulatedInputLag", 0, 6, "", 0, true, true, false); + UIWidgets::PaddedEnhancementSliderInt("Simulated Input Lag: %d frames", "##SimulatedInputLag", CVAR_SIMULATED_INPUT_LAG, 0, 6, "", 0, true, true, false); UIWidgets::Tooltip("Buffers your inputs to be executed a specified amount of frames later"); ImGui::EndMenu(); @@ -272,9 +272,9 @@ void DrawSettingsMenu() { #ifndef __APPLE__ const bool disabled_resolutionSlider = CVarGetInteger("gAdvancedResolution.VerticalResolutionToggle", 0) && CVarGetInteger("gAdvancedResolution.Enabled", 0); - if (UIWidgets::EnhancementSliderFloat("Internal Resolution: %.1f %%", "##IMul", "gInternalResolution", 0.5f, + if (UIWidgets::EnhancementSliderFloat("Internal Resolution: %.1f %%", "##IMul", CVAR_INTERNAL_RESOLUTION, 0.5f, 2.0f, "", 1.0f, true, true, disabled_resolutionSlider)) { - Ship::Context::GetInstance()->GetWindow()->SetResolutionMultiplier(CVarGetFloat("gInternalResolution", 1)); + Ship::Context::GetInstance()->GetWindow()->SetResolutionMultiplier(CVarGetFloat(CVAR_INTERNAL_RESOLUTION, 1)); } UIWidgets::Tooltip("Resolution scale. Multiplies output resolution by this value, on each axis relative to window size.\n" "Lower values may improve performance.\n" @@ -305,9 +305,9 @@ void DrawSettingsMenu() { #ifndef __WIIU__ if (UIWidgets::PaddedEnhancementSliderInt( - (CVarGetInteger("gMSAAValue", 1) == 1) ? "Anti-aliasing (MSAA): Off" : "Anti-aliasing (MSAA): %d", - "##IMSAA", "gMSAAValue", 1, 8, "", 1, true, true, false)) { - Ship::Context::GetInstance()->GetWindow()->SetMsaaLevel(CVarGetInteger("gMSAAValue", 1)); + (CVarGetInteger(CVAR_MSAA_VALUE, 1) == 1) ? "Anti-aliasing (MSAA): Off" : "Anti-aliasing (MSAA): %d", + "##IMSAA", CVAR_MSAA_VALUE, 1, 8, "", 1, true, true, false)) { + Ship::Context::GetInstance()->GetWindow()->SetMsaaLevel(CVarGetInteger(CVAR_MSAA_VALUE, 1)); } UIWidgets::Tooltip("Activates MSAA (multi-sample anti-aliasing) from 2x up to 8x, to smooth the edges of rendered geometry.\n" "Higher sample count will result in smoother edges on models, but may reduce performance.\n\n" @@ -479,22 +479,22 @@ void DrawSettingsMenu() { } if (Ship::Context::GetInstance()->GetWindow()->CanDisableVerticalSync()) { - UIWidgets::PaddedEnhancementCheckbox("Enable Vsync", "gVsyncEnabled", true, false); + UIWidgets::PaddedEnhancementCheckbox("Enable Vsync", CVAR_VSYNC_ENABLED, true, false); UIWidgets::Tooltip("Activate vertical sync, to prevent screen tearing."); } if (Ship::Context::GetInstance()->GetWindow()->SupportsWindowedFullscreen()) { - UIWidgets::PaddedEnhancementCheckbox("Windowed fullscreen", "gSdlWindowedFullscreen", true, false); + UIWidgets::PaddedEnhancementCheckbox("Windowed fullscreen", CVAR_SDL_WINDOWED_FULLSCREEN, true, false); } if (Ship::Context::GetInstance()->GetWindow()->GetGui()->SupportsViewports()) { - UIWidgets::PaddedEnhancementCheckbox("Allow multi-windows (Needs reload)", "gEnableMultiViewports", true, false, false, "", UIWidgets::CheckboxGraphics::Cross, true); + UIWidgets::PaddedEnhancementCheckbox("Allow multi-windows (Needs reload)", CVAR_ENABLE_MULTI_VIEWPORTS, true, false, false, "", UIWidgets::CheckboxGraphics::Cross, true); UIWidgets::Tooltip("Allows windows to be able to be dragged off of the main game window. Requires a reload to take effect."); } // If more filters are added to LUS, make sure to add them to the filters list here ImGui::Text("Texture Filtering (Needs reload)"); - UIWidgets::EnhancementCombobox("gTextureFilter", filters, FILTER_THREE_POINT); + UIWidgets::EnhancementCombobox(CVAR_TEXTURE_FILTER, filters, FILTER_THREE_POINT); UIWidgets::Tooltip("Texture filtering, aka texture smoothing. Requires a reload to take effect.\n\n" "Three-Point: Replicates real N64 texture filtering.\n" "Bilinear: If Three-Point causes poor performance, try this.\n" @@ -1059,10 +1059,10 @@ void DrawEnhancementsMenu() { if (ImGui::BeginMenu("Graphics")) { if (ImGui::BeginMenu("Mods")) { - if (UIWidgets::PaddedEnhancementCheckbox("Use Alternate Assets", "gAltAssets", false, false)) { + if (UIWidgets::PaddedEnhancementCheckbox("Use Alternate Assets", CVAR_ALT_ASSETS, false, false)) { // The checkbox will flip the alt asset CVar, but we instead want it to change at the end of the game frame // We toggle it back while setting the flag to update the CVar later - CVarSetInteger("gAltAssets", !CVarGetInteger("gAltAssets", 0)); + CVarSetInteger(CVAR_ALT_ASSETS, !CVarGetInteger(CVAR_ALT_ASSETS, 0)); ToggleAltAssetsAtEndOfFrame = true; } UIWidgets::Tooltip("Toggle between standard assets and alternate assets. Usually mods will indicate if this setting has to be used or not."); @@ -1147,7 +1147,7 @@ void DrawEnhancementsMenu() { UIWidgets::PaddedEnhancementCheckbox("Scale Adult Equipment as Child", CVAR_ENHANCEMENT("ScaleAdultEquimentAsChild"), true, false); UIWidgets::Tooltip("Scales all of the Adult Equipment, as well and moving some a bit, to fit on Child Link Better. May not work properly with some mods."); } - UIWidgets::PaddedEnhancementCheckbox("N64 Mode", "gLowResMode", true, false); + UIWidgets::PaddedEnhancementCheckbox("N64 Mode", CVAR_LOW_RES_MODE, true, false); UIWidgets::Tooltip("Sets aspect ratio to 4:3 and lowers resolution to 240p, the N64's native resolution"); UIWidgets::PaddedEnhancementCheckbox("Glitch line-up tick", CVAR_ENHANCEMENT("DrawLineupTick"), true, false); UIWidgets::Tooltip("Displays a tick in the top center of the screen to help with glitch line-ups in SoH, as traditional UI based line-ups do not work outside of 4:3"); @@ -1680,14 +1680,14 @@ void DrawDeveloperToolsMenu() { ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f); ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.22f, 0.38f, 0.56f, 1.0f)); if (mStatsWindow) { - if (ImGui::Button(GetWindowButtonText("Stats", CVarGetInteger("gStatsEnabled", 0)).c_str(), ImVec2(-1.0f, 0.0f))) { + if (ImGui::Button(GetWindowButtonText("Stats", CVarGetInteger(CVAR_STATS_WINDOW_OPEN, 0)).c_str(), ImVec2(-1.0f, 0.0f))) { mStatsWindow->ToggleVisibility(); } UIWidgets::Tooltip("Shows the stats window, with your FPS and frametimes, and the OS you're playing on"); } UIWidgets::Spacer(0); if (mConsoleWindow) { - if (ImGui::Button(GetWindowButtonText("Console", CVarGetInteger("gConsoleEnabled", 0)).c_str(), ImVec2(-1.0f, 0.0f))) { + if (ImGui::Button(GetWindowButtonText("Console", CVarGetInteger(CVAR_CONSOLE_WINDOW_OPEN, 0)).c_str(), ImVec2(-1.0f, 0.0f))) { mConsoleWindow->ToggleVisibility(); } UIWidgets::Tooltip("Enables the console window, allowing you to input commands, type help for some examples"); diff --git a/soh/soh/config/ConfigUpdaters.cpp b/soh/soh/config/ConfigUpdaters.cpp index 994505dd676..b3d137c1f9e 100644 --- a/soh/soh/config/ConfigUpdaters.cpp +++ b/soh/soh/config/ConfigUpdaters.cpp @@ -52,7 +52,7 @@ namespace SOH { conf->Erase("Game.Patches Archive"); } if (CVarGetInteger("gDirtPathFix", 0) != 0) { - CVarSetInteger("gZFightingMode", CVarGetInteger("gDirtPathFix", 0)); + CVarSetInteger(CVAR_Z_FIGHTING_MODE, CVarGetInteger("gDirtPathFix", 0)); CVarClear("gDirtPathFix"); } if (CVarGetInteger("gRandomizedEnemies", 0) != 0) { diff --git a/soh/soh/resource/type/Skeleton.cpp b/soh/soh/resource/type/Skeleton.cpp index 8abce78db80..8ac676c5557 100644 --- a/soh/soh/resource/type/Skeleton.cpp +++ b/soh/soh/resource/type/Skeleton.cpp @@ -65,7 +65,7 @@ void SkeletonPatcher::ClearSkeletons() } void SkeletonPatcher::UpdateSkeletons() { - bool isHD = CVarGetInteger("gAltAssets", 0); + bool isHD = CVarGetInteger(CVAR_ALT_ASSETS, 0); for (auto skel : skeletons) { Skeleton* newSkel = (Skeleton*)Ship::Context::GetInstance()->GetResourceManager() diff --git a/soh/src/code/game.c b/soh/src/code/game.c index 5fca89dbdc8..8d97177fd2a 100644 --- a/soh/src/code/game.c +++ b/soh/src/code/game.c @@ -467,7 +467,7 @@ void GameState_Destroy(GameState* gameState) { // Performing clear skeletons before unload resources fixes an actor heap corruption crash due to the skeleton patching system. ResourceMgr_ClearSkeletons(); - if (CVarGetInteger("gAltAssets", 0)) { + if (CVarGetInteger(CVAR_ALT_ASSETS, 0)) { ResourceUnloadDirectory("alt/*"); gfx_texture_cache_clear(); } diff --git a/soh/src/code/gfxprint.c b/soh/src/code/gfxprint.c index 8a0dbead434..9caad46a8f2 100644 --- a/soh/src/code/gfxprint.c +++ b/soh/src/code/gfxprint.c @@ -141,7 +141,7 @@ static const ALIGN_ASSET(2) char rGfxPrintFontDataAlt[] = drGfxPrintFontDataAlt; // https://github.com/HarbourMasters/Shipwright/issues/2762 typedef enum {hardcoded, otrDefault, otrAlt} font_texture_t; font_texture_t GfxPrint_TextureToUse() { - if (CVarGetInteger("gAltAssets", 0) && ResourceMgr_FileExists(rGfxPrintFontDataAlt)) { + if (CVarGetInteger(CVAR_ALT_ASSETS, 0) && ResourceMgr_FileExists(rGfxPrintFontDataAlt)) { // If we have alt assets enabled, and we have alt prefixed font texture, use that return otrAlt; } else if (ResourceMgr_FileExists(rGfxPrintFontData)) { From fd9cd9c5ebf611ed1c3f42c6406182c0534c8099 Mon Sep 17 00:00:00 2001 From: Archez Date: Wed, 1 May 2024 16:41:17 -0400 Subject: [PATCH 10/59] Fix: add workaround for boost versions >=1.84.0 (#4098) --- .../container_hash/detail/hash_range_32.hpp | 15 ++++++++++-- .../boost_custom/container_hash/hash_32.hpp | 24 +++++++++++++++---- .../boost_custom/container_hash/version.hpp | 2 ++ 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/soh/include/boost_custom/container_hash/detail/hash_range_32.hpp b/soh/include/boost_custom/container_hash/detail/hash_range_32.hpp index 7430152ab66..cfa0a2a2d20 100644 --- a/soh/include/boost_custom/container_hash/detail/hash_range_32.hpp +++ b/soh/include/boost_custom/container_hash/detail/hash_range_32.hpp @@ -46,10 +46,18 @@ template<> struct is_char_type: public boost::true_type {}; #endif // #if !BOOST_VERSION_HAS_HASH_RANGE +#if BOOST_USE_STD_TYPES +#define BOOST_ENABLE_IF std::enable_if +#define BOOST_IS_SAME std::is_same +#else +#define BOOST_ENABLE_IF boost::enable_if_ +#define BOOST_IS_SAME is_same +#endif + template -inline typename boost::enable_if_< +inline typename BOOST_ENABLE_IF< is_char_type::value_type>::value && - is_same::iterator_category, std::random_access_iterator_tag>::value, + BOOST_IS_SAME::iterator_category, std::random_access_iterator_tag>::value, std::size_t>::type hash_range_32( uint32_t seed, It first, It last ) { @@ -114,4 +122,7 @@ std::size_t>::type } // namespace hash_detail } // namespace boost +#undef BOOST_ENABLE_IF +#undef BOOST_IS_SAME + #endif // #ifndef BOOST_HASH_DETAIL_HASH_RANGE_32_HPP diff --git a/soh/include/boost_custom/container_hash/hash_32.hpp b/soh/include/boost_custom/container_hash/hash_32.hpp index 4b955c43a02..eaf459a3439 100644 --- a/soh/include/boost_custom/container_hash/hash_32.hpp +++ b/soh/include/boost_custom/container_hash/hash_32.hpp @@ -23,6 +23,18 @@ #endif // #if !BOOST_VERSION_HAS_HASH_RANGE +#if BOOST_USE_STD_TYPES +#define BOOST_ENABLE_IF std::enable_if +#define BOOST_IS_INTEGRAL hash_detail::is_integral +#define BOOST_IS_UNSIGNED is_unsigned +#define BOOST_MAKE_UNSIGNED make_unsigned +#else +#define BOOST_ENABLE_IF boost::enable_if_ +#define BOOST_IS_INTEGRAL boost::is_integral +#define BOOST_IS_UNSIGNED boost::is_unsigned +#define BOOST_MAKE_UNSIGNED boost::make_unsigned +#endif + namespace boost { @@ -36,7 +48,7 @@ namespace boost { template sizeof(uint32_t)), - bool is_unsigned = boost::is_unsigned::value, + bool is_unsigned = BOOST_IS_UNSIGNED::value, std::size_t size_t_bits = sizeof(uint32_t) * CHAR_BIT, std::size_t type_bits = sizeof(T) * CHAR_BIT> struct hash_integral_impl_32; @@ -53,7 +65,7 @@ namespace boost { static uint32_t fn( T v ) { - typedef typename boost::make_unsigned::type U; + typedef typename BOOST_MAKE_UNSIGNED::type U; if( v >= 0 ) { @@ -97,7 +109,7 @@ namespace boost } // namespace hash_detail template - typename boost::enable_if_::value, uint32_t>::type + typename BOOST_ENABLE_IF::value, uint32_t>::type hash_value_32( T v ) { return hash_detail::hash_integral_impl_32::fn( v ); @@ -106,7 +118,7 @@ namespace boost // contiguous ranges (string, vector, array) #if BOOST_VERSION_HAS_HASH_RANGE template - typename boost::enable_if_::value, uint32_t>::type + typename BOOST_ENABLE_IF::value, uint32_t>::type hash_value_32( T const& v ) { return boost::hash_range_32( v.data(), v.data() + v.size() ); @@ -168,5 +180,9 @@ namespace boost } // namespace boost #undef BOOST_HASH_CHAR_TRAITS +#undef BOOST_ENABLE_IF +#undef BOOST_IS_INTEGRAL +#undef BOOST_IS_UNSIGNED +#undef BOOST_MAKE_UNSIGNED #endif // #ifndef BOOST_FUNCTIONAL_HASH_HASH_32_HPP diff --git a/soh/include/boost_custom/container_hash/version.hpp b/soh/include/boost_custom/container_hash/version.hpp index 22ad6634cfc..3863b507c87 100644 --- a/soh/include/boost_custom/container_hash/version.hpp +++ b/soh/include/boost_custom/container_hash/version.hpp @@ -6,4 +6,6 @@ #define BOOST_VERSION_HAS_HASH_RANGE ((BOOST_VERSION / 100 % 1000) >= 81) +#define BOOST_USE_STD_TYPES ((BOOST_VERSION / 100 % 1000) >= 84) + #endif // #ifndef BOOST_CONTAINER_HASH_VERSION_HPP From 345cef9b781c3b029c300c2b2c684bbb55e41ef2 Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Wed, 1 May 2024 22:47:40 -0400 Subject: [PATCH 11/59] detangle zapdutils (#4096) --- OTRExporter | 2 +- ZAPDTR | 2 +- libultraship | 2 +- soh/CMakeLists.txt | 10 ---------- soh/soh/Enhancements/audio/AudioCollection.cpp | 2 +- soh/soh/Enhancements/audio/AudioEditor.cpp | 2 +- soh/soh/Enhancements/controls/SohInputEditorWindow.cpp | 2 +- soh/soh/Enhancements/debugconsole.cpp | 2 +- soh/soh/Extractor/Extract.cpp | 2 +- soh/soh/OTRGlobals.cpp | 2 +- soh/soh/z_message_OTR.cpp | 2 +- soh/soh/z_play_otr.cpp | 2 +- soh/soh/z_scene_otr.cpp | 2 +- 13 files changed, 12 insertions(+), 22 deletions(-) diff --git a/OTRExporter b/OTRExporter index 8815dd98f25..c1e30dad1b3 160000 --- a/OTRExporter +++ b/OTRExporter @@ -1 +1 @@ -Subproject commit 8815dd98f25d5f4c7a80f162e9ee1ec0a3f7dd4e +Subproject commit c1e30dad1b333a6fb19a6b00b680d17e6f7d773a diff --git a/ZAPDTR b/ZAPDTR index 9f9d0be3c91..222cb8a23bd 160000 --- a/ZAPDTR +++ b/ZAPDTR @@ -1 +1 @@ -Subproject commit 9f9d0be3c914354ecabab3695581f1123c13ac20 +Subproject commit 222cb8a23bd0fa8b901b1654ac5d6cc2ecb25a2e diff --git a/libultraship b/libultraship index fd603a40e0c..986d037126f 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit fd603a40e0c847092d142d77f144ec44c386f323 +Subproject commit 986d037126f13d83bc35daa15a115c714a6fb2b3 diff --git a/soh/CMakeLists.txt b/soh/CMakeLists.txt index a32c0ac4fa6..f8ee476b86b 100644 --- a/soh/CMakeLists.txt +++ b/soh/CMakeLists.txt @@ -92,10 +92,6 @@ if (NOT TARGET libultraship) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../libultraship ${CMAKE_BINARY_DIR}/libultraship) endif() -if (NOT TARGET ZAPDUtils) - add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../ZAPDTR/ZAPDUtils ${CMAKE_BINARY_DIR}/ZAPDUtils) -endif() - if (NOT TARGET ZAPDLib) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../ZAPDTR/ZAPD ${CMAKE_BINARY_DIR}/ZAPD) endif() @@ -390,7 +386,6 @@ target_include_directories(${PROJECT_NAME} PRIVATE assets ${CMAKE_CURRENT_SOURCE_DIR}/../libultraship/libultraship/Lib/libjpeg/include/ ${CMAKE_CURRENT_SOURCE_DIR}/../libultraship/src/graphic/Fast3D/U64/PR ${CMAKE_CURRENT_SOURCE_DIR}/../libultraship/src/graphic - ${CMAKE_CURRENT_SOURCE_DIR}/../ZAPDTR/ZAPDUtils ${CMAKE_CURRENT_SOURCE_DIR}/../ZAPDTR/ZAPD/resource/type ${SDL2-INCLUDE} ${SDL2-NET-INCLUDE} @@ -666,7 +661,6 @@ endif() # Dependencies ################################################################################ add_dependencies(${PROJECT_NAME} - ZAPDUtils libultraship ) if(NOT CMAKE_SYSTEM_NAME MATCHES "NintendoSwitch|CafeOS") @@ -680,7 +674,6 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Windows") if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64") set(ADDITIONAL_LIBRARY_DEPENDENCIES "libultraship;" - "ZAPDUtils;" "ZAPDLib;" "glu32;" "SDL2::SDL2;" @@ -695,7 +688,6 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Windows") elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "Win32") set(ADDITIONAL_LIBRARY_DEPENDENCIES "libultraship;" - "ZAPDUtils;" "ZAPDLib;" "glu32;" "SDL2::SDL2;" @@ -713,7 +705,6 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "NintendoSwitch") find_package(Threads REQUIRED) set(ADDITIONAL_LIBRARY_DEPENDENCIES "libultraship;" - "ZAPDUtils;" SDL2::SDL2 -lglad Threads::Threads @@ -735,7 +726,6 @@ else() find_package(Threads REQUIRED) set(ADDITIONAL_LIBRARY_DEPENDENCIES "libultraship;" - "ZAPDUtils;" "ZAPDLib;" SDL2::SDL2 "$<$:SDL2_net::SDL2_net>" diff --git a/soh/soh/Enhancements/audio/AudioCollection.cpp b/soh/soh/Enhancements/audio/AudioCollection.cpp index 8f9c01d0afa..dadcbf2aca3 100644 --- a/soh/soh/Enhancements/audio/AudioCollection.cpp +++ b/soh/soh/Enhancements/audio/AudioCollection.cpp @@ -2,7 +2,7 @@ #include "sequence.h" #include "sfx.h" #include -#include +#include #include #include #include diff --git a/soh/soh/Enhancements/audio/AudioEditor.cpp b/soh/soh/Enhancements/audio/AudioEditor.cpp index f33f73b3d5d..3b0c2bb123b 100644 --- a/soh/soh/Enhancements/audio/AudioEditor.cpp +++ b/soh/soh/Enhancements/audio/AudioEditor.cpp @@ -9,7 +9,7 @@ #include #include "../randomizer/3drando/random.hpp" #include "../../OTRGlobals.h" -#include +#include #include "../../UIWidgets.hpp" #include "AudioCollection.h" #include "soh/Enhancements/game-interactor/GameInteractor.h" diff --git a/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp b/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp index be71c7de157..f5acca70b0d 100644 --- a/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp +++ b/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp @@ -1,5 +1,5 @@ #include "SohInputEditorWindow.h" -#include +#include #include "soh/OTRGlobals.h" #include "../../UIWidgets.hpp" #include "z64.h" diff --git a/soh/soh/Enhancements/debugconsole.cpp b/soh/soh/Enhancements/debugconsole.cpp index 470785f7b53..ad51f1e4b01 100644 --- a/soh/soh/Enhancements/debugconsole.cpp +++ b/soh/soh/Enhancements/debugconsole.cpp @@ -13,7 +13,7 @@ #define Path _Path #define PATH_HACK -#include +#include #include #include diff --git a/soh/soh/Extractor/Extract.cpp b/soh/soh/Extractor/Extract.cpp index b08783763e8..673afc8a645 100644 --- a/soh/soh/Extractor/Extract.cpp +++ b/soh/soh/Extractor/Extract.cpp @@ -6,7 +6,7 @@ #endif #include "Extract.h" #include "portable-file-dialogs.h" -#include +#include #include "variables.h" #ifdef unix diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 744db9561e7..4f54e4e80aa 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -47,7 +47,7 @@ #include "z64.h" #include "macros.h" #include "Fonts.h" -#include +#include #include "Enhancements/custom-message/CustomMessageManager.h" #include "Enhancements/presets.h" #include "util.h" diff --git a/soh/soh/z_message_OTR.cpp b/soh/soh/z_message_OTR.cpp index 49e1e91c483..9136d916f04 100644 --- a/soh/soh/z_message_OTR.cpp +++ b/soh/soh/z_message_OTR.cpp @@ -1,7 +1,7 @@ #include "OTRGlobals.h" #include #include "soh/resource/type/Scene.h" -#include +#include #include "global.h" #include "vt.h" #include "soh/resource/type/Text.h" diff --git a/soh/soh/z_play_otr.cpp b/soh/soh/z_play_otr.cpp index ff485664d5c..237b48ef37b 100644 --- a/soh/soh/z_play_otr.cpp +++ b/soh/soh/z_play_otr.cpp @@ -1,7 +1,7 @@ #include "OTRGlobals.h" #include #include "soh/resource/type/Scene.h" -#include +#include #include "soh/Enhancements/game-interactor/GameInteractor.h" #include "global.h" #include "vt.h" diff --git a/soh/soh/z_scene_otr.cpp b/soh/soh/z_scene_otr.cpp index 6c5ba67df2c..0aa92e0ec22 100644 --- a/soh/soh/z_scene_otr.cpp +++ b/soh/soh/z_scene_otr.cpp @@ -1,7 +1,7 @@ #include "OTRGlobals.h" #include #include "soh/resource/type/Scene.h" -#include +#include #include "global.h" #include "vt.h" #include "soh/resource/type/CollisionHeader.h" From bcf5a0c307c71e58bec8deda90605ef720d6055c Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Thu, 2 May 2024 00:14:36 -0400 Subject: [PATCH 12/59] support lus factories no longer being registered in `RegisterGlobalResourceFactories` (#4099) --- libultraship | 2 +- soh/soh/OTRGlobals.cpp | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/libultraship b/libultraship index 986d037126f..33ede265298 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit 986d037126f13d83bc35daa15a115c714a6fb2b3 +Subproject commit 33ede265298930577193c51ca1f2a0b291744ea3 diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 4f54e4e80aa..4149ee461e6 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -92,6 +92,12 @@ GameInteractorSail* GameInteractorSail::Instance; #include // Resource Types/Factories +#include "resource/type/Array.h" +#include "resource/type/Blob.h" +#include "resource/type/DisplayList.h" +#include "resource/type/Matrix.h" +#include "resource/type/Texture.h" +#include "resource/type/Vertex.h" #include "soh/resource/type/SohResourceType.h" #include "soh/resource/type/Animation.h" #include "soh/resource/type/AudioSample.h" @@ -105,6 +111,12 @@ GameInteractorSail* GameInteractorSail::Instance; #include "soh/resource/type/Skeleton.h" #include "soh/resource/type/SkeletonLimb.h" #include "soh/resource/type/Text.h" +#include "resource/factory/ArrayFactory.h" +#include "resource/factory/BlobFactory.h" +#include "resource/factory/DisplayListFactory.h" +#include "resource/factory/MatrixFactory.h" +#include "resource/factory/TextureFactory.h" +#include "resource/factory/VertexFactory.h" #include "soh/resource/importer/AnimationFactory.h" #include "soh/resource/importer/AudioSampleFactory.h" #include "soh/resource/importer/AudioSequenceFactory.h" @@ -331,6 +343,15 @@ OTRGlobals::OTRGlobals() { SPDLOG_INFO("Starting Ship of Harkinian version {}", (char*)gBuildVersion); auto loader = context->GetResourceManager()->GetResourceLoader(); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Texture", static_cast(LUS::ResourceType::Texture), 0); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Texture", static_cast(LUS::ResourceType::Texture), 1); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Vertex", static_cast(LUS::ResourceType::Vertex), 0); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_XML, "Vertex", static_cast(LUS::ResourceType::Vertex), 0); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "DisplayList", static_cast(LUS::ResourceType::DisplayList), 0); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_XML, "DisplayList", static_cast(LUS::ResourceType::DisplayList), 0); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Matrix", static_cast(LUS::ResourceType::Matrix), 0); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Array", static_cast(LUS::ResourceType::Array), 0); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Blob", static_cast(LUS::ResourceType::Blob), 0); loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Animation", static_cast(SOH::ResourceType::SOH_Animation), 0); loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "PlayerAnimation", static_cast(SOH::ResourceType::SOH_PlayerAnimation), 0); loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Room", static_cast(SOH::ResourceType::SOH_Room), 0); // Is room scene? maybe? From 725670d9984b23a5254a28dbfdbf54d68364e1a4 Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Thu, 2 May 2024 14:43:52 -0400 Subject: [PATCH 13/59] support lus strhash64 change (#4102) --- OTRExporter | 2 +- libultraship | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/OTRExporter b/OTRExporter index c1e30dad1b3..3cea9ee7c01 160000 --- a/OTRExporter +++ b/OTRExporter @@ -1 +1 @@ -Subproject commit c1e30dad1b333a6fb19a6b00b680d17e6f7d773a +Subproject commit 3cea9ee7c017d842aa4d9ceeb8d3ffbf29c6effb diff --git a/libultraship b/libultraship index 33ede265298..0a45004554c 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit 33ede265298930577193c51ca1f2a0b291744ea3 +Subproject commit 0a45004554c0917c771300957a7cd87271516965 From e02e4ead02e30b1c01bfebcaf14f403e4f3c921c Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Fri, 3 May 2024 11:07:07 -0400 Subject: [PATCH 14/59] support lus fetching stb (#4105) --- ZAPDTR | 2 +- libultraship | 2 +- soh/soh/OTRGlobals.cpp | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/ZAPDTR b/ZAPDTR index 222cb8a23bd..f38a9c92eb9 160000 --- a/ZAPDTR +++ b/ZAPDTR @@ -1 +1 @@ -Subproject commit 222cb8a23bd0fa8b901b1654ac5d6cc2ecb25a2e +Subproject commit f38a9c92eb99368c0607acf356d5651ebdc96f51 diff --git a/libultraship b/libultraship index 0a45004554c..f55d3910e7b 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit 0a45004554c0917c771300957a7cd87271516965 +Subproject commit f55d3910e7ba29f6973512c15cde21d2a0b2e292 diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 4149ee461e6..86d96afbd51 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -22,7 +22,6 @@ #include #endif #include -#include #define DRMP3_IMPLEMENTATION #include #define DRWAV_IMPLEMENTATION From b6fc54ad8b70421f2fe1792024b77c26a88882ff Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Fri, 3 May 2024 12:55:38 -0400 Subject: [PATCH 15/59] support lus `dr_libs` removal (#4108) --- libultraship | 2 +- soh/soh/OTRGlobals.cpp | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/libultraship b/libultraship index f55d3910e7b..7d71a290657 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit f55d3910e7ba29f6973512c15cde21d2a0b2e292 +Subproject commit 7d71a290657a2d3b09a83e8b33025e807f4fb38e diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 86d96afbd51..2dd324fe864 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -22,10 +22,6 @@ #include #endif #include -#define DRMP3_IMPLEMENTATION -#include -#define DRWAV_IMPLEMENTATION -#include #include #include "Enhancements/speechsynthesizer/SpeechSynthesizer.h" #include "Enhancements/controls/SohInputEditorWindow.h" From 6443a986d9751b87a0b4e82c15f82a9971f88201 Mon Sep 17 00:00:00 2001 From: Malkierian Date: Sun, 5 May 2024 12:14:55 -0700 Subject: [PATCH 16/59] Final Step of CVar macro/sectionalizing (#4107) * p * Missed the prefix renames. * More missed ones. * Mostly finished cleanup. Removed a few CVars and some related functionality. * Bit more (prepping non-existent title card color editing). * Resolve gCrowdControl. * Final cleanup. * Universal constant, not acceleration... * Preset CVars. --- soh/soh/Enhancements/bootcommands.c | 15 +- soh/soh/Enhancements/controls/InputViewer.cpp | 136 +-- soh/soh/Enhancements/controls/InputViewer.h | 2 + .../controls/SohInputEditorWindow.cpp | 122 +-- .../cosmetics/CosmeticsEditor.cpp | 157 +-- .../cosmetics/authenticGfxPatches.cpp | 4 +- soh/soh/Enhancements/debugger/actorViewer.cpp | 9 +- soh/soh/Enhancements/debugger/colViewer.cpp | 129 ++- .../Enhancements/debugger/debugSaveEditor.cpp | 2 +- soh/soh/Enhancements/debugger/valueViewer.cpp | 5 +- .../GameInteractor_RawAction.cpp | 20 +- soh/soh/Enhancements/gameplaystats.cpp | 28 +- soh/soh/Enhancements/gameplaystats.h | 2 +- soh/soh/Enhancements/mods.cpp | 16 +- soh/soh/Enhancements/nametag.cpp | 2 +- soh/soh/Enhancements/presets.cpp | 2 +- soh/soh/Enhancements/presets.h | 88 +- .../randomizer/3drando/rando_main.cpp | 7 +- .../Enhancements/randomizer/randomizer.cpp | 14 +- .../randomizer/randomizer_check_tracker.cpp | 6 +- .../resolution-editor/ResolutionEditor.cpp | 101 +- soh/soh/Enhancements/tts/tts.cpp | 40 +- soh/soh/OTRGlobals.cpp | 36 +- soh/soh/SaveManager.cpp | 4 +- soh/soh/SohGui.cpp | 2 +- soh/soh/SohMenuBar.cpp | 60 +- soh/soh/UIWidgets.cpp | 8 +- soh/src/code/audioMgr.c | 8 +- soh/src/code/audio_playback.c | 4 +- soh/src/code/audio_synthesis.c | 2 +- soh/src/code/code_800EC960.c | 24 +- soh/src/code/game.c | 2 +- soh/src/code/gfxprint.c | 4 +- soh/src/code/graph.c | 2 +- soh/src/code/padmgr.c | 4 +- soh/src/code/z_actor.c | 16 +- soh/src/code/z_camera.c | 32 +- soh/src/code/z_en_item00.c | 3 +- soh/src/code/z_kaleido_setup.c | 10 +- soh/src/code/z_lib.c | 2 +- soh/src/code/z_lifemeter.c | 60 +- soh/src/code/z_map_exp.c | 174 ++-- soh/src/code/z_map_mark.c | 38 +- soh/src/code/z_message_PAL.c | 2 +- soh/src/code/z_parameter.c | 894 +++++++++--------- soh/src/code/z_play.c | 26 +- soh/src/code/z_player_lib.c | 14 +- soh/src/code/z_room.c | 5 +- soh/src/code/z_sram.c | 4 +- soh/src/code/z_view.c | 4 +- .../actors/ovl_Arms_Hook/z_arms_hook.c | 2 +- .../ovl_Bg_Mori_Bigst/z_bg_mori_bigst.c | 5 +- .../z_bg_spot06_objects.c | 2 +- .../actors/ovl_En_Blkobj/z_en_blkobj.c | 8 +- .../actors/ovl_En_Bom_Chu/z_en_bom_chu.c | 2 +- soh/src/overlays/actors/ovl_En_Box/z_en_box.c | 2 +- .../actors/ovl_En_Clear_Tag/z_en_clear_tag.c | 2 +- soh/src/overlays/actors/ovl_En_Go2/z_en_go2.c | 6 +- .../overlays/actors/ovl_En_Horse/z_en_horse.c | 2 +- soh/src/overlays/actors/ovl_En_Ik/z_en_ik.c | 9 +- soh/src/overlays/actors/ovl_En_Mag/z_en_mag.c | 4 +- .../overlays/actors/ovl_En_Ossan/z_en_ossan.c | 20 +- .../actors/ovl_En_Partner/z_en_partner.c | 4 +- soh/src/overlays/actors/ovl_En_Rd/z_en_rd.c | 4 +- .../actors/ovl_En_Torch2/z_en_torch2.c | 4 +- .../overlays/actors/ovl_Fishing/z_fishing.c | 2 +- .../actors/ovl_Magic_Dark/z_magic_dark.c | 6 +- .../actors/ovl_Magic_Fire/z_magic_fire.c | 6 +- .../actors/ovl_player_actor/z_player.c | 144 +-- .../ovl_Effect_Ss_Extra/z_eff_ss_extra.c | 2 +- .../ovl_file_choose/z_file_choose.c | 63 +- .../ovl_file_choose/z_file_copy_erase.c | 10 +- .../ovl_file_choose/z_file_nameset_PAL.c | 10 +- .../overlays/gamestates/ovl_select/z_select.c | 30 +- .../overlays/gamestates/ovl_title/z_title.c | 2 +- .../ovl_kaleido_scope/z_kaleido_collect.c | 2 +- .../ovl_kaleido_scope/z_kaleido_equipment.c | 10 +- .../misc/ovl_kaleido_scope/z_kaleido_item.c | 144 +-- .../ovl_kaleido_scope/z_kaleido_map_PAL.c | 8 +- .../misc/ovl_kaleido_scope/z_kaleido_prompt.c | 2 +- .../ovl_kaleido_scope/z_kaleido_scope_PAL.c | 22 +- .../misc/ovl_kaleido_scope/z_lmap_mark.c | 2 +- 82 files changed, 1435 insertions(+), 1457 deletions(-) diff --git a/soh/soh/Enhancements/bootcommands.c b/soh/soh/Enhancements/bootcommands.c index be3a766dc28..16ad651fcf2 100644 --- a/soh/soh/Enhancements/bootcommands.c +++ b/soh/soh/Enhancements/bootcommands.c @@ -9,6 +9,7 @@ #include #include #include +#include "soh/OTRGlobals.h" uint8_t gLoadFileSelect = 0, gSkipLogoTest = 0; @@ -21,13 +22,13 @@ static BootCommand sCommands[] = { { "--skiplogo", BootCommands_Command_SkipLogo void BootCommands_Init() { // Clears vars to prevent randomizer menu from being disabled - CVarClear("gRandoGenerating"); // Clear when a crash happened during rando seed generation - CVarClear("gNewSeedGenerated"); - CVarClear("gOnFileSelectNameEntry"); // Clear when soh is killed on the file name entry page - CVarClear("gBetterDebugWarpScreenMQMode"); - CVarClear("gBetterDebugWarpScreenMQModeScene"); - CVarClear("gCheatEasyPauseBufferLastInputs"); - CVarClear("gCheatEasyPauseBufferTimer"); + CVarClear(CVAR_GENERAL("RandoGenerating")); // Clear when a crash happened during rando seed generation + CVarClear(CVAR_GENERAL("NewSeedGenerated")); + CVarClear(CVAR_GENERAL("OnFileSelectNameEntry")); // Clear when soh is killed on the file name entry page + CVarClear(CVAR_GENERAL("BetterDebugWarpScreenMQMode")); + CVarClear(CVAR_GENERAL("BetterDebugWarpScreenMQModeScene")); + CVarClear(CVAR_GENERAL("CheatEasyPauseBufferLastInputs")); + CVarClear(CVAR_GENERAL("CheatEasyPauseBufferTimer")); #if defined(__SWITCH__) || defined(__WIIU__) CVarRegisterInteger(CVAR_IMGUI_CONTROLLER_NAV, 1); // always enable controller nav on switch/wii u #endif diff --git a/soh/soh/Enhancements/controls/InputViewer.cpp b/soh/soh/Enhancements/controls/InputViewer.cpp index c9b85c607c4..93727b5fa30 100644 --- a/soh/soh/Enhancements/controls/InputViewer.cpp +++ b/soh/soh/Enhancements/controls/InputViewer.cpp @@ -126,12 +126,12 @@ void InputViewer::DrawElement() { ImVec2 size = ImGui::GetContentRegionAvail(); #ifdef __WIIU__ - const float scale = CVarGetFloat("gInputViewer.Scale", 1.0f) * 2.0f; + const float scale = CVarGetFloat(CVAR_INPUT_VIEWER("Scale"), 1.0f) * 2.0f; #else - const float scale = CVarGetFloat("gInputViewer.Scale", 1.0f); + const float scale = CVarGetFloat(CVAR_INPUT_VIEWER("Scale"), 1.0f); #endif - const int showAnalogAngles = CVarGetInteger("gInputViewer.AnalogAngles.Enabled", 0); - const int buttonOutlineMode = CVarGetInteger("gInputViewer.ButtonOutlineMode", BUTTON_OUTLINE_NOT_PRESSED); + const int showAnalogAngles = CVarGetInteger(CVAR_INPUT_VIEWER("AnalogAngles.Enabled"), 0); + const int buttonOutlineMode = CVarGetInteger(CVAR_INPUT_VIEWER("ButtonOutlineMode"), BUTTON_OUTLINE_NOT_PRESSED); ImVec2 bgSize = Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureSize("Input-Viewer-Background"); ImVec2 scaledBGSize = ImVec2(bgSize.x * scale, bgSize.y * scale); @@ -139,10 +139,10 @@ void InputViewer::DrawElement() { ImGui::SetNextWindowSize(ImVec2( scaledBGSize.x + 20, scaledBGSize.y + - (showAnalogAngles ? ImGui::CalcTextSize("X").y : 0) * scale * CVarGetFloat("gInputViewer.AnalogAngles.Scale", 1.0f) + 20)); + (showAnalogAngles ? ImGui::CalcTextSize("X").y : 0) * scale * CVarGetFloat(CVAR_INPUT_VIEWER("AnalogAngles.Scale"), 1.0f) + 20)); ImGui::SetNextWindowContentSize( ImVec2(scaledBGSize.x, scaledBGSize.y + (showAnalogAngles ? 15 : 0) * scale * - CVarGetFloat("gInputViewer.AnalogAngles.Scale", 1.0f))); + CVarGetFloat(CVAR_INPUT_VIEWER("AnalogAngles.Scale"), 1.0f))); ImGui::SetNextWindowPos( ImVec2(mainPos.x + size.x - scaledBGSize.x - 30, mainPos.y + size.y - scaledBGSize.y - 30), ImGuiCond_FirstUseEver); @@ -156,7 +156,7 @@ void InputViewer::DrawElement() { ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoFocusOnAppearing; - if (!CVarGetInteger("gInputViewer.EnableDragging", 1)) { + if (!CVarGetInteger(CVAR_INPUT_VIEWER("EnableDragging"), 1)) { windowFlags |= ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoMove; } @@ -164,7 +164,7 @@ void InputViewer::DrawElement() { ImGui::SetCursorPos(ImVec2(10, 10)); const ImVec2 aPos = ImGui::GetCursorPos(); - if (CVarGetInteger("gInputViewer.ShowBackground", 1)) { + if (CVarGetInteger(CVAR_INPUT_VIEWER("ShowBackground"), 1)) { ImGui::SetNextItemAllowOverlap(); // Background ImGui::Image( @@ -173,59 +173,59 @@ void InputViewer::DrawElement() { } // A/B - if (CVarGetInteger("gInputViewer.BBtn", 1)) { + if (CVarGetInteger(CVAR_INPUT_VIEWER("BBtn"), 1)) { ImGui::SetNextItemAllowOverlap(); ImGui::SetCursorPos(aPos); RenderButton("B-Btn", "B-Btn Outline", pads[0].button & BTN_B, scaledBGSize, buttonOutlineMode); } - if (CVarGetInteger("gInputViewer.ABtn", 1)) { + if (CVarGetInteger(CVAR_INPUT_VIEWER("ABtn"), 1)) { ImGui::SetNextItemAllowOverlap(); ImGui::SetCursorPos(aPos); RenderButton("A-Btn", "A-Btn Outline", pads[0].button & BTN_A, scaledBGSize, buttonOutlineMode); } // C buttons - if (CVarGetInteger("gInputViewer.CUp", 1)) { + if (CVarGetInteger(CVAR_INPUT_VIEWER("CUp"), 1)) { ImGui::SetNextItemAllowOverlap(); ImGui::SetCursorPos(aPos); RenderButton("C-Up", "C-Up Outline", pads[0].button & BTN_CUP, scaledBGSize, buttonOutlineMode); } - if (CVarGetInteger("gInputViewer.CLeft", 1)) { + if (CVarGetInteger(CVAR_INPUT_VIEWER("CLeft"), 1)) { ImGui::SetNextItemAllowOverlap(); ImGui::SetCursorPos(aPos); RenderButton("C-Left", "C-Left Outline", pads[0].button & BTN_CLEFT, scaledBGSize, buttonOutlineMode); } - if (CVarGetInteger("gInputViewer.CRight", 1)) { + if (CVarGetInteger(CVAR_INPUT_VIEWER("CRight"), 1)) { ImGui::SetNextItemAllowOverlap(); ImGui::SetCursorPos(aPos); RenderButton("C-Right", "C-Right Outline", pads[0].button & BTN_CRIGHT, scaledBGSize, buttonOutlineMode); } - if (CVarGetInteger("gInputViewer.CDown", 1)) { + if (CVarGetInteger(CVAR_INPUT_VIEWER("CDown"), 1)) { ImGui::SetNextItemAllowOverlap(); ImGui::SetCursorPos(aPos); RenderButton("C-Down", "C-Down Outline", pads[0].button & BTN_CDOWN, scaledBGSize, buttonOutlineMode); } // L/R/Z - if (CVarGetInteger("gInputViewer.LBtn", 1)) { + if (CVarGetInteger(CVAR_INPUT_VIEWER("LBtn"), 1)) { ImGui::SetNextItemAllowOverlap(); ImGui::SetCursorPos(aPos); RenderButton("L-Btn", "L-Btn Outline", pads[0].button & BTN_L, scaledBGSize, buttonOutlineMode); } - if (CVarGetInteger("gInputViewer.RBtn", 1)) { + if (CVarGetInteger(CVAR_INPUT_VIEWER("RBtn"), 1)) { ImGui::SetNextItemAllowOverlap(); ImGui::SetCursorPos(aPos); RenderButton("R-Btn", "R-Btn Outline", pads[0].button & BTN_R, scaledBGSize, buttonOutlineMode); } - if (CVarGetInteger("gInputViewer.ZBtn", 1)) { + if (CVarGetInteger(CVAR_INPUT_VIEWER("ZBtn"), 1)) { ImGui::SetNextItemAllowOverlap(); ImGui::SetCursorPos(aPos); RenderButton("Z-Btn", "Z-Btn Outline", pads[0].button & BTN_Z, scaledBGSize, buttonOutlineMode); } // Start - if (CVarGetInteger("gInputViewer.StartBtn", 1)) { + if (CVarGetInteger(CVAR_INPUT_VIEWER("StartBtn"), 1)) { ImGui::SetNextItemAllowOverlap(); ImGui::SetCursorPos(aPos); RenderButton("Start-Btn", "Start-Btn Outline", pads[0].button & BTN_START, scaledBGSize, @@ -233,7 +233,7 @@ void InputViewer::DrawElement() { } // Dpad - if (CVarGetInteger("gInputViewer.Dpad", 0)) { + if (CVarGetInteger(CVAR_INPUT_VIEWER("Dpad"), 0)) { ImGui::SetNextItemAllowOverlap(); ImGui::SetCursorPos(aPos); RenderButton("Dpad-Left", "Dpad-Left Outline", pads[0].button & BTN_DLEFT, scaledBGSize, @@ -256,8 +256,8 @@ void InputViewer::DrawElement() { // Analog Stick const int analogOutlineMode = - CVarGetInteger("gInputViewer.AnalogStick.OutlineMode", STICK_MODE_ALWAYS_SHOWN); - const float maxStickDistance = CVarGetInteger("gInputViewer.AnalogStick.Movement", 12); + CVarGetInteger(CVAR_INPUT_VIEWER("AnalogStick.OutlineMode"), STICK_MODE_ALWAYS_SHOWN); + const float maxStickDistance = CVarGetInteger(CVAR_INPUT_VIEWER("AnalogStick.Movement"), 12); if (analogOutlineMode == STICK_MODE_ALWAYS_SHOWN || (analogOutlineMode == STICK_MODE_HIDDEN_IN_DEADZONE && !analogStickIsInDeadzone)) { ImGui::SetNextItemAllowOverlap(); @@ -267,7 +267,7 @@ void InputViewer::DrawElement() { scaledBGSize, ImVec2(0, 0), ImVec2(1.0f, 1.0f), ImVec4(255, 255, 255, 255)); } const int analogStickMode = - CVarGetInteger("gInputViewer.AnalogStick.VisibilityMode", STICK_MODE_ALWAYS_SHOWN); + CVarGetInteger(CVAR_INPUT_VIEWER("AnalogStick.VisibilityMode"), STICK_MODE_ALWAYS_SHOWN); if (analogStickMode == STICK_MODE_ALWAYS_SHOWN || (analogStickMode == STICK_MODE_HIDDEN_IN_DEADZONE && !analogStickIsInDeadzone)) { ImGui::SetNextItemAllowOverlap(); @@ -279,9 +279,9 @@ void InputViewer::DrawElement() { } // Right Stick - const float maxRightStickDistance = CVarGetInteger("gInputViewer.RightStick.Movement", 7); + const float maxRightStickDistance = CVarGetInteger(CVAR_INPUT_VIEWER("RightStick.Movement"), 7); const int rightOutlineMode = - CVarGetInteger("gInputViewer.RightStick.OutlineMode", STICK_MODE_ALWAYS_HIDDEN); + CVarGetInteger(CVAR_INPUT_VIEWER("RightStick.OutlineMode"), STICK_MODE_ALWAYS_HIDDEN); if (rightOutlineMode == STICK_MODE_ALWAYS_SHOWN || (rightOutlineMode == STICK_MODE_HIDDEN_IN_DEADZONE && !rightStickIsInDeadzone)) { ImGui::SetNextItemAllowOverlap(); @@ -291,7 +291,7 @@ void InputViewer::DrawElement() { scaledBGSize, ImVec2(0, 0), ImVec2(1.0f, 1.0f), ImVec4(255, 255, 255, 255)); } const int rightStickMode = - CVarGetInteger("gInputViewer.RightStick.VisibilityMode", STICK_MODE_ALWAYS_HIDDEN); + CVarGetInteger(CVAR_INPUT_VIEWER("RightStick.VisibilityMode"), STICK_MODE_ALWAYS_HIDDEN); if (rightStickMode == STICK_MODE_ALWAYS_SHOWN || (rightStickMode == STICK_MODE_HIDDEN_IN_DEADZONE && !rightStickIsInDeadzone)) { ImGui::SetNextItemAllowOverlap(); @@ -304,36 +304,36 @@ void InputViewer::DrawElement() { // Analog stick angle text if (showAnalogAngles) { - ImGui::SetCursorPos(ImVec2(aPos.x + 10 + CVarGetInteger("gInputViewer.AnalogAngles.Offset", 0) * scale, + ImGui::SetCursorPos(ImVec2(aPos.x + 10 + CVarGetInteger(CVAR_INPUT_VIEWER("AnalogAngles.Offset"), 0) * scale, scaledBGSize.y + aPos.y + 10)); // Scale font with input viewer scale float oldFontScale = ImGui::GetFont()->Scale; - ImGui::GetFont()->Scale *= scale * CVarGetFloat("gInputViewer.AnalogAngles.Scale", 1.0f); + ImGui::GetFont()->Scale *= scale * CVarGetFloat(CVAR_INPUT_VIEWER("AnalogAngles.Scale"), 1.0f); ImGui::PushFont(ImGui::GetFont()); // Calculate polar R coordinate from X and Y angles, squared to avoid sqrt const float rSquared = pads[0].stick_x * pads[0].stick_x + pads[0].stick_y * pads[0].stick_y; // ESS range - const int range1Min = CVarGetInteger("gInputViewer.AnalogAngles.Range1.Min", 8); - const int range1Max = CVarGetInteger("gInputViewer.AnalogAngles.Range1.Max", 27); + const int range1Min = CVarGetInteger(CVAR_INPUT_VIEWER("AnalogAngles.Range1.Min"), 8); + const int range1Max = CVarGetInteger(CVAR_INPUT_VIEWER("AnalogAngles.Range1.Max"), 27); // Walking speed range - const int range2Min = CVarGetInteger("gInputViewer.AnalogAngles.Range2.Min", 27); - const int range2Max = CVarGetInteger("gInputViewer.AnalogAngles.Range2.Max", 62); + const int range2Min = CVarGetInteger(CVAR_INPUT_VIEWER("AnalogAngles.Range2.Min"), 27); + const int range2Max = CVarGetInteger(CVAR_INPUT_VIEWER("AnalogAngles.Range2.Max"), 62); // Push color based on angle ranges - if (CVarGetInteger("gInputViewer.AnalogAngles.Range1.Enabled", 0) && + if (CVarGetInteger(CVAR_INPUT_VIEWER("AnalogAngles.Range1.Enabled"), 0) && (rSquared >= (range1Min * range1Min)) && (rSquared < (range1Max * range1Max))) { ImGui::PushStyleColor( ImGuiCol_Text, - color2Vec(CVarGetColor("gInputViewer.AnalogAngles.Range1.Color", vec2Color(range1Color)))); - } else if (CVarGetInteger("gInputViewer.AnalogAngles.Range2.Enabled", 0) && + color2Vec(CVarGetColor(CVAR_INPUT_VIEWER("AnalogAngles.Range1.Color"), vec2Color(range1Color)))); + } else if (CVarGetInteger(CVAR_INPUT_VIEWER("AnalogAngles.Range2.Enabled"), 0) && (rSquared >= (range2Min * range2Min)) && (rSquared < (range2Max * range2Max))) { ImGui::PushStyleColor( ImGuiCol_Text, - color2Vec(CVarGetColor("gInputViewer.AnalogAngles.Range2.Color", vec2Color(range2Color)))); + color2Vec(CVarGetColor(CVAR_INPUT_VIEWER("AnalogAngles.Range2.Color"), vec2Color(range2Color)))); } else { - ImGui::PushStyleColor(ImGuiCol_Text, color2Vec(CVarGetColor("gInputViewer.AnalogAngles.TextColor", + ImGui::PushStyleColor(ImGuiCol_Text, color2Vec(CVarGetColor(CVAR_INPUT_VIEWER("AnalogAngles.TextColor"), vec2Color(textColor)))); } @@ -364,60 +364,60 @@ void InputViewerSettingsWindow::DrawElement() { if (ImGui::Begin("Input Viewer Settings", &mIsVisible)) { // gInputViewer.Scale - UIWidgets::EnhancementSliderFloat("Input Viewer Scale: %.2f", "##Input", "gInputViewer.Scale", 0.1f, 5.0f, "", + UIWidgets::EnhancementSliderFloat("Input Viewer Scale: %.2f", "##Input", CVAR_INPUT_VIEWER("Scale"), 0.1f, 5.0f, "", 1.0f, false, true); UIWidgets::Tooltip("Sets the on screen size of the input viewer"); // gInputViewer.EnableDragging - UIWidgets::EnhancementCheckbox("Enable Dragging", "gInputViewer.EnableDragging", false, "", + UIWidgets::EnhancementCheckbox("Enable Dragging", CVAR_INPUT_VIEWER("EnableDragging"), false, "", UIWidgets::CheckboxGraphics::Checkmark, true); UIWidgets::PaddedSeparator(true, true); // gInputViewer.ShowBackground - UIWidgets::EnhancementCheckbox("Show Background Layer", "gInputViewer.ShowBackground", false, "", + UIWidgets::EnhancementCheckbox("Show Background Layer", CVAR_INPUT_VIEWER("ShowBackground"), false, "", UIWidgets::CheckboxGraphics::Checkmark, true); UIWidgets::PaddedSeparator(true, true); if (ImGui::CollapsingHeader("Buttons")) { // gInputViewer.ABtn - UIWidgets::EnhancementCheckbox("Show A-Button Layers", "gInputViewer.ABtn", false, "", + UIWidgets::EnhancementCheckbox("Show A-Button Layers", CVAR_INPUT_VIEWER("ABtn"), false, "", UIWidgets::CheckboxGraphics::Checkmark, true); // gInputViewer.BBtn - UIWidgets::EnhancementCheckbox("Show B-Button Layers", "gInputViewer.BBtn", false, "", + UIWidgets::EnhancementCheckbox("Show B-Button Layers", CVAR_INPUT_VIEWER("BBtn"), false, "", UIWidgets::CheckboxGraphics::Checkmark, true); // gInputViewer.CUp - UIWidgets::EnhancementCheckbox("Show C-Up Layers", "gInputViewer.CUp", false, "", + UIWidgets::EnhancementCheckbox("Show C-Up Layers", CVAR_INPUT_VIEWER("CUp"), false, "", UIWidgets::CheckboxGraphics::Checkmark, true); // gInputViewer.CRight - UIWidgets::EnhancementCheckbox("Show C-Right Layers", "gInputViewer.CRight", false, "", + UIWidgets::EnhancementCheckbox("Show C-Right Layers", CVAR_INPUT_VIEWER("CRight"), false, "", UIWidgets::CheckboxGraphics::Checkmark, true); // gInputViewer.CDown - UIWidgets::EnhancementCheckbox("Show C-Down Layers", "gInputViewer.CDown", false, "", + UIWidgets::EnhancementCheckbox("Show C-Down Layers", CVAR_INPUT_VIEWER("CDown"), false, "", UIWidgets::CheckboxGraphics::Checkmark, true); // gInputViewer.CLeft - UIWidgets::EnhancementCheckbox("Show C-Left Layers", "gInputViewer.CLeft", false, "", + UIWidgets::EnhancementCheckbox("Show C-Left Layers", CVAR_INPUT_VIEWER("CLeft"), false, "", UIWidgets::CheckboxGraphics::Checkmark, true); // gInputViewer.LBtn - UIWidgets::EnhancementCheckbox("Show L-Button Layers", "gInputViewer.LBtn", false, "", + UIWidgets::EnhancementCheckbox("Show L-Button Layers", CVAR_INPUT_VIEWER("LBtn"), false, "", UIWidgets::CheckboxGraphics::Checkmark, true); // gInputViewer.RBtn - UIWidgets::EnhancementCheckbox("Show R-Button Layers", "gInputViewer.RBtn", false, "", + UIWidgets::EnhancementCheckbox("Show R-Button Layers", CVAR_INPUT_VIEWER("RBtn"), false, "", UIWidgets::CheckboxGraphics::Checkmark, true); // gInputViewer.ZBtn - UIWidgets::EnhancementCheckbox("Show Z-Button Layers", "gInputViewer.ZBtn", false, "", + UIWidgets::EnhancementCheckbox("Show Z-Button Layers", CVAR_INPUT_VIEWER("ZBtn"), false, "", UIWidgets::CheckboxGraphics::Checkmark, true); // gInputViewer.StartBtn - UIWidgets::EnhancementCheckbox("Show Start Button Layers", "gInputViewer.StartBtn", false, "", + UIWidgets::EnhancementCheckbox("Show Start Button Layers", CVAR_INPUT_VIEWER("StartBtn"), false, "", UIWidgets::CheckboxGraphics::Checkmark, true); // gInputViewer.Dpad - UIWidgets::EnhancementCheckbox("Show D-Pad Layers", "gInputViewer.Dpad", false, "", + UIWidgets::EnhancementCheckbox("Show D-Pad Layers", CVAR_INPUT_VIEWER("Dpad"), false, "", UIWidgets::CheckboxGraphics::Checkmark, false); // gInputViewer.ButtonOutlineMode UIWidgets::PaddedText("Button Outlines/Backgrounds", true, false); - UIWidgets::EnhancementCombobox("gInputViewer.ButtonOutlineMode", buttonOutlineOptions, + UIWidgets::EnhancementCombobox(CVAR_INPUT_VIEWER("ButtonOutlineMode"), buttonOutlineOptions, BUTTON_OUTLINE_NOT_PRESSED); UIWidgets::Tooltip( "Sets the desired visibility behavior for the button outline/background layers. Useful for " @@ -429,21 +429,21 @@ void InputViewerSettingsWindow::DrawElement() { if (ImGui::CollapsingHeader("Analog Stick")) { // gInputViewer.AnalogStick.VisibilityMode UIWidgets::PaddedText("Analog Stick Visibility", true, false); - UIWidgets::EnhancementCombobox("gInputViewer.AnalogStick.VisibilityMode", stickModeOptions, + UIWidgets::EnhancementCombobox(CVAR_INPUT_VIEWER("AnalogStick.VisibilityMode"), stickModeOptions, STICK_MODE_ALWAYS_SHOWN); UIWidgets::Tooltip( "Determines the conditions under which the moving layer of the analog stick texture is visible."); // gInputViewer.AnalogStick.OutlineMode UIWidgets::PaddedText("Analog Stick Outline/Background Visibility", true, false); - UIWidgets::EnhancementCombobox("gInputViewer.AnalogStick.OutlineMode", stickModeOptions, + UIWidgets::EnhancementCombobox(CVAR_INPUT_VIEWER("AnalogStick.OutlineMode"), stickModeOptions, STICK_MODE_ALWAYS_SHOWN); UIWidgets::Tooltip( "Determines the conditions under which the analog stick outline/background texture is visible."); // gInputViewer.AnalogStick.Movement UIWidgets::EnhancementSliderInt("Analog Stick Movement: %dpx", "##AnalogMovement", - "gInputViewer.AnalogStick.Movement", 0, 200, "", 12, true); + CVAR_INPUT_VIEWER("AnalogStick.Movement"), 0, 200, "", 12, true); UIWidgets::Tooltip( "Sets the distance to move the analog stick in the input viewer. Useful for custom input viewers."); UIWidgets::PaddedSeparator(true, true); @@ -452,21 +452,21 @@ void InputViewerSettingsWindow::DrawElement() { if (ImGui::CollapsingHeader("Additional (\"Right\") Stick")) { // gInputViewer.RightStick.VisibilityMode UIWidgets::PaddedText("Right Stick Visibility", true, false); - UIWidgets::EnhancementCombobox("gInputViewer.RightStick.VisibilityMode", stickModeOptions, + UIWidgets::EnhancementCombobox(CVAR_INPUT_VIEWER("RightStick.VisibilityMode"), stickModeOptions, STICK_MODE_HIDDEN_IN_DEADZONE); UIWidgets::Tooltip( "Determines the conditions under which the moving layer of the right stick texture is visible."); // gInputViewer.RightStick.OutlineMode UIWidgets::PaddedText("Right Stick Outline/Background Visibility", true, false); - UIWidgets::EnhancementCombobox("gInputViewer.RightStick.OutlineMode", stickModeOptions, + UIWidgets::EnhancementCombobox(CVAR_INPUT_VIEWER("RightStick.OutlineMode"), stickModeOptions, STICK_MODE_HIDDEN_IN_DEADZONE); UIWidgets::Tooltip( "Determines the conditions under which the right stick outline/background texture is visible."); // gInputViewer.RightStick.Movement UIWidgets::EnhancementSliderInt("Right Stick Movement: %dpx", "##RightMovement", - "gInputViewer.RightStick.Movement", 0, 200, "", 7, true); + CVAR_INPUT_VIEWER("RightStick.Movement"), 0, 200, "", 7, true); UIWidgets::Tooltip( "Sets the distance to move the right stick in the input viewer. Useful for custom input viewers."); UIWidgets::PaddedSeparator(true, true); @@ -474,42 +474,42 @@ void InputViewerSettingsWindow::DrawElement() { if (ImGui::CollapsingHeader("Analog Angle Values")) { // gAnalogAngles - UIWidgets::EnhancementCheckbox("Show Analog Stick Angle Values", "gInputViewer.AnalogAngles.Enabled"); + UIWidgets::EnhancementCheckbox("Show Analog Stick Angle Values", CVAR_INPUT_VIEWER("AnalogAngles.Enabled")); UIWidgets::Tooltip("Displays analog stick angle values in the input viewer"); - if (CVarGetInteger("gInputViewer.AnalogAngles.Enabled", 0)) { + if (CVarGetInteger(CVAR_INPUT_VIEWER("AnalogAngles.Enabled"), 0)) { // gInputViewer.AnalogAngles.TextColor if (ImGui::ColorEdit4("Text Color", (float*)&textColor)) { - CVarSetColor("gInputViewer.AnalogAngles.TextColor", vec2Color(textColor)); + CVarSetColor(CVAR_INPUT_VIEWER("AnalogAngles.TextColor"), vec2Color(textColor)); } // gAnalogAngleScale UIWidgets::EnhancementSliderFloat("Angle Text Scale: %.2f%%", "##AnalogAngleScale", - "gInputViewer.AnalogAngles.Scale", 0.1f, 5.0f, "", 1.0f, true, true); + CVAR_INPUT_VIEWER("AnalogAngles.Scale"), 0.1f, 5.0f, "", 1.0f, true, true); // gInputViewer.AnalogAngles.Offset UIWidgets::EnhancementSliderInt("Angle Text Offset: %dpx", "##AnalogAngleOffset", - "gInputViewer.AnalogAngles.Offset", 0, 400, "", 0, true); + CVAR_INPUT_VIEWER("AnalogAngles.Offset"), 0, 400, "", 0, true); UIWidgets::PaddedSeparator(true, true); // gInputViewer.AnalogAngles.Range1.Enabled - UIWidgets::EnhancementCheckbox("Highlight ESS Position", "gInputViewer.AnalogAngles.Range1.Enabled"); + UIWidgets::EnhancementCheckbox("Highlight ESS Position", CVAR_INPUT_VIEWER("AnalogAngles.Range1.Enabled")); UIWidgets::Tooltip( "Highlights the angle value text when the analog stick is in ESS position (on flat ground)"); - if (CVarGetInteger("gInputViewer.AnalogAngles.Range1.Enabled", 0)) { + if (CVarGetInteger(CVAR_INPUT_VIEWER("AnalogAngles.Range1.Enabled"), 0)) { // gInputViewer.AnalogAngles.Range1.Color if (ImGui::ColorEdit4("ESS Color", (float*)&range1Color)) { - CVarSetColor("gInputViewer.AnalogAngles.Range1.Color", vec2Color(range1Color)); + CVarSetColor(CVAR_INPUT_VIEWER("AnalogAngles.Range1.Color"), vec2Color(range1Color)); } } UIWidgets::PaddedSeparator(true, true); // gInputViewer.AnalogAngles.Range2.Enabled UIWidgets::EnhancementCheckbox("Highlight Walking Speed Angles", - "gInputViewer.AnalogAngles.Range2.Enabled"); + CVAR_INPUT_VIEWER("AnalogAngles.Range2.Enabled")); UIWidgets::Tooltip("Highlights the angle value text when the analog stick is at an angle that would " "produce a walking speed (on flat ground)\n\n" "Useful for 1.0 Empty Jumpslash Quick Put Away"); - if (CVarGetInteger("gInputViewer.AnalogAngles.Range2.Enabled", 0)) { + if (CVarGetInteger(CVAR_INPUT_VIEWER("AnalogAngles.Range2.Enabled"), 0)) { // gInputViewer.AnalogAngles.Range2.Color if (ImGui::ColorEdit4("Walking Speed Color", (float*)&range2Color)) { - CVarSetColor("gInputViewer.AnalogAngles.Range2.Color", vec2Color(range2Color)); + CVarSetColor(CVAR_INPUT_VIEWER("AnalogAngles.Range2.Color"), vec2Color(range2Color)); } } } diff --git a/soh/soh/Enhancements/controls/InputViewer.h b/soh/soh/Enhancements/controls/InputViewer.h index 4d528ead484..3e1e9c98798 100644 --- a/soh/soh/Enhancements/controls/InputViewer.h +++ b/soh/soh/Enhancements/controls/InputViewer.h @@ -2,6 +2,8 @@ #include +#define CVAR_INPUT_VIEWER(var) "gInputViewer." var + typedef enum { BUTTON_OUTLINE_ALWAYS_SHOWN, BUTTON_OUTLINE_NOT_PRESSED, diff --git a/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp b/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp index f5acca70b0d..667d96c18ec 100644 --- a/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp +++ b/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp @@ -1070,15 +1070,15 @@ void SohInputEditorWindow::DrawLEDSection(uint8_t port) { "Original Navi Targeting Colors", "Cosmetics Navi Targeting Colors", "Custom" }; UIWidgets::PaddedText("Source"); - UIWidgets::EnhancementCombobox("gLedColorSource", ledSources, LED_SOURCE_TUNIC_ORIGINAL); + UIWidgets::EnhancementCombobox(CVAR_SETTING("LEDColorSource"), ledSources, LED_SOURCE_TUNIC_ORIGINAL); UIWidgets::Tooltip("Health\n- Red when health critical (13-20% depending on max health)\n- Yellow when " "health < 40%. Green otherwise.\n\n" "Tunics: colors will mirror currently equipped tunic, whether original or the current " "values in Cosmetics Editor.\n\n" "Custom: single, solid color"); - if (CVarGetInteger("gLedColorSource", 1) == LED_SOURCE_CUSTOM) { + if (CVarGetInteger(CVAR_SETTING("LEDColorSource"), 1) == LED_SOURCE_CUSTOM) { UIWidgets::Spacer(3); - auto port1Color = CVarGetColor24("gLedPort1Color", { 255, 255, 255 }); + auto port1Color = CVarGetColor24(CVAR_SETTING("LEDPort1Color"), { 255, 255, 255 }); ImVec4 colorVec = { port1Color.r / 255.0f, port1Color.g / 255.0f, port1Color.b / 255.0f, 1.0f }; if (ImGui::ColorEdit3("", (float*)&colorVec, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel)) { @@ -1087,18 +1087,18 @@ void SohInputEditorWindow::DrawLEDSection(uint8_t port) { color.g = colorVec.y * 255.0; color.b = colorVec.z * 255.0; - CVarSetColor24("gLedPort1Color", color); + CVarSetColor24(CVAR_SETTING("LEDPort1Color"), color); Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } ImGui::SameLine(); ImGui::Text("Custom Color"); } - UIWidgets::PaddedEnhancementSliderFloat("Brightness: %.1f %%", "##LED_Brightness", "gLedBrightness", 0.0f, + UIWidgets::PaddedEnhancementSliderFloat("Brightness: %.1f %%", "##LED_Brightness", CVAR_SETTING("LEDBrightness"), 0.0f, 1.0f, "", 1.0f, true, true); UIWidgets::Tooltip("Sets the brightness of controller LEDs. 0% brightness = LEDs off."); UIWidgets::PaddedEnhancementCheckbox( - "Critical Health Override", "gLedCriticalOverride", true, true, - CVarGetInteger("gLedColorSource", LED_SOURCE_TUNIC_ORIGINAL) == LED_SOURCE_HEALTH, + "Critical Health Override", CVAR_SETTING("LEDCriticalOverride"), true, true, + CVarGetInteger(CVAR_SETTING("LEDColorSource"), LED_SOURCE_TUNIC_ORIGINAL) == LED_SOURCE_HEALTH, "Override redundant for health source.", UIWidgets::CheckboxGraphics::Cross, true); UIWidgets::Tooltip("Shows red color when health is critical, otherwise displays according to color source."); } @@ -1478,14 +1478,14 @@ void SohInputEditorWindow::addButtonName(N64ButtonMask mask, const char* name) { } // Ocarina button maps -static CustomButtonMap ocarinaD5 = {"D5", "gOcarinaD5BtnMap", BTN_CUP}; -static CustomButtonMap ocarinaB4 = {"B4", "gOcarinaB4BtnMap", BTN_CLEFT}; -static CustomButtonMap ocarinaA4 = {"A4", "gOcarinaA4BtnMap", BTN_CRIGHT}; -static CustomButtonMap ocarinaF4 = {"F4", "gOcarinaF4BtnMap", BTN_CDOWN}; -static CustomButtonMap ocarinaD4 = {"D4", "gOcarinaD4BtnMap", BTN_A}; -static CustomButtonMap ocarinaSongDisable = {"Disable songs", "gOcarinaDisableBtnMap", BTN_L}; -static CustomButtonMap ocarinaSharp = {"Pitch up", "gOcarinaSharpBtnMap", BTN_R}; -static CustomButtonMap ocarinaFlat = {"Pitch down", "gOcarinaFlatBtnMap", BTN_Z}; +static CustomButtonMap ocarinaD5 = {"D5", CVAR_SETTING("CustomOcarina.D5Button"), BTN_CUP}; +static CustomButtonMap ocarinaB4 = {"B4", CVAR_SETTING("CustomOcarina.B4Button"), BTN_CLEFT}; +static CustomButtonMap ocarinaA4 = {"A4", CVAR_SETTING("CustomOcarina.A4Button"), BTN_CRIGHT}; +static CustomButtonMap ocarinaF4 = {"F4", CVAR_SETTING("CustomOcarina.F4Button"), BTN_CDOWN}; +static CustomButtonMap ocarinaD4 = {"D4", CVAR_SETTING("CustomOcarina.D4Button"), BTN_A}; +static CustomButtonMap ocarinaSongDisable = {"Disable songs", CVAR_SETTING("CustomOcarina.DisableButton"), BTN_L}; +static CustomButtonMap ocarinaSharp = {"Pitch up", CVAR_SETTING("CustomOcarina.SharpButton"), BTN_R}; +static CustomButtonMap ocarinaFlat = {"Pitch down", CVAR_SETTING("CustomOcarina.FlatButton"), BTN_Z}; // Draw a button mapping setting consisting of a padded label and button dropdown. // excludedButtons indicates which buttons are unavailable to choose from. @@ -1534,13 +1534,13 @@ void SohInputEditorWindow::DrawOcarinaControlPanel() { ImVec2 cursor = ImGui::GetCursorPos(); ImGui::SetCursorPos(ImVec2(cursor.x + 5, cursor.y + 5)); - UIWidgets::EnhancementCheckbox("Customize Ocarina Controls", "gCustomOcarinaControls"); + UIWidgets::EnhancementCheckbox("Customize Ocarina Controls", CVAR_SETTING("CustomOcarina.Enabled")); - if (CVarGetInteger("gCustomOcarinaControls", 0) == 1) { + if (CVarGetInteger(CVAR_SETTING("CustomOcarina.Enabled"), 0) == 1) { if (ImGui::BeginTable("tableCustomMainOcarinaControls", 2, ImGuiTableFlags_SizingStretchProp)) { float labelWidth; N64ButtonMask disableMask = BTN_B; - if (CVarGetInteger("gDpadOcarina", 0)) { + if (CVarGetInteger(CVAR_SETTING("OcarinaControl.Dpad"), 0)) { disableMask |= BTN_DUP | BTN_DDOWN | BTN_DLEFT | BTN_DRIGHT; } @@ -1583,9 +1583,9 @@ void SohInputEditorWindow::DrawOcarinaControlPanel() { ImGui::TableSetupColumn("Right stick", PANEL_TABLE_COLUMN_FLAGS); TableHelper::InitHeader(false); ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 5); - UIWidgets::EnhancementCheckbox("Play with D-pad", "gDpadOcarina"); + UIWidgets::EnhancementCheckbox("Play with D-pad", CVAR_SETTING("OcarinaControl.Dpad")); TableHelper::NextCol(); - UIWidgets::EnhancementCheckbox("Play with camera stick", "gRStickOcarina"); + UIWidgets::EnhancementCheckbox("Play with camera stick", CVAR_SETTING("OcarinaControl.RStick")); UIWidgets::Spacer(0); ImGui::EndTable(); } @@ -1598,35 +1598,35 @@ void SohInputEditorWindow::DrawCameraControlPanel() { ImVec2 cursor = ImGui::GetCursorPos(); ImGui::SetCursorPos(ImVec2(cursor.x + 5, cursor.y + 5)); Ship::GuiWindow::BeginGroupPanel("Aiming/First-Person Camera", ImGui::GetContentRegionAvail()); - UIWidgets::PaddedEnhancementCheckbox("Right Stick Aiming", "gRightStickAiming"); + UIWidgets::PaddedEnhancementCheckbox("Right Stick Aiming", CVAR_SETTING("Controls.RightStickAim")); UIWidgets::Tooltip("Allows for aiming with the right stick in:\n-First-Person/C-Up view\n-Weapon Aiming"); - if (CVarGetInteger("gRightStickAiming", 0)) { - UIWidgets::PaddedEnhancementCheckbox("Allow moving while in first person mode", "gMoveWhileFirstPerson"); + if (CVarGetInteger(CVAR_SETTING("Controls.RightStickAim"), 0)) { + UIWidgets::PaddedEnhancementCheckbox("Allow moving while in first person mode", CVAR_SETTING("MoveInFirstPerson")); UIWidgets::Tooltip("Changes the left stick to move the player while in first person mode"); } - UIWidgets::PaddedEnhancementCheckbox("Invert Aiming X Axis", "gInvertAimingXAxis"); + UIWidgets::PaddedEnhancementCheckbox("Invert Aiming X Axis", CVAR_SETTING("Controls.InvertAimingXAxis")); UIWidgets::Tooltip("Inverts the Camera X Axis in:\n-First-Person/C-Up view\n-Weapon Aiming"); - UIWidgets::PaddedEnhancementCheckbox("Invert Aiming Y Axis", "gInvertAimingYAxis", true, true, false, "", UIWidgets::CheckboxGraphics::Cross, true); + UIWidgets::PaddedEnhancementCheckbox("Invert Aiming Y Axis", CVAR_SETTING("Controls.InvertAimingYAxis"), true, true, false, "", UIWidgets::CheckboxGraphics::Cross, true); UIWidgets::Tooltip("Inverts the Camera Y Axis in:\n-First-Person/C-Up view\n-Weapon Aiming"); - UIWidgets::PaddedEnhancementCheckbox("Invert Shield Aiming Y Axis", "gInvertShieldAimingYAxis", true, true, false, "", UIWidgets::CheckboxGraphics::Cross, true); + UIWidgets::PaddedEnhancementCheckbox("Invert Shield Aiming Y Axis", CVAR_SETTING("Controls.InvertShieldAimingYAxis"), true, true, false, "", UIWidgets::CheckboxGraphics::Cross, true); UIWidgets::Tooltip("Inverts the Shield Aiming Y Axis"); - UIWidgets::PaddedEnhancementCheckbox("Invert Shield Aiming X Axis", "gInvertShieldAimingXAxis"); + UIWidgets::PaddedEnhancementCheckbox("Invert Shield Aiming X Axis", CVAR_SETTING("Controls.InvertShieldAimingYAxis")); UIWidgets::Tooltip("Inverts the Shield Aiming X Axis"); - UIWidgets::PaddedEnhancementCheckbox("Invert Z-Weapon Aiming Y Axis", "gInvertZAimingYAxis", true, true, false, "", UIWidgets::CheckboxGraphics::Cross, true); + UIWidgets::PaddedEnhancementCheckbox("Invert Z-Weapon Aiming Y Axis", CVAR_SETTING("Controls.InvertZAimingYAxis"), true, true, false, "", UIWidgets::CheckboxGraphics::Cross, true); UIWidgets::Tooltip("Inverts the Camera Y Axis in:\n-Z-Weapon Aiming"); - UIWidgets::PaddedEnhancementCheckbox("Disable Auto-Centering in First-Person View", "gDisableAutoCenterViewFirstPerson"); + UIWidgets::PaddedEnhancementCheckbox("Disable Auto-Centering in First-Person View", CVAR_SETTING("DisableFirstPersonAutoCenterView")); UIWidgets::Tooltip("Prevents the C-Up view from auto-centering, allowing for Gyro Aiming"); - if (UIWidgets::PaddedEnhancementCheckbox("Enable Custom Aiming/First-Person sensitivity", "gEnableFirstPersonSensitivity", true, false)) { - if (!CVarGetInteger("gEnableFirstPersonSensitivity", 0)) { - CVarClear("gFirstPersonCameraSensitivityX"); - CVarClear("gFirstPersonCameraSensitivityY"); + if (UIWidgets::PaddedEnhancementCheckbox("Enable Custom Aiming/First-Person sensitivity", CVAR_SETTING("FirstPersonCameraSensitivity.Enabled"), true, false)) { + if (!CVarGetInteger(CVAR_SETTING("FirstPersonCameraSensitivity.Enabled"), 0)) { + CVarClear(CVAR_SETTING("FirstPersonCameraSensitivity.X")); + CVarClear(CVAR_SETTING("FirstPersonCameraSensitivity.Y")); } } - if (CVarGetInteger("gEnableFirstPersonSensitivity", 0)) { + if (CVarGetInteger(CVAR_SETTING("FirstPersonCameraSensitivity.Enabled"), 0)) { UIWidgets::EnhancementSliderFloat("Aiming/First-Person Horizontal Sensitivity: %.0f %%", "##FirstPersonSensitivity Horizontal", - "gFirstPersonCameraSensitivityX", 0.01f, 5.0f, "", 1.0f, true); + CVAR_SETTING("FirstPersonCameraSensitivity.X"), 0.01f, 5.0f, "", 1.0f, true); UIWidgets::EnhancementSliderFloat("Aiming/First-Person Vertical Sensitivity: %.0f %%", "##FirstPersonSensitivity Vertical", - "gFirstPersonCameraSensitivityY", 0.01f, 5.0f, "", 1.0f, true); + CVAR_SETTING("FirstPersonCameraSensitivity.Y"), 0.01f, 5.0f, "", 1.0f, true); } UIWidgets::Spacer(0); Ship::GuiWindow::EndGroupPanel(0); @@ -1636,22 +1636,22 @@ void SohInputEditorWindow::DrawCameraControlPanel() { ImGui::SetCursorPos(ImVec2(cursor.x + 5, cursor.y + 5)); Ship::GuiWindow::BeginGroupPanel("Third-Person Camera", ImGui::GetContentRegionAvail()); - UIWidgets::PaddedEnhancementCheckbox("Free Camera", "gFreeCamera"); - UIWidgets::Tooltip("Enables free camera control\nNote: You must remap C buttons off of the right stick in the " + UIWidgets::PaddedEnhancementCheckbox("Free Look", CVAR_SETTING("FreeLook.Enabled")); + UIWidgets::Tooltip("Enables free look camera control\nNote: You must remap C buttons off of the right stick in the " "controller config menu, and map the camera stick to the right stick."); - UIWidgets::PaddedEnhancementCheckbox("Invert Camera X Axis", "gInvertXAxis"); - UIWidgets::Tooltip("Inverts the Camera X Axis in:\n-Free camera"); - UIWidgets::PaddedEnhancementCheckbox("Invert Camera Y Axis", "gInvertYAxis", true, true, false, "", UIWidgets::CheckboxGraphics::Cross, true); - UIWidgets::Tooltip("Inverts the Camera Y Axis in:\n-Free camera"); + UIWidgets::PaddedEnhancementCheckbox("Invert Camera X Axis", CVAR_SETTING("FreeLook.InvertXAxis")); + UIWidgets::Tooltip("Inverts the Camera X Axis in:\n-Free look"); + UIWidgets::PaddedEnhancementCheckbox("Invert Camera Y Axis", CVAR_SETTING("FreeLook.InvertYAxis"), true, true, false, "", UIWidgets::CheckboxGraphics::Cross, true); + UIWidgets::Tooltip("Inverts the Camera Y Axis in:\n-Free look"); UIWidgets::Spacer(0); UIWidgets::PaddedEnhancementSliderFloat("Third-Person Horizontal Sensitivity: %.0f %%", "##ThirdPersonSensitivity Horizontal", - "gThirdPersonCameraSensitivityX", 0.01f, 5.0f, "", 1.0f, true, true, false, true); + CVAR_SETTING("FreeLook.CameraSensitivity.X"), 0.01f, 5.0f, "", 1.0f, true, true, false, true); UIWidgets::PaddedEnhancementSliderFloat("Third-Person Vertical Sensitivity: %.0f %%", "##ThirdPersonSensitivity Vertical", - "gThirdPersonCameraSensitivityY", 0.01f, 5.0f, "", 1.0f, true, true, false, true); + CVAR_SETTING("FreeLook.CameraSensitivity.Y"), 0.01f, 5.0f, "", 1.0f, true, true, false, true); UIWidgets::PaddedEnhancementSliderInt("Camera Distance: %d", "##CamDist", - "gFreeCameraDistMax", 100, 900, "", 185, true, false, true); + CVAR_SETTING("FreeLook.MaxCameraDistance"), 100, 900, "", 185, true, false, true); UIWidgets::PaddedEnhancementSliderInt("Camera Transition Speed: %d", "##CamTranSpeed", - "gFreeCameraTransitionSpeed", 0, 900, "", 25, true, false, true); + CVAR_SETTING("FreeLook.TransitionSpeed"), 0, 900, "", 25, true, false, true); Ship::GuiWindow::EndGroupPanel(0); } @@ -1659,13 +1659,13 @@ void SohInputEditorWindow::DrawDpadControlPanel() { ImVec2 cursor = ImGui::GetCursorPos(); ImGui::SetCursorPos(ImVec2(cursor.x + 5, cursor.y + 5)); Ship::GuiWindow::BeginGroupPanel("D-Pad Options", ImGui::GetContentRegionAvail()); - UIWidgets::PaddedEnhancementCheckbox("D-pad Support on Pause Screen", "gDpadPause"); + UIWidgets::PaddedEnhancementCheckbox("D-pad Support on Pause Screen", CVAR_SETTING("DPadOnPause")); UIWidgets::Tooltip("Navigate Pause with the D-pad\nIf used with D-pad as Equip Items, you must hold C-Up to equip instead of navigate\n" - "To make the cursor only move a single space no matter how long a direction is held, manually set gDpadHoldChange to 0"); - UIWidgets::PaddedEnhancementCheckbox("D-pad Support in Text Boxes", "gDpadText"); + "To make the cursor only move a single space no matter how long a direction is held, manually set gSettings.DpadHoldChange to 0"); + UIWidgets::PaddedEnhancementCheckbox("D-pad Support in Text Boxes", CVAR_SETTING("DpadInText")); UIWidgets::Tooltip("Navigate choices in text boxes, shop item selection, and the file select / name entry screens with the D-pad\n" - "To make the cursor only move a single space during name entry no matter how long a direction is held, manually set gDpadHoldChange to 0"); - UIWidgets::PaddedEnhancementCheckbox("D-pad as Equip Items", "gDpadEquips"); + "To make the cursor only move a single space during name entry no matter how long a direction is held, manually set gSettings.DpadHoldChange to 0"); + UIWidgets::PaddedEnhancementCheckbox("D-pad as Equip Items", CVAR_SETTING("DpadEquips")); UIWidgets::Tooltip("Equip items and equipment on the D-pad\nIf used with D-pad on Pause Screen, you must hold C-Up to equip instead of navigate"); Ship::GuiWindow::EndGroupPanel(0); } @@ -1676,31 +1676,31 @@ void SohInputEditorWindow::DrawMiscControlPanel() { Ship::GuiWindow::BeginGroupPanel("Misc Controls", ImGui::GetContentRegionAvail()); UIWidgets::PaddedText("Allow the cursor to be on any slot"); static const char* cursorOnAnySlot[3] = { "Only in Rando", "Always", "Never" }; - UIWidgets::EnhancementCombobox("gPauseAnyCursor", cursorOnAnySlot, PAUSE_ANY_CURSOR_RANDO_ONLY); + UIWidgets::EnhancementCombobox(CVAR_SETTING("PauseAnyCursor"), cursorOnAnySlot, PAUSE_ANY_CURSOR_RANDO_ONLY); UIWidgets::Tooltip("Allows the cursor on the pause menu to be over any slot. Sometimes required in rando to select " "certain items."); UIWidgets::Spacer(0); ImGui::BeginDisabled(CVarGetInteger(CVAR_SETTING("DisableChanges"), 0)); - UIWidgets::PaddedEnhancementCheckbox("Enable speed modifiers", "gEnableWalkModify", true, false); + UIWidgets::PaddedEnhancementCheckbox("Enable speed modifiers", CVAR_SETTING("WalkModifier.Enabled"), true, false); UIWidgets::Tooltip("Hold the assigned button to change the maximum walking or swimming speed"); - if (CVarGetInteger("gEnableWalkModify", 0)) { + if (CVarGetInteger(CVAR_SETTING("WalkModifier.Enabled"), 0)) { UIWidgets::Spacer(5); Ship::GuiWindow::BeginGroupPanel("Speed Modifier", ImGui::GetContentRegionAvail()); - UIWidgets::PaddedEnhancementCheckbox("Toggle modifier instead of holding", "gWalkSpeedToggle", true, false); + UIWidgets::PaddedEnhancementCheckbox("Toggle modifier instead of holding", CVAR_SETTING("WalkModifier.SpeedToggle"), true, false); Ship::GuiWindow::BeginGroupPanel("Walk Modifier", ImGui::GetContentRegionAvail()); - UIWidgets::PaddedEnhancementCheckbox("Don't affect jump distance/velocity", "gWalkModifierDoesntChangeJump", true, false); - UIWidgets::PaddedEnhancementSliderFloat("Walk Modifier 1: %.0f %%", "##WalkMod1", "gWalkModifierOne", 0.0f, 5.0f, "", 1.0f, true, true, false, true); - UIWidgets::PaddedEnhancementSliderFloat("Walk Modifier 2: %.0f %%", "##WalkMod2", "gWalkModifierTwo", 0.0f, 5.0f, "", 1.0f, true, true, false, true); + UIWidgets::PaddedEnhancementCheckbox("Don't affect jump distance/velocity", CVAR_SETTING("WalkModifier.DoesntChangeJump"), true, false); + UIWidgets::PaddedEnhancementSliderFloat("Walk Modifier 1: %.0f %%", "##WalkMod1", CVAR_SETTING("WalkModifier.Mapping1"), 0.0f, 5.0f, "", 1.0f, true, true, false, true); + UIWidgets::PaddedEnhancementSliderFloat("Walk Modifier 2: %.0f %%", "##WalkMod2", CVAR_SETTING("WalkModifier.Mapping2"), 0.0f, 5.0f, "", 1.0f, true, true, false, true); Ship::GuiWindow::EndGroupPanel(0); Ship::GuiWindow::BeginGroupPanel("Swim Modifier", ImGui::GetContentRegionAvail()); - UIWidgets::PaddedEnhancementSliderFloat("Swim Modifier 1: %.0f %%", "##SwimMod1", "gSwimModifierOne", 0.0f, 5.0f, "", 1.0f, true, true, false, true); - UIWidgets::PaddedEnhancementSliderFloat("Swim Modifier 2: %.0f %%", "##SwimMod2", "gSwimModifierTwo", 0.0f, 5.0f, "", 1.0f, true, true, false, true); + UIWidgets::PaddedEnhancementSliderFloat("Swim Modifier 1: %.0f %%", "##SwimMod1", CVAR_SETTING("WalkModifier.SwimMapping1"), 0.0f, 5.0f, "", 1.0f, true, true, false, true); + UIWidgets::PaddedEnhancementSliderFloat("Swim Modifier 2: %.0f %%", "##SwimMod2", CVAR_SETTING("WalkModifier.SwimMapping2"), 0.0f, 5.0f, "", 1.0f, true, true, false, true); Ship::GuiWindow::EndGroupPanel(0); Ship::GuiWindow::EndGroupPanel(0); } ImGui::EndDisabled(); UIWidgets::Spacer(0); - UIWidgets::PaddedEnhancementCheckbox("Answer Navi Prompt with L Button", "gNaviOnL"); + UIWidgets::PaddedEnhancementCheckbox("Answer Navi Prompt with L Button", CVAR_SETTING("NaviOnL")); UIWidgets::Tooltip("Speak to Navi with L but enter first-person camera with C-Up"); Ship::GuiWindow::EndGroupPanel(0); } diff --git a/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp b/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp index 51eabd08d56..b932d24cc52 100644 --- a/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp +++ b/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp @@ -229,24 +229,25 @@ static std::map cosmeticOptions = { COSMETIC_OPTION("Consumable.GoldRupee", "Gold Rupee", COSMETICS_GROUP_CONSUMABLE, ImVec4(255, 190, 55, 255), false, true, true), COSMETIC_OPTION("Consumable.SilverRupee", "Silver Rupee", COSMETICS_GROUP_CONSUMABLE, ImVec4(255, 255, 255, 255), false, true, true), - COSMETIC_OPTION("Hud.AButton", "A Button", COSMETICS_GROUP_HUD, ImVec4( 90, 90, 255, 255), false, true, false), - COSMETIC_OPTION("Hud.BButton", "B Button", COSMETICS_GROUP_HUD, ImVec4( 0, 150, 0, 255), false, true, false), - COSMETIC_OPTION("Hud.CButtons", "C Buttons", COSMETICS_GROUP_HUD, ImVec4(255, 160, 0, 255), false, true, false), - COSMETIC_OPTION("Hud.CUpButton", "C Up Button", COSMETICS_GROUP_HUD, ImVec4(255, 160, 0, 255), false, true, true), - COSMETIC_OPTION("Hud.CDownButton", "C Down Button", COSMETICS_GROUP_HUD, ImVec4(255, 160, 0, 255), false, true, true), - COSMETIC_OPTION("Hud.CLeftButton", "C Left Button", COSMETICS_GROUP_HUD, ImVec4(255, 160, 0, 255), false, true, true), - COSMETIC_OPTION("Hud.CRightButton", "C Right Button", COSMETICS_GROUP_HUD, ImVec4(255, 160, 0, 255), false, true, true), - COSMETIC_OPTION("Hud.StartButton", "Start Button", COSMETICS_GROUP_HUD, ImVec4(200, 0, 0, 255), false, true, false), - COSMETIC_OPTION("Hud.Dpad", "Dpad", COSMETICS_GROUP_HUD, ImVec4(255, 255, 255, 255), false, true, false), - COSMETIC_OPTION("Hud.KeyCount", "Key Count", COSMETICS_GROUP_HUD, ImVec4(200, 230, 255, 255), false, true, true), - COSMETIC_OPTION("Hud.StoneOfAgony", "Stone of Agony", COSMETICS_GROUP_HUD, ImVec4(255, 255, 255, 255), false, true, true), - COSMETIC_OPTION("Hud.Minimap", "Minimap", COSMETICS_GROUP_HUD, ImVec4( 0, 255, 255, 255), false, true, false), - COSMETIC_OPTION("Hud.MinimapPosition", "Minimap Position", COSMETICS_GROUP_HUD, ImVec4(200, 255, 0, 255), false, true, true), - COSMETIC_OPTION("Hud.MinimapEntrance", "Minimap Entrance", COSMETICS_GROUP_HUD, ImVec4(200, 0, 0, 255), false, true, true), - COSMETIC_OPTION("Hud.EnemyHealthBar", "Enemy Health Bar", COSMETICS_GROUP_HUD, ImVec4(255, 0, 0, 255), true, true, false), - COSMETIC_OPTION("Hud.EnemyHealthBorder", "Enemy Health Border", COSMETICS_GROUP_HUD, ImVec4(255, 255, 255, 255), true, false, true), - COSMETIC_OPTION("Hud.NameTagActorText", "Nametag Text", COSMETICS_GROUP_HUD, ImVec4(255, 255, 255, 255), true, true, false), - COSMETIC_OPTION("Hud.NameTagActorBackground", "Nametag Background", COSMETICS_GROUP_HUD, ImVec4(0, 0, 0, 80), true, false, true), + COSMETIC_OPTION("HUD.AButton", "A Button", COSMETICS_GROUP_HUD, ImVec4( 90, 90, 255, 255), false, true, false), + COSMETIC_OPTION("HUD.BButton", "B Button", COSMETICS_GROUP_HUD, ImVec4( 0, 150, 0, 255), false, true, false), + COSMETIC_OPTION("HUD.CButtons", "C Buttons", COSMETICS_GROUP_HUD, ImVec4(255, 160, 0, 255), false, true, false), + COSMETIC_OPTION("HUD.CUpButton", "C Up Button", COSMETICS_GROUP_HUD, ImVec4(255, 160, 0, 255), false, true, true), + COSMETIC_OPTION("HUD.CDownButton", "C Down Button", COSMETICS_GROUP_HUD, ImVec4(255, 160, 0, 255), false, true, true), + COSMETIC_OPTION("HUD.CLeftButton", "C Left Button", COSMETICS_GROUP_HUD, ImVec4(255, 160, 0, 255), false, true, true), + COSMETIC_OPTION("HUD.CRightButton", "C Right Button", COSMETICS_GROUP_HUD, ImVec4(255, 160, 0, 255), false, true, true), + COSMETIC_OPTION("HUD.StartButton", "Start Button", COSMETICS_GROUP_HUD, ImVec4(200, 0, 0, 255), false, true, false), + COSMETIC_OPTION("HUD.Dpad", "Dpad", COSMETICS_GROUP_HUD, ImVec4(255, 255, 255, 255), false, true, false), + COSMETIC_OPTION("HUD.KeyCount", "Key Count", COSMETICS_GROUP_HUD, ImVec4(200, 230, 255, 255), false, true, true), + COSMETIC_OPTION("HUD.StoneOfAgony", "Stone of Agony", COSMETICS_GROUP_HUD, ImVec4(255, 255, 255, 255), false, true, true), + COSMETIC_OPTION("HUD.Minimap", "Minimap", COSMETICS_GROUP_HUD, ImVec4( 0, 255, 255, 255), false, true, false), + COSMETIC_OPTION("HUD.MinimapPosition", "Minimap Position", COSMETICS_GROUP_HUD, ImVec4(200, 255, 0, 255), false, true, true), + COSMETIC_OPTION("HUD.MinimapEntrance", "Minimap Entrance", COSMETICS_GROUP_HUD, ImVec4(200, 0, 0, 255), false, true, true), + COSMETIC_OPTION("HUD.EnemyHealthBar", "Enemy Health Bar", COSMETICS_GROUP_HUD, ImVec4(255, 0, 0, 255), true, true, false), + COSMETIC_OPTION("HUD.EnemyHealthBorder", "Enemy Health Border", COSMETICS_GROUP_HUD, ImVec4(255, 255, 255, 255), true, false, true), + COSMETIC_OPTION("HUD.NameTagActorText", "Nametag Text", COSMETICS_GROUP_HUD, ImVec4(255, 255, 255, 255), true, true, false), + COSMETIC_OPTION("HUD.NameTagActorBackground", "Nametag Background", COSMETICS_GROUP_HUD, ImVec4(0, 0, 0, 80), true, false, true), + // Todo (Cosmetics): re-implement title card colors COSMETIC_OPTION("Kaleido.ItemSelA", "Item Select Color", COSMETICS_GROUP_KALEIDO, ImVec4(10, 50, 80, 255), false, true, false), COSMETIC_OPTION("Kaleido.ItemSelB", "Item Select Color B", COSMETICS_GROUP_KALEIDO, ImVec4(70, 100, 130, 255), false, true, true), @@ -298,12 +299,12 @@ static std::map cosmeticOptions = { COSMETIC_OPTION("Arrows.LightPrimary", "Light Primary", COSMETICS_GROUP_ARROWS, ImVec4(255, 255, 0, 255), false, true, false), COSMETIC_OPTION("Arrows.LightSecondary", "Light Secondary", COSMETICS_GROUP_ARROWS, ImVec4(255, 255, 170, 0), false, true, true), - // COSMETIC_OPTION("Magic.DinsPrimary", "Din's Primary", COSMETICS_GROUP_MAGIC, ImVec4(255, 255, 255, 255), false, true, false), // Todo (Cosmetics): Replace gDF_Col - // COSMETIC_OPTION("Magic.DinsSecondary", "Din's Secondary", COSMETICS_GROUP_MAGIC, ImVec4(255, 255, 255, 255), false, true, true), // Todo (Cosmetics): Replace gDF_Env + // COSMETIC_OPTION("Magic.DinsPrimary", "Din's Primary", COSMETICS_GROUP_MAGIC, ImVec4(255, 255, 255, 255), false, true, false), + // COSMETIC_OPTION("Magic.DinsSecondary", "Din's Secondary", COSMETICS_GROUP_MAGIC, ImVec4(255, 255, 255, 255), false, true, true), // COSMETIC_OPTION("Magic.FaroresPrimary", "Farore's Primary", COSMETICS_GROUP_MAGIC, ImVec4(255, 255, 255, 255), false, true, false), // Todo (Cosmetics): Implement // COSMETIC_OPTION("Magic.FaroresSecondary", "Farore's Secondary", COSMETICS_GROUP_MAGIC, ImVec4(255, 255, 255, 255), false, true, true), // Todo (Cosmetics): Implement - // COSMETIC_OPTION("Magic.NayrusPrimary", "Nayru's Primary", COSMETICS_GROUP_MAGIC, ImVec4(255, 255, 255, 255), false, true, false), // Todo (Cosmetics): Replace gNL_Diamond_Col / gNL_Orb_Col - // COSMETIC_OPTION("Magic.NayrusSecondary", "Nayru's Secondary", COSMETICS_GROUP_MAGIC, ImVec4(255, 255, 255, 255), false, true, true), // Todo (Cosmetics): Replace gNL_Diamond_Env / gNL_Orb_Env + // COSMETIC_OPTION("Magic.NayrusPrimary", "Nayru's Primary", COSMETICS_GROUP_MAGIC, ImVec4(255, 255, 255, 255), false, true, false), + // COSMETIC_OPTION("Magic.NayrusSecondary", "Nayru's Secondary", COSMETICS_GROUP_MAGIC, ImVec4(255, 255, 255, 255), false, true, true), COSMETIC_OPTION("SpinAttack.Level1Primary", "Level 1 Primary", COSMETICS_GROUP_SPIN_ATTACK, ImVec4(170, 255, 255, 255), false, true, true), COSMETIC_OPTION("SpinAttack.Level1Secondary", "Level 1 Secondary", COSMETICS_GROUP_SPIN_ATTACK, ImVec4( 0, 100, 255, 255), false, true, false), @@ -350,11 +351,11 @@ static std::map cosmeticOptions = { }; static const char* MarginCvarList[] { - CVAR_COSMETIC("Hearts"), CVAR_COSMETIC("HeartsCount"), CVAR_COSMETIC("MagicBar"), CVAR_COSMETIC("VisualSoA"), CVAR_COSMETIC("BButton"), CVAR_COSMETIC("AButton"), CVAR_COSMETIC("StartButton"), - CVAR_COSMETIC("CUpButton"), CVAR_COSMETIC("CDownButton"), CVAR_COSMETIC("CLeftButton"), CVAR_COSMETIC("CRightButton"), CVAR_COSMETIC("Dpad"), CVAR_COSMETIC("Minimap"), - CVAR_COSMETIC("SmallKey"), CVAR_COSMETIC("Rupees"), CVAR_COSMETIC("Carrots"), CVAR_COSMETIC("Timers"), CVAR_COSMETIC("ArcheryScore"), CVAR_COSMETIC("TitleCard.Map"), CVAR_COSMETIC("TitleCard.Boss"), CVAR_COSMETIC("IGT") + CVAR_COSMETIC("HUD.Hearts"), CVAR_COSMETIC("HUD.HeartsCount"), CVAR_COSMETIC("HUD.MagicBar"), CVAR_COSMETIC("HUD.VisualSoA"), CVAR_COSMETIC("HUD.BButton"), CVAR_COSMETIC("HUD.AButton"), CVAR_COSMETIC("HUD.StartButton"), + CVAR_COSMETIC("HUD.CUpButton"), CVAR_COSMETIC("HUD.CDownButton"), CVAR_COSMETIC("HUD.CLeftButton"), CVAR_COSMETIC("HUD.CRightButton"), CVAR_COSMETIC("HUD.Dpad"), CVAR_COSMETIC("HUD.Minimap"), + CVAR_COSMETIC("HUD.SmallKey"), CVAR_COSMETIC("HUD.Rupees"), CVAR_COSMETIC("HUD.Carrots"), CVAR_COSMETIC("HUD.Timers"), CVAR_COSMETIC("HUD.ArcheryScore"), CVAR_COSMETIC("HUD.TitleCard.Map"), CVAR_COSMETIC("HUD.TitleCard.Boss"), CVAR_COSMETIC("HUD.IGT") }; -static const char* MarginCvarNonAnchor[]{ CVAR_COSMETIC("Carrots"), CVAR_COSMETIC("Timers"), CVAR_COSMETIC("ArcheryScore"), CVAR_COSMETIC("TitleCard.Map"),CVAR_COSMETIC("TitleCard.Boss") }; +static const char* MarginCvarNonAnchor[]{ CVAR_COSMETIC("HUD.Carrots"), CVAR_COSMETIC("HUD.Timers"), CVAR_COSMETIC("HUD.ArcheryScore"), CVAR_COSMETIC("HUD.TitleCard.Map"),CVAR_COSMETIC("HUD.TitleCard.Boss") }; ImVec4 GetRandomValue(int MaximumPossible){ ImVec4 NewColor; @@ -1205,10 +1206,10 @@ void Draw_Placements(){ if (ImGui::BeginTable("tableMargins", 1, FlagsTable)) { ImGui::TableSetupColumn("General margins settings", FlagsCell, TablesCellsWidth); Table_InitHeader(); - UIWidgets::EnhancementSliderInt("Top : %dx", "##UIMARGINT", "gHUDMargin_T", (ImGui::GetWindowViewport()->Size.y/2)*-1, 25, "", 0); - UIWidgets::EnhancementSliderInt("Left: %dx", "##UIMARGINL", "gHUDMargin_L", -25, ImGui::GetWindowViewport()->Size.x, "", 0); - UIWidgets::EnhancementSliderInt("Right: %dx", "##UIMARGINR", "gHUDMargin_R", (ImGui::GetWindowViewport()->Size.x)*-1, 25, "", 0); - UIWidgets::EnhancementSliderInt("Bottom: %dx", "##UIMARGINB", "gHUDMargin_B", (ImGui::GetWindowViewport()->Size.y/2)*-1, 25, "", 0); + UIWidgets::EnhancementSliderInt("Top : %dx", "##UIMARGINT", CVAR_COSMETIC("HUD.Margin.T"), (ImGui::GetWindowViewport()->Size.y/2)*-1, 25, "", 0); + UIWidgets::EnhancementSliderInt("Left: %dx", "##UIMARGINL", CVAR_COSMETIC("HUD.Margin.L"), -25, ImGui::GetWindowViewport()->Size.x, "", 0); + UIWidgets::EnhancementSliderInt("Right: %dx", "##UIMARGINR", CVAR_COSMETIC("HUD.Margin.R"), (ImGui::GetWindowViewport()->Size.x)*-1, 25, "", 0); + UIWidgets::EnhancementSliderInt("Bottom: %dx", "##UIMARGINB", CVAR_COSMETIC("HUD.Margin.B"), (ImGui::GetWindowViewport()->Size.y/2)*-1, 25, "", 0); SetMarginAll("All margins on",true); UIWidgets::Tooltip("Set most of the elements to use margins\nSome elements with default position will not be affected\nElements without Anchor or Hidden will not be turned on"); ImGui::SameLine(); @@ -1224,11 +1225,11 @@ void Draw_Placements(){ if (ImGui::BeginTable("tableHeartsCounts", 1, FlagsTable)) { ImGui::TableSetupColumn("Hearts counts settings", FlagsCell, TablesCellsWidth); Table_InitHeader(false); - DrawUseMarginsSlider("Hearts counts", CVAR_COSMETIC("Hearts")); - DrawPositionsRadioBoxes(CVAR_COSMETIC("HeartsCount")); - DrawPositionSlider(CVAR_COSMETIC("HeartsCount"),-22,ImGui::GetWindowViewport()->Size.y,-125,ImGui::GetWindowViewport()->Size.x); - DrawScaleSlider(CVAR_COSMETIC("HeartsCount"),0.7f); - UIWidgets::EnhancementSliderInt("Heart line length : %d", "##HeartLineLength", CVAR_COSMETIC("Hearts.LineLength"), 0, 20, "", 10); + DrawUseMarginsSlider("Hearts counts", CVAR_COSMETIC("HUD.Hearts")); + DrawPositionsRadioBoxes(CVAR_COSMETIC("HUD.HeartsCount")); + DrawPositionSlider(CVAR_COSMETIC("HUD.HeartsCount"),-22,ImGui::GetWindowViewport()->Size.y,-125,ImGui::GetWindowViewport()->Size.x); + DrawScaleSlider(CVAR_COSMETIC("HUD.HeartsCount"),0.7f); + UIWidgets::EnhancementSliderInt("Heart line length : %d", "##HeartLineLength", CVAR_COSMETIC("HUD.Hearts.LineLength"), 0, 20, "", 10); UIWidgets::Tooltip("This will set the length of a row of hearts. Set to 0 for unlimited length."); ImGui::NewLine(); ImGui::EndTable(); @@ -1238,12 +1239,12 @@ void Draw_Placements(){ if (ImGui::BeginTable("tablemmpos", 1, FlagsTable)) { ImGui::TableSetupColumn("Magic meter settings", FlagsCell, TablesCellsWidth); Table_InitHeader(false); - DrawUseMarginsSlider("Magic meter", CVAR_COSMETIC("MagicBar")); - DrawPositionsRadioBoxes(CVAR_COSMETIC("MagicBar")); - UIWidgets::EnhancementRadioButton("Anchor to life bar", CVAR_COSMETIC("MagicBar.PosType"), 5); + DrawUseMarginsSlider("Magic meter", CVAR_COSMETIC("HUD.MagicBar")); + DrawPositionsRadioBoxes(CVAR_COSMETIC("HUD.MagicBar")); + UIWidgets::EnhancementRadioButton("Anchor to life bar", CVAR_COSMETIC("HUD.MagicBar.PosType"), 5); UIWidgets::Tooltip("This will make your elements follow the bottom of the life meter"); - DrawPositionSlider(CVAR_COSMETIC("MagicBar"), 0, ImGui::GetWindowViewport()->Size.y/2, -5, ImGui::GetWindowViewport()->Size.x/2); - DrawScaleSlider(CVAR_COSMETIC("MagicBar"),1.0f); + DrawPositionSlider(CVAR_COSMETIC("HUD.MagicBar"), 0, ImGui::GetWindowViewport()->Size.y/2, -5, ImGui::GetWindowViewport()->Size.x/2); + DrawScaleSlider(CVAR_COSMETIC("HUD.MagicBar"),1.0f); ImGui::NewLine(); ImGui::EndTable(); } @@ -1252,76 +1253,76 @@ void Draw_Placements(){ if (ImGui::BeginTable("tabledvisualstoneofagony", 1, FlagsTable)) { ImGui::TableSetupColumn("Visual stone of agony settings", FlagsCell, TablesCellsWidth); Table_InitHeader(false); - DrawUseMarginsSlider("Visual stone of agony", CVAR_COSMETIC("VisualSoA")); - DrawPositionsRadioBoxes(CVAR_COSMETIC("VisualSoA")); + DrawUseMarginsSlider("Visual stone of agony", CVAR_COSMETIC("HUD.VisualSoA")); + DrawPositionsRadioBoxes(CVAR_COSMETIC("HUD.VisualSoA")); s16 Min_X_VSOA = 0; s16 Max_X_VSOA = ImGui::GetWindowViewport()->Size.x/2; - if(CVarGetInteger(CVAR_COSMETIC("VisualSoA.PosType"),0) == 2){ + if(CVarGetInteger(CVAR_COSMETIC("HUD.VisualSoA.PosType"),0) == 2){ Max_X_VSOA = 290; - } else if(CVarGetInteger(CVAR_COSMETIC("VisualSoA.PosType"),0) == 4){ + } else if(CVarGetInteger(CVAR_COSMETIC("HUD.VisualSoA.PosType"),0) == 4){ Min_X_VSOA = (ImGui::GetWindowViewport()->Size.x/2)*-1; } - DrawPositionSlider(CVAR_COSMETIC("VisualSoA"), 0, ImGui::GetWindowViewport()->Size.y/2, Min_X_VSOA, Max_X_VSOA); - DrawScaleSlider(CVAR_COSMETIC("VisualSoA"),1.0f); + DrawPositionSlider(CVAR_COSMETIC("HUD.VisualSoA"), 0, ImGui::GetWindowViewport()->Size.y/2, Min_X_VSOA, Max_X_VSOA); + DrawScaleSlider(CVAR_COSMETIC("HUD.VisualSoA"),1.0f); ImGui::NewLine(); ImGui::EndTable(); } } - Draw_Table_Dropdown("B Button position", "tablebbtn", "B Button settings", "B Button", CVAR_COSMETIC("BButton"), 0, ImGui::GetWindowViewport()->Size.y/4+50, -1, ImGui::GetWindowViewport()->Size.x-50, 0.95f); - Draw_Table_Dropdown("A Button position", "tableabtn", "A Button settings", "A Button", CVAR_COSMETIC("AButton"), -10, ImGui::GetWindowViewport()->Size.y/4+50, -20, ImGui::GetWindowViewport()->Size.x-50, 0.95f); - Draw_Table_Dropdown("Start Button position", "tablestartbtn", "Start Button settings", "Start Button", CVAR_COSMETIC("StartButton"), 0, ImGui::GetWindowViewport()->Size.y/2, 0, ImGui::GetWindowViewport()->Size.x/2+70, 0.75f); - C_Button_Dropdown("C Button Up position", "tablecubtn", "C Button Up settings", "C Button Up", CVAR_COSMETIC("CUpButton"), CVAR_COSMETIC("CUpButton.PosType"), 0.5f); - C_Button_Dropdown("C Button Down position", "tablecdbtn", "C Button Down settings", "C Button Down", CVAR_COSMETIC("CDownButton"), CVAR_COSMETIC("CDownButton.PosType"), 0.87f); - C_Button_Dropdown("C Button Left position", "tableclbtn", "C Button Left settings", "C Button Left", CVAR_COSMETIC("CLeftButton"), CVAR_COSMETIC("CLeftButton.PosType"), 0.87f); - C_Button_Dropdown("C Button Right position", "tablecrbtn", "C Button Right settings", "C Button Right", CVAR_COSMETIC("CRightButton"), CVAR_COSMETIC("CRightButton.PosType"), 0.87f); - if (CVarGetInteger("gDpadEquips",0) && ImGui::CollapsingHeader("DPad items position")) { + Draw_Table_Dropdown("B Button position", "tablebbtn", "B Button settings", "B Button", CVAR_COSMETIC("HUD.BButton"), 0, ImGui::GetWindowViewport()->Size.y/4+50, -1, ImGui::GetWindowViewport()->Size.x-50, 0.95f); + Draw_Table_Dropdown("A Button position", "tableabtn", "A Button settings", "A Button", CVAR_COSMETIC("HUD.AButton"), -10, ImGui::GetWindowViewport()->Size.y/4+50, -20, ImGui::GetWindowViewport()->Size.x-50, 0.95f); + Draw_Table_Dropdown("Start Button position", "tablestartbtn", "Start Button settings", "Start Button", CVAR_COSMETIC("HUD.StartButton"), 0, ImGui::GetWindowViewport()->Size.y/2, 0, ImGui::GetWindowViewport()->Size.x/2+70, 0.75f); + C_Button_Dropdown("C Button Up position", "tablecubtn", "C Button Up settings", "C Button Up", CVAR_COSMETIC("HUD.CUpButton"), CVAR_COSMETIC("HUD.CUpButton.PosType"), 0.5f); + C_Button_Dropdown("C Button Down position", "tablecdbtn", "C Button Down settings", "C Button Down", CVAR_COSMETIC("HUD.CDownButton"), CVAR_COSMETIC("HUD.CDownButton.PosType"), 0.87f); + C_Button_Dropdown("C Button Left position", "tableclbtn", "C Button Left settings", "C Button Left", CVAR_COSMETIC("HUD.CLeftButton"), CVAR_COSMETIC("HUD.CLeftButton.PosType"), 0.87f); + C_Button_Dropdown("C Button Right position", "tablecrbtn", "C Button Right settings", "C Button Right", CVAR_COSMETIC("HUD.CRightButton"), CVAR_COSMETIC("HUD.CRightButton.PosType"), 0.87f); + if (CVarGetInteger(CVAR_SETTING("DpadEquips"),0) && ImGui::CollapsingHeader("DPad items position")) { if (ImGui::BeginTable("tabledpaditems", 1, FlagsTable)) { ImGui::TableSetupColumn("DPad items settings", FlagsCell, TablesCellsWidth); Table_InitHeader(false); - DrawUseMarginsSlider("DPad items", CVAR_COSMETIC("Dpad")); - DrawPositionsRadioBoxes(CVAR_COSMETIC("Dpad")); + DrawUseMarginsSlider("DPad items", CVAR_COSMETIC("HUD.Dpad")); + DrawPositionsRadioBoxes(CVAR_COSMETIC("HUD.Dpad")); s16 Min_X_Dpad = 0; s16 Max_X_Dpad = ImGui::GetWindowViewport()->Size.x/2; - if(CVarGetInteger("gDPadPosType",0) == 2){ + if(CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosType"),0) == 2){ Max_X_Dpad = 290; - } else if(CVarGetInteger("gDPadPosType",0) == 4){ + } else if(CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosType"),0) == 4){ Min_X_Dpad = (ImGui::GetWindowViewport()->Size.x/2)*-1; } - DrawPositionSlider(CVAR_COSMETIC("Dpad"), 0, ImGui::GetWindowViewport()->Size.y/2, Min_X_Dpad, Max_X_Dpad); - DrawScaleSlider(CVAR_COSMETIC("Dpad"),1.0f); + DrawPositionSlider(CVAR_COSMETIC("HUD.Dpad"), 0, ImGui::GetWindowViewport()->Size.y/2, Min_X_Dpad, Max_X_Dpad); + DrawScaleSlider(CVAR_COSMETIC("HUD.Dpad"),1.0f); ImGui::NewLine(); ImGui::EndTable(); } } - Draw_Table_Dropdown("Minimaps position", "tableminimapspos", "minimaps settings", "Minimap", CVAR_COSMETIC("Minimap"), (ImGui::GetWindowViewport()->Size.y/3)*-1, ImGui::GetWindowViewport()->Size.y/3, ImGui::GetWindowViewport()->Size.x*-1, ImGui::GetWindowViewport()->Size.x/2, 1.0f); - Draw_Table_Dropdown("Small Keys counter position", "tablesmolekeys", "Small Keys counter settings", "Small Keys counter", CVAR_COSMETIC("SmallKey"), 0, ImGui::GetWindowViewport()->Size.y/3, -1, ImGui::GetWindowViewport()->Size.x/2, 1.0f); - Draw_Table_Dropdown("Rupee counter position", "tablerupeecount", "Rupee counter settings", "Rupee counter", CVAR_COSMETIC("Rupees"), -2, ImGui::GetWindowViewport()->Size.y/3, -3, ImGui::GetWindowViewport()->Size.x/2, 1.0f); - Draw_Table_Dropdown("Carrots position", "tableCarrots", "Carrots settings", "Carrots", CVAR_COSMETIC("Carrots"), 0, ImGui::GetWindowViewport()->Size.y/2, -50, ImGui::GetWindowViewport()->Size.x/2+25, 1.0f); - Draw_Table_Dropdown("Timers position", "tabletimers", "Timers settings", "Timers", CVAR_COSMETIC("Timers"), 0, ImGui::GetWindowViewport()->Size.y/2, -50, ImGui::GetWindowViewport()->Size.x/2-50, 1.0f); - Draw_Table_Dropdown("Archery Scores position", "tablearchery", "Archery Scores settings", "Archery scores", CVAR_COSMETIC("ArcheryScore"), 0, ImGui::GetWindowViewport()->Size.y/2, -50, ImGui::GetWindowViewport()->Size.x/2-50, 1.0f); - Draw_Table_Dropdown("Title cards (Maps) position", "tabletcmaps", "Titlecard maps settings", "Title cards (overworld)", CVAR_COSMETIC("TitleCard.Map"), 0, ImGui::GetWindowViewport()->Size.y/2, -50, ImGui::GetWindowViewport()->Size.x/2+10, 1.0f); - Draw_Table_Dropdown("Title cards (Bosses) position", "tabletcbosses", "Title cards (Bosses) settings", "Title cards (Bosses)", CVAR_COSMETIC("TitleCard.Boss"), 0, ImGui::GetWindowViewport()->Size.y/2, -50, ImGui::GetWindowViewport()->Size.x/2+10, 1.0f); - Draw_Table_Dropdown("In-game Gameplay Timer position", "tablegameplaytimer", "In-game Gameplay Timer settings", "In-game Gameplay Timer", CVAR_COSMETIC("IGT"), 0, ImGui::GetWindowViewport()->Size.y / 2, -50, ImGui::GetWindowViewport()->Size.x / 2 + 10, 1.0f); + Draw_Table_Dropdown("Minimaps position", "tableminimapspos", "minimaps settings", "Minimap", CVAR_COSMETIC("HUD.Minimap"), (ImGui::GetWindowViewport()->Size.y/3)*-1, ImGui::GetWindowViewport()->Size.y/3, ImGui::GetWindowViewport()->Size.x*-1, ImGui::GetWindowViewport()->Size.x/2, 1.0f); + Draw_Table_Dropdown("Small Keys counter position", "tablesmolekeys", "Small Keys counter settings", "Small Keys counter", CVAR_COSMETIC("HUD.SmallKey"), 0, ImGui::GetWindowViewport()->Size.y/3, -1, ImGui::GetWindowViewport()->Size.x/2, 1.0f); + Draw_Table_Dropdown("Rupee counter position", "tablerupeecount", "Rupee counter settings", "Rupee counter", CVAR_COSMETIC("HUD.Rupees"), -2, ImGui::GetWindowViewport()->Size.y/3, -3, ImGui::GetWindowViewport()->Size.x/2, 1.0f); + Draw_Table_Dropdown("Carrots position", "tableCarrots", "Carrots settings", "Carrots", CVAR_COSMETIC("HUD.Carrots"), 0, ImGui::GetWindowViewport()->Size.y/2, -50, ImGui::GetWindowViewport()->Size.x/2+25, 1.0f); + Draw_Table_Dropdown("Timers position", "tabletimers", "Timers settings", "Timers", CVAR_COSMETIC("HUD.Timers"), 0, ImGui::GetWindowViewport()->Size.y/2, -50, ImGui::GetWindowViewport()->Size.x/2-50, 1.0f); + Draw_Table_Dropdown("Archery Scores position", "tablearchery", "Archery Scores settings", "Archery scores", CVAR_COSMETIC("HUD.ArcheryScore"), 0, ImGui::GetWindowViewport()->Size.y/2, -50, ImGui::GetWindowViewport()->Size.x/2-50, 1.0f); + Draw_Table_Dropdown("Title cards (Maps) position", "tabletcmaps", "Titlecard maps settings", "Title cards (overworld)", CVAR_COSMETIC("HUD.TitleCard.Map"), 0, ImGui::GetWindowViewport()->Size.y/2, -50, ImGui::GetWindowViewport()->Size.x/2+10, 1.0f); + Draw_Table_Dropdown("Title cards (Bosses) position", "tabletcbosses", "Title cards (Bosses) settings", "Title cards (Bosses)", CVAR_COSMETIC("HUD.TitleCard.Boss"), 0, ImGui::GetWindowViewport()->Size.y/2, -50, ImGui::GetWindowViewport()->Size.x/2+10, 1.0f); + Draw_Table_Dropdown("In-game Gameplay Timer position", "tablegameplaytimer", "In-game Gameplay Timer settings", "In-game Gameplay Timer", CVAR_COSMETIC("HUD.IGT"), 0, ImGui::GetWindowViewport()->Size.y / 2, -50, ImGui::GetWindowViewport()->Size.x / 2 + 10, 1.0f); if (ImGui::CollapsingHeader("Enemy Health Bar position")) { if (ImGui::BeginTable("enemyhealthbar", 1, FlagsTable)) { ImGui::TableSetupColumn("Enemy Health Bar settings", FlagsCell, TablesCellsWidth); Table_InitHeader(false); - std::string posTypeCVar = CVAR_COSMETIC("HUD.EnemyHealthBarPosType"); + std::string posTypeCVar = CVAR_COSMETIC("HUD.EnemyHealthBar.PosType"); UIWidgets::EnhancementRadioButton("Anchor to Enemy", posTypeCVar.c_str(), ENEMYHEALTH_ANCHOR_ACTOR); UIWidgets::Tooltip("This will use enemy on screen position"); UIWidgets::EnhancementRadioButton("Anchor to the top", posTypeCVar.c_str(), ENEMYHEALTH_ANCHOR_TOP); UIWidgets::Tooltip("This will make your elements follow the top edge of your game window"); UIWidgets::EnhancementRadioButton("Anchor to the bottom", posTypeCVar.c_str(), ENEMYHEALTH_ANCHOR_BOTTOM); UIWidgets::Tooltip("This will make your elements follow the bottom edge of your game window"); - DrawPositionSlider(CVAR_COSMETIC("HUD.EnemyHealthBar"), -SCREEN_HEIGHT, SCREEN_HEIGHT, -ImGui::GetWindowViewport()->Size.x / 2, ImGui::GetWindowViewport()->Size.x / 2); - if (UIWidgets::EnhancementSliderInt("Health Bar Width: %d", "##EnemyHealthBarWidth", CVAR_COSMETIC("HUD.EnemyHealthBarWidth.Value"), 32, 128, "", 64)) { - CVarSetInteger(CVAR_COSMETIC("HUD.EnemyHealthBarWidth.Changed"), 1); + DrawPositionSlider(CVAR_COSMETIC("HUD.EnemyHealthBar."), -SCREEN_HEIGHT, SCREEN_HEIGHT, -ImGui::GetWindowViewport()->Size.x / 2, ImGui::GetWindowViewport()->Size.x / 2); + if (UIWidgets::EnhancementSliderInt("Health Bar Width: %d", "##EnemyHealthBarWidth", CVAR_COSMETIC("HUD.EnemyHealthBar.Width.Value"), 32, 128, "", 64)) { + CVarSetInteger(CVAR_COSMETIC("HUD.EnemyHealthBar.Width.Changed"), 1); } UIWidgets::Tooltip("This will change the width of the health bar"); ImGui::SameLine(); if (ImGui::Button("Reset##EnemyHealthBarWidth")) { - CVarClear(CVAR_COSMETIC("HUD.EnemyHealthBarWidth.Value")); - CVarClear(CVAR_COSMETIC("HUD.EnemyHealthBarWidth.Changed")); + CVarClear(CVAR_COSMETIC("HUD.EnemyHealthBar.Width.Value")); + CVarClear(CVAR_COSMETIC("HUD.EnemyHealthBar.Width.Changed")); Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } ImGui::NewLine(); @@ -1346,8 +1347,8 @@ void Reset_Option_Double(const char* Button_Title, const char* name) { } void DrawSillyTab() { ImGui::BeginDisabled(CVarGetInteger(CVAR_SETTING("DisableChanges"), 0)); - if (CVarGetInteger("gLetItSnow", 0)) { - if (UIWidgets::EnhancementCheckbox("Let It Snow", "gLetItSnow")) { + if (CVarGetInteger(CVAR_GENERAL("LetItSnow"), 0)) { + if (UIWidgets::EnhancementCheckbox("Let It Snow", CVAR_GENERAL("LetItSnow"))) { Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } } @@ -1380,7 +1381,7 @@ void DrawSillyTab() { Reset_Option_Single("Reset##BunnyHood_EarSpread", CVAR_COSMETIC("BunnyHood.EarSpread")); UIWidgets::EnhancementSliderFloat("Goron Neck Length: %f", "##Goron_NeckLength", CVAR_COSMETIC("Goron.NeckLength"), 0.0f, 1000.0f, "", 0.0f, false); Reset_Option_Single("Reset##Goron_NeckLength", CVAR_COSMETIC("Goron.NeckLength")); - UIWidgets::EnhancementCheckbox("Unfix Goron Spin", "gUnfixGoronSpin"); + UIWidgets::EnhancementCheckbox("Unfix Goron Spin", CVAR_COSMETIC("UnfixGoronSpin")); UIWidgets::EnhancementSliderFloat("Fairies Size: %f", "##Fairies_Size", CVAR_COSMETIC("Fairies.Size"), 0.25f, 5.0f, "", 1.0f, false); Reset_Option_Single("Reset##Fairies_Size", CVAR_COSMETIC("Fairies.Size")); UIWidgets::EnhancementSliderFloat("N64 Logo Spin Speed: %f", "##N64Logo_SpinSpeed", CVAR_COSMETIC("N64Logo.SpinSpeed"), 0.25f, 5.0f, "", 1.0f, false); diff --git a/soh/soh/Enhancements/cosmetics/authenticGfxPatches.cpp b/soh/soh/Enhancements/cosmetics/authenticGfxPatches.cpp index 31051729933..f31eedd2cd3 100644 --- a/soh/soh/Enhancements/cosmetics/authenticGfxPatches.cpp +++ b/soh/soh/Enhancements/cosmetics/authenticGfxPatches.cpp @@ -223,7 +223,7 @@ void PatchMirroredSoldOutGI() { G_TX_NOMIRROR | G_TX_CLAMP, 5, 5, G_TX_NOLOD, G_TX_NOLOD), }; - if (CVarGetInteger("gMirroredWorld", 0)) { + if (CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0)) { if (mirroredSoldOutVtx == nullptr) { // Copy the original vertices that we want to modify (4 at the beginning of the resource) mirroredSoldOutVtx = (Vtx*)malloc(sizeof(Vtx) * 4); @@ -270,7 +270,7 @@ void PatchMirroredSunSongEtching() { G_TX_NOMIRROR | G_TX_CLAMP, 7, 5, G_TX_NOLOD, G_TX_NOLOD) }; - if (CVarGetInteger("gMirroredWorld", 0)) { + if (CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0)) { if (mirroredSunSongVtx == nullptr) { // Copy the original vertices that we want to modify (4 at the beginning of the resource) mirroredSunSongVtx = (Vtx*)malloc(sizeof(Vtx) * 4); diff --git a/soh/soh/Enhancements/debugger/actorViewer.cpp b/soh/soh/Enhancements/debugger/actorViewer.cpp index e2b45a41969..3e4d271a827 100644 --- a/soh/soh/Enhancements/debugger/actorViewer.cpp +++ b/soh/soh/Enhancements/debugger/actorViewer.cpp @@ -12,6 +12,7 @@ #include #include #include +#include "soh/OTRGlobals.h" extern "C" { #include @@ -887,7 +888,7 @@ std::vector GetActorsWithDescriptionContainingString(std::string s) { } void ActorViewer_AddTagForActor(Actor* actor) { - int val = CVarGetInteger("gDebugActorViewerNameTags", ACTORVIEWER_NAMETAGS_NONE); + int val = CVarGetInteger(CVAR_DEVELOPER_TOOLS("ActorViewer.NameTags"), ACTORVIEWER_NAMETAGS_NONE); auto entry = ActorDB::Instance->RetrieveEntry(actor->id); std::string tag; @@ -1129,10 +1130,10 @@ void ActorViewerWindow::DrawElement() { newActor.params = 0; } - UIWidgets::EnhancementCheckbox("Advanced mode", "gActorViewerAdvancedParams"); + UIWidgets::EnhancementCheckbox("Advanced mode", CVAR_DEVELOPER_TOOLS("ActorViewer.AdvancedParams")); UIWidgets::InsertHelpHoverText("Changes the actor specific param menus with a direct input"); - if (CVarGetInteger("gActorViewerAdvancedParams", 0)) { + if (CVarGetInteger(CVAR_DEVELOPER_TOOLS("ActorViewer.AdvancedParams"), 0)) { ImGui::InputScalar("params", ImGuiDataType_S16, &newActor.params, &one); } else if (std::find(noParamsActors.begin(), noParamsActors.end(), newActor.id) == noParamsActors.end()) { CreateActorSpecificData(); @@ -1214,7 +1215,7 @@ void ActorViewerWindow::DrawElement() { UIWidgets::Spacer(0); ImGui::Text("Actor Name Tags"); - if (UIWidgets::EnhancementCombobox("gDebugActorViewerNameTags", nameTagOptions, ACTORVIEWER_NAMETAGS_NONE)) { + if (UIWidgets::EnhancementCombobox(CVAR_DEVELOPER_TOOLS("ActorViewer.NameTags"), nameTagOptions, ACTORVIEWER_NAMETAGS_NONE)) { NameTag_RemoveAllByTag(DEBUG_ACTOR_NAMETAG_TAG); ActorViewer_AddTagForAllActors(); } diff --git a/soh/soh/Enhancements/debugger/colViewer.cpp b/soh/soh/Enhancements/debugger/colViewer.cpp index 135dcb0f07a..159e27128f0 100644 --- a/soh/soh/Enhancements/debugger/colViewer.cpp +++ b/soh/soh/Enhancements/debugger/colViewer.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "soh/OTRGlobals.h" extern "C" { #include @@ -57,17 +58,17 @@ void ColViewerWindow::DrawElement() { ImGui::End(); return; } - UIWidgets::EnhancementCheckbox("Enabled", "gColViewerEnabled"); + UIWidgets::EnhancementCheckbox("Enabled", CVAR_DEVELOPER_TOOLS("ColViewer.Enabled")); - UIWidgets::LabeledRightAlignedEnhancementCombobox("Scene", "gColViewerScene", ColRenderSettingNames, COLVIEW_DISABLED); - UIWidgets::LabeledRightAlignedEnhancementCombobox("Bg Actors", "gColViewerBgActors", ColRenderSettingNames, COLVIEW_DISABLED); - UIWidgets::LabeledRightAlignedEnhancementCombobox("Col Check", "gColViewerColCheck", ColRenderSettingNames, COLVIEW_DISABLED); - UIWidgets::LabeledRightAlignedEnhancementCombobox("Waterbox", "gColViewerWaterbox", ColRenderSettingNames, COLVIEW_DISABLED); + UIWidgets::LabeledRightAlignedEnhancementCombobox("Scene", CVAR_DEVELOPER_TOOLS("ColViewer.Scene"), ColRenderSettingNames, COLVIEW_DISABLED); + UIWidgets::LabeledRightAlignedEnhancementCombobox("Bg Actors", CVAR_DEVELOPER_TOOLS("ColViewer.BGActors"), ColRenderSettingNames, COLVIEW_DISABLED); + UIWidgets::LabeledRightAlignedEnhancementCombobox("Col Check", CVAR_DEVELOPER_TOOLS("ColViewer.ColCheck"), ColRenderSettingNames, COLVIEW_DISABLED); + UIWidgets::LabeledRightAlignedEnhancementCombobox("Waterbox", CVAR_DEVELOPER_TOOLS("ColViewer.Waterbox"), ColRenderSettingNames, COLVIEW_DISABLED); - UIWidgets::EnhancementCheckbox("Apply as decal", "gColViewerDecal"); + UIWidgets::EnhancementCheckbox("Apply as decal", CVAR_DEVELOPER_TOOLS("ColViewer.Decal")); UIWidgets::InsertHelpHoverText("Applies the collision as a decal display. This can be useful if there is z-fighting occuring " "with the scene geometry, but can cause other artifacts."); - UIWidgets::EnhancementCheckbox("Shaded", "gColViewerShaded"); + UIWidgets::EnhancementCheckbox("Shaded", CVAR_DEVELOPER_TOOLS("ColViewer.Shaded")); UIWidgets::InsertHelpHoverText("Applies the scene's shading to the collision display."); // This has to be duplicated in both code paths due to the nature of ImGui::IsItemHovered() @@ -75,20 +76,20 @@ void ColViewerWindow::DrawElement() { if (ImGui::TreeNode("Colors")) { UIWidgets::InsertHelpHoverText(colorHelpText); - UIWidgets::EnhancementColor("Normal", "gColViewerColorNormal", scene_col, ImVec4(255, 255, 255, 255), false); - UIWidgets::EnhancementColor("Hookshot", "gColViewerColorHookshot", hookshot_col, ImVec4(128, 128, 255, 255), + UIWidgets::EnhancementColor("Normal", CVAR_DEVELOPER_TOOLS("ColViewer.ColorNormal"), scene_col, ImVec4(255, 255, 255, 255), false); + UIWidgets::EnhancementColor("Hookshot", CVAR_DEVELOPER_TOOLS("ColViewer.ColorHookshot"), hookshot_col, ImVec4(128, 128, 255, 255), false); - UIWidgets::EnhancementColor("Entrance", "gColViewerColorEntrance", entrance_col, ImVec4(0, 255, 0, 255), false); - UIWidgets::EnhancementColor("Special Surface (Grass/Sand/Etc)", "gColViewerColorSpecialSurface", + UIWidgets::EnhancementColor("Entrance", CVAR_DEVELOPER_TOOLS("ColViewer.ColorEntrance"), entrance_col, ImVec4(0, 255, 0, 255), false); + UIWidgets::EnhancementColor("Special Surface (Grass/Sand/Etc)", CVAR_DEVELOPER_TOOLS("ColViewer.ColorSpecialSurface"), specialSurface_col, ImVec4(192, 255, 192, 255), false); - UIWidgets::EnhancementColor("Interactable (Vines/Crawlspace/Etc)", "gColViewerColorInteractable", + UIWidgets::EnhancementColor("Interactable (Vines/Crawlspace/Etc)", CVAR_DEVELOPER_TOOLS("ColViewer.ColorInteractable"), interactable_col, ImVec4(192, 0, 192, 255), false); - UIWidgets::EnhancementColor("Slope", "gColViewerColorSlope", slope_col, ImVec4(255, 255, 128, 255), false); - UIWidgets::EnhancementColor("Void", "gColViewerColorVoid", void_col, ImVec4(255, 0, 0, 255), false); - UIWidgets::EnhancementColor("OC", "gColViewerColorOC", oc_col, ImVec4(255, 255, 255, 255), false); - UIWidgets::EnhancementColor("AC", "gColViewerColorAC", ac_col, ImVec4(0, 0, 255, 255), false); - UIWidgets::EnhancementColor("AT", "gColViewerColorAT", at_col, ImVec4(255, 0, 0, 255), false); - UIWidgets::EnhancementColor("Waterbox", "gColViewerColorWaterbox", waterbox_col, ImVec4(0, 0, 255, 255), false); + UIWidgets::EnhancementColor("Slope", CVAR_DEVELOPER_TOOLS("ColViewer.ColorSlope"), slope_col, ImVec4(255, 255, 128, 255), false); + UIWidgets::EnhancementColor("Void", CVAR_DEVELOPER_TOOLS("ColViewer.ColorVoid"), void_col, ImVec4(255, 0, 0, 255), false); + UIWidgets::EnhancementColor("OC", CVAR_DEVELOPER_TOOLS("ColViewer.ColorOC"), oc_col, ImVec4(255, 255, 255, 255), false); + UIWidgets::EnhancementColor("AC", CVAR_DEVELOPER_TOOLS("ColViewer.ColorAC"), ac_col, ImVec4(0, 0, 255, 255), false); + UIWidgets::EnhancementColor("AT", CVAR_DEVELOPER_TOOLS("ColViewer.ColorAT"), at_col, ImVec4(255, 0, 0, 255), false); + UIWidgets::EnhancementColor("Waterbox", CVAR_DEVELOPER_TOOLS("ColViewer.ColorWaterbox"), waterbox_col, ImVec4(0, 0, 255, 255), false); ImGui::TreePop(); } else { @@ -308,7 +309,7 @@ void InitGfx(std::vector& gfx, ColRenderSetting setting) { alpha = 0xFF; } - if (CVarGetInteger("gColViewerDecal", 0) != 0) { + if (CVarGetInteger(CVAR_DEVELOPER_TOOLS("ColViewer.Decal"), 0) != 0) { rm |= ZMODE_DEC; } else if (setting == ColRenderSetting::Transparent) { rm |= ZMODE_XLU; @@ -320,7 +321,7 @@ void InitGfx(std::vector& gfx, ColRenderSetting setting) { gfx.push_back(gsDPSetCycleType(G_CYC_1CYCLE)); gfx.push_back(gsDPSetRenderMode(rm | blc1, rm | blc2)); - if (CVarGetInteger("gColViewerShaded", 0) != 0) { + if (CVarGetInteger(CVAR_DEVELOPER_TOOLS("ColViewer.Shaded"), 0) != 0) { gfx.push_back(gsDPSetCombineMode(G_CC_MODULATERGB_PRIM_ENVA, G_CC_MODULATERGB_PRIM_ENVA)); gfx.push_back(gsSPLoadGeometryMode(G_CULL_BACK | G_ZBUFFER | G_LIGHTING)); } else { @@ -333,16 +334,13 @@ void InitGfx(std::vector& gfx, ColRenderSetting setting) { // Draws a dynapoly structure (scenes or Bg Actors) void DrawDynapoly(std::vector& dl, CollisionHeader* col, int32_t bgId) { - uint32_t colorR = CVarGetInteger("gColViewerColorNormalR", 255); - uint32_t colorG = CVarGetInteger("gColViewerColorNormalG", 255); - uint32_t colorB = CVarGetInteger("gColViewerColorNormalB", 255); - uint32_t colorA = 255; + Color_RGBA8 color = {255, 255, 255, 255}; - uint32_t lastColorR = colorR; - uint32_t lastColorG = colorG; - uint32_t lastColorB = colorB; + uint32_t lastColorR = color.r; + uint32_t lastColorG = color.g; + uint32_t lastColorB = color.b; - dl.push_back(gsDPSetPrimColor(0, 0, colorR, colorG, colorB, colorA)); + dl.push_back(gsDPSetPrimColor(0, 0, color.r, color.g, color.b, 255)); // This keeps track of if we have processed a poly, but not drawn it yet so we can batch them. // This saves several hundred commands in larger scenes @@ -352,49 +350,35 @@ void DrawDynapoly(std::vector& dl, CollisionHeader* col, int32_t bgId) { CollisionPoly* poly = &col->polyList[i]; if (SurfaceType_IsHookshotSurface(&gPlayState->colCtx, poly, bgId)) { - colorR = CVarGetInteger("gColViewerColorHookshotR", 128); - colorG = CVarGetInteger("gColViewerColorHookshotG", 128); - colorB = CVarGetInteger("gColViewerColorHookshotB", 255); + color = CVarGetColor(CVAR_DEVELOPER_TOOLS("ColViewer.ColorHookshot"), { 128, 128, 255, 255 }); } else if (func_80041D94(&gPlayState->colCtx, poly, bgId) > 0x01) { - colorR = CVarGetInteger("gColViewerColorInteractableR", 192); - colorG = CVarGetInteger("gColViewerColorInteractableG", 0); - colorB = CVarGetInteger("gColViewerColorInteractableB", 192); + color = CVarGetColor(CVAR_DEVELOPER_TOOLS("ColViewer.ColorInteractable"), {192, 0, 192, 255}); } else if (func_80041E80(&gPlayState->colCtx, poly, bgId) == 0x0C) { - colorR = CVarGetInteger("gColViewerColorVoidR", 255); - colorG = CVarGetInteger("gColViewerColorVoidG", 0); - colorB = CVarGetInteger("gColViewerColorVoidB", 0); + color = CVarGetColor(CVAR_DEVELOPER_TOOLS("ColViewer.ColorVoid"), { 255, 0, 0, 255 }); } else if (SurfaceType_GetSceneExitIndex(&gPlayState->colCtx, poly, bgId) || func_80041E80(&gPlayState->colCtx, poly, bgId) == 0x05) { - colorR = CVarGetInteger("gColViewerColorEntranceR", 0); - colorG = CVarGetInteger("gColViewerColorEntranceG", 255); - colorB = CVarGetInteger("gColViewerColorEntranceB", 0); + color = CVarGetColor(CVAR_DEVELOPER_TOOLS("ColViewer.ColorEntrance"), { 0, 255, 0, 255 }); } else if (func_80041D4C(&gPlayState->colCtx, poly, bgId) != 0 || SurfaceType_IsWallDamage(&gPlayState->colCtx, poly, bgId)) { - colorR = CVarGetInteger("gColViewerColorSpecialSurfaceR", 192); - colorG = CVarGetInteger("gColViewerColorSpecialSurfaceG", 255); - colorB = CVarGetInteger("gColViewerColorSpecialSurfaceB", 192); + color = CVarGetColor(CVAR_DEVELOPER_TOOLS("ColViewer.ColorSpecialSurface"), { 192, 255, 192, 255 }); } else if (SurfaceType_GetSlope(&gPlayState->colCtx, poly, bgId) == 0x01) { - colorR = CVarGetInteger("gColViewerColorSlopeR", 255); - colorG = CVarGetInteger("gColViewerColorSlopeG", 255); - colorB = CVarGetInteger("gColViewerColorSlopeB", 128); + color = CVarGetColor(CVAR_DEVELOPER_TOOLS("ColViewer.ColorSlope"), { 255, 255, 128, 255 }); } else { - colorR = CVarGetInteger("gColViewerColorNormalR", 255); - colorG = CVarGetInteger("gColViewerColorNormalG", 255); - colorB = CVarGetInteger("gColViewerColorNormalB", 255); + color = CVarGetColor(CVAR_DEVELOPER_TOOLS("ColViewer.ColorNormal"), { 255, 255, 255, 255 }); } - if (colorR != lastColorR || colorG != lastColorG || colorB != lastColorB) { + if (color.r != lastColorR || color.g != lastColorG || color.b != lastColorB) { // Color changed, flush previous poly if (previousPoly) { dl.push_back(gsSPVertex((uintptr_t)&vtxDl.at(vtxDl.size() - 3), 3, 0)); dl.push_back(gsSP1Triangle(0, 1, 2, 0)); previousPoly = false; } - dl.push_back(gsDPSetPrimColor(0, 0, colorR, colorG, colorB, colorA)); + dl.push_back(gsDPSetPrimColor(0, 0, color.r, color.g, color.b, 255)); } - lastColorR = colorR; - lastColorG = colorG; - lastColorB = colorB; + lastColorR = color.r; + lastColorG = color.g; + lastColorB = color.b; Vec3s* va = &col->vtxList[COLPOLY_VTX_INDEX(poly->flags_vIA)]; Vec3s* vb = &col->vtxList[COLPOLY_VTX_INDEX(poly->flags_vIB)]; @@ -428,9 +412,9 @@ void DrawDynapoly(std::vector& dl, CollisionHeader* col, int32_t bgId) { // Draws the scene void DrawSceneCollision() { - ColRenderSetting showSceneColSetting = (ColRenderSetting)CVarGetInteger("gColViewerScene", COLVIEW_DISABLED); + ColRenderSetting showSceneColSetting = (ColRenderSetting)CVarGetInteger(CVAR_DEVELOPER_TOOLS("ColViewer.Scene"), COLVIEW_DISABLED); - if (showSceneColSetting == ColRenderSetting::Disabled || !CVarGetInteger("gColViewerEnabled", 0)) { + if (showSceneColSetting == ColRenderSetting::Disabled || !CVarGetInteger(CVAR_DEVELOPER_TOOLS("ColViewer.Enabled"), 0)) { return; } @@ -443,8 +427,8 @@ void DrawSceneCollision() { // Draws all Bg Actors void DrawBgActorCollision() { - ColRenderSetting showBgActorSetting = (ColRenderSetting)CVarGetInteger("gColViewerBgActors", COLVIEW_DISABLED); - if (showBgActorSetting == ColRenderSetting::Disabled || !CVarGetInteger("gColViewerEnabled", 0)) { + ColRenderSetting showBgActorSetting = (ColRenderSetting)CVarGetInteger(CVAR_DEVELOPER_TOOLS("ColViewer.BGActors"), COLVIEW_DISABLED); + if (showBgActorSetting == ColRenderSetting::Disabled || !CVarGetInteger(CVAR_DEVELOPER_TOOLS("ColViewer.Enabled"), 0)) { return; } @@ -568,8 +552,8 @@ void DrawColCheckList(std::vector& dl, Collider** objects, int32_t count) { // Draws all Col Check objects void DrawColCheckCollision() { - ColRenderSetting showColCheckSetting = (ColRenderSetting)CVarGetInteger("gColViewerColCheck", COLVIEW_DISABLED); - if (showColCheckSetting == ColRenderSetting::Disabled || !CVarGetInteger("gColViewerEnabled", 0)) { + ColRenderSetting showColCheckSetting = (ColRenderSetting)CVarGetInteger(CVAR_DEVELOPER_TOOLS("ColViewer.ColCheck"), COLVIEW_DISABLED); + if (showColCheckSetting == ColRenderSetting::Disabled || !CVarGetInteger(CVAR_DEVELOPER_TOOLS("ColViewer.Enabled"), 0)) { return; } @@ -578,15 +562,14 @@ void DrawColCheckCollision() { dl.push_back(gsSPMatrix(&gMtxClear, G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH)); CollisionCheckContext& col = gPlayState->colChkCtx; - - dl.push_back(gsDPSetPrimColor(0, 0, CVarGetInteger("gColViewerColorOCR", 255), CVarGetInteger("gColViewerColorOCG", 255), - CVarGetInteger("gColViewerColorOCB", 255), 255)); + Color_RGBA8 color = CVarGetColor(CVAR_DEVELOPER_TOOLS("ColViewer.ColorOC"), { 255, 255, 255, 255 }); + dl.push_back(gsDPSetPrimColor(0, 0, color.r, color.g, color.b, 255)); DrawColCheckList(dl, col.colOC, col.colOCCount); - dl.push_back(gsDPSetPrimColor(0, 0, CVarGetInteger("gColViewerColorACR", 0), CVarGetInteger("gColViewerColorACG", 0), - CVarGetInteger("gColViewerColorACB", 255), 255)); + color = CVarGetColor(CVAR_DEVELOPER_TOOLS("ColViewer.ColorAC"), { 0, 0, 255, 255 }); + dl.push_back(gsDPSetPrimColor(0, 0, color.r, color.g, color.b, 255)); DrawColCheckList(dl, col.colAC, col.colACCount); - dl.push_back(gsDPSetPrimColor(0, 0, CVarGetInteger("gColViewerColorATR", 255), CVarGetInteger("gColViewerColorATG", 0), - CVarGetInteger("gColViewerColorATB", 0), 255)); + color = CVarGetColor(CVAR_DEVELOPER_TOOLS("ColViewer.ColorAT"), { 0, 0, 255, 255 }); + dl.push_back(gsDPSetPrimColor(0, 0, color.r, color.g, color.b, 255)); DrawColCheckList(dl, col.colAT, col.colATCount); } @@ -621,8 +604,8 @@ extern "C" f32 zdWaterBoxMinY; // Draws all waterboxes void DrawWaterboxList() { - ColRenderSetting showWaterboxSetting = (ColRenderSetting)CVarGetInteger("gColViewerWaterbox", COLVIEW_DISABLED); - if (showWaterboxSetting == ColRenderSetting::Disabled || !CVarGetInteger("gColViewerEnabled", 0)) { + ColRenderSetting showWaterboxSetting = (ColRenderSetting)CVarGetInteger(CVAR_DEVELOPER_TOOLS("ColViewer.Waterbox"), COLVIEW_DISABLED); + if (showWaterboxSetting == ColRenderSetting::Disabled || !CVarGetInteger(CVAR_DEVELOPER_TOOLS("ColViewer.Enabled"), 0)) { return; } @@ -630,9 +613,9 @@ void DrawWaterboxList() { InitGfx(dl, showWaterboxSetting); dl.push_back(gsSPMatrix(&gMtxClear, G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH)); - dl.push_back(gsDPSetPrimColor(0, 0, CVarGetInteger("gColViewerColorWaterboxR", 0), - CVarGetInteger("gColViewerColorWaterboxG", 0), - CVarGetInteger("gColViewerColorWaterboxB", 255), 255)); + Color_RGBA8 color = CVarGetColor(CVAR_DEVELOPER_TOOLS("ColViewer.ColorWaterbox"), { 0, 0, 255, 255 }); + + dl.push_back(gsDPSetPrimColor(0, 0, color.r, color.g, color.b, 255)); CollisionHeader* col = gPlayState->colCtx.colHeader; for (int32_t waterboxIndex = 0; waterboxIndex < col->numWaterBoxes; waterboxIndex++) { @@ -693,7 +676,7 @@ extern "C" void DrawColViewer() { OPEN_DISPS(gPlayState->state.gfxCtx); - uint8_t mirroredWorld = CVarGetInteger("gMirroredWorld", 0); + uint8_t mirroredWorld = CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0); // Col viewer needs inverted culling in mirror mode for both OPA and XLU buffers if (mirroredWorld) { gSPSetExtraGeometryMode(POLY_OPA_DISP++, G_EX_INVERT_CULLING); diff --git a/soh/soh/Enhancements/debugger/debugSaveEditor.cpp b/soh/soh/Enhancements/debugger/debugSaveEditor.cpp index f7b85251cd4..216e0e12f2a 100644 --- a/soh/soh/Enhancements/debugger/debugSaveEditor.cpp +++ b/soh/soh/Enhancements/debugger/debugSaveEditor.cpp @@ -1705,7 +1705,7 @@ void DrawPlayerTab() { ImGui::SameLine(); ImGui::InputScalar("C Right", ImGuiDataType_U8, &gSaveContext.equips.buttonItems[3], &one, NULL); - if (CVarGetInteger("gDpadEquips", 0)) { + if (CVarGetInteger(CVAR_SETTING("DpadEquips"), 0)) { ImGui::NewLine(); ImGui::Text("Current D-pad Equips"); ImGui::InputScalar("D-pad Up ", ImGuiDataType_U8, &gSaveContext.equips.buttonItems[4], &one, NULL); // Two spaces at the end for aligning, not elegant but it's working diff --git a/soh/soh/Enhancements/debugger/valueViewer.cpp b/soh/soh/Enhancements/debugger/valueViewer.cpp index 14a571dacf9..97bf8516403 100644 --- a/soh/soh/Enhancements/debugger/valueViewer.cpp +++ b/soh/soh/Enhancements/debugger/valueViewer.cpp @@ -1,5 +1,6 @@ #include "valueViewer.h" #include "../../UIWidgets.hpp" +#include "soh/OTRGlobals.h" extern "C" { #include @@ -107,7 +108,7 @@ void ValueViewerWindow::DrawElement() { return; } - UIWidgets::PaddedEnhancementCheckbox("Enable Printing", "gValueViewer.EnablePrinting"); + UIWidgets::PaddedEnhancementCheckbox("Enable Printing", CVAR_DEVELOPER_TOOLS("ValueViewerEnablePrinting")); ImGui::BeginGroup(); static int selectedElement = -1; @@ -187,7 +188,7 @@ void ValueViewerWindow::DrawElement() { } ImGui::BeginGroup(); - if (CVarGetInteger("gValueViewer.EnablePrinting", 0)) { + if (CVarGetInteger(CVAR_DEVELOPER_TOOLS("ValueViewerEnablePrinting"), 0)) { ImGui::Checkbox(("Print##" + std::string(element.name)).c_str(), &element.isPrinted); if (element.isPrinted) { char* prefix = (char*)element.prefix.c_str(); diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor_RawAction.cpp b/soh/soh/Enhancements/game-interactor/GameInteractor_RawAction.cpp index cf098bda313..5e61f704ded 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor_RawAction.cpp +++ b/soh/soh/Enhancements/game-interactor/GameInteractor_RawAction.cpp @@ -353,19 +353,19 @@ void GameInteractor::RawAction::SetTimeOfDay(uint32_t time) { } void GameInteractor::RawAction::SetCollisionViewer(bool active) { - CVarSetInteger("gColViewerEnabled", active); - CVarSetInteger("gColViewerDecal", active); + CVarSetInteger(CVAR_DEVELOPER_TOOLS("ColViewer.Enabled"), active); + CVarSetInteger(CVAR_DEVELOPER_TOOLS("ColViewer.Decal"), active); if (active) { - CVarSetInteger("gColViewerScene", COLVIEW_TRANSPARENT); - CVarSetInteger("gColViewerBgActors", COLVIEW_TRANSPARENT); - CVarSetInteger("gColViewerColCheck", COLVIEW_TRANSPARENT); - CVarSetInteger("gColViewerWaterbox", COLVIEW_TRANSPARENT); + CVarSetInteger(CVAR_DEVELOPER_TOOLS("ColViewer.Scene"), COLVIEW_TRANSPARENT); + CVarSetInteger(CVAR_DEVELOPER_TOOLS("ColViewer.BGActors"), COLVIEW_TRANSPARENT); + CVarSetInteger(CVAR_DEVELOPER_TOOLS("ColViewer.ColCheck"), COLVIEW_TRANSPARENT); + CVarSetInteger(CVAR_DEVELOPER_TOOLS("ColViewer.Waterbox"), COLVIEW_TRANSPARENT); } else { - CVarSetInteger("gColViewerScene", COLVIEW_DISABLED); - CVarSetInteger("gColViewerBgActors", COLVIEW_DISABLED); - CVarSetInteger("gColViewerColCheck", COLVIEW_DISABLED); - CVarSetInteger("gColViewerWaterbox", COLVIEW_DISABLED); + CVarSetInteger(CVAR_DEVELOPER_TOOLS("ColViewer.Scene"), COLVIEW_DISABLED); + CVarSetInteger(CVAR_DEVELOPER_TOOLS("ColViewer.BGActors"), COLVIEW_DISABLED); + CVarSetInteger(CVAR_DEVELOPER_TOOLS("ColViewer.ColCheck"), COLVIEW_DISABLED); + CVarSetInteger(CVAR_DEVELOPER_TOOLS("ColViewer.Waterbox"), COLVIEW_DISABLED); } } diff --git a/soh/soh/Enhancements/gameplaystats.cpp b/soh/soh/Enhancements/gameplaystats.cpp index fa35edfb603..61eb88a6f16 100644 --- a/soh/soh/Enhancements/gameplaystats.cpp +++ b/soh/soh/Enhancements/gameplaystats.cpp @@ -388,7 +388,7 @@ void GameplayStatsRow(const char* label, const std::string& value, ImVec4 color } bool compareTimestampInfoByTime(const TimestampInfo& a, const TimestampInfo& b) { - return CVarGetInteger("gGameplayStats.TimestampsReverse", 0) ? a.time > b.time : a.time < b.time; + return CVarGetInteger(CVAR_ENHANCEMENT("GameplayStats.ReverseTimestamps"), 0) ? a.time > b.time : a.time < b.time; } const char* ResolveSceneID(int sceneID, int roomID){ @@ -443,13 +443,13 @@ void DrawGameplayStatsHeader() { } else { GameplayStatsRow("Total Game Time:", formatTimestampGameplayStat(GAMEPLAYSTAT_TOTAL_TIME), gSaveContext.sohStats.gameComplete ? COLOR_GREEN : COLOR_WHITE); } - if (CVarGetInteger("gGameplayStats.ShowAdditionalTimers", 0)) { // !Only display total game time + if (CVarGetInteger(CVAR_ENHANCEMENT("GameplayStats.ShowAdditionalTimers"), 0)) { // !Only display total game time GameplayStatsRow("Gameplay Time:", formatTimestampGameplayStat(gSaveContext.sohStats.playTimer / 2), COLOR_GREY); GameplayStatsRow("Pause Menu Time:", formatTimestampGameplayStat(gSaveContext.sohStats.pauseTimer / 3), COLOR_GREY); GameplayStatsRow("Time in scene:", formatTimestampGameplayStat(gSaveContext.sohStats.sceneTimer / 2), COLOR_LIGHT_BLUE); GameplayStatsRow("Time in room:", formatTimestampGameplayStat(gSaveContext.sohStats.roomTimer / 2), COLOR_LIGHT_BLUE); } - if (gPlayState != NULL && CVarGetInteger("gGameplayStats.ShowDebugInfo", 0)) { // && display debug info + if (gPlayState != NULL && CVarGetInteger(CVAR_ENHANCEMENT("GameplayStats.ShowDebugInfo"), 0)) { // && display debug info GameplayStatsRow("play->sceneNum:", formatHexGameplayStat(gPlayState->sceneNum), COLOR_YELLOW); GameplayStatsRow("gSaveContext.entranceIndex:", formatHexGameplayStat(gSaveContext.entranceIndex), COLOR_YELLOW); GameplayStatsRow("gSaveContext.cutsceneIndex:", formatHexOnlyGameplayStat(gSaveContext.cutsceneIndex), COLOR_YELLOW); @@ -567,13 +567,13 @@ void DrawGameplayStatsBreakdownTab() { for (int i = 0; i < gSaveContext.sohStats.tsIdx; i++) { std::string sceneName = ResolveSceneID(gSaveContext.sohStats.sceneTimestamps[i].scene, gSaveContext.sohStats.sceneTimestamps[i].room); std::string name; - if (CVarGetInteger("gGameplayStats.RoomBreakdown", 0) && gSaveContext.sohStats.sceneTimestamps[i].scene != SCENE_GROTTOS) { + if (CVarGetInteger(CVAR_ENHANCEMENT("GameplayStats.RoomBreakdown"), 0) && gSaveContext.sohStats.sceneTimestamps[i].scene != SCENE_GROTTOS) { name = fmt::format("{:s} Room {:d}", sceneName, gSaveContext.sohStats.sceneTimestamps[i].room); } else { name = sceneName; } strcpy(sceneTimestampDisplay[i].name, name.c_str()); - sceneTimestampDisplay[i].time = CVarGetInteger("gGameplayStats.RoomBreakdown", 0) ? + sceneTimestampDisplay[i].time = CVarGetInteger(CVAR_ENHANCEMENT("GameplayStats.RoomBreakdown"), 0) ? gSaveContext.sohStats.sceneTimestamps[i].roomTime : gSaveContext.sohStats.sceneTimestamps[i].sceneTime; sceneTimestampDisplay[i].color = COLOR_GREY; sceneTimestampDisplay[i].isRoom = gSaveContext.sohStats.sceneTimestamps[i].isRoom; @@ -584,13 +584,13 @@ void DrawGameplayStatsBreakdownTab() { ImGui::TableSetupColumn("stat", ImGuiTableColumnFlags_WidthStretch); for (int i = 0; i < gSaveContext.sohStats.tsIdx; i++) { TimestampInfo tsInfo = sceneTimestampDisplay[i]; - bool canShow = !tsInfo.isRoom || CVarGetInteger("gGameplayStats.RoomBreakdown", 0); + bool canShow = !tsInfo.isRoom || CVarGetInteger(CVAR_ENHANCEMENT("GameplayStats.RoomBreakdown"), 0); if (tsInfo.time > 0 && strnlen(tsInfo.name, 40) > 1 && canShow) { GameplayStatsRow(tsInfo.name, formatTimestampGameplayStat(tsInfo.time), tsInfo.color); } } std::string toPass; - if (CVarGetInteger("gGameplayStats.RoomBreakdown", 0) && gSaveContext.sohStats.sceneNum != SCENE_GROTTOS) { + if (CVarGetInteger(CVAR_ENHANCEMENT("GameplayStats.RoomBreakdown"), 0) && gSaveContext.sohStats.sceneNum != SCENE_GROTTOS) { toPass = fmt::format("{:s} Room {:d}", ResolveSceneID(gSaveContext.sohStats.sceneNum, gSaveContext.sohStats.roomNum), gSaveContext.sohStats.roomNum); } else { toPass = ResolveSceneID(gSaveContext.sohStats.sceneNum, gSaveContext.sohStats.roomNum); @@ -601,21 +601,21 @@ void DrawGameplayStatsBreakdownTab() { } void DrawGameplayStatsOptionsTab() { - UIWidgets::PaddedEnhancementCheckbox("Show in-game total timer", "gGameplayStats.ShowIngameTimer", true, false); + UIWidgets::PaddedEnhancementCheckbox("Show in-game total timer", CVAR_ENHANCEMENT("GameplayStats.ShowIngameTimer"), true, false); UIWidgets::InsertHelpHoverText("Keep track of the timer as an in-game HUD element. The position of the timer can be changed in the Cosmetics Editor."); - UIWidgets::PaddedEnhancementCheckbox("Show latest timestamps on top", "gGameplayStats.TimestampsReverse", true, false); - UIWidgets::PaddedEnhancementCheckbox("Room Breakdown", "gGameplayStats.RoomBreakdown", true, false); + UIWidgets::PaddedEnhancementCheckbox("Show latest timestamps on top", CVAR_ENHANCEMENT("GameplayStats.ReverseTimestamps"), true, false); + UIWidgets::PaddedEnhancementCheckbox("Room Breakdown", CVAR_ENHANCEMENT("GameplayStats.RoomBreakdown"), true, false); ImGui::SameLine(); UIWidgets::InsertHelpHoverText("Allows a more in-depth perspective of time spent in a certain map."); - UIWidgets::PaddedEnhancementCheckbox("RTA Timing on new files", "gGameplayStats.RTATiming", true, false); + UIWidgets::PaddedEnhancementCheckbox("RTA Timing on new files", CVAR_ENHANCEMENT("GameplayStats.RTATiming"), true, false); ImGui::SameLine(); UIWidgets::InsertHelpHoverText( "Timestamps are relative to starting timestamp rather than in game time, usually necessary for races/speedruns.\n\n" "Starting timestamp is on first non-c-up input after intro cutscene.\n\n" "NOTE: THIS NEEDS TO BE SET BEFORE CREATING A FILE TO TAKE EFFECT" ); - UIWidgets::PaddedEnhancementCheckbox("Show additional detail timers", "gGameplayStats.ShowAdditionalTimers", true, false); - UIWidgets::PaddedEnhancementCheckbox("Show Debug Info", "gGameplayStats.ShowDebugInfo"); + UIWidgets::PaddedEnhancementCheckbox("Show additional detail timers", CVAR_ENHANCEMENT("GameplayStats.ShowAdditionalTimers"), true, false); + UIWidgets::PaddedEnhancementCheckbox("Show Debug Info", CVAR_ENHANCEMENT("GameplayStats.ShowDebugInfo")); } void GameplayStatsWindow::DrawElement() { @@ -657,7 +657,7 @@ void InitStats(bool isDebug) { for (int dungeon = 0; dungeon < ARRAY_COUNT(gSaveContext.sohStats.dungeonKeys); dungeon++) { gSaveContext.sohStats.dungeonKeys[dungeon] = isDebug ? 8 : 0; } - gSaveContext.sohStats.rtaTiming = CVarGetInteger("gGameplayStats.RTATiming", 0); + gSaveContext.sohStats.rtaTiming = CVarGetInteger(CVAR_ENHANCEMENT("GameplayStats.RTATiming"), 0); gSaveContext.sohStats.fileCreatedAt = 0; gSaveContext.sohStats.playTimer = 0; gSaveContext.sohStats.pauseTimer = 0; diff --git a/soh/soh/Enhancements/gameplaystats.h b/soh/soh/Enhancements/gameplaystats.h index 8772dd37f15..528da33f93f 100644 --- a/soh/soh/Enhancements/gameplaystats.h +++ b/soh/soh/Enhancements/gameplaystats.h @@ -12,7 +12,7 @@ (!gSaveContext.sohStats.fileCreatedAt ? 0 : ((GetUnixTimestamp() - gSaveContext.sohStats.fileCreatedAt) / 100)) :\ (gSaveContext.sohStats.itemTimestamp[TIMESTAMP_DEFEAT_GANON])) :\ (gSaveContext.sohStats.playTimer / 2 + gSaveContext.sohStats.pauseTimer / 3)) -#define CURRENT_MODE_TIMER (CVarGetInteger("gGameplayStats.RoomBreakdown", 0) ?\ +#define CURRENT_MODE_TIMER (CVarGetInteger(CVAR_ENHANCEMENT("GameplayStats.RoomBreakdown"), 0) ?\ gSaveContext.sohStats.roomTimer :\ gSaveContext.sohStats.sceneTimer) diff --git a/soh/soh/Enhancements/mods.cpp b/soh/soh/Enhancements/mods.cpp index 8ddd59cef98..9a3988e39a5 100644 --- a/soh/soh/Enhancements/mods.cpp +++ b/soh/soh/Enhancements/mods.cpp @@ -196,14 +196,14 @@ void RegisterUnrestrictedItems() { void RegisterFreezeTime() { GameInteractor::Instance->RegisterGameHook([]() { if (CVarGetInteger(CVAR_CHEAT("FreezeTime"), 0) != 0) { - if (CVarGetInteger("gPrevTime", -1) == -1) { - CVarSetInteger("gPrevTime", gSaveContext.dayTime); + if (CVarGetInteger(CVAR_GENERAL("PrevTime"), -1) == -1) { + CVarSetInteger(CVAR_GENERAL("PrevTime"), gSaveContext.dayTime); } - int32_t prevTime = CVarGetInteger("gPrevTime", gSaveContext.dayTime); + int32_t prevTime = CVarGetInteger(CVAR_GENERAL("PrevTime"), gSaveContext.dayTime); gSaveContext.dayTime = prevTime; } else { - CVarClear("gPrevTime"); + CVarClear(CVAR_GENERAL("PrevTime")); } }); } @@ -272,11 +272,11 @@ void RegisterOcarinaTimeTravel() { !nearbyOcarinaSpot && !nearbyFrogs) { if (IS_RANDO) { - CVarSetInteger("gSwitchTimeline", 1); + CVarSetInteger(CVAR_GENERAL("SwitchTimeline"), 1); } else if (!IS_RANDO && !nearbyDoorOfTime) { // This check is made for when Link is learning the Song Of Time in a vanilla save file that load a // Temple of Time scene where the only object present is the Door of Time - CVarSetInteger("gSwitchTimeline", 1); + CVarSetInteger(CVAR_GENERAL("SwitchTimeline"), 1); } ReloadSceneTogglingLinkAge(); } @@ -699,10 +699,10 @@ void UpdateMirrorModeState(int32_t sceneNum) { ((mirroredMode == MIRRORED_WORLD_DUNGEONS_RANDOM || mirroredMode == MIRRORED_WORLD_DUNGEONS_RANDOM_SEEDED) && randomMirror))) ) { nextMirroredWorld = true; - CVarSetInteger("gMirroredWorld", 1); + CVarSetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 1); } else { nextMirroredWorld = false; - CVarClear("gMirroredWorld"); + CVarClear(CVAR_ENHANCEMENT("MirroredWorld")); } if (prevMirroredWorld != nextMirroredWorld) { diff --git a/soh/soh/Enhancements/nametag.cpp b/soh/soh/Enhancements/nametag.cpp index 0d4ce2a0c60..2adc3fffb39 100644 --- a/soh/soh/Enhancements/nametag.cpp +++ b/soh/soh/Enhancements/nametag.cpp @@ -91,7 +91,7 @@ void DrawNameTag(PlayState* play, const NameTag* nameTag) { // Set position, billboard effect, scale (with mirror mode), then center nametag Matrix_Translate(nameTag->actor->world.pos.x, posY, nameTag->actor->world.pos.z, MTXMODE_NEW); Matrix_ReplaceRotation(&play->billboardMtxF); - Matrix_Scale(scale * (CVarGetInteger("gMirroredWorld", 0) ? -1 : 1), -scale, 1.0f, MTXMODE_APPLY); + Matrix_Scale(scale * (CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0) ? -1 : 1), -scale, 1.0f, MTXMODE_APPLY); Matrix_Translate(-(float)nameTag->width / 2, -nameTag->height, 0, MTXMODE_APPLY); Matrix_ToMtx(nameTag->mtx, (char*)__FILE__, __LINE__); diff --git a/soh/soh/Enhancements/presets.cpp b/soh/soh/Enhancements/presets.cpp index ea51502e3ad..57bfd689cad 100644 --- a/soh/soh/Enhancements/presets.cpp +++ b/soh/soh/Enhancements/presets.cpp @@ -40,7 +40,7 @@ void applyPreset(std::vector entries) { } void DrawPresetSelector(PresetType presetTypeId) { - const std::string presetTypeCvar = "gPreset" + std::to_string(presetTypeId); + const std::string presetTypeCvar = CVAR_GENERAL("SelectedPresets.") + std::to_string(presetTypeId); const PresetTypeDefinition presetTypeDef = presetTypes.at(presetTypeId); const uint16_t selectedPresetId = CVarGetInteger(presetTypeCvar.c_str(), 0); const PresetDefinition selectedPresetDef = presetTypeDef.presets.at(selectedPresetId); diff --git a/soh/soh/Enhancements/presets.h b/soh/soh/Enhancements/presets.h index 1392691df06..aea4bb1fd79 100644 --- a/soh/soh/Enhancements/presets.h +++ b/soh/soh/Enhancements/presets.h @@ -60,18 +60,18 @@ void applyPreset(std::vector entries); // TODO: Ideally everything below this point will come from one/many JSON files const std::vector enhancementsCvars = { - "gDpadPause", - "gDpadText", - "gDpadOcarina", - "gRStickOcarina", - "gDpadEquips", - "gPauseAnyCursor", + CVAR_SETTING("DPadOnPause"), + CVAR_SETTING("DpadInText"), + CVAR_SETTING("OcarinaControl.Dpad"), + CVAR_SETTING("OcarinaControl.RStick"), + CVAR_SETTING("DpadEquips"), + CVAR_SETTING("PauseAnyCursor"), CVAR_ENHANCEMENT("DpadNoDropOcarinaInput"), - "gNaviOnL", - "gInvertXAxis", - "gInvertYAxis", - "gRightStickAiming", - "gDisableAutoCenterViewFirstPerson", + CVAR_SETTING("NaviOnL"), + CVAR_SETTING("FreeLook.InvertXAxis"), + CVAR_SETTING("FreeLook.InvertYAxis"), + CVAR_SETTING("Controls.RightStickAim"), + CVAR_SETTING("DisableFirstPersonAutoCenterView"), CVAR_ENHANCEMENT("TextSpeed"), CVAR_ENHANCEMENT("MweepSpeed"), CVAR_ENHANCEMENT("ForgeTime"), @@ -152,7 +152,6 @@ const std::vector enhancementsCvars = { CVAR_ENHANCEMENT("PauseLiveLinkRotation"), CVAR_ENHANCEMENT("PauseLiveLink"), CVAR_ENHANCEMENT("MinFrameCount"), - "gN64Mode", CVAR_ENHANCEMENT("NewDrops"), CVAR_ENHANCEMENT("DisableBlackBars"), CVAR_ENHANCEMENT("DynamicWalletIcon"), @@ -240,7 +239,7 @@ const std::vector enhancementsCvars = { CVAR_ENHANCEMENT("RandomizedEnemySizes"), CVAR_ENHANCEMENT("RandomizedEnemies"), CVAR_ENHANCEMENT("MirroredWorldMode"), - "gMirroredWorld", + CVAR_ENHANCEMENT("MirroredWorld"), CVAR_ENHANCEMENT("HyperEnemies"), CVAR_ENHANCEMENT("HookshotableReticle"), CVAR_ENHANCEMENT("HideBunnyHood"), @@ -287,12 +286,12 @@ const std::vector cheatCvars = { CVAR_WINDOW("CollisionViewer"), CVAR_WINDOW("DLViewer"), CVAR_WINDOW("SaveEditor"), - "gEnableWalkModify", - "gWalkSpeedToggle", - "gWalkModifierOne", - "gWalkModifierTwo", - "gSwimModifierOne", - "gSwimModifierTwo", + CVAR_SETTING("WalkModifier.Enabled"), + CVAR_SETTING("WalkModifier.SpeedToggle"), + CVAR_SETTING("WalkModifier.Mapping1"), + CVAR_SETTING("WalkModifier.Mapping2"), + CVAR_SETTING("WalkModifier.SwimMapping1"), + CVAR_SETTING("WalkModifier.SwimMapping2"), CVAR_ENHANCEMENT("GoronPot"), CVAR_ENHANCEMENT("DampeWin"), CVAR_ENHANCEMENT("CustomizeShootingGallery"), @@ -317,7 +316,7 @@ const std::vector cheatCvars = { CVAR_CHEAT("EasyInputBuffer"), CVAR_CHEAT("NoRestrictItems"), CVAR_CHEAT("FreezeTime"), - "gPrevTime", + CVAR_GENERAL("PrevTime"), CVAR_CHEAT("DropsDontDie"), CVAR_CHEAT("FireproofDekuShield"), CVAR_CHEAT("ShieldTwoHanded"), @@ -329,19 +328,17 @@ const std::vector cheatCvars = { CVAR_CHEAT("EnableBetaQuest"), CVAR_DEVELOPER_TOOLS("BetterDebugWarpScreen"), CVAR_GENERAL("SwitchAge"), - "gSwitchTimeline", + CVAR_GENERAL("SwitchTimeline"), CVAR_CHEAT("NoRedeadFreeze"), CVAR_CHEAT("NoKeeseGuayTarget"), CVAR_CHEAT("BombTimerMultiplier"), CVAR_CHEAT("NoFishDespawn"), CVAR_CHEAT("NoBugsDespawn"), - "gWalkModifierDoesntChangeJump", + CVAR_SETTING("WalkModifier.DoesntChangeJump"), CVAR_STATS_WINDOW_OPEN, CVAR_CHEAT("SaveStatesEnabled"), CVAR_CHEAT("SaveStatePromise"), CVAR_DEVELOPER_TOOLS("RegEditEnabled"), - "gPreset0", - "gPreset1", CVAR_CHEAT("DekuStick"), CVAR_DEVELOPER_TOOLS("DebugWarpScreenTranslation"), CVAR_DEVELOPER_TOOLS("DebugSaveFileMode"), @@ -493,17 +490,17 @@ const std::vector randomizerCvars = { const std::vector vanillaPlusPresetEntries = { // D-pad Support in text and file select - PRESET_ENTRY_S32("gDpadText", 1), + PRESET_ENTRY_S32(CVAR_SETTING("DpadInText"), 1), // Play Ocarina with D-pad - PRESET_ENTRY_S32("gDpadOcarina", 1), + PRESET_ENTRY_S32(CVAR_SETTING("OcarinaControl.Dpad"), 1), // Play Ocarina with Right Stick - PRESET_ENTRY_S32("gRStickOcarina", 1), + PRESET_ENTRY_S32(CVAR_SETTING("OcarinaControl.RStick"), 1), // D-pad as Equip Items - PRESET_ENTRY_S32("gDpadEquips", 1), + PRESET_ENTRY_S32(CVAR_SETTING("DpadEquips"), 1), // Prevent Dropped Ocarina Inputs PRESET_ENTRY_S32(CVAR_ENHANCEMENT("DpadNoDropOcarinaInput"), 1), // Right Stick Aiming - PRESET_ENTRY_S32("gRightStickAiming", 1), + PRESET_ENTRY_S32(CVAR_SETTING("Controls.RightStickAim"), 1), // Text Speed (1 to 5) PRESET_ENTRY_S32(CVAR_ENHANCEMENT("TextSpeed"), 5), @@ -564,17 +561,17 @@ const std::vector vanillaPlusPresetEntries = { const std::vector enhancedPresetEntries = { // D-pad Support in text and file select - PRESET_ENTRY_S32("gDpadText", 1), + PRESET_ENTRY_S32(CVAR_SETTING("DpadInText"), 1), // Play Ocarina with D-pad - PRESET_ENTRY_S32("gDpadOcarina", 1), + PRESET_ENTRY_S32(CVAR_SETTING("OcarinaControl.Dpad"), 1), // Play Ocarina with Right Stick - PRESET_ENTRY_S32("gRStickOcarina", 1), + PRESET_ENTRY_S32(CVAR_SETTING("OcarinaControl.RStick"), 1), // D-pad as Equip Items - PRESET_ENTRY_S32("gDpadEquips", 1), + PRESET_ENTRY_S32(CVAR_SETTING("DpadEquips"), 1), // Prevent Dropped Ocarina Inputs PRESET_ENTRY_S32(CVAR_ENHANCEMENT("DpadNoDropOcarinaInput"), 1), // Right Stick Aiming - PRESET_ENTRY_S32("gRightStickAiming", 1), + PRESET_ENTRY_S32(CVAR_SETTING("Controls.RightStickAim"), 1), // Text Speed (1 to 5) PRESET_ENTRY_S32(CVAR_ENHANCEMENT("TextSpeed"), 5), @@ -693,17 +690,17 @@ const std::vector enhancedPresetEntries = { const std::vector randomizerPresetEntries = { // D-pad Support in text and file select - PRESET_ENTRY_S32("gDpadText", 1), + PRESET_ENTRY_S32(CVAR_SETTING("DpadInText"), 1), // Play Ocarina with D-pad - PRESET_ENTRY_S32("gDpadOcarina", 1), + PRESET_ENTRY_S32(CVAR_SETTING("OcarinaControl.Dpad"), 1), // Play Ocarina with Right Stick - PRESET_ENTRY_S32("gRStickOcarina", 1), + PRESET_ENTRY_S32(CVAR_SETTING("OcarinaControl.RStick"), 1), // D-pad as Equip Items - PRESET_ENTRY_S32("gDpadEquips", 1), + PRESET_ENTRY_S32(CVAR_SETTING("DpadEquips"), 1), // Prevent Dropped Ocarina Inputs PRESET_ENTRY_S32(CVAR_ENHANCEMENT("DpadNoDropOcarinaInput"), 1), // Right Stick Aiming - PRESET_ENTRY_S32("gRightStickAiming", 1), + PRESET_ENTRY_S32(CVAR_SETTING("Controls.RightStickAim"), 1), // Text Speed (1 to 5) PRESET_ENTRY_S32(CVAR_ENHANCEMENT("TextSpeed"), 5), @@ -867,10 +864,10 @@ const std::vector spockRacePresetEntries = { PRESET_ENTRY_S32(CVAR_ENHANCEMENT("DisableNaviCallAudio"), 1), PRESET_ENTRY_S32(CVAR_ENHANCEMENT("FastChests"), 1), PRESET_ENTRY_S32(CVAR_ENHANCEMENT("FastDrops"), 1), - PRESET_ENTRY_S32("gDpadText", 1), - PRESET_ENTRY_S32("gDpadOcarina", 1), - PRESET_ENTRY_S32("gRStickOcarina", 1), - PRESET_ENTRY_S32("gDpadEquips", 1), + PRESET_ENTRY_S32(CVAR_SETTING("DpadInText"), 1), + PRESET_ENTRY_S32(CVAR_SETTING("OcarinaControl.Dpad"), 1), + PRESET_ENTRY_S32(CVAR_SETTING("OcarinaControl.RStick"), 1), + PRESET_ENTRY_S32(CVAR_SETTING("DpadEquips"), 1), PRESET_ENTRY_S32(CVAR_ENHANCEMENT("FastOcarinaPlayback"), 1), PRESET_ENTRY_S32(CVAR_ENHANCEMENT("InstantScarecrow"), 1), PRESET_ENTRY_S32(CVAR_ENHANCEMENT("MarketSneak"), 1), @@ -886,7 +883,7 @@ const std::vector spockRacePresetEntries = { PRESET_ENTRY_S32(CVAR_ENHANCEMENT("CreditsFix"), 1), PRESET_ENTRY_S32(CVAR_ENHANCEMENT("SkipText"), 1), PRESET_ENTRY_S32(CVAR_ENHANCEMENT("SkulltulaFreeze"), 1), - PRESET_ENTRY_S32("gPauseAnyCursor", 1), + PRESET_ENTRY_S32(CVAR_SETTING("PauseAnyCursor"), 1), PRESET_ENTRY_S32(CVAR_ENHANCEMENT("FastFarores"), 1), PRESET_ENTRY_S32(CVAR_ENHANCEMENT("NoInputForCredits"), 1), PRESET_ENTRY_S32(CVAR_ENHANCEMENT("MaskSelect"), 1), @@ -969,7 +966,6 @@ const std::vector spockRaceNoLogicPresetEntries = { PRESET_ENTRY_S32(CVAR_ENHANCEMENT("ForgeTime"), 0), PRESET_ENTRY_S32(CVAR_ENHANCEMENT("GoronPot"), 1), PRESET_ENTRY_S32(CVAR_ENHANCEMENT("GuaranteeFishingBite"), 1), - PRESET_ENTRY_S32("gHideBuildInfo", 1), PRESET_ENTRY_S32(CVAR_ENHANCEMENT("InjectItemCounts"), 1), PRESET_ENTRY_S32(CVAR_ENHANCEMENT("InstantFishing"), 1), PRESET_ENTRY_S32(CVAR_ENHANCEMENT("InstantPutaway"), 1), @@ -979,7 +975,7 @@ const std::vector spockRaceNoLogicPresetEntries = { PRESET_ENTRY_S32(CVAR_ENHANCEMENT("MweepSpeed"), 5), PRESET_ENTRY_S32(CVAR_ENHANCEMENT("NoForcedNavi"), 1), PRESET_ENTRY_S32(CVAR_ENHANCEMENT("NoInputForCredits"), 1), - PRESET_ENTRY_S32("gPauseAnyCursor", 1), + PRESET_ENTRY_S32(CVAR_SETTING("PauseAnyCursor"), 1), PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("10GSHint"), 1), PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("20GSHint"), 1), PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("30GSHint"), 1), diff --git a/soh/soh/Enhancements/randomizer/3drando/rando_main.cpp b/soh/soh/Enhancements/randomizer/3drando/rando_main.cpp index e53caeef21c..6f342535b00 100644 --- a/soh/soh/Enhancements/randomizer/3drando/rando_main.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/rando_main.cpp @@ -8,6 +8,7 @@ #include #include #include +#include "soh/OTRGlobals.h" void RandoMain::GenerateRando(std::unordered_map cvarSettings, std::set excludedLocations, std::set enabledTricks, std::string seedString) { @@ -16,14 +17,14 @@ void RandoMain::GenerateRando(std::unordered_map cvarS LocationTable_Init(); // std::string settingsFileName = "./randomizer/latest_settings.json"; - // CVarSetString("gLoadedPreset", settingsFileName.c_str()); + // CVarSetString(CVAR_RANDOMIZER_SETTING("LoadedPreset"), settingsFileName.c_str()); std::string fileName = Ship::Context::GetPathRelativeToAppDirectory(GenerateRandomizer(cvarSettings, excludedLocations, enabledTricks, seedString).c_str()); - CVarSetString("gSpoilerLog", fileName.c_str()); + CVarSetString(CVAR_GENERAL("SpoilerLog"), fileName.c_str()); CVarSave(); CVarLoad(); - CVarSetInteger("gNewSeedGenerated", 1); + CVarSetInteger(CVAR_GENERAL("NewSeedGenerated"), 1); } std::array* RandoMain::GetFullItemTable() { diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index 187e50eab60..f5c522ddc0d 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -2827,7 +2827,7 @@ RandomizerCheck Randomizer::GetCheckFromRandomizerInf(RandomizerInf randomizerIn std::thread randoThread; void GenerateRandomizerImgui(std::string seed = "") { - CVarSetInteger("gRandoGenerating", 1); + CVarSetInteger(CVAR_GENERAL("RandoGenerating"), 1); CVarSave(); std::unordered_map cvarSettings; @@ -2945,7 +2945,7 @@ void GenerateRandomizerImgui(std::string seed = "") { // RANDOTODO implement chest minigame shuffle with keysanity cvarSettings[RSK_SHUFFLE_CHEST_MINIGAME] = false; - cvarSettings[RSK_LANGUAGE] = CVarGetInteger("gLanguages", 0); + cvarSettings[RSK_LANGUAGE] = CVarGetInteger(CVAR_SETTING("Languages"), 0); cvarSettings[RSK_CUCCO_COUNT] = CVarGetInteger(CVAR_RANDOMIZER_SETTING("CuccosToReturn"), 7); cvarSettings[RSK_BIG_POE_COUNT] = CVarGetInteger(CVAR_RANDOMIZER_SETTING("BigPoeTargetCount"), 10); @@ -3052,7 +3052,7 @@ void GenerateRandomizerImgui(std::string seed = "") { RandoMain::GenerateRando(cvarSettings, excludedLocations, enabledTricks, seed); - CVarSetInteger("gRandoGenerating", 0); + CVarSetInteger(CVAR_GENERAL("RandoGenerating"), 0); CVarSave(); CVarLoad(); @@ -3060,7 +3060,7 @@ void GenerateRandomizerImgui(std::string seed = "") { } bool GenerateRandomizer(std::string seed /*= ""*/) { - if (CVarGetInteger("gRandoGenerating", 0) == 0) { + if (CVarGetInteger(CVAR_GENERAL("RandoGenerating"), 0) == 0) { randoThread = std::thread(&GenerateRandomizerImgui, seed); return true; } @@ -3144,7 +3144,7 @@ void RandomizerSettingsWindow::DrawElement() { return; } - bool disableEditingRandoSettings = CVarGetInteger("gRandoGenerating", 0) || CVarGetInteger("gOnFileSelectNameEntry", 0); + bool disableEditingRandoSettings = CVarGetInteger(CVAR_GENERAL("RandoGenerating"), 0) || CVarGetInteger(CVAR_GENERAL("OnFileSelectNameEntry"), 0); if (disableEditingRandoSettings) { UIWidgets::DisableComponent(ImGui::GetStyle().Alpha * 0.5f); } @@ -3182,12 +3182,12 @@ void RandomizerSettingsWindow::DrawElement() { UIWidgets::Spacer(0); if (!CVarGetInteger(CVAR_RANDOMIZER_SETTING("DontGenerateSpoiler"), 0)) { - std::string spoilerfilepath = CVarGetString("gSpoilerLog", ""); + std::string spoilerfilepath = CVarGetString(CVAR_GENERAL("SpoilerLog"), ""); ImGui::Text("Spoiler File: %s", spoilerfilepath.c_str()); } // RANDOTODO settings presets - // std::string presetfilepath = CVarGetString("gLoadedPreset", ""); + // std::string presetfilepath = CVarGetString(CVAR_RANDOMIZER_SETTING("LoadedPreset"), ""); // ImGui::Text("Settings File: %s", presetfilepath.c_str()); UIWidgets::PaddedSeparator(); diff --git a/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp b/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp index 20b5c333dc2..4ca8c79937a 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp @@ -1068,7 +1068,7 @@ void CheckTrackerWindow::DrawElement() { } bool shouldHideArea(ImGuiTextFilter& checkSearch, std::map> checksByArea, RandomizerCheckArea rcArea) { - bool shouldHideFilteredAreas = CVarGetInteger("gTrackers.CheckTracker.HideFilteredAreas", 1); + bool shouldHideFilteredAreas = CVarGetInteger(CVAR_TRACKER_CHECK("HideFilteredAreas"), 1); if (!shouldHideFilteredAreas) { return false; } @@ -1640,7 +1640,7 @@ void CheckTrackerSettingsWindow::DrawElement() { // Filtering settings UIWidgets::PaddedSeparator(); - UIWidgets::EnhancementCheckbox("Filter Empty Areas", "gTrackers.CheckTracker.HideFilteredAreas", false, "", UIWidgets::CheckboxGraphics::Checkmark, true); + UIWidgets::EnhancementCheckbox("Filter Empty Areas", CVAR_TRACKER_CHECK("HideFilteredAreas"), false, "", UIWidgets::CheckboxGraphics::Checkmark, true); UIWidgets::Tooltip("If enabled, will hide area headers that have no locations matching filter"); ImGui::TableNextColumn(); @@ -1650,7 +1650,7 @@ void CheckTrackerSettingsWindow::DrawElement() { CheckTracker::ImGuiDrawTwoColorPickerSection("Unchecked", CVAR_TRACKER_CHECK("Unchecked.MainColor"), CVAR_TRACKER_CHECK("Unchecked.ExtraColor"), Color_Unchecked_Main, Color_Unchecked_Extra, Color_Main_Default, Color_Unchecked_Extra_Default, CVAR_TRACKER_CHECK("Unchecked.Hide"), "Checks you have not interacted with at all."); CheckTracker::ImGuiDrawTwoColorPickerSection("Skipped", CVAR_TRACKER_CHECK("Skipped.MainColor"), CVAR_TRACKER_CHECK("Skipped.ExtraColor"), Color_Skipped_Main, Color_Skipped_Extra, Color_Main_Default, Color_Skipped_Extra_Default, CVAR_TRACKER_CHECK("Skipped.Hide"), ""); CheckTracker::ImGuiDrawTwoColorPickerSection("Seen", CVAR_TRACKER_CHECK("Seen.MainColor"), CVAR_TRACKER_CHECK("Seen.ExtraColor"), Color_Seen_Main, Color_Seen_Extra, Color_Main_Default, Color_Seen_Extra_Default, CVAR_TRACKER_CHECK("Seen.Hide"), "Used for shops. Shows item names for shop slots when walking in, and prices when highlighting them in buy mode."); - CheckTracker::ImGuiDrawTwoColorPickerSection("Scummed", CVAR_TRACKER_CHECK("Scummed.MainColor"), CVAR_TRACKER_CHECK("Scummed.ExtraColor"), Color_Scummed_Main, Color_Scummed_Extra, Color_Main_Default, Color_Scummed_Extra_Default, "gCheckTrackerScummedHide", "Checks you collect, but then reload before saving so you no longer have them."); + CheckTracker::ImGuiDrawTwoColorPickerSection("Scummed", CVAR_TRACKER_CHECK("Scummed.MainColor"), CVAR_TRACKER_CHECK("Scummed.ExtraColor"), Color_Scummed_Main, Color_Scummed_Extra, Color_Main_Default, Color_Scummed_Extra_Default, CVAR_TRACKER_CHECK("Scummed.Hide"), "Checks you collect, but then reload before saving so you no longer have them."); //CheckTracker::ImGuiDrawTwoColorPickerSection("Hinted (WIP)", CVAR_TRACKER_CHECK("Hinted.MainColor"), CVAR_TRACKER_CHECK("Hinted.ExtraColor"), Color_Hinted_Main, Color_Hinted_Extra, Color_Main_Default, Color_Hinted_Extra_Default, CVAR_TRACKER_CHECK("Hinted.Hide"), ""); CheckTracker::ImGuiDrawTwoColorPickerSection("Collected", CVAR_TRACKER_CHECK("Collected.MainColor"), CVAR_TRACKER_CHECK("Collected.ExtraColor"), Color_Collected_Main, Color_Collected_Extra, Color_Main_Default, Color_Collected_Extra_Default, CVAR_TRACKER_CHECK("Collected.Hide"), "Checks you have collected without saving or reloading yet."); CheckTracker::ImGuiDrawTwoColorPickerSection("Saved", CVAR_TRACKER_CHECK("Saved.MainColor"), CVAR_TRACKER_CHECK("Saved.ExtraColor"), Color_Saved_Main, Color_Saved_Extra, Color_Main_Default, Color_Saved_Extra_Default, CVAR_TRACKER_CHECK("Saved.Hide"), "Checks that you saved the game while having collected."); diff --git a/soh/soh/Enhancements/resolution-editor/ResolutionEditor.cpp b/soh/soh/Enhancements/resolution-editor/ResolutionEditor.cpp index b522879cb12..f7eea08737b 100644 --- a/soh/soh/Enhancements/resolution-editor/ResolutionEditor.cpp +++ b/soh/soh/Enhancements/resolution-editor/ResolutionEditor.cpp @@ -4,8 +4,9 @@ #include #include +#include "soh/OTRGlobals.h" -/* Console Variables are grouped under gAdvancedResolution. (e.g. "gAdvancedResolution.Enabled") +/* Console Variables are grouped under gAdvancedResolution. (e.g. CVAR_PREFIX_ADVANCED_RESOLUTION ".Enabled") The following cvars are used in Libultraship and can be edited here: - Enabled - Turns Advanced Resolution Mode on. @@ -83,25 +84,25 @@ void AdvancedResolutionSettingsWindow::DrawElement() { // Letting it go below 1 in this Editor will even allow for checking if screen bounds are being exceeded. if (default_maxIntegerScaleFactor < integerScale_maximumBounds) { max_integerScaleFactor = - integerScale_maximumBounds + CVarGetInteger("gAdvancedResolution.IntegerScale.ExceedBoundsBy", 0); + integerScale_maximumBounds + CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.ExceedBoundsBy", 0); } // Combo List defaults - static int item_aspectRatio = CVarGetInteger("gAdvancedResolution.UIComboItem.AspectRatio", 3); - static int item_pixelCount = CVarGetInteger("gAdvancedResolution.UIComboItem.PixelCount", default_pixelCount); + static int item_aspectRatio = CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".UIComboItem.AspectRatio", 3); + static int item_pixelCount = CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".UIComboItem.PixelCount", default_pixelCount); // Stored Values for non-UIWidgets elements static float aspectRatioX = - CVarGetFloat("gAdvancedResolution.AspectRatioX", aspectRatioPresetsX[item_aspectRatio]); + CVarGetFloat(CVAR_PREFIX_ADVANCED_RESOLUTION ".AspectRatioX", aspectRatioPresetsX[item_aspectRatio]); static float aspectRatioY = - CVarGetFloat("gAdvancedResolution.AspectRatioY", aspectRatioPresetsY[item_aspectRatio]); + CVarGetFloat(CVAR_PREFIX_ADVANCED_RESOLUTION ".AspectRatioY", aspectRatioPresetsY[item_aspectRatio]); static int verticalPixelCount = - CVarGetInteger("gAdvancedResolution.VerticalPixelCount", pixelCountPresets[item_pixelCount]); + CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".VerticalPixelCount", pixelCountPresets[item_pixelCount]); // Additional settings static bool showHorizontalResField = false; static int horizontalPixelCount = (verticalPixelCount / aspectRatioY) * aspectRatioX; // Disabling flags - const bool disabled_everything = !CVarGetInteger("gAdvancedResolution.Enabled", 0); - const bool disabled_pixelCount = !CVarGetInteger("gAdvancedResolution.VerticalResolutionToggle", 0); + const bool disabled_everything = !CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".Enabled", 0); + const bool disabled_pixelCount = !CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".VerticalResolutionToggle", 0); #ifdef __APPLE__ // Display HiDPI warning. (Remove this once we can definitively say it's fixed.) @@ -112,8 +113,8 @@ void AdvancedResolutionSettingsWindow::DrawElement() { if (ImGui::CollapsingHeader("Original Settings", ImGuiTreeNodeFlags_DefaultOpen)) { // The original resolution slider (for convenience) - const bool disabled_resolutionSlider = (CVarGetInteger("gAdvancedResolution.VerticalResolutionToggle", 0) && - CVarGetInteger("gAdvancedResolution.Enabled", 0)) || + const bool disabled_resolutionSlider = (CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".VerticalResolutionToggle", 0) && + CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".Enabled", 0)) || CVarGetInteger(CVAR_LOW_RES_MODE, 0); if (UIWidgets::EnhancementSliderFloat("Internal Resolution: %.1f%%", "##IMul", CVAR_INTERNAL_RESOLUTION, 0.5f, 2.0f, "", 1.0f, true, true, disabled_resolutionSlider)) { @@ -140,7 +141,7 @@ void AdvancedResolutionSettingsWindow::DrawElement() { UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); // Activator - UIWidgets::PaddedEnhancementCheckbox("Enable advanced settings.", "gAdvancedResolution.Enabled", false, false, + UIWidgets::PaddedEnhancementCheckbox("Enable advanced settings.", CVAR_PREFIX_ADVANCED_RESOLUTION ".Enabled", false, false, false, "", UIWidgets::CheckboxGraphics::Cross, false); // Error/Warning display if (!CVarGetInteger(CVAR_LOW_RES_MODE, 0)) { @@ -185,9 +186,9 @@ void AdvancedResolutionSettingsWindow::DrawElement() { horizontalPixelCount = (verticalPixelCount / aspectRatioY) * aspectRatioX; } - CVarSetFloat("gAdvancedResolution.AspectRatioX", aspectRatioX); - CVarSetFloat("gAdvancedResolution.AspectRatioY", aspectRatioY); - CVarSetInteger("gAdvancedResolution.UIComboItem.AspectRatio", item_aspectRatio); + CVarSetFloat(CVAR_PREFIX_ADVANCED_RESOLUTION ".AspectRatioX", aspectRatioX); + CVarSetFloat(CVAR_PREFIX_ADVANCED_RESOLUTION ".AspectRatioY", aspectRatioY); + CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".UIComboItem.AspectRatio", item_aspectRatio); CVarSave(); } // Hide aspect ratio input fields if using one of the presets. @@ -217,7 +218,7 @@ void AdvancedResolutionSettingsWindow::DrawElement() { // Vertical Resolution UIWidgets::PaddedEnhancementCheckbox("Set fixed vertical resolution (disables Resolution slider)", - "gAdvancedResolution.VerticalResolutionToggle", true, false, + CVAR_PREFIX_ADVANCED_RESOLUTION ".VerticalResolutionToggle", true, false, disabled_everything, "", UIWidgets::CheckboxGraphics::Cross, false); UIWidgets::Tooltip( "Override the resolution scale slider and use the settings below, irrespective of window size."); @@ -233,8 +234,8 @@ void AdvancedResolutionSettingsWindow::DrawElement() { horizontalPixelCount = (verticalPixelCount / aspectRatioY) * aspectRatioX; } - CVarSetInteger("gAdvancedResolution.VerticalPixelCount", verticalPixelCount); - CVarSetInteger("gAdvancedResolution.UIComboItem.PixelCount", item_pixelCount); + CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".VerticalPixelCount", verticalPixelCount); + CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".UIComboItem.PixelCount", item_pixelCount); CVarSave(); } // Horizontal Resolution, if visibility is enabled for it. @@ -290,43 +291,43 @@ void AdvancedResolutionSettingsWindow::DrawElement() { // Integer scaling settings group (Pixel-perfect Mode) static const ImGuiTreeNodeFlags IntegerScalingResolvedImGuiFlag = - CVarGetInteger("gAdvancedResolution.PixelPerfectMode", 0) ? ImGuiTreeNodeFlags_DefaultOpen + CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", 0) ? ImGuiTreeNodeFlags_DefaultOpen : ImGuiTreeNodeFlags_None; if (ImGui::CollapsingHeader("Integer Scaling Settings", IntegerScalingResolvedImGuiFlag)) { const bool disabled_pixelPerfectMode = - !CVarGetInteger("gAdvancedResolution.PixelPerfectMode", 0) || disabled_everything; + !CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", 0) || disabled_everything; // Pixel-perfect Mode - UIWidgets::PaddedEnhancementCheckbox("Pixel-perfect Mode", "gAdvancedResolution.PixelPerfectMode", true, + UIWidgets::PaddedEnhancementCheckbox("Pixel-perfect Mode", CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", true, true, disabled_pixelCount || disabled_everything, "", UIWidgets::CheckboxGraphics::Cross, false); UIWidgets::Tooltip("Don't scale image to fill window."); - if (disabled_pixelCount && CVarGetInteger("gAdvancedResolution.PixelPerfectMode", 0)) { - CVarSetInteger("gAdvancedResolution.PixelPerfectMode", 0); + if (disabled_pixelCount && CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", 0)) { + CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", 0); CVarSave(); } // Integer Scaling UIWidgets::EnhancementSliderInt( - "Integer scale factor: %d", "##ARSIntScale", "gAdvancedResolution.IntegerScale.Factor", 1, + "Integer scale factor: %d", "##ARSIntScale", CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.Factor", 1, max_integerScaleFactor, "%d", 1, true, - disabled_pixelPerfectMode || CVarGetInteger("gAdvancedResolution.IntegerScale.FitAutomatically", 0)); + disabled_pixelPerfectMode || CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.FitAutomatically", 0)); UIWidgets::Tooltip("Integer scales the image. Only available in pixel-perfect mode."); // Display warning if size is being clamped or if framebuffer is larger than viewport. if (!disabled_pixelPerfectMode && - (CVarGetInteger("gAdvancedResolution.IntegerScale.NeverExceedBounds", 1) && - CVarGetInteger("gAdvancedResolution.IntegerScale.Factor", 1) > integerScale_maximumBounds)) { + (CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.NeverExceedBounds", 1) && + CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.Factor", 1) > integerScale_maximumBounds)) { ImGui::SameLine(); ImGui::TextColored(messageColor[MESSAGE_WARNING], ICON_FA_EXCLAMATION_TRIANGLE " Window exceeded."); } UIWidgets::PaddedEnhancementCheckbox( - "Automatically scale image to fit viewport", "gAdvancedResolution.IntegerScale.FitAutomatically", true, + "Automatically scale image to fit viewport", CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.FitAutomatically", true, true, disabled_pixelPerfectMode, "", UIWidgets::CheckboxGraphics::Cross, false); UIWidgets::Tooltip("Automatically sets scale factor to fit window. Only available in pixel-perfect mode."); - if (CVarGetInteger("gAdvancedResolution.IntegerScale.FitAutomatically", 0)) { + if (CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.FitAutomatically", 0)) { // This is just here to update the value shown on the slider. // The function in LUS to handle this setting will ignore IntegerScaleFactor while active. - CVarSetInteger("gAdvancedResolution.IntegerScale.Factor", integerScale_maximumBounds); + CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.Factor", integerScale_maximumBounds); // CVarSave(); } } // End of integer scaling settings @@ -344,19 +345,19 @@ void AdvancedResolutionSettingsWindow::DrawElement() { UIWidgets::PaddedEnhancementCheckbox("Disable aspect correction and stretch the output image.\n" "(Might be useful for 4:3 televisions!)\n" "Not available in Pixel Perfect Mode.", - "gAdvancedResolution.IgnoreAspectCorrection", false, true, - CVarGetInteger("gAdvancedResolution.PixelPerfectMode", 0) || + CVAR_PREFIX_ADVANCED_RESOLUTION ".IgnoreAspectCorrection", false, true, + CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", 0) || disabled_everything, "", UIWidgets::CheckboxGraphics::Cross, false); #else - if (CVarGetInteger("gAdvancedResolution.IgnoreAspectCorrection", 0)) { + if (CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IgnoreAspectCorrection", 0)) { // This setting is intentionally not exposed on PC platforms, // but may be accidentally activated for varying reasons. // Having this button should hopefully prevent support headaches. ImGui::TextColored(messageColor[MESSAGE_QUESTION], ICON_FA_QUESTION_CIRCLE " If the image is stretched and you don't know why, click this."); if (ImGui::Button("Click to reenable aspect correction.")) { - CVarSetInteger("gAdvancedResolution.IgnoreAspectCorrection", 0); + CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IgnoreAspectCorrection", 0); CVarSave(); } UIWidgets::Spacer(2); @@ -386,12 +387,12 @@ void AdvancedResolutionSettingsWindow::DrawElement() { // Integer Scaling - Never Exceed Bounds. const bool disabled_neverExceedBounds = - !CVarGetInteger("gAdvancedResolution.PixelPerfectMode", 0) || - CVarGetInteger("gAdvancedResolution.IntegerScale.FitAutomatically", 0) || disabled_everything; + !CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", 0) || + CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.FitAutomatically", 0) || disabled_everything; const bool checkbox_neverExceedBounds = UIWidgets::PaddedEnhancementCheckbox("Prevent integer scaling from exceeding screen bounds.\n" "(Makes screen bounds take priority over specified factor.)", - "gAdvancedResolution.IntegerScale.NeverExceedBounds", + CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.NeverExceedBounds", true, false, disabled_neverExceedBounds, "", UIWidgets::CheckboxGraphics::Cross, true); UIWidgets::Tooltip( @@ -403,22 +404,22 @@ void AdvancedResolutionSettingsWindow::DrawElement() { // Initialise the (currently unused) "Exceed Bounds By" cvar if it's been changed. if (checkbox_neverExceedBounds && - CVarGetInteger("gAdvancedResolution.IntegerScale.ExceedBoundsBy", 0)) { - CVarSetInteger("gAdvancedResolution.IntegerScale.ExceedBoundsBy", 0); + CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.ExceedBoundsBy", 0)) { + CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.ExceedBoundsBy", 0); CVarSave(); } // Integer Scaling - Exceed Bounds By 1x/Offset. // A popular feature in some retro frontends/upscalers, sometimes called "crop overscan" or "1080p 5x". /* - UIWidgets::PaddedEnhancementCheckbox("Allow integer scale factor to go +1 above maximum screen bounds.", "gAdvancedResolution.IntegerScale.ExceedBoundsBy", false, false, !CVarGetInteger("gAdvancedResolution.PixelPerfectMode", 0) || disabled_everything, "", UIWidgets::CheckboxGraphics::Cross, false); + UIWidgets::PaddedEnhancementCheckbox("Allow integer scale factor to go +1 above maximum screen bounds.", CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.ExceedBoundsBy", false, false, !CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", 0) || disabled_everything, "", UIWidgets::CheckboxGraphics::Cross, false); */ // It does actually function as expected, but exceeding the bottom of the screen shows a scroll bar. // I've ended up commenting this one out because of the scroll bar, and for simplicity. // Display an info message about the scroll bar. - if (!CVarGetInteger("gAdvancedResolution.IntegerScale.NeverExceedBounds", 1) || - CVarGetInteger("gAdvancedResolution.IntegerScale.ExceedBoundsBy", 0)) { + if (!CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.NeverExceedBounds", 1) || + CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.ExceedBoundsBy", 0)) { if (disabled_neverExceedBounds) { // Dim this help text accordingly UIWidgets::DisableComponent(ImGui::GetStyle().Alpha * 0.5f); } @@ -431,9 +432,9 @@ void AdvancedResolutionSettingsWindow::DrawElement() { // Another support helper button, to disable the unused "Exceed Bounds By" cvar. // (Remove this button if uncommenting the checkbox.) - if (CVarGetInteger("gAdvancedResolution.IntegerScale.ExceedBoundsBy", 0)) { + if (CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.ExceedBoundsBy", 0)) { if (ImGui::Button("Click to reset a console variable that may be causing this.")) { - CVarSetInteger("gAdvancedResolution.IntegerScale.ExceedBoundsBy", 0); + CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.ExceedBoundsBy", 0); CVarSave(); } } @@ -451,13 +452,13 @@ void AdvancedResolutionSettingsWindow::DrawElement() { if (aspectRatioX < 0.0f) { aspectRatioX = 0.0f; } - CVarSetFloat("gAdvancedResolution.AspectRatioX", aspectRatioX); + CVarSetFloat(CVAR_PREFIX_ADVANCED_RESOLUTION ".AspectRatioX", aspectRatioX); } if (update[UPDATE_aspectRatioY]) { if (aspectRatioY < 0.0f) { aspectRatioY = 0.0f; } - CVarSetFloat("gAdvancedResolution.AspectRatioY", aspectRatioY); + CVarSetFloat(CVAR_PREFIX_ADVANCED_RESOLUTION ".AspectRatioY", aspectRatioY); } if (update[UPDATE_verticalPixelCount]) { // There's a upper and lower clamp on the Libultraship side too, @@ -468,10 +469,10 @@ void AdvancedResolutionSettingsWindow::DrawElement() { if (verticalPixelCount > maxVerticalPixelCount) { verticalPixelCount = maxVerticalPixelCount; } - CVarSetInteger("gAdvancedResolution.VerticalPixelCount", verticalPixelCount); + CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".VerticalPixelCount", verticalPixelCount); } - CVarSetInteger("gAdvancedResolution.UIComboItem.AspectRatio", item_aspectRatio); - CVarSetInteger("gAdvancedResolution.UIComboItem.PixelCount", item_pixelCount); + CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".UIComboItem.AspectRatio", item_aspectRatio); + CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".UIComboItem.PixelCount", item_pixelCount); CVarSave(); } } @@ -484,7 +485,7 @@ void AdvancedResolutionSettingsWindow::UpdateElement() { bool AdvancedResolutionSettingsWindow::IsDroppingFrames() { // a rather imprecise way of checking for frame drops. // but it's mostly there to inform the player of large drops. - const short targetFPS = CVarGetInteger("gInterpolationFPS", 20); + const short targetFPS = CVarGetInteger(CVAR_SETTING("InterpolationFPS"), 20); const float threshold = targetFPS / 20.0f + 4.1f; return ImGui::GetIO().Framerate < targetFPS - threshold; } diff --git a/soh/soh/Enhancements/tts/tts.cpp b/soh/soh/Enhancements/tts/tts.cpp index abdcda0eeeb..593706dd6e2 100644 --- a/soh/soh/Enhancements/tts/tts.cpp +++ b/soh/soh/Enhancements/tts/tts.cpp @@ -92,7 +92,7 @@ std::string GetParameritizedText(std::string key, TextBank bank, const char* arg } const char* GetLanguageCode() { - switch (CVarGetInteger("gLanguages", 0)) { + switch (CVarGetInteger(CVAR_SETTING("Languages"), 0)) { case LANGUAGE_FRA: return "fr-FR"; break; @@ -116,7 +116,7 @@ static std::string titleCardText; void RegisterOnSceneInitHook() { GameInteractor::Instance->RegisterGameHook([](int16_t sceneNum) { - if (!CVarGetInteger("gA11yTTS", 0)) return; + if (!CVarGetInteger(CVAR_SETTING("A11yTTS"), 0)) return; titleCardText = NameForSceneId(sceneNum); }); @@ -124,7 +124,7 @@ void RegisterOnSceneInitHook() { void RegisterOnPresentTitleCardHook() { GameInteractor::Instance->RegisterGameHook([]() { - if (!CVarGetInteger("gA11yTTS", 0)) return; + if (!CVarGetInteger(CVAR_SETTING("A11yTTS"), 0)) return; SpeechSynthesizer::Instance->Speak(titleCardText.c_str(), GetLanguageCode()); }); @@ -134,7 +134,7 @@ void RegisterOnPresentTitleCardHook() { void RegisterOnInterfaceUpdateHook() { GameInteractor::Instance->RegisterGameHook([]() { - if (!CVarGetInteger("gA11yTTS", 0)) return; + if (!CVarGetInteger(CVAR_SETTING("A11yTTS"), 0)) return; static uint32_t prevTimer = 0; static char ttsAnnounceBuf[32]; @@ -193,7 +193,7 @@ void RegisterOnInterfaceUpdateHook() { void RegisterOnKaleidoscopeUpdateHook() { GameInteractor::Instance->RegisterGameHook([](int16_t inDungeonScene) { - if (!CVarGetInteger("gA11yTTS", 0)) return; + if (!CVarGetInteger(CVAR_SETTING("A11yTTS"), 0)) return; static int16_t prevCursorIndex = 0; static uint16_t prevCursorSpecialPos = 0; @@ -550,14 +550,14 @@ void RegisterOnKaleidoscopeUpdateHook() { void RegisterOnUpdateMainMenuSelection() { GameInteractor::Instance->RegisterGameHook([]() { - if (!CVarGetInteger("gA11yTTS", 0)) return; + if (!CVarGetInteger(CVAR_SETTING("A11yTTS"), 0)) return; auto translation = GetParameritizedText("file1", TEXT_BANK_FILECHOOSE, nullptr); SpeechSynthesizer::Instance->Speak(translation.c_str(), GetLanguageCode()); }); GameInteractor::Instance->RegisterGameHook([](uint16_t optionIndex) { - if (!CVarGetInteger("gA11yTTS", 0)) return; + if (!CVarGetInteger(CVAR_SETTING("A11yTTS"), 0)) return; switch (optionIndex) { case FS_BTN_MAIN_FILE_1: { @@ -596,7 +596,7 @@ void RegisterOnUpdateMainMenuSelection() { }); GameInteractor::Instance->RegisterGameHook([](uint16_t optionIndex) { - if (!CVarGetInteger("gA11yTTS", 0)) return; + if (!CVarGetInteger(CVAR_SETTING("A11yTTS"), 0)) return; switch (optionIndex) { case FS_BTN_CONFIRM_YES: { @@ -615,7 +615,7 @@ void RegisterOnUpdateMainMenuSelection() { }); GameInteractor::Instance->RegisterGameHook([](uint16_t optionIndex) { - if (!CVarGetInteger("gA11yTTS", 0)) return; + if (!CVarGetInteger(CVAR_SETTING("A11yTTS"), 0)) return; switch (optionIndex) { case FS_BTN_COPY_FILE_1: { @@ -644,7 +644,7 @@ void RegisterOnUpdateMainMenuSelection() { }); GameInteractor::Instance->RegisterGameHook([](uint16_t optionIndex) { - if (!CVarGetInteger("gA11yTTS", 0)) return; + if (!CVarGetInteger(CVAR_SETTING("A11yTTS"), 0)) return; switch (optionIndex) { case FS_BTN_CONFIRM_YES: { @@ -663,7 +663,7 @@ void RegisterOnUpdateMainMenuSelection() { }); GameInteractor::Instance->RegisterGameHook([](uint16_t optionIndex) { - if (!CVarGetInteger("gA11yTTS", 0)) return; + if (!CVarGetInteger(CVAR_SETTING("A11yTTS"), 0)) return; switch (optionIndex) { case FS_BTN_ERASE_FILE_1: { @@ -692,7 +692,7 @@ void RegisterOnUpdateMainMenuSelection() { }); GameInteractor::Instance->RegisterGameHook([](uint16_t optionIndex) { - if (!CVarGetInteger("gA11yTTS", 0)) return; + if (!CVarGetInteger(CVAR_SETTING("A11yTTS"), 0)) return; switch (optionIndex) { case FS_BTN_CONFIRM_YES: { @@ -711,7 +711,7 @@ void RegisterOnUpdateMainMenuSelection() { }); GameInteractor::Instance->RegisterGameHook([](uint8_t optionIndex) { - if (!CVarGetInteger("gA11yTTS", 0)) return; + if (!CVarGetInteger(CVAR_SETTING("A11yTTS"), 0)) return; switch (optionIndex) { case FS_AUDIO_STEREO: { @@ -740,7 +740,7 @@ void RegisterOnUpdateMainMenuSelection() { }); GameInteractor::Instance->RegisterGameHook([](uint8_t optionIndex) { - if (!CVarGetInteger("gA11yTTS", 0)) return; + if (!CVarGetInteger(CVAR_SETTING("A11yTTS"), 0)) return; switch (optionIndex) { case FS_TARGET_SWITCH: { @@ -759,7 +759,7 @@ void RegisterOnUpdateMainMenuSelection() { }); GameInteractor::Instance->RegisterGameHook([](uint8_t optionIndex) { - if (!CVarGetInteger("gA11yTTS", 0)) return; + if (!CVarGetInteger(CVAR_SETTING("A11yTTS"), 0)) return; switch (optionIndex) { case LANGUAGE_ENG: { @@ -783,7 +783,7 @@ void RegisterOnUpdateMainMenuSelection() { }); GameInteractor::Instance->RegisterGameHook([](uint8_t questIndex) { - if (!CVarGetInteger("gA11yTTS", 0)) return; + if (!CVarGetInteger(CVAR_SETTING("A11yTTS"), 0)) return; switch (questIndex) { case QUEST_NORMAL: { @@ -812,7 +812,7 @@ void RegisterOnUpdateMainMenuSelection() { }); GameInteractor::Instance->RegisterGameHook([](uint8_t optionIndex, uint8_t optionValue) { - if (!CVarGetInteger("gA11yTTS", 0)) return; + if (!CVarGetInteger(CVAR_SETTING("A11yTTS"), 0)) return; auto optionName = BossRush_GetSettingName(optionIndex, gSaveContext.language); auto optionValueName = BossRush_GetSettingChoiceName(optionIndex, optionValue, gSaveContext.language); @@ -821,7 +821,7 @@ void RegisterOnUpdateMainMenuSelection() { }); GameInteractor::Instance->RegisterGameHook([](int16_t charCode) { - if (!CVarGetInteger("gA11yTTS", 0)) return; + if (!CVarGetInteger(CVAR_SETTING("A11yTTS"), 0)) return; char charVal[2]; std::string translation; @@ -958,7 +958,7 @@ std::string Message_TTS_Decode(uint8_t* sourceBuf, uint16_t startOfset, uint16_t void RegisterOnDialogMessageHook() { GameInteractor::Instance->RegisterGameHook([]() { - if (!CVarGetInteger("gA11yTTS", 0)) return; + if (!CVarGetInteger(CVAR_SETTING("A11yTTS"), 0)) return; MessageContext *msgCtx = &gPlayState->msgCtx; @@ -1030,7 +1030,7 @@ void RegisterOnDialogMessageHook() { void InitTTSBank() { std::string languageSuffix = "_eng.json"; - switch (CVarGetInteger("gLanguages", 0)) { + switch (CVarGetInteger(CVAR_SETTING("Languages"), 0)) { case LANGUAGE_FRA: languageSuffix = "_fra.json"; break; diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 2dd324fe864..0a0b83d4a02 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -432,7 +432,7 @@ OTRGlobals::~OTRGlobals() { } void OTRGlobals::ScaleImGui() { - float scale = imguiScaleOptionToValue[CVarGetInteger("gImGuiScale", defaultImGuiScale)]; + float scale = imguiScaleOptionToValue[CVarGetInteger(CVAR_SETTING("ImGuiScale"), defaultImGuiScale)]; float newScale = scale / previousImGuiScale; ImGui::GetStyle().ScaleAllSizes(newScale); ImGui::GetIO().FontGlobalScale = scale; @@ -467,14 +467,14 @@ bool OTRGlobals::HasOriginal() { uint32_t OTRGlobals::GetInterpolationFPS() { if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::DX11) { - return CVarGetInteger("gInterpolationFPS", 20); + return CVarGetInteger(CVAR_SETTING("InterpolationFPS"), 20); } - if (CVarGetInteger("gMatchRefreshRate", 0)) { + if (CVarGetInteger(CVAR_SETTING("MatchRefreshRate"), 0)) { return Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(); } - return std::min(Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(), CVarGetInteger("gInterpolationFPS", 20)); + return std::min(Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(), CVarGetInteger(CVAR_SETTING("InterpolationFPS"), 20)); } struct ExtensionEntry { @@ -1153,17 +1153,17 @@ extern "C" void InitOTR() { InitMods(); ActorDB::AddBuiltInCustomActors(); // #region SOH [Randomizer] TODO: Remove these and refactor spoiler file handling for randomizer - CVarClear("gRandomizerNewFileDropped"); - CVarClear("gRandomizerDroppedFile"); + CVarClear(CVAR_GENERAL("RandomizerNewFileDropped")); + CVarClear(CVAR_GENERAL("RandomizerDroppedFile")); // #endregion GameInteractor::Instance->RegisterGameHook(SoH_ProcessDroppedFiles); time_t now = time(NULL); tm *tm_now = localtime(&now); if (tm_now->tm_mon == 11 && tm_now->tm_mday >= 24 && tm_now->tm_mday <= 25) { - CVarRegisterInteger("gLetItSnow", 1); + CVarRegisterInteger(CVAR_GENERAL("LetItSnow"), 1); } else { - CVarClear("gLetItSnow"); + CVarClear(CVAR_GENERAL("LetItSnow")); } srand(now); @@ -1335,7 +1335,7 @@ extern "C" void Graph_StartFrame() { #if defined(_WIN32) || defined(__APPLE__) case KbScancode::LUS_KB_F9: { // Toggle TTS - CVarSetInteger("gA11yTTS", !CVarGetInteger("gA11yTTS", 0)); + CVarSetInteger(CVAR_SETTING("A11yTTS"), !CVarGetInteger(CVAR_SETTING("A11yTTS"), 0)); break; } #endif @@ -1405,7 +1405,7 @@ extern "C" void Graph_ProcessGfxCommands(Gfx* commands) { OTRGlobals::Instance->context->GetWindow()->SetTargetFps(fps); - int threshold = CVarGetInteger("gExtraLatencyThreshold", 80); + int threshold = CVarGetInteger(CVAR_SETTING("ExtraLatencyThreshold"), 80); OTRGlobals::Instance->context->GetWindow()->SetMaximumFrameLatency(threshold > 0 && target_fps >= threshold ? 2 : 1); RunCommands(commands, mtx_replacements); @@ -1502,7 +1502,7 @@ extern "C" uint32_t ResourceMgr_GetGameRegion(int index) { uint32_t IsSceneMasterQuest(s16 sceneNum) { uint32_t value = 0; - uint8_t mqMode = CVarGetInteger("gBetterDebugWarpScreenMQMode", WARP_MODE_OVERRIDE_OFF); + uint8_t mqMode = CVarGetInteger(CVAR_GENERAL("BetterDebugWarpScreenMQMode"), WARP_MODE_OVERRIDE_OFF); if (mqMode == WARP_MODE_OVERRIDE_MQ_AS_VANILLA) { return 1; } else if (mqMode == WARP_MODE_OVERRIDE_VANILLA_AS_MQ) { @@ -2131,11 +2131,11 @@ extern "C" uint32_t OTRGetCurrentHeight() { } Color_RGB8 GetColorForControllerLED() { - auto brightness = CVarGetFloat("gLedBrightness", 1.0f) / 1.0f; + auto brightness = CVarGetFloat(CVAR_SETTING("LEDBrightness"), 1.0f) / 1.0f; Color_RGB8 color = { 0, 0, 0 }; if (brightness > 0.0f) { - LEDColorSource source = static_cast(CVarGetInteger("gLedColorSource", LED_SOURCE_TUNIC_ORIGINAL)); - bool criticalOverride = CVarGetInteger("gLedCriticalOverride", 1); + LEDColorSource source = static_cast(CVarGetInteger(CVAR_SETTING("LEDColorSource"), LED_SOURCE_TUNIC_ORIGINAL)); + bool criticalOverride = CVarGetInteger(CVAR_SETTING("LEDCriticalOverride"), 1); if (gPlayState && (source == LED_SOURCE_TUNIC_ORIGINAL || source == LED_SOURCE_TUNIC_COSMETICS)) { switch (CUR_EQUIP_VALUE(EQUIP_TYPE_TUNIC)) { case EQUIP_VALUE_TUNIC_KOKIRI: @@ -2202,7 +2202,7 @@ Color_RGB8 GetColorForControllerLED() { } } if (source == LED_SOURCE_CUSTOM) { - color = CVarGetColor24("gLedPort1Color", { 255, 255, 255 }); + color = CVarGetColor24(CVAR_SETTING("LEDPort1Color"), { 255, 255, 255 }); } if (gPlayState && (criticalOverride || source == LED_SOURCE_HEALTH)) { if (HealthMeter_IsCritical()) { @@ -2462,7 +2462,7 @@ extern "C" int CustomMessage_RetrieveIfExists(PlayState* play) { if (player->getItemEntry.getItemId == RG_ICE_TRAP) { u16 iceTrapTextId = Random(0, NUM_ICE_TRAP_MESSAGES); messageEntry = CustomMessageManager::Instance->RetrieveMessage(Randomizer::IceTrapRandoMessageTableID, iceTrapTextId); - if (CVarGetInteger("gLetItSnow", 0)) { + if (CVarGetInteger(CVAR_GENERAL("LetItSnow"), 0)) { messageEntry = CustomMessageManager::Instance->RetrieveMessage(Randomizer::IceTrapRandoMessageTableID, NUM_ICE_TRAP_MESSAGES + 1); } } else if (player->getItemEntry.getItemId == RG_TRIFORCE_PIECE) { @@ -2724,8 +2724,8 @@ void SoH_ProcessDroppedFiles(std::string filePath) { // #region SOH [Randomizer] TODO: Refactor spoiler file handling for randomizer if (configJson.contains("version") && configJson.contains("finalSeed")) { - CVarSetString("gRandomizerDroppedFile", filePath.c_str()); - CVarSetInteger("gRandomizerNewFileDropped", 1); + CVarSetString(CVAR_GENERAL("RandomizerDroppedFile"), filePath.c_str()); + CVarSetInteger(CVAR_GENERAL("RandomizerNewFileDropped"), 1); return; } // #endregion diff --git a/soh/soh/SaveManager.cpp b/soh/soh/SaveManager.cpp index 484a9e1b170..0a96f9f1959 100644 --- a/soh/soh/SaveManager.cpp +++ b/soh/soh/SaveManager.cpp @@ -1166,7 +1166,7 @@ int SaveManager::GetSaveSectionID(std::string& sectionName) { void SaveManager::CreateDefaultGlobal() { gSaveContext.audioSetting = 0; gSaveContext.zTargetSetting = 0; - gSaveContext.language = CVarGetInteger("gLanguages", LANGUAGE_ENG); + gSaveContext.language = CVarGetInteger(CVAR_SETTING("Languages"), LANGUAGE_ENG); SaveGlobal(); } @@ -2546,7 +2546,7 @@ void SaveManager::ConvertFromUnversioned() { gSaveContext.zTargetSetting = data[SRAM_HEADER_ZTARGET] & 1; gSaveContext.language = data[SRAM_HEADER_LANGUAGE]; if (gSaveContext.language >= LANGUAGE_MAX) { - gSaveContext.language = CVarGetInteger("gLanguages", LANGUAGE_ENG); + gSaveContext.language = CVarGetInteger(CVAR_SETTING("Languages"), LANGUAGE_ENG); } SaveGlobal(); diff --git a/soh/soh/SohGui.cpp b/soh/soh/SohGui.cpp index e7eb998dd63..7fde4f351b0 100644 --- a/soh/soh/SohGui.cpp +++ b/soh/soh/SohGui.cpp @@ -201,7 +201,7 @@ namespace SohGui { gui->AddGuiWindow(mRandomizerSettingsWindow); mAdvancedResolutionSettingsWindow = std::make_shared(CVAR_WINDOW("AdvancedResolutionEditor"), "Advanced Resolution Settings"); gui->AddGuiWindow(mAdvancedResolutionSettingsWindow); - mModalWindow = std::make_shared("gOpenWindows.modalWindowEnabled", "Modal Window"); + mModalWindow = std::make_shared(CVAR_WINDOW("ModalWindow"), "Modal Window"); gui->AddGuiWindow(mModalWindow); mModalWindow->Show(); } diff --git a/soh/soh/SohMenuBar.cpp b/soh/soh/SohMenuBar.cpp index fbcf2496a4f..b847988dc9e 100644 --- a/soh/soh/SohMenuBar.cpp +++ b/soh/soh/SohMenuBar.cpp @@ -182,18 +182,18 @@ void DrawSettingsMenu() { if (ImGui::BeginMenu("Settings")) { if (ImGui::BeginMenu("Audio")) { - UIWidgets::PaddedEnhancementSliderFloat("Master Volume: %.1f %%", "##Master_Vol", "gGameMasterVolume", 0.0f, 1.0f, "", 1.0f, true, true, false, true); - if (UIWidgets::PaddedEnhancementSliderFloat("Main Music Volume: %.1f %%", "##Main_Music_Vol", "gMainMusicVolume", 0.0f, 1.0f, "", 1.0f, true, true, false, true)) { - Audio_SetGameVolume(SEQ_PLAYER_BGM_MAIN, CVarGetFloat("gMainMusicVolume", 1.0f)); + UIWidgets::PaddedEnhancementSliderFloat("Master Volume: %.1f %%", "##Master_Vol", CVAR_SETTING("Volume.Master"), 0.0f, 1.0f, "", 1.0f, true, true, false, true); + if (UIWidgets::PaddedEnhancementSliderFloat("Main Music Volume: %.1f %%", "##Main_Music_Vol", CVAR_SETTING("Volume.MainMusic"), 0.0f, 1.0f, "", 1.0f, true, true, false, true)) { + Audio_SetGameVolume(SEQ_PLAYER_BGM_MAIN, CVarGetFloat(CVAR_SETTING("Volume.MainMusic"), 1.0f)); } - if (UIWidgets::PaddedEnhancementSliderFloat("Sub Music Volume: %.1f %%", "##Sub_Music_Vol", "gSubMusicVolume", 0.0f, 1.0f, "", 1.0f, true, true, false, true)) { - Audio_SetGameVolume(SEQ_PLAYER_BGM_SUB, CVarGetFloat("gSubMusicVolume", 1.0f)); + if (UIWidgets::PaddedEnhancementSliderFloat("Sub Music Volume: %.1f %%", "##Sub_Music_Vol", CVAR_SETTING("Volume.SubMusic"), 0.0f, 1.0f, "", 1.0f, true, true, false, true)) { + Audio_SetGameVolume(SEQ_PLAYER_BGM_SUB, CVarGetFloat(CVAR_SETTING("Volume.SubMusic"), 1.0f)); } - if (UIWidgets::PaddedEnhancementSliderFloat("Sound Effects Volume: %.1f %%", "##Sound_Effect_Vol", "gSFXMusicVolume", 0.0f, 1.0f, "", 1.0f, true, true, false, true)) { - Audio_SetGameVolume(SEQ_PLAYER_SFX, CVarGetFloat("gSFXMusicVolume", 1.0f)); + if (UIWidgets::PaddedEnhancementSliderFloat("Sound Effects Volume: %.1f %%", "##Sound_Effect_Vol", CVAR_SETTING("Volume.SFX"), 0.0f, 1.0f, "", 1.0f, true, true, false, true)) { + Audio_SetGameVolume(SEQ_PLAYER_SFX, CVarGetFloat(CVAR_SETTING("Volume.SFX"), 1.0f)); } - if (UIWidgets::PaddedEnhancementSliderFloat("Fanfare Volume: %.1f %%", "##Fanfare_Vol", "gFanfareVolume", 0.0f, 1.0f, "", 1.0f, true, true, false, true)) { - Audio_SetGameVolume(SEQ_PLAYER_FANFARE, CVarGetFloat("gFanfareVolume", 1.0f)); + if (UIWidgets::PaddedEnhancementSliderFloat("Fanfare Volume: %.1f %%", "##Fanfare_Vol", CVAR_SETTING("Volume.Fanfare"), 0.0f, 1.0f, "", 1.0f, true, true, false, true)) { + Audio_SetGameVolume(SEQ_PLAYER_FANFARE, CVarGetFloat(CVAR_SETTING("Volume.Fanfare"), 1.0f)); } static std::unordered_map audioBackendNames = { @@ -270,8 +270,8 @@ void DrawSettingsMenu() { if (ImGui::BeginMenu("Graphics")) { #ifndef __APPLE__ - const bool disabled_resolutionSlider = CVarGetInteger("gAdvancedResolution.VerticalResolutionToggle", 0) && - CVarGetInteger("gAdvancedResolution.Enabled", 0); + const bool disabled_resolutionSlider = CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".VerticalResolutionToggle", 0) && + CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".Enabled", 0); if (UIWidgets::EnhancementSliderFloat("Internal Resolution: %.1f %%", "##IMul", CVAR_INTERNAL_RESOLUTION, 0.5f, 2.0f, "", 1.0f, true, true, disabled_resolutionSlider)) { Ship::Context::GetInstance()->GetWindow()->SetResolutionMultiplier(CVarGetFloat(CVAR_INTERNAL_RESOLUTION, 1)); @@ -344,7 +344,7 @@ void DrawSettingsMenu() { fpsSlider = 3; } } - if (CVarGetInteger("gMatchRefreshRate", 0)) { + if (CVarGetInteger(CVAR_SETTING("MatchRefreshRate"), 0)) { UIWidgets::DisableComponent(ImGui::GetStyle().Alpha * 0.5f); } @@ -366,7 +366,7 @@ void DrawSettingsMenu() { fpsSlider++; } - if (CVarGetInteger("gMatchRefreshRate", 0)) { + if (CVarGetInteger(CVAR_SETTING("MatchRefreshRate"), 0)) { UIWidgets::ReEnableComponent(""); } if (fpsSlider > 3) { @@ -382,14 +382,14 @@ void DrawSettingsMenu() { } else if (fpsSlider == 3) { currentFps = 60; } - CVarSetInteger("gInterpolationFPS", currentFps); + CVarSetInteger(CVAR_SETTING("InterpolationFPS"), currentFps); Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); #else bool matchingRefreshRate = - CVarGetInteger("gMatchRefreshRate", 0) && Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() != Ship::WindowBackend::DX11; + CVarGetInteger(CVAR_SETTING("MatchRefreshRate"), 0) && Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() != Ship::WindowBackend::DX11; UIWidgets::PaddedEnhancementSliderInt( (currentFps == 20) ? "Frame Rate: Original (20 fps)" : "Frame Rate: %d fps", - "##FPSInterpolation", "gInterpolationFPS", minFps, maxFps, "", 20, true, true, false, matchingRefreshRate); + "##FPSInterpolation", CVAR_SETTING("InterpolationFPS"), minFps, maxFps, "", 20, true, true, false, matchingRefreshRate); #endif if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::DX11) { UIWidgets::Tooltip( @@ -411,18 +411,18 @@ void DrawSettingsMenu() { if (ImGui::Button("Match Frame Rate to Refresh Rate")) { int hz = Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(); if (hz >= 20 && hz <= 360) { - CVarSetInteger("gInterpolationFPS", hz); + CVarSetInteger(CVAR_SETTING("InterpolationFPS"), hz); Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } } } else { - UIWidgets::PaddedEnhancementCheckbox("Match Frame Rate to Refresh Rate", "gMatchRefreshRate", true, false); + UIWidgets::PaddedEnhancementCheckbox("Match Frame Rate to Refresh Rate", CVAR_SETTING("MatchRefreshRate"), true, false); } UIWidgets::Tooltip("Matches interpolation value to the game window's current refresh rate."); if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::DX11) { - UIWidgets::PaddedEnhancementSliderInt(CVarGetInteger("gExtraLatencyThreshold", 80) == 0 ? "Jitter fix: Off" : "Jitter fix: >= %d FPS", - "##ExtraLatencyThreshold", "gExtraLatencyThreshold", 0, 360, "", 80, true, true, false); + UIWidgets::PaddedEnhancementSliderInt(CVarGetInteger(CVAR_SETTING("ExtraLatencyThreshold"), 80) == 0 ? "Jitter fix: Off" : "Jitter fix: >= %d FPS", + "##ExtraLatencyThreshold", CVAR_SETTING("ExtraLatencyThreshold"), 0, 360, "", 80, true, true, false); UIWidgets::Tooltip( "(For DirectX backend only)\n\n" "When Interpolation FPS (Frame Rate) setting is at least this threshold, add one frame of delay (e.g. 16.6 ms for 60 FPS) in order to avoid jitter." @@ -435,7 +435,7 @@ void DrawSettingsMenu() { ImGui::Text("ImGui Menu Scale"); ImGui::SameLine(); ImGui::TextColored({ 0.85f, 0.35f, 0.0f, 1.0f }, "(Experimental)"); - if (UIWidgets::EnhancementCombobox("gImGuiScale", imguiScaleOptions, 1)) { + if (UIWidgets::EnhancementCombobox(CVAR_SETTING("ImGuiScale"), imguiScaleOptions, 1)) { OTRGlobals::Instance->ScaleImGui(); } UIWidgets::Tooltip("Changes the scaling of the ImGui menu elements."); @@ -511,14 +511,14 @@ void DrawSettingsMenu() { UIWidgets::Spacer(0); if (ImGui::BeginMenu("Languages")) { - UIWidgets::PaddedEnhancementCheckbox("Translate Title Screen", "gTitleScreenTranslation"); - if (UIWidgets::EnhancementRadioButton("English", "gLanguages", LANGUAGE_ENG)) { + UIWidgets::PaddedEnhancementCheckbox("Translate Title Screen", CVAR_SETTING("TitleScreenTranslation")); + if (UIWidgets::EnhancementRadioButton("English", CVAR_SETTING("Languages"), LANGUAGE_ENG)) { GameInteractor::Instance->ExecuteHooks(); } - if (UIWidgets::EnhancementRadioButton("German", "gLanguages", LANGUAGE_GER)) { + if (UIWidgets::EnhancementRadioButton("German", CVAR_SETTING("Languages"), LANGUAGE_GER)) { GameInteractor::Instance->ExecuteHooks(); } - if (UIWidgets::EnhancementRadioButton("French", "gLanguages", LANGUAGE_FRA)) { + if (UIWidgets::EnhancementRadioButton("French", CVAR_SETTING("Languages"), LANGUAGE_FRA)) { GameInteractor::Instance->ExecuteHooks(); } ImGui::EndMenu(); @@ -528,10 +528,10 @@ void DrawSettingsMenu() { if (ImGui::BeginMenu("Accessibility")) { #if defined(_WIN32) || defined(__APPLE__) - UIWidgets::PaddedEnhancementCheckbox("Text to Speech", "gA11yTTS"); + UIWidgets::PaddedEnhancementCheckbox("Text to Speech", CVAR_SETTING("A11yTTS")); UIWidgets::Tooltip("Enables text to speech for in game dialog"); #endif - UIWidgets::PaddedEnhancementCheckbox("Disable Idle Camera Re-Centering", "gA11yDisableIdleCam"); + UIWidgets::PaddedEnhancementCheckbox("Disable Idle Camera Re-Centering", CVAR_SETTING("A11yDisableIdleCam")); UIWidgets::Tooltip("Disables the automatic re-centering of the camera when idle."); ImGui::EndMenu(); @@ -1763,7 +1763,8 @@ void DrawRemoteControlMenu() { ImGui::BeginDisabled(GameInteractor::Instance->isRemoteInteractorEnabled); ImGui::Text("Remote Interaction Scheme"); if (UIWidgets::EnhancementCombobox(CVAR_REMOTE("Scheme"), remoteOptions, GI_SCHEME_SAIL)) { - switch (CVarGetInteger(CVAR_REMOTE("Scheme"), GI_SCHEME_SAIL)) { + auto scheme = CVarGetInteger(CVAR_REMOTE("Scheme"), GI_SCHEME_SAIL); + switch (scheme) { case GI_SCHEME_SAIL: case GI_SCHEME_CROWD_CONTROL: CVarSetString(CVAR_REMOTE("IP"), "127.0.0.1"); @@ -1827,7 +1828,8 @@ void DrawRemoteControlMenu() { const char* buttonLabel = GameInteractor::Instance->isRemoteInteractorEnabled ? "Disable" : "Enable"; if (ImGui::Button(buttonLabel, ImVec2(-1.0f, 0.0f))) { if (GameInteractor::Instance->isRemoteInteractorEnabled) { - CVarSetInteger(CVAR_REMOTE("Enabled"), 0); + CVarClear(CVAR_REMOTE("Enabled")); + CVarClear(CVAR_REMOTE("CrowdControl")); Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); switch (CVarGetInteger(CVAR_REMOTE("Scheme"), GI_SCHEME_SAIL)) { case GI_SCHEME_SAIL: diff --git a/soh/soh/UIWidgets.cpp b/soh/soh/UIWidgets.cpp index bd0843e960b..d1bf0967ae5 100644 --- a/soh/soh/UIWidgets.cpp +++ b/soh/soh/UIWidgets.cpp @@ -486,14 +486,14 @@ namespace UIWidgets { bool EnhancementRadioButton(const char* text, const char* cvarName, int id) { /*Usage : - EnhancementRadioButton("My Visible Name","gMyCVarName", MyID); + EnhancementRadioButton("My Visible Name",CVAR_GROUP("MyCVarName"), MyID); First arg is the visible name of the Radio button Second is the cvar name where MyID will be saved. Note: the CVar name should be the same to each Buddies. Example : - EnhancementRadioButton("English", "gLanguages", LANGUAGE_ENG); - EnhancementRadioButton("German", "gLanguages", LANGUAGE_GER); - EnhancementRadioButton("French", "gLanguages", LANGUAGE_FRA); + EnhancementRadioButton("English", CVAR_SETTING("Languages"), LANGUAGE_ENG); + EnhancementRadioButton("German", CVAR_SETTING("Languages"), LANGUAGE_GER); + EnhancementRadioButton("French", CVAR_SETTING("Languages"), LANGUAGE_FRA); */ std::string make_invisible = "##" + std::string(text) + std::string(cvarName); diff --git a/soh/src/code/audioMgr.c b/soh/src/code/audioMgr.c index d9b215d07b9..2a675220675 100644 --- a/soh/src/code/audioMgr.c +++ b/soh/src/code/audioMgr.c @@ -109,10 +109,10 @@ void AudioMgr_Init(AudioMgr* audioMgr, void* stack, OSPri pri, OSId id, SchedCon Audio_InitSound(); osSendMesgPtr(&audioMgr->unk_C8, NULL, OS_MESG_BLOCK); - Audio_SetGameVolume(SEQ_PLAYER_BGM_MAIN, CVarGetFloat("gMainMusicVolume", 1.0f)); - Audio_SetGameVolume(SEQ_PLAYER_BGM_SUB, CVarGetFloat("gSubMusicVolume", 1.0f)); - Audio_SetGameVolume(SEQ_PLAYER_FANFARE, CVarGetFloat("gFanfareVolume", 1.0f)); - Audio_SetGameVolume(SEQ_PLAYER_SFX, CVarGetFloat("gSFXMusicVolume", 1.0f)); + Audio_SetGameVolume(SEQ_PLAYER_BGM_MAIN, CVarGetFloat(CVAR_SETTING("Volume.MainMusic"), 1.0f)); + Audio_SetGameVolume(SEQ_PLAYER_BGM_SUB, CVarGetFloat(CVAR_SETTING("Volume.SubMusic"), 1.0f)); + Audio_SetGameVolume(SEQ_PLAYER_FANFARE, CVarGetFloat(CVAR_SETTING("Volume.Fanfare"), 1.0f)); + Audio_SetGameVolume(SEQ_PLAYER_SFX, CVarGetFloat(CVAR_SETTING("Volume.SFX"), 1.0f)); // Removed due to crash //IrqMgr_AddClient(audioMgr->irqMgr, &irqClient, &audioMgr->unk_74); diff --git a/soh/src/code/audio_playback.c b/soh/src/code/audio_playback.c index 66f236c4392..39be0c3a75f 100644 --- a/soh/src/code/audio_playback.c +++ b/soh/src/code/audio_playback.c @@ -94,7 +94,7 @@ void Audio_InitNoteSub(Note* note, NoteSubEu* sub, NoteSubAttributes* attrs) { vel = 0.0f > vel ? 0.0f : vel; vel = 1.0f < vel ? 1.0f : vel; - float master_vol = CVarGetFloat("gGameMasterVolume", 1.0f); + float master_vol = CVarGetFloat(CVAR_SETTING("Volume.Master"), 1.0f); sub->targetVolLeft = (s32)((vel * volLeft) * (0x1000 - 0.001f)) * master_vol; sub->targetVolRight = (s32)((vel * volRight) * (0x1000 - 0.001f)) * master_vol; @@ -120,7 +120,7 @@ void Audio_NoteSetResamplingRate(NoteSubEu* noteSubEu, f32 resamplingRateInput) } else { noteSubEu->bitField1.hasTwoParts = true; if (3.99996f < resamplingRateInput) { - if (CVarGetInteger("gExperimentalOctaveDrop", 0)) { + if (CVarGetInteger(CVAR_AUDIO("ExperimentalOctaveDrop"), 0)) { resamplingRate = resamplingRateInput * 0.25; } else { resamplingRate = 1.99998f; diff --git a/soh/src/code/audio_synthesis.c b/soh/src/code/audio_synthesis.c index f2c52663037..7044a48c464 100644 --- a/soh/src/code/audio_synthesis.c +++ b/soh/src/code/audio_synthesis.c @@ -653,7 +653,7 @@ Acmd* AudioSynth_DoOneAudioUpdate(s16* aiBuf, s32 aiBufLen, Acmd* cmd, s32 updat } updateIndex = aiBufLen * 2; - if (CVarGetInteger("gMirroredWorld", 0)) { + if (CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0)) { aInterleave(cmd++, DMEM_TEMP, DMEM_RIGHT_CH, DMEM_LEFT_CH, updateIndex); } else { aInterleave(cmd++, DMEM_TEMP, DMEM_LEFT_CH, DMEM_RIGHT_CH, updateIndex); diff --git a/soh/src/code/code_800EC960.c b/soh/src/code/code_800EC960.c index 95387b44827..756dcaa89ad 100644 --- a/soh/src/code/code_800EC960.c +++ b/soh/src/code/code_800EC960.c @@ -1259,11 +1259,11 @@ void Audio_PlayFanfare_Rando(GetItemEntry getItem); // Function originally not called, so repurposing for control mapping void Audio_OcaUpdateBtnMap(bool customControls, bool dpad, bool rStick) { if (customControls) { - sOcarinaD5BtnMap = CVarGetInteger("gOcarinaD5BtnMap", BTN_CUP); - sOcarinaB4BtnMap = CVarGetInteger("gOcarinaB4BtnMap", BTN_CLEFT); - sOcarinaA4BtnMap = CVarGetInteger("gOcarinaA4BtnMap", BTN_CRIGHT); - sOcarinaF4BtnMap = CVarGetInteger("gOcarinaF4BtnMap", BTN_CDOWN); - sOcarinaD4BtnMap = CVarGetInteger("gOcarinaD4BtnMap", BTN_A); + sOcarinaD5BtnMap = CVarGetInteger(CVAR_SETTING("CustomOcarina.D5Button"), BTN_CUP); + sOcarinaB4BtnMap = CVarGetInteger(CVAR_SETTING("CustomOcarina.B4Button"), BTN_CLEFT); + sOcarinaA4BtnMap = CVarGetInteger(CVAR_SETTING("CustomOcarina.A4Button"), BTN_CRIGHT); + sOcarinaF4BtnMap = CVarGetInteger(CVAR_SETTING("CustomOcarina.F4Button"), BTN_CDOWN); + sOcarinaD4BtnMap = CVarGetInteger(CVAR_SETTING("CustomOcarina.D4Button"), BTN_A); } else { sOcarinaD5BtnMap = BTN_CUP; sOcarinaB4BtnMap = BTN_CLEFT; @@ -1540,8 +1540,8 @@ void func_800ED200(void) { u8 k; u32 disableSongBtnMap; - if (CVarGetInteger("gCustomOcarinaControls", 0)) { - disableSongBtnMap = CVarGetInteger("gOcarinaDisableBtnMap", BTN_L); + if (CVarGetInteger(CVAR_SETTING("CustomOcarina.Enabled"), 0)) { + disableSongBtnMap = CVarGetInteger(CVAR_SETTING("CustomOcarina.DisableButton"), BTN_L); } else { disableSongBtnMap = BTN_L; } @@ -1602,9 +1602,9 @@ void func_800ED200(void) { void func_800ED458(s32 arg0) { u32 phi_v1_2; - bool customControls = CVarGetInteger("gCustomOcarinaControls", 0); - bool dpad = CVarGetInteger("gDpadOcarina", 0); - bool rStick = CVarGetInteger("gRStickOcarina", 0); + bool customControls = CVarGetInteger(CVAR_SETTING("CustomOcarina.Enabled"), 0); + bool dpad = CVarGetInteger(CVAR_SETTING("OcarinaControl.Dpad"), 0); + bool rStick = CVarGetInteger(CVAR_SETTING("OcarinaControl.RStick"), 0); if (D_80130F3C != 0 && sOcarinaDropInputTimer != 0) { sOcarinaDropInputTimer--; @@ -1650,7 +1650,7 @@ void func_800ED458(s32 arg0) { u32 noteSharpBtnMap; if (customControls) { - noteSharpBtnMap = CVarGetInteger("gOcarinaSharpBtnMap", BTN_R); + noteSharpBtnMap = CVarGetInteger(CVAR_SETTING("CustomOcarina.SharpButton"), BTN_R); } else { noteSharpBtnMap = BTN_R; } @@ -1661,7 +1661,7 @@ void func_800ED458(s32 arg0) { u32 noteFlatBtnMap; if (customControls) { - noteFlatBtnMap = CVarGetInteger("gOcarinaFlatBtnMap", BTN_Z); + noteFlatBtnMap = CVarGetInteger(CVAR_SETTING("CustomOcarina.FlatButton"), BTN_Z); } else { noteFlatBtnMap = BTN_Z; } diff --git a/soh/src/code/game.c b/soh/src/code/game.c index 8d97177fd2a..f0988c7c39d 100644 --- a/soh/src/code/game.c +++ b/soh/src/code/game.c @@ -329,7 +329,7 @@ void GameState_Update(GameState* gameState) { func_800C49F4(gfxCtx); } - gSaveContext.language = CVarGetInteger("gLanguages", LANGUAGE_ENG); + gSaveContext.language = CVarGetInteger(CVAR_SETTING("Languages"), LANGUAGE_ENG); GameInteractor_ExecuteOnGameFrameUpdate(); gameState->frames++; diff --git a/soh/src/code/gfxprint.c b/soh/src/code/gfxprint.c index 9caad46a8f2..1717e46b3cc 100644 --- a/soh/src/code/gfxprint.c +++ b/soh/src/code/gfxprint.c @@ -214,7 +214,7 @@ void GfxPrint_SetColor(GfxPrint* this, u32 r, u32 g, u32 b, u32 a) { } void GfxPrint_SetPosPx(GfxPrint* this, s32 x, s32 y) { - this->posX = this->baseX + (x * 4) + CVarGetInteger("gGfxPrintCharStartOffset", 0); + this->posX = this->baseX + (x * 4) + CVarGetInteger(CVAR_DEVELOPER_TOOLS("GfxPrintChar.StartOffset"), 0); this->posY = this->baseY + (y * 4); } @@ -272,7 +272,7 @@ void GfxPrint_PrintCharImpl(GfxPrint* this, u8 c) { (u16)(c >> 3) * 256, 1 << 10, 1 << 10); } - this->posX += CVarGetInteger("gGfxPrintCharSpacing", 32); + this->posX += CVarGetInteger(CVAR_DEVELOPER_TOOLS("GfxPrintChar.Spacing"), 32); } void GfxPrint_PrintStringWithSize(GfxPrint* this, const void* buffer, u32 charSize, u32 charCount) { diff --git a/soh/src/code/graph.c b/soh/src/code/graph.c index d72a302777f..f5d620e72eb 100644 --- a/soh/src/code/graph.c +++ b/soh/src/code/graph.c @@ -290,7 +290,7 @@ void Graph_Update(GraphicsContext* gfxCtx, GameState* gameState) { OPEN_DISPS(gfxCtx); - if (CVarGetInteger("gValueViewer.EnablePrinting", 0)) { + if (CVarGetInteger(CVAR_DEVELOPER_TOOLS("ValueViewerEnablePrinting"), 0)) { Gfx* gfx; Gfx* polyOpa; GfxPrint printer; diff --git a/soh/src/code/padmgr.c b/soh/src/code/padmgr.c index 3315a9fe8c6..57dd2c6f706 100644 --- a/soh/src/code/padmgr.c +++ b/soh/src/code/padmgr.c @@ -287,8 +287,8 @@ void PadMgr_ProcessInputs(PadMgr* padMgr) { // When 3 frames are left on easy pause buffer, re-apply the last held inputs to the prev inputs // to compute the pressed difference. This makes it so previously held inputs are continued as "held", // but new inputs when unpausing are "pressed" out of the pause menu. - if (CVarGetInteger("gCheatEasyPauseBufferTimer", 0) == 3) { - input->prev.button = CVarGetInteger("gCheatEasyPauseBufferLastInputs", 0); + if (CVarGetInteger(CVAR_GENERAL("CheatEasyPauseBufferTimer"), 0) == 3) { + input->prev.button = CVarGetInteger(CVAR_GENERAL("CheatEasyPauseBufferLastInputs"), 0); } buttonDiff = input->prev.button ^ input->cur.button; diff --git a/soh/src/code/z_actor.c b/soh/src/code/z_actor.c index 4242b9ecc2a..9eac795593d 100644 --- a/soh/src/code/z_actor.c +++ b/soh/src/code/z_actor.c @@ -1082,10 +1082,10 @@ void TitleCard_InitPlaceName(PlayState* play, TitleCardContext* titleCtx, void* void TitleCard_Update(PlayState* play, TitleCardContext* titleCtx) { const Color_RGB8 TitleCard_Colors_ori = {255,255,255}; Color_RGB8 TitleCard_Colors = {255,255,255}; - if (titleCtx->isBossCard && CVarGetInteger("gHudColors", 1) == 2) {//Bosses cards. - TitleCard_Colors = CVarGetColor24("gCCTC_B_U_Prim", TitleCard_Colors_ori); - } else if (!titleCtx->isBossCard && CVarGetInteger("gHudColors", 1) == 2) { - TitleCard_Colors = CVarGetColor24("gCCTC_OW_U_Prim", TitleCard_Colors_ori); + if (titleCtx->isBossCard && CVarGetInteger(CVAR_COSMETIC("HUD.TitleCard.Boss.Changed"), 1) == 2) { + TitleCard_Colors = CVarGetColor24(CVAR_COSMETIC("HUD.TitleCard.Boss.Value"), TitleCard_Colors_ori); + } else if (!titleCtx->isBossCard && CVarGetInteger(CVAR_COSMETIC("HUD.TitleCard.Map.Changed"), 1) == 2) { + TitleCard_Colors = CVarGetColor24(CVAR_COSMETIC("HUD.TitleCard.Map.Value"), TitleCard_Colors_ori); } else { TitleCard_Colors = TitleCard_Colors_ori; } @@ -1129,10 +1129,10 @@ void TitleCard_Draw(PlayState* play, TitleCardContext* titleCtx) { if (TitleCard_PosType_Checker != 0) { TitleCard_PosY = TitleCard_PosY_Modifier; if (TitleCard_PosType_Checker == 1) {//Anchor Left - if (TitleCard_Margin_Checker != 0) {TitleCard_MarginX = CVarGetInteger("gHUDMargin_L", 0)*-1;}; + if (TitleCard_Margin_Checker != 0) {TitleCard_MarginX = CVarGetInteger(CVAR_COSMETIC("HUD.Margin.L"), 0)*-1;}; TitleCard_PosX = OTRGetDimensionFromLeftEdge(TitleCard_PosX_Modifier+TitleCard_MarginX)-11; } else if (TitleCard_PosType_Checker == 2) {//Anchor Right - if (TitleCard_Margin_Checker != 0) {TitleCard_MarginX = CVarGetInteger("gHUDMargin_R", 0);}; + if (TitleCard_Margin_Checker != 0) {TitleCard_MarginX = CVarGetInteger(CVAR_COSMETIC("HUD.Margin.R"), 0);}; TitleCard_PosX = OTRGetDimensionFromRightEdge(TitleCard_PosX_Modifier+TitleCard_MarginX); } else if (TitleCard_PosType_Checker == 3) {//Anchor None TitleCard_PosX = TitleCard_PosX_Modifier; @@ -2214,7 +2214,7 @@ void Player_PlaySfx(Actor* actor, u16 sfxId) { if (actor->id != ACTOR_PLAYER || sfxId < NA_SE_VO_LI_SWORD_N || sfxId > NA_SE_VO_LI_ELECTRIC_SHOCK_LV_KID) { Audio_PlaySoundGeneral(sfxId, &actor->projectedPos, 4, &D_801333E0 , &D_801333E0, &D_801333E8); } else { - freqMultiplier = CVarGetFloat("gLinkVoiceFreqMultiplier", 1.0); + freqMultiplier = CVarGetFloat(CVAR_AUDIO("LinkVoiceFreqMultiplier"), 1.0); if (freqMultiplier <= 0) { freqMultiplier = 1; } @@ -2911,7 +2911,7 @@ s32 func_800314D4(PlayState* play, Actor* actor, Vec3f* arg2, f32 arg3) { // #region SoH [Widescreen support] // Doors will cull quite noticeably on wider screens. For these actors the zone is increased f32 limit = 1.0f; - if (((actor->id == ACTOR_EN_DOOR) || (actor->id == ACTOR_DOOR_SHUTTER)) && CVarGetInteger("gIncreaseDoorUncullZones", 1)) { + if (((actor->id == ACTOR_EN_DOOR) || (actor->id == ACTOR_DOOR_SHUTTER)) && CVarGetInteger(CVAR_GENERAL("IncreaseDoorUncullZones"), 1)) { limit = 2.0f; } diff --git a/soh/src/code/z_camera.c b/soh/src/code/z_camera.c index 03f8b4b7ad7..c9bd14ff012 100644 --- a/soh/src/code/z_camera.c +++ b/soh/src/code/z_camera.c @@ -1485,12 +1485,12 @@ s32 Camera_Free(Camera* camera) { camera->animState = 0; - f32 newCamX = -D_8015BD7C->state.input[0].cur.right_stick_x * 10.0f * (CVarGetFloat("gThirdPersonCameraSensitivityX", 1.0f)); - f32 newCamY = D_8015BD7C->state.input[0].cur.right_stick_y * 10.0f * (CVarGetFloat("gThirdPersonCameraSensitivityY", 1.0f)); - bool invertXAxis = (CVarGetInteger("gInvertXAxis", 0) && !CVarGetInteger("gMirroredWorld", 0)) || (!CVarGetInteger("gInvertXAxis", 0) && CVarGetInteger("gMirroredWorld", 0)); + f32 newCamX = -D_8015BD7C->state.input[0].cur.right_stick_x * 10.0f * (CVarGetFloat(CVAR_SETTING("FreeLook.CameraSensitivity.X"), 1.0f)); + f32 newCamY = D_8015BD7C->state.input[0].cur.right_stick_y * 10.0f * (CVarGetFloat(CVAR_SETTING("FreeLook.CameraSensitivity.Y"), 1.0f)); + bool invertXAxis = (CVarGetInteger(CVAR_SETTING("FreeLook.InvertXAxis"), 0) && !CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0)) || (!CVarGetInteger(CVAR_SETTING("FreeLook.InvertXAxis"), 0) && CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0)); camera->play->camX += newCamX * (invertXAxis ? -1 : 1); - camera->play->camY += newCamY * (CVarGetInteger("gInvertYAxis", 1) ? 1 : -1); + camera->play->camY += newCamY * (CVarGetInteger(CVAR_SETTING("FreeLook.InvertYAxis"), 1) ? 1 : -1); if (camera->play->camY > 0x32A4) { camera->play->camY = 0x32A4; @@ -1499,8 +1499,8 @@ s32 Camera_Free(Camera* camera) { camera->play->camY = -0x228C; } - f32 distTarget = CVarGetInteger("gFreeCameraDistMax", para1->distTarget); - f32 speedScaler = CVarGetInteger("gFreeCameraTransitionSpeed", 25); + f32 distTarget = CVarGetInteger(CVAR_SETTING("FreeLook.MaxCameraDistance"), para1->distTarget); + f32 speedScaler = CVarGetInteger(CVAR_SETTING("FreeLook.TransitionSpeed"), 25); f32 distDiff = ABS(distTarget - camera->dist); if (distDiff > 0) camera->dist = Camera_LERPCeilF(distTarget, camera->dist, speedScaler / (distDiff + speedScaler), 0.0f); @@ -1524,7 +1524,7 @@ s32 Camera_Free(Camera* camera) { } s32 Camera_Normal1(Camera* camera) { - if (CVarGetInteger("gFreeCamera", 0) && SetCameraManual(camera) == 1) { + if (CVarGetInteger(CVAR_SETTING("FreeLook.Enabled"), 0) && SetCameraManual(camera) == 1) { Camera_Free(camera); return 1; } @@ -1679,7 +1679,7 @@ s32 Camera_Normal1(Camera* camera) { if (anim->startSwingTimer <= 0) { // idle camera re-center - if (CVarGetInteger("gA11yDisableIdleCam", 0)) { + if (CVarGetInteger(CVAR_SETTING("A11yDisableIdleCam"), 0)) { return 1; } eyeAdjustment.pitch = atEyeNextGeo.pitch; @@ -1770,7 +1770,7 @@ s32 Camera_Normal1(Camera* camera) { } s32 Camera_Normal2(Camera* camera) { - if (CVarGetInteger("gFreeCamera", 0) && SetCameraManual(camera) == 1) { + if (CVarGetInteger(CVAR_SETTING("FreeLook.Enabled"), 0) && SetCameraManual(camera) == 1) { Camera_Free(camera); return 1; } @@ -1941,7 +1941,7 @@ s32 Camera_Normal2(Camera* camera) { // riding epona s32 Camera_Normal3(Camera* camera) { - if (CVarGetInteger("gFreeCamera", 0) && SetCameraManual(camera) == 1) { + if (CVarGetInteger(CVAR_SETTING("FreeLook.Enabled"), 0) && SetCameraManual(camera) == 1) { Camera_Free(camera); return 1; } @@ -2305,7 +2305,7 @@ s32 Camera_Parallel0(Camera* camera) { * Generic jump, jumping off ledges */ s32 Camera_Jump1(Camera* camera) { - if (CVarGetInteger("gFreeCamera", 0) && SetCameraManual(camera) == 1) { + if (CVarGetInteger(CVAR_SETTING("FreeLook.Enabled"), 0) && SetCameraManual(camera) == 1) { Camera_Free(camera); return 1; } @@ -2455,7 +2455,7 @@ s32 Camera_Jump1(Camera* camera) { // Climbing ladders/vines s32 Camera_Jump2(Camera* camera) { - if (CVarGetInteger("gFreeCamera", 0) && SetCameraManual(camera) == 1) { + if (CVarGetInteger(CVAR_SETTING("FreeLook.Enabled"), 0) && SetCameraManual(camera) == 1) { Camera_Free(camera); return 1; } @@ -2642,7 +2642,7 @@ s32 Camera_Jump2(Camera* camera) { // swimming s32 Camera_Jump3(Camera* camera) { - if (CVarGetInteger("gFreeCamera", 0) && SetCameraManual(camera) == 1) { + if (CVarGetInteger(CVAR_SETTING("FreeLook.Enabled"), 0) && SetCameraManual(camera) == 1) { Camera_Free(camera); return 1; } @@ -3104,7 +3104,7 @@ s32 Camera_Battle3(Camera* camera) { * setting value. */ s32 Camera_Battle4(Camera* camera) { - if (CVarGetInteger("gFreeCamera", 0) && SetCameraManual(camera) == 1) { + if (CVarGetInteger(CVAR_SETTING("FreeLook.Enabled"), 0) && SetCameraManual(camera) == 1) { Camera_Free(camera); return 1; } @@ -4639,7 +4639,7 @@ s32 Camera_Data4(Camera* camera) { * Hanging off of a ledge */ s32 Camera_Unique1(Camera* camera) { - if (CVarGetInteger("gFreeCamera", 0) && SetCameraManual(camera) == 1) { + if (CVarGetInteger(CVAR_SETTING("FreeLook.Enabled"), 0) && SetCameraManual(camera) == 1) { Camera_Free(camera); return 1; } @@ -7890,7 +7890,7 @@ s32 Camera_ChangeModeFlags(Camera* camera, s16 mode, u8 flags) { } // Clear free look if an action is performed that would move the camera (targeting, first person, talking) - if (CVarGetInteger("gFreeCamera", 0) && SetCameraManual(camera) == 1 && + if (CVarGetInteger(CVAR_SETTING("FreeLook.Enabled"), 0) && SetCameraManual(camera) == 1 && ((mode >= CAM_MODE_TARGET && mode <= CAM_MODE_BATTLE) || (mode >= CAM_MODE_FIRSTPERSON && mode <= CAM_MODE_CLIMBZ) || mode == CAM_MODE_HANGZ || mode == CAM_MODE_FOLLOWBOOMERANG)) { diff --git a/soh/src/code/z_en_item00.c b/soh/src/code/z_en_item00.c index 7a2b9d3d83e..db344d39e98 100644 --- a/soh/src/code/z_en_item00.c +++ b/soh/src/code/z_en_item00.c @@ -3,6 +3,7 @@ #include "objects/gameplay_keep/gameplay_keep.h" #include "overlays/effects/ovl_Effect_Ss_Dead_Sound/z_eff_ss_dead_sound.h" #include "textures/icon_item_static/icon_item_static.h" +#include "soh/Enhancements/game-interactor/GameInteractor.h" #define FLAGS 0 @@ -333,7 +334,7 @@ void EnItem00_SetupAction(EnItem00* this, EnItem00ActionFunc actionFunc) { void EnItem00_SetObjectDependency(EnItem00* this, PlayState* play, s16 objectIndex) { // Remove object dependency for Enemy Randomizer and Crowd Control to allow Like-likes to // drop equipment correctly in rooms where Like-likes normally don't spawn. - if (CVarGetInteger(CVAR_ENHANCEMENT("RandomizedEnemies"), 0) || CVarGetInteger("gCrowdControl", 0)) { + if (CVarGetInteger(CVAR_ENHANCEMENT("RandomizedEnemies"), 0) || (CVarGetInteger(CVAR_REMOTE("Scheme"), GI_SCHEME_SAIL) == GI_SCHEME_CROWD_CONTROL && CVarGetInteger(CVAR_REMOTE("Enabled"), 0))) { this->actor.objBankIndex = 0; } else { this->actor.objBankIndex = Object_GetIndex(&play->objectCtx, objectIndex); diff --git a/soh/src/code/z_kaleido_setup.c b/soh/src/code/z_kaleido_setup.c index e2feccf3c86..3efbd6ade84 100644 --- a/soh/src/code/z_kaleido_setup.c +++ b/soh/src/code/z_kaleido_setup.c @@ -19,12 +19,12 @@ void KaleidoSetup_Update(PlayState* play) { (play->sceneNum != SCENE_BOMBCHU_BOWLING_ALLEY || !Flags_GetSwitch(play, 0x38))) { u8 easyPauseBufferEnabled = CVarGetInteger(CVAR_CHEAT("EasyPauseBuffer"), 0); - u8 easyPauseBufferTimer = CVarGetInteger("gCheatEasyPauseBufferTimer", 0); + u8 easyPauseBufferTimer = CVarGetInteger(CVAR_GENERAL("CheatEasyPauseBufferTimer"), 0); // If start is not seen as pressed on the 2nd to last frame then we should end the easy frame advance flow if (easyPauseBufferEnabled && easyPauseBufferTimer == 2 && !CHECK_BTN_ALL(input->press.button, BTN_START)) { - CVarSetInteger("gCheatEasyPauseBufferTimer", 0); + CVarSetInteger(CVAR_GENERAL("CheatEasyPauseBufferTimer"), 0); } if (CHECK_BTN_ALL(input->cur.button, BTN_L) && CHECK_BTN_ALL(input->press.button, BTN_CUP)) { @@ -34,14 +34,14 @@ void KaleidoSetup_Update(PlayState* play) { } else if ((CHECK_BTN_ALL(input->press.button, BTN_START) && (!easyPauseBufferEnabled || !easyPauseBufferTimer)) || (easyPauseBufferEnabled && easyPauseBufferTimer == 1)) { // Force Kaleido open when easy pause buffer reaches 0 // Remember last held buttons for pause buffer cheat (minus start so easy frame advance works) - CVarSetInteger("gCheatEasyPauseBufferLastInputs", input->cur.button & ~(BTN_START)); + CVarSetInteger(CVAR_GENERAL("CheatEasyPauseBufferLastInputs"), input->cur.button & ~(BTN_START)); gSaveContext.unk_13EE = gSaveContext.unk_13EA; if (CHECK_BTN_ALL(input->cur.button, BTN_L)) - CVarSetInteger("gPauseTriforce", 1); + CVarSetInteger(CVAR_GENERAL("PauseTriforce"), 1); else - CVarSetInteger("gPauseTriforce", 0); + CVarSetInteger(CVAR_GENERAL("PauseTriforce"), 0); WREG(16) = -175; diff --git a/soh/src/code/z_lib.c b/soh/src/code/z_lib.c index 820256cbb21..57f1312ddc4 100644 --- a/soh/src/code/z_lib.c +++ b/soh/src/code/z_lib.c @@ -201,7 +201,7 @@ void func_80077D10(f32* arg0, s16* arg1, Input* input) { f32 relX = input->rel.stick_x; f32 relY = input->rel.stick_y; - if (CVarGetInteger("gMirroredWorld", 0)) { + if (CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0)) { relX = -input->rel.stick_x; } diff --git a/soh/src/code/z_lifemeter.c b/soh/src/code/z_lifemeter.c index da4c16a51ea..3cb9d471591 100644 --- a/soh/src/code/z_lifemeter.c +++ b/soh/src/code/z_lifemeter.c @@ -176,10 +176,10 @@ void HealthMeter_Update(PlayState* play) { s16 gFactor; s16 bFactor; - Top_LM_Margin = CVarGetInteger("gHUDMargin_T", 0); - Left_LM_Margin = CVarGetInteger("gHUDMargin_L", 0); - Right_LM_Margin = CVarGetInteger("gHUDMargin_R", 0); - Bottom_LM_Margin = CVarGetInteger("gHUDMargin_B", 0); + Top_LM_Margin = CVarGetInteger(CVAR_COSMETIC("HUD.Margin.T"), 0); + Left_LM_Margin = CVarGetInteger(CVAR_COSMETIC("HUD.Margin.L"), 0); + Right_LM_Margin = CVarGetInteger(CVAR_COSMETIC("HUD.Margin.R"), 0); + Bottom_LM_Margin = CVarGetInteger(CVAR_COSMETIC("HUD.Margin.B"), 0); Color_RGB8 mainColor = {HEARTS_PRIM_R, HEARTS_PRIM_G, HEARTS_PRIM_B}; if (CVarGetInteger(CVAR_COSMETIC("Consumable.Hearts.Changed"), 0)) { @@ -336,20 +336,20 @@ static void* sHeartDDTextures[] = { s16 getHealthMeterXOffset() { s16 X_Margins; - if (CVarGetInteger(CVAR_COSMETIC("Hearts.UseMargins"), 0) != 0) + if (CVarGetInteger(CVAR_COSMETIC("HUD.Hearts.UseMargins"), 0) != 0) X_Margins = Left_LM_Margin; else X_Margins = 0; - if (CVarGetInteger(CVAR_COSMETIC("HeartsCount.PosType"), 0) != 0) { - if (CVarGetInteger(CVAR_COSMETIC("HeartsCount.PosType"), 0) == 1) {//Anchor Left - return OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("HeartsCount.PosX"), 0)+X_Margins+70.0f); - } else if (CVarGetInteger(CVAR_COSMETIC("HeartsCount.PosType"), 0) == 2) {//Anchor Right + if (CVarGetInteger(CVAR_COSMETIC("HUD.HeartsCount.PosType"), 0) != 0) { + if (CVarGetInteger(CVAR_COSMETIC("HUD.HeartsCount.PosType"), 0) == 1) {//Anchor Left + return OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("HUD.HeartsCount.PosX"), 0)+X_Margins+70.0f); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.HeartsCount.PosType"), 0) == 2) {//Anchor Right X_Margins = Right_LM_Margin; - return OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("HeartsCount.PosX"), 0)+X_Margins+70.0f); - } else if (CVarGetInteger(CVAR_COSMETIC("HeartsCount.PosType"), 0) == 3) {//Anchor None - return CVarGetInteger(CVAR_COSMETIC("HeartsCount.PosX"), 0)+70.0f;; - } else if (CVarGetInteger(CVAR_COSMETIC("HeartsCount.PosType"), 0) == 4) {//Hidden + return OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("HUD.HeartsCount.PosX"), 0)+X_Margins+70.0f); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.HeartsCount.PosType"), 0) == 3) {//Anchor None + return CVarGetInteger(CVAR_COSMETIC("HUD.HeartsCount.PosX"), 0)+70.0f;; + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.HeartsCount.PosType"), 0) == 4) {//Hidden return -9999; } } else { @@ -359,15 +359,15 @@ s16 getHealthMeterXOffset() { s16 getHealthMeterYOffset() { s16 Y_Margins; - if (CVarGetInteger(CVAR_COSMETIC("Hearts.UseMargins"), 0) != 0) + if (CVarGetInteger(CVAR_COSMETIC("HUD.Hearts.UseMargins"), 0) != 0) Y_Margins = (Top_LM_Margin*-1); else Y_Margins = 0; f32 HeartsScale = 0.7f; - if (CVarGetInteger(CVAR_COSMETIC("HeartsCount.PosType"), 0) != 0) { - HeartsScale = CVarGetFloat(CVAR_COSMETIC("HeartsCount.Scale"), 0.7f); - return CVarGetInteger(CVAR_COSMETIC("HeartsCount.PosY"), 0)+Y_Margins+(HeartsScale*15); + if (CVarGetInteger(CVAR_COSMETIC("HUD.HeartsCount.PosType"), 0) != 0) { + HeartsScale = CVarGetFloat(CVAR_COSMETIC("HUD.HeartsCount.Scale"), 0.7f); + return CVarGetInteger(CVAR_COSMETIC("HUD.HeartsCount.PosY"), 0)+Y_Margins+(HeartsScale*15); } else { return 0.0f+Y_Margins; } @@ -397,8 +397,8 @@ void HealthMeter_Draw(PlayState* play) { u8* curBgImgLoaded = NULL; s32 ddHeartCountMinusOne = gSaveContext.isDoubleDefenseAcquired ? totalHeartCount - 1 : -1; f32 HeartsScale = 0.7f; - if (CVarGetInteger(CVAR_COSMETIC("HeartsCount.PosType"), 0) != 0) { - HeartsScale = CVarGetFloat(CVAR_COSMETIC("HeartsCount.Scale"), 0.7f); + if (CVarGetInteger(CVAR_COSMETIC("HUD.HeartsCount.PosType"), 0) != 0) { + HeartsScale = CVarGetFloat(CVAR_COSMETIC("HUD.HeartsCount.Scale"), 0.7f); } static u32 epoch = 0; epoch++; @@ -413,7 +413,7 @@ void HealthMeter_Draw(PlayState* play) { /* s16 X_Margins; s16 Y_Margins; - if (CVarGetInteger(CVAR_COSMETIC("Hearts.UseMargins"), 0) != 0) { + if (CVarGetInteger(CVAR_COSMETIC("HUD.Hearts.UseMargins"), 0) != 0) { X_Margins = Left_LM_Margin; Y_Margins = (Top_LM_Margin*-1); } else { @@ -422,16 +422,16 @@ void HealthMeter_Draw(PlayState* play) { } s16 PosX_original = OTRGetDimensionFromLeftEdge(0.0f)+X_Margins; s16 PosY_original = 0.0f+Y_Margins; - if (CVarGetInteger(CVAR_COSMETIC("HeartsCount.PosType"), 0) != 0) { - offsetY = CVarGetInteger(CVAR_COSMETIC("HeartsCount.PosY"), 0)+Y_Margins+(HeartsScale*15); - if (CVarGetInteger(CVAR_COSMETIC("HeartsCount.PosType"), 0) == 1) {//Anchor Left - offsetX = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("HeartsCount.PosX"), 0)+X_Margins+70.0f); - } else if (CVarGetInteger(CVAR_COSMETIC("HeartsCount.PosType"), 0) == 2) {//Anchor Right + if (CVarGetInteger(CVAR_COSMETIC("HUD.HeartsCount.PosType"), 0) != 0) { + offsetY = CVarGetInteger(CVAR_COSMETIC("HUD.HeartsCount.PosY"), 0)+Y_Margins+(HeartsScale*15); + if (CVarGetInteger(CVAR_COSMETIC("HUD.HeartsCount.PosType"), 0) == 1) {//Anchor Left + offsetX = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("HUD.HeartsCount.PosX"), 0)+X_Margins+70.0f); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.HeartsCount.PosType"), 0) == 2) {//Anchor Right X_Margins = Right_LM_Margin; - offsetX = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("HeartsCount.PosX"), 0)+X_Margins+70.0f); - } else if (CVarGetInteger(CVAR_COSMETIC("HeartsCount.PosType"), 0) == 3) {//Anchor None - offsetX = CVarGetInteger(CVAR_COSMETIC("HeartsCount.PosX"), 0)+70.0f; - } else if (CVarGetInteger(CVAR_COSMETIC("HeartsCount.PosType"), 0) == 4) {//Hidden + offsetX = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("HUD.HeartsCount.PosX"), 0)+X_Margins+70.0f); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.HeartsCount.PosType"), 0) == 3) {//Anchor None + offsetX = CVarGetInteger(CVAR_COSMETIC("HUD.HeartsCount.PosX"), 0)+70.0f; + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.HeartsCount.PosType"), 0) == 4) {//Hidden offsetX = -9999; } } else { @@ -626,7 +626,7 @@ void HealthMeter_Draw(PlayState* play) { } offsetX += 10.0f; - s32 lineLength = CVarGetInteger(CVAR_COSMETIC("Hearts.LineLength"), 10); + s32 lineLength = CVarGetInteger(CVAR_COSMETIC("HUD.Hearts.LineLength"), 10); if (lineLength != 0 && (i+1)%lineLength == 0) { offsetX = PosX_anchor; offsetY += 10.0f; diff --git a/soh/src/code/z_map_exp.c b/soh/src/code/z_map_exp.c index abee561aa74..6cf1dcc3404 100644 --- a/soh/src/code/z_map_exp.c +++ b/soh/src/code/z_map_exp.c @@ -615,8 +615,8 @@ void Minimap_DrawCompassIcons(PlayState* play) { } s16 X_Margins_Minimap; s16 Y_Margins_Minimap; - if (CVarGetInteger(CVAR_COSMETIC("Minimap.UseMargins"), 0) != 0) { - if (CVarGetInteger(CVAR_COSMETIC("Minimap.PosType"), 0) == 0) {X_Margins_Minimap = Right_MM_Margin;}; + if (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.UseMargins"), 0) != 0) { + if (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosType"), 0) == 0) {X_Margins_Minimap = Right_MM_Margin;}; Y_Margins_Minimap = Bottom_MM_Margin; } else { X_Margins_Minimap = 0; @@ -652,32 +652,32 @@ void Minimap_DrawCompassIcons(PlayState* play) { tempX = player->actor.world.pos.x; tempZ = player->actor.world.pos.z; - tempX /= R_COMPASS_SCALE_X * (CVarGetInteger("gMirroredWorld", 0) ? -1 : 1); + tempX /= R_COMPASS_SCALE_X * (CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0) ? -1 : 1); tempZ /= R_COMPASS_SCALE_Y; - s16 tempXOffset = R_COMPASS_OFFSET_X + (CVarGetInteger("gMirroredWorld", 0) ? mirrorOffset : 0); - if (CVarGetInteger(CVAR_COSMETIC("Minimap.PosType"), 0) != 0) { - if (CVarGetInteger(CVAR_COSMETIC("Minimap.PosType"), 0) == 1) {//Anchor Left - if (CVarGetInteger(CVAR_COSMETIC("Minimap.UseMargins"), 0) != 0) {X_Margins_Minimap = Left_MM_Margin;}; + s16 tempXOffset = R_COMPASS_OFFSET_X + (CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0) ? mirrorOffset : 0); + if (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosType"), 0) != 0) { + if (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosType"), 0) == 1) {//Anchor Left + if (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.UseMargins"), 0) != 0) {X_Margins_Minimap = Left_MM_Margin;}; Matrix_Translate( - OTRGetDimensionFromLeftEdge((tempXOffset + (X_Margins_Minimap*10) + tempX + (CVarGetInteger(CVAR_COSMETIC("Minimap.PosX"), 0)*10)) / 10.0f), - (R_COMPASS_OFFSET_Y + ((Y_Margins_Minimap*10)*-1) - tempZ + ((CVarGetInteger(CVAR_COSMETIC("Minimap.PosY"), 0)*10)*-1)) / 10.0f, 0.0f, MTXMODE_NEW); - } else if (CVarGetInteger(CVAR_COSMETIC("Minimap.PosType"), 0) == 2) {//Anchor Right - if (CVarGetInteger(CVAR_COSMETIC("Minimap.UseMargins"), 0) != 0) {X_Margins_Minimap = Right_MM_Margin;}; + OTRGetDimensionFromLeftEdge((tempXOffset + (X_Margins_Minimap*10) + tempX + (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosX"), 0)*10)) / 10.0f), + (R_COMPASS_OFFSET_Y + ((Y_Margins_Minimap*10)*-1) - tempZ + ((CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosY"), 0)*10)*-1)) / 10.0f, 0.0f, MTXMODE_NEW); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosType"), 0) == 2) {//Anchor Right + if (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.UseMargins"), 0) != 0) {X_Margins_Minimap = Right_MM_Margin;}; Matrix_Translate( - OTRGetDimensionFromRightEdge((tempXOffset + (X_Margins_Minimap*10) + tempX + (CVarGetInteger(CVAR_COSMETIC("Minimap.PosX"), 0)*10)) / 10.0f), - (R_COMPASS_OFFSET_Y +((Y_Margins_Minimap*10)*-1) - tempZ + ((CVarGetInteger(CVAR_COSMETIC("Minimap.PosY"), 0)*10)*-1)) / 10.0f, 0.0f, MTXMODE_NEW); - } else if (CVarGetInteger(CVAR_COSMETIC("Minimap.PosType"), 0) == 3) {//Anchor None + OTRGetDimensionFromRightEdge((tempXOffset + (X_Margins_Minimap*10) + tempX + (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosX"), 0)*10)) / 10.0f), + (R_COMPASS_OFFSET_Y +((Y_Margins_Minimap*10)*-1) - tempZ + ((CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosY"), 0)*10)*-1)) / 10.0f, 0.0f, MTXMODE_NEW); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosType"), 0) == 3) {//Anchor None Matrix_Translate( - (tempXOffset + tempX + (CVarGetInteger(CVAR_COSMETIC("Minimap.PosX"), 0)*10) / 10.0f), - (R_COMPASS_OFFSET_Y + ((Y_Margins_Minimap*10)*-1) - tempZ + ((CVarGetInteger(CVAR_COSMETIC("Minimap.PosY"), 0)*10)*-1)) / 10.0f, 0.0f, MTXMODE_NEW); + (tempXOffset + tempX + (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosX"), 0)*10) / 10.0f), + (R_COMPASS_OFFSET_Y + ((Y_Margins_Minimap*10)*-1) - tempZ + ((CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosY"), 0)*10)*-1)) / 10.0f, 0.0f, MTXMODE_NEW); } } else { Matrix_Translate(OTRGetDimensionFromRightEdge((tempXOffset+(X_Margins_Minimap*10) + tempX) / 10.0f), (R_COMPASS_OFFSET_Y+((Y_Margins_Minimap*10)*-1) - tempZ) / 10.0f, 0.0f, MTXMODE_NEW); } Matrix_Scale(0.4f, 0.4f, 0.4f, MTXMODE_APPLY); Matrix_RotateX(-1.6f, MTXMODE_APPLY); - tempX = ((0x7FFF - player->actor.shape.rot.y) / 0x400) * (CVarGetInteger("gMirroredWorld", 0) ? -1 : 1); + tempX = ((0x7FFF - player->actor.shape.rot.y) / 0x400) * (CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0) ? -1 : 1); Matrix_RotateY(tempX / 10.0f, MTXMODE_APPLY); gSPMatrix(OVERLAY_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -688,30 +688,30 @@ void Minimap_DrawCompassIcons(PlayState* play) { //Player map entry (red arrow) tempX = sPlayerInitialPosX; tempZ = sPlayerInitialPosZ; - tempX /= R_COMPASS_SCALE_X * (CVarGetInteger("gMirroredWorld", 0) ? -1 : 1); + tempX /= R_COMPASS_SCALE_X * (CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0) ? -1 : 1); tempZ /= R_COMPASS_SCALE_Y; - if (CVarGetInteger(CVAR_COSMETIC("Minimap.PosType"), 0) != 0) { - if (CVarGetInteger(CVAR_COSMETIC("Minimap.PosType"), 0) == 1) {//Anchor Left - if (CVarGetInteger(CVAR_COSMETIC("Minimap.UseMargins"), 0) != 0) {X_Margins_Minimap = Left_MM_Margin;}; + if (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosType"), 0) != 0) { + if (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosType"), 0) == 1) {//Anchor Left + if (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.UseMargins"), 0) != 0) {X_Margins_Minimap = Left_MM_Margin;}; Matrix_Translate( - OTRGetDimensionFromLeftEdge((tempXOffset + (X_Margins_Minimap*10) + tempX + (CVarGetInteger(CVAR_COSMETIC("Minimap.PosX"), 0)*10)) / 10.0f), - (R_COMPASS_OFFSET_Y + ((Y_Margins_Minimap*10)*-1) - tempZ + ((CVarGetInteger(CVAR_COSMETIC("Minimap.PosY"), 0)*10)*-1)) / 10.0f, 0.0f, MTXMODE_NEW); - } else if (CVarGetInteger(CVAR_COSMETIC("Minimap.PosType"), 0) == 2) {//Anchor Right - if (CVarGetInteger(CVAR_COSMETIC("Minimap.UseMargins"), 0) != 0) {X_Margins_Minimap = Right_MM_Margin;}; + OTRGetDimensionFromLeftEdge((tempXOffset + (X_Margins_Minimap*10) + tempX + (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosX"), 0)*10)) / 10.0f), + (R_COMPASS_OFFSET_Y + ((Y_Margins_Minimap*10)*-1) - tempZ + ((CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosY"), 0)*10)*-1)) / 10.0f, 0.0f, MTXMODE_NEW); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosType"), 0) == 2) {//Anchor Right + if (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.UseMargins"), 0) != 0) {X_Margins_Minimap = Right_MM_Margin;}; Matrix_Translate( - OTRGetDimensionFromRightEdge((tempXOffset + (X_Margins_Minimap*10) + tempX + (CVarGetInteger(CVAR_COSMETIC("Minimap.PosX"), 0)*10)) / 10.0f), - (R_COMPASS_OFFSET_Y +((Y_Margins_Minimap*10)*-1) - tempZ + ((CVarGetInteger(CVAR_COSMETIC("Minimap.PosY"), 0)*10)*-1)) / 10.0f, 0.0f, MTXMODE_NEW); - } else if (CVarGetInteger(CVAR_COSMETIC("Minimap.PosType"), 0) == 3) {//Anchor None + OTRGetDimensionFromRightEdge((tempXOffset + (X_Margins_Minimap*10) + tempX + (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosX"), 0)*10)) / 10.0f), + (R_COMPASS_OFFSET_Y +((Y_Margins_Minimap*10)*-1) - tempZ + ((CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosY"), 0)*10)*-1)) / 10.0f, 0.0f, MTXMODE_NEW); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosType"), 0) == 3) {//Anchor None Matrix_Translate( - (tempXOffset + tempX + (CVarGetInteger(CVAR_COSMETIC("Minimap.PosX"), 0)*10) / 10.0f), - (R_COMPASS_OFFSET_Y - tempZ + ((CVarGetInteger(CVAR_COSMETIC("Minimap.PosY"), 0)*10)*-1)) / 10.0f, 0.0f, MTXMODE_NEW); + (tempXOffset + tempX + (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosX"), 0)*10) / 10.0f), + (R_COMPASS_OFFSET_Y - tempZ + ((CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosY"), 0)*10)*-1)) / 10.0f, 0.0f, MTXMODE_NEW); } } else { Matrix_Translate(OTRGetDimensionFromRightEdge((tempXOffset+(X_Margins_Minimap*10) + tempX) / 10.0f), (R_COMPASS_OFFSET_Y+((Y_Margins_Minimap*10)*-1) - tempZ) / 10.0f, 0.0f, MTXMODE_NEW); } Matrix_Scale(VREG(9) / 100.0f, VREG(9) / 100.0f, VREG(9) / 100.0f, MTXMODE_APPLY); Matrix_RotateX(VREG(52) / 10.0f, MTXMODE_APPLY); - Matrix_RotateY((sPlayerInitialDirection * (CVarGetInteger("gMirroredWorld", 0) ? -1 : 1)) / 10.0f, MTXMODE_APPLY); + Matrix_RotateY((sPlayerInitialDirection * (CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0) ? -1 : 1)) / 10.0f, MTXMODE_APPLY); gSPMatrix(OVERLAY_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -735,15 +735,15 @@ void Minimap_Draw(PlayState* play) { // If any of these CVars are enabled, disable toggling the minimap with L, unless gEnableMapToggle is set bool enableMapToggle = - !(CVarGetInteger(CVAR_DEVELOPER_TOOLS("DebugEnabled"), 0) || CVarGetInteger(CVAR_CHEAT("MoonJumpOnL"), 0) || CVarGetInteger("gTurboOnL", 0)) || - CVarGetInteger("gEnableMapToggle", 0); + !(CVarGetInteger(CVAR_DEVELOPER_TOOLS("DebugEnabled"), 0) || CVarGetInteger(CVAR_CHEAT("MoonJumpOnL"), 0)) || + CVarGetInteger(CVAR_DEVELOPER_TOOLS("EnableMapToggle"), 0); if (play->pauseCtx.state < 4) { //Minimap margins s16 X_Margins_Minimap; s16 Y_Margins_Minimap; - if (CVarGetInteger(CVAR_COSMETIC("Minimap.UseMargins"), 0) != 0) { - if (CVarGetInteger(CVAR_COSMETIC("Minimap.PosType"), 0) == 0) {X_Margins_Minimap = Right_MM_Margin;}; + if (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.UseMargins"), 0) != 0) { + if (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosType"), 0) == 0) {X_Margins_Minimap = Right_MM_Margin;}; Y_Margins_Minimap = Bottom_MM_Margin; } else { X_Margins_Minimap = 0; @@ -761,7 +761,7 @@ void Minimap_Draw(PlayState* play) { case SCENE_SHADOW_TEMPLE: case SCENE_BOTTOM_OF_THE_WELL: case SCENE_ICE_CAVERN: - if (!R_MINIMAP_DISABLED && CVarGetInteger(CVAR_COSMETIC("Minimap.PosType"), 0) != 4) { // Not Hidden + if (!R_MINIMAP_DISABLED && CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosType"), 0) != 4) { // Not Hidden Gfx_SetupDL_39Overlay(play->state.gfxCtx); gDPSetCombineLERP(OVERLAY_DISP++, 1, 0, PRIMITIVE, 0, TEXEL0, 0, PRIMITIVE, 0, 1, 0, PRIMITIVE, 0, TEXEL0, 0, PRIMITIVE, 0); @@ -769,28 +769,28 @@ void Minimap_Draw(PlayState* play) { if (CHECK_DUNGEON_ITEM(DUNGEON_MAP, mapIndex)) { gDPSetPrimColor(OVERLAY_DISP++, 0, 0, minimapColor.r, minimapColor.g, minimapColor.b, interfaceCtx->minimapAlpha); - u8 mirrorMode = CVarGetInteger("gMirroredWorld", 0) ? G_TX_MIRROR : G_TX_NOMIRROR; + u8 mirrorMode = CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0) ? G_TX_MIRROR : G_TX_NOMIRROR; gDPLoadTextureBlock_4b(OVERLAY_DISP++, interfaceCtx->mapSegmentName[0], G_IM_FMT_I, 96, 85, 0, mirrorMode | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); s16 dgnMiniMapX = OTRGetRectDimensionFromRightEdge(R_DGN_MINIMAP_X + X_Margins_Minimap); s16 dgnMiniMapY = R_DGN_MINIMAP_Y + Y_Margins_Minimap; - if (CVarGetInteger(CVAR_COSMETIC("Minimap.PosType"), 0) != 0) { - dgnMiniMapY = R_DGN_MINIMAP_Y+CVarGetInteger(CVAR_COSMETIC("Minimap.PosY"), 0)+Y_Margins_Minimap; - if (CVarGetInteger(CVAR_COSMETIC("Minimap.PosType"), 0) == 1) {//Anchor Left - if (CVarGetInteger(CVAR_COSMETIC("Minimap.UseMargins"), 0) != 0) {X_Margins_Minimap = Left_MM_Margin;}; - dgnMiniMapX = OTRGetDimensionFromLeftEdge(R_DGN_MINIMAP_X+CVarGetInteger(CVAR_COSMETIC("Minimap.PosX"), 0)+X_Margins_Minimap); - } else if (CVarGetInteger(CVAR_COSMETIC("Minimap.PosType"), 0) == 2) {//Anchor Right - if (CVarGetInteger(CVAR_COSMETIC("Minimap.UseMargins"), 0) != 0) {X_Margins_Minimap = Right_MM_Margin;}; - dgnMiniMapX = OTRGetDimensionFromRightEdge(R_DGN_MINIMAP_X+CVarGetInteger(CVAR_COSMETIC("Minimap.PosX"), 0)+X_Margins_Minimap); - } else if (CVarGetInteger(CVAR_COSMETIC("Minimap.PosType"), 0) == 3) {//Anchor None - dgnMiniMapX = CVarGetInteger(CVAR_COSMETIC("Minimap.PosX"), 0); + if (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosType"), 0) != 0) { + dgnMiniMapY = R_DGN_MINIMAP_Y+CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosY"), 0)+Y_Margins_Minimap; + if (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosType"), 0) == 1) {//Anchor Left + if (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.UseMargins"), 0) != 0) {X_Margins_Minimap = Left_MM_Margin;}; + dgnMiniMapX = OTRGetDimensionFromLeftEdge(R_DGN_MINIMAP_X+CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosX"), 0)+X_Margins_Minimap); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosType"), 0) == 2) {//Anchor Right + if (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.UseMargins"), 0) != 0) {X_Margins_Minimap = Right_MM_Margin;}; + dgnMiniMapX = OTRGetDimensionFromRightEdge(R_DGN_MINIMAP_X+CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosX"), 0)+X_Margins_Minimap); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosType"), 0) == 3) {//Anchor None + dgnMiniMapX = CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosX"), 0); } } s32 sValue = 0; - if (CVarGetInteger("gMirroredWorld", 0)) { + if (CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0)) { // Flip the minimap on the x-axis (s-axis) by setting s to the textures mirror boundary sValue = 96 << 5; } @@ -839,13 +839,13 @@ void Minimap_Draw(PlayState* play) { case SCENE_GORON_CITY: case SCENE_LON_LON_RANCH: case SCENE_OUTSIDE_GANONS_CASTLE: - if (!R_MINIMAP_DISABLED && CVarGetInteger(CVAR_COSMETIC("Minimap.PosType"), 0) != 4) { // Not Hidden + if (!R_MINIMAP_DISABLED && CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosType"), 0) != 4) { // Not Hidden Gfx_SetupDL_39Overlay(play->state.gfxCtx); gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, minimapColor.r, minimapColor.g, minimapColor.b, interfaceCtx->minimapAlpha); - u8 mirrorMode = CVarGetInteger("gMirroredWorld", 0) ? G_TX_MIRROR : G_TX_NOMIRROR; + u8 mirrorMode = CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0) ? G_TX_MIRROR : G_TX_NOMIRROR; gDPLoadTextureBlock_4b(OVERLAY_DISP++, interfaceCtx->mapSegmentName[0], G_IM_FMT_IA, gMapData->owMinimapWidth[mapIndex], gMapData->owMinimapHeight[mapIndex], 0, mirrorMode | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, @@ -853,21 +853,21 @@ void Minimap_Draw(PlayState* play) { s16 oWMiniMapX = OTRGetRectDimensionFromRightEdge(R_OW_MINIMAP_X + X_Margins_Minimap); s16 oWMiniMapY = R_OW_MINIMAP_Y + Y_Margins_Minimap; - if (CVarGetInteger(CVAR_COSMETIC("Minimap.PosType"), 0) != 0) { - oWMiniMapY = R_OW_MINIMAP_Y+CVarGetInteger(CVAR_COSMETIC("Minimap.PosY"), 0)+Y_Margins_Minimap; - if (CVarGetInteger(CVAR_COSMETIC("Minimap.PosType"), 0) == 1) {//Anchor Left - if (CVarGetInteger(CVAR_COSMETIC("Minimap.UseMargins"), 0) != 0) {X_Margins_Minimap = Left_MM_Margin;}; - oWMiniMapX = OTRGetDimensionFromLeftEdge(R_OW_MINIMAP_X+CVarGetInteger(CVAR_COSMETIC("Minimap.PosX"), 0)+X_Margins_Minimap); - } else if (CVarGetInteger(CVAR_COSMETIC("Minimap.PosType"), 0) == 2) {//Anchor Right - if (CVarGetInteger(CVAR_COSMETIC("Minimap.UseMargins"), 0) != 0) {X_Margins_Minimap = Right_MM_Margin;}; - oWMiniMapX = OTRGetDimensionFromRightEdge(R_OW_MINIMAP_X+CVarGetInteger(CVAR_COSMETIC("Minimap.PosX"), 0)+X_Margins_Minimap); - } else if (CVarGetInteger(CVAR_COSMETIC("Minimap.PosType"), 0) == 3) {//Anchor None - oWMiniMapX = CVarGetInteger(CVAR_COSMETIC("Minimap.PosX"), 0); + if (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosType"), 0) != 0) { + oWMiniMapY = R_OW_MINIMAP_Y+CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosY"), 0)+Y_Margins_Minimap; + if (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosType"), 0) == 1) {//Anchor Left + if (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.UseMargins"), 0) != 0) {X_Margins_Minimap = Left_MM_Margin;}; + oWMiniMapX = OTRGetDimensionFromLeftEdge(R_OW_MINIMAP_X+CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosX"), 0)+X_Margins_Minimap); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosType"), 0) == 2) {//Anchor Right + if (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.UseMargins"), 0) != 0) {X_Margins_Minimap = Right_MM_Margin;}; + oWMiniMapX = OTRGetDimensionFromRightEdge(R_OW_MINIMAP_X+CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosX"), 0)+X_Margins_Minimap); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosType"), 0) == 3) {//Anchor None + oWMiniMapX = CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosX"), 0); } } s32 sValue = 0; - if (CVarGetInteger("gMirroredWorld", 0)) { + if (CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0)) { // Flip the minimap on the x-axis (s-axis) by setting s to the textures mirror boundary sValue = gMapData->owMinimapWidth[mapIndex] << 5; } @@ -890,7 +890,7 @@ void Minimap_Draw(PlayState* play) { // Then duplicate that and right-align the texture (extra 2 pixels are due to the texture being a 6px left-aligned in a 8px tex) s16 distFromCenter = (R_OW_MINIMAP_X + (gMapData->owMinimapWidth[mapIndex] / 2)) - (origX + (iconSize / 2)); s16 mirrorOffset = distFromCenter * 2 + (iconSize / 2) - 2; - s16 newX = origX + (CVarGetInteger("gMirroredWorld", 0) ? mirrorOffset : 0); + s16 newX = origX + (CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0) ? mirrorOffset : 0); // The game authentically uses larger negative values for the entrance icon Y pos value. Normally only the first 12 bits // would be read when the final value is passed into `gSPTextureRectangle`, but our cosmetic hud placements requires using @@ -901,16 +901,16 @@ void Minimap_Draw(PlayState* play) { s16 entranceX = OTRGetRectDimensionFromRightEdge(newX + X_Margins_Minimap); s16 entranceY = newY + Y_Margins_Minimap; - if (CVarGetInteger(CVAR_COSMETIC("Minimap.PosType"), 0) != 0) { - entranceY = newY + CVarGetInteger(CVAR_COSMETIC("Minimap.PosY"), 0) + Y_Margins_Minimap; - if (CVarGetInteger(CVAR_COSMETIC("Minimap.PosType"), 0) == 1) { // Anchor Left - if (CVarGetInteger(CVAR_COSMETIC("Minimap.UseMargins"), 0) != 0) {X_Margins_Minimap = Left_MM_Margin;}; - entranceX = OTRGetRectDimensionFromLeftEdge(newX + X_Margins_Minimap + CVarGetInteger(CVAR_COSMETIC("Minimap.PosX"), 0)); - } else if (CVarGetInteger(CVAR_COSMETIC("Minimap.PosType"), 0) == 2) { // Anchor Right - if (CVarGetInteger(CVAR_COSMETIC("Minimap.UseMargins"), 0) != 0) {X_Margins_Minimap = Right_MM_Margin;}; - entranceX = OTRGetRectDimensionFromRightEdge(newX + X_Margins_Minimap + CVarGetInteger(CVAR_COSMETIC("Minimap.PosX"), 0)); - } else if (CVarGetInteger(CVAR_COSMETIC("Minimap.PosType"), 0) == 3) { // Anchor None - entranceX = newX + X_Margins_Minimap + CVarGetInteger(CVAR_COSMETIC("Minimap.PosX"), 0); + if (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosType"), 0) != 0) { + entranceY = newY + CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosY"), 0) + Y_Margins_Minimap; + if (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosType"), 0) == 1) { // Anchor Left + if (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.UseMargins"), 0) != 0) {X_Margins_Minimap = Left_MM_Margin;}; + entranceX = OTRGetRectDimensionFromLeftEdge(newX + X_Margins_Minimap + CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosX"), 0)); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosType"), 0) == 2) { // Anchor Right + if (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.UseMargins"), 0) != 0) {X_Margins_Minimap = Right_MM_Margin;}; + entranceX = OTRGetRectDimensionFromRightEdge(newX + X_Margins_Minimap + CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosX"), 0)); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosType"), 0) == 3) { // Anchor None + entranceX = newX + X_Margins_Minimap + CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosX"), 0); } } @@ -934,19 +934,19 @@ void Minimap_Draw(PlayState* play) { } } - s16 origX = CVarGetInteger("gMirroredWorld", 0) ? 256 : 270; + s16 origX = CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0) ? 256 : 270; s16 entranceX = OTRGetRectDimensionFromRightEdge(origX + X_Margins_Minimap); s16 entranceY = 154 + Y_Margins_Minimap; - if (CVarGetInteger(CVAR_COSMETIC("Minimap.PosType"), 0) != 0) { - entranceY = 154 + Y_Margins_Minimap + CVarGetInteger(CVAR_COSMETIC("Minimap.PosY"), 0); - if (CVarGetInteger(CVAR_COSMETIC("Minimap.PosType"), 0) == 1) {//Anchor Left - if (CVarGetInteger(CVAR_COSMETIC("Minimap.UseMargins"), 0) != 0) {X_Margins_Minimap = Left_MM_Margin;}; - entranceX = OTRGetRectDimensionFromLeftEdge(origX + X_Margins_Minimap + CVarGetInteger(CVAR_COSMETIC("Minimap.PosX"), 0)); - } else if (CVarGetInteger(CVAR_COSMETIC("Minimap.PosType"), 0) == 2) {//Anchor Right - if (CVarGetInteger(CVAR_COSMETIC("Minimap.UseMargins"), 0) != 0) {X_Margins_Minimap = Right_MM_Margin;}; - entranceX = OTRGetRectDimensionFromRightEdge(origX + X_Margins_Minimap + CVarGetInteger(CVAR_COSMETIC("Minimap.PosX"), 0)); - } else if (CVarGetInteger(CVAR_COSMETIC("Minimap.PosType"), 0) == 3) {//Anchor None - entranceX = origX + X_Margins_Minimap + CVarGetInteger(CVAR_COSMETIC("Minimap.PosX"), 0); + if (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosType"), 0) != 0) { + entranceY = 154 + Y_Margins_Minimap + CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosY"), 0); + if (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosType"), 0) == 1) {//Anchor Left + if (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.UseMargins"), 0) != 0) {X_Margins_Minimap = Left_MM_Margin;}; + entranceX = OTRGetRectDimensionFromLeftEdge(origX + X_Margins_Minimap + CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosX"), 0)); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosType"), 0) == 2) {//Anchor Right + if (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.UseMargins"), 0) != 0) {X_Margins_Minimap = Right_MM_Margin;}; + entranceX = OTRGetRectDimensionFromRightEdge(origX + X_Margins_Minimap + CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosX"), 0)); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosType"), 0) == 3) {//Anchor None + entranceX = origX + X_Margins_Minimap + CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosX"), 0); } } @@ -992,10 +992,10 @@ void Map_Update(PlayState* play) { s16 floor; s16 i; - Top_MM_Margin = CVarGetInteger("gHUDMargin_T", 0); - Left_MM_Margin = CVarGetInteger("gHUDMargin_L", 0); - Right_MM_Margin = CVarGetInteger("gHUDMargin_R", 0); - Bottom_MM_Margin = CVarGetInteger("gHUDMargin_B", 0); + Top_MM_Margin = CVarGetInteger(CVAR_COSMETIC("HUD.Margin.T"), 0); + Left_MM_Margin = CVarGetInteger(CVAR_COSMETIC("HUD.Margin.L"), 0); + Right_MM_Margin = CVarGetInteger(CVAR_COSMETIC("HUD.Margin.R"), 0); + Bottom_MM_Margin = CVarGetInteger(CVAR_COSMETIC("HUD.Margin.B"), 0); if ((play->pauseCtx.state == 0) && (play->pauseCtx.debugState == 0)) { switch (play->sceneNum) { diff --git a/soh/src/code/z_map_mark.c b/soh/src/code/z_map_mark.c index c9d5d753fef..df8ef44643d 100644 --- a/soh/src/code/z_map_mark.c +++ b/soh/src/code/z_map_mark.c @@ -113,15 +113,15 @@ void MapMark_DrawForDungeon(PlayState* play) { gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->minimapAlpha); gDPSetEnvColor(OVERLAY_DISP++, 0, 0, 0, interfaceCtx->minimapAlpha); - s32 Top_MC_Margin = CVarGetInteger("gHUDMargin_T", 0); - s32 Left_MC_Margin = CVarGetInteger("gHUDMargin_L", 0); - s32 Right_MC_Margin = CVarGetInteger("gHUDMargin_R", 0); - s32 Bottom_MC_Margin = CVarGetInteger("gHUDMargin_B", 0); + s32 Top_MC_Margin = CVarGetInteger(CVAR_COSMETIC("HUD.Margin.T"), 0); + s32 Left_MC_Margin = CVarGetInteger(CVAR_COSMETIC("HUD.Margin.L"), 0); + s32 Right_MC_Margin = CVarGetInteger(CVAR_COSMETIC("HUD.Margin.R"), 0); + s32 Bottom_MC_Margin = CVarGetInteger(CVAR_COSMETIC("HUD.Margin.B"), 0); s32 X_Margins_Minimap_ic; s32 Y_Margins_Minimap_ic; - if (CVarGetInteger(CVAR_COSMETIC("Minimap.UseMargins"), 0) != 0) { - if (CVarGetInteger(CVAR_COSMETIC("Minimap.PosType"), 0) == 0) {X_Margins_Minimap_ic = Right_MC_Margin;}; + if (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.UseMargins"), 0) != 0) { + if (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosType"), 0) == 0) {X_Margins_Minimap_ic = Right_MC_Margin;}; Y_Margins_Minimap_ic = Bottom_MC_Margin; } else { X_Margins_Minimap_ic = 0; @@ -141,29 +141,29 @@ void MapMark_DrawForDungeon(PlayState* play) { // The original mark point X originates from the left edge of the map // For mirror mode, we compute the new mark point X by subtracting it from the right side of the // dungeon map and the textures width - s16 markPointX = CVarGetInteger("gMirroredWorld", 0) ? 96 - markPoint->x - width : markPoint->x; + s16 markPointX = CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0) ? 96 - markPoint->x - width : markPoint->x; //Minimap chest / boss icon const s32 PosX_Minimap_ori = GREG(94) + OTRGetRectDimensionFromRightEdge(markPointX+X_Margins_Minimap_ic) + 204; const s32 PosY_Minimap_ori = GREG(95) + markPoint->y + Y_Margins_Minimap_ic + 140; - if (CVarGetInteger(CVAR_COSMETIC("Minimap.PosType"), 0) != 0) { - rectTop = (markPoint->y + Y_Margins_Minimap_ic + 140 + CVarGetInteger(CVAR_COSMETIC("Minimap.PosY"), 0)); - if (CVarGetInteger(CVAR_COSMETIC("Minimap.PosType"), 0) == 1) {//Anchor Left - if (CVarGetInteger(CVAR_COSMETIC("Minimap.UseMargins"), 0) != 0) {X_Margins_Minimap_ic = Left_MC_Margin;}; + if (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosType"), 0) != 0) { + rectTop = (markPoint->y + Y_Margins_Minimap_ic + 140 + CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosY"), 0)); + if (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosType"), 0) == 1) {//Anchor Left + if (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.UseMargins"), 0) != 0) {X_Margins_Minimap_ic = Left_MC_Margin;}; if (play->sceneNum == SCENE_DEKU_TREE || play->sceneNum == SCENE_DODONGOS_CAVERN || play->sceneNum == SCENE_JABU_JABU || play->sceneNum == SCENE_FOREST_TEMPLE || play->sceneNum == SCENE_FIRE_TEMPLE || play->sceneNum == SCENE_WATER_TEMPLE || play->sceneNum == SCENE_SPIRIT_TEMPLE || play->sceneNum == SCENE_SHADOW_TEMPLE || play->sceneNum == SCENE_BOTTOM_OF_THE_WELL || play->sceneNum == SCENE_ICE_CAVERN) { - rectLeft = OTRGetRectDimensionFromLeftEdge(markPointX+CVarGetInteger(CVAR_COSMETIC("Minimap.PosX"), 0)+204+X_Margins_Minimap_ic); + rectLeft = OTRGetRectDimensionFromLeftEdge(markPointX+CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosX"), 0)+204+X_Margins_Minimap_ic); } else { - rectLeft = OTRGetRectDimensionFromLeftEdge(markPointX+CVarGetInteger(CVAR_COSMETIC("Minimap.PosX"), 0)+204+X_Margins_Minimap_ic); + rectLeft = OTRGetRectDimensionFromLeftEdge(markPointX+CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosX"), 0)+204+X_Margins_Minimap_ic); } - } else if (CVarGetInteger(CVAR_COSMETIC("Minimap.PosType"), 0) == 2) {//Anchor Right - if (CVarGetInteger(CVAR_COSMETIC("Minimap.UseMargins"), 0) != 0) {X_Margins_Minimap_ic = Right_MC_Margin;}; - rectLeft = OTRGetRectDimensionFromRightEdge(markPointX+CVarGetInteger(CVAR_COSMETIC("Minimap.PosX"), 0)+204+X_Margins_Minimap_ic); - } else if (CVarGetInteger(CVAR_COSMETIC("Minimap.PosType"), 0) == 3) {//Anchor None - rectLeft = markPointX+CVarGetInteger(CVAR_COSMETIC("Minimap.PosX"), 0)+204+X_Margins_Minimap_ic; - } else if (CVarGetInteger(CVAR_COSMETIC("Minimap.PosType"), 0) == 4) {//Hidden + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosType"), 0) == 2) {//Anchor Right + if (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.UseMargins"), 0) != 0) {X_Margins_Minimap_ic = Right_MC_Margin;}; + rectLeft = OTRGetRectDimensionFromRightEdge(markPointX+CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosX"), 0)+204+X_Margins_Minimap_ic); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosType"), 0) == 3) {//Anchor None + rectLeft = markPointX+CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosX"), 0)+204+X_Margins_Minimap_ic; + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosType"), 0) == 4) {//Hidden rectLeft = -9999; } } else { diff --git a/soh/src/code/z_message_PAL.c b/soh/src/code/z_message_PAL.c index 3a77fb35f73..c6b1415f627 100644 --- a/soh/src/code/z_message_PAL.c +++ b/soh/src/code/z_message_PAL.c @@ -187,7 +187,7 @@ void Message_HandleChoiceSelection(PlayState* play, u8 numChoices) { static s16 sAnalogStickHeld = false; MessageContext* msgCtx = &play->msgCtx; Input* input = &play->state.input[0]; - bool dpad = CVarGetInteger("gDpadText", 0); + bool dpad = CVarGetInteger(CVAR_SETTING("DpadInText"), 0); if ((input->rel.stick_y >= 30 && !sAnalogStickHeld) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DUP))) { sAnalogStickHeld = true; diff --git a/soh/src/code/z_parameter.c b/soh/src/code/z_parameter.c index 9b8f8504230..d6d84486d1a 100644 --- a/soh/src/code/z_parameter.c +++ b/soh/src/code/z_parameter.c @@ -1539,7 +1539,7 @@ void Inventory_SwapAgeEquipment(void) { // When using enhancements, set swordless flag if player doesn't have kokiri sword or hasn't equipped a sword yet. // Then set the child equips button items to item none to ensure kokiri sword is not equipped - if ((CVarGetInteger(CVAR_GENERAL("SwitchAge"), 0) || CVarGetInteger("gSwitchTimeline", 0)) && (CHECK_OWNED_EQUIP(EQUIP_TYPE_SWORD, EQUIP_INV_SWORD_KOKIRI) == 0 || Flags_GetInfTable(INFTABLE_SWORDLESS))) { + if ((CVarGetInteger(CVAR_GENERAL("SwitchAge"), 0) || CVarGetInteger(CVAR_GENERAL("SwitchTimeline"), 0)) && (CHECK_OWNED_EQUIP(EQUIP_TYPE_SWORD, EQUIP_INV_SWORD_KOKIRI) == 0 || Flags_GetInfTable(INFTABLE_SWORDLESS))) { Flags_SetInfTable(INFTABLE_SWORDLESS); gSaveContext.childEquips.buttonItems[0] = ITEM_NONE; } @@ -1554,7 +1554,7 @@ void Inventory_SwapAgeEquipment(void) { gSaveContext.adultEquips.equipment = gSaveContext.equips.equipment; // Switching age using enhancements separated out to make vanilla flow clear - if (CVarGetInteger(CVAR_GENERAL("SwitchAge"), 0) || CVarGetInteger("gSwitchTimeline", 0)) { + if (CVarGetInteger(CVAR_GENERAL("SwitchAge"), 0) || CVarGetInteger(CVAR_GENERAL("SwitchTimeline"), 0)) { for (i = 0; i < ARRAY_COUNT(gSaveContext.equips.buttonItems); i++) { gSaveContext.equips.buttonItems[i] = gSaveContext.childEquips.buttonItems[i]; @@ -1629,7 +1629,7 @@ void Inventory_SwapAgeEquipment(void) { (EQUIP_VALUE_BOOTS_KOKIRI << (EQUIP_TYPE_BOOTS * 4)); } - if ((CVarGetInteger(CVAR_GENERAL("SwitchAge"), 0) || CVarGetInteger("gSwitchTimeline", 0)) && + if ((CVarGetInteger(CVAR_GENERAL("SwitchAge"), 0) || CVarGetInteger(CVAR_GENERAL("SwitchTimeline"), 0)) && (gSaveContext.equips.buttonItems[0] == ITEM_NONE)) { Flags_SetInfTable(INFTABLE_SWORDLESS); if (gSaveContext.childEquips.equipment == 0) { @@ -1640,7 +1640,7 @@ void Inventory_SwapAgeEquipment(void) { } } } - CVarSetInteger("gSwitchTimeline", 0); + CVarSetInteger(CVAR_GENERAL("SwitchTimeline"), 0); shieldEquipValue = gEquipMasks[EQUIP_TYPE_SHIELD] & gSaveContext.equips.equipment; if (shieldEquipValue != 0) { shieldEquipValue >>= gEquipShifts[EQUIP_TYPE_SHIELD]; @@ -3495,7 +3495,7 @@ void Interface_UpdateMagicBar(PlayState* play) { (msgCtx->msgMode == MSGMODE_NONE) && (play->gameOverCtx.state == GAMEOVER_INACTIVE) && (play->transitionTrigger == TRANS_TRIGGER_OFF) && (play->transitionMode == TRANS_MODE_OFF) && !Play_InCsMode(play)) { bool hasLens = false; - for (int buttonIndex = 1; buttonIndex < (CVarGetInteger("gDpadEquips", 0) != 0) ? ARRAY_COUNT(gSaveContext.equips.buttonItems) : 4; buttonIndex++) { + for (int buttonIndex = 1; buttonIndex < (CVarGetInteger(CVAR_SETTING("DpadEquips"), 0) != 0) ? ARRAY_COUNT(gSaveContext.equips.buttonItems) : 4; buttonIndex++) { if (gSaveContext.equips.buttonItems[buttonIndex] == ITEM_LENS) { hasLens = true; break; @@ -3616,7 +3616,7 @@ void Interface_DrawMagicBar(PlayState* play) { if (gSaveContext.magicLevel != 0) { s16 X_Margins; s16 Y_Margins; - if (CVarGetInteger(CVAR_COSMETIC("MagicBar.UseMargins"), 0) != 0) { + if (CVarGetInteger(CVAR_COSMETIC("HUD.MagicBar.UseMargins"), 0) != 0) { X_Margins = Left_HUD_Margin; Y_Margins = (Top_HUD_Margin*-1); } else { @@ -3634,40 +3634,40 @@ void Interface_DrawMagicBar(PlayState* play) { s16 rMagicBarX; s16 PosX_MidEnd; s16 rMagicFillX; - s32 lineLength = CVarGetInteger(CVAR_COSMETIC("Hearts.LineLength"), 10); - if (CVarGetInteger(CVAR_COSMETIC("MagicBar.PosType"), 0) != 0) { - magicBarY = CVarGetInteger(CVAR_COSMETIC("MagicBar.PosY"), 0)+Y_Margins; - if (CVarGetInteger(CVAR_COSMETIC("MagicBar.PosType"), 0) == 1) {//Anchor Left - if (CVarGetInteger(CVAR_COSMETIC("MagicBar.UseMargins"), 0) != 0) {X_Margins = Left_HUD_Margin;}; - PosX_Start = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("MagicBar.PosX"), 0)+X_Margins); - rMagicBarX = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("MagicBar.PosX"), 0)+X_Margins); - PosX_MidEnd = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("MagicBar.PosX"), 0)+X_Margins+8); - rMagicFillX = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("MagicBar.PosX"), 0)+X_Margins+8); - } else if (CVarGetInteger(CVAR_COSMETIC("MagicBar.PosType"), 0) == 2) {//Anchor Right - if (CVarGetInteger(CVAR_COSMETIC("MagicBar.UseMargins"), 0) != 0) {X_Margins = Right_HUD_Margin;}; - PosX_Start = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("MagicBar.PosX"), 0)+X_Margins); - rMagicBarX = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("MagicBar.PosX"), 0)+X_Margins); - PosX_MidEnd = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("MagicBar.PosX"), 0)+X_Margins+8); - rMagicFillX = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("MagicBar.PosX"), 0)+X_Margins+8); - } else if (CVarGetInteger(CVAR_COSMETIC("MagicBar.PosType"), 0) == 3) {//Anchor None - PosX_Start = CVarGetInteger(CVAR_COSMETIC("MagicBar.PosX"), 0)+X_Margins; - rMagicBarX = CVarGetInteger(CVAR_COSMETIC("MagicBar.PosX"), 0)+X_Margins; - PosX_MidEnd = CVarGetInteger(CVAR_COSMETIC("MagicBar.PosX"), 0)+X_Margins+8; - rMagicFillX = CVarGetInteger(CVAR_COSMETIC("MagicBar.PosX"), 0)+X_Margins+8; - } else if (CVarGetInteger(CVAR_COSMETIC("MagicBar.PosType"), 0) == 4) {//hidden + s32 lineLength = CVarGetInteger(CVAR_COSMETIC("HUD.Hearts.LineLength"), 10); + if (CVarGetInteger(CVAR_COSMETIC("HUD.MagicBar.PosType"), 0) != 0) { + magicBarY = CVarGetInteger(CVAR_COSMETIC("HUD.MagicBar.PosY"), 0)+Y_Margins; + if (CVarGetInteger(CVAR_COSMETIC("HUD.MagicBar.PosType"), 0) == 1) {//Anchor Left + if (CVarGetInteger(CVAR_COSMETIC("HUD.MagicBar.UseMargins"), 0) != 0) {X_Margins = Left_HUD_Margin;}; + PosX_Start = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("HUD.MagicBar.PosX"), 0)+X_Margins); + rMagicBarX = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("HUD.MagicBar.PosX"), 0)+X_Margins); + PosX_MidEnd = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("HUD.MagicBar.PosX"), 0)+X_Margins+8); + rMagicFillX = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("HUD.MagicBar.PosX"), 0)+X_Margins+8); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.MagicBar.PosType"), 0) == 2) {//Anchor Right + if (CVarGetInteger(CVAR_COSMETIC("HUD.MagicBar.UseMargins"), 0) != 0) {X_Margins = Right_HUD_Margin;}; + PosX_Start = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("HUD.MagicBar.PosX"), 0)+X_Margins); + rMagicBarX = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("HUD.MagicBar.PosX"), 0)+X_Margins); + PosX_MidEnd = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("HUD.MagicBar.PosX"), 0)+X_Margins+8); + rMagicFillX = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("HUD.MagicBar.PosX"), 0)+X_Margins+8); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.MagicBar.PosType"), 0) == 3) {//Anchor None + PosX_Start = CVarGetInteger(CVAR_COSMETIC("HUD.MagicBar.PosX"), 0)+X_Margins; + rMagicBarX = CVarGetInteger(CVAR_COSMETIC("HUD.MagicBar.PosX"), 0)+X_Margins; + PosX_MidEnd = CVarGetInteger(CVAR_COSMETIC("HUD.MagicBar.PosX"), 0)+X_Margins+8; + rMagicFillX = CVarGetInteger(CVAR_COSMETIC("HUD.MagicBar.PosX"), 0)+X_Margins+8; + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.MagicBar.PosType"), 0) == 4) {//hidden PosX_Start = -9999; rMagicBarX = -9999; PosX_MidEnd = -9999; rMagicFillX = -9999; - } else if (CVarGetInteger(CVAR_COSMETIC("MagicBar.PosType"), 0) == 5) {//Anchor To life meter + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.MagicBar.PosType"), 0) == 5) {//Anchor To life meter magicBarY = R_MAGIC_BAR_SMALL_Y-2 + magicDrop*(lineLength == 0 ? 0 : (gSaveContext.healthCapacity-1)/(0x10*lineLength)) + - CVarGetInteger(CVAR_COSMETIC("MagicBar.PosY"), 0) + getHealthMeterYOffset(); - s16 xPushover = CVarGetInteger(CVAR_COSMETIC("MagicBar.PosX"), 0) + getHealthMeterXOffset() + R_MAGIC_BAR_X-1; + CVarGetInteger(CVAR_COSMETIC("HUD.MagicBar.PosY"), 0) + getHealthMeterYOffset(); + s16 xPushover = CVarGetInteger(CVAR_COSMETIC("HUD.MagicBar.PosX"), 0) + getHealthMeterXOffset() + R_MAGIC_BAR_X-1; PosX_Start = xPushover; rMagicBarX = xPushover; PosX_MidEnd = xPushover+8; - rMagicFillX = CVarGetInteger(CVAR_COSMETIC("MagicBar.PosX"), 0) + getHealthMeterXOffset() + R_MAGIC_FILL_X-1; + rMagicFillX = CVarGetInteger(CVAR_COSMETIC("HUD.MagicBar.PosX"), 0) + getHealthMeterXOffset() + R_MAGIC_FILL_X-1; } } else { if ((gSaveContext.healthCapacity-1)/0x10 >= lineLength && lineLength != 0) { @@ -3780,18 +3780,18 @@ void Interface_DrawEnemyHealthBar(TargetContext* targetCtx, PlayState* play) { Color_RGBA8 healthbar_border = { 255, 255, 255, 255 }; s16 healthbar_fillWidth = 64; s16 healthbar_actorOffset = 40; - s32 healthbar_offsetX = CVarGetInteger(CVAR_COSMETIC("HUD.EnemyHealthBarPosX"), 0); - s32 healthbar_offsetY = CVarGetInteger(CVAR_COSMETIC("HUD.EnemyHealthBarPosY"), 0); - s8 anchorType = CVarGetInteger(CVAR_COSMETIC("HUD.EnemyHealthBarPosType"), ENEMYHEALTH_ANCHOR_ACTOR); + s32 healthbar_offsetX = CVarGetInteger(CVAR_COSMETIC("HUD.EnemyHealthBar.PosX"), 0); + s32 healthbar_offsetY = CVarGetInteger(CVAR_COSMETIC("HUD.EnemyHealthBar.PosY"), 0); + s8 anchorType = CVarGetInteger(CVAR_COSMETIC("HUD.EnemyHealthBar.PosType"), ENEMYHEALTH_ANCHOR_ACTOR); - if (CVarGetInteger(CVAR_COSMETIC("HUD.EnemyHealthBar.Changed"), 0)) { - healthbar_red = CVarGetColor(CVAR_COSMETIC("HUD.EnemyHealthBar.Value"), healthbar_red); + if (CVarGetInteger(CVAR_COSMETIC("HUD.EnemyHealthBar..Changed"), 0)) { + healthbar_red = CVarGetColor(CVAR_COSMETIC("HUD.EnemyHealthBar..Value"), healthbar_red); } if (CVarGetInteger(CVAR_COSMETIC("HUD.EnemyHealthBorder.Changed"), 0)) { healthbar_border = CVarGetColor(CVAR_COSMETIC("HUD.EnemyHealthBorder.Value"), healthbar_border); } - if (CVarGetInteger(CVAR_COSMETIC("HUD.EnemyHealthBarWidth.Changed"), 0)) { - healthbar_fillWidth = CVarGetInteger(CVAR_COSMETIC("HUD.EnemyHealthBarWidth.Value"), healthbar_fillWidth); + if (CVarGetInteger(CVAR_COSMETIC("HUD.EnemyHealthBar.Width.Changed"), 0)) { + healthbar_fillWidth = CVarGetInteger(CVAR_COSMETIC("HUD.EnemyHealthBar.Width.Value"), healthbar_fillWidth); } OPEN_DISPS(play->state.gfxCtx); @@ -3809,7 +3809,7 @@ void Interface_DrawEnemyHealthBar(TargetContext* targetCtx, PlayState* play) { func_8002BE04(play, &targetCtx->targetCenterPos, &projTargetCenter, &projTargetCappedInvW); projTargetCenter.x = (SCREEN_WIDTH / 2) * (projTargetCenter.x * projTargetCappedInvW); - projTargetCenter.x = projTargetCenter.x * (CVarGetInteger("gMirroredWorld", 0) ? -1 : 1); + projTargetCenter.x = projTargetCenter.x * (CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0) ? -1 : 1); projTargetCenter.x = CLAMP(projTargetCenter.x, (-SCREEN_WIDTH / 2) + halfBarWidth, (SCREEN_WIDTH / 2) - halfBarWidth); @@ -4010,12 +4010,12 @@ void Interface_DrawItemButtons(PlayState* play) { s16 Y_Margins_BtnB; s16 BBtn_Size = 32; int BBtnScaled = BBtn_Size * 0.95f; - if (CVarGetInteger(CVAR_COSMETIC("BButton.PosType"), 0) != 0) { - BBtnScaled = BBtn_Size * CVarGetFloat(CVAR_COSMETIC("BButton.Scale"), 0.95f); + if (CVarGetInteger(CVAR_COSMETIC("HUD.BButton.PosType"), 0) != 0) { + BBtnScaled = BBtn_Size * CVarGetFloat(CVAR_COSMETIC("HUD.BButton.Scale"), 0.95f); } int BBtn_factor = (1 << 10) * BBtn_Size / BBtnScaled; - if (CVarGetInteger(CVAR_COSMETIC("BButton.UseMargins"), 0) != 0) { - if (CVarGetInteger(CVAR_COSMETIC("BButton.PosType"), 0) == 0) {X_Margins_BtnB = Right_HUD_Margin;}; + if (CVarGetInteger(CVAR_COSMETIC("HUD.BButton.UseMargins"), 0) != 0) { + if (CVarGetInteger(CVAR_COSMETIC("HUD.BButton.PosType"), 0) == 0) {X_Margins_BtnB = Right_HUD_Margin;}; Y_Margins_BtnB = (Top_HUD_Margin*-1); } else { X_Margins_BtnB = 0; @@ -4025,17 +4025,17 @@ void Interface_DrawItemButtons(PlayState* play) { s16 PosY_BtnB_ori = R_ITEM_BTN_Y(0)+Y_Margins_BtnB; s16 PosX_BtnB; s16 PosY_BtnB; - if (CVarGetInteger(CVAR_COSMETIC("BButton.PosType"), 0) != 0) { - PosY_BtnB = CVarGetInteger(CVAR_COSMETIC("BButton.PosY"), 0)+Y_Margins_BtnB; - if (CVarGetInteger(CVAR_COSMETIC("BButton.PosType"), 0) == 1) {//Anchor Left - if (CVarGetInteger(CVAR_COSMETIC("BButton.UseMargins"), 0) != 0) {X_Margins_BtnB = Left_HUD_Margin;}; - PosX_BtnB = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("BButton.PosX"), 0)+X_Margins_BtnB); - } else if (CVarGetInteger(CVAR_COSMETIC("BButton.PosType"), 0) == 2) {//Anchor Right - if (CVarGetInteger(CVAR_COSMETIC("BButton.UseMargins"), 0) != 0) {X_Margins_BtnB = Right_HUD_Margin;}; - PosX_BtnB = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("BButton.PosX"), 0)+X_Margins_BtnB); - } else if (CVarGetInteger(CVAR_COSMETIC("BButton.PosType"), 0) == 3) {//Anchor None - PosX_BtnB = CVarGetInteger(CVAR_COSMETIC("BButton.PosX"), 0); - } else if (CVarGetInteger(CVAR_COSMETIC("BButton.PosType"), 0) == 4) {//Hidden + if (CVarGetInteger(CVAR_COSMETIC("HUD.BButton.PosType"), 0) != 0) { + PosY_BtnB = CVarGetInteger(CVAR_COSMETIC("HUD.BButton.PosY"), 0)+Y_Margins_BtnB; + if (CVarGetInteger(CVAR_COSMETIC("HUD.BButton.PosType"), 0) == 1) {//Anchor Left + if (CVarGetInteger(CVAR_COSMETIC("HUD.BButton.UseMargins"), 0) != 0) {X_Margins_BtnB = Left_HUD_Margin;}; + PosX_BtnB = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("HUD.BButton.PosX"), 0)+X_Margins_BtnB); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.BButton.PosType"), 0) == 2) {//Anchor Right + if (CVarGetInteger(CVAR_COSMETIC("HUD.BButton.UseMargins"), 0) != 0) {X_Margins_BtnB = Right_HUD_Margin;}; + PosX_BtnB = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("HUD.BButton.PosX"), 0)+X_Margins_BtnB); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.BButton.PosType"), 0) == 3) {//Anchor None + PosX_BtnB = CVarGetInteger(CVAR_COSMETIC("HUD.BButton.PosX"), 0); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.BButton.PosType"), 0) == 4) {//Hidden PosX_BtnB = -9999; } } else { @@ -4045,8 +4045,8 @@ void Interface_DrawItemButtons(PlayState* play) { //Start Button s16 X_Margins_StartBtn; s16 Y_Margins_StartBtn; - if (CVarGetInteger(CVAR_COSMETIC("StartButton.UseMargins"), 0) != 0) { - if (CVarGetInteger(CVAR_COSMETIC("StartButton.PosType"), 0) == 0) { + if (CVarGetInteger(CVAR_COSMETIC("HUD.StartButton.UseMargins"), 0) != 0) { + if (CVarGetInteger(CVAR_COSMETIC("HUD.StartButton.PosType"), 0) == 0) { X_Margins_StartBtn = Right_HUD_Margin; }; Y_Margins_StartBtn = Top_HUD_Margin*-1; @@ -4057,8 +4057,8 @@ void Interface_DrawItemButtons(PlayState* play) { s16 StartBtn_Icon_H = 32; s16 StartBtn_Icon_W = 32; float Start_BTN_Scale = 0.75f; - if (CVarGetInteger(CVAR_COSMETIC("StartButton.PosType"), 0) != 0) { - Start_BTN_Scale = CVarGetFloat(CVAR_COSMETIC("StartButton.Scale"), 0.75f); + if (CVarGetInteger(CVAR_COSMETIC("HUD.StartButton.PosType"), 0) != 0) { + Start_BTN_Scale = CVarGetFloat(CVAR_COSMETIC("HUD.StartButton.Scale"), 0.75f); } int StartBTN_H_Scaled = StartBtn_Icon_H * Start_BTN_Scale; int StartBTN_W_Scaled = StartBtn_Icon_W * Start_BTN_Scale; @@ -4070,17 +4070,17 @@ void Interface_DrawItemButtons(PlayState* play) { s16 StartBTN_Label_H = DO_ACTION_TEX_HEIGHT(); s16 PosX_StartBtn; s16 PosY_StartBtn; - if (CVarGetInteger(CVAR_COSMETIC("StartButton.PosType"), 0) != 0) { - PosY_StartBtn = CVarGetInteger(CVAR_COSMETIC("StartButton.PosY"), 0)-(Start_BTN_Scale*13)+Y_Margins_StartBtn; - if (CVarGetInteger(CVAR_COSMETIC("StartButton.PosType"), 0) == 1) {//Anchor Left - if (CVarGetInteger(CVAR_COSMETIC("StartButton.UseMargins"), 0) != 0) {X_Margins_StartBtn = Left_HUD_Margin;}; - PosX_StartBtn = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("StartButton.PosX"), 0)-(Start_BTN_Scale*13)+X_Margins_StartBtn); - } else if (CVarGetInteger(CVAR_COSMETIC("StartButton.PosType"), 0) == 2) {//Anchor Right - if (CVarGetInteger(CVAR_COSMETIC("StartButton.UseMargins"), 0) != 0) {X_Margins_StartBtn = Right_HUD_Margin;}; - PosX_StartBtn = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("StartButton.PosX"), 0)-(Start_BTN_Scale*13)+X_Margins_StartBtn); - } else if (CVarGetInteger(CVAR_COSMETIC("StartButton.PosType"), 0) == 3) {//Anchor None - PosX_StartBtn = CVarGetInteger(CVAR_COSMETIC("StartButton.PosX"), 0); - } else if (CVarGetInteger(CVAR_COSMETIC("StartButton.PosType"), 0) == 4) {//Hidden + if (CVarGetInteger(CVAR_COSMETIC("HUD.StartButton.PosType"), 0) != 0) { + PosY_StartBtn = CVarGetInteger(CVAR_COSMETIC("HUD.StartButton.PosY"), 0)-(Start_BTN_Scale*13)+Y_Margins_StartBtn; + if (CVarGetInteger(CVAR_COSMETIC("HUD.StartButton.PosType"), 0) == 1) {//Anchor Left + if (CVarGetInteger(CVAR_COSMETIC("HUD.StartButton.UseMargins"), 0) != 0) {X_Margins_StartBtn = Left_HUD_Margin;}; + PosX_StartBtn = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("HUD.StartButton.PosX"), 0)-(Start_BTN_Scale*13)+X_Margins_StartBtn); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.StartButton.PosType"), 0) == 2) {//Anchor Right + if (CVarGetInteger(CVAR_COSMETIC("HUD.StartButton.UseMargins"), 0) != 0) {X_Margins_StartBtn = Right_HUD_Margin;}; + PosX_StartBtn = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("HUD.StartButton.PosX"), 0)-(Start_BTN_Scale*13)+X_Margins_StartBtn); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.StartButton.PosType"), 0) == 3) {//Anchor None + PosX_StartBtn = CVarGetInteger(CVAR_COSMETIC("HUD.StartButton.PosX"), 0); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.StartButton.PosType"), 0) == 4) {//Hidden PosX_StartBtn = -9999; } } else { @@ -4100,29 +4100,29 @@ void Interface_DrawItemButtons(PlayState* play) { s16 Y_Margins_CR; s16 Y_Margins_CU; s16 Y_Margins_CD; - if (CVarGetInteger(CVAR_COSMETIC("CLeftButton.UseMargins"), 0) != 0) { - if (CVarGetInteger(CVAR_COSMETIC("CLeftButton.PosType"), 0) == 0) {X_Margins_CL = Right_HUD_Margin;}; + if (CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.UseMargins"), 0) != 0) { + if (CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.PosType"), 0) == 0) {X_Margins_CL = Right_HUD_Margin;}; Y_Margins_CL = (Top_HUD_Margin*-1); } else { X_Margins_CL = 0; Y_Margins_CL = 0; } - if (CVarGetInteger(CVAR_COSMETIC("CRightButton.UseMargins"), 0) != 0) { - if (CVarGetInteger(CVAR_COSMETIC("CRightButton.PosType"), 0) == 0) {X_Margins_CR = Right_HUD_Margin;}; + if (CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.UseMargins"), 0) != 0) { + if (CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.PosType"), 0) == 0) {X_Margins_CR = Right_HUD_Margin;}; Y_Margins_CR = (Top_HUD_Margin*-1); } else { X_Margins_CR = 0; Y_Margins_CR = 0; } - if (CVarGetInteger(CVAR_COSMETIC("CUpButton.UseMargins"), 0) != 0) { - if (CVarGetInteger(CVAR_COSMETIC("CUpButton.PosType"), 0) == 0) {X_Margins_CU = Right_HUD_Margin;}; + if (CVarGetInteger(CVAR_COSMETIC("HUD.CUpButton.UseMargins"), 0) != 0) { + if (CVarGetInteger(CVAR_COSMETIC("HUD.CUpButton.PosType"), 0) == 0) {X_Margins_CU = Right_HUD_Margin;}; Y_Margins_CU = (Top_HUD_Margin*-1); } else { X_Margins_CU = 0; Y_Margins_CU = 0; } - if (CVarGetInteger(CVAR_COSMETIC("CDownButton.UseMargins"), 0) != 0) { - if (CVarGetInteger(CVAR_COSMETIC("CDownButton.PosType"), 0) == 0) {X_Margins_CD = Right_HUD_Margin;}; + if (CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.UseMargins"), 0) != 0) { + if (CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.PosType"), 0) == 0) {X_Margins_CD = Right_HUD_Margin;}; Y_Margins_CD = (Top_HUD_Margin*-1); } else { X_Margins_CD = 0; @@ -4140,23 +4140,23 @@ void Interface_DrawItemButtons(PlayState* play) { s16 C_Down_BTN_Pos[2]; //C button Left s16 C_Left_BTN_Size = 32; - float CLeftScale = CVarGetFloat(CVAR_COSMETIC("CLeftButton.Scale"), 0.87f); + float CLeftScale = CVarGetFloat(CVAR_COSMETIC("HUD.CLeftButton.Scale"), 0.87f); int CLeftScaled = C_Left_BTN_Size * 0.87f; - if (CVarGetInteger(CVAR_COSMETIC("CLeftButton.PosType"), 0) != 0) { + if (CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.PosType"), 0) != 0) { CLeftScaled = C_Left_BTN_Size * CLeftScale; } int CLeft_factor = (1 << 10) * C_Left_BTN_Size / CLeftScaled; - if (CVarGetInteger(CVAR_COSMETIC("CLeftButton.PosType"), 0) != 0) { - C_Left_BTN_Pos[1] = CVarGetInteger(CVAR_COSMETIC("CLeftButton.PosY"), 0)+Y_Margins_CL; - if (CVarGetInteger(CVAR_COSMETIC("CLeftButton.PosType"), 0) == 1) {//Anchor Left - if (CVarGetInteger(CVAR_COSMETIC("CLeftButton.UseMargins"), 0) != 0) {X_Margins_CL = Left_HUD_Margin;}; - C_Left_BTN_Pos[0] = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("CLeftButton.PosX"), 0)+X_Margins_CL); - } else if (CVarGetInteger(CVAR_COSMETIC("CLeftButton.PosType"), 0) == 2) {//Anchor Right - if (CVarGetInteger(CVAR_COSMETIC("CLeftButton.UseMargins"), 0) != 0) {X_Margins_CL = Right_HUD_Margin;}; - C_Left_BTN_Pos[0] = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("CLeftButton.PosX"), 0)+X_Margins_CL); - } else if (CVarGetInteger(CVAR_COSMETIC("CLeftButton.PosType"), 0) == 3) {//Anchor None - C_Left_BTN_Pos[0] = CVarGetInteger(CVAR_COSMETIC("CLeftButton.PosX"), 0); - } else if (CVarGetInteger(CVAR_COSMETIC("CLeftButton.PosType"), 0) == 4) {//Hidden + if (CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.PosType"), 0) != 0) { + C_Left_BTN_Pos[1] = CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.PosY"), 0)+Y_Margins_CL; + if (CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.PosType"), 0) == 1) {//Anchor Left + if (CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.UseMargins"), 0) != 0) {X_Margins_CL = Left_HUD_Margin;}; + C_Left_BTN_Pos[0] = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.PosX"), 0)+X_Margins_CL); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.PosType"), 0) == 2) {//Anchor Right + if (CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.UseMargins"), 0) != 0) {X_Margins_CL = Right_HUD_Margin;}; + C_Left_BTN_Pos[0] = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.PosX"), 0)+X_Margins_CL); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.PosType"), 0) == 3) {//Anchor None + C_Left_BTN_Pos[0] = CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.PosX"), 0); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.PosType"), 0) == 4) {//Hidden C_Left_BTN_Pos[0] = -9999; } } else { @@ -4165,23 +4165,23 @@ void Interface_DrawItemButtons(PlayState* play) { } //C button Right s16 C_Right_BTN_Size = 32; - float CRightScale = CVarGetFloat(CVAR_COSMETIC("CRightButton.Scale"), 0.87f); + float CRightScale = CVarGetFloat(CVAR_COSMETIC("HUD.CRightButton.Scale"), 0.87f); int CRightScaled = C_Right_BTN_Size * 0.87f; - if (CVarGetInteger(CVAR_COSMETIC("CRightButton.PosType"), 0) != 0) { + if (CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.PosType"), 0) != 0) { CRightScaled = C_Right_BTN_Size * CRightScale; } int CRight_factor = (1 << 10) * C_Right_BTN_Size / CRightScaled; - if (CVarGetInteger(CVAR_COSMETIC("CRightButton.PosType"), 0) != 0) { - C_Right_BTN_Pos[1] = CVarGetInteger(CVAR_COSMETIC("CRightButton.PosY"), 0)+Y_Margins_CR; - if (CVarGetInteger(CVAR_COSMETIC("CRightButton.PosType"), 0) == 1) {//Anchor Left - if (CVarGetInteger(CVAR_COSMETIC("CRightButton.UseMargins"), 0) != 0) {X_Margins_CR = Left_HUD_Margin;}; - C_Right_BTN_Pos[0] = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("CRightButton.PosX"), 0)+X_Margins_CR); - } else if (CVarGetInteger(CVAR_COSMETIC("CRightButton.PosType"), 0) == 2) {//Anchor Right - if (CVarGetInteger(CVAR_COSMETIC("CRightButton.UseMargins"), 0) != 0) {X_Margins_CR = Right_HUD_Margin;}; - C_Right_BTN_Pos[0] = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("CRightButton.PosX"), 0)+X_Margins_CR); - } else if (CVarGetInteger(CVAR_COSMETIC("CRightButton.PosType"), 0) == 3) {//Anchor None - C_Right_BTN_Pos[0] = CVarGetInteger(CVAR_COSMETIC("CRightButton.PosX"), 0); - } else if (CVarGetInteger(CVAR_COSMETIC("CRightButton.PosType"), 0) == 4) {//Hidden + if (CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.PosType"), 0) != 0) { + C_Right_BTN_Pos[1] = CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.PosY"), 0)+Y_Margins_CR; + if (CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.PosType"), 0) == 1) {//Anchor Left + if (CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.UseMargins"), 0) != 0) {X_Margins_CR = Left_HUD_Margin;}; + C_Right_BTN_Pos[0] = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.PosX"), 0)+X_Margins_CR); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.PosType"), 0) == 2) {//Anchor Right + if (CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.UseMargins"), 0) != 0) {X_Margins_CR = Right_HUD_Margin;}; + C_Right_BTN_Pos[0] = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.PosX"), 0)+X_Margins_CR); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.PosType"), 0) == 3) {//Anchor None + C_Right_BTN_Pos[0] = CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.PosX"), 0); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.PosType"), 0) == 4) {//Hidden C_Right_BTN_Pos[0] = -9999; } } else { @@ -4191,22 +4191,22 @@ void Interface_DrawItemButtons(PlayState* play) { //C Button Up s16 C_Up_BTN_Size = 32; int CUpScaled = C_Up_BTN_Size * 0.5f; - float CUpScale = CVarGetFloat(CVAR_COSMETIC("CUpButton.Scale"), 0.5f); - if (CVarGetInteger(CVAR_COSMETIC("CUpButton.PosType"), 0) != 0) { + float CUpScale = CVarGetFloat(CVAR_COSMETIC("HUD.CUpButton.Scale"), 0.5f); + if (CVarGetInteger(CVAR_COSMETIC("HUD.CUpButton.PosType"), 0) != 0) { CUpScaled = C_Up_BTN_Size * CUpScale; } int CUp_factor = (1 << 10) * C_Up_BTN_Size / CUpScaled; - if (CVarGetInteger(CVAR_COSMETIC("CUpButton.PosType"), 0) != 0) { - C_Up_BTN_Pos[1] = CVarGetInteger(CVAR_COSMETIC("CUpButton.PosY"), 0)+Y_Margins_CU; - if (CVarGetInteger(CVAR_COSMETIC("CUpButton.PosType"), 0) == 1) {//Anchor Left - if (CVarGetInteger(CVAR_COSMETIC("CUpButton.UseMargins"), 0) != 0) {X_Margins_CU = Left_HUD_Margin;}; - C_Up_BTN_Pos[0] = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("CUpButton.PosX"), 0)+X_Margins_CU); - } else if (CVarGetInteger(CVAR_COSMETIC("CUpButton.PosType"), 0) == 2) {//Anchor Right - if (CVarGetInteger(CVAR_COSMETIC("CUpButton.UseMargins"), 0) != 0) {X_Margins_CU = Right_HUD_Margin;}; - C_Up_BTN_Pos[0] = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("CUpButton.PosX"), 0)+X_Margins_CU); - } else if (CVarGetInteger(CVAR_COSMETIC("CUpButton.PosType"), 0) == 3) {//Anchor None - C_Up_BTN_Pos[0] = CVarGetInteger(CVAR_COSMETIC("CUpButton.PosX"), 0); - } else if (CVarGetInteger(CVAR_COSMETIC("CUpButton.PosType"), 0) == 4) {//Hidden + if (CVarGetInteger(CVAR_COSMETIC("HUD.CUpButton.PosType"), 0) != 0) { + C_Up_BTN_Pos[1] = CVarGetInteger(CVAR_COSMETIC("HUD.CUpButton.PosY"), 0)+Y_Margins_CU; + if (CVarGetInteger(CVAR_COSMETIC("HUD.CUpButton.PosType"), 0) == 1) {//Anchor Left + if (CVarGetInteger(CVAR_COSMETIC("HUD.CUpButton.UseMargins"), 0) != 0) {X_Margins_CU = Left_HUD_Margin;}; + C_Up_BTN_Pos[0] = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("HUD.CUpButton.PosX"), 0)+X_Margins_CU); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.CUpButton.PosType"), 0) == 2) {//Anchor Right + if (CVarGetInteger(CVAR_COSMETIC("HUD.CUpButton.UseMargins"), 0) != 0) {X_Margins_CU = Right_HUD_Margin;}; + C_Up_BTN_Pos[0] = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("HUD.CUpButton.PosX"), 0)+X_Margins_CU); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.CUpButton.PosType"), 0) == 3) {//Anchor None + C_Up_BTN_Pos[0] = CVarGetInteger(CVAR_COSMETIC("HUD.CUpButton.PosX"), 0); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.CUpButton.PosType"), 0) == 4) {//Hidden C_Up_BTN_Pos[0] = -9999; } } else { @@ -4215,24 +4215,24 @@ void Interface_DrawItemButtons(PlayState* play) { } //C Button down s16 C_Down_BTN_Size = 32; - float CDownScale = CVarGetFloat(CVAR_COSMETIC("CDownButton.Scale"), 0.87f); - if (CVarGetInteger(CVAR_COSMETIC("CDownButton.PosType"), 0) == 0) { + float CDownScale = CVarGetFloat(CVAR_COSMETIC("HUD.CDownButton.Scale"), 0.87f); + if (CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.PosType"), 0) == 0) { CDownScale = 0.87f; } int CDownScaled = C_Down_BTN_Size * CDownScale; int CDown_factor = (1 << 10) * C_Down_BTN_Size / CDownScaled; int PositionAdjustment = CDownScaled/2; - if (CVarGetInteger(CVAR_COSMETIC("CDownButton.PosType"), 0) != 0) { - C_Down_BTN_Pos[1] = CVarGetInteger(CVAR_COSMETIC("CDownButton.PosY"), 0)+Y_Margins_CD; - if (CVarGetInteger(CVAR_COSMETIC("CDownButton.PosType"), 0) == 1) {//Anchor Left - if (CVarGetInteger(CVAR_COSMETIC("CDownButton.UseMargins"), 0) != 0) {X_Margins_CD = Left_HUD_Margin;}; - C_Down_BTN_Pos[0] = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("CDownButton.PosX"), 0)+X_Margins_CD); - } else if (CVarGetInteger(CVAR_COSMETIC("CDownButton.PosType"), 0) == 2) {//Anchor Right - if (CVarGetInteger(CVAR_COSMETIC("CDownButton.UseMargins"), 0) != 0) {X_Margins_CD = Right_HUD_Margin;}; - C_Down_BTN_Pos[0] = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("CDownButton.PosX"), 0)+X_Margins_CD); - } else if (CVarGetInteger(CVAR_COSMETIC("CDownButton.PosType"), 0) == 3) {//Anchor None - C_Down_BTN_Pos[0] = CVarGetInteger(CVAR_COSMETIC("CDownButton.PosX"), 0); - } else if (CVarGetInteger(CVAR_COSMETIC("CDownButton.PosType"), 0) == 4) {//Hidden + if (CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.PosType"), 0) != 0) { + C_Down_BTN_Pos[1] = CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.PosY"), 0)+Y_Margins_CD; + if (CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.PosType"), 0) == 1) {//Anchor Left + if (CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.UseMargins"), 0) != 0) {X_Margins_CD = Left_HUD_Margin;}; + C_Down_BTN_Pos[0] = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.PosX"), 0)+X_Margins_CD); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.PosType"), 0) == 2) {//Anchor Right + if (CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.UseMargins"), 0) != 0) {X_Margins_CD = Right_HUD_Margin;}; + C_Down_BTN_Pos[0] = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.PosX"), 0)+X_Margins_CD); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.PosType"), 0) == 3) {//Anchor None + C_Down_BTN_Pos[0] = CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.PosX"), 0); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.PosType"), 0) == 4) {//Hidden C_Down_BTN_Pos[0] = -9999; } } else { @@ -4360,22 +4360,22 @@ void Interface_DrawItemButtons(PlayState* play) { s16 Y_Margins_CL; s16 Y_Margins_CR; s16 Y_Margins_CD; - if (CVarGetInteger(CVAR_COSMETIC("CLeftButton.UseMargins"), 0) != 0) { - if (CVarGetInteger(CVAR_COSMETIC("CLeftButton.PosType"), 0) == 0) {X_Margins_CL = Right_HUD_Margin;}; + if (CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.UseMargins"), 0) != 0) { + if (CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.PosType"), 0) == 0) {X_Margins_CL = Right_HUD_Margin;}; Y_Margins_CL = (Top_HUD_Margin*-1); } else { X_Margins_CL = 0; Y_Margins_CL = 0; } - if (CVarGetInteger(CVAR_COSMETIC("CRightButton.UseMargins"), 0) != 0) { - if (CVarGetInteger(CVAR_COSMETIC("CRightButton.PosType"), 0) == 0) {X_Margins_CR = Right_HUD_Margin;}; + if (CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.UseMargins"), 0) != 0) { + if (CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.PosType"), 0) == 0) {X_Margins_CR = Right_HUD_Margin;}; Y_Margins_CR = (Top_HUD_Margin*-1); } else { X_Margins_CR = 0; Y_Margins_CR = 0; } - if (CVarGetInteger(CVAR_COSMETIC("CDownButton.UseMargins"), 0) != 0) { - if (CVarGetInteger(CVAR_COSMETIC("CDownButton.PosType"), 0) == 0) {X_Margins_CD = Right_HUD_Margin;}; + if (CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.UseMargins"), 0) != 0) { + if (CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.PosType"), 0) == 0) {X_Margins_CD = Right_HUD_Margin;}; Y_Margins_CD = (Top_HUD_Margin*-1); } else { X_Margins_CD = 0; @@ -4393,17 +4393,17 @@ void Interface_DrawItemButtons(PlayState* play) { }; s16 ItemIconPos[3][2]; //(X,Y) //C button Left - if (CVarGetInteger(CVAR_COSMETIC("CLeftButton.PosType"), 0) != 0) { - ItemIconPos[0][1] = CVarGetInteger(CVAR_COSMETIC("CLeftButton.PosY"), 0)+Y_Margins_CL; - if (CVarGetInteger(CVAR_COSMETIC("CLeftButton.PosType"), 0) == 1) {//Anchor Left - if (CVarGetInteger(CVAR_COSMETIC("CLeftButton.UseMargins"), 0) != 0) {X_Margins_CL = Left_HUD_Margin;}; - ItemIconPos[0][0] = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("CLeftButton.PosX"), 0)+X_Margins_CL); - } else if (CVarGetInteger(CVAR_COSMETIC("CLeftButton.PosType"), 0) == 2) {//Anchor Right - if (CVarGetInteger(CVAR_COSMETIC("CLeftButton.UseMargins"), 0) != 0) {X_Margins_CL = Right_HUD_Margin;}; - ItemIconPos[0][0] = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("CLeftButton.PosX"), 0)+X_Margins_CL); - } else if (CVarGetInteger(CVAR_COSMETIC("CLeftButton.PosType"), 0) == 3) {//Anchor None - ItemIconPos[0][0] = CVarGetInteger(CVAR_COSMETIC("CLeftButton.PosX"), 0); - } else if (CVarGetInteger(CVAR_COSMETIC("CLeftButton.PosType"), 0) == 4) {//Hidden + if (CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.PosType"), 0) != 0) { + ItemIconPos[0][1] = CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.PosY"), 0)+Y_Margins_CL; + if (CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.PosType"), 0) == 1) {//Anchor Left + if (CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.UseMargins"), 0) != 0) {X_Margins_CL = Left_HUD_Margin;}; + ItemIconPos[0][0] = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.PosX"), 0)+X_Margins_CL); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.PosType"), 0) == 2) {//Anchor Right + if (CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.UseMargins"), 0) != 0) {X_Margins_CL = Right_HUD_Margin;}; + ItemIconPos[0][0] = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.PosX"), 0)+X_Margins_CL); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.PosType"), 0) == 3) {//Anchor None + ItemIconPos[0][0] = CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.PosX"), 0); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.PosType"), 0) == 4) {//Hidden ItemIconPos[0][0] = -9999; } } else { @@ -4411,17 +4411,17 @@ void Interface_DrawItemButtons(PlayState* play) { ItemIconPos[0][1] = ItemIconPos_ori[0][1]; } //C Button down - if (CVarGetInteger(CVAR_COSMETIC("CDownButton.PosType"), 0) != 0) { - ItemIconPos[1][1] = CVarGetInteger(CVAR_COSMETIC("CDownButton.PosY"), 0)+Y_Margins_CD; - if (CVarGetInteger(CVAR_COSMETIC("CDownButton.PosType"), 0) == 1) {//Anchor Left - if (CVarGetInteger(CVAR_COSMETIC("CDownButton.UseMargins"), 0) != 0) {X_Margins_CD = Left_HUD_Margin;}; - ItemIconPos[1][0] = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("CDownButton.PosX"), 0)+X_Margins_CD); - } else if (CVarGetInteger(CVAR_COSMETIC("CDownButton.PosType"), 0) == 2) {//Anchor Right - if (CVarGetInteger(CVAR_COSMETIC("CDownButton.UseMargins"), 0) != 0) {X_Margins_CD = Right_HUD_Margin;}; - ItemIconPos[1][0] = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("CDownButton.PosX"), 0)+X_Margins_CD); - } else if (CVarGetInteger(CVAR_COSMETIC("CDownButton.PosType"), 0) == 3) {//Anchor None - ItemIconPos[1][0] = CVarGetInteger(CVAR_COSMETIC("CDownButton.PosX"), 0); - } else if (CVarGetInteger(CVAR_COSMETIC("CDownButton.PosType"), 0) == 4) {//Hidden + if (CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.PosType"), 0) != 0) { + ItemIconPos[1][1] = CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.PosY"), 0)+Y_Margins_CD; + if (CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.PosType"), 0) == 1) {//Anchor Left + if (CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.UseMargins"), 0) != 0) {X_Margins_CD = Left_HUD_Margin;}; + ItemIconPos[1][0] = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.PosX"), 0)+X_Margins_CD); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.PosType"), 0) == 2) {//Anchor Right + if (CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.UseMargins"), 0) != 0) {X_Margins_CD = Right_HUD_Margin;}; + ItemIconPos[1][0] = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.PosX"), 0)+X_Margins_CD); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.PosType"), 0) == 3) {//Anchor None + ItemIconPos[1][0] = CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.PosX"), 0); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.PosType"), 0) == 4) {//Hidden ItemIconPos[1][0] = -9999; } } else { @@ -4429,17 +4429,17 @@ void Interface_DrawItemButtons(PlayState* play) { ItemIconPos[1][1] = ItemIconPos_ori[1][1]; } //C button Right - if (CVarGetInteger(CVAR_COSMETIC("CRightButton.PosType"), 0) != 0) { - ItemIconPos[2][1] = CVarGetInteger(CVAR_COSMETIC("CRightButton.PosY"), 0)+Y_Margins_CR; - if (CVarGetInteger(CVAR_COSMETIC("CRightButton.PosType"), 0) == 1) {//Anchor Left - if (CVarGetInteger(CVAR_COSMETIC("CRightButton.UseMargins"), 0) != 0) {X_Margins_CR = Left_HUD_Margin;}; - ItemIconPos[2][0] = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("CRightButton.PosX"), 0)+X_Margins_CR); - } else if (CVarGetInteger(CVAR_COSMETIC("CRightButton.PosType"), 0) == 2) {//Anchor Right - if (CVarGetInteger(CVAR_COSMETIC("CRightButton.UseMargins"), 0) != 0) {X_Margins_CR = Right_HUD_Margin;}; - ItemIconPos[2][0] = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("CRightButton.PosX"), 0)+X_Margins_CR); - } else if (CVarGetInteger(CVAR_COSMETIC("CRightButton.PosType"), 0) == 3) {//Anchor None - ItemIconPos[2][0] = CVarGetInteger(CVAR_COSMETIC("CRightButton.PosX"), 0); - } else if (CVarGetInteger(CVAR_COSMETIC("CRightButton.PosType"), 0) == 4) {//Hidden + if (CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.PosType"), 0) != 0) { + ItemIconPos[2][1] = CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.PosY"), 0)+Y_Margins_CR; + if (CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.PosType"), 0) == 1) {//Anchor Left + if (CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.UseMargins"), 0) != 0) {X_Margins_CR = Left_HUD_Margin;}; + ItemIconPos[2][0] = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.PosX"), 0)+X_Margins_CR); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.PosType"), 0) == 2) {//Anchor Right + if (CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.UseMargins"), 0) != 0) {X_Margins_CR = Right_HUD_Margin;}; + ItemIconPos[2][0] = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.PosX"), 0)+X_Margins_CR); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.PosType"), 0) == 3) {//Anchor None + ItemIconPos[2][0] = CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.PosX"), 0); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.PosType"), 0) == 4) {//Hidden ItemIconPos[2][0] = -9999; } } else { @@ -4489,36 +4489,36 @@ void Interface_DrawItemIconTexture(PlayState* play, void* texture, s16 button) { s16 Y_Margins_BtnB; s16 X_Margins_DPad_Items; s16 Y_Margins_DPad_Items; - if (CVarGetInteger(CVAR_COSMETIC("BButton.UseMargins"), 0) != 0) { - if (CVarGetInteger(CVAR_COSMETIC("BButton.PosType"), 0) == 0) {X_Margins_BtnB = Right_HUD_Margin;}; + if (CVarGetInteger(CVAR_COSMETIC("HUD.BButton.UseMargins"), 0) != 0) { + if (CVarGetInteger(CVAR_COSMETIC("HUD.BButton.PosType"), 0) == 0) {X_Margins_BtnB = Right_HUD_Margin;}; Y_Margins_BtnB = (Top_HUD_Margin*-1); } else { X_Margins_BtnB = 0; Y_Margins_BtnB = 0; } - if (CVarGetInteger(CVAR_COSMETIC("CLeftButton.UseMargins"), 0) != 0) { - if (CVarGetInteger(CVAR_COSMETIC("CLeftButton.PosType"), 0) == 0) {X_Margins_CL = Right_HUD_Margin;}; + if (CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.UseMargins"), 0) != 0) { + if (CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.PosType"), 0) == 0) {X_Margins_CL = Right_HUD_Margin;}; Y_Margins_CL = (Top_HUD_Margin*-1); } else { X_Margins_CL = 0; Y_Margins_CL = 0; } - if (CVarGetInteger(CVAR_COSMETIC("CRightButton.UseMargins"), 0) != 0) { - if (CVarGetInteger(CVAR_COSMETIC("CRightButton.PosType"), 0) == 0) {X_Margins_CR = Right_HUD_Margin;}; + if (CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.UseMargins"), 0) != 0) { + if (CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.PosType"), 0) == 0) {X_Margins_CR = Right_HUD_Margin;}; Y_Margins_CR = (Top_HUD_Margin*-1); } else { X_Margins_CR = 0; Y_Margins_CR = 0; } - if (CVarGetInteger(CVAR_COSMETIC("CDownButton.UseMargins"), 0) != 0) { - if (CVarGetInteger(CVAR_COSMETIC("CDownButton.PosType"), 0) == 0) {X_Margins_CD = Right_HUD_Margin;}; + if (CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.UseMargins"), 0) != 0) { + if (CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.PosType"), 0) == 0) {X_Margins_CD = Right_HUD_Margin;}; Y_Margins_CD = (Top_HUD_Margin*-1); } else { X_Margins_CD = 0; Y_Margins_CD = 0; } - if (CVarGetInteger("gDPadUseMargins", 0) != 0) { - if (CVarGetInteger("gDPadPosType", 0) == 0) {X_Margins_DPad_Items = Right_HUD_Margin;}; + if (CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.UseMargins"), 0) != 0) { + if (CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosType"), 0) == 0) {X_Margins_DPad_Items = Right_HUD_Margin;}; Y_Margins_DPad_Items = (Top_HUD_Margin*-1); } else { X_Margins_DPad_Items = 0; @@ -4552,29 +4552,29 @@ void Interface_DrawItemIconTexture(PlayState* play, void* texture, s16 button) { }; //(X,Y) Used with custom position to place it properly. s16 ItemIconPos[8][2]; //(X,Y) //DPadItems - if (CVarGetInteger("gDPadPosType", 0) != 0) { - ItemIconPos[4][1] = CVarGetInteger("gDPadPosY", 0)+Y_Margins_DPad_Items+DPad_ItemsOffset[0][1];//Up - ItemIconPos[5][1] = CVarGetInteger("gDPadPosY", 0)+Y_Margins_DPad_Items+DPad_ItemsOffset[1][1];//Down - ItemIconPos[6][1] = CVarGetInteger("gDPadPosY", 0)+Y_Margins_DPad_Items+DPad_ItemsOffset[2][1];//Left - ItemIconPos[7][1] = CVarGetInteger("gDPadPosY", 0)+Y_Margins_DPad_Items+DPad_ItemsOffset[3][1];//Right - if (CVarGetInteger("gDPadPosType", 0) == 1) {//Anchor Left - if (CVarGetInteger("gDPadUseMargins", 0) != 0) {X_Margins_DPad_Items = Left_HUD_Margin;}; - ItemIconPos[4][0] = OTRGetDimensionFromLeftEdge(CVarGetInteger("gDPadPosX", 0)+X_Margins_DPad_Items+DPad_ItemsOffset[0][0]); - ItemIconPos[5][0] = OTRGetDimensionFromLeftEdge(CVarGetInteger("gDPadPosX", 0)+X_Margins_DPad_Items+DPad_ItemsOffset[1][0]); - ItemIconPos[6][0] = OTRGetDimensionFromLeftEdge(CVarGetInteger("gDPadPosX", 0)+X_Margins_DPad_Items+DPad_ItemsOffset[2][0]); - ItemIconPos[7][0] = OTRGetDimensionFromLeftEdge(CVarGetInteger("gDPadPosX", 0)+X_Margins_DPad_Items+DPad_ItemsOffset[3][0]); - } else if (CVarGetInteger("gDPadPosType", 0) == 2) {//Anchor Right - if (CVarGetInteger("gDPadUseMargins", 0) != 0) {X_Margins_DPad_Items = Right_HUD_Margin;}; - ItemIconPos[4][0] = OTRGetDimensionFromRightEdge(CVarGetInteger("gDPadPosX", 0)+X_Margins_DPad_Items+DPad_ItemsOffset[0][0]); - ItemIconPos[5][0] = OTRGetDimensionFromRightEdge(CVarGetInteger("gDPadPosX", 0)+X_Margins_DPad_Items+DPad_ItemsOffset[1][0]); - ItemIconPos[6][0] = OTRGetDimensionFromRightEdge(CVarGetInteger("gDPadPosX", 0)+X_Margins_DPad_Items+DPad_ItemsOffset[2][0]); - ItemIconPos[7][0] = OTRGetDimensionFromRightEdge(CVarGetInteger("gDPadPosX", 0)+X_Margins_DPad_Items+DPad_ItemsOffset[3][0]); - } else if (CVarGetInteger("gDPadPosType", 0) == 3) {//Anchor None - ItemIconPos[4][0] = CVarGetInteger("gDPadPosX", 0)+DPad_ItemsOffset[0][0]; - ItemIconPos[5][0] = CVarGetInteger("gDPadPosX", 0)+DPad_ItemsOffset[1][0]; - ItemIconPos[6][0] = CVarGetInteger("gDPadPosX", 0)+DPad_ItemsOffset[2][0]; - ItemIconPos[7][0] = CVarGetInteger("gDPadPosX", 0)+DPad_ItemsOffset[3][0]; - } else if (CVarGetInteger("gDPadPosType", 0) == 4) {//Hidden + if (CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosType"), 0) != 0) { + ItemIconPos[4][1] = CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosY"), 0)+Y_Margins_DPad_Items+DPad_ItemsOffset[0][1];//Up + ItemIconPos[5][1] = CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosY"), 0)+Y_Margins_DPad_Items+DPad_ItemsOffset[1][1];//Down + ItemIconPos[6][1] = CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosY"), 0)+Y_Margins_DPad_Items+DPad_ItemsOffset[2][1];//Left + ItemIconPos[7][1] = CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosY"), 0)+Y_Margins_DPad_Items+DPad_ItemsOffset[3][1];//Right + if (CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosType"), 0) == 1) {//Anchor Left + if (CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.UseMargins"), 0) != 0) {X_Margins_DPad_Items = Left_HUD_Margin;}; + ItemIconPos[4][0] = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosX"), 0)+X_Margins_DPad_Items+DPad_ItemsOffset[0][0]); + ItemIconPos[5][0] = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosX"), 0)+X_Margins_DPad_Items+DPad_ItemsOffset[1][0]); + ItemIconPos[6][0] = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosX"), 0)+X_Margins_DPad_Items+DPad_ItemsOffset[2][0]); + ItemIconPos[7][0] = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosX"), 0)+X_Margins_DPad_Items+DPad_ItemsOffset[3][0]); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosType"), 0) == 2) {//Anchor Right + if (CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.UseMargins"), 0) != 0) {X_Margins_DPad_Items = Right_HUD_Margin;}; + ItemIconPos[4][0] = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosX"), 0)+X_Margins_DPad_Items+DPad_ItemsOffset[0][0]); + ItemIconPos[5][0] = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosX"), 0)+X_Margins_DPad_Items+DPad_ItemsOffset[1][0]); + ItemIconPos[6][0] = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosX"), 0)+X_Margins_DPad_Items+DPad_ItemsOffset[2][0]); + ItemIconPos[7][0] = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosX"), 0)+X_Margins_DPad_Items+DPad_ItemsOffset[3][0]); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosType"), 0) == 3) {//Anchor None + ItemIconPos[4][0] = CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosX"), 0)+DPad_ItemsOffset[0][0]; + ItemIconPos[5][0] = CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosX"), 0)+DPad_ItemsOffset[1][0]; + ItemIconPos[6][0] = CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosX"), 0)+DPad_ItemsOffset[2][0]; + ItemIconPos[7][0] = CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosX"), 0)+DPad_ItemsOffset[3][0]; + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosType"), 0) == 4) {//Hidden ItemIconPos[4][0] = -9999; ItemIconPos[5][0] = -9999; ItemIconPos[6][0] = -9999; @@ -4591,17 +4591,17 @@ void Interface_DrawItemIconTexture(PlayState* play, void* texture, s16 button) { ItemIconPos[7][1] = ItemIconPos_ori[7][1]; } //B Button - if (CVarGetInteger(CVAR_COSMETIC("BButton.PosType"), 0) != 0) { - ItemIconPos[0][1] = CVarGetInteger(CVAR_COSMETIC("BButton.PosY"), 0)+Y_Margins_BtnB; - if (CVarGetInteger(CVAR_COSMETIC("BButton.PosType"), 0) == 1) {//Anchor Left - if (CVarGetInteger(CVAR_COSMETIC("BButton.UseMargins"), 0) != 0) {X_Margins_BtnB = Left_HUD_Margin;}; - ItemIconPos[0][0] = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("BButton.PosX"), 0)+X_Margins_BtnB); - } else if (CVarGetInteger(CVAR_COSMETIC("BButton.PosType"), 0) == 2) {//Anchor Right - if (CVarGetInteger(CVAR_COSMETIC("BButton.UseMargins"), 0) != 0) {X_Margins_BtnB = Right_HUD_Margin;}; - ItemIconPos[0][0] = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("BButton.PosX"), 0)+X_Margins_BtnB); - } else if (CVarGetInteger(CVAR_COSMETIC("BButton.PosType"), 0) == 3) {//Anchor None - ItemIconPos[0][0] = CVarGetInteger(CVAR_COSMETIC("BButton.PosX"), 0); - } else if (CVarGetInteger(CVAR_COSMETIC("BButton.PosType"), 0) == 4) {//Hidden + if (CVarGetInteger(CVAR_COSMETIC("HUD.BButton.PosType"), 0) != 0) { + ItemIconPos[0][1] = CVarGetInteger(CVAR_COSMETIC("HUD.BButton.PosY"), 0)+Y_Margins_BtnB; + if (CVarGetInteger(CVAR_COSMETIC("HUD.BButton.PosType"), 0) == 1) {//Anchor Left + if (CVarGetInteger(CVAR_COSMETIC("HUD.BButton.UseMargins"), 0) != 0) {X_Margins_BtnB = Left_HUD_Margin;}; + ItemIconPos[0][0] = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("HUD.BButton.PosX"), 0)+X_Margins_BtnB); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.BButton.PosType"), 0) == 2) {//Anchor Right + if (CVarGetInteger(CVAR_COSMETIC("HUD.BButton.UseMargins"), 0) != 0) {X_Margins_BtnB = Right_HUD_Margin;}; + ItemIconPos[0][0] = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("HUD.BButton.PosX"), 0)+X_Margins_BtnB); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.BButton.PosType"), 0) == 3) {//Anchor None + ItemIconPos[0][0] = CVarGetInteger(CVAR_COSMETIC("HUD.BButton.PosX"), 0); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.BButton.PosType"), 0) == 4) {//Hidden ItemIconPos[0][0] = -9999; } } else { @@ -4609,17 +4609,17 @@ void Interface_DrawItemIconTexture(PlayState* play, void* texture, s16 button) { ItemIconPos[0][1] = ItemIconPos_ori[0][1]; } //C button Left - if (CVarGetInteger(CVAR_COSMETIC("CLeftButton.PosType"), 0) != 0) { - ItemIconPos[1][1] = CVarGetInteger(CVAR_COSMETIC("CLeftButton.PosY"), 0)+Y_Margins_CL; - if (CVarGetInteger(CVAR_COSMETIC("CLeftButton.PosType"), 0) == 1) {//Anchor Left - if (CVarGetInteger(CVAR_COSMETIC("CLeftButton.UseMargins"), 0) != 0) {X_Margins_CL = Left_HUD_Margin;}; - ItemIconPos[1][0] = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("CLeftButton.PosX"), 0)+X_Margins_CL); - } else if (CVarGetInteger(CVAR_COSMETIC("CLeftButton.PosType"), 0) == 2) {//Anchor Right - if (CVarGetInteger(CVAR_COSMETIC("CLeftButton.UseMargins"), 0) != 0) {X_Margins_CL = Right_HUD_Margin;}; - ItemIconPos[1][0] = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("CLeftButton.PosX"), 0)+X_Margins_CL); - } else if (CVarGetInteger(CVAR_COSMETIC("CLeftButton.PosType"), 0) == 3) {//Anchor None - ItemIconPos[1][0] = CVarGetInteger(CVAR_COSMETIC("CLeftButton.PosX"), 0); - } else if (CVarGetInteger(CVAR_COSMETIC("CLeftButton.PosType"), 0) == 4) {//Hidden + if (CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.PosType"), 0) != 0) { + ItemIconPos[1][1] = CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.PosY"), 0)+Y_Margins_CL; + if (CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.PosType"), 0) == 1) {//Anchor Left + if (CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.UseMargins"), 0) != 0) {X_Margins_CL = Left_HUD_Margin;}; + ItemIconPos[1][0] = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.PosX"), 0)+X_Margins_CL); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.PosType"), 0) == 2) {//Anchor Right + if (CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.UseMargins"), 0) != 0) {X_Margins_CL = Right_HUD_Margin;}; + ItemIconPos[1][0] = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.PosX"), 0)+X_Margins_CL); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.PosType"), 0) == 3) {//Anchor None + ItemIconPos[1][0] = CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.PosX"), 0); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.PosType"), 0) == 4) {//Hidden ItemIconPos[1][0] = -9999; } } else { @@ -4627,17 +4627,17 @@ void Interface_DrawItemIconTexture(PlayState* play, void* texture, s16 button) { ItemIconPos[1][1] = ItemIconPos_ori[1][1]; } //C Button down - if (CVarGetInteger(CVAR_COSMETIC("CDownButton.PosType"), 0) != 0) { - ItemIconPos[2][1] = CVarGetInteger(CVAR_COSMETIC("CDownButton.PosY"), 0)+Y_Margins_CD; - if (CVarGetInteger(CVAR_COSMETIC("CDownButton.PosType"), 0) == 1) {//Anchor Left - if (CVarGetInteger(CVAR_COSMETIC("CDownButton.UseMargins"), 0) != 0) {X_Margins_CD = Left_HUD_Margin;}; - ItemIconPos[2][0] = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("CDownButton.PosX"), 0)+X_Margins_CD); - } else if (CVarGetInteger(CVAR_COSMETIC("CDownButton.PosType"), 0) == 2) {//Anchor Right - if (CVarGetInteger(CVAR_COSMETIC("CDownButton.UseMargins"), 0) != 0) {X_Margins_CD = Right_HUD_Margin;}; - ItemIconPos[2][0] = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("CDownButton.PosX"), 0)+X_Margins_CD); - } else if (CVarGetInteger(CVAR_COSMETIC("CDownButton.PosType"), 0) == 3) {//Anchor None - ItemIconPos[2][0] = CVarGetInteger(CVAR_COSMETIC("CDownButton.PosX"), 0); - } else if (CVarGetInteger(CVAR_COSMETIC("CDownButton.PosType"), 0) == 4) {//Hidden + if (CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.PosType"), 0) != 0) { + ItemIconPos[2][1] = CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.PosY"), 0)+Y_Margins_CD; + if (CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.PosType"), 0) == 1) {//Anchor Left + if (CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.UseMargins"), 0) != 0) {X_Margins_CD = Left_HUD_Margin;}; + ItemIconPos[2][0] = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.PosX"), 0)+X_Margins_CD); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.PosType"), 0) == 2) {//Anchor Right + if (CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.UseMargins"), 0) != 0) {X_Margins_CD = Right_HUD_Margin;}; + ItemIconPos[2][0] = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.PosX"), 0)+X_Margins_CD); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.PosType"), 0) == 3) {//Anchor None + ItemIconPos[2][0] = CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.PosX"), 0); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.PosType"), 0) == 4) {//Hidden ItemIconPos[2][0] = -9999; } } else { @@ -4645,17 +4645,17 @@ void Interface_DrawItemIconTexture(PlayState* play, void* texture, s16 button) { ItemIconPos[2][1] = ItemIconPos_ori[2][1]; } //C button Right - if (CVarGetInteger(CVAR_COSMETIC("CRightButton.PosType"), 0) != 0) { - ItemIconPos[3][1] = CVarGetInteger(CVAR_COSMETIC("CRightButton.PosY"), 0)+Y_Margins_CR; - if (CVarGetInteger(CVAR_COSMETIC("CRightButton.PosType"), 0) == 1) {//Anchor Left - if (CVarGetInteger(CVAR_COSMETIC("CRightButton.UseMargins"), 0) != 0) {X_Margins_CR = Left_HUD_Margin;}; - ItemIconPos[3][0] = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("CRightButton.PosX"), 0)+X_Margins_CR); - } else if (CVarGetInteger(CVAR_COSMETIC("CRightButton.PosType"), 0) == 2) {//Anchor Right - if (CVarGetInteger(CVAR_COSMETIC("CRightButton.UseMargins"), 0) != 0) {X_Margins_CR = Right_HUD_Margin;}; - ItemIconPos[3][0] = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("CRightButton.PosX"), 0)+X_Margins_CR); - } else if (CVarGetInteger(CVAR_COSMETIC("CRightButton.PosType"), 0) == 3) {//Anchor None - ItemIconPos[3][0] = CVarGetInteger(CVAR_COSMETIC("CRightButton.PosX"), 0); - } else if (CVarGetInteger(CVAR_COSMETIC("CRightButton.PosType"), 0) == 4) {//Hidden + if (CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.PosType"), 0) != 0) { + ItemIconPos[3][1] = CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.PosY"), 0)+Y_Margins_CR; + if (CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.PosType"), 0) == 1) {//Anchor Left + if (CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.UseMargins"), 0) != 0) {X_Margins_CR = Left_HUD_Margin;}; + ItemIconPos[3][0] = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.PosX"), 0)+X_Margins_CR); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.PosType"), 0) == 2) {//Anchor Right + if (CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.UseMargins"), 0) != 0) {X_Margins_CR = Right_HUD_Margin;}; + ItemIconPos[3][0] = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.PosX"), 0)+X_Margins_CR); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.PosType"), 0) == 3) {//Anchor None + ItemIconPos[3][0] = CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.PosX"), 0); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.PosType"), 0) == 4) {//Hidden ItemIconPos[3][0] = -9999; } } else { @@ -4698,36 +4698,36 @@ void Interface_DrawAmmoCount(PlayState* play, s16 button, s16 alpha) { s16 Y_Margins_BtnB; s16 X_Margins_DPad_Items; s16 Y_Margins_DPad_Items; - if (CVarGetInteger(CVAR_COSMETIC("BButton.UseMargins"), 0) != 0) { - if (CVarGetInteger(CVAR_COSMETIC("BButton.PosType"), 0) == 0) {X_Margins_BtnB = Right_HUD_Margin;}; + if (CVarGetInteger(CVAR_COSMETIC("HUD.BButton.UseMargins"), 0) != 0) { + if (CVarGetInteger(CVAR_COSMETIC("HUD.BButton.PosType"), 0) == 0) {X_Margins_BtnB = Right_HUD_Margin;}; Y_Margins_BtnB = (Top_HUD_Margin*-1); } else { X_Margins_BtnB = 0; Y_Margins_BtnB = 0; } - if (CVarGetInteger(CVAR_COSMETIC("CLeftButton.UseMargins"), 0) != 0) { - if (CVarGetInteger(CVAR_COSMETIC("CLeftButton.PosType"), 0) == 0) {X_Margins_CL = Right_HUD_Margin;}; + if (CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.UseMargins"), 0) != 0) { + if (CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.PosType"), 0) == 0) {X_Margins_CL = Right_HUD_Margin;}; Y_Margins_CL = (Top_HUD_Margin*-1); } else { X_Margins_CL = 0; Y_Margins_CL = 0; } - if (CVarGetInteger(CVAR_COSMETIC("CRightButton.UseMargins"), 0) != 0) { - if (CVarGetInteger(CVAR_COSMETIC("CRightButton.PosType"), 0) == 0) {X_Margins_CR = Right_HUD_Margin;}; + if (CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.UseMargins"), 0) != 0) { + if (CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.PosType"), 0) == 0) {X_Margins_CR = Right_HUD_Margin;}; Y_Margins_CR = (Top_HUD_Margin*-1); } else { X_Margins_CR = 0; Y_Margins_CR = 0; } - if (CVarGetInteger(CVAR_COSMETIC("CDownButton.UseMargins"), 0) != 0) { - if (CVarGetInteger(CVAR_COSMETIC("CDownButton.PosType"), 0) == 0) {X_Margins_CD = Right_HUD_Margin;}; + if (CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.UseMargins"), 0) != 0) { + if (CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.PosType"), 0) == 0) {X_Margins_CD = Right_HUD_Margin;}; Y_Margins_CD = (Top_HUD_Margin*-1); } else { X_Margins_CD = 0; Y_Margins_CD = 0; } - if (CVarGetInteger("gDPadUseMargins", 0) != 0) { - if (CVarGetInteger("gDPadPosType", 0) == 0) {X_Margins_DPad_Items = Right_HUD_Margin;}; + if (CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.UseMargins"), 0) != 0) { + if (CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosType"), 0) == 0) {X_Margins_DPad_Items = Right_HUD_Margin;}; Y_Margins_DPad_Items = (Top_HUD_Margin*-1); } else { X_Margins_DPad_Items = 0; @@ -4751,29 +4751,29 @@ void Interface_DrawAmmoCount(PlayState* play, s16 button, s16 alpha) { {23,19},//Right }; //(X,Y) Used with custom position to place it properly. //DPadItems - if (CVarGetInteger("gDPadPosType", 0) != 0) { - ItemIconPos[4][1] = CVarGetInteger("gDPadPosY", 0)+Y_Margins_DPad_Items+DPad_ItemsOffset[0][1];//Up - ItemIconPos[5][1] = CVarGetInteger("gDPadPosY", 0)+Y_Margins_DPad_Items+DPad_ItemsOffset[1][1];//Down - ItemIconPos[6][1] = CVarGetInteger("gDPadPosY", 0)+Y_Margins_DPad_Items+DPad_ItemsOffset[2][1];//Left - ItemIconPos[7][1] = CVarGetInteger("gDPadPosY", 0)+Y_Margins_DPad_Items+DPad_ItemsOffset[3][1];//Right - if (CVarGetInteger("gDPadPosType", 0) == 1) {//Anchor Left - if (CVarGetInteger("gDPadUseMargins", 0) != 0) {X_Margins_DPad_Items = Left_HUD_Margin;}; - ItemIconPos[4][0] = OTRGetDimensionFromLeftEdge(CVarGetInteger("gDPadPosX", 0)+X_Margins_DPad_Items+DPad_ItemsOffset[0][0]); - ItemIconPos[5][0] = OTRGetDimensionFromLeftEdge(CVarGetInteger("gDPadPosX", 0)+X_Margins_DPad_Items+DPad_ItemsOffset[1][0]); - ItemIconPos[6][0] = OTRGetDimensionFromLeftEdge(CVarGetInteger("gDPadPosX", 0)+X_Margins_DPad_Items+DPad_ItemsOffset[2][0]); - ItemIconPos[7][0] = OTRGetDimensionFromLeftEdge(CVarGetInteger("gDPadPosX", 0)+X_Margins_DPad_Items+DPad_ItemsOffset[3][0]); - } else if (CVarGetInteger("gDPadPosType", 0) == 2) {//Anchor Right - if (CVarGetInteger("gDPadUseMargins", 0) != 0) {X_Margins_DPad_Items = Right_HUD_Margin;}; - ItemIconPos[4][0] = OTRGetDimensionFromRightEdge(CVarGetInteger("gDPadPosX", 0)+X_Margins_DPad_Items+DPad_ItemsOffset[0][0]); - ItemIconPos[5][0] = OTRGetDimensionFromRightEdge(CVarGetInteger("gDPadPosX", 0)+X_Margins_DPad_Items+DPad_ItemsOffset[1][0]); - ItemIconPos[6][0] = OTRGetDimensionFromRightEdge(CVarGetInteger("gDPadPosX", 0)+X_Margins_DPad_Items+DPad_ItemsOffset[2][0]); - ItemIconPos[7][0] = OTRGetDimensionFromRightEdge(CVarGetInteger("gDPadPosX", 0)+X_Margins_DPad_Items+DPad_ItemsOffset[3][0]); - } else if (CVarGetInteger("gDPadPosType", 0) == 3) {//Anchor None - ItemIconPos[4][0] = CVarGetInteger("gDPadPosX", 0)+DPad_ItemsOffset[0][0]; - ItemIconPos[5][0] = CVarGetInteger("gDPadPosX", 0)+DPad_ItemsOffset[1][0]; - ItemIconPos[6][0] = CVarGetInteger("gDPadPosX", 0)+DPad_ItemsOffset[2][0]; - ItemIconPos[7][0] = CVarGetInteger("gDPadPosX", 0)+DPad_ItemsOffset[3][0]; - } else if (CVarGetInteger("gDPadPosType", 0) == 4) {//Hidden + if (CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosType"), 0) != 0) { + ItemIconPos[4][1] = CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosY"), 0)+Y_Margins_DPad_Items+DPad_ItemsOffset[0][1];//Up + ItemIconPos[5][1] = CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosY"), 0)+Y_Margins_DPad_Items+DPad_ItemsOffset[1][1];//Down + ItemIconPos[6][1] = CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosY"), 0)+Y_Margins_DPad_Items+DPad_ItemsOffset[2][1];//Left + ItemIconPos[7][1] = CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosY"), 0)+Y_Margins_DPad_Items+DPad_ItemsOffset[3][1];//Right + if (CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosType"), 0) == 1) {//Anchor Left + if (CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.UseMargins"), 0) != 0) {X_Margins_DPad_Items = Left_HUD_Margin;}; + ItemIconPos[4][0] = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosX"), 0)+X_Margins_DPad_Items+DPad_ItemsOffset[0][0]); + ItemIconPos[5][0] = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosX"), 0)+X_Margins_DPad_Items+DPad_ItemsOffset[1][0]); + ItemIconPos[6][0] = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosX"), 0)+X_Margins_DPad_Items+DPad_ItemsOffset[2][0]); + ItemIconPos[7][0] = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosX"), 0)+X_Margins_DPad_Items+DPad_ItemsOffset[3][0]); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosType"), 0) == 2) {//Anchor Right + if (CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.UseMargins"), 0) != 0) {X_Margins_DPad_Items = Right_HUD_Margin;}; + ItemIconPos[4][0] = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosX"), 0)+X_Margins_DPad_Items+DPad_ItemsOffset[0][0]); + ItemIconPos[5][0] = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosX"), 0)+X_Margins_DPad_Items+DPad_ItemsOffset[1][0]); + ItemIconPos[6][0] = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosX"), 0)+X_Margins_DPad_Items+DPad_ItemsOffset[2][0]); + ItemIconPos[7][0] = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosX"), 0)+X_Margins_DPad_Items+DPad_ItemsOffset[3][0]); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosType"), 0) == 3) {//Anchor None + ItemIconPos[4][0] = CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosX"), 0)+DPad_ItemsOffset[0][0]; + ItemIconPos[5][0] = CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosX"), 0)+DPad_ItemsOffset[1][0]; + ItemIconPos[6][0] = CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosX"), 0)+DPad_ItemsOffset[2][0]; + ItemIconPos[7][0] = CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosX"), 0)+DPad_ItemsOffset[3][0]; + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosType"), 0) == 4) {//Hidden ItemIconPos[4][0] = -9999; ItemIconPos[5][0] = -9999; ItemIconPos[6][0] = -9999; @@ -4792,17 +4792,17 @@ void Interface_DrawAmmoCount(PlayState* play, s16 button, s16 alpha) { //B Button s16 PosX_adjust = 1; s16 PosY_adjust = 17; - if (CVarGetInteger(CVAR_COSMETIC("BButton.PosType"), 0) != 0) { - ItemIconPos[0][1] = CVarGetInteger(CVAR_COSMETIC("BButton.PosY"), 0)+Y_Margins_BtnB+PosY_adjust; - if (CVarGetInteger(CVAR_COSMETIC("BButton.PosType"), 0) == 1) {//Anchor Left - if (CVarGetInteger(CVAR_COSMETIC("BButton.UseMargins"), 0) != 0) {X_Margins_BtnB = Left_HUD_Margin;}; - ItemIconPos[0][0] = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("BButton.PosX"), 0)+X_Margins_BtnB+PosX_adjust); - } else if (CVarGetInteger(CVAR_COSMETIC("BButton.PosType"), 0) == 2) {//Anchor Right - if (CVarGetInteger(CVAR_COSMETIC("BButton.UseMargins"), 0) != 0) {X_Margins_BtnB = Right_HUD_Margin;}; - ItemIconPos[0][0] = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("BButton.PosX"), 0)+X_Margins_BtnB+PosX_adjust); - } else if (CVarGetInteger(CVAR_COSMETIC("BButton.PosType"), 0) == 3) {//Anchor None - ItemIconPos[0][0] = CVarGetInteger(CVAR_COSMETIC("BButton.PosX"), 0)+PosX_adjust; - } else if (CVarGetInteger(CVAR_COSMETIC("BButton.PosType"), 0) == 4) {//Hidden + if (CVarGetInteger(CVAR_COSMETIC("HUD.BButton.PosType"), 0) != 0) { + ItemIconPos[0][1] = CVarGetInteger(CVAR_COSMETIC("HUD.BButton.PosY"), 0)+Y_Margins_BtnB+PosY_adjust; + if (CVarGetInteger(CVAR_COSMETIC("HUD.BButton.PosType"), 0) == 1) {//Anchor Left + if (CVarGetInteger(CVAR_COSMETIC("HUD.BButton.UseMargins"), 0) != 0) {X_Margins_BtnB = Left_HUD_Margin;}; + ItemIconPos[0][0] = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("HUD.BButton.PosX"), 0)+X_Margins_BtnB+PosX_adjust); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.BButton.PosType"), 0) == 2) {//Anchor Right + if (CVarGetInteger(CVAR_COSMETIC("HUD.BButton.UseMargins"), 0) != 0) {X_Margins_BtnB = Right_HUD_Margin;}; + ItemIconPos[0][0] = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("HUD.BButton.PosX"), 0)+X_Margins_BtnB+PosX_adjust); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.BButton.PosType"), 0) == 3) {//Anchor None + ItemIconPos[0][0] = CVarGetInteger(CVAR_COSMETIC("HUD.BButton.PosX"), 0)+PosX_adjust; + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.BButton.PosType"), 0) == 4) {//Hidden ItemIconPos[0][0] = -9999; } } else { @@ -4810,17 +4810,17 @@ void Interface_DrawAmmoCount(PlayState* play, s16 button, s16 alpha) { ItemIconPos[0][1] = ItemIconPos_ori[0][1]; } //C button Left - if (CVarGetInteger(CVAR_COSMETIC("CLeftButton.PosType"), 0) != 0) { - ItemIconPos[1][1] = CVarGetInteger(CVAR_COSMETIC("CLeftButton.PosY"), 0)+Y_Margins_CL+PosY_adjust; - if (CVarGetInteger(CVAR_COSMETIC("CLeftButton.PosType"), 0) == 1) {//Anchor Left - if (CVarGetInteger(CVAR_COSMETIC("CLeftButton.UseMargins"), 0) != 0) {X_Margins_CL = Left_HUD_Margin;}; - ItemIconPos[1][0] = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("CLeftButton.PosX"), 0)+X_Margins_CL+PosX_adjust); - } else if (CVarGetInteger(CVAR_COSMETIC("CLeftButton.PosType"), 0) == 2) {//Anchor Right - if (CVarGetInteger(CVAR_COSMETIC("CLeftButton.UseMargins"), 0) != 0) {X_Margins_CL = Right_HUD_Margin;}; - ItemIconPos[1][0] = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("CLeftButton.PosX"), 0)+X_Margins_CL+PosX_adjust); - } else if (CVarGetInteger(CVAR_COSMETIC("CLeftButton.PosType"), 0) == 3) {//Anchor None - ItemIconPos[1][0] = CVarGetInteger(CVAR_COSMETIC("CLeftButton.PosX"), 0)+PosX_adjust; - } else if (CVarGetInteger(CVAR_COSMETIC("CLeftButton.PosType"), 0) == 4) {//Hidden + if (CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.PosType"), 0) != 0) { + ItemIconPos[1][1] = CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.PosY"), 0)+Y_Margins_CL+PosY_adjust; + if (CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.PosType"), 0) == 1) {//Anchor Left + if (CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.UseMargins"), 0) != 0) {X_Margins_CL = Left_HUD_Margin;}; + ItemIconPos[1][0] = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.PosX"), 0)+X_Margins_CL+PosX_adjust); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.PosType"), 0) == 2) {//Anchor Right + if (CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.UseMargins"), 0) != 0) {X_Margins_CL = Right_HUD_Margin;}; + ItemIconPos[1][0] = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.PosX"), 0)+X_Margins_CL+PosX_adjust); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.PosType"), 0) == 3) {//Anchor None + ItemIconPos[1][0] = CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.PosX"), 0)+PosX_adjust; + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.PosType"), 0) == 4) {//Hidden ItemIconPos[1][0] = -9999; } } else { @@ -4828,17 +4828,17 @@ void Interface_DrawAmmoCount(PlayState* play, s16 button, s16 alpha) { ItemIconPos[1][1] = ItemIconPos_ori[1][1]; } //C Button down - if (CVarGetInteger(CVAR_COSMETIC("CDownButton.PosType"), 0) != 0) { - ItemIconPos[2][1] = CVarGetInteger(CVAR_COSMETIC("CDownButton.PosY"), 0)+Y_Margins_CD+PosY_adjust; - if (CVarGetInteger(CVAR_COSMETIC("CDownButton.PosType"), 0) == 1) {//Anchor Left - if (CVarGetInteger(CVAR_COSMETIC("CDownButton.UseMargins"), 0) != 0) {X_Margins_CD = Left_HUD_Margin;}; - ItemIconPos[2][0] = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("CDownButton.PosX"), 0)+X_Margins_CD+PosX_adjust); - } else if (CVarGetInteger(CVAR_COSMETIC("CDownButton.PosType"), 0) == 2) {//Anchor Right - if (CVarGetInteger(CVAR_COSMETIC("CDownButton.UseMargins"), 0) != 0) {X_Margins_CD = Right_HUD_Margin;}; - ItemIconPos[2][0] = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("CDownButton.PosX"), 0)+X_Margins_CD+PosX_adjust); - } else if (CVarGetInteger(CVAR_COSMETIC("CDownButton.PosType"), 0) == 3) {//Anchor None - ItemIconPos[2][0] = CVarGetInteger(CVAR_COSMETIC("CDownButton.PosX"), 0)+PosX_adjust; - } else if (CVarGetInteger(CVAR_COSMETIC("CDownButton.PosType"), 0) == 4) {//Hidden + if (CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.PosType"), 0) != 0) { + ItemIconPos[2][1] = CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.PosY"), 0)+Y_Margins_CD+PosY_adjust; + if (CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.PosType"), 0) == 1) {//Anchor Left + if (CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.UseMargins"), 0) != 0) {X_Margins_CD = Left_HUD_Margin;}; + ItemIconPos[2][0] = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.PosX"), 0)+X_Margins_CD+PosX_adjust); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.PosType"), 0) == 2) {//Anchor Right + if (CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.UseMargins"), 0) != 0) {X_Margins_CD = Right_HUD_Margin;}; + ItemIconPos[2][0] = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.PosX"), 0)+X_Margins_CD+PosX_adjust); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.PosType"), 0) == 3) {//Anchor None + ItemIconPos[2][0] = CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.PosX"), 0)+PosX_adjust; + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.PosType"), 0) == 4) {//Hidden ItemIconPos[2][0] = -9999; } } else { @@ -4846,17 +4846,17 @@ void Interface_DrawAmmoCount(PlayState* play, s16 button, s16 alpha) { ItemIconPos[2][1] = ItemIconPos_ori[2][1]; } //C button Right - if (CVarGetInteger(CVAR_COSMETIC("CRightButton.PosType"), 0) != 0) { - ItemIconPos[3][1] = CVarGetInteger(CVAR_COSMETIC("CRightButton.PosY"), 0)+Y_Margins_CR+PosY_adjust; - if (CVarGetInteger(CVAR_COSMETIC("CRightButton.PosType"), 0) == 1) {//Anchor Left - if (CVarGetInteger(CVAR_COSMETIC("CRightButton.UseMargins"), 0) != 0) {X_Margins_CR = Left_HUD_Margin;}; - ItemIconPos[3][0] = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("CRightButton.PosX"), 0)+X_Margins_CR+PosX_adjust); - } else if (CVarGetInteger(CVAR_COSMETIC("CRightButton.PosType"), 0) == 2) {//Anchor Right - if (CVarGetInteger(CVAR_COSMETIC("CRightButton.UseMargins"), 0) != 0) {X_Margins_CR = Right_HUD_Margin;}; - ItemIconPos[3][0] = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("CRightButton.PosX"), 0)+X_Margins_CR+PosX_adjust); - } else if (CVarGetInteger(CVAR_COSMETIC("CRightButton.PosType"), 0) == 3) {//Anchor None - ItemIconPos[3][0] = CVarGetInteger(CVAR_COSMETIC("CRightButton.PosX"), 0)+PosX_adjust; - } else if (CVarGetInteger(CVAR_COSMETIC("CRightButton.PosType"), 0) == 4) {//Hidden + if (CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.PosType"), 0) != 0) { + ItemIconPos[3][1] = CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.PosY"), 0)+Y_Margins_CR+PosY_adjust; + if (CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.PosType"), 0) == 1) {//Anchor Left + if (CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.UseMargins"), 0) != 0) {X_Margins_CR = Left_HUD_Margin;}; + ItemIconPos[3][0] = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.PosX"), 0)+X_Margins_CR+PosX_adjust); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.PosType"), 0) == 2) {//Anchor Right + if (CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.UseMargins"), 0) != 0) {X_Margins_CR = Right_HUD_Margin;}; + ItemIconPos[3][0] = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.PosX"), 0)+X_Margins_CR+PosX_adjust); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.PosType"), 0) == 3) {//Anchor None + ItemIconPos[3][0] = CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.PosX"), 0)+PosX_adjust; + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.PosType"), 0) == 4) {//Hidden ItemIconPos[3][0] = -9999; } } else { @@ -5185,8 +5185,8 @@ void Interface_Draw(PlayState* play) { //Rupee icon & counter s16 X_Margins_RC; s16 Y_Margins_RC; - if (CVarGetInteger("gRCUseMargins", 0) != 0) { - if (CVarGetInteger("gRCPosType", 0) == 0) {X_Margins_RC = Left_HUD_Margin;}; + if (CVarGetInteger(CVAR_COSMETIC("HUD.Rupees.UseMargins"), 0) != 0) { + if (CVarGetInteger(CVAR_COSMETIC("HUD.Rupees.PosType"), 0) == 0) {X_Margins_RC = Left_HUD_Margin;}; Y_Margins_RC = Bottom_HUD_Margin; } else { X_Margins_RC = 0; @@ -5196,17 +5196,17 @@ void Interface_Draw(PlayState* play) { s16 PosY_RC_ori = 206+Y_Margins_RC; s16 PosX_RC; s16 PosY_RC; - if (CVarGetInteger("gRCPosType", 0) != 0) { - PosY_RC = CVarGetInteger("gRCPosY", 0)+Y_Margins_RC; - if (CVarGetInteger("gRCPosType", 0) == 1) {//Anchor Left - if (CVarGetInteger("gRCUseMargins", 0) != 0) {X_Margins_RC = Left_HUD_Margin;}; - PosX_RC = OTRGetDimensionFromLeftEdge(CVarGetInteger("gRCPosX", 0)+X_Margins_RC); - } else if (CVarGetInteger("gRCPosType", 0) == 2) {//Anchor Right - if (CVarGetInteger("gRCUseMargins", 0) != 0) {X_Margins_RC = Right_HUD_Margin;}; - PosX_RC = OTRGetDimensionFromRightEdge(CVarGetInteger("gRCPosX", 0)+X_Margins_RC); - } else if (CVarGetInteger("gRCPosType", 0) == 3) {//Anchor None - PosX_RC = CVarGetInteger("gRCPosX", 0); - } else if (CVarGetInteger("gRCPosType", 0) == 4) {//Hidden + if (CVarGetInteger(CVAR_COSMETIC("HUD.Rupees.PosType"), 0) != 0) { + PosY_RC = CVarGetInteger(CVAR_COSMETIC("HUD.Rupees.PosY"), 0)+Y_Margins_RC; + if (CVarGetInteger(CVAR_COSMETIC("HUD.Rupees.PosType"), 0) == 1) {//Anchor Left + if (CVarGetInteger(CVAR_COSMETIC("HUD.Rupees.UseMargins"), 0) != 0) {X_Margins_RC = Left_HUD_Margin;}; + PosX_RC = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("HUD.Rupees.PosX"), 0)+X_Margins_RC); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.Rupees.PosType"), 0) == 2) {//Anchor Right + if (CVarGetInteger(CVAR_COSMETIC("HUD.Rupees.UseMargins"), 0) != 0) {X_Margins_RC = Right_HUD_Margin;}; + PosX_RC = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("HUD.Rupees.PosX"), 0)+X_Margins_RC); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.Rupees.PosType"), 0) == 3) {//Anchor None + PosX_RC = CVarGetInteger(CVAR_COSMETIC("HUD.Rupees.PosX"), 0); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.Rupees.PosType"), 0) == 4) {//Hidden PosX_RC = -9999; } } else { @@ -5237,8 +5237,8 @@ void Interface_Draw(PlayState* play) { if (gSaveContext.inventory.dungeonKeys[gSaveContext.mapIndex] >= 0) { s16 X_Margins_SKC; s16 Y_Margins_SKC; - if (CVarGetInteger("gSKCUseMargins", 0) != 0) { - if (CVarGetInteger("gSKCPosType", 0) == 0) {X_Margins_SKC = Left_HUD_Margin;}; + if (CVarGetInteger(CVAR_COSMETIC("HUD.SmallKey.UseMargins"), 0) != 0) { + if (CVarGetInteger(CVAR_COSMETIC("HUD.SmallKey.PosType"), 0) == 0) {X_Margins_SKC = Left_HUD_Margin;}; Y_Margins_SKC = Bottom_HUD_Margin; } else { X_Margins_SKC = 0; @@ -5248,17 +5248,17 @@ void Interface_Draw(PlayState* play) { s16 PosY_SKC_ori = 190+Y_Margins_SKC; s16 PosX_SKC; s16 PosY_SKC; - if (CVarGetInteger("gSKCPosType", 0) != 0) { - PosY_SKC = CVarGetInteger("gSKCPosY", 0)+Y_Margins_SKC; - if (CVarGetInteger("gSKCPosType", 0) == 1) {//Anchor Left - if (CVarGetInteger("gSKCUseMargins", 0) != 0) {X_Margins_SKC = Left_HUD_Margin;}; - PosX_SKC = OTRGetDimensionFromLeftEdge(CVarGetInteger("gSKCPosX", 0)+X_Margins_SKC); - } else if (CVarGetInteger("gSKCPosType", 0) == 2) {//Anchor Right - if (CVarGetInteger("gSKCUseMargins", 0) != 0) {X_Margins_SKC = Right_HUD_Margin;}; - PosX_SKC = OTRGetDimensionFromRightEdge(CVarGetInteger("gSKCPosX", 0)+X_Margins_SKC); - } else if (CVarGetInteger("gSKCPosType", 0) == 3) {//Anchor None - PosX_SKC = CVarGetInteger("gSKCPosX", 0); - } else if (CVarGetInteger("gSKCPosType", 0) == 4) {//Hidden + if (CVarGetInteger(CVAR_COSMETIC("HUD.SmallKey.PosType"), 0) != 0) { + PosY_SKC = CVarGetInteger(CVAR_COSMETIC("HUD.SmallKey.PosY"), 0)+Y_Margins_SKC; + if (CVarGetInteger(CVAR_COSMETIC("HUD.SmallKey.PosType"), 0) == 1) {//Anchor Left + if (CVarGetInteger(CVAR_COSMETIC("HUD.SmallKey.UseMargins"), 0) != 0) {X_Margins_SKC = Left_HUD_Margin;}; + PosX_SKC = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("HUD.SmallKey.PosX"), 0)+X_Margins_SKC); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.SmallKey.PosType"), 0) == 2) {//Anchor Right + if (CVarGetInteger(CVAR_COSMETIC("HUD.SmallKey.UseMargins"), 0) != 0) {X_Margins_SKC = Right_HUD_Margin;}; + PosX_SKC = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("HUD.SmallKey.PosX"), 0)+X_Margins_SKC); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.SmallKey.PosType"), 0) == 3) {//Anchor None + PosX_SKC = CVarGetInteger(CVAR_COSMETIC("HUD.SmallKey.PosX"), 0); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.SmallKey.PosType"), 0) == 4) {//Hidden PosX_SKC = -9999; } } else { @@ -5357,11 +5357,11 @@ void Interface_Draw(PlayState* play) { Minimap_Draw(play); if ((R_PAUSE_MENU_MODE != 2) && (R_PAUSE_MENU_MODE != 3)) { - if (CVarGetInteger("gMirroredWorld", 0)) { + if (CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0)) { gSPMatrix(OVERLAY_DISP++, interfaceCtx->view.projectionFlippedPtr, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); } func_8002C124(&play->actorCtx.targetCtx, play); // Draw Z-Target - if (CVarGetInteger("gMirroredWorld", 0)) { + if (CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0)) { gSPMatrix(OVERLAY_DISP++, interfaceCtx->view.projectionPtr, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); } @@ -5421,24 +5421,24 @@ void Interface_Draw(PlayState* play) { s16 BbtnPosY; s16 X_Margins_BtnB_label; s16 Y_Margins_BtnB_label; - if (CVarGetInteger(CVAR_COSMETIC("BButton.UseMargins"), 0) != 0) { - if (CVarGetInteger(CVAR_COSMETIC("BButton.PosType"), 0) == 0) {X_Margins_BtnB_label = Right_HUD_Margin;}; + if (CVarGetInteger(CVAR_COSMETIC("HUD.BButton.UseMargins"), 0) != 0) { + if (CVarGetInteger(CVAR_COSMETIC("HUD.BButton.PosType"), 0) == 0) {X_Margins_BtnB_label = Right_HUD_Margin;}; Y_Margins_BtnB_label = (Top_HUD_Margin*-1); } else { X_Margins_BtnB_label = 0; Y_Margins_BtnB_label = 0; } - if (CVarGetInteger(CVAR_COSMETIC("BButton.PosType"), 0) != 0) { - BbtnPosY = CVarGetInteger(CVAR_COSMETIC("BButton.PosY"), 0)+Y_Margins_BtnB_label+PosY_adjust; - if (CVarGetInteger(CVAR_COSMETIC("BButton.PosType"), 0) == 1) {//Anchor Left - if (CVarGetInteger(CVAR_COSMETIC("BButton.UseMargins"), 0) != 0) {X_Margins_BtnB_label = Left_HUD_Margin;}; - BbtnPosX = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("BButton.PosX"), 0)+X_Margins_BtnB_label+PosX_adjust); - } else if (CVarGetInteger(CVAR_COSMETIC("BButton.PosType"), 0) == 2) {//Anchor Right - if (CVarGetInteger(CVAR_COSMETIC("BButton.UseMargins"), 0) != 0) {X_Margins_BtnB_label = Right_HUD_Margin;}; - BbtnPosX = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("BButton.PosX"), 0)+X_Margins_BtnB_label+PosX_adjust); - } else if (CVarGetInteger(CVAR_COSMETIC("BButton.PosType"), 0) == 3) {//Anchor None - BbtnPosX = CVarGetInteger(CVAR_COSMETIC("BButton.PosX"), 0)+PosX_adjust; - } else if (CVarGetInteger(CVAR_COSMETIC("BButton.PosType"), 0) == 4) {//Hidden + if (CVarGetInteger(CVAR_COSMETIC("HUD.BButton.PosType"), 0) != 0) { + BbtnPosY = CVarGetInteger(CVAR_COSMETIC("HUD.BButton.PosY"), 0)+Y_Margins_BtnB_label+PosY_adjust; + if (CVarGetInteger(CVAR_COSMETIC("HUD.BButton.PosType"), 0) == 1) {//Anchor Left + if (CVarGetInteger(CVAR_COSMETIC("HUD.BButton.UseMargins"), 0) != 0) {X_Margins_BtnB_label = Left_HUD_Margin;}; + BbtnPosX = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("HUD.BButton.PosX"), 0)+X_Margins_BtnB_label+PosX_adjust); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.BButton.PosType"), 0) == 2) {//Anchor Right + if (CVarGetInteger(CVAR_COSMETIC("HUD.BButton.UseMargins"), 0) != 0) {X_Margins_BtnB_label = Right_HUD_Margin;}; + BbtnPosX = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("HUD.BButton.PosX"), 0)+X_Margins_BtnB_label+PosX_adjust); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.BButton.PosType"), 0) == 3) {//Anchor None + BbtnPosX = CVarGetInteger(CVAR_COSMETIC("HUD.BButton.PosX"), 0)+PosX_adjust; + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.BButton.PosType"), 0) == 4) {//Hidden BbtnPosX = -9999; } } else { @@ -5500,7 +5500,7 @@ void Interface_Draw(PlayState* play) { Interface_DrawAmmoCount(play, 3, interfaceCtx->cRightAlpha); } - if (CVarGetInteger("gDpadEquips", 0) != 0) { + if (CVarGetInteger(CVAR_SETTING("DpadEquips"), 0) != 0) { // DPad is only greyed-out when all 4 DPad directions are too uint16_t dpadAlpha = MAX(MAX(MAX(interfaceCtx->dpadUpAlpha, interfaceCtx->dpadDownAlpha), interfaceCtx->dpadLeftAlpha), @@ -5511,24 +5511,24 @@ void Interface_Draw(PlayState* play) { s16 DpadPosY; s16 X_Margins_Dpad; s16 Y_Margins_Dpad; - if (CVarGetInteger("gDPadUseMargins", 0) != 0) { - if (CVarGetInteger("gDPadPosType", 0) == 0) {X_Margins_Dpad = Right_HUD_Margin;}; + if (CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.UseMargins"), 0) != 0) { + if (CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosType"), 0) == 0) {X_Margins_Dpad = Right_HUD_Margin;}; Y_Margins_Dpad = (Top_HUD_Margin*-1); } else { Y_Margins_Dpad = 0; X_Margins_Dpad = 0; } - if (CVarGetInteger("gDPadPosType", 0) != 0) { - DpadPosY = CVarGetInteger("gDPadPosY", 0)+Y_Margins_Dpad; - if (CVarGetInteger("gDPadPosType", 0) == 1) {//Anchor Left - if (CVarGetInteger("gDPadUseMargins", 0) != 0) {X_Margins_Dpad = Left_HUD_Margin;}; - DpadPosX = OTRGetDimensionFromLeftEdge(CVarGetInteger("gDPadPosX", 0)+X_Margins_Dpad); - } else if (CVarGetInteger("gDPadPosType", 0) == 2) {//Anchor Right - if (CVarGetInteger("gDPadUseMargins", 0) != 0) {X_Margins_Dpad = Right_HUD_Margin;}; - DpadPosX = OTRGetDimensionFromRightEdge(CVarGetInteger("gDPadPosX", 0)+X_Margins_Dpad); - } else if (CVarGetInteger("gDPadPosType", 0) == 3) {//Anchor None - DpadPosX = CVarGetInteger("gDPadPosX", 0); - } else if (CVarGetInteger("gDPadPosType", 0) == 4) {//Hidden + if (CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosType"), 0) != 0) { + DpadPosY = CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosY"), 0)+Y_Margins_Dpad; + if (CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosType"), 0) == 1) {//Anchor Left + if (CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.UseMargins"), 0) != 0) {X_Margins_Dpad = Left_HUD_Margin;}; + DpadPosX = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosX"), 0)+X_Margins_Dpad); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosType"), 0) == 2) {//Anchor Right + if (CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.UseMargins"), 0) != 0) {X_Margins_Dpad = Right_HUD_Margin;}; + DpadPosX = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosX"), 0)+X_Margins_Dpad); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosType"), 0) == 3) {//Anchor None + DpadPosX = CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosX"), 0); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosType"), 0) == 4) {//Hidden DpadPosX = -9999; } } else { @@ -5597,7 +5597,7 @@ void Interface_Draw(PlayState* play) { Gfx_SetupDL_42Overlay(play->state.gfxCtx); s16 X_Margins_BtnA; s16 Y_Margins_BtnA; - if (CVarGetInteger(CVAR_COSMETIC("AButton.UseMargins"), 0) != 0) { + if (CVarGetInteger(CVAR_COSMETIC("HUD.AButton.UseMargins"), 0) != 0) { X_Margins_BtnA = Right_HUD_Margin; Y_Margins_BtnA = (Top_HUD_Margin*-1); } else { @@ -5612,21 +5612,21 @@ void Interface_Draw(PlayState* play) { s16 PosY_BtnA; s16 rAIconX; s16 rAIconY; - if (CVarGetInteger(CVAR_COSMETIC("AButton.PosType"), 0) != 0) { - PosY_BtnA = CVarGetInteger(CVAR_COSMETIC("AButton.PosY"), 0)+Y_Margins_BtnA; + if (CVarGetInteger(CVAR_COSMETIC("HUD.AButton.PosType"), 0) != 0) { + PosY_BtnA = CVarGetInteger(CVAR_COSMETIC("HUD.AButton.PosY"), 0)+Y_Margins_BtnA; rAIconY = 98.0f - PosY_BtnA; - if (CVarGetInteger(CVAR_COSMETIC("AButton.PosType"), 0) == 1) {//Anchor Left - if (CVarGetInteger(CVAR_COSMETIC("AButton.UseMargins"), 0) != 0) {X_Margins_BtnA = Left_HUD_Margin;}; - PosX_BtnA = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("AButton.PosX"), 0)+X_Margins_BtnA); - rAIconX = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("AButton.PosX"), 0)+X_Margins_BtnA); - } else if (CVarGetInteger(CVAR_COSMETIC("AButton.PosType"), 0) == 2) {//Anchor Right - if (CVarGetInteger(CVAR_COSMETIC("AButton.UseMargins"), 0) != 0) {X_Margins_BtnA = Right_HUD_Margin;}; - PosX_BtnA = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("AButton.PosX"), 0)+X_Margins_BtnA); - rAIconX= OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("AButton.PosX"), 0)+X_Margins_BtnA); - } else if (CVarGetInteger(CVAR_COSMETIC("AButton.PosType"), 0) == 3) {//Anchor None - PosX_BtnA = CVarGetInteger(CVAR_COSMETIC("AButton.PosX"), 0); - rAIconX = CVarGetInteger(CVAR_COSMETIC("AButton.PosX"), 0); - } else if (CVarGetInteger(CVAR_COSMETIC("AButton.PosType"), 0) == 4) {//Hidden + if (CVarGetInteger(CVAR_COSMETIC("HUD.AButton.PosType"), 0) == 1) {//Anchor Left + if (CVarGetInteger(CVAR_COSMETIC("HUD.AButton.UseMargins"), 0) != 0) {X_Margins_BtnA = Left_HUD_Margin;}; + PosX_BtnA = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("HUD.AButton.PosX"), 0)+X_Margins_BtnA); + rAIconX = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("HUD.AButton.PosX"), 0)+X_Margins_BtnA); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.AButton.PosType"), 0) == 2) {//Anchor Right + if (CVarGetInteger(CVAR_COSMETIC("HUD.AButton.UseMargins"), 0) != 0) {X_Margins_BtnA = Right_HUD_Margin;}; + PosX_BtnA = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("HUD.AButton.PosX"), 0)+X_Margins_BtnA); + rAIconX= OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("HUD.AButton.PosX"), 0)+X_Margins_BtnA); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.AButton.PosType"), 0) == 3) {//Anchor None + PosX_BtnA = CVarGetInteger(CVAR_COSMETIC("HUD.AButton.PosX"), 0); + rAIconX = CVarGetInteger(CVAR_COSMETIC("HUD.AButton.PosX"), 0); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.AButton.PosType"), 0) == 4) {//Hidden PosX_BtnA = -9999; rAIconX = -9999; } @@ -5730,17 +5730,17 @@ void Interface_Draw(PlayState* play) { s16 CarrotsPosX = ZREG(14); s16 CarrotsPosY = ZREG(15); s16 CarrotsMargins_X = 0; - if (CVarGetInteger("gCarrotsPosType", 0) != 0) { - CarrotsPosY = CVarGetInteger("gCarrotsPosY", 0); - if (CVarGetInteger("gCarrotsPosType", 0) == 1) {//Anchor Left - if (CVarGetInteger("gCarrotsUseMargins", 0) != 0) {CarrotsMargins_X = Left_HUD_Margin;}; - CarrotsPosX = OTRGetDimensionFromLeftEdge(CVarGetInteger("gCarrotsPosX", 0)+CarrotsMargins_X); - } else if (CVarGetInteger("gCarrotsPosType", 0) == 2) {//Anchor Right - if (CVarGetInteger("gCarrotsUseMargins", 0) != 0) {CarrotsMargins_X = Right_HUD_Margin;}; - CarrotsPosX = OTRGetDimensionFromRightEdge(CVarGetInteger("gCarrotsPosX", 0)+CarrotsMargins_X); - } else if (CVarGetInteger("gCarrotsPosType", 0) == 3) {//Anchor None - CarrotsPosX = CVarGetInteger("gCarrotsPosX", 0); - } else if (CVarGetInteger("gCarrotsPosType", 0) == 4) {//Hidden + if (CVarGetInteger(CVAR_COSMETIC("HUD.Carrots.PosType"), 0) != 0) { + CarrotsPosY = CVarGetInteger(CVAR_COSMETIC("HUD.Carrots.PosY"), 0); + if (CVarGetInteger(CVAR_COSMETIC("HUD.Carrots.PosType"), 0) == 1) {//Anchor Left + if (CVarGetInteger(CVAR_COSMETIC("HUD.Carrots.UseMargins"), 0) != 0) {CarrotsMargins_X = Left_HUD_Margin;}; + CarrotsPosX = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("HUD.Carrots.PosX"), 0)+CarrotsMargins_X); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.Carrots.PosType"), 0) == 2) {//Anchor Right + if (CVarGetInteger(CVAR_COSMETIC("HUD.Carrots.UseMargins"), 0) != 0) {CarrotsMargins_X = Right_HUD_Margin;}; + CarrotsPosX = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("HUD.Carrots.PosX"), 0)+CarrotsMargins_X); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.Carrots.PosType"), 0) == 3) {//Anchor None + CarrotsPosX = CVarGetInteger(CVAR_COSMETIC("HUD.Carrots.PosX"), 0); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.Carrots.PosType"), 0) == 4) {//Hidden CarrotsPosX = -9999; } } @@ -5759,25 +5759,25 @@ void Interface_Draw(PlayState* play) { } else { // Score for the Horseback Archery s32 X_Margins_Archery; - if (CVarGetInteger("gASUseMargins", 0) != 0) { - if (CVarGetInteger("gASPosType", 0) == 0) {X_Margins_Archery = Right_HUD_Margin;}; + if (CVarGetInteger(CVAR_COSMETIC("HUD.ArcheryScore.UseMargins"), 0) != 0) { + if (CVarGetInteger(CVAR_COSMETIC("HUD.ArcheryScore.PosType"), 0) == 0) {X_Margins_Archery = Right_HUD_Margin;}; } else { X_Margins_Archery = 0; } s16 ArcheryPos_Y = ZREG(15); s16 ArcheryPos_X = OTRGetRectDimensionFromRightEdge(WREG(32)+X_Margins_Archery); - if (CVarGetInteger("gASPosType", 0) != 0) { - ArcheryPos_Y = CVarGetInteger("gASPosY", 0); - if (CVarGetInteger("gASPosType", 0) == 1) {//Anchor Left - if (CVarGetInteger("gASUseMargins", 0) != 0) {X_Margins_Archery = Left_HUD_Margin;}; - ArcheryPos_X = OTRGetRectDimensionFromLeftEdge(CVarGetInteger("gASPosX", 0)+X_Margins_Archery); - } else if (CVarGetInteger("gASPosType", 0) == 2) {//Anchor Right - if (CVarGetInteger("gASUseMargins", 0) != 0) {X_Margins_Archery = Right_HUD_Margin;}; - ArcheryPos_X = OTRGetRectDimensionFromRightEdge(CVarGetInteger("gASPosX", 0)+X_Margins_Archery); - } else if (CVarGetInteger("gASPosType", 0) == 3) {//Anchor None - ArcheryPos_X = CVarGetInteger("gASPosX", 0)+204+X_Margins_Archery; - } else if (CVarGetInteger("gASPosType", 0) == 4) {//Hidden + if (CVarGetInteger(CVAR_COSMETIC("HUD.ArcheryScore.PosType"), 0) != 0) { + ArcheryPos_Y = CVarGetInteger(CVAR_COSMETIC("HUD.ArcheryScore.PosY"), 0); + if (CVarGetInteger(CVAR_COSMETIC("HUD.ArcheryScore.PosType"), 0) == 1) {//Anchor Left + if (CVarGetInteger(CVAR_COSMETIC("HUD.ArcheryScore.UseMargins"), 0) != 0) {X_Margins_Archery = Left_HUD_Margin;}; + ArcheryPos_X = OTRGetRectDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("HUD.ArcheryScore.PosX"), 0)+X_Margins_Archery); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.ArcheryScore.PosType"), 0) == 2) {//Anchor Right + if (CVarGetInteger(CVAR_COSMETIC("HUD.ArcheryScore.UseMargins"), 0) != 0) {X_Margins_Archery = Right_HUD_Margin;}; + ArcheryPos_X = OTRGetRectDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("HUD.ArcheryScore.PosX"), 0)+X_Margins_Archery); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.ArcheryScore.PosType"), 0) == 3) {//Anchor None + ArcheryPos_X = CVarGetInteger(CVAR_COSMETIC("HUD.ArcheryScore.PosX"), 0)+204+X_Margins_Archery; + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.ArcheryScore.PosType"), 0) == 4) {//Hidden ArcheryPos_X = -9999; } } @@ -6197,24 +6197,24 @@ void Interface_Draw(PlayState* play) { gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, 255); gDPSetEnvColor(OVERLAY_DISP++, 0, 0, 0, 0); s32 X_Margins_Timer; - if (CVarGetInteger("gTimersUseMargins", 0) != 0) { - if (CVarGetInteger("gTimersPosType", 0) == 0) {X_Margins_Timer = Left_HUD_Margin;}; + if (CVarGetInteger(CVAR_COSMETIC("HUD.Timers.UseMargins"), 0) != 0) { + if (CVarGetInteger(CVAR_COSMETIC("HUD.Timers.PosType"), 0) == 0) {X_Margins_Timer = Left_HUD_Margin;}; } else { X_Margins_Timer = 0; } svar5 = OTRGetRectDimensionFromLeftEdge(gSaveContext.timerX[svar6]+X_Margins_Timer); svar2 = gSaveContext.timerY[svar6]; - if (CVarGetInteger("gTimersPosType", 0) != 0) { - svar2 = (CVarGetInteger("gTimersPosY", 0)); - if (CVarGetInteger("gTimersPosType", 0) == 1) {//Anchor Left - if (CVarGetInteger("gTimersUseMargins", 0) != 0) {X_Margins_Timer = Left_HUD_Margin;}; - svar5 = OTRGetRectDimensionFromLeftEdge(CVarGetInteger("gTimersPosX", 0)+X_Margins_Timer); - } else if (CVarGetInteger("gTimersPosType", 0) == 2) {//Anchor Right - if (CVarGetInteger("gTimersUseMargins", 0) != 0) {X_Margins_Timer = Right_HUD_Margin;}; - svar5 = OTRGetRectDimensionFromRightEdge(CVarGetInteger("gTimersPosX", 0)+X_Margins_Timer); - } else if (CVarGetInteger("gTimersPosType", 0) == 3) {//Anchor None - svar5 = CVarGetInteger("gTimersPosX", 0)+204+X_Margins_Timer; - } else if (CVarGetInteger("gTimersPosType", 0) == 4) {//Hidden + if (CVarGetInteger(CVAR_COSMETIC("HUD.Timers.PosType"), 0) != 0) { + svar2 = (CVarGetInteger(CVAR_COSMETIC("HUD.Timers.PosY"), 0)); + if (CVarGetInteger(CVAR_COSMETIC("HUD.Timers.PosType"), 0) == 1) {//Anchor Left + if (CVarGetInteger(CVAR_COSMETIC("HUD.Timers.UseMargins"), 0) != 0) {X_Margins_Timer = Left_HUD_Margin;}; + svar5 = OTRGetRectDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("HUD.Timers.PosX"), 0)+X_Margins_Timer); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.Timers.PosType"), 0) == 2) {//Anchor Right + if (CVarGetInteger(CVAR_COSMETIC("HUD.Timers.UseMargins"), 0) != 0) {X_Margins_Timer = Right_HUD_Margin;}; + svar5 = OTRGetRectDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("HUD.Timers.PosX"), 0)+X_Margins_Timer); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.Timers.PosType"), 0) == 3) {//Anchor None + svar5 = CVarGetInteger(CVAR_COSMETIC("HUD.Timers.PosX"), 0)+204+X_Margins_Timer; + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.Timers.PosType"), 0) == 4) {//Hidden svar5 = -9999; } } @@ -6273,31 +6273,31 @@ void Interface_DrawTotalGameplayTimer(PlayState* play) { // Draw timer based on the Gameplay Stats total time. if ((IS_BOSS_RUSH && gSaveContext.bossRushOptions[BR_OPTIONS_TIMER] == BR_CHOICE_TIMER_YES) || - (CVarGetInteger("gGameplayStats.ShowIngameTimer", 0) && gSaveContext.fileNum >= 0 && gSaveContext.fileNum <= 2)) { + (CVarGetInteger(CVAR_ENHANCEMENT("GameplayStats.ShowIngameTimer"), 0) && gSaveContext.fileNum >= 0 && gSaveContext.fileNum <= 2)) { s32 X_Margins_Timer = 0; - if (CVarGetInteger("gIGTUseMargins", 0) != 0) { - if (CVarGetInteger("gIGTPosType", 0) == 0) { + if (CVarGetInteger(CVAR_COSMETIC("HUD.IGT.UseMargins"), 0) != 0) { + if (CVarGetInteger(CVAR_COSMETIC("HUD.IGT.PosType"), 0) == 0) { X_Margins_Timer = Left_HUD_Margin; }; } s32 rectLeftOri = OTRGetRectDimensionFromLeftEdge(24 + X_Margins_Timer); s32 rectTopOri = 73; - if (CVarGetInteger("gIGTPosType", 0) != 0) { - rectTopOri = (CVarGetInteger("gIGTPosY", 0)); - if (CVarGetInteger("gIGTPosType", 0) == 1) { // Anchor Left - if (CVarGetInteger("gIGTUseMargins", 0) != 0) { + if (CVarGetInteger(CVAR_COSMETIC("HUD.IGT.PosType"), 0) != 0) { + rectTopOri = (CVarGetInteger(CVAR_COSMETIC("HUD.IGT.PosY"), 0)); + if (CVarGetInteger(CVAR_COSMETIC("HUD.IGT.PosType"), 0) == 1) { // Anchor Left + if (CVarGetInteger(CVAR_COSMETIC("HUD.IGT.UseMargins"), 0) != 0) { X_Margins_Timer = Left_HUD_Margin; }; - rectLeftOri = OTRGetRectDimensionFromLeftEdge(CVarGetInteger("gIGTPosX", 0) + X_Margins_Timer); - } else if (CVarGetInteger("gIGTPosType", 0) == 2) { // Anchor Right - if (CVarGetInteger("gIGTUseMargins", 0) != 0) { + rectLeftOri = OTRGetRectDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("HUD.IGT.PosX"), 0) + X_Margins_Timer); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.IGT.PosType"), 0) == 2) { // Anchor Right + if (CVarGetInteger(CVAR_COSMETIC("HUD.IGT.UseMargins"), 0) != 0) { X_Margins_Timer = Right_HUD_Margin; }; - rectLeftOri = OTRGetRectDimensionFromRightEdge(CVarGetInteger("gIGTPosX", 0) + X_Margins_Timer); - } else if (CVarGetInteger("gIGTPosType", 0) == 3) { // Anchor None - rectLeftOri = CVarGetInteger("gIGTPosX", 0) + 204 + X_Margins_Timer; - } else if (CVarGetInteger("gIGTPosType", 0) == 4) { // Hidden + rectLeftOri = OTRGetRectDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("HUD.IGT.PosX"), 0) + X_Margins_Timer); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.IGT.PosType"), 0) == 3) { // Anchor None + rectLeftOri = CVarGetInteger(CVAR_COSMETIC("HUD.IGT.PosX"), 0) + 204 + X_Margins_Timer; + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.IGT.PosType"), 0) == 4) { // Hidden rectLeftOri = -9999; } } @@ -6384,10 +6384,10 @@ void Interface_Update(PlayState* play) { u16 action; Input* debugInput = &play->state.input[2]; - Top_HUD_Margin = CVarGetInteger("gHUDMargin_T", 0); - Left_HUD_Margin = CVarGetInteger("gHUDMargin_L", 0); - Right_HUD_Margin = CVarGetInteger("gHUDMargin_R", 0); - Bottom_HUD_Margin = CVarGetInteger("gHUDMargin_B", 0); + Top_HUD_Margin = CVarGetInteger(CVAR_COSMETIC("HUD.Margin.T"), 0); + Left_HUD_Margin = CVarGetInteger(CVAR_COSMETIC("HUD.Margin.L"), 0); + Right_HUD_Margin = CVarGetInteger(CVAR_COSMETIC("HUD.Margin.R"), 0); + Bottom_HUD_Margin = CVarGetInteger(CVAR_COSMETIC("HUD.Margin.B"), 0); GameInteractor_ExecuteOnInterfaceUpdate(); diff --git a/soh/src/code/z_play.c b/soh/src/code/z_play.c index 6e745ea7fa0..f3773d6a755 100644 --- a/soh/src/code/z_play.c +++ b/soh/src/code/z_play.c @@ -627,12 +627,6 @@ void Play_Init(GameState* thisx) { gTrnsnUnkState = 0; play->transitionMode = TRANS_MODE_OFF; - if (CVarGetInteger("gSceneTransitions", 255)!= 255){ - play->transitionMode = CVarGetInteger("gSceneTransitions", 0); - gSaveContext.nextTransitionType = CVarGetInteger("gSceneTransitions", 0); - play->transitionType = CVarGetInteger("gSceneTransitions", 0); - } - FrameAdvance_Init(&play->frameAdvCtx); Rand_Seed((u32)osGetTime()); Matrix_Init(&play->state); @@ -800,7 +794,7 @@ void Play_Update(PlayState* play) { HREG(82) = 0; } - if (CVarGetInteger("gFreeCamera", 0) && Player_InCsMode(play)) { + if (CVarGetInteger(CVAR_SETTING("FreeLook.Enabled"), 0) && Player_InCsMode(play)) { play->manualCamera = false; } @@ -1514,7 +1508,7 @@ void Play_Draw(PlayState* play) { // Flip the projections and invert culling for the OPA and XLU display buffers // These manage the world and effects - if (CVarGetInteger("gMirroredWorld", 0)) { + if (CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0)) { gSPSetExtraGeometryMode(POLY_OPA_DISP++, G_EX_INVERT_CULLING); gSPSetExtraGeometryMode(POLY_XLU_DISP++, G_EX_INVERT_CULLING); gSPMatrix(POLY_OPA_DISP++, play->view.projectionFlippedPtr, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); @@ -1748,7 +1742,7 @@ void Play_Draw(PlayState* play) { GameInteractor_ExecuteOnPlayDrawEnd(); // Reset the inverted culling - if (CVarGetInteger("gMirroredWorld", 0)) { + if (CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0)) { gSPClearExtraGeometryMode(POLY_OPA_DISP++, G_EX_INVERT_CULLING); gSPClearExtraGeometryMode(POLY_XLU_DISP++, G_EX_INVERT_CULLING); } @@ -1796,11 +1790,11 @@ void Play_Main(GameState* thisx) { PlayState* play = (PlayState*)thisx; // Decrease the easy pause buffer timer every frame - if (CVarGetInteger("gCheatEasyPauseBufferTimer", 0) > 0) { - CVarSetInteger("gCheatEasyPauseBufferTimer", CVarGetInteger("gCheatEasyPauseBufferTimer", 0) - 1); + if (CVarGetInteger(CVAR_GENERAL("CheatEasyPauseBufferTimer"), 0) > 0) { + CVarSetInteger(CVAR_GENERAL("CheatEasyPauseBufferTimer"), CVarGetInteger(CVAR_GENERAL("CheatEasyPauseBufferTimer"), 0) - 1); } - if (play->envCtx.unk_EE[2] == 0 && CVarGetInteger("gLetItSnow", 0)) { + if (play->envCtx.unk_EE[2] == 0 && CVarGetInteger(CVAR_GENERAL("LetItSnow"), 0)) { play->envCtx.unk_EE[3] = 64; Actor_Spawn(&gPlayState->actorCtx, gPlayState, ACTOR_OBJECT_KANKYO, 0, 0, 0, 0, 0, 0, 3, 0); } @@ -1977,11 +1971,11 @@ void Play_InitScene(PlayState* play, s32 spawn) } void Play_SpawnScene(PlayState* play, s32 sceneNum, s32 spawn) { - uint8_t mqMode = CVarGetInteger("gBetterDebugWarpScreenMQMode", WARP_MODE_OVERRIDE_OFF); - int16_t mqModeScene = CVarGetInteger("gBetterDebugWarpScreenMQModeScene", -1); + uint8_t mqMode = CVarGetInteger(CVAR_GENERAL("BetterDebugWarpScreenMQMode"), WARP_MODE_OVERRIDE_OFF); + int16_t mqModeScene = CVarGetInteger(CVAR_GENERAL("BetterDebugWarpScreenMQModeScene"), -1); if (mqMode != WARP_MODE_OVERRIDE_OFF && sceneNum != mqModeScene) { - CVarClear("gBetterDebugWarpScreenMQMode"); - CVarClear("gBetterDebugWarpScreenMQModeScene"); + CVarClear(CVAR_GENERAL("BetterDebugWarpScreenMQMode")); + CVarClear(CVAR_GENERAL("BetterDebugWarpScreenMQModeScene")); } OTRPlay_SpawnScene(play, sceneNum, spawn); diff --git a/soh/src/code/z_player_lib.c b/soh/src/code/z_player_lib.c index c38dc8ca8cd..b9ef17f6e82 100644 --- a/soh/src/code/z_player_lib.c +++ b/soh/src/code/z_player_lib.c @@ -1558,7 +1558,7 @@ void func_800906D4(PlayState* play, Player* this, Vec3f* newTipPos) { void Player_DrawGetItemIceTrap(PlayState* play, Player* this, Vec3f* refPos, s32 drawIdPlusOne, f32 height) { OPEN_DISPS(play->state.gfxCtx); - if (CVarGetInteger("gLetItSnow", 0)) { + if (CVarGetInteger(CVAR_GENERAL("LetItSnow"), 0)) { Gfx_SetupDL_25Opa(play->state.gfxCtx); Matrix_Scale(0.2f, 0.2f, 0.2f, MTXMODE_APPLY); @@ -2123,8 +2123,8 @@ void Player_DrawPauseImpl(PlayState* play, void* seg04, void* seg06, SkelAnime* playerSwordAndShield[1] = shield; Matrix_SetTranslateRotateYXZ(pos->x - ((CVarGetInteger(CVAR_ENHANCEMENT("PauseLiveLink"), 0) && LINK_AGE_IN_YEARS == YEARS_ADULT) ? 25 : 0), - pos->y - (CVarGetInteger("gPauseTriforce", 0) ? 16 : 0), pos->z, rot); - Matrix_Scale(scale * (CVarGetInteger("gMirroredWorld", 0) ? -1 : 1), scale, scale, MTXMODE_APPLY); + pos->y - (CVarGetInteger(CVAR_GENERAL("PauseTriforce"), 0) ? 16 : 0), pos->z, rot); + Matrix_Scale(scale * (CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0) ? -1 : 1), scale, scale, MTXMODE_APPLY); gSPSegment(POLY_OPA_DISP++, 0x04, seg04); gSPSegment(POLY_OPA_DISP++, 0x06, seg06); @@ -2142,11 +2142,11 @@ void Player_DrawPauseImpl(PlayState* play, void* seg04, void* seg06, SkelAnime* Player_DrawImpl(play, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, 0, tunic, boots, 0, Player_OverrideLimbDrawPause, NULL, &playerSwordAndShield); - if (CVarGetInteger("gPauseTriforce", 0)) { + if (CVarGetInteger(CVAR_GENERAL("PauseTriforce"), 0)) { Matrix_SetTranslateRotateYXZ(pos->x - (LINK_AGE_IN_YEARS == YEARS_ADULT ? 25 : 0), pos->y + 280 + (LINK_AGE_IN_YEARS == YEARS_ADULT ? 48 : 0), pos->z, rot); - Matrix_Scale(scale * (CVarGetInteger("gMirroredWorld", 0) ? -1 : 1), scale * 1, scale * 1, MTXMODE_APPLY); + Matrix_Scale(scale * (CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0) ? -1 : 1), scale * 1, scale * 1, MTXMODE_APPLY); Gfx* ohNo = POLY_XLU_DISP; POLY_XLU_DISP = POLY_OPA_DISP; @@ -2202,7 +2202,7 @@ void Player_DrawPause(PlayState* play, u8* segment, SkelAnime* skelAnime, Vec3f* }; s16 AnimArraySize = ARRAY_COUNT(PauseMenuAnimSet); - if (CVarGetInteger(CVAR_ENHANCEMENT("PauseLiveLink"), 0) || CVarGetInteger("gPauseTriforce", 0)) { + if (CVarGetInteger(CVAR_ENHANCEMENT("PauseLiveLink"), 0) || CVarGetInteger(CVAR_GENERAL("PauseTriforce"), 0)) { uintptr_t anim = 0; // Initialise anim if (CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD) >= EQUIP_VALUE_SWORD_BIGGORON) { @@ -2359,7 +2359,7 @@ void Player_DrawPause(PlayState* play, u8* segment, SkelAnime* skelAnime, Vec3f* //anim = gPlayerAnim_link_wait_itemD2_20f; // Use for biggoron sword? - if (CVarGetInteger("gPauseTriforce", 0)) { + if (CVarGetInteger(CVAR_GENERAL("PauseTriforce"), 0)) { anim = gPlayerAnim_link_magic_kaze2; sword = 0; shield = 0; diff --git a/soh/src/code/z_room.c b/soh/src/code/z_room.c index 3b60850405f..8970dac1b36 100644 --- a/soh/src/code/z_room.c +++ b/soh/src/code/z_room.c @@ -5,6 +5,7 @@ #include "global.h" #include "vt.h" #include "soh/Enhancements/randomizer/randomizer_entrance.h" +#include "soh/Enhancements/game-interactor/GameInteractor.h" #include #include @@ -275,7 +276,7 @@ void Room_DrawBackground2D(Gfx** gfxP, void* tex, void* tlut, u16 width, u16 hei bg->b.imageFmt = fmt; bg->b.imageSiz = siz; bg->b.imagePal = 0; - bg->b.imageFlip = CVarGetInteger("gMirroredWorld", 0) ? G_BG_FLAG_FLIPS : 0; + bg->b.imageFlip = CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0) ? G_BG_FLAG_FLIPS : 0; // When an alt resource exists for the background, we need to unload the original asset // to clear the cache so the alt asset will be loaded instead @@ -412,7 +413,7 @@ BgImage* func_80096A74(PolygonType1* polygon1, PlayState* play) { camera = GET_ACTIVE_CAM(play); camId = camera->camDataIdx; - if (camId == -1 && (CVarGetInteger(CVAR_CHEAT("NoRestrictItems"), 0) || CVarGetInteger("gCrowdControl", 0))) { + if (camId == -1 && (CVarGetInteger(CVAR_CHEAT("NoRestrictItems"), 0) || (CVarGetInteger(CVAR_REMOTE("Scheme"), GI_SCHEME_SAIL) == GI_SCHEME_CROWD_CONTROL && CVarGetInteger(CVAR_REMOTE("Enabled"), 0)))) { // This prevents a crash when using items that change the // camera (such as din's fire), voiding out or dying on // scenes with prerendered backgrounds. diff --git a/soh/src/code/z_sram.c b/soh/src/code/z_sram.c index 60285a8bf13..af92afe9120 100644 --- a/soh/src/code/z_sram.c +++ b/soh/src/code/z_sram.c @@ -232,7 +232,7 @@ void Sram_InitSave(FileChooseContext* fileChooseCtx) { gSaveContext.dayTime = 0x6AAB; gSaveContext.cutsceneIndex = 0xFFF1; - if ((fileChooseCtx->buttonIndex == 0 && CVarGetInteger(CVAR_DEVELOPER_TOOLS("DebugEnabled"), 0)) || CVarGetInteger("gNaviSkipCutscene", 0)) { + if ((fileChooseCtx->buttonIndex == 0 && CVarGetInteger(CVAR_DEVELOPER_TOOLS("DebugEnabled"), 0))) { gSaveContext.cutsceneIndex = 0; } @@ -245,7 +245,7 @@ void Sram_InitSave(FileChooseContext* fileChooseCtx) { u8 currentQuest = fileChooseCtx->questType[fileChooseCtx->buttonIndex]; if (currentQuest == QUEST_RANDOMIZER && - strnlen(CVarGetString("gSpoilerLog", ""), 1) != 0) { + strnlen(CVarGetString(CVAR_GENERAL("SpoilerLog"), ""), 1) != 0) { gSaveContext.questId = QUEST_RANDOMIZER; Randomizer_InitSaveFile(); diff --git a/soh/src/code/z_view.c b/soh/src/code/z_view.c index 42e4bcce7b7..c6235c9237c 100644 --- a/soh/src/code/z_view.c +++ b/soh/src/code/z_view.c @@ -432,7 +432,7 @@ s32 func_800AAA9C(View* view) { } osSyncPrintf("\n"); } - if (CVarGetInteger("gMirroredWorld", 0)) { + if (CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0)) { MtxF flipF; SkinMatrix_Clear(&flipF); flipF.xx = -1.0; @@ -553,7 +553,7 @@ s32 func_800AB2C4(View* view) { (f32)gScreenHeight * 0.5f, -30, view->zFar, view->scale); // This is for z-targeting - if (CVarGetInteger("gMirroredWorld", 0)) { + if (CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0)) { MtxF flipF; SkinMatrix_Clear(&flipF); flipF.xx = -1.0; diff --git a/soh/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c b/soh/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c index bb521ede92c..80457e5fb52 100644 --- a/soh/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c +++ b/soh/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c @@ -258,7 +258,7 @@ void ArmsHook_Shoot(ArmsHook* this, PlayState* play) { sp60.y = this->unk_1F4.y - (this->unk_1E8.y - this->unk_1F4.y); sp60.z = this->unk_1F4.z - (this->unk_1E8.z - this->unk_1F4.z); u16 buttonsToCheck = BTN_A | BTN_B | BTN_R | BTN_CUP | BTN_CLEFT | BTN_CRIGHT | BTN_CDOWN; - if (CVarGetInteger("gDpadEquips", 0) != 0) { + if (CVarGetInteger(CVAR_SETTING("DpadEquips"), 0) != 0) { buttonsToCheck |= BTN_DUP | BTN_DDOWN | BTN_DLEFT | BTN_DRIGHT; } if (BgCheck_EntityLineTest1(&play->colCtx, &sp60, &this->unk_1E8, &sp78, &poly, true, true, true, true, diff --git a/soh/src/overlays/actors/ovl_Bg_Mori_Bigst/z_bg_mori_bigst.c b/soh/src/overlays/actors/ovl_Bg_Mori_Bigst/z_bg_mori_bigst.c index 6e1c36f78fc..ea4cfbfec8e 100644 --- a/soh/src/overlays/actors/ovl_Bg_Mori_Bigst/z_bg_mori_bigst.c +++ b/soh/src/overlays/actors/ovl_Bg_Mori_Bigst/z_bg_mori_bigst.c @@ -6,6 +6,7 @@ #include "z_bg_mori_bigst.h" #include "objects/object_mori_objects/object_mori_objects.h" +#include "soh/Enhancements/game-interactor/GameInteractor.h" #define FLAGS ACTOR_FLAG_UPDATE_WHILE_CULLED @@ -216,8 +217,8 @@ void BgMoriBigst_SetupStalfosPairFight(BgMoriBigst* this, PlayState* play) { void BgMoriBigst_StalfosPairFight(BgMoriBigst* this, PlayState* play) { if ((this->dyna.actor.home.rot.z == 0 || // Check if all enemies are defeated instead of the regular stalfos when enemy randomizer or crowd control is on. - (Flags_GetTempClear(play, this->dyna.actor.room) && (CVarGetInteger(CVAR_ENHANCEMENT("RandomizedEnemies"), 0) || (CVarGetInteger("gCrowdControl", 0))))) && - !Player_InCsMode(play)) { + (Flags_GetTempClear(play, this->dyna.actor.room) && (CVarGetInteger(CVAR_ENHANCEMENT("RandomizedEnemies"), 0) || + ((CVarGetInteger(CVAR_REMOTE("Scheme"), GI_SCHEME_SAIL) == GI_SCHEME_CROWD_CONTROL && CVarGetInteger(CVAR_REMOTE("Enabled"), 0)))))) && !Player_InCsMode(play)) { Flags_SetSwitch(play, (this->dyna.actor.params >> 8) & 0x3F); BgMoriBigst_SetupDone(this, play); } diff --git a/soh/src/overlays/actors/ovl_Bg_Spot06_Objects/z_bg_spot06_objects.c b/soh/src/overlays/actors/ovl_Bg_Spot06_Objects/z_bg_spot06_objects.c index 816f96aa4dd..9a22a21c67c 100644 --- a/soh/src/overlays/actors/ovl_Bg_Spot06_Objects/z_bg_spot06_objects.c +++ b/soh/src/overlays/actors/ovl_Bg_Spot06_Objects/z_bg_spot06_objects.c @@ -251,7 +251,7 @@ void BgSpot06Objects_GateSpawnBubbles(BgSpot06Objects* this, PlayState* play) { void BgSpot06Objects_GateWaitForSwitch(BgSpot06Objects* this, PlayState* play) { s32 i; - if ((CVarGetInteger("gWaterTempleGateFix", 0) == 0 || LINK_IS_ADULT) && Flags_GetSwitch(play, this->switchFlag)) { + if (Flags_GetSwitch(play, this->switchFlag)) { this->timer = 100; this->dyna.actor.world.pos.y += 3.0f; this->actionFunc = BgSpot06Objects_GateWaitToOpen; diff --git a/soh/src/overlays/actors/ovl_En_Blkobj/z_en_blkobj.c b/soh/src/overlays/actors/ovl_En_Blkobj/z_en_blkobj.c index d612475d48b..0d367a4119a 100644 --- a/soh/src/overlays/actors/ovl_En_Blkobj/z_en_blkobj.c +++ b/soh/src/overlays/actors/ovl_En_Blkobj/z_en_blkobj.c @@ -6,6 +6,7 @@ #include "z_en_blkobj.h" #include "objects/object_blkobj/object_blkobj.h" +#include "soh/Enhancements/game-interactor/GameInteractor.h" #define FLAGS (ACTOR_FLAG_UPDATE_WHILE_CULLED | ACTOR_FLAG_DRAW_WHILE_CULLED) @@ -104,8 +105,11 @@ void EnBlkobj_DarkLinkFight(EnBlkobj* this, PlayState* play) { // Check for if Dark Link is defeated in authentic gameplay. // Check for if all enemies are defeated with enemy randomizer or crowd control on. uint8_t roomCleared = - (!CVarGetInteger(CVAR_ENHANCEMENT("RandomizedEnemies"), 0) && !CVarGetInteger("gCrowdControl", 0) && Actor_Find(&play->actorCtx, ACTOR_EN_TORCH2, ACTORCAT_BOSS) == NULL) || - ((CVarGetInteger(CVAR_ENHANCEMENT("RandomizedEnemies"), 0) || CVarGetInteger("gCrowdControl", 0)) && Flags_GetTempClear(play, this->dyna.actor.room)); + (!CVarGetInteger(CVAR_ENHANCEMENT("RandomizedEnemies"), 0) && + !(CVarGetInteger(CVAR_REMOTE("Scheme"), GI_SCHEME_SAIL) == GI_SCHEME_CROWD_CONTROL && CVarGetInteger(CVAR_REMOTE("Enabled"), 0)) && + Actor_Find(&play->actorCtx, ACTOR_EN_TORCH2, ACTORCAT_BOSS) == NULL) || + ((CVarGetInteger(CVAR_ENHANCEMENT("RandomizedEnemies"), 0) || (CVarGetInteger(CVAR_REMOTE("Scheme"), GI_SCHEME_SAIL) == GI_SCHEME_CROWD_CONTROL && CVarGetInteger(CVAR_REMOTE("Enabled"), 0))) && + Flags_GetTempClear(play, this->dyna.actor.room)); if (roomCleared) { Flags_SetClear(play, this->dyna.actor.room); this->timer++; diff --git a/soh/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c b/soh/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c index 40ba64503f7..c265b3eb070 100644 --- a/soh/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c +++ b/soh/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c @@ -491,7 +491,7 @@ void EnBomChu_Draw(Actor* thisx, PlayState* play) { f32 colorIntensity; s32 blinkHalfPeriod; s32 blinkTime; - Color_RGB8 BombchuCol = CVarGetColor24("gBombTrailCol", BombchuColorOriginal); + Color_RGB8 BombchuCol = CVarGetColor24(CVAR_COSMETIC("Trails.Bombchu.Value"), BombchuColorOriginal); OPEN_DISPS(play->state.gfxCtx); diff --git a/soh/src/overlays/actors/ovl_En_Box/z_en_box.c b/soh/src/overlays/actors/ovl_En_Box/z_en_box.c index 7ec29b818c8..ee052bc584b 100644 --- a/soh/src/overlays/actors/ovl_En_Box/z_en_box.c +++ b/soh/src/overlays/actors/ovl_En_Box/z_en_box.c @@ -733,7 +733,7 @@ void EnBox_UpdateSizeAndTexture(EnBox* this, PlayState* play) { } } - if (CVarGetInteger("gLetItSnow", 0) && hasChristmasChestTexturesAvailable && hasCreatedRandoChestTextures && !hasCustomChestDLs) { + if (CVarGetInteger(CVAR_GENERAL("LetItSnow"), 0) && hasChristmasChestTexturesAvailable && hasCreatedRandoChestTextures && !hasCustomChestDLs) { if (this->dyna.actor.scale.x == 0.01f) { this->boxBodyDL = gChristmasRedTreasureChestChestFrontDL; this->boxLidDL = gChristmasRedTreasureChestChestSideAndLidDL; diff --git a/soh/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c b/soh/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c index c4ed47bf630..f0f6b5bb523 100644 --- a/soh/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c +++ b/soh/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c @@ -262,7 +262,7 @@ void EnClearTag_Init(Actor* thisx, PlayState* play) { // Change Arwing to regular enemy instead of boss with enemy randomizer and crowd control. // This way Arwings will be considered for "clear enemy" rooms properly. - if (CVarGetInteger(CVAR_ENHANCEMENT("RandomizedEnemies"), 0) || CVarGetInteger("gCrowdControl", 0)) { + if (CVarGetInteger(CVAR_ENHANCEMENT("RandomizedEnemies"), 0) || (CVarGetInteger(CVAR_REMOTE("Scheme"), GI_SCHEME_SAIL) == GI_SCHEME_CROWD_CONTROL && CVarGetInteger(CVAR_REMOTE("Enabled"), 0))) { Actor_ChangeCategory(play, &play->actorCtx, thisx, ACTORCAT_ENEMY); } diff --git a/soh/src/overlays/actors/ovl_En_Go2/z_en_go2.c b/soh/src/overlays/actors/ovl_En_Go2/z_en_go2.c index d8155e2da60..67ac098ff9e 100644 --- a/soh/src/overlays/actors/ovl_En_Go2/z_en_go2.c +++ b/soh/src/overlays/actors/ovl_En_Go2/z_en_go2.c @@ -1363,7 +1363,7 @@ void EnGo2_RollingAnimation(EnGo2* this, PlayState* play) { } void EnGo2_WakeUp(EnGo2* this, PlayState* play) { - if (CVarGetInteger("gUnfixGoronSpin", 0)) { + if (CVarGetInteger(CVAR_COSMETIC("UnfixGoronSpin"), 0)) { // Trick SkelAnime into thinking the current animation is changing so that it morphs between the same position, // making the goron do a spin this->skelAnime.animation = NULL; @@ -1384,14 +1384,14 @@ void EnGo2_WakeUp(EnGo2* this, PlayState* play) { // which uses the same frame data as ANIM_1/10 but no morph frames, but only when the // current animation frame is at 0, meaning no morphing is necessary anyway. // ANIM_13 is ANIM_0 but with the startFrame and mode adjusted for biggoron. - if (this->skelAnime.curFrame == 0.0f && !CVarGetInteger("gUnfixGoronSpin", 0)) { + if (this->skelAnime.curFrame == 0.0f && !CVarGetInteger(CVAR_COSMETIC("UnfixGoronSpin"), 0)) { Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENGO2_ANIM_13); } else { Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENGO2_ANIM_10); } this->skelAnime.playSpeed = 0.5f; } else { - if (this->skelAnime.curFrame == 0.0f && !CVarGetInteger("gUnfixGoronSpin", 0)) { + if (this->skelAnime.curFrame == 0.0f && !CVarGetInteger(CVAR_COSMETIC("UnfixGoronSpin"), 0)) { Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENGO2_ANIM_0); } else { Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENGO2_ANIM_1); diff --git a/soh/src/overlays/actors/ovl_En_Horse/z_en_horse.c b/soh/src/overlays/actors/ovl_En_Horse/z_en_horse.c index de3770988ae..a9fb3267ef6 100644 --- a/soh/src/overlays/actors/ovl_En_Horse/z_en_horse.c +++ b/soh/src/overlays/actors/ovl_En_Horse/z_en_horse.c @@ -3042,7 +3042,7 @@ void EnHorse_StickDirection(Vec2f* curStick, f32* stickMag, s16* angle) { void EnHorse_UpdateStick(EnHorse* this, PlayState* play) { this->lastStick = this->curStick; - this->curStick.x = play->state.input[0].rel.stick_x * (CVarGetInteger("gMirroredWorld", 0) ? -1 : 1); + this->curStick.x = play->state.input[0].rel.stick_x * (CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0) ? -1 : 1); this->curStick.y = play->state.input[0].rel.stick_y; } diff --git a/soh/src/overlays/actors/ovl_En_Ik/z_en_ik.c b/soh/src/overlays/actors/ovl_En_Ik/z_en_ik.c index b3f1219adae..87ed6aeae61 100644 --- a/soh/src/overlays/actors/ovl_En_Ik/z_en_ik.c +++ b/soh/src/overlays/actors/ovl_En_Ik/z_en_ik.c @@ -233,7 +233,8 @@ void func_80A74398(Actor* thisx, PlayState* play) { Effect_Add(play, &this->blureIdx, EFFECT_BLURE1, 0, 0, &blureInit); func_80A74714(this); - uint8_t enemyRandoCCActive = CVarGetInteger(CVAR_ENHANCEMENT("RandomizedEnemies"), 0) || CVarGetInteger("gCrowdControl", 0); + uint8_t enemyRandoCCActive = CVarGetInteger(CVAR_ENHANCEMENT("RandomizedEnemies"), 0) || + (CVarGetInteger(CVAR_REMOTE("Scheme"), GI_SCHEME_SAIL) == GI_SCHEME_CROWD_CONTROL && CVarGetInteger(CVAR_REMOTE("Enabled"), 0)); if (this->switchFlags != 0xFF) { // In vanilla gameplay, Iron Knuckles are despawned based on specific flags in specific scenarios. @@ -663,7 +664,8 @@ void func_80A75A38(EnIk* this, PlayState* play) { Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, 0xB0); // Don't set flag when Enemy Rando or CrowdControl are on. // Instead Iron Knuckles rely on the "clear room" flag. - if (this->switchFlags != 0xFF && !CVarGetInteger(CVAR_ENHANCEMENT("RandomizedEnemies"), 0) && !CVarGetInteger("gCrowdControl", 0)) { + if (this->switchFlags != 0xFF && !CVarGetInteger(CVAR_ENHANCEMENT("RandomizedEnemies"), 0) && + !(CVarGetInteger(CVAR_REMOTE("Scheme"), GI_SCHEME_SAIL) == GI_SCHEME_CROWD_CONTROL && CVarGetInteger(CVAR_REMOTE("Enabled"), 0))) { Flags_SetSwitch(play, this->switchFlags); } Actor_Kill(&this->actor); @@ -1484,7 +1486,8 @@ void EnIk_Init(Actor* thisx, PlayState* play) { } // Immediately trigger Iron Knuckle for Enemy Rando and Crowd Control - if ((CVarGetInteger(CVAR_ENHANCEMENT("RandomizedEnemies"), 0) || CVarGetInteger("gCrowdControl", 0)) && (thisx->params == 2 || thisx->params == 3)) { + if ((CVarGetInteger(CVAR_ENHANCEMENT("RandomizedEnemies"), 0) || (CVarGetInteger(CVAR_REMOTE("Scheme"), GI_SCHEME_SAIL) == GI_SCHEME_CROWD_CONTROL && CVarGetInteger(CVAR_REMOTE("Enabled"), 0))) + && (thisx->params == 2 || thisx->params == 3)) { this->skelAnime.playSpeed = 1.0f; } } diff --git a/soh/src/overlays/actors/ovl_En_Mag/z_en_mag.c b/soh/src/overlays/actors/ovl_En_Mag/z_en_mag.c index adff5253e1b..44b3399b049 100644 --- a/soh/src/overlays/actors/ovl_En_Mag/z_en_mag.c +++ b/soh/src/overlays/actors/ovl_En_Mag/z_en_mag.c @@ -655,7 +655,7 @@ void EnMag_DrawInnerMq(Actor* thisx, PlayState* play, Gfx** gfxp) { u16 rectTop; u16 length; int lang = LANGUAGE_ENG; - if (CVarGetInteger("gTitleScreenTranslation", 0)) { + if (CVarGetInteger(CVAR_SETTING("TitleScreenTranslation"), 0)) { lang = gSaveContext.language; } @@ -855,7 +855,7 @@ void EnMag_DrawInnerVanilla(Actor* thisx, PlayState* play, Gfx** gfxp) { u16 rectTop; u16 length; int lang = LANGUAGE_ENG; - if (CVarGetInteger("gTitleScreenTranslation", 0)) { + if (CVarGetInteger(CVAR_SETTING("TitleScreenTranslation"), 0)) { lang = gSaveContext.language; } diff --git a/soh/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c b/soh/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c index c538e568e67..5f0270d035a 100644 --- a/soh/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c +++ b/soh/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c @@ -664,7 +664,7 @@ void EnOssan_UpdateCursorPos(PlayState* play, EnOssan* this) { this->cursorX = x; this->cursorY = y; - if (CVarGetInteger("gMirroredWorld", 0)) { + if (CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0)) { this->cursorX = SCREEN_WIDTH - x; } } @@ -775,7 +775,7 @@ void EnOssan_UpdateJoystickInputState(PlayState* play, EnOssan* this) { s8 stickX = input->rel.stick_x; s8 stickY = input->rel.stick_y; - if (CVarGetInteger("gMirroredWorld", 0)) { + if (CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0)) { stickX = -input->rel.stick_x; } @@ -981,7 +981,7 @@ s32 EnOssan_FacingShopkeeperDialogResult(EnOssan* this, PlayState* play) { void EnOssan_State_FacingShopkeeper(EnOssan* this, PlayState* play, Player* player) { Input* input = &play->state.input[0]; u8 nextIndex; - bool dpad = CVarGetInteger("gDpadText", 0); + bool dpad = CVarGetInteger(CVAR_SETTING("DpadInText"), 0); if ((Message_GetState(&play->msgCtx) == TEXT_STATE_CHOICE) && !EnOssan_TestEndInteraction(this, play, &play->state.input[0])) { @@ -992,7 +992,7 @@ void EnOssan_State_FacingShopkeeper(EnOssan* this, PlayState* play, Player* play u16 dLeft = BTN_DLEFT; u16 dRight = BTN_DRIGHT; - if (CVarGetInteger("gMirroredWorld", 0)) { + if (CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0)) { dLeft = BTN_DRIGHT; dRight = BTN_DLEFT; } @@ -1070,7 +1070,7 @@ void EnOssan_CursorUpDown(EnOssan* this, PlayState* play) { Input* input = &play->state.input[0]; u8 curTemp = this->cursorIndex; u8 curScanTemp; - bool dpad = CVarGetInteger("gDpadText", 0); + bool dpad = CVarGetInteger(CVAR_SETTING("DpadInText"), 0); if ((this->stickAccumY < 0) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DDOWN))) { curTemp &= 0xFE; @@ -1223,7 +1223,7 @@ void EnOssan_State_BrowseLeftShelf(EnOssan* this, PlayState* play, Player* playe u8 prevIndex = this->cursorIndex; s32 c; s32 d; - bool dpad = CVarGetInteger("gDpadText", 0); + bool dpad = CVarGetInteger(CVAR_SETTING("DpadInText"), 0); if (!EnOssan_ReturnItemToShelf(this)) { osSyncPrintf("%s[%d]:" VT_FGCOL(GREEN) "ズーム中!!" VT_RST "\n", __FILE__, __LINE__); @@ -1242,7 +1242,7 @@ void EnOssan_State_BrowseLeftShelf(EnOssan* this, PlayState* play, Player* playe u16 dLeft = BTN_DLEFT; u16 dRight = BTN_DRIGHT; - if (CVarGetInteger("gMirroredWorld", 0)) { + if (CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0)) { dLeft = BTN_DRIGHT; dRight = BTN_DLEFT; } @@ -1292,7 +1292,7 @@ void EnOssan_State_BrowseRightShelf(EnOssan* this, PlayState* play, Player* play s32 pad[2]; u8 prevIndex; u8 nextIndex; - bool dpad = CVarGetInteger("gDpadText", 0); + bool dpad = CVarGetInteger(CVAR_SETTING("DpadInText"), 0); prevIndex = this->cursorIndex; if (!EnOssan_ReturnItemToShelf(this)) { @@ -1312,7 +1312,7 @@ void EnOssan_State_BrowseRightShelf(EnOssan* this, PlayState* play, Player* play u16 dLeft = BTN_DLEFT; u16 dRight = BTN_DRIGHT; - if (CVarGetInteger("gMirroredWorld", 0)) { + if (CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0)) { dLeft = BTN_DRIGHT; dRight = BTN_DLEFT; } @@ -2414,7 +2414,7 @@ void EnOssan_DrawStickDirectionPrompts(PlayState* play, EnOssan* this) { s32 drawStickRightPrompt = this->stickRightPrompt.isEnabled; // Invert which stick prompt is active when only one is active - if (CVarGetInteger("gMirroredWorld", 0) && (drawStickLeftPrompt != drawStickRightPrompt)) { + if (CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0) && (drawStickLeftPrompt != drawStickRightPrompt)) { drawStickLeftPrompt = !drawStickLeftPrompt; drawStickRightPrompt = !drawStickRightPrompt; } diff --git a/soh/src/overlays/actors/ovl_En_Partner/z_en_partner.c b/soh/src/overlays/actors/ovl_En_Partner/z_en_partner.c index 901191d0dfd..de7bddf8243 100644 --- a/soh/src/overlays/actors/ovl_En_Partner/z_en_partner.c +++ b/soh/src/overlays/actors/ovl_En_Partner/z_en_partner.c @@ -580,7 +580,7 @@ void EnPartner_Update(Actor* thisx, PlayState* play) { Input sControlInput = play->state.input[this->actor.params]; - f32 relX = sControlInput.cur.stick_x / 10.0f * (CVarGetInteger("gMirroredWorld", 0) ? -1 : 1); + f32 relX = sControlInput.cur.stick_x / 10.0f * (CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0) ? -1 : 1); f32 relY = sControlInput.cur.stick_y / 10.0f; Vec3f camForward = { GET_ACTIVE_CAM(play)->at.x - GET_ACTIVE_CAM(play)->eye.x, 0.0f, @@ -689,7 +689,7 @@ void EnPartner_Update(Actor* thisx, PlayState* play) { uint16_t partnerButtons[7] = { BTN_CLEFT, BTN_CDOWN, BTN_CRIGHT, BTN_DUP, BTN_DDOWN, BTN_DLEFT, BTN_DRIGHT}; uint8_t buttonMax = 3; - if (CVarGetInteger("gDpadEquips", 0) != 0) { + if (CVarGetInteger(CVAR_SETTING("DpadEquips"), 0) != 0) { buttonMax = ARRAY_COUNT(gSaveContext.equips.cButtonSlots); } diff --git a/soh/src/overlays/actors/ovl_En_Rd/z_en_rd.c b/soh/src/overlays/actors/ovl_En_Rd/z_en_rd.c index 0ffd1459e99..e69cfda78b7 100644 --- a/soh/src/overlays/actors/ovl_En_Rd/z_en_rd.c +++ b/soh/src/overlays/actors/ovl_En_Rd/z_en_rd.c @@ -254,7 +254,7 @@ void func_80AE2744(EnRd* this, PlayState* play) { // Add a height check to redeads/gibdos freeze when Enemy Randomizer is on. // Without the height check, redeads/gibdos can freeze the player from insane distances in // vertical rooms (like the first room in Deku Tree), making these rooms nearly unplayable. - s8 enemyRandoCCActive = CVarGetInteger(CVAR_ENHANCEMENT("RandomizedEnemies"), 0) || CVarGetInteger("gCrowdControl", 0); + s8 enemyRandoCCActive = CVarGetInteger(CVAR_ENHANCEMENT("RandomizedEnemies"), 0) || (CVarGetInteger(CVAR_REMOTE("Scheme"), GI_SCHEME_SAIL) == GI_SCHEME_CROWD_CONTROL && CVarGetInteger(CVAR_REMOTE("Enabled"), 0)); if (!enemyRandoCCActive || (enemyRandoCCActive && this->actor.yDistToPlayer <= 100.0f && this->actor.yDistToPlayer >= -100.0f)) { if ((this->actor.params != 2) && (this->unk_305 == 0)) { func_80AE37BC(this); @@ -668,7 +668,7 @@ void func_80AE3C98(EnRd* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime)) { if (this->unk_30C == 0) { - s8 enemyRandoCCActive = CVarGetInteger(CVAR_ENHANCEMENT("RandomizedEnemies"), 0) || CVarGetInteger("gCrowdControl", 0); + s8 enemyRandoCCActive = CVarGetInteger(CVAR_ENHANCEMENT("RandomizedEnemies"), 0) || (CVarGetInteger(CVAR_REMOTE("Scheme"), GI_SCHEME_SAIL) == GI_SCHEME_CROWD_CONTROL && CVarGetInteger(CVAR_REMOTE("Enabled"), 0)); // Don't set this flag in Enemy Rando as it can overlap with other objects using the same flag. if (!Flags_GetSwitch(play, this->unk_312 & 0x7F) && !enemyRandoCCActive) { Flags_SetSwitch(play, this->unk_312 & 0x7F); diff --git a/soh/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c b/soh/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c index ef2b79cdbd9..9e9fc82f545 100644 --- a/soh/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c +++ b/soh/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c @@ -128,7 +128,7 @@ void EnTorch2_Init(Actor* thisx, PlayState* play2) { // Change Dark Link to regular enemy instead of boss with enemy randomizer and crowd control. // This way Dark Link will be considered for "clear enemy" rooms properly. - if (CVarGetInteger(CVAR_ENHANCEMENT("RandomizedEnemies"), 0) || CVarGetInteger("gCrowdControl", 0)) { + if (CVarGetInteger(CVAR_ENHANCEMENT("RandomizedEnemies"), 0) || (CVarGetInteger(CVAR_REMOTE("Scheme"), GI_SCHEME_SAIL) == GI_SCHEME_CROWD_CONTROL && CVarGetInteger(CVAR_REMOTE("Enabled"), 0))) { Actor_ChangeCategory(play, &play->actorCtx, thisx, ACTORCAT_ENEMY); } @@ -592,7 +592,7 @@ void EnTorch2_Update(Actor* thisx, PlayState* play2) { input->prev.button = input->cur.button & (u16) ~(BTN_A | BTN_B); PadUtils_UpdateRelXY(input); - if (CVarGetInteger("gMirroredWorld", 0)) { + if (CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0)) { input->rel.stick_x *= -1; } diff --git a/soh/src/overlays/actors/ovl_Fishing/z_fishing.c b/soh/src/overlays/actors/ovl_Fishing/z_fishing.c index 7bf1ac7d1fd..b54a3ee76ba 100644 --- a/soh/src/overlays/actors/ovl_Fishing/z_fishing.c +++ b/soh/src/overlays/actors/ovl_Fishing/z_fishing.c @@ -2025,7 +2025,7 @@ void Fishing_DrawRod(PlayState* play) { spC8 = player->unk_85C - spC8; spC4 = player->unk_858; - Math_SmoothStepToF(&player->unk_858, input->rel.stick_x * 0.02f * (CVarGetInteger("gMirroredWorld", 0) ? -1 : 1), 0.3f, 5.0f, 0.0f); + Math_SmoothStepToF(&player->unk_858, input->rel.stick_x * 0.02f * (CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0) ? -1 : 1), 0.3f, 5.0f, 0.0f); spC4 = player->unk_858 - spC4; if (player->unk_858 > 1.0f) { diff --git a/soh/src/overlays/actors/ovl_Magic_Dark/z_magic_dark.c b/soh/src/overlays/actors/ovl_Magic_Dark/z_magic_dark.c index 73a588ab364..db1ea82080a 100644 --- a/soh/src/overlays/actors/ovl_Magic_Dark/z_magic_dark.c +++ b/soh/src/overlays/actors/ovl_Magic_Dark/z_magic_dark.c @@ -200,8 +200,8 @@ void MagicDark_DiamondDraw(Actor* thisx, PlayState* play) { u16 gameplayFrames = play->gameplayFrames; Color_RGB8 Spell_env_ori = {0, 100, 255}; Color_RGB8 Spell_col_ori = {170, 255, 255}; - Color_RGB8 Spell_env = CVarGetColor24("gNL_Diamond_Env", Spell_env_ori); - Color_RGB8 Spell_col = CVarGetColor24("gNL_Diamond_Col", Spell_col_ori); + Color_RGB8 Spell_env = CVarGetColor24(CVAR_COSMETIC("Magic.NayrusSecondary.Value"), Spell_env_ori); + Color_RGB8 Spell_col = CVarGetColor24(CVAR_COSMETIC("Magic.NayrusPrimary.Value"), Spell_col_ori); OPEN_DISPS(play->state.gfxCtx); @@ -224,7 +224,7 @@ void MagicDark_DiamondDraw(Actor* thisx, PlayState* play) { Matrix_RotateY(this->actor.shape.rot.y * (M_PI / 0x8000), MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - if (CVarGetInteger("gUseSpellsCol",0)) { + if (CVarGetInteger(CVAR_COSMETIC("UseSpellsColors"),0)) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, Spell_col.r, Spell_col.g, Spell_col.b, (s32)(this->primAlpha * 0.6f) & 0xFF); gDPSetEnvColor(POLY_XLU_DISP++, Spell_env.r, Spell_env.g, Spell_env.b, 128); } else { diff --git a/soh/src/overlays/actors/ovl_Magic_Fire/z_magic_fire.c b/soh/src/overlays/actors/ovl_Magic_Fire/z_magic_fire.c index b245c988c39..f785124f42b 100644 --- a/soh/src/overlays/actors/ovl_Magic_Fire/z_magic_fire.c +++ b/soh/src/overlays/actors/ovl_Magic_Fire/z_magic_fire.c @@ -218,8 +218,8 @@ void MagicFire_Draw(Actor* thisx, PlayState* play) { u8 alpha; Color_RGB8 Spell_env_ori = {255, 0, 0}; Color_RGB8 Spell_col_ori = {255, 200, 0}; - Color_RGB8 Spell_env = CVarGetColor24("gDF_Env", Spell_env_ori); - Color_RGB8 Spell_col = CVarGetColor24("gDF_Col", Spell_col_ori); + Color_RGB8 Spell_env = CVarGetColor24(CVAR_COSMETIC("Magic.DinsSecondary.Value"), Spell_env_ori); + Color_RGB8 Spell_col = CVarGetColor24(CVAR_COSMETIC("Magic.DinsPrimaryary.Value"), Spell_col_ori); if (this->action > 0) { OPEN_DISPS(play->state.gfxCtx); @@ -231,7 +231,7 @@ void MagicFire_Draw(Actor* thisx, PlayState* play) { gDPSetColorDither(POLY_XLU_DISP++, G_CD_DISABLE); gDPFillRectangle(POLY_XLU_DISP++, 0, 0, 319, 239); Gfx_SetupDL_25Xlu(play->state.gfxCtx); - if (CVarGetInteger("gUseSpellsCol",0)) { + if (CVarGetInteger(CVAR_COSMETIC("UseSpellsColors"),0)) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, Spell_col.r, Spell_col.g, Spell_col.b, (u8)(this->alphaMultiplier * 255)); gDPSetEnvColor(POLY_XLU_DISP++, Spell_env.r, Spell_env.g, Spell_env.b, (u8)(this->alphaMultiplier * 255)); } else { diff --git a/soh/src/overlays/actors/ovl_player_actor/z_player.c b/soh/src/overlays/actors/ovl_player_actor/z_player.c index cef3f2d3f97..f1dd52d6e17 100644 --- a/soh/src/overlays/actors/ovl_player_actor/z_player.c +++ b/soh/src/overlays/actors/ovl_player_actor/z_player.c @@ -2213,7 +2213,7 @@ s32 Player_ItemIsItemAction(s32 item1, s32 itemAction) { } s32 Player_GetItemOnButton(PlayState* play, s32 index) { - if (index >= ((CVarGetInteger("gDpadEquips", 0) != 0) ? 8 : 4)) { + if (index >= ((CVarGetInteger(CVAR_SETTING("DpadEquips"), 0) != 0) ? 8 : 4)) { return ITEM_NONE; } else if (play->bombchuBowlingStatus != 0) { return (play->bombchuBowlingStatus > 0) ? ITEM_BOMBCHU : ITEM_NONE; @@ -2254,7 +2254,7 @@ void Player_ProcessItemButtons(Player* this, PlayState* play) { if (CVarGetInteger(CVAR_ENHANCEMENT("MMBunnyHood"), BUNNY_HOOD_VANILLA) != BUNNY_HOOD_VANILLA) { s32 maskItem = this->currentMask - PLAYER_MASK_KEATON + ITEM_MASK_KEATON; bool hasOnDpad = false; - if (CVarGetInteger("gDpadEquips", 0) != 0) { + if (CVarGetInteger(CVAR_SETTING("DpadEquips"), 0) != 0) { for (int buttonIndex = 4; buttonIndex < 8; buttonIndex++) { hasOnDpad |= gSaveContext.equips.buttonItems[buttonIndex] == maskItem; } @@ -2270,7 +2270,7 @@ void Player_ProcessItemButtons(Player* this, PlayState* play) { maskItemAction = this->currentMask - 1 + PLAYER_IA_MASK_KEATON; bool hasOnDpad = false; - if (CVarGetInteger("gDpadEquips", 0) != 0) { + if (CVarGetInteger(CVAR_SETTING("DpadEquips"), 0) != 0) { for (int buttonIndex = 0; buttonIndex < 4; buttonIndex++) { hasOnDpad |= Player_ItemIsItemAction(DPAD_ITEM(buttonIndex), maskItemAction); } @@ -2286,7 +2286,7 @@ void Player_ProcessItemButtons(Player* this, PlayState* play) { if (!(this->stateFlags1 & (PLAYER_STATE1_ITEM_OVER_HEAD | PLAYER_STATE1_IN_CUTSCENE)) && !func_8008F128(this)) { if (this->itemAction >= PLAYER_IA_FISHING_POLE) { bool hasOnDpad = false; - if (CVarGetInteger("gDpadEquips", 0) != 0) { + if (CVarGetInteger(CVAR_SETTING("DpadEquips"), 0) != 0) { for (int buttonIndex = 0; buttonIndex < 4; buttonIndex++) { hasOnDpad |= Player_ItemIsInUse(this, DPAD_ITEM(buttonIndex)); } @@ -2677,7 +2677,7 @@ int func_80834E44(PlayState* play) { int func_80834E7C(PlayState* play) { u16 buttonsToCheck = BTN_A | BTN_B | BTN_CUP | BTN_CLEFT | BTN_CRIGHT | BTN_CDOWN; - if (CVarGetInteger("gDpadEquips", 0) != 0) { + if (CVarGetInteger(CVAR_SETTING("DpadEquips"), 0) != 0) { buttonsToCheck |= BTN_DUP | BTN_DDOWN | BTN_DLEFT | BTN_DRIGHT; } return (play->shootingGalleryStatus != 0) && @@ -4003,7 +4003,7 @@ void func_80837948(PlayState* play, Player* this, s32 arg2) { } if ((arg2 >= PLAYER_MWA_FLIPSLASH_START) && (arg2 <= PLAYER_MWA_JUMPSLASH_FINISH)) { - if (CVarGetInteger("gRestoreQPA", 1) && temp == -1) { + if (CVarGetInteger(CVAR_GENERAL("RestoreQPA"), 1) && temp == -1) { dmgFlags = 0x16171617; } else { @@ -5653,7 +5653,7 @@ s32 Player_ActionChange_4(Player* this, PlayState* play) { this->stateFlags2 |= PLAYER_STATE2_NAVI_ALERT; } - if (!CHECK_BTN_ALL(sControlInput->press.button, CVarGetInteger("gNaviOnL", 0) ? BTN_L : BTN_CUP) && !sp28) { + if (!CHECK_BTN_ALL(sControlInput->press.button, CVarGetInteger(CVAR_SETTING("NaviOnL"), 0) ? BTN_L : BTN_CUP) && !sp28) { return 0; } @@ -5702,7 +5702,7 @@ s32 Player_ActionChange_0(Player* this, PlayState* play) { if ((this->unk_664 != NULL) && (CHECK_FLAG_ALL(this->unk_664->flags, ACTOR_FLAG_TARGETABLE | ACTOR_FLAG_NAVI_HAS_INFO) || (this->unk_664->naviEnemyId != 0xFF))) { this->stateFlags2 |= PLAYER_STATE2_NAVI_ALERT; - } else if ((this->naviTextId == 0 || CVarGetInteger("gNaviOnL", 0)) && !func_8008E9C4(this) && CHECK_BTN_ALL(sControlInput->press.button, BTN_CUP) && + } else if ((this->naviTextId == 0 || CVarGetInteger(CVAR_SETTING("NaviOnL"), 0)) && !func_8008E9C4(this) && CHECK_BTN_ALL(sControlInput->press.button, BTN_CUP) && (YREG(15) != 0x10) && (YREG(15) != 0x20) && !func_8083B8F4(this, play)) { func_80078884(NA_SE_SY_ERROR); @@ -6551,18 +6551,18 @@ void func_8083DFE0(Player* this, f32* arg1, s16* arg2) { maxSpeed *= 1.5f; } - if (CVarGetInteger("gEnableWalkModify", 0) && !CVarGetInteger("gWalkModifierDoesntChangeJump", 0)) { - if (CVarGetInteger("gWalkSpeedToggle", 0)) { + if (CVarGetInteger(CVAR_SETTING("WalkModifier.Enabled"), 0) && !CVarGetInteger(CVAR_SETTING("WalkModifier.DoesntChangeJump"), 0)) { + if (CVarGetInteger(CVAR_SETTING("WalkModifier.SpeedToggle"), 0)) { if (gWalkSpeedToggle1) { - maxSpeed *= CVarGetFloat("gWalkModifierOne", 1.0f); + maxSpeed *= CVarGetFloat(CVAR_SETTING("WalkModifier.Mapping1"), 1.0f); } else if (gWalkSpeedToggle2) { - maxSpeed *= CVarGetFloat("gWalkModifierTwo", 1.0f); + maxSpeed *= CVarGetFloat(CVAR_SETTING("WalkModifier.Mapping2"), 1.0f); } } else { if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_MODIFIER1)) { - maxSpeed *= CVarGetFloat("gWalkModifierOne", 1.0f); + maxSpeed *= CVarGetFloat(CVAR_SETTING("WalkModifier.Mapping1"), 1.0f); } else if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_MODIFIER2)) { - maxSpeed *= CVarGetFloat("gWalkModifierTwo", 1.0f); + maxSpeed *= CVarGetFloat(CVAR_SETTING("WalkModifier.Mapping2"), 1.0f); } } } @@ -6932,7 +6932,7 @@ s32 func_8083EAF0(Player* this, Actor* actor) { s32 Player_ActionChange_9(Player* this, PlayState* play) { u16 buttonsToCheck = BTN_A | BTN_B | BTN_CLEFT | BTN_CRIGHT | BTN_CDOWN; - if (CVarGetInteger("gDpadEquips", 0) != 0) { + if (CVarGetInteger(CVAR_SETTING("DpadEquips"), 0) != 0) { buttonsToCheck |= BTN_DUP | BTN_DDOWN | BTN_DLEFT | BTN_DRIGHT; } if ((this->stateFlags1 & PLAYER_STATE1_ITEM_OVER_HEAD) && (this->heldActor != NULL) && @@ -7415,7 +7415,7 @@ s32 func_8083FD78(Player* this, f32* arg1, s16* arg2, PlayState* play) { } // #region SOH [Enhancement] - if (CVarGetInteger("gRightStickAiming", 0) || !CVarGetInteger("gInvertZAimingYAxis", 1)) { + if (CVarGetInteger(CVAR_SETTING("Controls.RightStickAim"), 0) || !CVarGetInteger(CVAR_SETTING("Controls.InvertZAimingYAxis"), 1)) { if (this->unk_664 != NULL) { func_8083DB98(this, 1); @@ -7423,7 +7423,7 @@ s32 func_8083FD78(Player* this, f32* arg1, s16* arg2, PlayState* play) { int8_t relStickY; // preserves simultaneous left/right-stick aiming - if (CVarGetInteger("gRightStickAiming", 0)) { + if (CVarGetInteger(CVAR_SETTING("Controls.RightStickAim"), 0)) { if ((sControlInput->rel.stick_y + sControlInput->rel.right_stick_y) >= 0) { relStickY = (((sControlInput->rel.stick_y) > (sControlInput->rel.right_stick_y)) ? (sControlInput->rel.stick_y) @@ -7438,7 +7438,7 @@ s32 func_8083FD78(Player* this, f32* arg1, s16* arg2, PlayState* play) { } Math_SmoothStepToS(&this->actor.focus.rot.x, - relStickY * (CVarGetInteger("gInvertZAimingYAxis", 1) ? 1 : -1) * 240.0f, 14, 4000, 30); + relStickY * (CVarGetInteger(CVAR_SETTING("Controls.InvertZAimingYAxis"), 1) ? 1 : -1) * 240.0f, 14, 4000, 30); func_80836AB8(this, 1); } // #endregion @@ -8289,18 +8289,18 @@ void Player_Action_80842180(Player* this, PlayState* play) { sp2C *= 1.5f; } - if (CVarGetInteger("gEnableWalkModify", 0)) { - if (CVarGetInteger("gWalkSpeedToggle", 0)) { + if (CVarGetInteger(CVAR_SETTING("WalkModifier.Enabled"), 0)) { + if (CVarGetInteger(CVAR_SETTING("WalkModifier.SpeedToggle"), 0)) { if (gWalkSpeedToggle1) { - sp2C *= CVarGetFloat("gWalkModifierOne", 1.0f); + sp2C *= CVarGetFloat(CVAR_SETTING("WalkModifier.Mapping1"), 1.0f); } else if (gWalkSpeedToggle2) { - sp2C *= CVarGetFloat("gWalkModifierTwo", 1.0f); + sp2C *= CVarGetFloat(CVAR_SETTING("WalkModifier.Mapping2"), 1.0f); } } else { if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_MODIFIER1)) { - sp2C *= CVarGetFloat("gWalkModifierOne", 1.0f); + sp2C *= CVarGetFloat(CVAR_SETTING("WalkModifier.Mapping1"), 1.0f); } else if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_MODIFIER2)) { - sp2C *= CVarGetFloat("gWalkModifierTwo", 1.0f); + sp2C *= CVarGetFloat(CVAR_SETTING("WalkModifier.Mapping2"), 1.0f); } } } @@ -8694,8 +8694,8 @@ void Player_Action_80843188(Player* this, PlayState* play) { func_8083721C(this); if (this->av2.actionVar2 != 0) { - sp54 = sControlInput->rel.stick_y * 100 * (CVarGetInteger("gInvertShieldAimingYAxis", 1) ? 1 : -1); - sp50 = sControlInput->rel.stick_x * (CVarGetInteger("gMirroredWorld", 0) ? 120 : -120) * (CVarGetInteger("gInvertShieldAimingXAxis", 0) ? -1 : 1); + sp54 = sControlInput->rel.stick_y * 100 * (CVarGetInteger(CVAR_SETTING("Controls.InvertShieldAimingYAxis"), 1) ? 1 : -1); + sp50 = sControlInput->rel.stick_x * (CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0) ? 120 : -120) * (CVarGetInteger(CVAR_SETTING("Controls.InvertShieldAimingYAxis"), 0) ? -1 : 1); sp4E = this->actor.shape.rot.y - Camera_GetInputDirYaw(GET_ACTIVE_CAM(play)); sp40 = Math_CosS(sp4E); @@ -9076,7 +9076,7 @@ void Player_Action_8084411C(Player* this, PlayState* play) { Actor* heldActor = this->heldActor; u16 buttonsToCheck = BTN_A | BTN_B | BTN_CLEFT | BTN_CRIGHT | BTN_CDOWN; - if (CVarGetInteger("gDpadEquips", 0) != 0) { + if (CVarGetInteger(CVAR_SETTING("DpadEquips"), 0) != 0) { buttonsToCheck |= BTN_DUP | BTN_DDOWN | BTN_DLEFT | BTN_DRIGHT; } if (!func_80835644(play, this, heldActor) && (heldActor->id == ACTOR_EN_NIW) && @@ -9858,7 +9858,7 @@ void Player_Action_80846260(Player* this, PlayState* play) { } u16 buttonsToCheck = BTN_A | BTN_B | BTN_CLEFT | BTN_CRIGHT | BTN_CDOWN; - if (CVarGetInteger("gDpadEquips", 0) != 0) { + if (CVarGetInteger(CVAR_SETTING("DpadEquips"), 0) != 0) { buttonsToCheck |= BTN_DUP | BTN_DDOWN | BTN_DLEFT | BTN_DRIGHT; } if (this->av2.actionVar2 == 0) { @@ -11074,13 +11074,13 @@ void func_80848EF8(Player* this, PlayState* play) { stoneOfAgonyColor = CVarGetColor24(CVAR_COSMETIC("HUD.StoneOfAgony.Value"), stoneOfAgonyColor); } if (CVarGetInteger(CVAR_ENHANCEMENT("VisualAgony"), 0) && !this->stateFlags1 && !GameInteractor_NoUIActive()) { - s16 Top_Margins = (CVarGetInteger("gHUDMargin_T", 0) * -1); - s16 Left_Margins = CVarGetInteger("gHUDMargin_L", 0); - s16 Right_Margins = CVarGetInteger("gHUDMargin_R", 0); + s16 Top_Margins = (CVarGetInteger(CVAR_COSMETIC("HUD.Margin.T"), 0) * -1); + s16 Left_Margins = CVarGetInteger(CVAR_COSMETIC("HUD.Margin.L"), 0); + s16 Right_Margins = CVarGetInteger(CVAR_COSMETIC("HUD.Margin.R"), 0); s16 X_Margins_VSOA; s16 Y_Margins_VSOA; - if (CVarGetInteger(CVAR_COSMETIC("VisualSoA.UseMargins"), 0) != 0) { - if (CVarGetInteger(CVAR_COSMETIC("VisualSoA.PosType"), 0) == 0) { + if (CVarGetInteger(CVAR_COSMETIC("HUD.VisualSoA.UseMargins"), 0) != 0) { + if (CVarGetInteger(CVAR_COSMETIC("HUD.VisualSoA.PosType"), 0) == 0) { X_Margins_VSOA = Left_Margins; }; Y_Margins_VSOA = Top_Margins; @@ -11092,21 +11092,21 @@ void func_80848EF8(Player* this, PlayState* play) { s16 PosY_VSOA_ori = 60 + Y_Margins_VSOA; s16 PosX_VSOA; s16 PosY_VSOA; - if (CVarGetInteger(CVAR_COSMETIC("VisualSoA.PosType"), 0) != 0) { - PosY_VSOA = CVarGetInteger(CVAR_COSMETIC("VisualSoA.PosY"), 0) + Y_Margins_VSOA; - if (CVarGetInteger(CVAR_COSMETIC("VisualSoA.PosType"), 0) == 1) { // Anchor Left - if (CVarGetInteger(CVAR_COSMETIC("VisualSoA.UseMargins"), 0) != 0) { + if (CVarGetInteger(CVAR_COSMETIC("HUD.VisualSoA.PosType"), 0) != 0) { + PosY_VSOA = CVarGetInteger(CVAR_COSMETIC("HUD.VisualSoA.PosY"), 0) + Y_Margins_VSOA; + if (CVarGetInteger(CVAR_COSMETIC("HUD.VisualSoA.PosType"), 0) == 1) { // Anchor Left + if (CVarGetInteger(CVAR_COSMETIC("HUD.VisualSoA.UseMargins"), 0) != 0) { X_Margins_VSOA = Left_Margins; }; - PosX_VSOA = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("VisualSoA.PosX"), 0) + X_Margins_VSOA); - } else if (CVarGetInteger(CVAR_COSMETIC("VisualSoA.PosType"), 0) == 2) { // Anchor Right - if (CVarGetInteger(CVAR_COSMETIC("VisualSoA.UseMargins"), 0) != 0) { + PosX_VSOA = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("HUD.VisualSoA.PosX"), 0) + X_Margins_VSOA); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.VisualSoA.PosType"), 0) == 2) { // Anchor Right + if (CVarGetInteger(CVAR_COSMETIC("HUD.VisualSoA.UseMargins"), 0) != 0) { X_Margins_VSOA = Right_Margins; }; - PosX_VSOA = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("VisualSoA.PosX"), 0) + X_Margins_VSOA); - } else if (CVarGetInteger(CVAR_COSMETIC("VisualSoA.PosType"), 0) == 3) { // Anchor None - PosX_VSOA = CVarGetInteger(CVAR_COSMETIC("VisualSoA.PosX"), 0); - } else if (CVarGetInteger(CVAR_COSMETIC("VisualSoA.PosType"), 0) == 4) { // Hidden + PosX_VSOA = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("HUD.VisualSoA.PosX"), 0) + X_Margins_VSOA); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.VisualSoA.PosType"), 0) == 3) { // Anchor None + PosX_VSOA = CVarGetInteger(CVAR_COSMETIC("HUD.VisualSoA.PosX"), 0); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.VisualSoA.PosType"), 0) == 4) { // Hidden PosX_VSOA = -9999; } } else { @@ -11661,7 +11661,7 @@ void Player_Update(Actor* thisx, PlayState* play) { } } - if (CVarGetInteger("gEnableWalkModify", 0) && CVarGetInteger("gWalkSpeedToggle", 0)) { + if (CVarGetInteger(CVAR_SETTING("WalkModifier.Enabled"), 0) && CVarGetInteger(CVAR_SETTING("WalkModifier.SpeedToggle"), 0)) { if (CHECK_BTN_ALL(sControlInput->press.button, BTN_MODIFIER1)) { gWalkSpeedToggle1 = !gWalkSpeedToggle1; } @@ -11774,7 +11774,7 @@ void Player_DrawGameplay(PlayState* play, Player* this, s32 lod, Gfx* cullDList, if ((overrideLimbDraw == Player_OverrideLimbDrawGameplayDefault) && (this->currentMask != PLAYER_MASK_NONE)) { // Fixes a bug in vanilla where ice traps are rendered extremely large while wearing a bunny hood - if (CVarGetInteger("gFixIceTrapWithBunnyHood", 1)) Matrix_Push(); + if (CVarGetInteger(CVAR_GENERAL("FixIceTrapWithBunnyHood"), 1)) Matrix_Push(); Mtx* bunnyEarMtx = Graph_Alloc(play->state.gfxCtx, 2 * sizeof(Mtx)); if (this->currentMask == PLAYER_MASK_BUNNY) { @@ -11803,7 +11803,7 @@ void Player_DrawGameplay(PlayState* play, Player* this, s32 lod, Gfx* cullDList, gSPDisplayList(POLY_OPA_DISP++, sMaskDlists[this->currentMask - 1]); } - if (CVarGetInteger("gFixIceTrapWithBunnyHood", 1)) Matrix_Pop(); + if (CVarGetInteger(CVAR_GENERAL("FixIceTrapWithBunnyHood"), 1)) Matrix_Pop(); } if ((this->currentBoots == PLAYER_BOOTS_HOVER || @@ -11997,23 +11997,23 @@ s16 func_8084ABD8(PlayState* play, Player* this, s32 arg2, s16 arg3) { s32 temp1 = 0; s16 temp2 = 0; s16 temp3 = 0; - s8 invertXAxisMulti = ((CVarGetInteger("gInvertAimingXAxis", 0) && !CVarGetInteger("gMirroredWorld", 0)) || (!CVarGetInteger("gInvertAimingXAxis", 0) && CVarGetInteger("gMirroredWorld", 0))) ? -1 : 1; - s8 invertYAxisMulti = CVarGetInteger("gInvertAimingYAxis", 1) ? 1 : -1; - f32 xAxisMulti = CVarGetFloat("gFirstPersonCameraSensitivityX", 1.0f); - f32 yAxisMulti = CVarGetFloat("gFirstPersonCameraSensitivityY", 1.0f); + s8 invertXAxisMulti = ((CVarGetInteger(CVAR_SETTING("Controls.InvertAimingXAxis"), 0) && !CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0)) || (!CVarGetInteger(CVAR_SETTING("Controls.InvertAimingXAxis"), 0) && CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0))) ? -1 : 1; + s8 invertYAxisMulti = CVarGetInteger(CVAR_SETTING("Controls.InvertAimingYAxis"), 1) ? 1 : -1; + f32 xAxisMulti = CVarGetFloat(CVAR_SETTING("FirstPersonCameraSensitivity.X"), 1.0f); + f32 yAxisMulti = CVarGetFloat(CVAR_SETTING("FirstPersonCameraSensitivity.Y"), 1.0f); if (!func_8002DD78(this) && !func_808334B4(this) && (arg2 == 0)) { // First person without weapon // Y Axis - if (!CVarGetInteger("gMoveWhileFirstPerson", 0)) { + if (!CVarGetInteger(CVAR_SETTING("MoveInFirstPerson"), 0)) { temp2 += sControlInput->rel.stick_y * 240.0f * invertYAxisMulti * yAxisMulti; } - if (CVarGetInteger("gRightStickAiming", 0) && fabsf(sControlInput->cur.right_stick_y) > 15.0f) { + if (CVarGetInteger(CVAR_SETTING("Controls.RightStickAim"), 0) && fabsf(sControlInput->cur.right_stick_y) > 15.0f) { temp2 += sControlInput->cur.right_stick_y * 240.0f * invertYAxisMulti * yAxisMulti; } if (fabsf(sControlInput->cur.gyro_x) > 0.01f) { temp2 += (-sControlInput->cur.gyro_x) * 750.0f; } - if (CVarGetInteger("gDisableAutoCenterViewFirstPerson", 0)) { + if (CVarGetInteger(CVAR_SETTING("DisableFirstPersonAutoCenterView"), 0)) { this->actor.focus.rot.x += temp2 * 0.1f; this->actor.focus.rot.x = CLAMP(this->actor.focus.rot.x, -14000, 14000); } else { @@ -12022,10 +12022,10 @@ s16 func_8084ABD8(PlayState* play, Player* this, s32 arg2, s16 arg3) { // X Axis temp2 = 0; - if (!CVarGetInteger("gMoveWhileFirstPerson", 0)) { + if (!CVarGetInteger(CVAR_SETTING("MoveInFirstPerson"), 0)) { temp2 += sControlInput->rel.stick_x * -16.0f * invertXAxisMulti * xAxisMulti; } - if (CVarGetInteger("gRightStickAiming", 0) && fabsf(sControlInput->cur.right_stick_x) > 15.0f) { + if (CVarGetInteger(CVAR_SETTING("Controls.RightStickAim"), 0) && fabsf(sControlInput->cur.right_stick_x) > 15.0f) { temp2 += sControlInput->cur.right_stick_x * -16.0f * invertXAxisMulti * xAxisMulti; } if (fabsf(sControlInput->cur.gyro_y) > 0.01f) { @@ -12037,11 +12037,11 @@ s16 func_8084ABD8(PlayState* play, Player* this, s32 arg2, s16 arg3) { // Y Axis temp1 = (this->stateFlags1 & PLAYER_STATE1_ON_HORSE) ? 3500 : 14000; - if (!CVarGetInteger("gMoveWhileFirstPerson", 0)) { + if (!CVarGetInteger(CVAR_SETTING("MoveInFirstPerson"), 0)) { temp3 += ((sControlInput->rel.stick_y >= 0) ? 1 : -1) * (s32)((1.0f - Math_CosS(sControlInput->rel.stick_y * 200)) * 1500.0f) * invertYAxisMulti * yAxisMulti; } - if (CVarGetInteger("gRightStickAiming", 0) && fabsf(sControlInput->cur.right_stick_y) > 15.0f) { + if (CVarGetInteger(CVAR_SETTING("Controls.RightStickAim"), 0) && fabsf(sControlInput->cur.right_stick_y) > 15.0f) { temp3 += ((sControlInput->cur.right_stick_y >= 0) ? 1 : -1) * (s32)((1.0f - Math_CosS(sControlInput->cur.right_stick_y * 200)) * 1500.0f) * invertYAxisMulti * yAxisMulti; } @@ -12055,11 +12055,11 @@ s16 func_8084ABD8(PlayState* play, Player* this, s32 arg2, s16 arg3) { temp1 = 19114; temp2 = this->actor.focus.rot.y - this->actor.shape.rot.y; temp3 = 0; - if (!CVarGetInteger("gMoveWhileFirstPerson", 0)) { + if (!CVarGetInteger(CVAR_SETTING("MoveInFirstPerson"), 0)) { temp3 = ((sControlInput->rel.stick_x >= 0) ? 1 : -1) * (s32)((1.0f - Math_CosS(sControlInput->rel.stick_x * 200)) * -1500.0f) * invertXAxisMulti * xAxisMulti; } - if (CVarGetInteger("gRightStickAiming", 0) && fabsf(sControlInput->cur.right_stick_x) > 15.0f) { + if (CVarGetInteger(CVAR_SETTING("Controls.RightStickAim"), 0) && fabsf(sControlInput->cur.right_stick_x) > 15.0f) { temp3 += ((sControlInput->cur.right_stick_x >= 0) ? 1 : -1) * (s32)((1.0f - Math_CosS(sControlInput->cur.right_stick_x * 200)) * -1500.0f) * invertXAxisMulti * xAxisMulti; } @@ -12070,7 +12070,7 @@ s16 func_8084ABD8(PlayState* play, Player* this, s32 arg2, s16 arg3) { this->actor.focus.rot.y = CLAMP(temp2, -temp1, temp1) + this->actor.shape.rot.y; } - if (CVarGetInteger("gMoveWhileFirstPerson", 0)) { + if (CVarGetInteger(CVAR_SETTING("MoveInFirstPerson"), 0)) { f32 movementSpeed = LINK_IS_ADULT ? 9.0f : 8.25f; if (CVarGetInteger(CVAR_ENHANCEMENT("MMBunnyHood"), BUNNY_HOOD_VANILLA) != BUNNY_HOOD_VANILLA && this->currentMask == PLAYER_MASK_BUNNY) { movementSpeed *= 1.5f; @@ -12109,18 +12109,18 @@ void func_8084AEEC(Player* this, f32* arg1, f32 arg2, s16 arg3) { // #region SOH [Enhancement] f32 swimMod = 1.0f; - if (CVarGetInteger("gEnableWalkModify", 0) == 1) { - if (CVarGetInteger("gWalkSpeedToggle", 0) == 1) { + if (CVarGetInteger(CVAR_SETTING("WalkModifier.Enabled"), 0) == 1) { + if (CVarGetInteger(CVAR_SETTING("WalkModifier.SpeedToggle"), 0) == 1) { if (gWalkSpeedToggle1) { - swimMod *= CVarGetFloat("gSwimModifierOne", 1.0f); + swimMod *= CVarGetFloat(CVAR_SETTING("WalkModifier.SwimMapping1"), 1.0f); } else if (gWalkSpeedToggle2) { - swimMod *= CVarGetFloat("gSwimModifierTwo", 1.0f); + swimMod *= CVarGetFloat(CVAR_SETTING("WalkModifier.SwimMapping2"), 1.0f); } } else { if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_MODIFIER1)) { - swimMod *= CVarGetFloat("gSwimModifierOne", 1.0f); + swimMod *= CVarGetFloat(CVAR_SETTING("WalkModifier.SwimMapping1"), 1.0f); } else if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_MODIFIER2)) { - swimMod *= CVarGetFloat("gSwimModifierTwo", 1.0f); + swimMod *= CVarGetFloat(CVAR_SETTING("WalkModifier.SwimMapping2"), 1.0f); } } temp1 = this->skelAnime.curFrame - 10.0f; @@ -12268,7 +12268,7 @@ void Player_Action_8084B1D8(Player* this, PlayState* play) { } u16 buttonsToCheck = BTN_A | BTN_B | BTN_R | BTN_CUP | BTN_CLEFT | BTN_CRIGHT | BTN_CDOWN; - if (CVarGetInteger("gDpadEquips", 0) != 0) { + if (CVarGetInteger(CVAR_SETTING("DpadEquips"), 0) != 0) { buttonsToCheck |= BTN_DUP | BTN_DDOWN | BTN_DLEFT | BTN_DRIGHT; } if ((this->csAction != 0) || (this->unk_6AD == 0) || (this->unk_6AD >= 4) || func_80833B54(this) || @@ -12707,7 +12707,7 @@ void Player_Action_8084BF1C(Player* this, PlayState* play) { if ((this->av1.actionVar1 != 0) && (sp80 != 0)) { anim2 = this->ageProperties->unk_BC[this->av2.actionVar2]; - if (CVarGetInteger("gMirroredWorld", 0) ? (sp80 < 0) : (sp80 > 0)) { + if (CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0) ? (sp80 < 0) : (sp80 > 0)) { this->skelAnime.prevTransl = this->ageProperties->unk_7A[this->av2.actionVar2]; Player_AnimPlayOnce(play, this, anim2); } else { @@ -13356,7 +13356,7 @@ void func_8084DBC4(PlayState* play, Player* this, f32 arg2) { func_8084AEEC(this, &this->linearVelocity, sp2C * 0.5f, sp2A); // Original implementation of func_8084AEEC (SurfaceWithoutSwimMod) to prevent velocity increases via swim mod which push Link into the air // #region SOH [Enhancement] - if (CVarGetInteger("gEnableWalkModify", 0)) { + if (CVarGetInteger(CVAR_SETTING("WalkModifier.Enabled"), 0)) { SurfaceWithoutSwimMod(this, &this->actor.velocity.y, arg2, this->yaw); // #endregion } else { @@ -14413,9 +14413,9 @@ s32 func_8084FCAC(Player* this, PlayState* play) { if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_DDOWN)) { angle = temp + 0x8000; } else if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_DLEFT)) { - angle = temp + (0x4000 * (CVarGetInteger("gMirroredWorld", 0) ? -1 : 1)); + angle = temp + (0x4000 * (CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0) ? -1 : 1)); } else if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_DRIGHT)) { - angle = temp - (0x4000 * (CVarGetInteger("gMirroredWorld", 0) ? -1 : 1)); + angle = temp - (0x4000 * (CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0) ? -1 : 1)); } this->actor.world.pos.x += speed * Math_SinS(angle); diff --git a/soh/src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.c b/soh/src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.c index fe92d8a3f08..014541ee084 100644 --- a/soh/src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.c +++ b/soh/src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.c @@ -62,7 +62,7 @@ void EffectSsExtra_Draw(PlayState* play, u32 index, EffectSs* this) { s32 pad; f32 scale = this->rScale / 100.0f; void* object = play->objectCtx.status[this->rObjBankIdx].segment; - u8 mirroredWorld = CVarGetInteger("gMirroredWorld", 0); + u8 mirroredWorld = CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0); OPEN_DISPS(play->state.gfxCtx); diff --git a/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c b/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c index f43cf7a746a..bb22c90ae00 100644 --- a/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c +++ b/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c @@ -673,7 +673,7 @@ void Sram_InitDebugSave(void); void Sram_InitBossRushSave(); u8 hasRandomizerQuest() { - if (strnlen(CVarGetString("gSpoilerLog", ""), 1) != 0) { + if (strnlen(CVarGetString(CVAR_GENERAL("SpoilerLog"), ""), 1) != 0) { return 1; } return 0; @@ -991,7 +991,7 @@ void DrawSeedHashSprites(FileChooseContext* this) { // Draw Seed Icons for spoiler log if (this->configMode == CM_QUEST_MENU && this->questType[this->buttonIndex] == QUEST_RANDOMIZER && - strnlen(CVarGetString("gSpoilerLog", ""), 1) != 0 && fileSelectSpoilerFileLoaded) { + strnlen(CVarGetString(CVAR_GENERAL("SpoilerLog"), ""), 1) != 0 && fileSelectSpoilerFileLoaded) { u16 xStart = 64; for (unsigned int i = 0; i < 5; i++) { SpriteLoad(this, GetSeedTexture(gSaveContext.seedIcons[i])); @@ -1008,12 +1008,12 @@ void DrawSeedHashSprites(FileChooseContext* this) { u8 generating; void FileChoose_UpdateRandomizer() { - if (CVarGetInteger("gRandoGenerating", 0) != 0 && generating == 0) { + if (CVarGetInteger(CVAR_GENERAL("RandoGenerating"), 0) != 0 && generating == 0) { generating = 1; func_800F5E18(SEQ_PLAYER_BGM_MAIN, NA_BGM_HORSE, 0, 7, 1); return; - } else if (CVarGetInteger("gRandoGenerating", 0) == 0 && generating) { - if (SpoilerFileExists(CVarGetString("gSpoilerLog", ""))) { + } else if (CVarGetInteger(CVAR_GENERAL("RandoGenerating"), 0) == 0 && generating) { + if (SpoilerFileExists(CVarGetString(CVAR_GENERAL("SpoilerLog"), ""))) { Audio_PlayFanfare(NA_BGM_HORSE_GOAL); } else { func_80078884(NA_SE_SY_OCARINA_ERROR); @@ -1025,25 +1025,25 @@ void FileChoose_UpdateRandomizer() { return; } - if (!SpoilerFileExists(CVarGetString("gSpoilerLog", "")) && !CVarGetInteger(CVAR_RANDOMIZER_SETTING("DontGenerateSpoiler"), 0)) { - CVarSetString("gSpoilerLog", ""); + if (!SpoilerFileExists(CVarGetString(CVAR_GENERAL("SpoilerLog"), "")) && !CVarGetInteger(CVAR_RANDOMIZER_SETTING("DontGenerateSpoiler"), 0)) { + CVarSetString(CVAR_GENERAL("SpoilerLog"), ""); fileSelectSpoilerFileLoaded = false; } - if ((CVarGetInteger("gRandomizerNewFileDropped", 0) != 0) || (CVarGetInteger("gNewSeedGenerated", 0) != 0) || - (!fileSelectSpoilerFileLoaded && SpoilerFileExists(CVarGetString("gSpoilerLog", "")))) { - if (CVarGetInteger("gRandomizerNewFileDropped", 0) != 0) { - CVarSetString("gSpoilerLog", CVarGetString("gRandomizerDroppedFile", "None")); + if ((CVarGetInteger(CVAR_GENERAL("RandomizerNewFileDropped"), 0) != 0) || (CVarGetInteger(CVAR_GENERAL("NewSeedGenerated"), 0) != 0) || + (!fileSelectSpoilerFileLoaded && SpoilerFileExists(CVarGetString(CVAR_GENERAL("SpoilerLog"), "")))) { + if (CVarGetInteger(CVAR_GENERAL("RandomizerNewFileDropped"), 0) != 0) { + CVarSetString(CVAR_GENERAL("SpoilerLog"), CVarGetString(CVAR_GENERAL("RandomizerDroppedFile"), "None")); } bool silent = true; - if ((CVarGetInteger("gRandomizerNewFileDropped", 0) != 0) || (CVarGetInteger("gNewSeedGenerated", 0) != 0)) { + if ((CVarGetInteger(CVAR_GENERAL("RandomizerNewFileDropped"), 0) != 0) || (CVarGetInteger(CVAR_GENERAL("NewSeedGenerated"), 0) != 0)) { silent = false; } - CVarSetInteger("gNewSeedGenerated", 0); - CVarSetInteger("gRandomizerNewFileDropped", 0); - CVarSetString("gRandomizerDroppedFile", ""); + CVarSetInteger(CVAR_GENERAL("NewSeedGenerated"), 0); + CVarSetInteger(CVAR_GENERAL("RandomizerNewFileDropped"), 0); + CVarSetString(CVAR_GENERAL("RandomizerDroppedFile"), ""); fileSelectSpoilerFileLoaded = false; - const char* fileLoc = CVarGetString("gSpoilerLog", ""); + const char* fileLoc = CVarGetString(CVAR_GENERAL("SpoilerLog"), ""); Randomizer_LoadSettings(fileLoc); Randomizer_LoadHintLocations(fileLoc); Randomizer_LoadRequiredTrials(fileLoc); @@ -1053,7 +1053,7 @@ void FileChoose_UpdateRandomizer() { Randomizer_LoadEntranceOverrides(fileLoc, silent); fileSelectSpoilerFileLoaded = true; - if (SpoilerFileExists(CVarGetString("gSpoilerLog", "")) && CVarGetInteger(CVAR_RANDOMIZER_SETTING("DontGenerateSpoiler"), 0)) { + if (SpoilerFileExists(CVarGetString(CVAR_GENERAL("SpoilerLog"), "")) && CVarGetInteger(CVAR_RANDOMIZER_SETTING("DontGenerateSpoiler"), 0)) { remove(fileLoc); } } @@ -1074,7 +1074,7 @@ void FileChoose_UpdateMainMenu(GameState* thisx) { static u8 linkName[] = { 0x15, 0x2C, 0x31, 0x2E, 0x3E, 0x3E, 0x3E, 0x3E }; FileChooseContext* this = (FileChooseContext*)thisx; Input* input = &this->state.input[0]; - bool dpad = CVarGetInteger("gDpadText", 0); + bool dpad = CVarGetInteger(CVAR_SETTING("DpadInText"), 0); FileChoose_UpdateRandomizer(); @@ -1264,7 +1264,7 @@ void FileChoose_UpdateQuestMenu(GameState* thisx) { FileChooseContext* this = (FileChooseContext*)thisx; Input* input = &this->state.input[0]; s8 i = 0; - bool dpad = CVarGetInteger("gDpadText", 0); + bool dpad = CVarGetInteger(CVAR_SETTING("DpadInText"), 0); FileChoose_UpdateRandomizer(); @@ -1311,7 +1311,7 @@ void FileChoose_UpdateQuestMenu(GameState* thisx) { this->prevConfigMode = this->configMode; this->configMode = CM_ROTATE_TO_NAME_ENTRY; this->logoAlpha = 0; - CVarSetInteger("gOnFileSelectNameEntry", 1); + CVarSetInteger(CVAR_GENERAL("OnFileSelectNameEntry"), 1); this->kbdButton = FS_KBD_BTN_NONE; this->charPage = FS_CHAR_PAGE_ENG; this->kbdX = 0; @@ -1340,7 +1340,7 @@ void FileChoose_UpdateBossRushMenu(GameState* thisx) { FileChoose_UpdateStickDirectionPromptAnim(thisx); FileChooseContext* this = (FileChooseContext*)thisx; Input* input = &this->state.input[0]; - bool dpad = CVarGetInteger("gDpadText", 0); + bool dpad = CVarGetInteger(CVAR_SETTING("DpadInText"), 0); // Fade in elements after opening Boss Rush options menu this->bossRushUIAlpha += 25; @@ -2816,7 +2816,7 @@ void FileChoose_FadeInFileInfo(GameState* thisx) { void FileChoose_ConfirmFile(GameState* thisx) { FileChooseContext* this = (FileChooseContext*)thisx; Input* input = &this->state.input[0]; - bool dpad = CVarGetInteger("gDpadText", 0); + bool dpad = CVarGetInteger(CVAR_SETTING("DpadInText"), 0); if (CHECK_BTN_ALL(input->press.button, BTN_START) || (CHECK_BTN_ALL(input->press.button, BTN_A))) { if (this->confirmButtonIndex == FS_BTN_CONFIRM_YES) { @@ -3016,21 +3016,6 @@ void FileChoose_LoadGame(GameState* thisx) { gSaveContext.naviTimer = 0; - // SWORDLESS LINK IS BACK BABY - if (CVarGetInteger("gSwordlessLink", 0) != 0) - { - if ((gSaveContext.equips.buttonItems[0] != ITEM_SWORD_KOKIRI) && - (gSaveContext.equips.buttonItems[0] != ITEM_SWORD_MASTER) && - (gSaveContext.equips.buttonItems[0] != ITEM_SWORD_BGS) && - (gSaveContext.equips.buttonItems[0] != ITEM_SWORD_KNIFE)) { - - gSaveContext.equips.buttonItems[0] = ITEM_NONE; - swordEquipValue = (BOMSWAP16(gEquipMasks[EQUIP_TYPE_SWORD]) & gSaveContext.equips.equipment) >> (EQUIP_TYPE_SWORD * 4); - gSaveContext.equips.equipment &= gEquipNegMasks[EQUIP_TYPE_SWORD]; - gSaveContext.inventory.equipment ^= (gBitFlags[swordEquipValue - 1] << BOMSWAP16(gEquipShifts[EQUIP_TYPE_SWORD])); - } - } - if (IS_RANDO) { // Setup the modified entrance table and entrance shuffle table for rando Entrance_Init(); @@ -3313,7 +3298,7 @@ void FileChoose_Main(GameState* thisx) { this->stickRelX = input->rel.stick_x; this->stickRelY = input->rel.stick_y; - if (CVarGetInteger("gDpadHoldChange", 1) && CVarGetInteger("gDpadText", 0)) { + if (CVarGetInteger(CVAR_SETTING("DpadHoldChange"), 1) && CVarGetInteger(CVAR_SETTING("DpadInText"), 0)) { if (CHECK_BTN_ALL(input->cur.button, BTN_DLEFT)) { if (CHECK_BTN_ALL(input->press.button, BTN_DLEFT)) { this->inputTimerX = 10; @@ -3661,7 +3646,7 @@ void FileChoose_Init(GameState* thisx) { this->questType[2] = MIN_QUEST; fileSelectSpoilerFileLoaded = false; isFastFileIdIncompatible = 0; - CVarSetInteger("gOnFileSelectNameEntry", 0); + CVarSetInteger(CVAR_GENERAL("OnFileSelectNameEntry"), 0); SREG(30) = 1; osSyncPrintf("SIZE=%x\n", size); diff --git a/soh/src/overlays/gamestates/ovl_file_choose/z_file_copy_erase.c b/soh/src/overlays/gamestates/ovl_file_choose/z_file_copy_erase.c index 6f155e36765..3080eb14f77 100644 --- a/soh/src/overlays/gamestates/ovl_file_choose/z_file_copy_erase.c +++ b/soh/src/overlays/gamestates/ovl_file_choose/z_file_copy_erase.c @@ -64,7 +64,7 @@ static s16 sLastCopyEraseButtonIndex; void FileChoose_SelectCopySource(GameState* thisx) { FileChooseContext* this = (FileChooseContext*)thisx; Input* input = &this->state.input[0]; - bool dpad = CVarGetInteger("gDpadText", 0); + bool dpad = CVarGetInteger(CVAR_SETTING("DpadInText"), 0); if (((this->buttonIndex == FS_BTN_COPY_QUIT) && CHECK_BTN_ANY(input->press.button, BTN_A | BTN_START)) || CHECK_BTN_ALL(input->press.button, BTN_B)) { @@ -181,7 +181,7 @@ void FileChoose_SetupCopyDest2(GameState* thisx) { void FileChoose_SelectCopyDest(GameState* thisx) { FileChooseContext* this = (FileChooseContext*)thisx; Input* input = &this->state.input[0]; - bool dpad = CVarGetInteger("gDpadText", 0); + bool dpad = CVarGetInteger(CVAR_SETTING("DpadInText"), 0); if (((this->buttonIndex == FS_BTN_COPY_QUIT) && CHECK_BTN_ANY(input->press.button, BTN_A | BTN_START)) || CHECK_BTN_ALL(input->press.button, BTN_B)) { @@ -370,7 +370,7 @@ void FileChoose_CopyConfirm(GameState* thisx) { FileChooseContext* this = (FileChooseContext*)thisx; Input* input = &this->state.input[0]; u16 dayTime; - bool dpad = CVarGetInteger("gDpadText", 0); + bool dpad = CVarGetInteger(CVAR_SETTING("DpadInText"), 0); if (((this->buttonIndex != FS_BTN_CONFIRM_YES) && CHECK_BTN_ANY(input->press.button, BTN_A | BTN_START)) || CHECK_BTN_ALL(input->press.button, BTN_B)) { @@ -695,7 +695,7 @@ void FileChoose_SetupEraseSelect(GameState* thisx) { void FileChoose_EraseSelect(GameState* thisx) { FileChooseContext* this = (FileChooseContext*)thisx; Input* input = &this->state.input[0]; - bool dpad = CVarGetInteger("gDpadText", 0); + bool dpad = CVarGetInteger(CVAR_SETTING("DpadInText"), 0); if (((this->buttonIndex == FS_BTN_COPY_QUIT) && CHECK_BTN_ANY(input->press.button, BTN_A | BTN_START)) || CHECK_BTN_ALL(input->press.button, BTN_B)) { @@ -837,7 +837,7 @@ void FileChoose_SetupEraseConfirm2(GameState* thisx) { void FileChoose_EraseConfirm(GameState* thisx) { FileChooseContext* this = (FileChooseContext*)thisx; Input* input = &this->state.input[0]; - bool dpad = CVarGetInteger("gDpadText", 0); + bool dpad = CVarGetInteger(CVAR_SETTING("DpadInText"), 0); if (((this->buttonIndex != FS_BTN_CONFIRM_YES) && CHECK_BTN_ANY(input->press.button, BTN_A | BTN_START)) || CHECK_BTN_ALL(input->press.button, BTN_B)) { diff --git a/soh/src/overlays/gamestates/ovl_file_choose/z_file_nameset_PAL.c b/soh/src/overlays/gamestates/ovl_file_choose/z_file_nameset_PAL.c index 525f5ac2864..26c24e37d7c 100644 --- a/soh/src/overlays/gamestates/ovl_file_choose/z_file_nameset_PAL.c +++ b/soh/src/overlays/gamestates/ovl_file_choose/z_file_nameset_PAL.c @@ -380,7 +380,7 @@ void FileChoose_DrawNameEntry(GameState* thisx) { } this->prevConfigMode = CM_NAME_ENTRY; sLastCharIndex = -1; - CVarSetInteger("gOnFileSelectNameEntry", 0); + CVarSetInteger(CVAR_GENERAL("OnFileSelectNameEntry"), 0); } else { for (i = this->newFileNameCharCount; i < 7; i++) { filename[i] = filename[i + 1]; @@ -455,7 +455,7 @@ void FileChoose_DrawNameEntry(GameState* thisx) { gSaveContext.dayTime = dayTime; this->prevConfigMode = CM_MAIN_MENU; this->configMode = CM_NAME_ENTRY_TO_MAIN; - CVarSetInteger("gOnFileSelectNameEntry", 0); + CVarSetInteger(CVAR_GENERAL("OnFileSelectNameEntry"), 0); this->nameBoxAlpha[this->buttonIndex] = this->nameAlpha[this->buttonIndex] = 200; this->connectorAlpha[this->buttonIndex] = 255; func_800AA000(300.0f, 0xB4, 0x14, 0x64); @@ -527,7 +527,7 @@ void FileChoose_UpdateKeyboardCursor(GameState* thisx) { FileChooseContext* this = (FileChooseContext*)thisx; Input* input = &this->state.input[0]; s16 prevKbdX; - bool dpad = CVarGetInteger("gDpadText", 0); + bool dpad = CVarGetInteger(CVAR_SETTING("DpadInText"), 0); this->kbdButton = 99; @@ -683,7 +683,7 @@ static s8 sLastOptionButtonIndex = -1; void FileChoose_UpdateOptionsMenu(GameState* thisx) { FileChooseContext* this = (FileChooseContext*)thisx; Input* input = &this->state.input[0]; - bool dpad = CVarGetInteger("gDpadText", 0); + bool dpad = CVarGetInteger(CVAR_SETTING("DpadInText"), 0); if (CHECK_BTN_ALL(input->press.button, BTN_B)) { Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); @@ -753,7 +753,7 @@ void FileChoose_UpdateOptionsMenu(GameState* thisx) { // Persist the new language so it is not overridden on the next frame if (languageChanged) { - CVarSetInteger("gLanguages", gSaveContext.language); + CVarSetInteger(CVAR_SETTING("Languages"), gSaveContext.language); GameInteractor_ExecuteOnSetGameLanguage(); } diff --git a/soh/src/overlays/gamestates/ovl_select/z_select.c b/soh/src/overlays/gamestates/ovl_select/z_select.c index 65c23b68547..f4d577c5cdc 100644 --- a/soh/src/overlays/gamestates/ovl_select/z_select.c +++ b/soh/src/overlays/gamestates/ovl_select/z_select.c @@ -45,9 +45,9 @@ void Select_LoadGame(SelectContext* this, s32 entranceIndex) { } if (this->isBetterWarp) { - CVarSetInteger("gBetterDebugWarpScreenCurrentScene", this->currentScene); - CVarSetInteger("gBetterDebugWarpScreenTopDisplayedScene", this->topDisplayedScene); - CVarSetInteger("gBetterDebugWarpScreenPageDownIndex", this->pageDownIndex); + CVarSetInteger(CVAR_GENERAL("BetterDebugWarpScreenCurrentScene"), this->currentScene); + CVarSetInteger(CVAR_GENERAL("BetterDebugWarpScreenTopDisplayedScene"), this->topDisplayedScene); + CVarSetInteger(CVAR_GENERAL("BetterDebugWarpScreenPageDownIndex"), this->pageDownIndex); CVarSave(); if (ResourceMgr_GameHasMasterQuest() && ResourceMgr_GameHasOriginal()) { @@ -57,11 +57,11 @@ void Select_LoadGame(SelectContext* this, s32 entranceIndex) { s16 scene = gEntranceTable[entrancePair.entranceIndex].scene; u8 isEntranceDefaultMQ = ResourceMgr_IsSceneMasterQuest(scene); if (!isEntranceDefaultMQ && this->opt) { // Force vanilla for default MQ scene - CVarSetInteger("gBetterDebugWarpScreenMQMode", WARP_MODE_OVERRIDE_MQ_AS_VANILLA); - CVarSetInteger("gBetterDebugWarpScreenMQModeScene", scene); + CVarSetInteger(CVAR_GENERAL("BetterDebugWarpScreenMQMode"), WARP_MODE_OVERRIDE_MQ_AS_VANILLA); + CVarSetInteger(CVAR_GENERAL("BetterDebugWarpScreenMQModeScene"), scene); } else if (isEntranceDefaultMQ && !this->opt) { // Force MQ for default vanilla scene - CVarSetInteger("gBetterDebugWarpScreenMQMode", WARP_MODE_OVERRIDE_VANILLA_AS_MQ); - CVarSetInteger("gBetterDebugWarpScreenMQModeScene", scene); + CVarSetInteger(CVAR_GENERAL("BetterDebugWarpScreenMQMode"), WARP_MODE_OVERRIDE_VANILLA_AS_MQ); + CVarSetInteger(CVAR_GENERAL("BetterDebugWarpScreenMQModeScene"), scene); } } } @@ -111,9 +111,9 @@ void Select_Grotto_LoadGame(SelectContext* this, s32 grottoIndex) { } if (this->isBetterWarp) { - CVarSetInteger("gBetterDebugWarpScreenCurrentScene", this->currentScene); - CVarSetInteger("gBetterDebugWarpScreenTopDisplayedScene", this->topDisplayedScene); - CVarSetInteger("gBetterDebugWarpScreenPageDownIndex", this->pageDownIndex); + CVarSetInteger(CVAR_GENERAL("BetterDebugWarpScreenCurrentScene"), this->currentScene); + CVarSetInteger(CVAR_GENERAL("BetterDebugWarpScreenTopDisplayedScene"), this->topDisplayedScene); + CVarSetInteger(CVAR_GENERAL("BetterDebugWarpScreenPageDownIndex"), this->pageDownIndex); CVarSave(); } @@ -1564,13 +1564,13 @@ void Select_SwitchBetterWarpMode(SelectContext* this, u8 isBetterWarpMode) { gSaveContext.dayTime = 0x8000; if (isBetterWarpMode) { - s32 currScene = CVarGetInteger("gBetterDebugWarpScreenCurrentScene", 0); + s32 currScene = CVarGetInteger(CVAR_GENERAL("BetterDebugWarpScreenCurrentScene"), 0); this->count = ARRAY_COUNT(sBetterScenes); if (currScene >= 0 && currScene < this->count) { this->currentScene = currScene; - this->topDisplayedScene = CVarGetInteger("gBetterDebugWarpScreenTopDisplayedScene", 0); - this->pageDownIndex = CVarGetInteger("gBetterDebugWarpScreenPageDownIndex", 0); + this->topDisplayedScene = CVarGetInteger(CVAR_GENERAL("BetterDebugWarpScreenTopDisplayedScene"), 0); + this->pageDownIndex = CVarGetInteger(CVAR_GENERAL("BetterDebugWarpScreenPageDownIndex"), 0); BetterSceneSelectEntrancePair entrancePair = this->betterScenes[this->currentScene].entrancePairs[this->pageDownIndex]; if (entrancePair.canBeMQ && ResourceMgr_IsSceneMasterQuest(gEntranceTable[entrancePair.entranceIndex].scene)) { @@ -1637,7 +1637,7 @@ void Select_Init(GameState* thisx) { gSaveContext.nightFlag = 0; gSaveContext.dayTime = 0x8000; - CVarClear("gBetterDebugWarpScreenMQMode"); - CVarClear("gBetterDebugWarpScreenMQModeScene"); + CVarClear(CVAR_GENERAL("BetterDebugWarpScreenMQMode")); + CVarClear(CVAR_GENERAL("BetterDebugWarpScreenMQModeScene")); Select_SwitchBetterWarpMode(this, CVarGetInteger(CVAR_DEVELOPER_TOOLS("BetterDebugWarpScreen"), 0)); } diff --git a/soh/src/overlays/gamestates/ovl_title/z_title.c b/soh/src/overlays/gamestates/ovl_title/z_title.c index 617edba1b47..51d0ac62b3a 100644 --- a/soh/src/overlays/gamestates/ovl_title/z_title.c +++ b/soh/src/overlays/gamestates/ovl_title/z_title.c @@ -204,7 +204,7 @@ void Title_Draw(TitleContext* this) { } // Draw ice cube around N64 logo. - if (CVarGetInteger("gLetItSnow", 0)) { + if (CVarGetInteger(CVAR_GENERAL("LetItSnow"), 0)) { f32 scale = 0.4f; gSPSegment(POLY_OPA_DISP++, 0x08, diff --git a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_collect.c b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_collect.c index 80d47ea4f5d..72f07b522f6 100644 --- a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_collect.c +++ b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_collect.c @@ -103,7 +103,7 @@ void KaleidoScope_DrawQuestStatus(PlayState* play, GraphicsContext* gfxCtx) { s16 pad2; s16 phi_s0_2; s16 sp208[3]; - bool dpad = CVarGetInteger("gDpadPause", 0); + bool dpad = CVarGetInteger(CVAR_SETTING("DPadOnPause"), 0); OPEN_DISPS(gfxCtx); diff --git a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c index 9d699db9032..99ba5df7212 100644 --- a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c +++ b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c @@ -143,7 +143,7 @@ void KaleidoScope_DrawPlayerWork(PlayState* play) { pos.y = -130.0f; pos.z = -150.0f; scale = 0.046f; - } else if (CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD) != EQUIP_VALUE_SWORD_MASTER && !CVarGetInteger("gPauseTriforce", 0)) { + } else if (CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD) != EQUIP_VALUE_SWORD_MASTER && !CVarGetInteger(CVAR_GENERAL("PauseTriforce"), 0)) { pos.x = 25.0f; pos.y = -228.0f; pos.z = 60.0f; @@ -213,9 +213,9 @@ void KaleidoScope_DrawEquipment(PlayState* play) { s16 cursorX; s16 cursorY; s16 oldCursorPoint; - bool dpad = (CVarGetInteger("gDpadPause", 0) && !CHECK_BTN_ALL(input->cur.button, BTN_CUP)); - bool pauseAnyCursor = (CVarGetInteger("gPauseAnyCursor", 0) == PAUSE_ANY_CURSOR_RANDO_ONLY && IS_RANDO) || - (CVarGetInteger("gPauseAnyCursor", 0) == PAUSE_ANY_CURSOR_ALWAYS_ON); + bool dpad = (CVarGetInteger(CVAR_SETTING("DPadOnPause"), 0) && !CHECK_BTN_ALL(input->cur.button, BTN_CUP)); + bool pauseAnyCursor = (CVarGetInteger(CVAR_SETTING("PauseAnyCursor"), 0) == PAUSE_ANY_CURSOR_RANDO_ONLY && IS_RANDO) || + (CVarGetInteger(CVAR_SETTING("PauseAnyCursor"), 0) == PAUSE_ANY_CURSOR_ALWAYS_ON); OPEN_DISPS(play->state.gfxCtx); @@ -552,7 +552,7 @@ void KaleidoScope_DrawEquipment(PlayState* play) { } u16 buttonsToCheck = BTN_A | BTN_CLEFT | BTN_CDOWN | BTN_CRIGHT; - if (CVarGetInteger("gDpadEquips", 0) && (!CVarGetInteger("gDpadPause", 0) || CHECK_BTN_ALL(input->cur.button, BTN_CUP))) { + if (CVarGetInteger(CVAR_SETTING("DpadEquips"), 0) && (!CVarGetInteger(CVAR_SETTING("DPadOnPause"), 0) || CHECK_BTN_ALL(input->cur.button, BTN_CUP))) { buttonsToCheck |= BTN_DUP | BTN_DDOWN | BTN_DLEFT | BTN_DRIGHT; } diff --git a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.c b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.c index 40d00a1a4a3..6cc02aa034f 100644 --- a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.c +++ b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.c @@ -252,7 +252,7 @@ void KaleidoScope_DrawItemCycleExtras(PlayState* play, u8 slot, u8 canCycle, u8 void KaleidoScope_HandleItemCycleExtras(PlayState* play, u8 slot, bool canCycle, u8 leftItem, u8 rightItem, bool replaceCButtons) { Input* input = &play->state.input[0]; PauseContext* pauseCtx = &play->pauseCtx; - bool dpad = (CVarGetInteger("gDpadPause", 0) && !CHECK_BTN_ALL(input->cur.button, BTN_CUP)); + bool dpad = (CVarGetInteger(CVAR_SETTING("DPadOnPause"), 0) && !CHECK_BTN_ALL(input->cur.button, BTN_CUP)); u8 slotItem = gSaveContext.inventory.items[slot]; u8 hasLeftItem = leftItem != ITEM_NONE && slotItem != leftItem; u8 hasRightItem = rightItem != ITEM_NONE && slotItem != rightItem && leftItem != rightItem; @@ -414,9 +414,9 @@ void KaleidoScope_DrawItemSelect(PlayState* play) { s16 cursorY; s16 oldCursorPoint; s16 moveCursorResult; - bool dpad = (CVarGetInteger("gDpadPause", 0) && !CHECK_BTN_ALL(input->cur.button, BTN_CUP)); - bool pauseAnyCursor = pauseCtx->cursorSpecialPos == 0 && ((CVarGetInteger("gPauseAnyCursor", 0) == PAUSE_ANY_CURSOR_RANDO_ONLY && IS_RANDO) || - (CVarGetInteger("gPauseAnyCursor", 0) == PAUSE_ANY_CURSOR_ALWAYS_ON)); + bool dpad = (CVarGetInteger(CVAR_SETTING("DPadOnPause"), 0) && !CHECK_BTN_ALL(input->cur.button, BTN_CUP)); + bool pauseAnyCursor = pauseCtx->cursorSpecialPos == 0 && ((CVarGetInteger(CVAR_SETTING("PauseAnyCursor"), 0) == PAUSE_ANY_CURSOR_RANDO_ONLY && IS_RANDO) || + (CVarGetInteger(CVAR_SETTING("PauseAnyCursor"), 0) == PAUSE_ANY_CURSOR_ALWAYS_ON)); OPEN_DISPS(play->state.gfxCtx); @@ -669,7 +669,7 @@ void KaleidoScope_DrawItemSelect(PlayState* play) { if ((pauseCtx->debugState == 0) && (pauseCtx->state == 6) && (pauseCtx->unk_1E4 == 0)) { KaleidoScope_HandleItemCycles(play); u16 buttonsToCheck = BTN_CLEFT | BTN_CDOWN | BTN_CRIGHT; - if (CVarGetInteger("gDpadEquips", 0) && (!CVarGetInteger("gDpadPause", 0) || CHECK_BTN_ALL(input->cur.button, BTN_CUP))) { + if (CVarGetInteger(CVAR_SETTING("DpadEquips"), 0) && (!CVarGetInteger(CVAR_SETTING("DPadOnPause"), 0) || CHECK_BTN_ALL(input->cur.button, BTN_CUP))) { buttonsToCheck |= BTN_DUP | BTN_DDOWN | BTN_DLEFT | BTN_DRIGHT; } if (CHECK_BTN_ANY(input->press.button, buttonsToCheck)) { @@ -803,7 +803,7 @@ void KaleidoScope_SetupItemEquip(PlayState* play, u16 item, u16 slot, s16 animX, pauseCtx->equipTargetCBtn = 1; } else if (CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { pauseCtx->equipTargetCBtn = 2; - } else if (CVarGetInteger("gDpadEquips", 0)) { + } else if (CVarGetInteger(CVAR_SETTING("DpadEquips"), 0)) { if (CHECK_BTN_ALL(input->press.button, BTN_DUP)) { pauseCtx->equipTargetCBtn = 3; } else if (CHECK_BTN_ALL(input->press.button, BTN_DDOWN)) { @@ -858,10 +858,10 @@ void KaleidoScope_UpdateItemEquip(PlayState* play) { u16 offsetX; u16 offsetY; - s16 Top_HUD_Margin = CVarGetInteger("gHUDMargin_T", 0); - s16 Left_HUD_Margin = CVarGetInteger("gHUDMargin_L", 0); - s16 Right_HUD_Margin = CVarGetInteger("gHUDMargin_R", 0); - s16 Bottom_HUD_Margin = CVarGetInteger("gHUDMargin_B", 0); + s16 Top_HUD_Margin = CVarGetInteger(CVAR_COSMETIC("HUD.Margin.T"), 0); + s16 Left_HUD_Margin = CVarGetInteger(CVAR_COSMETIC("HUD.Margin.L"), 0); + s16 Right_HUD_Margin = CVarGetInteger(CVAR_COSMETIC("HUD.Margin.R"), 0); + s16 Bottom_HUD_Margin = CVarGetInteger(CVAR_COSMETIC("HUD.Margin.B"), 0); s16 X_Margins_CL; s16 X_Margins_CR; @@ -873,36 +873,36 @@ void KaleidoScope_UpdateItemEquip(PlayState* play) { s16 Y_Margins_BtnB; s16 X_Margins_DPad_Items; s16 Y_Margins_DPad_Items; - if (CVarGetInteger(CVAR_COSMETIC("BButton.UseMargins"), 0) != 0) { - if (CVarGetInteger(CVAR_COSMETIC("BButton.PosType"), 0) == 0) {X_Margins_BtnB = Right_HUD_Margin;}; + if (CVarGetInteger(CVAR_COSMETIC("HUD.BButton.UseMargins"), 0) != 0) { + if (CVarGetInteger(CVAR_COSMETIC("HUD.BButton.PosType"), 0) == 0) {X_Margins_BtnB = Right_HUD_Margin;}; Y_Margins_BtnB = (Top_HUD_Margin*-1); } else { X_Margins_BtnB = 0; Y_Margins_BtnB = 0; } - if (CVarGetInteger(CVAR_COSMETIC("CLeftButton.UseMargins"), 0) != 0) { - if (CVarGetInteger(CVAR_COSMETIC("CLeftButton.PosType"), 0) == 0) {X_Margins_CL = Right_HUD_Margin;}; + if (CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.UseMargins"), 0) != 0) { + if (CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.PosType"), 0) == 0) {X_Margins_CL = Right_HUD_Margin;}; Y_Margins_CL = (Top_HUD_Margin*-1); } else { X_Margins_CL = 0; Y_Margins_CL = 0; } - if (CVarGetInteger(CVAR_COSMETIC("CRightButton.UseMargins"), 0) != 0) { - if (CVarGetInteger(CVAR_COSMETIC("CRightButton.PosType"), 0) == 0) {X_Margins_CR = Right_HUD_Margin;}; + if (CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.UseMargins"), 0) != 0) { + if (CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.PosType"), 0) == 0) {X_Margins_CR = Right_HUD_Margin;}; Y_Margins_CR = (Top_HUD_Margin*-1); } else { X_Margins_CR = 0; Y_Margins_CR = 0; } - if (CVarGetInteger(CVAR_COSMETIC("CDownButton.UseMargins"), 0) != 0) { - if (CVarGetInteger(CVAR_COSMETIC("CDownButton.PosType"), 0) == 0) {X_Margins_CD = Right_HUD_Margin;}; + if (CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.UseMargins"), 0) != 0) { + if (CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.PosType"), 0) == 0) {X_Margins_CD = Right_HUD_Margin;}; Y_Margins_CD = (Top_HUD_Margin*-1); } else { X_Margins_CD = 0; Y_Margins_CD = 0; } - if (CVarGetInteger("gDPadUseMargins", 0) != 0) { - if (CVarGetInteger("gDPadPosType", 0) == 0) {X_Margins_DPad_Items = Right_HUD_Margin;}; + if (CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.UseMargins"), 0) != 0) { + if (CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosType"), 0) == 0) {X_Margins_DPad_Items = Right_HUD_Margin;}; Y_Margins_DPad_Items = (Top_HUD_Margin*-1); } else { X_Margins_DPad_Items = 0; @@ -925,28 +925,28 @@ void KaleidoScope_UpdateItemEquip(PlayState* play) { }; //(X,Y) Used with custom position to place it properly. //DPadItems - if (CVarGetInteger("gDPadPosType", 0) != 0) { - sCButtonPosY[3] = CVarGetInteger("gDPadPosY", 0)+Y_Margins_DPad_Items+DPad_ItemsOffset[0][1];//Up - sCButtonPosY[4] = CVarGetInteger("gDPadPosY", 0)+Y_Margins_DPad_Items+DPad_ItemsOffset[1][1];//Down - sCButtonPosY[5] = CVarGetInteger("gDPadPosY", 0)+Y_Margins_DPad_Items+DPad_ItemsOffset[2][1];//Left - sCButtonPosY[6] = CVarGetInteger("gDPadPosY", 0)+Y_Margins_DPad_Items+DPad_ItemsOffset[3][1];//Right - if (CVarGetInteger("gDPadPosType", 0) == 1) {//Anchor Left - if (CVarGetInteger("gDPadUseMargins", 0) != 0) {X_Margins_DPad_Items = Left_HUD_Margin;}; - sCButtonPosX[3] = OTRGetDimensionFromLeftEdge(CVarGetInteger("gDPadPosX", 0)+X_Margins_DPad_Items+DPad_ItemsOffset[0][0]); - sCButtonPosX[4] = OTRGetDimensionFromLeftEdge(CVarGetInteger("gDPadPosX", 0)+X_Margins_DPad_Items+DPad_ItemsOffset[1][0]); - sCButtonPosX[5] = OTRGetDimensionFromLeftEdge(CVarGetInteger("gDPadPosX", 0)+X_Margins_DPad_Items+DPad_ItemsOffset[2][0]); - sCButtonPosX[6] = OTRGetDimensionFromLeftEdge(CVarGetInteger("gDPadPosX", 0)+X_Margins_DPad_Items+DPad_ItemsOffset[3][0]); - } else if (CVarGetInteger("gDPadPosType", 0) == 2) {//Anchor Right - if (CVarGetInteger("gDPadUseMargins", 0) != 0) {X_Margins_DPad_Items = Right_HUD_Margin;}; - sCButtonPosX[3] = OTRGetDimensionFromRightEdge(CVarGetInteger("gDPadPosX", 0)+X_Margins_DPad_Items+DPad_ItemsOffset[0][0]); - sCButtonPosX[4] = OTRGetDimensionFromRightEdge(CVarGetInteger("gDPadPosX", 0)+X_Margins_DPad_Items+DPad_ItemsOffset[1][0]); - sCButtonPosX[5] = OTRGetDimensionFromRightEdge(CVarGetInteger("gDPadPosX", 0)+X_Margins_DPad_Items+DPad_ItemsOffset[2][0]); - sCButtonPosX[6] = OTRGetDimensionFromRightEdge(CVarGetInteger("gDPadPosX", 0)+X_Margins_DPad_Items+DPad_ItemsOffset[3][0]); - } else if (CVarGetInteger("gDPadPosType", 0) == 3) {//Anchor None - sCButtonPosX[3] = CVarGetInteger("gDPadPosX", 0)+DPad_ItemsOffset[0][0]; - sCButtonPosX[4] = CVarGetInteger("gDPadPosX", 0)+DPad_ItemsOffset[1][0]; - sCButtonPosX[5] = CVarGetInteger("gDPadPosX", 0)+DPad_ItemsOffset[2][0]; - sCButtonPosX[6] = CVarGetInteger("gDPadPosX", 0)+DPad_ItemsOffset[3][0]; + if (CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosType"), 0) != 0) { + sCButtonPosY[3] = CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosY"), 0)+Y_Margins_DPad_Items+DPad_ItemsOffset[0][1];//Up + sCButtonPosY[4] = CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosY"), 0)+Y_Margins_DPad_Items+DPad_ItemsOffset[1][1];//Down + sCButtonPosY[5] = CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosY"), 0)+Y_Margins_DPad_Items+DPad_ItemsOffset[2][1];//Left + sCButtonPosY[6] = CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosY"), 0)+Y_Margins_DPad_Items+DPad_ItemsOffset[3][1];//Right + if (CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosType"), 0) == 1) {//Anchor Left + if (CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.UseMargins"), 0) != 0) {X_Margins_DPad_Items = Left_HUD_Margin;}; + sCButtonPosX[3] = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosX"), 0)+X_Margins_DPad_Items+DPad_ItemsOffset[0][0]); + sCButtonPosX[4] = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosX"), 0)+X_Margins_DPad_Items+DPad_ItemsOffset[1][0]); + sCButtonPosX[5] = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosX"), 0)+X_Margins_DPad_Items+DPad_ItemsOffset[2][0]); + sCButtonPosX[6] = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosX"), 0)+X_Margins_DPad_Items+DPad_ItemsOffset[3][0]); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosType"), 0) == 2) {//Anchor Right + if (CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.UseMargins"), 0) != 0) {X_Margins_DPad_Items = Right_HUD_Margin;}; + sCButtonPosX[3] = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosX"), 0)+X_Margins_DPad_Items+DPad_ItemsOffset[0][0]); + sCButtonPosX[4] = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosX"), 0)+X_Margins_DPad_Items+DPad_ItemsOffset[1][0]); + sCButtonPosX[5] = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosX"), 0)+X_Margins_DPad_Items+DPad_ItemsOffset[2][0]); + sCButtonPosX[6] = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosX"), 0)+X_Margins_DPad_Items+DPad_ItemsOffset[3][0]); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosType"), 0) == 3) {//Anchor None + sCButtonPosX[3] = CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosX"), 0)+DPad_ItemsOffset[0][0]; + sCButtonPosX[4] = CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosX"), 0)+DPad_ItemsOffset[1][0]; + sCButtonPosX[5] = CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosX"), 0)+DPad_ItemsOffset[2][0]; + sCButtonPosX[6] = CVarGetInteger(CVAR_COSMETIC("HUD.Dpad.PosX"), 0)+DPad_ItemsOffset[3][0]; } } else { sCButtonPosX[3] = OTRGetDimensionFromRightEdge(ItemIconPos_ori[3][0]); @@ -959,48 +959,48 @@ void KaleidoScope_UpdateItemEquip(PlayState* play) { sCButtonPosY[6] = ItemIconPos_ori[6][1]; } //C button Left - if (CVarGetInteger(CVAR_COSMETIC("CLeftButton.PosType"), 0) != 0) { - sCButtonPosY[0] = CVarGetInteger(CVAR_COSMETIC("CLeftButton.PosY"), 0)+Y_Margins_CL; - if (CVarGetInteger(CVAR_COSMETIC("CLeftButton.PosType"), 0) == 1) {//Anchor Left - if (CVarGetInteger(CVAR_COSMETIC("CLeftButton.UseMargins"), 0) != 0) {X_Margins_CL = Left_HUD_Margin;}; - sCButtonPosX[0] = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("CLeftButton.PosX"), 0)+X_Margins_CL); - } else if (CVarGetInteger(CVAR_COSMETIC("CLeftButton.PosType"), 0) == 2) {//Anchor Right - if (CVarGetInteger(CVAR_COSMETIC("CLeftButton.UseMargins"), 0) != 0) {X_Margins_CL = Right_HUD_Margin;}; - sCButtonPosX[0] = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("CLeftButton.PosX"), 0)+X_Margins_CL); - } else if (CVarGetInteger(CVAR_COSMETIC("CLeftButton.PosType"), 0) == 3) {//Anchor None - sCButtonPosX[0] = CVarGetInteger(CVAR_COSMETIC("CLeftButton.PosX"), 0); + if (CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.PosType"), 0) != 0) { + sCButtonPosY[0] = CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.PosY"), 0)+Y_Margins_CL; + if (CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.PosType"), 0) == 1) {//Anchor Left + if (CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.UseMargins"), 0) != 0) {X_Margins_CL = Left_HUD_Margin;}; + sCButtonPosX[0] = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.PosX"), 0)+X_Margins_CL); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.PosType"), 0) == 2) {//Anchor Right + if (CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.UseMargins"), 0) != 0) {X_Margins_CL = Right_HUD_Margin;}; + sCButtonPosX[0] = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.PosX"), 0)+X_Margins_CL); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.PosType"), 0) == 3) {//Anchor None + sCButtonPosX[0] = CVarGetInteger(CVAR_COSMETIC("HUD.CLeftButton.PosX"), 0); } } else { sCButtonPosX[0] = OTRGetRectDimensionFromRightEdge(ItemIconPos_ori[0][0]); sCButtonPosY[0] = ItemIconPos_ori[0][1]; } //C Button down - if (CVarGetInteger(CVAR_COSMETIC("CDownButton.PosType"), 0) != 0) { - sCButtonPosY[1] = CVarGetInteger(CVAR_COSMETIC("CDownButton.PosY"), 0)+Y_Margins_CD; - if (CVarGetInteger(CVAR_COSMETIC("CDownButton.PosType"), 0) == 1) {//Anchor Left - if (CVarGetInteger(CVAR_COSMETIC("CDownButton.UseMargins"), 0) != 0) {X_Margins_CD = Left_HUD_Margin;}; - sCButtonPosX[1] = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("CDownButton.PosX"), 0)+X_Margins_CD); - } else if (CVarGetInteger(CVAR_COSMETIC("CDownButton.PosType"), 0) == 2) {//Anchor Right - if (CVarGetInteger(CVAR_COSMETIC("CDownButton.UseMargins"), 0) != 0) {X_Margins_CD = Right_HUD_Margin;}; - sCButtonPosX[1] = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("CDownButton.PosX"), 0)+X_Margins_CD); - } else if (CVarGetInteger(CVAR_COSMETIC("CDownButton.PosType"), 0) == 3) {//Anchor None - sCButtonPosX[1] = CVarGetInteger(CVAR_COSMETIC("CDownButton.PosX"), 0); + if (CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.PosType"), 0) != 0) { + sCButtonPosY[1] = CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.PosY"), 0)+Y_Margins_CD; + if (CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.PosType"), 0) == 1) {//Anchor Left + if (CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.UseMargins"), 0) != 0) {X_Margins_CD = Left_HUD_Margin;}; + sCButtonPosX[1] = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.PosX"), 0)+X_Margins_CD); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.PosType"), 0) == 2) {//Anchor Right + if (CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.UseMargins"), 0) != 0) {X_Margins_CD = Right_HUD_Margin;}; + sCButtonPosX[1] = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.PosX"), 0)+X_Margins_CD); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.PosType"), 0) == 3) {//Anchor None + sCButtonPosX[1] = CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.PosX"), 0); } } else { sCButtonPosX[1] = OTRGetRectDimensionFromRightEdge(ItemIconPos_ori[1][0]); sCButtonPosY[1] = ItemIconPos_ori[1][1]; } //C button Right - if (CVarGetInteger(CVAR_COSMETIC("CRightButton.PosType"), 0) != 0) { - sCButtonPosY[2] = CVarGetInteger(CVAR_COSMETIC("CRightButton.PosY"), 0)+Y_Margins_CR; - if (CVarGetInteger(CVAR_COSMETIC("CRightButton.PosType"), 0) == 1) {//Anchor Left - if (CVarGetInteger(CVAR_COSMETIC("CRightButton.UseMargins"), 0) != 0) {X_Margins_CR = Left_HUD_Margin;}; - sCButtonPosX[2] = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("CRightButton.PosX"), 0)+X_Margins_CR); - } else if (CVarGetInteger(CVAR_COSMETIC("CRightButton.PosType"), 0) == 2) {//Anchor Right - if (CVarGetInteger(CVAR_COSMETIC("CRightButton.UseMargins"), 0) != 0) {X_Margins_CR = Right_HUD_Margin;}; - sCButtonPosX[2] = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("CRightButton.PosX"), 0)+X_Margins_CR); - } else if (CVarGetInteger(CVAR_COSMETIC("CRightButton.PosType"), 0) == 3) {//Anchor None - sCButtonPosX[2] = CVarGetInteger(CVAR_COSMETIC("CRightButton.PosX"), 0); + if (CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.PosType"), 0) != 0) { + sCButtonPosY[2] = CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.PosY"), 0)+Y_Margins_CR; + if (CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.PosType"), 0) == 1) {//Anchor Left + if (CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.UseMargins"), 0) != 0) {X_Margins_CR = Left_HUD_Margin;}; + sCButtonPosX[2] = OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.PosX"), 0)+X_Margins_CR); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.PosType"), 0) == 2) {//Anchor Right + if (CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.UseMargins"), 0) != 0) {X_Margins_CR = Right_HUD_Margin;}; + sCButtonPosX[2] = OTRGetDimensionFromRightEdge(CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.PosX"), 0)+X_Margins_CR); + } else if (CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.PosType"), 0) == 3) {//Anchor None + sCButtonPosX[2] = CVarGetInteger(CVAR_COSMETIC("HUD.CRightButton.PosX"), 0); } } else { sCButtonPosX[2] = OTRGetRectDimensionFromRightEdge(ItemIconPos_ori[2][0]); diff --git a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_map_PAL.c b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_map_PAL.c index dc574532ce8..8aba85040f0 100644 --- a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_map_PAL.c +++ b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_map_PAL.c @@ -54,7 +54,7 @@ void KaleidoScope_DrawDungeonMap(PlayState* play, GraphicsContext* gfxCtx) { s16 stepG; s16 stepB; u16 rgba16; - bool dpad = CVarGetInteger("gDpadPause", 0); + bool dpad = CVarGetInteger(CVAR_SETTING("DPadOnPause"), 0); OPEN_DISPS(gfxCtx); @@ -347,7 +347,7 @@ void KaleidoScope_DrawDungeonMap(PlayState* play, GraphicsContext* gfxCtx) { gDPLoadTLUT_pal16(POLY_KAL_DISP++, 0, interfaceCtx->mapPalettesPulse[palettePulseIdx]); gDPSetTextureLUT(POLY_KAL_DISP++, G_TT_RGBA16); - u8 mirroredWorld = CVarGetInteger("gMirroredWorld", 0); + u8 mirroredWorld = CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0); u8 mirrorMode = mirroredWorld ? G_TX_MIRROR : G_TX_NOMIRROR; // Offset the U value of each vertex to be in the mirror boundary for the map textures if (mirroredWorld) { @@ -443,8 +443,8 @@ void KaleidoScope_DrawWorldMap(PlayState* play, GraphicsContext* gfxCtx) { s16 stepR; s16 stepG; s16 stepB; - bool dpad = CVarGetInteger("gDpadPause", 0); - u8 mirroredWorld = CVarGetInteger("gMirroredWorld", 0); + bool dpad = CVarGetInteger(CVAR_SETTING("DPadOnPause"), 0); + u8 mirroredWorld = CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0); u8 mirrorMode = mirroredWorld ? G_TX_MIRROR : G_TX_NOMIRROR; OPEN_DISPS(gfxCtx); diff --git a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_prompt.c b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_prompt.c index 0807b8356a8..80ab3da9e69 100644 --- a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_prompt.c +++ b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_prompt.c @@ -7,7 +7,7 @@ void KaleidoScope_UpdatePrompt(PlayState* play) { Input* input = &play->state.input[0]; s8 relStickX = input->rel.stick_x; s16 step; - bool dpad = CVarGetInteger("gDpadPause", 0); + bool dpad = CVarGetInteger(CVAR_SETTING("DPadOnPause"), 0); if (((pauseCtx->state == 7) && (pauseCtx->unk_1EC == 1)) || (pauseCtx->state == 0xE) || (pauseCtx->state == 0x10)) { if ((pauseCtx->promptChoice == 0) && ((relStickX >= 30) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DRIGHT)))) { diff --git a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c index 8939b0c6160..424c823d603 100644 --- a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c +++ b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c @@ -945,7 +945,7 @@ Gfx* KaleidoScope_QuadTextureIA4(Gfx* gfx, void* texture, s16 width, s16 height, } Gfx* KaleidoScope_QuadTextureIA8(Gfx* gfx, void* texture, s16 width, s16 height, u16 point) { - u8 mirrorMode = CVarGetInteger("gMirroredWorld", 0) ? G_TX_MIRROR : G_TX_NOMIRROR; + u8 mirrorMode = CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0) ? G_TX_MIRROR : G_TX_NOMIRROR; gDPLoadTextureBlock(gfx++, texture, G_IM_FMT_IA, G_IM_SIZ_8b, width, height, 0, mirrorMode | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); gSP1Quadrangle(gfx++, point, point + 2, point + 3, point + 1, 0); @@ -1099,7 +1099,7 @@ void KaleidoScope_HandlePageToggles(PauseContext* pauseCtx, Input* input) { return; } - bool dpad = CVarGetInteger("gDpadPause", 0); + bool dpad = CVarGetInteger(CVAR_SETTING("DPadOnPause"), 0); if (pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_LEFT) { if ((pauseCtx->stickRelX < -30) || (dpad && CHECK_BTN_ALL(input->cur.button, BTN_DLEFT))) { pauseCtx->pageSwitchTimer++; @@ -1273,7 +1273,7 @@ void KaleidoScope_DrawPages(PlayState* play, GraphicsContext* gfxCtx) { } } - if (CVarGetInteger("gDpadHoldChange", 1) && CVarGetInteger("gDpadPause", 0)) { + if (CVarGetInteger(CVAR_SETTING("DpadHoldChange"), 1) && CVarGetInteger(CVAR_SETTING("DPadOnPause"), 0)) { if (CHECK_BTN_ALL(input->cur.button, BTN_DLEFT)) { if (CHECK_BTN_ALL(input->press.button, BTN_DLEFT)) { D_8082AD44 = XREG(8); @@ -2061,8 +2061,8 @@ void KaleidoScope_DrawInfoPanel(PlayState* play) { } } else { bool pauseAnyCursor = - (CVarGetInteger("gPauseAnyCursor", 0) == PAUSE_ANY_CURSOR_RANDO_ONLY && IS_RANDO) || - (CVarGetInteger("gPauseAnyCursor", 0) == PAUSE_ANY_CURSOR_ALWAYS_ON); + (CVarGetInteger(CVAR_SETTING("PauseAnyCursor"), 0) == PAUSE_ANY_CURSOR_RANDO_ONLY && IS_RANDO) || + (CVarGetInteger(CVAR_SETTING("PauseAnyCursor"), 0) == PAUSE_ANY_CURSOR_ALWAYS_ON); if (!pauseCtx->pageIndex && (!pauseAnyCursor || (gSaveContext.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]] != ITEM_NONE))) { // pageIndex == PAUSE_ITEM pauseCtx->infoPanelVtx[16].v.ob[0] = pauseCtx->infoPanelVtx[18].v.ob[0] = WREG(49 + gSaveContext.language); @@ -2199,8 +2199,8 @@ void KaleidoScope_DrawInfoPanel(PlayState* play) { void KaleidoScope_UpdateNamePanel(PlayState* play) { PauseContext* pauseCtx = &play->pauseCtx; u16 sp2A; - bool pauseAnyCursor = (CVarGetInteger("gPauseAnyCursor", 0) == PAUSE_ANY_CURSOR_RANDO_ONLY && IS_RANDO) || - (CVarGetInteger("gPauseAnyCursor", 0) == PAUSE_ANY_CURSOR_ALWAYS_ON); + bool pauseAnyCursor = (CVarGetInteger(CVAR_SETTING("PauseAnyCursor"), 0) == PAUSE_ANY_CURSOR_RANDO_ONLY && IS_RANDO) || + (CVarGetInteger(CVAR_SETTING("PauseAnyCursor"), 0) == PAUSE_ANY_CURSOR_ALWAYS_ON); if ((pauseCtx->namedItem != pauseCtx->cursorItem[pauseCtx->pageIndex]) || ((pauseCtx->pageIndex == PAUSE_MAP) && (pauseCtx->cursorSpecialPos != 0))) { @@ -2868,7 +2868,7 @@ void KaleidoScope_InitVertices(PlayState* play, GraphicsContext* gfxCtx) { for (phi_t3 = 1; phi_t3 < ARRAY_COUNT(gSaveContext.equips.buttonItems); phi_t3++, phi_t2 += 4) { if (gSaveContext.equips.cButtonSlots[phi_t3 - 1] != ITEM_NONE && - ((phi_t3 < 4) || CVarGetInteger("gDpadEquips", 0))) { + ((phi_t3 < 4) || CVarGetInteger(CVAR_SETTING("DpadEquips"), 0))) { phi_t4 = gSaveContext.equips.cButtonSlots[phi_t3 - 1] * 4; pauseCtx->itemVtx[phi_t2 + 0].v.ob[0] = pauseCtx->itemVtx[phi_t2 + 2].v.ob[0] = @@ -3267,7 +3267,7 @@ void KaleidoScope_Draw(PlayState* play) { func_800AAA50(&play->view, 15); // Flip the OPA and XLU projections again as the set view call above reset the original flips from z_play - if (CVarGetInteger("gMirroredWorld", 0)) { + if (CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0)) { gSPMatrix(POLY_OPA_DISP++, play->view.projectionFlippedPtr, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); gSPMatrix(POLY_XLU_DISP++, play->view.projectionFlippedPtr, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); gSPMatrix(POLY_OPA_DISP++, play->view.viewingPtr, G_MTX_NOPUSH | G_MTX_MUL | G_MTX_PROJECTION); @@ -3996,7 +3996,7 @@ void KaleidoScope_Update(PlayState* play) (CHECK_BTN_ALL(input->press.button, BTN_B) && IS_BOSS_RUSH)) { if (CVarGetInteger(CVAR_CHEAT("EasyPauseBuffer"), 0) || CVarGetInteger(CVAR_CHEAT("EasyInputBuffer"), 0)) { // Easy pause buffer is 13 frames, 12 for kaledio to end, and one more to advance a single frame - CVarSetInteger("gCheatEasyPauseBufferTimer", 13); + CVarSetInteger(CVAR_GENERAL("CheatEasyPauseBufferTimer"), 13); } Interface_SetDoAction(play, DO_ACTION_NONE); pauseCtx->state = 0x12; @@ -4560,7 +4560,7 @@ void KaleidoScope_Update(PlayState* play) R_UPDATE_RATE = 3; R_PAUSE_MENU_MODE = 0; - CVarSetInteger("gPauseTriforce", 0); + CVarSetInteger(CVAR_GENERAL("PauseTriforce"), 0); func_800981B8(&play->objectCtx); func_800418D0(&play->colCtx, play); diff --git a/soh/src/overlays/misc/ovl_kaleido_scope/z_lmap_mark.c b/soh/src/overlays/misc/ovl_kaleido_scope/z_lmap_mark.c index 37093a28325..0de1d117ad8 100644 --- a/soh/src/overlays/misc/ovl_kaleido_scope/z_lmap_mark.c +++ b/soh/src/overlays/misc/ovl_kaleido_scope/z_lmap_mark.c @@ -132,7 +132,7 @@ void PauseMapMark_DrawForDungeon(PlayState* play) { G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); // Compute the offset to mirror icons over the map center (48) as an axis line - s16 mirrorOffset = CVarGetInteger("gMirroredWorld", 0) ? mirrorOffset = (48 - markPoint->x) * 2 + 1 : 0; + s16 mirrorOffset = CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0) ? mirrorOffset = (48 - markPoint->x) * 2 + 1 : 0; Matrix_Push(); Matrix_Translate(GREG(92) + markPoint->x + mirrorOffset, GREG(93) + markPoint->y, 0.0f, MTXMODE_APPLY); From 27dd303a57da376847fae6d223ba6f2dfe5cd351 Mon Sep 17 00:00:00 2001 From: Eric Hoey <121978037+A-Green-Spoon@users.noreply.github.com> Date: Mon, 6 May 2024 15:10:22 -0400 Subject: [PATCH 17/59] Limit crawl speed to modifier to 4 (#4113) --- soh/soh/SohMenuBar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/soh/soh/SohMenuBar.cpp b/soh/soh/SohMenuBar.cpp index b847988dc9e..f56c23c7fca 100644 --- a/soh/soh/SohMenuBar.cpp +++ b/soh/soh/SohMenuBar.cpp @@ -572,7 +572,7 @@ void DrawEnhancementsMenu() { UIWidgets::PaddedEnhancementSliderInt("King Zora Speed: %dx", "##MWEEPSPEED", CVAR_ENHANCEMENT("MweepSpeed"), 1, 5, "", 1, true, false, true); UIWidgets::PaddedEnhancementSliderInt("Vine/Ladder Climb speed +%d", "##CLIMBSPEED", CVAR_ENHANCEMENT("ClimbSpeed"), 0, 12, "", 0, true, false, true); UIWidgets::PaddedEnhancementSliderInt("Block pushing speed +%d", "##BLOCKSPEED", CVAR_ENHANCEMENT("FasterBlockPush"), 0, 5, "", 0, true, false, true); - UIWidgets::PaddedEnhancementSliderInt("Crawl speed %dx", "##CRAWLSPEED", CVAR_ENHANCEMENT("CrawlSpeed"), 1, 5, "", 1, true, false, true); + UIWidgets::PaddedEnhancementSliderInt("Crawl speed %dx", "##CRAWLSPEED", CVAR_ENHANCEMENT("CrawlSpeed"), 1, 4, "", 1, true, false, true); UIWidgets::PaddedEnhancementCheckbox("Faster Heavy Block Lift", CVAR_ENHANCEMENT("FasterHeavyBlockLift"), false, false); UIWidgets::Tooltip("Speeds up lifting silver rocks and obelisks"); UIWidgets::PaddedEnhancementCheckbox("Skip Pickup Messages", CVAR_ENHANCEMENT("FastDrops"), true, false); From 438dede792b236c12d37d3d67c54d0765f758a1e Mon Sep 17 00:00:00 2001 From: Malkierian Date: Mon, 6 May 2024 15:10:06 -0700 Subject: [PATCH 18/59] Change "AnubixFix" back to "AnubisFix". (#4124) --- soh/soh/Enhancements/presets.h | 6 +++--- soh/soh/SohMenuBar.cpp | 2 +- .../overlays/actors/ovl_En_Anubice_Fire/z_en_anubice_fire.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/soh/soh/Enhancements/presets.h b/soh/soh/Enhancements/presets.h index aea4bb1fd79..a502dc3daad 100644 --- a/soh/soh/Enhancements/presets.h +++ b/soh/soh/Enhancements/presets.h @@ -163,7 +163,7 @@ const std::vector enhancementsCvars = { CVAR_ENHANCEMENT("GravediggingTourFix"), CVAR_ENHANCEMENT("DekuNutUpgradeFix"), CVAR_ENHANCEMENT("NaviTextFix"), - CVAR_ENHANCEMENT("AnubixFix"), + CVAR_ENHANCEMENT("AnubisFix"), CVAR_ENHANCEMENT("CrouchStabHammerFix"), CVAR_ENHANCEMENT("CrouchStabFix"), CVAR_ENHANCEMENT("GerudoWarriorClothingFix"), @@ -682,7 +682,7 @@ const std::vector enhancedPresetEntries = { PRESET_ENTRY_S32(CVAR_ENHANCEMENT("NewDrops"), 1), // Fix Anubis fireballs - PRESET_ENTRY_S32(CVAR_ENHANCEMENT("AnubixFix"), 1), + PRESET_ENTRY_S32(CVAR_ENHANCEMENT("AnubisFix"), 1), // Autosave PRESET_ENTRY_S32(CVAR_ENHANCEMENT("Autosave"), AUTOSAVE_LOCATION_AND_MAJOR_ITEMS), @@ -808,7 +808,7 @@ const std::vector randomizerPresetEntries = { PRESET_ENTRY_S32(CVAR_ENHANCEMENT("NewDrops"), 1), // Fix Anubis fireballs - PRESET_ENTRY_S32(CVAR_ENHANCEMENT("AnubixFix"), 1), + PRESET_ENTRY_S32(CVAR_ENHANCEMENT("AnubisFix"), 1), // Autosave PRESET_ENTRY_S32(CVAR_ENHANCEMENT("Autosave"), AUTOSAVE_LOCATION_AND_MAJOR_ITEMS), diff --git a/soh/soh/SohMenuBar.cpp b/soh/soh/SohMenuBar.cpp index f56c23c7fca..c396de73893 100644 --- a/soh/soh/SohMenuBar.cpp +++ b/soh/soh/SohMenuBar.cpp @@ -1201,7 +1201,7 @@ void DrawEnhancementsMenu() { UIWidgets::Tooltip("Prevents the Forest Stage Deku Nut upgrade from becoming unobtainable after receiving the Poacher's Saw"); UIWidgets::PaddedEnhancementCheckbox("Fix Navi text HUD position", CVAR_ENHANCEMENT("NaviTextFix"), true, false); UIWidgets::Tooltip("Correctly centers the Navi text prompt on the HUD's C-Up button"); - UIWidgets::PaddedEnhancementCheckbox("Fix Anubis fireballs", CVAR_ENHANCEMENT("AnubixFix"), true, false); + UIWidgets::PaddedEnhancementCheckbox("Fix Anubis fireballs", CVAR_ENHANCEMENT("AnubisFix"), true, false); UIWidgets::Tooltip("Make Anubis fireballs do fire damage when reflected back at them with the Mirror Shield"); if (UIWidgets::PaddedEnhancementCheckbox("Fix Megaton Hammer crouch stab", CVAR_ENHANCEMENT("CrouchStabHammerFix"), true, false)) { if (!CVarGetInteger(CVAR_ENHANCEMENT("CrouchStabHammerFix"), 0)) { diff --git a/soh/src/overlays/actors/ovl_En_Anubice_Fire/z_en_anubice_fire.c b/soh/src/overlays/actors/ovl_En_Anubice_Fire/z_en_anubice_fire.c index 0b1a2b0b7ec..a26f5a08bd0 100644 --- a/soh/src/overlays/actors/ovl_En_Anubice_Fire/z_en_anubice_fire.c +++ b/soh/src/overlays/actors/ovl_En_Anubice_Fire/z_en_anubice_fire.c @@ -116,7 +116,7 @@ void func_809B27D8(EnAnubiceFire* this, PlayState* play) { Audio_PlayActorSound2(&this->actor, NA_SE_IT_SHIELD_REFLECT_SW); this->cylinder.base.atFlags &= 0xFFE9; this->cylinder.base.atFlags |= 8; - this->cylinder.info.toucher.dmgFlags = CVarGetInteger(CVAR_ENHANCEMENT("AnubixFix"), 0) ? 0x800 : 2; + this->cylinder.info.toucher.dmgFlags = CVarGetInteger(CVAR_ENHANCEMENT("AnubisFix"), 0) ? 0x800 : 2; this->unk_15A = 30; this->actor.params = 1; this->actor.velocity.x *= -1.0f; From f3b948226b11bca9c59715b27b404b3c1ec32c51 Mon Sep 17 00:00:00 2001 From: Lywx Date: Mon, 6 May 2024 17:19:15 -0600 Subject: [PATCH 19/59] Bump lus and fixed PatchGfx (#4125) * Bump lus and fixed PatchGfx * Bump libultraship to main --- libultraship | 2 +- soh/soh/OTRGlobals.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libultraship b/libultraship index 7d71a290657..a5d84b29429 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit 7d71a290657a2d3b09a83e8b33025e807f4fb38e +Subproject commit a5d84b29429dcd9b32fb1d8b169b6dd269e6c979 diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 0a0b83d4a02..b61bb65cc83 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -1791,7 +1791,7 @@ extern "C" void ResourceMgr_PatchGfxCopyCommandByName(const char* path, const ch } Gfx* destinationGfx = (Gfx*)&res->Instructions[destinationIndex]; - Gfx sourceGfx = res->Instructions[sourceIndex]; + Gfx sourceGfx = *(Gfx*)&res->Instructions[sourceIndex]; if (!originalGfx.contains(path) || !originalGfx[path].contains(patchName)) { originalGfx[path][patchName] = { From b3d51441eb8759f607a9448c535c46f6a9cddecd Mon Sep 17 00:00:00 2001 From: Malkierian Date: Mon, 6 May 2024 17:17:08 -0700 Subject: [PATCH 20/59] Rando Enhancement: Mysterious Shuffled Items (#3227) * Add rando enhancement "Mysterious Shuffled Items", which obfuscates shuffled freestanding/drawn-in-world items (PoH, tokens, shop items) with a custom question mark model (thanks Hato), and uses the "mysterious item" functionality of `GetMerchantMessage` for everything that supports it, regardless of hint status on generation. * Reverted back to rando enhancement, but added condition for Mysterious Shuffle not being on for the gem rotation fix to apply. * First attempt at changing to fake GetItemEntry instead of directly calling the mystery draw function. Needs more work. * Updated CVar to reflect CVar rework values. Added `IsCheckShuffled` as preliminary function for checking *only* if a check is shuffled, not necessarily if it is just visible on the tracker. This accounts for the difference between tokensanity and "Always Show GS On Tracker", where you don't want to obfuscate the latter. * Bit of cleanup. * Cross-platform building edits. If anyone has a better idea of how to handle this fake GIE, I'm all ears. * Update to CVar macros. * Fix freestanding item gives. Fix mysterious item model colors. * Fix bombchu bowling mystery. * Remove bowling bomchus check obfuscation (unused, removed in v3). --- .../object_mystery_item/gMysteryItemDL | 16 + .../object_mystery_item/gMysteryItemDL_tri_0 | 56 +++ .../object_mystery_item/gMysteryItemDL_tri_1 | 120 +++++ .../object_mystery_item/gMysteryItemDL_vtx_0 | 119 +++++ .../object_mystery_item/gMysteryItemDL_vtx_1 | 416 ++++++++++++++++++ .../gMysteryItemDL_vtx_cull | 10 + ...yItemDL_f3dlite_mysteryItem_light_material | 21 + ...MysteryItemDL_f3dlite_mysteryItem_material | 21 + .../objects/object_mystery_item/noise_tex | Bin 0 -> 1116 bytes soh/assets/soh_assets.h | 3 + soh/include/variables.h | 3 +- .../cosmetics/CosmeticsEditor.cpp | 1 + soh/soh/Enhancements/randomizer/draw.cpp | 25 +- soh/soh/Enhancements/randomizer/draw.h | 4 + .../Enhancements/randomizer/randomizer.cpp | 20 +- soh/soh/Enhancements/randomizer/randomizer.h | 1 + .../randomizer/randomizer_check_tracker.cpp | 19 +- .../randomizer/randomizer_check_tracker.h | 1 + soh/soh/OTRGlobals.cpp | 9 + soh/soh/OTRGlobals.h | 2 + soh/soh/SohMenuBar.cpp | 5 + soh/src/code/z_en_item00.c | 28 +- .../actors/ovl_Demo_Effect/z_demo_effect.c | 3 +- .../actors/ovl_En_Ex_Item/z_en_ex_item.c | 11 +- .../overlays/actors/ovl_En_GirlA/z_en_girla.c | 7 +- soh/src/overlays/actors/ovl_En_Si/z_en_si.c | 3 +- .../actors/ovl_Item_B_Heart/z_item_b_heart.c | 4 +- .../ovl_Item_Etcetera/z_item_etcetera.c | 7 +- .../actors/ovl_Item_Ocarina/z_item_ocarina.c | 2 +- 29 files changed, 896 insertions(+), 41 deletions(-) create mode 100644 soh/assets/custom/objects/object_mystery_item/gMysteryItemDL create mode 100644 soh/assets/custom/objects/object_mystery_item/gMysteryItemDL_tri_0 create mode 100644 soh/assets/custom/objects/object_mystery_item/gMysteryItemDL_tri_1 create mode 100644 soh/assets/custom/objects/object_mystery_item/gMysteryItemDL_vtx_0 create mode 100644 soh/assets/custom/objects/object_mystery_item/gMysteryItemDL_vtx_1 create mode 100644 soh/assets/custom/objects/object_mystery_item/gMysteryItemDL_vtx_cull create mode 100644 soh/assets/custom/objects/object_mystery_item/mat_gMysteryItemDL_f3dlite_mysteryItem_light_material create mode 100644 soh/assets/custom/objects/object_mystery_item/mat_gMysteryItemDL_f3dlite_mysteryItem_material create mode 100644 soh/assets/custom/objects/object_mystery_item/noise_tex diff --git a/soh/assets/custom/objects/object_mystery_item/gMysteryItemDL b/soh/assets/custom/objects/object_mystery_item/gMysteryItemDL new file mode 100644 index 00000000000..939042daaf1 --- /dev/null +++ b/soh/assets/custom/objects/object_mystery_item/gMysteryItemDL @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/soh/assets/custom/objects/object_mystery_item/gMysteryItemDL_tri_0 b/soh/assets/custom/objects/object_mystery_item/gMysteryItemDL_tri_0 new file mode 100644 index 00000000000..8c320d24362 --- /dev/null +++ b/soh/assets/custom/objects/object_mystery_item/gMysteryItemDL_tri_0 @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/soh/assets/custom/objects/object_mystery_item/gMysteryItemDL_tri_1 b/soh/assets/custom/objects/object_mystery_item/gMysteryItemDL_tri_1 new file mode 100644 index 00000000000..0990859d5a2 --- /dev/null +++ b/soh/assets/custom/objects/object_mystery_item/gMysteryItemDL_tri_1 @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/soh/assets/custom/objects/object_mystery_item/gMysteryItemDL_vtx_0 b/soh/assets/custom/objects/object_mystery_item/gMysteryItemDL_vtx_0 new file mode 100644 index 00000000000..37e6186e948 --- /dev/null +++ b/soh/assets/custom/objects/object_mystery_item/gMysteryItemDL_vtx_0 @@ -0,0 +1,119 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/soh/assets/custom/objects/object_mystery_item/gMysteryItemDL_vtx_1 b/soh/assets/custom/objects/object_mystery_item/gMysteryItemDL_vtx_1 new file mode 100644 index 00000000000..4360eedc507 --- /dev/null +++ b/soh/assets/custom/objects/object_mystery_item/gMysteryItemDL_vtx_1 @@ -0,0 +1,416 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/soh/assets/custom/objects/object_mystery_item/gMysteryItemDL_vtx_cull b/soh/assets/custom/objects/object_mystery_item/gMysteryItemDL_vtx_cull new file mode 100644 index 00000000000..cedf6351d19 --- /dev/null +++ b/soh/assets/custom/objects/object_mystery_item/gMysteryItemDL_vtx_cull @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/soh/assets/custom/objects/object_mystery_item/mat_gMysteryItemDL_f3dlite_mysteryItem_light_material b/soh/assets/custom/objects/object_mystery_item/mat_gMysteryItemDL_f3dlite_mysteryItem_light_material new file mode 100644 index 00000000000..4dc39e81139 --- /dev/null +++ b/soh/assets/custom/objects/object_mystery_item/mat_gMysteryItemDL_f3dlite_mysteryItem_light_material @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/soh/assets/custom/objects/object_mystery_item/mat_gMysteryItemDL_f3dlite_mysteryItem_material b/soh/assets/custom/objects/object_mystery_item/mat_gMysteryItemDL_f3dlite_mysteryItem_material new file mode 100644 index 00000000000..6941bb55fdd --- /dev/null +++ b/soh/assets/custom/objects/object_mystery_item/mat_gMysteryItemDL_f3dlite_mysteryItem_material @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/soh/assets/custom/objects/object_mystery_item/noise_tex b/soh/assets/custom/objects/object_mystery_item/noise_tex new file mode 100644 index 0000000000000000000000000000000000000000..aaf4e331f15f797a3b1122b58c57b3767e66bc0f GIT binary patch literal 1116 zcma)5S&rmH5G^FcIk*X5eDlKxBf5LKx?JVw&9uYY}ZlKyY|id266pZ|L)_-3^t z{^e>VIz`u(`^dKQ%g2w`bDu%x{^r%I8%i=wg`pMy&>oT`wvAwTeqNf)RT*l1cl(+W z4O3wm5FDBuCz%Uiv0TQ&*Cj#VNy!7F8h~R}KQ9uTqZsmTyW<5x_pt+H9l4&R zNV*$EuA#8o9Vc?s{bsv;)Pm5GMBTP6z|sQ5v2V)EX1(5QHV?AIOLmqzz`$u>%G@KX zAm1U#Q1`b#-cdY`0zWyHA&UB`uvJOq1z;j%s@!gUchADQtBSnLBiuZ{ObIeINsvAl zKp>GPf~X&wGE1T`oqzfLxlOSLfeJL;gpe$uxkXczdF&C0F2DWpa%!p~b}e0&RKxLI z%T231NzwpnD1Z9&={oddS76r=ISB@l@A&(Ji`>A~6jZ+b`Tf)mbH67OcwTj)5Scc{ zK!pLxobvMFI`+$@k4zv-0AY+25fE@S6z$W{&&H?oX}(_jP*+sLjS^qu9wmr;+rj%{ zAEy-|@BH@CVH4;m%+kORMa{#BXIWla6lGO6!#wp(?ire4hv`1{96uqtA;^bi)3$9t zo$9i#W2i_9OzJvM;xx4+nwI?IFm%JTj73}=LclXD2+J}FLmcRYNZGH3zUij9O&r(N zIC{GkOwTb52m2bcW%RfiySf=qM4ckHqqfwB78L>#iUN&&l-#mE4Q;=iy9hjP)*G6p zcAUU-vK4wNFT$)pja`3!_q^mt=2&vXvP9&Xrb8$zFlv{%J+_yZm#3OgWf__(%K$o# zDT@+s;Ci{tRaQ>d>(W(+JVHPr6kC2^iS&+v`RR%Lt01bUX&g>t6B|4yh?4GjP~1K+ zRyjYNyVUUyr+Hf5EKR78{fMr0WJ>e{hl cosmeticOptions = { COSMETIC_OPTION("World.Moon", "Moon", COSMETICS_GROUP_WORLD, ImVec4(240, 255, 180, 255), false, true, true), COSMETIC_OPTION("World.GossipStone", "Gossip Stone", COSMETICS_GROUP_WORLD, ImVec4(200, 200, 200, 255), false, true, true), COSMETIC_OPTION("World.RedIce", "Red Ice", COSMETICS_GROUP_WORLD, ImVec4(255, 0, 0, 255), false, true, false), + COSMETIC_OPTION("World.MysteryItem", "Mystery Item", COSMETICS_GROUP_WORLD, ImVec4(0, 60, 100, 255), false, true, false), COSMETIC_OPTION("Navi.IdlePrimary", "Idle Primary", COSMETICS_GROUP_NAVI, ImVec4(255, 255, 255, 255), false, true, false), COSMETIC_OPTION("Navi.IdleSecondary", "Idle Secondary", COSMETICS_GROUP_NAVI, ImVec4( 0, 0, 255, 0), false, true, true), diff --git a/soh/soh/Enhancements/randomizer/draw.cpp b/soh/soh/Enhancements/randomizer/draw.cpp index 4fbe489d2d9..7a970b8950c 100644 --- a/soh/soh/Enhancements/randomizer/draw.cpp +++ b/soh/soh/Enhancements/randomizer/draw.cpp @@ -248,7 +248,7 @@ extern "C" void Randomizer_DrawTriforcePieceGI(PlayState* play, GetItemEntry get if (triforcePieceScale < 0.0001f) { triforcePieceScale += 0.00003f; } - + // Animation. When not the completed triforce, create delay before showing the piece to bypass interpolation. // If the completed triforce, make it grow slowly. if (current != required) { @@ -275,5 +275,28 @@ extern "C" void Randomizer_DrawTriforcePieceGI(PlayState* play, GetItemEntry get } else if (current == required && triforcePieceScale > 0.00008f) { gSPDisplayList(POLY_XLU_DISP++, (Gfx*)gTriforcePieceCompletedDL); } + + CLOSE_DISPS(play->state.gfxCtx); +} + +extern "C" void Randomizer_DrawMysteryItem(PlayState* play, GetItemEntry getItemEntry) { + Color_RGB8 color = { 0, 60, 100 }; + if (CVarGetInteger(CVAR_COSMETIC("World.MysteryItem.Changed"), 0)) { + color = CVarGetColor24(CVAR_COSMETIC("World.MysteryItem.Value"), color); + } + + OPEN_DISPS(play->state.gfxCtx); + + Gfx_SetupDL_25Xlu(play->state.gfxCtx); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, (char*)__FILE__, __LINE__), G_MTX_MODELVIEW | G_MTX_LOAD); + + gDPSetGrayscaleColor(POLY_XLU_DISP++, color.r, color.g, color.b, 255); + gSPGrayscale(POLY_XLU_DISP++, true); + + gSPDisplayList(POLY_XLU_DISP++, (Gfx*)gMysteryItemDL); + + gSPGrayscale(POLY_XLU_DISP++, false); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/soh/soh/Enhancements/randomizer/draw.h b/soh/soh/Enhancements/randomizer/draw.h index d9134573d4f..8c152a4f9ff 100644 --- a/soh/soh/Enhancements/randomizer/draw.h +++ b/soh/soh/Enhancements/randomizer/draw.h @@ -16,6 +16,10 @@ void Randomizer_DrawDoubleDefense(PlayState* play, GetItemEntry getItemEntry); void Randomizer_DrawMasterSword(PlayState* play, GetItemEntry getItemEntry); void Randomizer_DrawTriforcePiece(PlayState* play, GetItemEntry getItemEntry); void Randomizer_DrawTriforcePieceGI(PlayState* play, GetItemEntry getItemEntry); +void Randomizer_DrawMysteryItem(PlayState* play, GetItemEntry getItemEntry); + +#define GET_ITEM_MYSTERY \ + { ITEM_NONE, 0, 0, 0, 0, 0, 0, 0, 0, false, ITEM_FROM_NPC, ITEM_CATEGORY_JUNK, Randomizer_DrawMysteryItem } #ifdef __cplusplus }; #endif diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index f5c522ddc0d..107e23e83d1 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -5412,12 +5412,20 @@ CustomMessage Randomizer::GetMerchantMessage(RandomizerInf randomizerInf, u16 te RandomizerCheck rc = GetCheckFromRandomizerInf(randomizerInf); RandomizerGet shopItemGet = this->itemLocations[rc].rgID; std::array shopItemName; - if (mysterious) { - shopItemName = { - "mysterious item", - "mysteriösen Gegenstand", - "objet mystérieux" - }; + if (mysterious || CVarGetInteger(CVAR_RANDOMIZER_ENHANCEMENT("MysteriousShuffle"), 0)) { + if (randomizerInf >= RAND_INF_SHOP_ITEMS_KF_SHOP_ITEM_1 && randomizerInf <= RAND_INF_SHOP_ITEMS_MARKET_BOMBCHU_SHOP_ITEM_8) { + shopItemName = { + "Mysterious Item", + "Mysteriösen Gegenstand", + "Objet Mystérieux" + }; + } else { + shopItemName = { + "mysterious item", + "mysteriösen Gegenstand", + "objet mystérieux" + }; + } // TODO: This should eventually be replaced with a full fledged trick model & trick name system } else if (shopItemGet == RG_ICE_TRAP) { shopItemGet = this->itemLocations[rc].fakeRgID; diff --git a/soh/soh/Enhancements/randomizer/randomizer.h b/soh/soh/Enhancements/randomizer/randomizer.h index a726cecdeee..ce8f5c45be9 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.h +++ b/soh/soh/Enhancements/randomizer/randomizer.h @@ -9,6 +9,7 @@ #include #include #include "soh/Enhancements/randomizer/randomizer_check_objects.h" +#include "soh/Enhancements/randomizer/randomizer_check_tracker.h" #include "soh/Enhancements/randomizer/randomizer_tricks.h" #include #include "soh/Enhancements/item-tables/ItemTableTypes.h" diff --git a/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp b/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp index 4ca8c79937a..a53b838f302 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp @@ -1223,7 +1223,7 @@ void LoadSettings() { } } -bool IsVisibleInCheckTracker(RandomizerCheckObject rcObj) { +bool IsCheckShuffled(RandomizerCheckObject rcObj) { if (IS_RANDO && OTRGlobals::Instance->gRandomizer->GetRandoSettingValue(RSK_LOGIC_RULES) != RO_LOGIC_VANILLA) { return (rcObj.rcArea != RCAREA_INVALID) && // don't show Invalid locations @@ -1236,7 +1236,7 @@ bool IsVisibleInCheckTracker(RandomizerCheckObject rcObj) { rcObj.vOrMQ == RCVORMQ_MQ && OTRGlobals::Instance->gRandomizer->masterQuestDungeons.contains(rcObj.sceneId) || rcObj.vOrMQ == RCVORMQ_VANILLA && !OTRGlobals::Instance->gRandomizer->masterQuestDungeons.contains(rcObj.sceneId) ) && - (rcObj.rcType != RCTYPE_SHOP || (showShops && (!hideShopRightChecks || hideShopRightChecks && rcObj.actorParams > 0x03))) && + (rcObj.rcType != RCTYPE_SHOP || (showShops && rcObj.actorParams > 0x03)) && (rcObj.rcType != RCTYPE_SCRUB || showScrubs || rcObj.rc == RC_LW_DEKU_SCRUB_NEAR_BRIDGE || // The 3 scrubs that are always randomized @@ -1245,7 +1245,7 @@ bool IsVisibleInCheckTracker(RandomizerCheckObject rcObj) { ) && (rcObj.rcType != RCTYPE_MERCHANT || showMerchants) && (rcObj.rcType != RCTYPE_OCARINA || showOcarinas) && - (rcObj.rcType != RCTYPE_SKULL_TOKEN || alwaysShowGS || + (rcObj.rcType != RCTYPE_SKULL_TOKEN || (showOverworldTokens && RandomizerCheckObjects::AreaIsOverworld(rcObj.rcArea)) || (showDungeonTokens && RandomizerCheckObjects::AreaIsDungeon(rcObj.rcArea)) ) && @@ -1265,6 +1265,7 @@ bool IsVisibleInCheckTracker(RandomizerCheckObject rcObj) { (rcObj.rcType != RCTYPE_BOSS_KEY || showBossKeysanity) && (rcObj.rcType != RCTYPE_GANON_BOSS_KEY || showGanonBossKey) && (rcObj.rc != RC_KAK_100_GOLD_SKULLTULA_REWARD || show100SkullReward) && + (rcObj.rc != RC_MARKET_BOMBCHU_BOWLING_BOMBCHUS) && (rcObj.rcType != RCTYPE_GF_KEY && rcObj.rc != RC_GF_GERUDO_MEMBERSHIP_CARD || (showGerudoCard && rcObj.rc == RC_GF_GERUDO_MEMBERSHIP_CARD) || (fortressNormal && showGerudoFortressKeys && rcObj.rcType == RCTYPE_GF_KEY) || @@ -1280,6 +1281,10 @@ bool IsVisibleInCheckTracker(RandomizerCheckObject rcObj) { return false; } +bool IsVisibleInCheckTracker(RandomizerCheckObject rcObj) { + return IsCheckShuffled(rcObj) || (rcObj.rcType == RCTYPE_SKULL_TOKEN && alwaysShowGS) || (rcObj.rcType == RCTYPE_SHOP && (showShops && (!hideShopRightChecks))); +} + void UpdateInventoryChecks() { //For all the areas with maps, if you have one, spoil the area for (auto [scene, area] : DungeonRCAreasBySceneID) { @@ -1444,6 +1449,8 @@ void DrawLocation(RandomizerCheckObject rcObj) { //Draw the extra info txt = ""; + bool mystery = CVarGetInteger(CVAR_RANDOMIZER_ENHANCEMENT("MysteriousShuffle"), 0) && OTRGlobals::Instance->gRandomizer->merchantPrices.contains(rcObj.rc); + if (checkData.hintItem != 0) { // TODO hints } else if (status != RCSHOW_UNCHECKED) { @@ -1466,16 +1473,16 @@ void DrawLocation(RandomizerCheckObject rcObj) { case RCSHOW_IDENTIFIED: case RCSHOW_SEEN: if (IS_RANDO) { - if (gSaveContext.itemLocations[rcObj.rc].get.rgID == RG_ICE_TRAP) { + if (gSaveContext.itemLocations[rcObj.rc].get.rgID == RG_ICE_TRAP && !mystery) { if (status == RCSHOW_IDENTIFIED) { txt = gSaveContext.itemLocations[rcObj.rc].get.trickName; } else { txt = OTRGlobals::Instance->gRandomizer->EnumToSpoilerfileGetName[gSaveContext.itemLocations[rcObj.rc].get.fakeRgID][gSaveContext.language]; } - } else { + } else if (!mystery) { txt = OTRGlobals::Instance->gRandomizer->EnumToSpoilerfileGetName[gSaveContext.itemLocations[rcObj.rc].get.rgID][gSaveContext.language]; } - if (status == RCSHOW_IDENTIFIED) { + if (!IsVisibleInCheckTracker(rcObj) && status == RCSHOW_IDENTIFIED && !mystery) { txt += fmt::format(" - {}", gSaveContext.checkTrackerData[rcObj.rc].price); } } else { diff --git a/soh/soh/Enhancements/randomizer/randomizer_check_tracker.h b/soh/soh/Enhancements/randomizer/randomizer_check_tracker.h index 216da367fc2..be1ae441c0d 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_check_tracker.h +++ b/soh/soh/Enhancements/randomizer/randomizer_check_tracker.h @@ -47,6 +47,7 @@ void DefaultCheckData(RandomizerCheck rc); void Teardown(); void UpdateAllOrdering(); bool IsVisibleInCheckTracker(RandomizerCheckObject rcObj); +bool IsCheckShuffled(RandomizerCheckObject check); void InitTrackerData(bool isDebug); RandomizerCheckArea GetCheckArea(); void UpdateCheck(uint32_t, RandomizerCheckTrackerData); diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index b61bb65cc83..518e9c1f321 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -84,6 +84,7 @@ GameInteractorSail* GameInteractorSail::Instance; #include "Enhancements/mods.h" #include "Enhancements/game-interactor/GameInteractor.h" +#include "Enhancements/randomizer/draw.h" #include // Resource Types/Factories @@ -2437,6 +2438,14 @@ extern "C" ItemObtainability Randomizer_GetItemObtainabilityFromRandomizerCheck( return OTRGlobals::Instance->gRandomizer->GetItemObtainabilityFromRandomizerCheck(randomizerCheck); } +extern "C" bool Randomizer_IsCheckShuffled(RandomizerCheck randomizerCheck) { + return CheckTracker::IsCheckShuffled(RandomizerCheckObjects::GetAllRCObjects().find(randomizerCheck)->second); +} + +extern "C" GetItemEntry GetItemMystery() { + return { ITEM_NONE_FE, 0, 0, 0, 0, 0, 0, ITEM_NONE_FE, 0, false, ITEM_FROM_NPC, ITEM_CATEGORY_JUNK, NULL, MOD_RANDOMIZER, (CustomDrawFunc)Randomizer_DrawMysteryItem }; +} + CustomMessage Randomizer_GetCustomGetItemMessage(Player* player) { s16 giid; if (player->getItemEntry.objectId != OBJECT_INVALID) { diff --git a/soh/soh/OTRGlobals.h b/soh/soh/OTRGlobals.h index 73cb58d9764..e0b5c7a3816 100644 --- a/soh/soh/OTRGlobals.h +++ b/soh/soh/OTRGlobals.h @@ -179,6 +179,8 @@ GetItemEntry Randomizer_GetItemFromActor(s16 actorId, s16 sceneNum, s16 actorPar GetItemEntry Randomizer_GetItemFromActorWithoutObtainabilityCheck(s16 actorId, s16 sceneNum, s16 actorParams, GetItemID ogId); GetItemEntry Randomizer_GetItemFromKnownCheck(RandomizerCheck randomizerCheck, GetItemID ogId); GetItemEntry Randomizer_GetItemFromKnownCheckWithoutObtainabilityCheck(RandomizerCheck randomizerCheck, GetItemID ogId); +bool Randomizer_IsCheckShuffled(RandomizerCheck check); +GetItemEntry GetItemMystery(); ItemObtainability Randomizer_GetItemObtainabilityFromRandomizerCheck(RandomizerCheck randomizerCheck); int CustomMessage_RetrieveIfExists(PlayState* play); void Overlay_DisplayText(float duration, const char* text); diff --git a/soh/soh/SohMenuBar.cpp b/soh/soh/SohMenuBar.cpp index c396de73893..35274e5ac5c 100644 --- a/soh/soh/SohMenuBar.cpp +++ b/soh/soh/SohMenuBar.cpp @@ -1972,6 +1972,11 @@ void DrawRandomizerMenu() { "Play unique fanfares when obtaining quest items " "(medallions/stones/songs). Note that these fanfares are longer than usual." ); + UIWidgets::PaddedEnhancementCheckbox("Mysterious Shuffled Items", CVAR_RANDOMIZER_ENHANCEMENT("MysteriousShuffle"), true, false); + UIWidgets::Tooltip( + "Displays a \"Mystery Item\" model in place of any freestanding/GS/shop items that were shuffled, " + "and replaces item names for them and scrubs and merchants, regardless of hint settings, " + "so you never know what you're getting."); ImGui::EndMenu(); } diff --git a/soh/src/code/z_en_item00.c b/soh/src/code/z_en_item00.c index db344d39e98..77281771605 100644 --- a/soh/src/code/z_en_item00.c +++ b/soh/src/code/z_en_item00.c @@ -1366,17 +1366,19 @@ void EnItem00_DrawCollectible(EnItem00* this, PlayState* play) { if (IS_RANDO && (this->getItemId != GI_NONE || this->actor.params == ITEM00_SMALL_KEY)) { RandomizerCheck randoCheck = Randomizer_GetCheckFromActor(this->actor.id, play->sceneNum, this->ogParams); + GetItemEntry giEntry = this->randoGiEntry; if (randoCheck != RC_UNKNOWN_CHECK) { - this->randoGiEntry = - Randomizer_GetItemFromKnownCheck(randoCheck, GI_NONE); - this->randoGiEntry.getItemFrom = ITEM_FROM_FREESTANDING; + this->randoGiEntry = Randomizer_GetItemFromKnownCheck(randoCheck, GI_NONE); + giEntry = (CVarGetInteger(CVAR_RANDOMIZER_ENHANCEMENT("MysteriousShuffle"), 0) && Randomizer_IsCheckShuffled(randoCheck)) + ? GetItemMystery() : this->randoGiEntry; + giEntry.getItemFrom = ITEM_FROM_FREESTANDING; } - - f32 mtxScale = 10.67f; + + f32 mtxScale = 16.0f; Matrix_Scale(mtxScale, mtxScale, mtxScale, MTXMODE_APPLY); - EnItem00_CustomItemsParticles(&this->actor, play, this->randoGiEntry); - GetItemEntry_Draw(play, this->randoGiEntry); + EnItem00_CustomItemsParticles(&this->actor, play, giEntry); + GetItemEntry_Draw(play, giEntry); } else if (this->actor.params == ITEM00_BOMBCHU) { OPEN_DISPS(play->state.gfxCtx); @@ -1460,17 +1462,19 @@ void EnItem00_DrawHeartPiece(EnItem00* this, PlayState* play) { if (IS_RANDO) { RandomizerCheck randoCheck = Randomizer_GetCheckFromActor(this->actor.id, play->sceneNum, this->ogParams); + GetItemEntry giEntry = this->randoGiEntry; if (randoCheck != RC_UNKNOWN_CHECK) { - this->randoGiEntry = - Randomizer_GetItemFromKnownCheck(randoCheck, GI_NONE); - this->randoGiEntry.getItemFrom = ITEM_FROM_FREESTANDING; + this->randoGiEntry = Randomizer_GetItemFromKnownCheck(randoCheck, GI_NONE); + giEntry = (CVarGetInteger(CVAR_RANDOMIZER_ENHANCEMENT("MysteriousShuffle"), 0) && Randomizer_IsCheckShuffled(randoCheck)) + ? GetItemMystery() : this->randoGiEntry; + giEntry.getItemFrom = ITEM_FROM_FREESTANDING; } f32 mtxScale = 16.0f; Matrix_Scale(mtxScale, mtxScale, mtxScale, MTXMODE_APPLY); - EnItem00_CustomItemsParticles(&this->actor, play, this->randoGiEntry); - GetItemEntry_Draw(play, this->randoGiEntry); + EnItem00_CustomItemsParticles(&this->actor, play, giEntry); + GetItemEntry_Draw(play, giEntry); } else { s32 pad; diff --git a/soh/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c b/soh/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c index 149c176c700..edab23ae808 100644 --- a/soh/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c +++ b/soh/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c @@ -2088,7 +2088,8 @@ void DemoEffect_DrawGetItem(Actor* thisx, PlayState* play) { return; } if (IS_RANDO && play->sceneNum == SCENE_JABU_JABU) { - GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(RC_BARINADE, RG_ZORA_SAPPHIRE); + GetItemEntry getItemEntry = (CVarGetInteger(CVAR_RANDOMIZER_ENHANCEMENT("MysteriousShuffle"), 0) && Randomizer_IsCheckShuffled(RC_BARINADE)) + ? GetItemMystery() : Randomizer_GetItemFromKnownCheck(RC_BARINADE, RG_ZORA_SAPPHIRE); this->getItem.drawId = getItemEntry.gid; func_8002EBCC(thisx, play, 0); func_8002ED80(thisx, play, 0); diff --git a/soh/src/overlays/actors/ovl_En_Ex_Item/z_en_ex_item.c b/soh/src/overlays/actors/ovl_En_Ex_Item/z_en_ex_item.c index a3a196e3141..b2d23984cce 100644 --- a/soh/src/overlays/actors/ovl_En_Ex_Item/z_en_ex_item.c +++ b/soh/src/overlays/actors/ovl_En_Ex_Item/z_en_ex_item.c @@ -515,14 +515,17 @@ void EnExItem_DrawItems(EnExItem* this, PlayState* play) { switch (this->type) { case EXITEM_BOMB_BAG_BOWLING: case EXITEM_BOMB_BAG_COUNTER: - randoGetItem = Randomizer_GetItemFromKnownCheck(RC_MARKET_BOMBCHU_BOWLING_FIRST_PRIZE, GI_BOMB_BAG_20); + randoGetItem = (CVarGetInteger(CVAR_RANDOMIZER_ENHANCEMENT("MysteriousShuffle"), 0) && Randomizer_IsCheckShuffled(RC_MARKET_BOMBCHU_BOWLING_FIRST_PRIZE)) + ? GetItemMystery() + : Randomizer_GetItemFromKnownCheck(RC_MARKET_BOMBCHU_BOWLING_FIRST_PRIZE, GI_BOMB_BAG_20); break; case EXITEM_BOMBCHUS_BOWLING: case EXITEM_BOMBCHUS_COUNTER: randoGetItem = Randomizer_GetItemFromKnownCheck(RC_MARKET_BOMBCHU_BOWLING_BOMBCHUS, GI_BOMBCHUS_10); break; case EXITEM_BULLET_BAG: - randoGetItem = Randomizer_GetItemFromKnownCheck(RC_LW_TARGET_IN_WOODS, GI_BULLET_BAG_50); + randoGetItem = (CVarGetInteger(CVAR_RANDOMIZER_ENHANCEMENT("MysteriousShuffle"), 0) && Randomizer_IsCheckShuffled(RC_LW_TARGET_IN_WOODS)) + ? GetItemMystery() : Randomizer_GetItemFromKnownCheck(RC_LW_TARGET_IN_WOODS, GI_BULLET_BAG_50); break; } @@ -540,8 +543,8 @@ void EnExItem_DrawHeartPiece(EnExItem* this, PlayState* play) { func_8002ED80(&this->actor, play, 0); if (IS_RANDO) { - GetItemEntry randoGetItem = - Randomizer_GetItemFromKnownCheck(RC_MARKET_BOMBCHU_BOWLING_SECOND_PRIZE, GI_HEART_PIECE); + GetItemEntry randoGetItem = (CVarGetInteger(CVAR_RANDOMIZER_ENHANCEMENT("MysteriousShuffle"), 0) && Randomizer_IsCheckShuffled(RC_MARKET_BOMBCHU_BOWLING_SECOND_PRIZE)) + ? GetItemMystery() : Randomizer_GetItemFromKnownCheck(RC_MARKET_BOMBCHU_BOWLING_SECOND_PRIZE, GI_HEART_PIECE); EnItem00_CustomItemsParticles(&this->actor, play, randoGetItem); GetItemEntry_Draw(play, randoGetItem); } else { diff --git a/soh/src/overlays/actors/ovl_En_GirlA/z_en_girla.c b/soh/src/overlays/actors/ovl_En_GirlA/z_en_girla.c index 11c29227fcd..0382735a3cd 100644 --- a/soh/src/overlays/actors/ovl_En_GirlA/z_en_girla.c +++ b/soh/src/overlays/actors/ovl_En_GirlA/z_en_girla.c @@ -1286,8 +1286,8 @@ void EnGirlA_InitializeItemAction(EnGirlA* this, PlayState* play) { this->basePrice = shopItemIdentity.itemPrice; this->giDrawId = getItemEntry.gid; - // Correct the rotation for spiritual stones - if (getItemEntry.getItemId >= RG_KOKIRI_EMERALD && getItemEntry.getItemId <= RG_ZORA_SAPPHIRE) { + // Correct the rotation for spiritual stones, but only if mysterious shuffle isn't on, else it's obvious what's there in shops + if (!CVarGetInteger(CVAR_RANDOMIZER_ENHANCEMENT("MysteriousShuffle"), 0) && (getItemEntry.getItemId >= RG_KOKIRI_EMERALD && getItemEntry.getItemId <= RG_ZORA_SAPPHIRE)) { this->actor.shape.rot.y = this->actor.shape.rot.y + 20000; } } @@ -1332,7 +1332,8 @@ void EnGirlA_Draw(Actor* thisx, PlayState* play) { if (this->actor.params == SI_RANDOMIZED_ITEM) { ShopItemIdentity shopItemIdentity = Randomizer_IdentifyShopItem(play->sceneNum, this->randoSlotIndex); - GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheckWithoutObtainabilityCheck(shopItemIdentity.randomizerCheck, shopItemIdentity.ogItemId); + GetItemEntry getItemEntry = (CVarGetInteger(CVAR_RANDOMIZER_ENHANCEMENT("MysteriousShuffle"), 0) && this->actor.params == SI_RANDOMIZED_ITEM) ? GetItemMystery() : + Randomizer_GetItemFromKnownCheckWithoutObtainabilityCheck(shopItemIdentity.randomizerCheck, shopItemIdentity.ogItemId); EnItem00_CustomItemsParticles(&this->actor, play, getItemEntry); GetItemEntry_Draw(play, getItemEntry); diff --git a/soh/src/overlays/actors/ovl_En_Si/z_en_si.c b/soh/src/overlays/actors/ovl_En_Si/z_en_si.c index 185a39c515d..98e8f411633 100644 --- a/soh/src/overlays/actors/ovl_En_Si/z_en_si.c +++ b/soh/src/overlays/actors/ovl_En_Si/z_en_si.c @@ -214,7 +214,8 @@ void EnSi_Draw(Actor* thisx, PlayState* play) { if (!IS_RANDO) { GetItem_Draw(play, GID_SKULL_TOKEN_2); } else { - getItem = Randomizer_GetItemFromActor(this->actor.id, play->sceneNum, this->actor.params, GI_SKULL_TOKEN); + RandomizerCheck check = Randomizer_GetCheckFromActor(this->actor.id, play->sceneNum, this->actor.params); + getItem = (CVarGetInteger(CVAR_RANDOMIZER_ENHANCEMENT("MysteriousShuffle"), 0) && Randomizer_IsCheckShuffled(check)) ? GetItemMystery() : Randomizer_GetItemFromKnownCheck(check, GI_SKULL_TOKEN); EnItem00_CustomItemsParticles(&this->actor, play, getItem); if (getItem.itemId != ITEM_SKULL_TOKEN) { f32 mtxScale = 1.5f; diff --git a/soh/src/overlays/actors/ovl_Item_B_Heart/z_item_b_heart.c b/soh/src/overlays/actors/ovl_Item_B_Heart/z_item_b_heart.c index abb65c1914e..bea2f608fc3 100644 --- a/soh/src/overlays/actors/ovl_Item_B_Heart/z_item_b_heart.c +++ b/soh/src/overlays/actors/ovl_Item_B_Heart/z_item_b_heart.c @@ -99,8 +99,8 @@ void ItemBHeart_Draw(Actor* thisx, PlayState* play) { } if (IS_RANDO) { - GetItemEntry_Draw(play, Randomizer_GetItemFromActor(this->actor.id, - play->sceneNum,this->actor.params, GI_HEART_CONTAINER_2)); + RandomizerCheck check = Randomizer_GetCheckFromActor(this->actor.id, play->sceneNum, this->actor.params); + GetItemEntry_Draw(play, (CVarGetInteger(CVAR_RANDOMIZER_ENHANCEMENT("MysteriousShuffle"), 0) && Randomizer_IsCheckShuffled(check)) ? GetItemMystery() : Randomizer_GetItemFromKnownCheck(check, GI_HEART_CONTAINER_2)); } else { if (flag) { Gfx_SetupDL_25Xlu(play->state.gfxCtx); diff --git a/soh/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c b/soh/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c index b12d7b4b034..fb93702aba2 100644 --- a/soh/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c +++ b/soh/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c @@ -230,7 +230,8 @@ void ItemEtcetera_DrawThroughLens(Actor* thisx, PlayState* play) { func_8002ED80(&this->actor, play, 0); if(IS_RANDO && play->sceneNum == SCENE_TREASURE_BOX_SHOP) { - GetItemEntry randoGetItem = GetChestGameRandoGetItem(this->actor.room, this->giDrawId, play); + RandomizerCheck check = RC_MAX; + GetItemEntry randoGetItem = GetChestGameRandoGetItem(this->actor.room, this->giDrawId, play); //TODO Rando: add mysterious shuffle when chest minigame keys get shuffled EnItem00_CustomItemsParticles(&this->actor, play, randoGetItem); if (randoGetItem.itemId != ITEM_NONE) { GetItemEntry_Draw(play, randoGetItem); @@ -249,9 +250,9 @@ void ItemEtcetera_Draw(Actor* thisx, PlayState* play) { if (IS_RANDO) { GetItemEntry randoGetItem = (GetItemEntry)GET_ITEM_NONE; if (type == ITEM_ETC_ARROW_FIRE) { - randoGetItem = Randomizer_GetItemFromKnownCheck(RC_LH_SUN, GI_ARROW_FIRE); + randoGetItem = (CVarGetInteger(CVAR_RANDOMIZER_ENHANCEMENT("MysteriousShuffle"), 0) && Randomizer_IsCheckShuffled(RC_LH_SUN)) ? GetItemMystery() : Randomizer_GetItemFromKnownCheck(RC_LH_SUN, GI_ARROW_FIRE); } else if (type == ITEM_ETC_LETTER) { - randoGetItem = Randomizer_GetItemFromKnownCheck(RC_LH_UNDERWATER_ITEM, GI_LETTER_RUTO); + randoGetItem = (CVarGetInteger(CVAR_RANDOMIZER_ENHANCEMENT("MysteriousShuffle"), 0) && Randomizer_IsCheckShuffled(RC_LH_UNDERWATER_ITEM)) ? GetItemMystery() : Randomizer_GetItemFromKnownCheck(RC_LH_UNDERWATER_ITEM, GI_LETTER_RUTO); } EnItem00_CustomItemsParticles(&this->actor, play, randoGetItem); diff --git a/soh/src/overlays/actors/ovl_Item_Ocarina/z_item_ocarina.c b/soh/src/overlays/actors/ovl_Item_Ocarina/z_item_ocarina.c index a9cd3644645..c1a0d67ecc8 100644 --- a/soh/src/overlays/actors/ovl_Item_Ocarina/z_item_ocarina.c +++ b/soh/src/overlays/actors/ovl_Item_Ocarina/z_item_ocarina.c @@ -215,7 +215,7 @@ void ItemOcarina_Draw(Actor* thisx, PlayState* play) { func_8002ED80(thisx, play, 0); if (IS_RANDO) { - GetItemEntry randoGetItem = Randomizer_GetItemFromKnownCheck(RC_HF_OCARINA_OF_TIME_ITEM, GI_OCARINA_OOT); + GetItemEntry randoGetItem = (CVarGetInteger(CVAR_RANDOMIZER_ENHANCEMENT("MysteriousShuffle"), 0) && Randomizer_IsCheckShuffled(RC_HF_OCARINA_OF_TIME_ITEM)) ? GetItemMystery() : Randomizer_GetItemFromKnownCheck(RC_HF_OCARINA_OF_TIME_ITEM, GI_OCARINA_OOT); EnItem00_CustomItemsParticles(&this->actor, play, randoGetItem); GetItemEntry_Draw(play, randoGetItem); return; From 8d3902a256cb07b9f8e65e9ba90b3f0c20c89a45 Mon Sep 17 00:00:00 2001 From: Malkierian Date: Mon, 6 May 2024 17:27:35 -0700 Subject: [PATCH 21/59] Remove unnecessary and redundant checks and references. (#4111) Stop passing checksByArea to functions in the same namespace. Only get value of `HideFilteredAreas` once per frame. Gate area and check evaluations behind checks being visible and search filter size greater than 0. Proper function capitalization. --- .../randomizer/randomizer_check_tracker.cpp | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp b/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp index a53b838f302..aca75ef93dc 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp @@ -133,8 +133,8 @@ RandomizerCheckArea previousArea = RCAREA_INVALID; RandomizerCheckArea currentArea = RCAREA_INVALID; OSContPad* trackerButtonsPressed; -bool passesTextFilter(ImGuiTextFilter& checkSearch, const RandomizerCheckObject rcObject); -bool shouldHideArea(ImGuiTextFilter& checkSearch, std::map> checksByArea, const RandomizerCheckArea rcArea); +bool ShouldShowCheck(RandomizerCheckObject rcObject); +bool ShouldHideArea(RandomizerCheckArea rcArea); void BeginFloatWindows(std::string UniqueName, bool& open, ImGuiWindowFlags flags = 0); bool CompareChecks(RandomizerCheckObject, RandomizerCheckObject); bool CheckByArea(RandomizerCheckArea); @@ -202,6 +202,7 @@ Color_RGBA8 Color_Saved_Extra = { 0, 185, 0, 255 }; // Green std::vector buttons = { BTN_A, BTN_B, BTN_CUP, BTN_CDOWN, BTN_CLEFT, BTN_CRIGHT, BTN_L, BTN_Z, BTN_R, BTN_START, BTN_DUP, BTN_DDOWN, BTN_DLEFT, BTN_DRIGHT }; +static ImGuiTextFilter checkSearch; void DefaultCheckData(RandomizerCheck rc) { gSaveContext.checkTrackerData[rc].status = RCSHOW_UNCHECKED; @@ -930,9 +931,9 @@ void CheckTrackerWindow::DrawElement() { optCollapseAll = true; } ImGui::SameLine(); - static ImGuiTextFilter checkSearch; if (ImGui::Button("Clear")) { checkSearch.Clear(); + doAreaScroll = true; } UIWidgets::Tooltip("Clear the search field"); checkSearch.Draw(); @@ -970,6 +971,8 @@ void CheckTrackerWindow::DrawElement() { Color_RGBA8 extraColor; std::string stemp; + bool shouldHideFilteredAreas = CVarGetInteger(CVAR_TRACKER_CHECK("HideFilteredAreas"), 1); + for (auto& [rcArea, objs] : checksByArea) { RandomizerCheckArea thisArea = currentArea; @@ -983,7 +986,7 @@ void CheckTrackerWindow::DrawElement() { previousShowHidden = showHidden; doAreaScroll = true; } - if (shouldHideArea(checkSearch, checksByArea, rcArea) || + if ((shouldHideFilteredAreas && ShouldHideArea(rcArea)) || (!showHidden && ((hideComplete && thisAreaFullyChecked) || (hideIncomplete && !thisAreaFullyChecked))) ) { doDraw = false; @@ -1046,7 +1049,8 @@ void CheckTrackerWindow::DrawElement() { } for (auto rcObject : objs) { - if (IsVisibleInCheckTracker(rcObject) && passesTextFilter(checkSearch, rcObject) && doDraw && + if (ShouldShowCheck(rcObject) && + doDraw && isThisAreaSpoiled) { DrawLocation(rcObject); } @@ -1067,14 +1071,12 @@ void CheckTrackerWindow::DrawElement() { } } -bool shouldHideArea(ImGuiTextFilter& checkSearch, std::map> checksByArea, RandomizerCheckArea rcArea) { - bool shouldHideFilteredAreas = CVarGetInteger(CVAR_TRACKER_CHECK("HideFilteredAreas"), 1); - if (!shouldHideFilteredAreas) { +bool ShouldHideArea(RandomizerCheckArea rcArea) { + if (checkSearch.Filters.Size == 0 || checkSearch.PassFilter(RandomizerCheckObjects::GetRCAreaName(rcArea).c_str())) { return false; } - for (auto check : checksByArea[rcArea]) { - if (IsVisibleInCheckTracker(check) && passesTextFilter(checkSearch, check)) { + if (ShouldShowCheck(check)) { return false; } } @@ -1082,10 +1084,12 @@ bool shouldHideArea(ImGuiTextFilter& checkSearch, std::map Date: Mon, 6 May 2024 22:08:11 -0400 Subject: [PATCH 22/59] support lus thread_pool changes (#4127) --- libultraship | 2 +- soh/soh/SaveManager.cpp | 4 ++-- soh/soh/SaveManager.h | 5 ++++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/libultraship b/libultraship index a5d84b29429..c2555d1cca2 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit a5d84b29429dcd9b32fb1d8b169b6dd269e6c979 +Subproject commit c2555d1cca2b7921c5b6790bbf0f6e66fe0433fb diff --git a/soh/soh/SaveManager.cpp b/soh/soh/SaveManager.cpp index 0a96f9f1959..b6fd0cb07c2 100644 --- a/soh/soh/SaveManager.cpp +++ b/soh/soh/SaveManager.cpp @@ -1000,7 +1000,7 @@ void SaveManager::SaveSection(int fileNum, int sectionID, bool threaded) { auto saveContext = new SaveContext; memcpy(saveContext, &gSaveContext, sizeof(gSaveContext)); if (threaded) { - smThreadPool->push_task_back(&SaveManager::SaveFileThreaded, this, fileNum, saveContext, sectionID); + smThreadPool->detach_task(std::bind(&SaveManager::SaveFileThreaded, this, fileNum, saveContext, sectionID)); } else { SaveFileThreaded(fileNum, saveContext, sectionID); } @@ -1091,7 +1091,7 @@ void SaveManager::LoadFile(int fileNum) { void SaveManager::ThreadPoolWait() { if (smThreadPool) { - smThreadPool->wait_for_tasks(); + smThreadPool->wait(); } } diff --git a/soh/soh/SaveManager.h b/soh/soh/SaveManager.h index 310ecda7d8e..817fc6fbfb2 100644 --- a/soh/soh/SaveManager.h +++ b/soh/soh/SaveManager.h @@ -39,7 +39,10 @@ typedef struct { #include #include #include -#include "thread-pool/BS_thread_pool.hpp" + +#define BS_THREAD_POOL_ENABLE_PRIORITY +#define BS_THREAD_POOL_ENABLE_PAUSE +#include #include "z64save.h" From 0976198f2c4c47ba35ce4a2886085a7bc4c5c2bc Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Wed, 8 May 2024 00:13:47 -0400 Subject: [PATCH 23/59] get soh working with latest lus (#4132) --- libultraship | 2 +- soh/include/functions.h | 2 - soh/soh/Enhancements/debugger/colViewer.cpp | 6 +- soh/soh/stubs.c | 93 +-------------------- 4 files changed, 5 insertions(+), 98 deletions(-) diff --git a/libultraship b/libultraship index c2555d1cca2..97b11c96011 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit c2555d1cca2b7921c5b6790bbf0f6e66fe0433fb +Subproject commit 97b11c9601178ff02e141b7398f5d50ddf91fdc4 diff --git a/soh/include/functions.h b/soh/include/functions.h index 08179b341a7..b9e1f69819f 100644 --- a/soh/include/functions.h +++ b/soh/include/functions.h @@ -2354,7 +2354,6 @@ s32 __osCheckPackId(OSPfs* pfs, __OSPackId* check); s32 __osGetId(OSPfs* pfs); s32 __osCheckId(OSPfs* pfs); s32 __osPfsRWInode(OSPfs* pfs, __OSInode* inode, u8 flag, u8 bank); -void guMtxL2F(MtxF* m1, Mtx* m2); s32 osPfsFindFile(OSPfs* pfs, u16 companyCode, u32 gameCode, u8* gameName, u8* extName, s32* fileNo); s32 osAfterPreNMI(void); s32 osContStartQuery(OSMesgQueue* mq); @@ -2408,7 +2407,6 @@ u32 __osSpGetStatus(void); void __osSpSetStatus(u32 status); void osWritebackDCacheAll(void); OSThread* __osGetCurrFaultedThread(void); -void guMtxF2L(MtxF* m1, Mtx* m2); // ? __d_to_ll(?); // ? __f_to_ll(?); // ? __d_to_ull(?); diff --git a/soh/soh/Enhancements/debugger/colViewer.cpp b/soh/soh/Enhancements/debugger/colViewer.cpp index 159e27128f0..da6e7363030 100644 --- a/soh/soh/Enhancements/debugger/colViewer.cpp +++ b/soh/soh/Enhancements/debugger/colViewer.cpp @@ -445,7 +445,7 @@ void DrawBgActorCollision() { bg.curTransform.scale.z, bg.curTransform.rot.x, bg.curTransform.rot.y, bg.curTransform.rot.z, bg.curTransform.pos.x, bg.curTransform.pos.y, bg.curTransform.pos.z); - guMtxF2L(&mf, &m); + // guMtxF2L(mf, &m); mtxDl.push_back(m); dl.push_back(gsSPMatrix(&mtxDl.back(), G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_PUSH)); @@ -493,7 +493,7 @@ void DrawColCheckList(std::vector& dl, Collider** objects, int32_t count) { SkinMatrix_SetScale(&ms, radius / 128.0f, radius / 128.0f, radius / 128.0f); MtxF dest; SkinMatrix_MtxFMtxFMult(&mf, &ms, &dest); - guMtxF2L(&dest, &m); + // guMtxF2L(&dest, &m); mtxDl.push_back(m); dl.push_back(gsSPMatrix(&mtxDl.back(), G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_PUSH)); @@ -512,7 +512,7 @@ void DrawColCheckList(std::vector& dl, Collider** objects, int32_t count) { SkinMatrix_SetScale(&ms, radius / 128.0f, cyl->dim.height / 128.0f, radius / 128.0f); MtxF dest; SkinMatrix_MtxFMtxFMult(&mt, &ms, &dest); - guMtxF2L(&dest, &m); + // guMtxF2L(&dest, &m); mtxDl.push_back(m); dl.push_back(gsSPMatrix(&mtxDl.back(), G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_PUSH)); diff --git a/soh/soh/stubs.c b/soh/soh/stubs.c index a162a7ac55a..63340734efe 100644 --- a/soh/soh/stubs.c +++ b/soh/soh/stubs.c @@ -1,4 +1,5 @@ #include +#include #include #include #include "z64.h" @@ -31,18 +32,6 @@ f32 qNaN0x10000 = 0x7F810000; // __gSPTextureRectangle(pkt, xl, yl, xh, yh, tile, s, t, dsdx, dtdy); //} -s32 osJamMesg(OSMesgQueue* mq, OSMesg msg, s32 flag) -{ -} - -void osSetEventMesg(OSEvent e, OSMesgQueue* mq, OSMesg msg) -{ -} - -void osViSetEvent(OSMesgQueue* mq, OSMesg msg, u32 retraceCount) -{ -} - OSId osGetThreadId(OSThread* thread) { } @@ -55,31 +44,11 @@ void osSetThreadPri(OSThread* thread, OSPri pri) { } -s32 osSetTimer(OSTimer* timer, OSTime countdown, OSTime interval, OSMesgQueue* mq, OSMesg msg) -{ - -} - void osCreatePiManager(OSPri pri, OSMesgQueue* cmdQ, OSMesg* cmdBuf, s32 cmdMsgCnt) { } -void osCreateViManager(OSPri pri) -{ - -} - -s32 osMotorInit(OSMesgQueue* ctrlrqueue, OSPfs* pfs, s32 channel) -{ - return 0; -} - -u32 osAiGetLength(void) -{ - -} - s32 osPfsFreeBlocks(OSPfs* pfs, s32* leftoverBytes) { @@ -130,16 +99,6 @@ s32 osPfsAllocateFile(OSPfs* pfs, u16 companyCode, u32 gameCode, u8* gameName, u } -s32 osAiSetNextBuffer(void* buf, size_t size) -{ - -} - -s32 __osMotorAccess(OSPfs* pfs, u32 vibrate) -{ - -} - OSIntMask osSetIntMask(OSIntMask a) { return 0; @@ -200,16 +159,6 @@ void osContGetQuery(OSContStatus* data) } -void osViSwapBuffer(void* vaddr) -{ - -} - -void* osViGetNextFramebuffer() -{ - -} - u32 __osGetFpcCsr() { return 0; @@ -240,11 +189,6 @@ OSThread* __osGetCurrFaultedThread(void) } -void osCartRomInit() -{ - -} - u32 osMemSize = 1024 * 1024 * 1024; void Audio_osInvalDCache(void* buf, s32 size) @@ -263,11 +207,6 @@ s32 osAiSetFrequency(u32 freq) return 1; } -s32 osEPiStartDma(OSPiHandle* handle, OSIoMesg* mb, s32 direction) -{ - -} - void osInvalDCache(void* vaddr, s32 nbytes) { @@ -313,31 +252,6 @@ OSPiHandle* osDriveRomInit() } -void osViSetMode(OSViMode* mode) -{ - -} - -void osViBlack(u8 active) -{ - -} - -void osViSetYScale(f32 scale) -{ - -} - -void osViSetXScale(f32 value) -{ - -} - -void osViSetSpecialFeatures(u32 func) -{ - -} - void __osInitialize_common(void) { @@ -390,11 +304,6 @@ s32 osEPiReadIo(OSPiHandle* handle, u32 devAddr, u32* data) return 0; } -u32* osViGetCurrentFramebuffer(void) -{ - -} - void osSpTaskYield(void) { } From 3c87c1ec98113d4da11c5d08d5a208ab982ba6f1 Mon Sep 17 00:00:00 2001 From: Kenix3 Date: Wed, 8 May 2024 02:25:50 -0400 Subject: [PATCH 24/59] Lus window bump (#4131) --- libultraship | 2 +- soh/soh/OTRGlobals.cpp | 27 ++++++++++++++++++--------- soh/soh/SohMenuBar.cpp | 1 + soh/src/code/graph.c | 6 ++++-- 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/libultraship b/libultraship index 97b11c96011..61e304d21fe 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit 97b11c9601178ff02e141b7398f5d50ddf91fdc4 +Subproject commit 61e304d21fe00b5b1de49998b16c510615ad7b44 diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 518e9c1f321..12f94e5fd31 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -7,6 +7,7 @@ #include #include +#include "graphic/Fast3D/Fast3dWindow.h" #include #include #include @@ -1253,11 +1254,6 @@ extern "C" uint64_t GetUnixTimestamp() { return (uint64_t)millis.count(); } -// C->C++ Bridge -extern "C" void Graph_ProcessFrame(void (*run_one_game_iter)(void)) { - OTRGlobals::Instance->context->GetWindow()->MainLoop(run_one_game_iter); -} - extern bool ToggleAltAssetsAtEndOfFrame; extern "C" void Graph_StartFrame() { @@ -1381,6 +1377,7 @@ extern "C" void Graph_ProcessGfxCommands(Gfx* commands) { static int time; int fps = target_fps; int original_fps = 60 / R_UPDATE_RATE; + auto wnd = std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()); if (target_fps == 20 || original_fps > target_fps) { fps = original_fps; @@ -1404,10 +1401,12 @@ extern "C" void Graph_ProcessGfxCommands(Gfx* commands) { time -= fps; - OTRGlobals::Instance->context->GetWindow()->SetTargetFps(fps); + if (wnd != nullptr) { + wnd->SetTargetFps(fps); + } int threshold = CVarGetInteger(CVAR_SETTING("ExtraLatencyThreshold"), 80); - OTRGlobals::Instance->context->GetWindow()->SetMaximumFrameLatency(threshold > 0 && target_fps >= threshold ? 2 : 1); + wnd->SetMaximumFrameLatency(threshold > 0 && target_fps >= threshold ? 2 : 1); RunCommands(commands, mtx_replacements); @@ -1440,11 +1439,21 @@ extern "C" void Graph_ProcessGfxCommands(Gfx* commands) { float divisor_num = 0.0f; extern "C" void OTRGetPixelDepthPrepare(float x, float y) { - OTRGlobals::Instance->context->GetWindow()->GetPixelDepthPrepare(x, y); + auto wnd = std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()); + if (wnd == nullptr) { + return; + } + + wnd->GetPixelDepthPrepare(x, y); } extern "C" uint16_t OTRGetPixelDepth(float x, float y) { - return OTRGlobals::Instance->context->GetWindow()->GetPixelDepth(x, y); + auto wnd = std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()); + if (wnd == nullptr) { + return 0; + } + + return wnd->GetPixelDepth(x, y); } extern "C" uint32_t ResourceMgr_GetNumGameVersions() { diff --git a/soh/soh/SohMenuBar.cpp b/soh/soh/SohMenuBar.cpp index 35274e5ac5c..f60983c59fc 100644 --- a/soh/soh/SohMenuBar.cpp +++ b/soh/soh/SohMenuBar.cpp @@ -8,6 +8,7 @@ #include #include "UIWidgets.hpp" #include "include/z64audio.h" +#include "graphic/Fast3D/gfx_rendering_api.h" #include "OTRGlobals.h" #include "z64.h" #include "Enhancements/game-interactor/GameInteractor.h" diff --git a/soh/src/code/graph.c b/soh/src/code/graph.c index f5d620e72eb..db0e8bca311 100644 --- a/soh/src/code/graph.c +++ b/soh/src/code/graph.c @@ -10,6 +10,7 @@ #include "soh/Enhancements/debugger/valueViewer.h" #include "soh/Enhancements/gameconsole.h" #include "soh/OTRGlobals.h" +#include "libultraship/bridge.h" #define GFXPOOL_HEAD_MAGIC 0x1234 #define GFXPOOL_TAIL_MAGIC 0x5678 @@ -541,8 +542,9 @@ static void RunFrame() } void Graph_ThreadEntry(void* arg0) { - - Graph_ProcessFrame(RunFrame); + while (WindowIsRunning()) { + RunFrame(); + } } void* Graph_Alloc(GraphicsContext* gfxCtx, size_t size) { From 22c9d53985dbee674b06a6241f1c3a29b6a89c23 Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Wed, 8 May 2024 11:23:43 -0400 Subject: [PATCH 25/59] bump lus (gfx debugger fix, stormlib optimizations) (#4135) --- libultraship | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libultraship b/libultraship index 61e304d21fe..878efcc2670 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit 61e304d21fe00b5b1de49998b16c510615ad7b44 +Subproject commit 878efcc26701f1779e06389a6c6ca8df7aef64da From 1231b8f9fa71ddf681b0f5599f2cf8d127c4546e Mon Sep 17 00:00:00 2001 From: Lywx Date: Wed, 8 May 2024 17:30:22 -0600 Subject: [PATCH 26/59] Fixed macos/ios errors (#4138) --- soh/CMakeLists.txt | 1 + soh/src/overlays/actors/ovl_player_actor/z_player.c | 2 +- soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.c | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/soh/CMakeLists.txt b/soh/CMakeLists.txt index f8ee476b86b..3f086bcac64 100644 --- a/soh/CMakeLists.txt +++ b/soh/CMakeLists.txt @@ -547,6 +547,7 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|AppleClang") -Wno-parentheses -Wno-narrowing -Wno-missing-braces + -Wno-int-conversion $<$: -Werror-implicit-function-declaration -Wno-incompatible-pointer-types diff --git a/soh/src/overlays/actors/ovl_player_actor/z_player.c b/soh/src/overlays/actors/ovl_player_actor/z_player.c index f1dd52d6e17..145da2f999c 100644 --- a/soh/src/overlays/actors/ovl_player_actor/z_player.c +++ b/soh/src/overlays/actors/ovl_player_actor/z_player.c @@ -6266,7 +6266,7 @@ s32 func_8083D12C(PlayState* play, Player* this, Input* arg2) { func_80832340(play, this); // Skip take breath animation on surface if Link didn't grab an item while underwater and the setting is enabled if (CVarGetInteger(CVAR_ENHANCEMENT("SkipSwimDeepEndAnim"), 0) && !(this->stateFlags1 & PLAYER_STATE1_ITEM_OVER_HEAD)) { - auto lastAnimFrame = Animation_GetLastFrame(&gPlayerAnim_link_swimer_swim_deep_end); + int lastAnimFrame = Animation_GetLastFrame(&gPlayerAnim_link_swimer_swim_deep_end); LinkAnimation_Change(play, &this->skelAnime, &gPlayerAnim_link_swimer_swim_deep_end, 1.0f, lastAnimFrame, lastAnimFrame, ANIMMODE_ONCE, -6.0f); } else { diff --git a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.c b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.c index 6cc02aa034f..83b734156b7 100644 --- a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.c +++ b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.c @@ -141,7 +141,7 @@ static Vtx sCycleAButtonVtx[] = { }; // Track animation timers for each inventory slot -static sSlotCycleActiveAnimTimer[24] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +static int sSlotCycleActiveAnimTimer[24] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; // Renders a left and/or right item for any item slot that can support cycling void KaleidoScope_DrawItemCycleExtras(PlayState* play, u8 slot, u8 canCycle, u8 leftItem, u8 rightItem) { From cbeec006ecb4eeb34017282a4dfc5957a9aee642 Mon Sep 17 00:00:00 2001 From: Archez Date: Thu, 9 May 2024 00:32:29 -0400 Subject: [PATCH 27/59] Fix syotes scene path to use shared (#4136) --- .../{nonmq => shared}/syotes_scene/syotes_room_0 | Bin 1 file changed, 0 insertions(+), 0 deletions(-) rename soh/assets/custom/scenes/{nonmq => shared}/syotes_scene/syotes_room_0 (100%) diff --git a/soh/assets/custom/scenes/nonmq/syotes_scene/syotes_room_0 b/soh/assets/custom/scenes/shared/syotes_scene/syotes_room_0 similarity index 100% rename from soh/assets/custom/scenes/nonmq/syotes_scene/syotes_room_0 rename to soh/assets/custom/scenes/shared/syotes_scene/syotes_room_0 From 47b690fb1e3cfbd5dad5cb948c46ea72794c18a7 Mon Sep 17 00:00:00 2001 From: Archez Date: Thu, 9 May 2024 01:26:58 -0400 Subject: [PATCH 28/59] Bump LUS and restore guMtx in collision viewer (#4137) --- libultraship | 2 +- soh/soh/Enhancements/debugger/colViewer.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libultraship b/libultraship index 878efcc2670..0da318c0f4e 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit 878efcc26701f1779e06389a6c6ca8df7aef64da +Subproject commit 0da318c0f4e431313565cad546fc469b8e850388 diff --git a/soh/soh/Enhancements/debugger/colViewer.cpp b/soh/soh/Enhancements/debugger/colViewer.cpp index da6e7363030..3b5b7aa4758 100644 --- a/soh/soh/Enhancements/debugger/colViewer.cpp +++ b/soh/soh/Enhancements/debugger/colViewer.cpp @@ -445,7 +445,7 @@ void DrawBgActorCollision() { bg.curTransform.scale.z, bg.curTransform.rot.x, bg.curTransform.rot.y, bg.curTransform.rot.z, bg.curTransform.pos.x, bg.curTransform.pos.y, bg.curTransform.pos.z); - // guMtxF2L(mf, &m); + guMtxF2L(mf.mf, &m); mtxDl.push_back(m); dl.push_back(gsSPMatrix(&mtxDl.back(), G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_PUSH)); @@ -493,7 +493,7 @@ void DrawColCheckList(std::vector& dl, Collider** objects, int32_t count) { SkinMatrix_SetScale(&ms, radius / 128.0f, radius / 128.0f, radius / 128.0f); MtxF dest; SkinMatrix_MtxFMtxFMult(&mf, &ms, &dest); - // guMtxF2L(&dest, &m); + guMtxF2L(dest.mf, &m); mtxDl.push_back(m); dl.push_back(gsSPMatrix(&mtxDl.back(), G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_PUSH)); @@ -512,7 +512,7 @@ void DrawColCheckList(std::vector& dl, Collider** objects, int32_t count) { SkinMatrix_SetScale(&ms, radius / 128.0f, cyl->dim.height / 128.0f, radius / 128.0f); MtxF dest; SkinMatrix_MtxFMtxFMult(&mt, &ms, &dest); - // guMtxF2L(&dest, &m); + guMtxF2L(dest.mf, &m); mtxDl.push_back(m); dl.push_back(gsSPMatrix(&mtxDl.back(), G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_PUSH)); From 3f67fed073f7848aadac96a99ace85d7d8f5db5b Mon Sep 17 00:00:00 2001 From: Archez Date: Thu, 9 May 2024 21:39:13 -0400 Subject: [PATCH 29/59] Fix some memory leaks with WrappedText and LoadArrayByNameAsVec3s (#4144) * avoid memory leaks with WrappedText * avoid memory leak with LoadArrayByNameAsVec3s --- .../Enhancements/debugger/debugSaveEditor.cpp | 2 +- soh/soh/OTRGlobals.cpp | 1 + soh/soh/UIWidgets.cpp | 16 ++++++++-------- soh/soh/UIWidgets.hpp | 4 ++-- soh/src/code/z_player_lib.c | 2 ++ 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/soh/soh/Enhancements/debugger/debugSaveEditor.cpp b/soh/soh/Enhancements/debugger/debugSaveEditor.cpp index 9af4eadb7e9..91eab6db5e0 100644 --- a/soh/soh/Enhancements/debugger/debugSaveEditor.cpp +++ b/soh/soh/Enhancements/debugger/debugSaveEditor.cpp @@ -782,7 +782,7 @@ void DrawFlagTableArray16(const FlagTable& flagTable, uint16_t row, uint16_t& fl ImGui::PopStyleColor(); if (ImGui::IsItemHovered() && hasDescription) { ImGui::BeginTooltip(); - ImGui::Text("%s", UIWidgets::WrappedText(flagTable.flagDescriptions.at(row * 16 + flagIndex), 60)); + ImGui::Text("%s", UIWidgets::WrappedText(flagTable.flagDescriptions.at(row * 16 + flagIndex), 60).c_str()); ImGui::EndTooltip(); } ImGui::PopID(); diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 64d70da8806..bb45fdba75c 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -1735,6 +1735,7 @@ extern "C" char* ResourceMgr_LoadArrayByName(const char* path) return (char*)res->Scalars.data(); } +// Return of LoadArrayByNameAsVec3s must be freed by the caller extern "C" char* ResourceMgr_LoadArrayByNameAsVec3s(const char* path) { auto res = std::static_pointer_cast(GetResourceByNameHandlingMQ(path)); diff --git a/soh/soh/UIWidgets.cpp b/soh/soh/UIWidgets.cpp index 15bb088a357..06eaa33cd21 100644 --- a/soh/soh/UIWidgets.cpp +++ b/soh/soh/UIWidgets.cpp @@ -21,7 +21,7 @@ namespace UIWidgets { // Automatically adds newlines to break up text longer than a specified number of characters // Manually included newlines will still be respected and reset the line length // If line is midword when it hits the limit, text should break at the last encountered space - char* WrappedText(const char* text, unsigned int charactersPerLine) { + std::string WrappedText(const char* text, unsigned int charactersPerLine) { std::string newText(text); const size_t tipLength = newText.length(); int lastSpace = -1; @@ -43,17 +43,17 @@ namespace UIWidgets { currentLineLength++; } - return strdup(newText.c_str()); + return newText; } - char* WrappedText(const std::string& text, unsigned int charactersPerLine) { + std::string WrappedText(const std::string& text, unsigned int charactersPerLine) { return WrappedText(text.c_str(), charactersPerLine); } void SetLastItemHoverText(const std::string& text) { if (ImGui::IsItemHovered()) { ImGui::BeginTooltip(); - ImGui::Text("%s", WrappedText(text, 60)); + ImGui::Text("%s", WrappedText(text, 60).c_str()); ImGui::EndTooltip(); } } @@ -61,7 +61,7 @@ namespace UIWidgets { void SetLastItemHoverText(const char* text) { if (ImGui::IsItemHovered()) { ImGui::BeginTooltip(); - ImGui::Text("%s", WrappedText(text, 60)); + ImGui::Text("%s", WrappedText(text, 60).c_str()); ImGui::EndTooltip(); } } @@ -72,7 +72,7 @@ namespace UIWidgets { ImGui::TextColored(ImVec4(0.7f, 0.7f, 0.7f, 1.0f), "?"); if (ImGui::IsItemHovered()) { ImGui::BeginTooltip(); - ImGui::Text("%s", WrappedText(text, 60)); + ImGui::Text("%s", WrappedText(text, 60).c_str()); ImGui::EndTooltip(); } } @@ -82,7 +82,7 @@ namespace UIWidgets { ImGui::TextColored(ImVec4(0.7f, 0.7f, 0.7f, 1.0f), "?"); if (ImGui::IsItemHovered()) { ImGui::BeginTooltip(); - ImGui::Text("%s", WrappedText(text, 60)); + ImGui::Text("%s", WrappedText(text, 60).c_str()); ImGui::EndTooltip(); } } @@ -92,7 +92,7 @@ namespace UIWidgets { void Tooltip(const char* text) { if (ImGui::IsItemHovered()) { - ImGui::SetTooltip("%s", WrappedText(text)); + ImGui::SetTooltip("%s", WrappedText(text).c_str()); } } diff --git a/soh/soh/UIWidgets.hpp b/soh/soh/UIWidgets.hpp index b18487977b7..3c4622bc8cb 100644 --- a/soh/soh/UIWidgets.hpp +++ b/soh/soh/UIWidgets.hpp @@ -50,8 +50,8 @@ namespace UIWidgets { constexpr float sliderButtonWidth = 30.0f; #endif - char* WrappedText(const char* text, unsigned int charactersPerLine = 60); - char* WrappedText(const std::string& text, unsigned int charactersPerLine); + std::string WrappedText(const char* text, unsigned int charactersPerLine = 60); + std::string WrappedText(const std::string& text, unsigned int charactersPerLine); void SetLastItemHoverText(const std::string& text); void SetLastItemHoverText(const char* text); diff --git a/soh/src/code/z_player_lib.c b/soh/src/code/z_player_lib.c index 820f2c67267..ee7fd3f539b 100644 --- a/soh/src/code/z_player_lib.c +++ b/soh/src/code/z_player_lib.c @@ -2307,10 +2307,12 @@ void Player_DrawPause(PlayState* play, u8* segment, SkelAnime* skelAnime, Vec3f* } srcTable = ResourceMgr_LoadArrayByNameAsVec3s(srcTable); + Vec3s* ogSrcTable = srcTable; destTable = skelAnime->jointTable; for (i = 0; i < skelAnime->limbCount; i++) { *destTable++ = *srcTable++; } + free(ogSrcTable); } From 5530ce2e61c2566eff1988bebdabfb3c70b1b2b7 Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Thu, 9 May 2024 21:45:21 -0400 Subject: [PATCH 30/59] simplify ci (#4129) --- .github/workflows/generate-builds.yml | 100 +++++++------------------- .github/workflows/gtar | 2 +- 2 files changed, 26 insertions(+), 76 deletions(-) diff --git a/.github/workflows/generate-builds.yml b/.github/workflows/generate-builds.yml index 5c1930ede5c..ec0676de84a 100644 --- a/.github/workflows/generate-builds.yml +++ b/.github/workflows/generate-builds.yml @@ -7,7 +7,7 @@ concurrency: cancel-in-progress: true jobs: generate-soh-otr: - runs-on: ${{ (vars.LINUX_RUNNER && fromJSON(vars.LINUX_RUNNER)) || 'ubuntu-latest' }} + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3 with: @@ -20,7 +20,6 @@ jobs: ${{ runner.os }}-otr-ccache-${{ github.ref }} ${{ runner.os }}-otr-ccache- - name: Install dependencies - if: ${{ !vars.LINUX_RUNNER }} run: | sudo apt-get update sudo apt-get install -y $(cat .github/workflows/apt-deps.txt) @@ -35,7 +34,6 @@ jobs: build-cmake SDL2-2.28.5 - name: Install latest SDL - if: ${{ !vars.LINUX_RUNNER }} run: | export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" if [ ! -d "SDL2-2.28.5" ]; then @@ -73,47 +71,44 @@ jobs: retention-days: 1 build-macos: needs: generate-soh-otr - runs-on: ${{ (vars.MAC_RUNNER && fromJSON(vars.MAC_RUNNER)) || 'macos-12' }} + runs-on: macos-14 steps: - uses: actions/checkout@v3 with: submodules: true - name: ccache - uses: hendrikmuhs/ccache-action@v1.2.11 + uses: hendrikmuhs/ccache-action@v1.2.13 with: - key: ${{ runner.os }}-ccache-${{ github.ref }}-${{ github.sha }} + create-symlink: true + key: ${{ runner.os }}-14-ccache-${{ github.ref }}-${{ github.sha }} restore-keys: | - ${{ runner.os }}-ccache-${{ github.ref }} - ${{ runner.os }}-ccache- + ${{ runner.os }}-14-ccache-${{ github.ref }} + ${{ runner.os }}-14-ccache- - name: Install gtar wrapper - if: ${{ !vars.MAC_RUNNER }} run: | - sudo mv /usr/local/bin/gtar /usr/local/bin/gtar.orig - sudo cp .github/workflows//gtar /usr/local/bin/gtar - sudo chmod +x /usr/local/bin/gtar + sudo mv /opt/homebrew/bin/gtar /opt/homebrew/bin/gtar.orig + sudo cp .github/workflows//gtar /opt/homebrew/bin/gtar + sudo chmod +x /opt/homebrew/bin/gtar - name: Cache MacPorts id: cache-macports - if: ${{ !vars.MAC_RUNNER }} uses: actions/cache@v2 with: path: /opt/local/ - key: ${{ runner.os }}-macports-${{ hashFiles('.github/workflows/macports-deps.txt') }} + key: ${{ runner.os }}-14-macports-${{ hashFiles('.github/workflows/macports-deps.txt') }} restore-keys: | - ${{ runner.os }}-macports- + ${{ runner.os }}-14-macports- - name: Install MacPorts (if necessary) - if: ${{ !vars.MAC_RUNNER }} run: | if [ -d /opt/local/ ]; then echo "MacPorts already installed" else - wget https://github.com/macports/macports-base/releases/download/v2.9.3/MacPorts-2.9.3-12-Monterey.pkg - sudo installer -pkg ./MacPorts-2.9.3-12-Monterey.pkg -target / + wget https://github.com/macports/macports-base/releases/download/v2.9.3/MacPorts-2.9.3-14-Sonoma.pkg + sudo installer -pkg ./MacPorts-2.9.3-14-Sonoma.pkg -target / fi echo "/opt/local/bin:/opt/local/sbin" >> $GITHUB_PATH - name: Install dependencies - if: ${{ !vars.MAC_RUNNER }} run: | - brew uninstall --ignore-dependencies libpng libzip + brew uninstall --ignore-dependencies libpng sudo port install $(cat .github/workflows/macports-deps.txt) brew install ninja - name: Download soh.otr @@ -122,7 +117,6 @@ jobs: name: soh.otr - name: Build SoH run: | - export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" cmake --no-warn-unused-cli -H. -Bbuild-cmake -GNinja -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" -DBUILD_REMOTE_CONTROL=1 cmake --build build-cmake --config Release --parallel 10 mv soh.otr build-cmake/soh @@ -139,45 +133,33 @@ jobs: readme.txt build-linux: needs: generate-soh-otr - strategy: - fail-fast: true - matrix: - include: - - os: ubuntu-20.04 - gcc: 10 - archive-suffix: compatibility - - os: ubuntu-22.04 - gcc: 12 - archive-suffix: performance - runs-on: ${{ (matrix.os == 'ubuntu-20.04' && ((vars.LINUX_COMPATIBILITY_RUNNER && fromJSON(vars.LINUX_COMPATIBILITY_RUNNER)) || matrix.os)) || (matrix.os == 'ubuntu-22.04' && ((vars.LINUX_PERFORMANCE_RUNNER && fromJSON(vars.LINUX_PERFORMANCE_RUNNER)) || matrix.os)) }} + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3 with: submodules: true - name: Install dependencies - if: ${{ (matrix.os == 'ubuntu-20.04' && !vars.LINUX_COMPATIBILITY_RUNNER) || (matrix.os == 'ubuntu-22.04' && !vars.LINUX_PERFORMANCE_RUNNER) }} run: | sudo apt-get update sudo apt-get install -y $(cat .github/workflows/apt-deps.txt) - name: ccache uses: hendrikmuhs/ccache-action@v1.2.11 with: - key: ${{ matrix.os }}-ccache-${{ github.ref }}-${{ github.sha }} + key: linux-ccache-${{ github.ref }}-${{ github.sha }} restore-keys: | - ${{ matrix.os }}-ccache-${{ github.ref }} - ${{ matrix.os }}-ccache- + linux-ccache-${{ github.ref }} + linux-ccache- - name: Cache build folders uses: actions/cache@v4 with: - key: ${{ matrix.os }}-build-${{ github.ref }}-${{ github.sha }} + key: linux-build-${{ github.ref }}-${{ github.sha }} restore-keys: | - ${{ matrix.os }}-build-${{ github.ref }} - ${{ matrix.os }}-build- + linux-build-${{ github.ref }} + linux-build- path: | SDL2-2.28.5 SDL2_net-2.2.0 - name: Install latest SDL - if: ${{ (matrix.os == 'ubuntu-20.04' && !vars.LINUX_COMPATIBILITY_RUNNER) || (matrix.os == 'ubuntu-22.04' && !vars.LINUX_PERFORMANCE_RUNNER) }} run: | export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" if [ ! -d "SDL2-2.28.5" ]; then @@ -189,38 +171,7 @@ jobs: make -j 10 sudo make install sudo cp -av /usr/local/lib/libSDL* /lib/x86_64-linux-gnu/ - - name: Install latest libzip - if: ${{ (matrix.os == 'ubuntu-20.04' && !vars.LINUX_COMPATIBILITY_RUNNER) }} - run: | - sudo apt-get remove libzip-dev zipcmp zipmerge ziptool - export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" - if [ ! -d "libzip-1.10.1" ]; then - wget https://libzip.org/download/libzip-1.10.1.tar.gz - tar -xzvf libzip-1.10.1.tar.gz - fi - cd libzip-1.10.1 - mkdir build - cd build - cmake .. - make - sudo make install - - name: Install latest nlohmann - if: ${{ (matrix.os == 'ubuntu-20.04' && !vars.LINUX_COMPATIBILITY_RUNNER) }} - run: | - sudo apt-get remove nlohmann-json3-dev - export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" - if [ ! -d "json-3.11.3" ]; then - wget https://github.com/nlohmann/json/archive/refs/tags/v3.11.3.tar.gz - tar -xzvf v3.11.3.tar.gz - fi - cd json-3.11.3 - mkdir build - cd build - cmake .. - make - sudo make install - name: Install latest tinyxml2 - if: ${{ (matrix.os == 'ubuntu-20.04' && !vars.LINUX_COMPATIBILITY_RUNNER) || (matrix.os == 'ubuntu-22.04' && !vars.LINUX_PERFORMANCE_RUNNER) }} run: | sudo apt-get remove libtinyxml2-dev export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" @@ -235,7 +186,6 @@ jobs: make sudo make install - name: Install latest SDL_net - if: ${{ (matrix.os == 'ubuntu-20.04' && !vars.LINUX_COMPATIBILITY_RUNNER) || (matrix.os == 'ubuntu-22.04' && !vars.LINUX_PERFORMANCE_RUNNER) }} run: | export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" if [ ! -d "SDL2_net-2.2.0" ]; then @@ -261,12 +211,12 @@ jobs: mv README.md readme.txt mv build-cmake/*.appimage soh.appimage env: - CC: gcc-${{ matrix.gcc }} - CXX: g++-${{ matrix.gcc }} + CC: gcc-12 + CXX: g++-12 - name: Upload build uses: actions/upload-artifact@v4 with: - name: soh-linux-${{ matrix.archive-suffix }} + name: soh-linux path: | soh.appimage readme.txt diff --git a/.github/workflows/gtar b/.github/workflows/gtar index 5814696d1bb..cf64d0281e9 100644 --- a/.github/workflows/gtar +++ b/.github/workflows/gtar @@ -1,2 +1,2 @@ #!/bin/sh -exec sudo /usr/local/bin/gtar.orig "$@" +exec sudo /opt/homebrew/bin/gtar.orig "$@" From 23f9654940902a1ae86ef9eda342011dcca6e1c8 Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Thu, 9 May 2024 21:49:32 -0400 Subject: [PATCH 31/59] update `BUILDING.md` (#4128) --- .github/workflows/test-builds-on-distros.yml | 32 ++++++++++++-------- docs/BUILDING.md | 16 +++++----- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/.github/workflows/test-builds-on-distros.yml b/.github/workflows/test-builds-on-distros.yml index 36bbc67a92f..e2029be781b 100644 --- a/.github/workflows/test-builds-on-distros.yml +++ b/.github/workflows/test-builds-on-distros.yml @@ -1,8 +1,3 @@ -# todo: -# nlohmann -# tinyxml2 -# spdlog - name: test-builds-on-distros on: workflow_dispatch: # by request @@ -28,31 +23,42 @@ jobs: if: ${{ matrix.image == 'archlinux:base' }} run: | echo arch - echo pacman -S ${{ matrix.cc }} git cmake ninja lsb-release sdl2 libpng libzip sdl2_net boost + echo pacman -S ${{ matrix.cc }} git cmake ninja lsb-release sdl2 libpng libzip nlohmann-json tinyxml2 spdlog sdl2_net boost pacman -Syu --noconfirm - pacman -S --noconfirm ${{ matrix.cc }} git cmake ninja lsb-release sdl2 libpng libzip sdl2_net boost + pacman -S --noconfirm ${{ matrix.cc }} git cmake ninja lsb-release sdl2 libpng libzip nlohmann-json tinyxml2 spdlog sdl2_net boost - name: Install dependencies (dnf) if: ${{ matrix.image == 'fedora:39' }} run: | echo fedora - echo dnf install ${{ matrix.cc }} ${{ (matrix.cxx == 'g++' && 'gcc-c++') || '' }} git cmake ninja-build lsb_release SDL2-devel libpng-devel libzip-devel libzip-tools boost-devel + echo dnf install ${{ matrix.cc }} ${{ (matrix.cxx == 'g++' && 'gcc-c++') || '' }} wget git cmake ninja-build lsb_release SDL2-devel libpng-devel libzip-devel libzip-tools tinyxml2-devel spdlog-devel boost-devel dnf -y upgrade - dnf -y install ${{ matrix.cc }} ${{ (matrix.cxx == 'g++' && 'gcc-c++') || '' }} git cmake ninja-build lsb_release SDL2-devel libpng-devel libzip-devel libzip-tools boost-devel + dnf -y install ${{ matrix.cc }} ${{ (matrix.cxx == 'g++' && 'gcc-c++') || '' }} wget git cmake ninja-build lsb_release SDL2-devel libpng-devel libzip-devel libzip-tools tinyxml2-devel spdlog-devel boost-devel - name: Install dependencies (apt) if: ${{ matrix.image == 'ubuntu:mantic' || matrix.image == 'debian:bookworm' }} run: | echo debian based - echo apt-get install ${{ matrix.cc }} ${{ (matrix.cxx == 'g++' && 'g++') || '' }} git cmake ninja-build lsb-release libsdl2-dev libpng-dev libsdl2-net-dev libzip-dev zipcmp zipmerge ziptool libboost-dev libopengl-dev + echo apt-get install ${{ matrix.cc }} ${{ (matrix.cxx == 'g++' && 'g++') || '' }} git cmake ninja-build lsb-release libsdl2-dev libpng-dev libsdl2-net-dev libzip-dev zipcmp zipmerge ziptool nlohmann-json3-dev libtinyxml2-dev libspdlog-dev libboost-dev libopengl-dev apt-get update apt-get -y full-upgrade - apt-get -y install ${{ matrix.cc }} ${{ (matrix.cxx == 'g++' && 'g++') || '' }} git cmake ninja-build lsb-release libsdl2-dev libpng-dev libsdl2-net-dev libzip-dev zipcmp zipmerge ziptool libboost-dev libopengl-dev + apt-get -y install ${{ matrix.cc }} ${{ (matrix.cxx == 'g++' && 'g++') || '' }} git cmake ninja-build lsb-release libsdl2-dev libpng-dev libsdl2-net-dev libzip-dev zipcmp zipmerge ziptool nlohmann-json3-dev libtinyxml2-dev libspdlog-dev libboost-dev libopengl-dev - name: Install dependencies (zypper) if: ${{ matrix.image == 'opensuse/tumbleweed:latest' }} run: | echo openSUSE - echo zypper in ${{ matrix.cc }} ${{ (matrix.cxx == 'g++' && 'gcc-c++') || '' }} ${{ matrix.cc == 'clang' && 'libstdc++-devel' || '' }} git cmake ninja SDL2-devel libpng16-devel libzip-devel libzip-tools + echo zypper in ${{ matrix.cc }} ${{ (matrix.cxx == 'g++' && 'gcc-c++') || '' }} ${{ matrix.cc == 'clang' && 'libstdc++-devel' || '' }} git cmake ninja SDL2-devel libpng16-devel libzip-devel libzip-tools nlohmann_json-devel tinyxml2-devel spdlog-devel zypper --non-interactive dup - zypper --non-interactive in ${{ matrix.cc }} ${{ (matrix.cxx == 'g++' && 'gcc-c++') || '' }} ${{ matrix.cc == 'clang' && 'libstdc++-devel' || '' }} git cmake ninja SDL2-devel libpng16-devel libzip-devel libzip-tools + zypper --non-interactive in ${{ matrix.cc }} ${{ (matrix.cxx == 'g++' && 'gcc-c++') || '' }} ${{ matrix.cc == 'clang' && 'libstdc++-devel' || '' }} git cmake ninja SDL2-devel libpng16-devel libzip-devel libzip-tools nlohmann_json-devel tinyxml2-devel spdlog-devel + - name: Install latest nlohmann + if: ${{ matrix.image == 'fedora:39' }} + run: | + wget https://github.com/nlohmann/json/archive/refs/tags/v3.11.3.tar.gz + tar -xzvf v3.11.3.tar.gz + cd json-3.11.3 + mkdir build + cd build + cmake .. + make + sudo make install - uses: actions/checkout@v3 with: submodules: true diff --git a/docs/BUILDING.md b/docs/BUILDING.md index 6c922224293..eb5a6a3365c 100644 --- a/docs/BUILDING.md +++ b/docs/BUILDING.md @@ -88,34 +88,34 @@ cd "build/x64" #### Debian/Ubuntu ```sh # using gcc -apt-get install gcc g++ git cmake ninja-build lsb-release libsdl2-dev libpng-dev libsdl2-net-dev libzip-dev zipcmp zipmerge ziptool libboost-dev libopengl-dev +apt-get install gcc g++ git cmake ninja-build lsb-release libsdl2-dev libpng-dev libsdl2-net-dev libzip-dev zipcmp zipmerge ziptool nlohmann-json3-dev libtinyxml2-dev libspdlog-dev libboost-dev libopengl-dev # or using clang -apt-get install clang git cmake ninja-build lsb-release libsdl2-dev libpng-dev libsdl2-net-dev libzip-dev zipcmp zipmerge ziptool libboost-dev libopengl-dev +apt-get install clang git cmake ninja-build lsb-release libsdl2-dev libpng-dev libsdl2-net-dev libzip-dev zipcmp zipmerge ziptool nlohmann-json3-dev libtinyxml2-dev libspdlog-dev libboost-dev libopengl-dev ``` #### Arch ```sh # using gcc -pacman -S gcc git cmake ninja lsb-release sdl2 libpng libzip sdl2_net boost +pacman -S gcc git cmake ninja lsb-release sdl2 libpng libzip nlohmann-json tinyxml2 spdlog sdl2_net boost # or using clang -pacman -S clang git cmake ninja lsb-release sdl2 libpng libzip sdl2_net boost +pacman -S clang git cmake ninja lsb-release sdl2 libpng libzip nlohmann-json tinyxml2 spdlog sdl2_net boost ``` #### Fedora ```sh # using gcc -dnf install gcc gcc-c++ git cmake ninja-build lsb_release SDL2-devel libpng-devel libzip-devel libzip-tools boost-devel +dnf install gcc gcc-c++ git cmake ninja-build lsb_release SDL2-devel libpng-devel libzip-devel libzip-tools nlohmann-json-devel tinyxml2-devel spdlog-devel boost-devel # or using clang -dnf install clang git cmake ninja-build lsb_release SDL2-devel libpng-devel libzip-devel libzip-tools boost-devel +dnf install clang git cmake ninja-build lsb_release SDL2-devel libpng-devel libzip-devel libzip-tools nlohmann-json-devel tinyxml2-devel spdlog-devel boost-devel ``` #### openSUSE ```sh # using gcc -zypper in gcc gcc-c++ git cmake ninja SDL2-devel libpng16-devel libzip-devel libzip-tools +zypper in gcc gcc-c++ git cmake ninja SDL2-devel libpng16-devel libzip-devel libzip-tools nlohmann_json-devel tinyxml2-devel spdlog-devel # or using clang -zypper in clang libstdc++-devel git cmake ninja SDL2-devel libpng16-devel libzip-devel libzip-tools +zypper in clang libstdc++-devel git cmake ninja SDL2-devel libpng16-devel libzip-devel libzip-tools nlohmann_json-devel tinyxml2-devel spdlog-devel ``` ### Build From 63bc2aff59ea9b0ec3019d026235afe35f40618c Mon Sep 17 00:00:00 2001 From: Eric Hoey <121978037+A-Green-Spoon@users.noreply.github.com> Date: Thu, 9 May 2024 21:55:53 -0400 Subject: [PATCH 32/59] Frogs Ocarina Game Difficulty Options (#3373) * Frog actor edits, menu, presets * Block off vanilla code + comments * fix logic + formatting * new documentation format * Update for CVAR changes * Fix alignment * Conditions cleanup * Update soh/soh/SohMenuBar.cpp Oops, added Co-authored-by: inspectredc <78732756+inspectredc@users.noreply.github.com> --------- Co-authored-by: inspectredc <78732756+inspectredc@users.noreply.github.com> --- soh/soh/Enhancements/presets.h | 4 ++ soh/soh/SohMenuBar.cpp | 26 +++++++++++++ soh/src/overlays/actors/ovl_En_Fr/z_en_fr.c | 43 +++++++++++++++++---- 3 files changed, 65 insertions(+), 8 deletions(-) diff --git a/soh/soh/Enhancements/presets.h b/soh/soh/Enhancements/presets.h index a502dc3daad..54c72937188 100644 --- a/soh/soh/Enhancements/presets.h +++ b/soh/soh/Enhancements/presets.h @@ -200,6 +200,10 @@ const std::vector enhancementsCvars = { CVAR_ENHANCEMENT("OcarinaGame.RoundOneNotes"), CVAR_ENHANCEMENT("OcarinaGame.RoundTwoNotes"), CVAR_ENHANCEMENT("OcarinaGame.RoundThreeNotes"), + CVAR_ENHANCEMENT("CustomizeFrogsOcarinaGame"), + CVAR_ENHANCEMENT("InstantFrogsGameWin"), + CVAR_ENHANCEMENT("FrogsUnlimitedFailTime"), + CVAR_ENHANCEMENT("FrogsModifyFailTime"), CVAR_ENHANCEMENT("CreditsFix"), CVAR_ENHANCEMENT("SilverRupeeJingleExtend"), CVAR_ENHANCEMENT("StaticExplosionRadius"), diff --git a/soh/soh/SohMenuBar.cpp b/soh/soh/SohMenuBar.cpp index f60983c59fc..9cd2c684416 100644 --- a/soh/soh/SohMenuBar.cpp +++ b/soh/soh/SohMenuBar.cpp @@ -891,6 +891,32 @@ void DrawEnhancementsMenu() { UIWidgets::Spacer(0); + if (ImGui::BeginMenu("Frogs Ocarina Game")) { + UIWidgets::EnhancementCheckbox("Customize Behavior", CVAR_ENHANCEMENT("CustomizeFrogsOcarinaGame")); + UIWidgets::Tooltip("Turn on/off changes to the frogs ocarina game behavior"); + bool disabled = !CVarGetInteger(CVAR_ENHANCEMENT("CustomizeFrogsOcarinaGame"), 0); + static const char* disabledTooltip = + "This option is disabled because \"Customize Behavior\" is turned off"; + UIWidgets::PaddedEnhancementCheckbox("Instant Win", CVAR_ENHANCEMENT("InstantFrogsGameWin"), true, false, disabled, disabledTooltip); + UIWidgets::Tooltip("Skips the frogs ocarina game"); + UIWidgets::PaddedEnhancementCheckbox("Unlimited Playback Time", CVAR_ENHANCEMENT("FrogsUnlimitedFailTime"), true, false, disabled, disabledTooltip); + UIWidgets::Tooltip("Removes the timer to play back the song"); + bool disabledFrog = 0; + static const char* disabledFrogTooltip = + "This option is disabled because \"Customize Behavior\" is turned off or \"Unlimited Playback Time\" is on"; + if (!CVarGetInteger(CVAR_ENHANCEMENT("CustomizeFrogsOcarinaGame"), 0) || CVarGetInteger(CVAR_ENHANCEMENT("FrogsUnlimitedFailTime"), 0)) { + disabledFrog = 1; + } else { + disabledFrog = 0; + } + UIWidgets::PaddedEnhancementSliderInt("Modify note timer: %dx", "##FrogsFailTimer", CVAR_ENHANCEMENT("FrogsModifyFailTime"), 1, 5, "", 1, true, true, false, + disabledFrog, disabledFrogTooltip); + UIWidgets::Tooltip("Adjusts the time allowed for playback before failing"); + ImGui::EndMenu(); + } + + UIWidgets::Spacer(0); + UIWidgets::PaddedEnhancementCheckbox("Delete File On Death", CVAR_ENHANCEMENT("DeleteFileOnDeath"), true, false); ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1.0f, 0.0f, 0.0f, 1.0f)); UIWidgets::Tooltip("Dying will delete your file\n\n " ICON_FA_EXCLAMATION_TRIANGLE " WARNING " ICON_FA_EXCLAMATION_TRIANGLE "\nTHIS IS NOT REVERSABLE\nUSE AT YOUR OWN RISK!"); diff --git a/soh/src/overlays/actors/ovl_En_Fr/z_en_fr.c b/soh/src/overlays/actors/ovl_En_Fr/z_en_fr.c index 36c9c281810..d616db0402a 100644 --- a/soh/src/overlays/actors/ovl_En_Fr/z_en_fr.c +++ b/soh/src/overlays/actors/ovl_En_Fr/z_en_fr.c @@ -819,12 +819,28 @@ void EnFr_SetupFrogSong(EnFr* this, PlayState* play) { if (this->frogSongTimer != 0) { this->frogSongTimer--; } else { - this->frogSongTimer = 40; - this->ocarinaNoteIndex = 0; - func_8010BD58(play, OCARINA_ACTION_FROGS); - this->ocarinaNote = EnFr_GetNextNoteFrogSong(this->ocarinaNoteIndex); - EnFr_CheckOcarinaInputFrogSong(this->ocarinaNote); - this->actionFunc = EnFr_ContinueFrogSong; + // #region SOH [Enhancement] + if (CVarGetInteger(CVAR_ENHANCEMENT("CustomizeFrogsOcarinaGame"), 0)) { + this->frogSongTimer = 40 * CVarGetInteger(CVAR_ENHANCEMENT("FrogsModifyFailTime"), 1); + if (CVarGetInteger(CVAR_ENHANCEMENT("InstantFrogsGameWin"), 0)) { + this->actor.textId = 0x40AC; + EnFr_SetupReward(this, play, false); + } else { + this->ocarinaNoteIndex = 0; + func_8010BD58(play, OCARINA_ACTION_FROGS); + this->ocarinaNote = EnFr_GetNextNoteFrogSong(this->ocarinaNoteIndex); + EnFr_CheckOcarinaInputFrogSong(this->ocarinaNote); + this->actionFunc = EnFr_ContinueFrogSong; + } + // #endregion + } else { + this->frogSongTimer = 40; + this->ocarinaNoteIndex = 0; + func_8010BD58(play, OCARINA_ACTION_FROGS); + this->ocarinaNote = EnFr_GetNextNoteFrogSong(this->ocarinaNoteIndex); + EnFr_CheckOcarinaInputFrogSong(this->ocarinaNote); + this->actionFunc = EnFr_ContinueFrogSong; + } } } @@ -846,7 +862,13 @@ s32 EnFr_IsFrogSongComplete(EnFr* this, PlayState* play) { ocarinaNote = EnFr_GetNextNoteFrogSong(ocarinaNoteIndex); this->ocarinaNote = ocarinaNote; EnFr_CheckOcarinaInputFrogSong(ocarinaNote); - this->frogSongTimer = sTimerFrogSong[index]; + // #region SOH [Enhancement] + if (CVarGetInteger(CVAR_ENHANCEMENT("CustomizeFrogsOcarinaGame"), 0)) { + this->frogSongTimer = sTimerFrogSong[index] * CVarGetInteger(CVAR_ENHANCEMENT("FrogsModifyFailTime"), 1); + // #endregion + } else { + this->frogSongTimer = sTimerFrogSong[index]; + } } return false; } @@ -870,7 +892,12 @@ void EnFr_ContinueFrogSong(EnFr* this, PlayState* play) { if (this->frogSongTimer == 0) { EnFr_OcarinaMistake(this, play); } else { - this->frogSongTimer--; + // #region SOH [Enhancement] - Don't decrement timer + if (!CVarGetInteger(CVAR_ENHANCEMENT("CustomizeFrogsOcarinaGame"), 0) || + !CVarGetInteger(CVAR_ENHANCEMENT("FrogsUnlimitedFailTime"), 0)) { + // #endregion + this->frogSongTimer--; + } if (play->msgCtx.msgMode == MSGMODE_FROGS_PLAYING) { counter = 0; for (i = 0; i < ARRAY_COUNT(sEnFrPointers.frogs); i++) { From 65b18d61cfba4a93b547f5ff016f48bb8cb8fc6a Mon Sep 17 00:00:00 2001 From: Eric Hoey <121978037+A-Green-Spoon@users.noreply.github.com> Date: Thu, 9 May 2024 23:02:50 -0400 Subject: [PATCH 33/59] Fix modifiers crash when obtaining underwater item (#4110) * NULL check * Update soh/src/overlays/actors/ovl_player_actor/z_player.c Co-authored-by: Garrett Cox * Update soh/src/overlays/actors/ovl_player_actor/z_player.c Co-authored-by: Garrett Cox --------- Co-authored-by: Garrett Cox --- soh/src/overlays/actors/ovl_player_actor/z_player.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/soh/src/overlays/actors/ovl_player_actor/z_player.c b/soh/src/overlays/actors/ovl_player_actor/z_player.c index 145da2f999c..3e1452648cb 100644 --- a/soh/src/overlays/actors/ovl_player_actor/z_player.c +++ b/soh/src/overlays/actors/ovl_player_actor/z_player.c @@ -12116,7 +12116,8 @@ void func_8084AEEC(Player* this, f32* arg1, f32 arg2, s16 arg3) { } else if (gWalkSpeedToggle2) { swimMod *= CVarGetFloat(CVAR_SETTING("WalkModifier.SwimMapping2"), 1.0f); } - } else { + // sControlInput is NULL to prevent inputs while surfacing after obtaining an underwater item so we want to ignore it for that case + } else if (sControlInput != NULL) { if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_MODIFIER1)) { swimMod *= CVarGetFloat(CVAR_SETTING("WalkModifier.SwimMapping1"), 1.0f); } else if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_MODIFIER2)) { From 844413b391eadef832a5dadf46adcdb3a887b6bd Mon Sep 17 00:00:00 2001 From: Ted Newman Date: Thu, 9 May 2024 19:57:31 -0800 Subject: [PATCH 34/59] Add Modifier buttons to input viewer and support individual button outline modes (#3966) * Add Modifier buttons to input viewer and support individual button outline modes * Clearer naming * Remove hardcoded indent values * clean up diff --------- Co-authored-by: briaguya <70942617+briaguya-ai@users.noreply.github.com> --- soh/assets/custom/textures/buttons/Mod1.png | Bin 0 -> 1166 bytes .../custom/textures/buttons/Mod1Outline.png | Bin 0 -> 1180 bytes soh/assets/custom/textures/buttons/Mod2.png | Bin 0 -> 1110 bytes .../custom/textures/buttons/Mod2Outline.png | Bin 0 -> 1192 bytes soh/soh/Enhancements/controls/InputViewer.cpp | 221 +++++++++++++++--- 5 files changed, 191 insertions(+), 30 deletions(-) create mode 100644 soh/assets/custom/textures/buttons/Mod1.png create mode 100644 soh/assets/custom/textures/buttons/Mod1Outline.png create mode 100644 soh/assets/custom/textures/buttons/Mod2.png create mode 100644 soh/assets/custom/textures/buttons/Mod2Outline.png diff --git a/soh/assets/custom/textures/buttons/Mod1.png b/soh/assets/custom/textures/buttons/Mod1.png new file mode 100644 index 0000000000000000000000000000000000000000..69496db6a7a9cc4a7fc8506653d4c1dbb55c7aa4 GIT binary patch literal 1166 zcmeAS@N?(olHy`uVBq!ia0y~yU~~tv*K@D|$vjON1E4@lrn7T^r?ay{K~a8MW=<*t zgT}<#iMAex9b}Hi2QO6;W$*5=NLk@0c0^ysTeLf2;TF-TQiGjexM!KDXzKMfWgk4) ze{@xI_vUqc>zWjPFg|+oV95(5)qnb$TRJ{I*dhP^o$b4Oj82OWg>24d3NStGaWpx} zY`Yd)oMM7NU5lZzVX*%aapMm%@!vmu{Hk|o^Pcm6Eq_hfbCO}chfM0OM8SN4^LbHL z&ubqEXnS&fwEVckQCy|&$*wn_q@OQ3%ygbda^@AA!j1@?vJH0*u1Q&OMy@;6SHIbwY{j0{t<>#4Z!73Kcv`Tyr-e*Mn8^+wU5?AAL%z-VDh@^*J&SjsS&VTJ?i zHaDOMXMsm#F#`j)FbFd;%$g$s6l5>)^mS!_!6e2az)-U5(nFw-WQl7;iF1B#Zfaf$ zgL6@8Vo7R>LV0FMhJw4NZ$Nk>pEv^pQ<|rXV@SoVw|5-#E<1>@Jur`RIHh@}=$7+? zc}rgTp7P{S&#daW7OgL+t>Tg`dh&3SPK>j&&@PWV?{DAywArod()voN(}F5`#t*~M+8E-_1jW_4sJE$Z&jn|g^iwDj`xJy(JrTy1%*A+p}gHauw8tKxqv)*g6s zxbWgOU#+KA?UU9mDY^N4&!xD8_^St(mut>1(^>g_1*65h0-K$?clUKv75(;hsp;)_ zFKFm;)OL6a!Nn1B0ilpUXO@geCwVzWjPFg|+oV95(5)qnb$TRJ{I*dhP^o$b4Oj82OWg>24d3NStGaWpx} zY`Yd)oMM7NU5lZzVX*%aapMm%@!vmu{Hk|o^Pcm6Eq_hfbCO}chfM0OM8SN4^LbHL z&ubqEXnS&fwEVckQCy|&$*wn_q@OQ3%ygbda^@AA!j1@?vJH0*u1Q&OMy@;6SHIbwY{j0{t<>#4Z!73Kcv`Tyr-e*Mn8^+wU5?AAL%z-VDh@^*J&SjsS&VTJ?i zHaDOMXMsm#F#`j)FbFd;%$g$s6l5>)^mS!_!6e2az)_VLbr~omS>hT|;+&tGo0?a` z;9QiNSdyBeP@Y+mq2TW68xY>eC(gjYRO0F47*cWT?HxzI#|{Fl7qr$J%{ina%V+pZ z<$!0yWCnFb8KsKX!90;mZ&oZ>!P>H5V%v=GWqo(TmQ32WYEm93`3x;^VE@$PUsA;n zUvN9(I_;9Xi@ad6OHbsf9l5iX`(D4Rt@$DOP@%d=zTK|%Dfe=Ay$g$MyxIOZN#d8z z(~k|R$tU;RD!J=b*|O|8(lKGnXe- z$_bWEzcFvkbta)1_apvZvzWW|&VNhm-Br*3z5Zo>a#Cg99=2!KEdQ;uKK8xIP$}t` za@yACk_^XX`_7i#4vT$oc%P~2=WVY{s#V$2MEg`X^KCodb3D29u9l&}_Km+1X0H?O zJMiZ4#|I0dc@C$VhTYc&iC2ZP-u=4IH1gEZcVD+7}grocu;!h2bt;Eep|J8nB3Q;&;Go5EHXV)3pe<$lg~an;SebEn_+`=4XK hXXAN6>zWjPFg|+oV95(5)qnb$TRJ{I*dhP^o$b4Oj82OWg>24d3NStGaWpx} zY`Yd)oMM7NU5lZzVX*%aapMm%@!vmu{Hk|o^Pcm6Eq_hfbCO}chfM0OM8SN4^LbHL z&ubqEXnS&fwEVckQCy|&$*wn_q@OQ3%ygbda^@AA!j1@?vJH0*u1Q&OMy@;6SHIbwY{j0{t<>#4Z!73Kcv`Tyr-e*Mn8^+wU5?AAL%z-VDh@^*J&SjsS&VTJ?i zHaDOMXMsm#F#`j)FbFd;%$g$s6l5>)^mS!_!6e4QuPqv*Y7Z2WEOCt}an8@pP0cG| za4t$sEJ;mKD9cK2*{>B+dB1v1Z{eLeI0Fw1>LjpOH+%HF!mo?YnXQku8) zTaWS`eg4M#3G%;}ty=YVYyFy(wEa@y@v0nZ$0MVT?~*_MQSA| zd!C%wG%5A7ft`k1K;P-275uR$Kh05{{p0b5+Z{J}4}U0@eI4h8Jx;kl@?Ab$oSfz1 QPy|xo>FVdQ&MBb@0BC5Em;e9( literal 0 HcmV?d00001 diff --git a/soh/assets/custom/textures/buttons/Mod2Outline.png b/soh/assets/custom/textures/buttons/Mod2Outline.png new file mode 100644 index 0000000000000000000000000000000000000000..06464c553e96bd4327fe8b65d764ed7bb629cd73 GIT binary patch literal 1192 zcmeAS@N?(olHy`uVBq!ia0y~yU~~tv*K@D|$vjON1E4@lrn7T^r?ay{K~a8MW=<*t zgT}<#iMAex9b}Hi2QO6;W$*5=NLk@0c0^ysTeLf2;TF-TQiGjexM!KDXzKMfWgk4) ze{@xI_vUqc>zWjPFg|+oV95(5)qnb$TRJ{I*dhP^o$b4Oj82OWg>24d3NStGaWpx} zY`Yd)oMM7NU5lZzVX*%aapMm%@!vmu{Hk|o^Pcm6Eq_hfbCO}chfM0OM8SN4^LbHL z&ubqEXnS&fwEVckQCy|&$*wn_q@OQ3%ygbda^@AA!j1@?vJH0*u1Q&OMy@;6SHIbwY{j0{t<>#4Z!73Kcv`Tyr-e*Mn8^+wU5?AAL%z-VDh@^*J&SjsS&VTJ?i zHaDOMXMsm#F#`j)FbFd;%$g$s6l5>)^mS!_!6e4QZ!#l9;}lRxvcxr_#5q4VH#M(> z!MP|ku_QG`p**uBL&4qCHz2%`Pn>~)sln65F{I+w+dGbVw*my%9#n4Sf8@c~8GL1q z%304z^HiRwObAwB6|?I&`})|_By-IRX@Y0Izul0dpZ3xC@%J|zKzoK3_z~mDX?Nai zTWI98a=}1%m$}7xL0-P6R$3l;n0oJQ_$rn|AElf>emt?Ve{0z$ZT}b!eN4(t zjuv&@Xjh)7`uxtB-9LM|nl@HV65E)uYhCoSnqQj_-=DkmRpYsjT2?25?IP2rusy7p zTK06EpXJ@BQ&v}e-gvv?#+KaQHus)mPbUXj{xZdh%qw?pS^o-@iacHYT-G@yGywnv C$;%r6 literal 0 HcmV?d00001 diff --git a/soh/soh/Enhancements/controls/InputViewer.cpp b/soh/soh/Enhancements/controls/InputViewer.cpp index 93727b5fa30..106a08b53e7 100644 --- a/soh/soh/Enhancements/controls/InputViewer.cpp +++ b/soh/soh/Enhancements/controls/InputViewer.cpp @@ -20,6 +20,8 @@ static ImVec4 range2Color = ImVec4(0, 1.0f, 0, 1.0f); static const char* buttonOutlineOptions[4] = { "Always Shown", "Shown Only While Not Pressed", "Shown Only While Pressed", "Always Hidden" }; +static const char* buttonOutlineOptionsVerbose[4] = { "Outline Always Shown", "Outline Shown Only While Not Pressed", + "Outline Shown Only While Pressed", "Outline Always Hidden" }; static const char* stickModeOptions[3] = { "Always", "While In Use", "Never" }; @@ -85,6 +87,8 @@ void InputViewer::DrawElement() { Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Dpad-Up", "textures/buttons/DPadUp.png"); Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Dpad-Down", "textures/buttons/DPadDown.png"); + Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Modifier-1", "textures/buttons/Mod1.png"); + Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Modifier-2", "textures/buttons/Mod2.png"); Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Right-Stick", "textures/buttons/RightStick.png"); Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("A-Btn Outline", @@ -117,6 +121,10 @@ void InputViewer::DrawElement() { "textures/buttons/DPadUpOutline.png"); Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Dpad-Down Outline", "textures/buttons/DPadDownOutline.png"); + Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Modifier-1 Outline", + "textures/buttons/Mod1Outline.png"); + Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Modifier-2 Outline", + "textures/buttons/Mod2Outline.png"); Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Right-Stick Outline", "textures/buttons/RightStickOutline.png"); sButtonTexturesLoaded = true; @@ -132,17 +140,19 @@ void InputViewer::DrawElement() { #endif const int showAnalogAngles = CVarGetInteger(CVAR_INPUT_VIEWER("AnalogAngles.Enabled"), 0); const int buttonOutlineMode = CVarGetInteger(CVAR_INPUT_VIEWER("ButtonOutlineMode"), BUTTON_OUTLINE_NOT_PRESSED); + const bool useGlobalOutlineMode = CVarGetInteger(CVAR_INPUT_VIEWER("UseGlobalButtonOutlineMode"), 1); ImVec2 bgSize = Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureSize("Input-Viewer-Background"); ImVec2 scaledBGSize = ImVec2(bgSize.x * scale, bgSize.y * scale); - ImGui::SetNextWindowSize(ImVec2( - scaledBGSize.x + 20, - scaledBGSize.y + - (showAnalogAngles ? ImGui::CalcTextSize("X").y : 0) * scale * CVarGetFloat(CVAR_INPUT_VIEWER("AnalogAngles.Scale"), 1.0f) + 20)); + ImGui::SetNextWindowSize( + ImVec2(scaledBGSize.x + 20, scaledBGSize.y + + (showAnalogAngles ? ImGui::CalcTextSize("X").y : 0) * scale * + CVarGetFloat(CVAR_INPUT_VIEWER("AnalogAngles.Scale"), 1.0f) + + 20)); ImGui::SetNextWindowContentSize( ImVec2(scaledBGSize.x, scaledBGSize.y + (showAnalogAngles ? 15 : 0) * scale * - CVarGetFloat(CVAR_INPUT_VIEWER("AnalogAngles.Scale"), 1.0f))); + CVarGetFloat(CVAR_INPUT_VIEWER("AnalogAngles.Scale"), 1.0f))); ImGui::SetNextWindowPos( ImVec2(mainPos.x + size.x - scaledBGSize.x - 30, mainPos.y + size.y - scaledBGSize.y - 30), ImGuiCond_FirstUseEver); @@ -176,52 +186,78 @@ void InputViewer::DrawElement() { if (CVarGetInteger(CVAR_INPUT_VIEWER("BBtn"), 1)) { ImGui::SetNextItemAllowOverlap(); ImGui::SetCursorPos(aPos); - RenderButton("B-Btn", "B-Btn Outline", pads[0].button & BTN_B, scaledBGSize, buttonOutlineMode); + RenderButton("B-Btn", "B-Btn Outline", pads[0].button & BTN_B, scaledBGSize, + useGlobalOutlineMode + ? buttonOutlineMode + : CVarGetInteger(CVAR_INPUT_VIEWER("BBtnOutlineMode"), BUTTON_OUTLINE_NOT_PRESSED)); } if (CVarGetInteger(CVAR_INPUT_VIEWER("ABtn"), 1)) { ImGui::SetNextItemAllowOverlap(); ImGui::SetCursorPos(aPos); - RenderButton("A-Btn", "A-Btn Outline", pads[0].button & BTN_A, scaledBGSize, buttonOutlineMode); + RenderButton("A-Btn", "A-Btn Outline", pads[0].button & BTN_A, scaledBGSize, + useGlobalOutlineMode + ? buttonOutlineMode + : CVarGetInteger(CVAR_INPUT_VIEWER("ABtnOutlineMode"), BUTTON_OUTLINE_NOT_PRESSED)); } // C buttons if (CVarGetInteger(CVAR_INPUT_VIEWER("CUp"), 1)) { ImGui::SetNextItemAllowOverlap(); ImGui::SetCursorPos(aPos); - RenderButton("C-Up", "C-Up Outline", pads[0].button & BTN_CUP, scaledBGSize, buttonOutlineMode); + RenderButton("C-Up", "C-Up Outline", pads[0].button & BTN_CUP, scaledBGSize, + useGlobalOutlineMode + ? buttonOutlineMode + : CVarGetInteger(CVAR_INPUT_VIEWER("CUpOutlineMode"), BUTTON_OUTLINE_NOT_PRESSED)); } if (CVarGetInteger(CVAR_INPUT_VIEWER("CLeft"), 1)) { ImGui::SetNextItemAllowOverlap(); ImGui::SetCursorPos(aPos); - RenderButton("C-Left", "C-Left Outline", pads[0].button & BTN_CLEFT, scaledBGSize, buttonOutlineMode); + RenderButton("C-Left", "C-Left Outline", pads[0].button & BTN_CLEFT, scaledBGSize, + useGlobalOutlineMode + ? buttonOutlineMode + : CVarGetInteger(CVAR_INPUT_VIEWER("CLeftOutlineMode"), BUTTON_OUTLINE_NOT_PRESSED)); } if (CVarGetInteger(CVAR_INPUT_VIEWER("CRight"), 1)) { ImGui::SetNextItemAllowOverlap(); ImGui::SetCursorPos(aPos); RenderButton("C-Right", "C-Right Outline", pads[0].button & BTN_CRIGHT, scaledBGSize, - buttonOutlineMode); + useGlobalOutlineMode + ? buttonOutlineMode + : CVarGetInteger(CVAR_INPUT_VIEWER("CRightOutlineMode"), BUTTON_OUTLINE_NOT_PRESSED)); } if (CVarGetInteger(CVAR_INPUT_VIEWER("CDown"), 1)) { ImGui::SetNextItemAllowOverlap(); ImGui::SetCursorPos(aPos); - RenderButton("C-Down", "C-Down Outline", pads[0].button & BTN_CDOWN, scaledBGSize, buttonOutlineMode); + RenderButton("C-Down", "C-Down Outline", pads[0].button & BTN_CDOWN, scaledBGSize, + useGlobalOutlineMode + ? buttonOutlineMode + : CVarGetInteger(CVAR_INPUT_VIEWER("CDownOutlineMode"), BUTTON_OUTLINE_NOT_PRESSED)); } // L/R/Z if (CVarGetInteger(CVAR_INPUT_VIEWER("LBtn"), 1)) { ImGui::SetNextItemAllowOverlap(); ImGui::SetCursorPos(aPos); - RenderButton("L-Btn", "L-Btn Outline", pads[0].button & BTN_L, scaledBGSize, buttonOutlineMode); + RenderButton("L-Btn", "L-Btn Outline", pads[0].button & BTN_L, scaledBGSize, + useGlobalOutlineMode + ? buttonOutlineMode + : CVarGetInteger(CVAR_INPUT_VIEWER("LBtnOutlineMode"), BUTTON_OUTLINE_NOT_PRESSED)); } if (CVarGetInteger(CVAR_INPUT_VIEWER("RBtn"), 1)) { ImGui::SetNextItemAllowOverlap(); ImGui::SetCursorPos(aPos); - RenderButton("R-Btn", "R-Btn Outline", pads[0].button & BTN_R, scaledBGSize, buttonOutlineMode); + RenderButton("R-Btn", "R-Btn Outline", pads[0].button & BTN_R, scaledBGSize, + useGlobalOutlineMode + ? buttonOutlineMode + : CVarGetInteger(CVAR_INPUT_VIEWER("RBtnOutlineMode"), BUTTON_OUTLINE_NOT_PRESSED)); } if (CVarGetInteger(CVAR_INPUT_VIEWER("ZBtn"), 1)) { ImGui::SetNextItemAllowOverlap(); ImGui::SetCursorPos(aPos); - RenderButton("Z-Btn", "Z-Btn Outline", pads[0].button & BTN_Z, scaledBGSize, buttonOutlineMode); + RenderButton("Z-Btn", "Z-Btn Outline", pads[0].button & BTN_Z, scaledBGSize, + useGlobalOutlineMode + ? buttonOutlineMode + : CVarGetInteger(CVAR_INPUT_VIEWER("ZBtnOutlineMode"), BUTTON_OUTLINE_NOT_PRESSED)); } // Start @@ -229,7 +265,9 @@ void InputViewer::DrawElement() { ImGui::SetNextItemAllowOverlap(); ImGui::SetCursorPos(aPos); RenderButton("Start-Btn", "Start-Btn Outline", pads[0].button & BTN_START, scaledBGSize, - buttonOutlineMode); + useGlobalOutlineMode + ? buttonOutlineMode + : CVarGetInteger(CVAR_INPUT_VIEWER("StartBtnOutlineMode"), BUTTON_OUTLINE_NOT_PRESSED)); } // Dpad @@ -237,18 +275,46 @@ void InputViewer::DrawElement() { ImGui::SetNextItemAllowOverlap(); ImGui::SetCursorPos(aPos); RenderButton("Dpad-Left", "Dpad-Left Outline", pads[0].button & BTN_DLEFT, scaledBGSize, - buttonOutlineMode); + useGlobalOutlineMode + ? buttonOutlineMode + : CVarGetInteger(CVAR_INPUT_VIEWER("DpadOutlineMode"), BUTTON_OUTLINE_NOT_PRESSED)); ImGui::SetNextItemAllowOverlap(); ImGui::SetCursorPos(aPos); RenderButton("Dpad-Right", "Dpad-Right Outline", pads[0].button & BTN_DRIGHT, scaledBGSize, - buttonOutlineMode); + useGlobalOutlineMode + ? buttonOutlineMode + : CVarGetInteger(CVAR_INPUT_VIEWER("DpadOutlineMode"), BUTTON_OUTLINE_NOT_PRESSED)); ImGui::SetNextItemAllowOverlap(); ImGui::SetCursorPos(aPos); - RenderButton("Dpad-Up", "Dpad-Up Outline", pads[0].button & BTN_DUP, scaledBGSize, buttonOutlineMode); + RenderButton("Dpad-Up", "Dpad-Up Outline", pads[0].button & BTN_DUP, scaledBGSize, + useGlobalOutlineMode + ? buttonOutlineMode + : CVarGetInteger(CVAR_INPUT_VIEWER("DpadOutlineMode"), BUTTON_OUTLINE_NOT_PRESSED)); ImGui::SetNextItemAllowOverlap(); ImGui::SetCursorPos(aPos); RenderButton("Dpad-Down", "Dpad-Down Outline", pads[0].button & BTN_DDOWN, scaledBGSize, - buttonOutlineMode); + useGlobalOutlineMode + ? buttonOutlineMode + : CVarGetInteger(CVAR_INPUT_VIEWER("DpadOutlineMode"), BUTTON_OUTLINE_NOT_PRESSED)); + } + + // Modifier 1 + if (CVarGetInteger(CVAR_INPUT_VIEWER("Mod1"), 0)) { + ImGui::SetNextItemAllowOverlap(); + ImGui::SetCursorPos(aPos); + RenderButton("Modifier-1", "Modifier-1 Outline", pads[0].button & BTN_MODIFIER1, scaledBGSize, + useGlobalOutlineMode + ? buttonOutlineMode + : CVarGetInteger(CVAR_INPUT_VIEWER("Mod1OutlineMode"), BUTTON_OUTLINE_NOT_PRESSED)); + } + // Modifier 2 + if (CVarGetInteger(CVAR_INPUT_VIEWER("Mod2"), 0)) { + ImGui::SetNextItemAllowOverlap(); + ImGui::SetCursorPos(aPos); + RenderButton("Modifier-2", "Modifier-2 Outline", pads[0].button & BTN_MODIFIER2, scaledBGSize, + useGlobalOutlineMode + ? buttonOutlineMode + : CVarGetInteger(CVAR_INPUT_VIEWER("Mod2OutlineMode"), BUTTON_OUTLINE_NOT_PRESSED)); } const bool analogStickIsInDeadzone = !pads[0].stick_x && !pads[0].stick_y; @@ -359,9 +425,9 @@ InputViewerSettingsWindow::~InputViewerSettingsWindow() { } void InputViewerSettingsWindow::DrawElement() { - ImGui::SetNextWindowSize(ImVec2(450, 525), ImGuiCond_FirstUseEver); + ImGui::SetNextWindowSize(ImVec2(500, 525), ImGuiCond_FirstUseEver); - if (ImGui::Begin("Input Viewer Settings", &mIsVisible)) { + if (ImGui::Begin("Input Viewer Settings", &mIsVisible, ImGuiWindowFlags_HorizontalScrollbar)) { // gInputViewer.Scale UIWidgets::EnhancementSliderFloat("Input Viewer Scale: %.2f", "##Input", CVAR_INPUT_VIEWER("Scale"), 0.1f, 5.0f, "", @@ -381,47 +447,142 @@ void InputViewerSettingsWindow::DrawElement() { UIWidgets::PaddedSeparator(true, true); if (ImGui::CollapsingHeader("Buttons")) { + + // gInputViewer.ButtonOutlineMode + UIWidgets::PaddedText("Button Outlines/Backgrounds", true, false); + UIWidgets::EnhancementCombobox( + CVAR_INPUT_VIEWER("ButtonOutlineMode"), buttonOutlineOptions, BUTTON_OUTLINE_NOT_PRESSED, + !CVarGetInteger(CVAR_INPUT_VIEWER("UseGlobalButtonOutlineMode"), 1), "", + CVarGetInteger(CVAR_INPUT_VIEWER("ButtonOutlineMode"), BUTTON_OUTLINE_NOT_PRESSED)); + UIWidgets::Tooltip( + "Sets the desired visibility behavior for the button outline/background layers. Useful for " + "custom input viewers."); + + // gInputViewer.UseGlobalButtonOutlineMode + UIWidgets::EnhancementCheckbox("Use for all buttons", CVAR_INPUT_VIEWER("UseGlobalButtonOutlineMode"), false, "", + UIWidgets::CheckboxGraphics::Checkmark, true); + + UIWidgets::PaddedSeparator(); + + bool useIndividualOutlines = !CVarGetInteger(CVAR_INPUT_VIEWER("UseGlobalButtonOutlineMode"), 1); + // gInputViewer.ABtn UIWidgets::EnhancementCheckbox("Show A-Button Layers", CVAR_INPUT_VIEWER("ABtn"), false, "", UIWidgets::CheckboxGraphics::Checkmark, true); + if (useIndividualOutlines && CVarGetInteger(CVAR_INPUT_VIEWER("ABtn"), 1)) { + ImGui::Indent(); + UIWidgets::EnhancementCombobox(CVAR_INPUT_VIEWER("ABtnOutlineMode"), buttonOutlineOptionsVerbose, + BUTTON_OUTLINE_NOT_PRESSED); + ImGui::Unindent(); + } // gInputViewer.BBtn UIWidgets::EnhancementCheckbox("Show B-Button Layers", CVAR_INPUT_VIEWER("BBtn"), false, "", UIWidgets::CheckboxGraphics::Checkmark, true); + if (useIndividualOutlines && CVarGetInteger(CVAR_INPUT_VIEWER("BBtn"), 1)) { + ImGui::Indent(); + UIWidgets::EnhancementCombobox(CVAR_INPUT_VIEWER("BBtnOutlineMode"), buttonOutlineOptionsVerbose, + BUTTON_OUTLINE_NOT_PRESSED); + ImGui::Unindent(); + } // gInputViewer.CUp UIWidgets::EnhancementCheckbox("Show C-Up Layers", CVAR_INPUT_VIEWER("CUp"), false, "", UIWidgets::CheckboxGraphics::Checkmark, true); + if (useIndividualOutlines && CVarGetInteger(CVAR_INPUT_VIEWER("CUp"), 1)) { + ImGui::Indent(); + UIWidgets::EnhancementCombobox(CVAR_INPUT_VIEWER("CUpOutlineMode"), buttonOutlineOptionsVerbose, + BUTTON_OUTLINE_NOT_PRESSED); + ImGui::Unindent(); + } // gInputViewer.CRight UIWidgets::EnhancementCheckbox("Show C-Right Layers", CVAR_INPUT_VIEWER("CRight"), false, "", UIWidgets::CheckboxGraphics::Checkmark, true); + if (useIndividualOutlines && CVarGetInteger(CVAR_INPUT_VIEWER("CRight"), 1)) { + ImGui::Indent(); + UIWidgets::EnhancementCombobox(CVAR_INPUT_VIEWER("CRightOutlineMode"), buttonOutlineOptionsVerbose, + BUTTON_OUTLINE_NOT_PRESSED); + ImGui::Unindent(); + } // gInputViewer.CDown UIWidgets::EnhancementCheckbox("Show C-Down Layers", CVAR_INPUT_VIEWER("CDown"), false, "", UIWidgets::CheckboxGraphics::Checkmark, true); + if (useIndividualOutlines && CVarGetInteger(CVAR_INPUT_VIEWER("CDown"), 1)) { + ImGui::Indent(); + UIWidgets::EnhancementCombobox(CVAR_INPUT_VIEWER("CDownOutlineMode"), buttonOutlineOptionsVerbose, + BUTTON_OUTLINE_NOT_PRESSED); + ImGui::Unindent(); + } // gInputViewer.CLeft UIWidgets::EnhancementCheckbox("Show C-Left Layers", CVAR_INPUT_VIEWER("CLeft"), false, "", UIWidgets::CheckboxGraphics::Checkmark, true); + if (useIndividualOutlines && CVarGetInteger(CVAR_INPUT_VIEWER("CLeft"), 1)) { + ImGui::Indent(); + UIWidgets::EnhancementCombobox(CVAR_INPUT_VIEWER("CLeftOutlineMode"), buttonOutlineOptionsVerbose, + BUTTON_OUTLINE_NOT_PRESSED); + ImGui::Unindent(); + } // gInputViewer.LBtn UIWidgets::EnhancementCheckbox("Show L-Button Layers", CVAR_INPUT_VIEWER("LBtn"), false, "", UIWidgets::CheckboxGraphics::Checkmark, true); + if (useIndividualOutlines && CVarGetInteger(CVAR_INPUT_VIEWER("LBtn"), 1)) { + ImGui::Indent(); + UIWidgets::EnhancementCombobox(CVAR_INPUT_VIEWER("LBtnOutlineMode"), buttonOutlineOptionsVerbose, + BUTTON_OUTLINE_NOT_PRESSED); + ImGui::Unindent(); + } // gInputViewer.RBtn UIWidgets::EnhancementCheckbox("Show R-Button Layers", CVAR_INPUT_VIEWER("RBtn"), false, "", UIWidgets::CheckboxGraphics::Checkmark, true); + if (useIndividualOutlines && CVarGetInteger(CVAR_INPUT_VIEWER("RBtn"), 1)) { + ImGui::Indent(); + UIWidgets::EnhancementCombobox(CVAR_INPUT_VIEWER("RBtnOutlineMode"), buttonOutlineOptionsVerbose, + BUTTON_OUTLINE_NOT_PRESSED); + ImGui::Unindent(); + } // gInputViewer.ZBtn UIWidgets::EnhancementCheckbox("Show Z-Button Layers", CVAR_INPUT_VIEWER("ZBtn"), false, "", UIWidgets::CheckboxGraphics::Checkmark, true); + if (useIndividualOutlines && CVarGetInteger(CVAR_INPUT_VIEWER("ZBtn"), 1)) { + ImGui::Indent(); + UIWidgets::EnhancementCombobox(CVAR_INPUT_VIEWER("ZBtnOutlineMode"), buttonOutlineOptionsVerbose, + BUTTON_OUTLINE_NOT_PRESSED); + ImGui::Unindent(); + } // gInputViewer.StartBtn UIWidgets::EnhancementCheckbox("Show Start Button Layers", CVAR_INPUT_VIEWER("StartBtn"), false, "", UIWidgets::CheckboxGraphics::Checkmark, true); + if (useIndividualOutlines && CVarGetInteger(CVAR_INPUT_VIEWER("StartBtn"), 1)) { + ImGui::Indent(); + UIWidgets::EnhancementCombobox(CVAR_INPUT_VIEWER("StartBtnOutlineMode"), buttonOutlineOptionsVerbose, + BUTTON_OUTLINE_NOT_PRESSED); + ImGui::Unindent(); + } // gInputViewer.Dpad UIWidgets::EnhancementCheckbox("Show D-Pad Layers", CVAR_INPUT_VIEWER("Dpad"), false, "", UIWidgets::CheckboxGraphics::Checkmark, false); - - // gInputViewer.ButtonOutlineMode - UIWidgets::PaddedText("Button Outlines/Backgrounds", true, false); - UIWidgets::EnhancementCombobox(CVAR_INPUT_VIEWER("ButtonOutlineMode"), buttonOutlineOptions, - BUTTON_OUTLINE_NOT_PRESSED); - UIWidgets::Tooltip( - "Sets the desired visibility behavior for the button outline/background layers. Useful for " - "custom input viewers."); + if (useIndividualOutlines && CVarGetInteger(CVAR_INPUT_VIEWER("Dpad"), 0)) { + ImGui::Indent(); + UIWidgets::EnhancementCombobox(CVAR_INPUT_VIEWER("DpadOutlineMode"), buttonOutlineOptionsVerbose, + BUTTON_OUTLINE_NOT_PRESSED); + ImGui::Unindent(); + } + // gInputViewer.Mod1 + UIWidgets::EnhancementCheckbox("Show Modifier Button 1 Layers", CVAR_INPUT_VIEWER("Mod1"), false, "", + UIWidgets::CheckboxGraphics::Checkmark, false); + if (useIndividualOutlines && CVarGetInteger(CVAR_INPUT_VIEWER("Mod1"), 0)) { + ImGui::Indent(); + UIWidgets::EnhancementCombobox(CVAR_INPUT_VIEWER("Mod1OutlineMode"), buttonOutlineOptionsVerbose, + BUTTON_OUTLINE_NOT_PRESSED); + ImGui::Unindent(); + } + // gInputViewer.Mod2 + UIWidgets::EnhancementCheckbox("Show Modifier Button 2 Layers", CVAR_INPUT_VIEWER("Mod2"), false, "", + UIWidgets::CheckboxGraphics::Checkmark, false); + if (useIndividualOutlines && CVarGetInteger(CVAR_INPUT_VIEWER("Mod2"), 0)) { + ImGui::Indent(); + UIWidgets::EnhancementCombobox(CVAR_INPUT_VIEWER("Mod2OutlineMode"), buttonOutlineOptionsVerbose, + BUTTON_OUTLINE_NOT_PRESSED); + ImGui::Unindent(); + } UIWidgets::PaddedSeparator(true, true); } @@ -517,4 +678,4 @@ void InputViewerSettingsWindow::DrawElement() { ImGui::End(); } -} \ No newline at end of file +} From 08ad16e75046c2a1d8424b56571980775dc0296a Mon Sep 17 00:00:00 2001 From: Pepe20129 <72659707+Pepe20129@users.noreply.github.com> Date: Fri, 10 May 2024 07:17:50 +0200 Subject: [PATCH 35/59] Add path XML parser (#4115) * Add path XML parser * Update SetPathwaysFactory.cpp --- soh/soh/resource/importer/PathFactory.cpp | 55 +++++++++++++++++++ soh/soh/resource/importer/PathFactory.h | 6 ++ .../scenecommand/SetPathwaysFactory.cpp | 1 + soh/soh/resource/logging/PathLogger.cpp | 33 +++++++++++ soh/soh/resource/logging/PathLogger.h | 6 ++ 5 files changed, 101 insertions(+) create mode 100644 soh/soh/resource/logging/PathLogger.cpp create mode 100644 soh/soh/resource/logging/PathLogger.h diff --git a/soh/soh/resource/importer/PathFactory.cpp b/soh/soh/resource/importer/PathFactory.cpp index 00807b75afa..f0f92be0221 100644 --- a/soh/soh/resource/importer/PathFactory.cpp +++ b/soh/soh/resource/importer/PathFactory.cpp @@ -1,5 +1,6 @@ #include "soh/resource/importer/PathFactory.h" #include "soh/resource/type/Path.h" +#include "soh/resource/logging/PathLogger.h" #include "spdlog/spdlog.h" namespace SOH { @@ -35,6 +36,60 @@ std::shared_ptr ResourceFactoryBinaryPathV0::ReadResource(std:: path->pathData.push_back(pathDataEntry); } + if (CVarGetInteger(CVAR_DEVELOPER_TOOLS("ResourceLogging"), 0)) { + LogPathAsXML(path); + } + return path; } + +std::shared_ptr ResourceFactoryXMLPathV0::ReadResource(std::shared_ptr file) { + if (!FileHasValidFormatAndReader(file)) { + return nullptr; + } + + auto path = std::make_shared(file->InitData); + auto reader = std::get>(file->Reader); + + auto pathElement = reader->RootElement(); + + //path->numPaths = pathElement->IntAttribute("NumPaths"); + //path->paths.reserve(path->numPaths); + + auto pathDataElement = pathElement->FirstChildElement(); + + while (pathDataElement != nullptr) { + std::vector points; + //uint32_t pointCount = pathDataElement->IntAttribute("NumPoints"); + //points.reserve(pointCount); + + auto pointElement = pathDataElement->FirstChildElement(); + + while (pointElement != nullptr) { + Vec3s point; + point.x = pointElement->IntAttribute("X"); + point.y = pointElement->IntAttribute("Y"); + point.z = pointElement->IntAttribute("Z"); + + points.push_back(point); + + pointElement = pointElement->NextSiblingElement(); + } + + PathData pathDataEntry; + //pathDataEntry.count = pointCount; + pathDataEntry.count = points.size(); + + path->paths.push_back(points); + pathDataEntry.points = path->paths.back().data(); + + path->pathData.push_back(pathDataEntry); + + pathDataElement = pathDataElement->NextSiblingElement(); + } + + path->numPaths = path->paths.size(); + + return path; +}; } // namespace SOH diff --git a/soh/soh/resource/importer/PathFactory.h b/soh/soh/resource/importer/PathFactory.h index ddbee772df4..9dd73b11025 100644 --- a/soh/soh/resource/importer/PathFactory.h +++ b/soh/soh/resource/importer/PathFactory.h @@ -2,10 +2,16 @@ #include "Resource.h" #include "ResourceFactoryBinary.h" +#include "ResourceFactoryXML.h" namespace SOH { class ResourceFactoryBinaryPathV0 : public Ship::ResourceFactoryBinary { public: std::shared_ptr ReadResource(std::shared_ptr file) override; }; + +class ResourceFactoryXMLPathV0 : public Ship::ResourceFactoryXML { + public: + std::shared_ptr ReadResource(std::shared_ptr file) override; +}; } // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.cpp b/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.cpp index 65af2e0de31..ed368123536 100644 --- a/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.cpp @@ -17,6 +17,7 @@ SetPathwaysFactory::ReadResource(std::shared_ptr initDat std::string pathFileName = reader->ReadString(); auto path = std::static_pointer_cast(Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(pathFileName.c_str())); setPathways->paths.push_back(path->GetPointer()); + setPathways->pathFileNames.push_back(pathFileName); } if (CVarGetInteger(CVAR_DEVELOPER_TOOLS("ResourceLogging"), 0)) { diff --git a/soh/soh/resource/logging/PathLogger.cpp b/soh/soh/resource/logging/PathLogger.cpp new file mode 100644 index 00000000000..5c216c9ff96 --- /dev/null +++ b/soh/soh/resource/logging/PathLogger.cpp @@ -0,0 +1,33 @@ +#include "soh/resource/type/Path.h" +#include "spdlog/spdlog.h" + +namespace SOH { + void LogPathAsXML(std::shared_ptr resource) { + std::shared_ptr path = std::static_pointer_cast(resource); + + tinyxml2::XMLDocument doc; + tinyxml2::XMLElement* root = doc.NewElement("Path"); + doc.InsertFirstChild(root); + + for (size_t i = 0; i < path->paths.size(); i += 1) { + tinyxml2::XMLElement* pathData = doc.NewElement("PathData"); + + for (size_t j = 0; j < path->paths[i].size(); j += 1) { + tinyxml2::XMLElement* pathPoint = doc.NewElement("PathPoint"); + + pathPoint->SetAttribute("X", path->paths[i][j].x); + pathPoint->SetAttribute("Y", path->paths[i][j].y); + pathPoint->SetAttribute("Z", path->paths[i][j].z); + + pathData->InsertEndChild(pathPoint); + } + + root->InsertEndChild(pathData); + } + + tinyxml2::XMLPrinter printer; + doc.Accept(&printer); + + SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr()); + } +} \ No newline at end of file diff --git a/soh/soh/resource/logging/PathLogger.h b/soh/soh/resource/logging/PathLogger.h new file mode 100644 index 00000000000..a5e42aeaf85 --- /dev/null +++ b/soh/soh/resource/logging/PathLogger.h @@ -0,0 +1,6 @@ +#include "Resource.h" +#include "soh/OTRGlobals.h" + +namespace SOH { + void LogPathAsXML(std::shared_ptr resource); +} \ No newline at end of file From ad0e17383e72c652541e6a90367ab720c6a18723 Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Thu, 16 May 2024 14:55:04 -0400 Subject: [PATCH 36/59] update nightly links in readme (#4147) --- README.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/README.md b/README.md index ad80f7f2f56..233ef86d9e3 100644 --- a/README.md +++ b/README.md @@ -91,10 +91,7 @@ If you want to playtest a continuous integration build, you can find them at the * [Windows](https://nightly.link/HarbourMasters/Shipwright/workflows/generate-builds/develop/soh-windows.zip) * [macOS](https://nightly.link/HarbourMasters/Shipwright/workflows/generate-builds/develop/soh-mac.zip) -* [Linux (performance)](https://nightly.link/HarbourMasters/Shipwright/workflows/generate-builds/develop/soh-linux-performance.zip) _(requires `glibc 2.35` or newer, but will be more performant than the compatibility build.)_ -* [Linux (compatibility)](https://nightly.link/HarbourMasters/Shipwright/workflows/generate-builds/develop/soh-linux-compatibility.zip) _(compatible with most Linux distributions, but may not be as performant as the performance build.)_ -* [Switch](https://nightly.link/HarbourMasters/Shipwright/workflows/generate-builds/develop/soh-switch.zip) -* [Wii U](https://nightly.link/HarbourMasters/Shipwright/workflows/generate-builds/develop/soh-wiiu.zip) +* [Linux](https://nightly.link/HarbourMasters/Shipwright/workflows/generate-builds/develop/soh-linux.zip) From 53efc22a23efd7bc76733efa00a35d67b798ae29 Mon Sep 17 00:00:00 2001 From: Lywx Date: Mon, 27 May 2024 16:33:02 -0600 Subject: [PATCH 37/59] Framebuffer clear and bump LUS (#4187) --- CMakeLists.txt | 6 ++++++ OTRExporter | 2 +- ZAPDTR | 2 +- libultraship | 2 +- soh/CMakeLists.txt | 4 ++++ soh/include/functions.h | 2 -- soh/soh/GbiWrap.cpp | 9 --------- soh/src/code/z_rcp.c | 8 ++++---- 8 files changed, 17 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 891d6ad26cd..490489f5576 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -84,6 +84,12 @@ include(CMake/GlobalSettingsInclude.cmake OPTIONAL) ################################################################################ set_property(GLOBAL PROPERTY USE_FOLDERS ON) +################################################################################ +# Set GBI version +################################################################################ + +add_compile_definitions(F3DEX_GBI_2) + ################################################################################ # Sub-projects ################################################################################ diff --git a/OTRExporter b/OTRExporter index 3cea9ee7c01..d70db9806c0 160000 --- a/OTRExporter +++ b/OTRExporter @@ -1 +1 @@ -Subproject commit 3cea9ee7c017d842aa4d9ceeb8d3ffbf29c6effb +Subproject commit d70db9806c02c229ca3ed928ad0bdae128fe4ac7 diff --git a/ZAPDTR b/ZAPDTR index f38a9c92eb9..04d42249d2c 160000 --- a/ZAPDTR +++ b/ZAPDTR @@ -1 +1 @@ -Subproject commit f38a9c92eb99368c0607acf356d5651ebdc96f51 +Subproject commit 04d42249d2c15c3b442a0282a90bc8b7bda25b03 diff --git a/libultraship b/libultraship index 0da318c0f4e..9def18e6246 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit 0da318c0f4e431313565cad546fc469b8e850388 +Subproject commit 9def18e62467b4225d26e206e0039a31ed406573 diff --git a/soh/CMakeLists.txt b/soh/CMakeLists.txt index 3f086bcac64..6984291d339 100644 --- a/soh/CMakeLists.txt +++ b/soh/CMakeLists.txt @@ -407,6 +407,7 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Windows") ">" "$<$:ENABLE_REMOTE_CONTROL>" "INCLUDE_GAME_PRINTF;" + "F3DEX_GBI_2" "UNICODE;" "_UNICODE" STORMLIB_NO_AUTO_LINK @@ -425,6 +426,7 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Windows") "NDEBUG;" ">" "INCLUDE_GAME_PRINTF;" + "F3DEX_GBI_2" "WIN32;" "UNICODE;" "_UNICODE" @@ -440,6 +442,7 @@ elseif (CMAKE_SYSTEM_NAME STREQUAL "CafeOS") "$<$:" "NDEBUG" ">" + "F3DEX_GBI_2" "SPDLOG_ACTIVE_LEVEL=3;" "SPDLOG_NO_THREAD_ID;" "SPDLOG_NO_TLS;" @@ -453,6 +456,7 @@ elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU|Clang|AppleClang") "$<$:" "NDEBUG" ">" + "F3DEX_GBI_2" "$<$:ENABLE_REMOTE_CONTROL>" "SPDLOG_ACTIVE_LEVEL=0;" "_CONSOLE;" diff --git a/soh/include/functions.h b/soh/include/functions.h index b9e1f69819f..fc7fc15b786 100644 --- a/soh/include/functions.h +++ b/soh/include/functions.h @@ -22,12 +22,10 @@ extern "C" void gSPSegment(void* value, int segNum, uintptr_t target); void gSPSegmentLoadRes(void* value, int segNum, uintptr_t target); -void gDPSetTextureImage(Gfx* pkt, u32 f, u32 s, u32 w, uintptr_t i); void gSPDisplayList(Gfx* pkt, Gfx* dl); void gSPDisplayListOffset(Gfx* pkt, Gfx* dl, int offset); void gSPVertex(Gfx* pkt, uintptr_t v, int n, int v0); void gSPInvalidateTexCache(Gfx* pkt, uintptr_t texAddr); -void gDPSetTextureImageFB(Gfx* pkt, u32 format, u32 size, u32 width, int fb); void cleararena(void); diff --git a/soh/soh/GbiWrap.cpp b/soh/soh/GbiWrap.cpp index 2399051f538..2dad29e606c 100644 --- a/soh/soh/GbiWrap.cpp +++ b/soh/soh/GbiWrap.cpp @@ -66,15 +66,6 @@ extern "C" void gSPSegmentLoadRes(void* value, int segNum, uintptr_t target) { __gSPSegment(value, segNum, target); } -extern "C" void gDPSetTextureImage(Gfx* pkt, u32 format, u32 size, u32 width, uintptr_t i) { - __gDPSetTextureImage(pkt, format, size, width, i); -} - -extern "C" void gDPSetTextureImageFB(Gfx* pkt, u32 format, u32 size, u32 width, int fb) -{ - __gDPSetTextureImageFB(pkt, format, size, width, fb); -} - extern "C" void gSPDisplayList(Gfx* pkt, Gfx* dl) { char* imgData = (char*)dl; diff --git a/soh/src/code/z_rcp.c b/soh/src/code/z_rcp.c index adfa946e738..978c04d3cee 100644 --- a/soh/src/code/z_rcp.c +++ b/soh/src/code/z_rcp.c @@ -1539,7 +1539,7 @@ void Gfx_SetupFrame(GraphicsContext* gfxCtx, u8 r, u8 g, u8 b) { gDPSetCycleType(POLY_OPA_DISP++, G_CYC_FILL); gDPSetRenderMode(POLY_OPA_DISP++, G_RM_NOOP, G_RM_NOOP2); gDPSetFillColor(POLY_OPA_DISP++, (GPACK_ZDZ(G_MAXFBZ, 0) << 16) | GPACK_ZDZ(G_MAXFBZ, 0)); - gDPFillRectangle(POLY_OPA_DISP++, 0, letterboxSize, gScreenWidth - 1, gScreenHeight - letterboxSize - 1); + gDPFillWideRectangle(POLY_OPA_DISP++, OTRGetRectDimensionFromLeftEdge(0), letterboxSize, OTRGetRectDimensionFromRightEdge(gScreenWidth - 1), gScreenHeight - letterboxSize - 1); gDPPipeSync(POLY_OPA_DISP++); // Fill the whole screen with the base color @@ -1548,7 +1548,7 @@ void Gfx_SetupFrame(GraphicsContext* gfxCtx, u8 r, u8 g, u8 b) { gDPSetCycleType(POLY_OPA_DISP++, G_CYC_FILL); gDPSetRenderMode(POLY_OPA_DISP++, G_RM_NOOP, G_RM_NOOP2); gDPSetFillColor(POLY_OPA_DISP++, (GPACK_RGBA5551(r, g, b, 1) << 16) | GPACK_RGBA5551(r, g, b, 1)); - gDPFillRectangle(POLY_OPA_DISP++, 0, letterboxSize, gScreenWidth - 1, gScreenHeight - letterboxSize - 1); + gDPFillWideRectangle(POLY_OPA_DISP++, OTRGetRectDimensionFromLeftEdge(0), letterboxSize, OTRGetRectDimensionFromRightEdge(gScreenWidth - 1), gScreenHeight - letterboxSize - 1); gDPPipeSync(POLY_OPA_DISP++); // Draw the letterbox if applicable (uses the same color as the screen base) @@ -1557,8 +1557,8 @@ void Gfx_SetupFrame(GraphicsContext* gfxCtx, u8 r, u8 g, u8 b) { gDPSetCycleType(OVERLAY_DISP++, G_CYC_FILL); gDPSetRenderMode(OVERLAY_DISP++, G_RM_NOOP, G_RM_NOOP2); gDPSetFillColor(OVERLAY_DISP++, (GPACK_RGBA5551(r, g, b, 1) << 16) | GPACK_RGBA5551(r, g, b, 1)); - gDPFillRectangle(OVERLAY_DISP++, 0, 0, gScreenWidth - 1, letterboxSize - 1); - gDPFillRectangle(OVERLAY_DISP++, 0, gScreenHeight - letterboxSize, gScreenWidth - 1, gScreenHeight - 1); + gDPFillWideRectangle(OVERLAY_DISP++, OTRGetRectDimensionFromLeftEdge(0), 0, OTRGetRectDimensionFromRightEdge(gScreenWidth - 1), letterboxSize - 1); + gDPFillWideRectangle(OVERLAY_DISP++, OTRGetRectDimensionFromLeftEdge(0), gScreenHeight - letterboxSize, OTRGetRectDimensionFromRightEdge(gScreenWidth - 1), gScreenHeight - 1); gDPPipeSync(OVERLAY_DISP++); } } From b8c7c715785a113142d3fc00d2a28f9b52eeb33b Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Sun, 2 Jun 2024 12:13:03 -0400 Subject: [PATCH 38/59] allow setting device visibility in controller mapping window (#4165) --- .../controls/SohInputEditorWindow.cpp | 256 ++++++------------ .../controls/SohInputEditorWindow.h | 4 +- 2 files changed, 82 insertions(+), 178 deletions(-) diff --git a/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp b/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp index 667d96c18ec..a5c1364b88f 100644 --- a/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp +++ b/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp @@ -38,6 +38,13 @@ void SohInputEditorWindow::InitElement() { addButtonName(BTN_DLEFT, "D-pad left"); addButtonName(BTN_DRIGHT, "D-pad right"); addButtonName(0, "None"); + + mDeviceIndexVisiblity.clear(); + mDeviceIndexVisiblity[Ship::ShipDeviceIndex::Keyboard] = true; + mDeviceIndexVisiblity[Ship::ShipDeviceIndex::Blue] = true; + for (auto index = 1; index < Ship::ShipDeviceIndex::Max; index++) { + mDeviceIndexVisiblity[static_cast(index)] = false; + } } #define INPUT_EDITOR_WINDOW_GAME_INPUT_BLOCK_ID 95237929 @@ -251,6 +258,9 @@ void SohInputEditorWindow::DrawButtonLineEditMappingButton(uint8_t port, uint16_ if (mapping == nullptr) { return; } + if (!mDeviceIndexVisiblity[mapping->GetShipDeviceIndex()]) { + return; + } ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0.0f, 0.5f)); std::string icon = ""; @@ -521,6 +531,9 @@ void SohInputEditorWindow::DrawStickDirectionLineEditMappingButton(uint8_t port, if (mapping == nullptr) { return; } + if (!mDeviceIndexVisiblity[mapping->GetShipDeviceIndex()]) { + return; + } ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0.0f, 0.5f)); std::string icon = ""; @@ -1705,11 +1718,75 @@ void SohInputEditorWindow::DrawMiscControlPanel() { Ship::GuiWindow::EndGroupPanel(0); } +void SohInputEditorWindow::DrawDeviceVisibilityButtons() { + std::map> indexMappings; + for (auto [lusIndex, mapping] : Ship::Context::GetInstance() + ->GetControlDeck() + ->GetDeviceIndexMappingManager() + ->GetAllDeviceIndexMappingsFromConfig()) { + auto sdlIndexMapping = std::static_pointer_cast(mapping); + if (sdlIndexMapping == nullptr) { + continue; + } + + indexMappings[lusIndex] = { sdlIndexMapping->GetSDLControllerName(), -1 }; + } + + for (auto [lusIndex, mapping] : Ship::Context::GetInstance() + ->GetControlDeck() + ->GetDeviceIndexMappingManager() + ->GetAllDeviceIndexMappings()) { + auto sdlIndexMapping = std::static_pointer_cast(mapping); + if (sdlIndexMapping == nullptr) { + continue; + } + + indexMappings[lusIndex] = { sdlIndexMapping->GetSDLControllerName(), sdlIndexMapping->GetSDLDeviceIndex() }; + } + + auto keyboardButtonColor = ImGui::GetStyleColorVec4(ImGuiCol_Button); + auto keyboardButtonHoveredColor = ImGui::GetStyleColorVec4(ImGuiCol_ButtonHovered); + GetButtonColorsForLUSDeviceIndex(Ship::ShipDeviceIndex::Keyboard, keyboardButtonColor, keyboardButtonHoveredColor); + ImGui::PushStyleColor(ImGuiCol_Button, keyboardButtonColor); + ImGui::PushStyleColor(ImGuiCol_ButtonHovered, keyboardButtonHoveredColor); + bool keyboardVisible = mDeviceIndexVisiblity[Ship::ShipDeviceIndex::Keyboard]; + if(ImGui::Button( + StringHelper::Sprintf("%s %s Keyboard", keyboardVisible ? ICON_FA_EYE : ICON_FA_EYE_SLASH, ICON_FA_KEYBOARD_O) + .c_str())) { + mDeviceIndexVisiblity[Ship::ShipDeviceIndex::Keyboard] = !keyboardVisible; + } + ImGui::PopStyleColor(); + ImGui::PopStyleColor(); + + + for (auto [lusIndex, info] : indexMappings) { + auto [name, sdlIndex] = info; + bool connected = sdlIndex != -1; + + auto buttonColor = ImGui::GetStyleColorVec4(ImGuiCol_Button); + auto buttonHoveredColor = ImGui::GetStyleColorVec4(ImGuiCol_ButtonHovered); + GetButtonColorsForLUSDeviceIndex(lusIndex, buttonColor, buttonHoveredColor); + + ImGui::PushStyleColor(ImGuiCol_Button, buttonColor); + ImGui::PushStyleColor(ImGuiCol_ButtonHovered, buttonHoveredColor); + bool visible = mDeviceIndexVisiblity[lusIndex]; + if(ImGui::Button( + StringHelper::Sprintf("%s %s %s (%s)", visible ? ICON_FA_EYE : ICON_FA_EYE_SLASH, connected ? ICON_FA_GAMEPAD : ICON_FA_CHAIN_BROKEN, name.c_str(), + connected ? StringHelper::Sprintf("SDL %d", sdlIndex).c_str() : "Disconnected") + .c_str())) { + mDeviceIndexVisiblity[lusIndex] = !visible; + } + ImGui::PopStyleColor(); + ImGui::PopStyleColor(); + } +} + void SohInputEditorWindow::DrawLinkTab() { uint8_t portIndex = 0; if (ImGui::BeginTabItem(StringHelper::Sprintf("Link (P1)###port%d", portIndex).c_str())) { DrawClearAllButton(portIndex); DrawSetDefaultsButton(portIndex); + DrawDeviceVisibilityButtons(); UpdateBitmaskToMappingIds(portIndex); UpdateStickDirectionToMappingIds(portIndex); @@ -1848,6 +1925,7 @@ void SohInputEditorWindow::DrawIvanTab() { if (ImGui::BeginTabItem(StringHelper::Sprintf("Ivan (P2)###port%d", portIndex).c_str())) { DrawClearAllButton(portIndex); DrawSetDefaultsButton(portIndex); + DrawDeviceVisibilityButtons(); UpdateBitmaskToMappingIds(portIndex); UpdateStickDirectionToMappingIds(portIndex); @@ -1903,6 +1981,7 @@ void SohInputEditorWindow::DrawDebugPortTab(uint8_t portIndex, std::string custo : customName.c_str())) { DrawClearAllButton(portIndex); DrawSetDefaultsButton(portIndex); + DrawDeviceVisibilityButtons(); UpdateBitmaskToMappingIds(portIndex); UpdateStickDirectionToMappingIds(portIndex); @@ -1972,133 +2051,6 @@ void SohInputEditorWindow::DrawClearAllButton(uint8_t portIndex) { } } -#ifdef __WIIU__ -void SohInputEditorWindow::DrawSetDefaultsButton(uint8_t portIndex) { - ImGui::SameLine(); - ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(1.0f, 0.5f)); - auto popupId = StringHelper::Sprintf("setDefaultsPopup##%d", portIndex); - if (ImGui::Button(StringHelper::Sprintf("Set defaults...##%d", portIndex).c_str())) { - ImGui::OpenPopup(popupId.c_str()); - } - ImGui::PopStyleVar(); - - if (ImGui::BeginPopup(popupId.c_str())) { - std::map> indexMappings; - for (auto [lusIndex, mapping] : Ship::Context::GetInstance() - ->GetControlDeck() - ->GetDeviceIndexMappingManager() - ->GetAllDeviceIndexMappings()) { - auto wiiuIndexMapping = std::static_pointer_cast(mapping); - if (wiiuIndexMapping == nullptr) { - continue; - } - - indexMappings[lusIndex] = { wiiuIndexMapping->GetWiiUControllerName(), - wiiuIndexMapping->IsWiiUGamepad() ? INT32_MAX - : wiiuIndexMapping->GetDeviceChannel() }; - } - - bool shouldClose = false; - for (auto [lusIndex, info] : indexMappings) { - auto [name, wiiuChannel] = info; - bool isGamepad = wiiuChannel == INT32_MAX; - - auto buttonColor = ImGui::GetStyleColorVec4(ImGuiCol_Button); - auto buttonHoveredColor = ImGui::GetStyleColorVec4(ImGuiCol_ButtonHovered); - GetButtonColorsForLUSDeviceIndex(lusIndex, buttonColor, buttonHoveredColor); - ImGui::PushStyleColor(ImGuiCol_Button, buttonColor); - ImGui::PushStyleColor(ImGuiCol_ButtonHovered, buttonHoveredColor); - - auto fancyName = StringHelper::Sprintf( - "%s%s", name.c_str(), isGamepad ? "" : StringHelper::Sprintf(" (%d)", wiiuChannel).c_str()); - if (ImGui::Button(StringHelper::Sprintf("%s %s", ICON_FA_GAMEPAD, fancyName.c_str()).c_str())) { - ImGui::OpenPopup(StringHelper::Sprintf("Set Defaults for %s", name.c_str()).c_str()); - } - ImGui::PopStyleColor(); - ImGui::PopStyleColor(); - if (ImGui::BeginPopupModal(StringHelper::Sprintf("Set Defaults for %s", name.c_str()).c_str(), NULL, - ImGuiWindowFlags_AlwaysAutoResize)) { - ImGui::Text("This will clear all existing mappings for\n%s on port %d.\n\nContinue?", fancyName.c_str(), - portIndex + 1); - if (ImGui::Button("Cancel")) { - shouldClose = true; - ImGui::CloseCurrentPopup(); - } - if (ImGui::Button("Set defaults")) { - Ship::Context::GetInstance() - ->GetControlDeck() - ->GetControllerByPort(portIndex) - ->ClearAllMappingsForDevice(lusIndex); - Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(portIndex)->AddDefaultMappings( - lusIndex); - shouldClose = true; - ImGui::CloseCurrentPopup(); - } - ImGui::EndPopup(); - } - } - - if (ImGui::Button("Cancel") || shouldClose) { - ImGui::CloseCurrentPopup(); - } - - ImGui::EndPopup(); - } -} - -void SohInputEditorWindow::DrawDevicesTab() { - if (ImGui::BeginTabItem("Devices")) { - std::map> indexMappings; - for (auto [lusIndex, mapping] : Ship::Context::GetInstance() - ->GetControlDeck() - ->GetDeviceIndexMappingManager() - ->GetAllDeviceIndexMappingsFromConfig()) { - auto wiiuIndexMapping = std::static_pointer_cast(mapping); - if (wiiuIndexMapping == nullptr) { - continue; - } - - indexMappings[lusIndex] = { wiiuIndexMapping->GetWiiUControllerName(), -1 }; - } - - for (auto [lusIndex, mapping] : Ship::Context::GetInstance() - ->GetControlDeck() - ->GetDeviceIndexMappingManager() - ->GetAllDeviceIndexMappings()) { - auto wiiuIndexMapping = std::static_pointer_cast(mapping); - if (wiiuIndexMapping == nullptr) { - continue; - } - - indexMappings[lusIndex] = { wiiuIndexMapping->GetWiiUControllerName(), - wiiuIndexMapping->IsWiiUGamepad() ? INT32_MAX - : wiiuIndexMapping->GetDeviceChannel() }; - } - - for (auto [lusIndex, info] : indexMappings) { - auto [name, wiiuChannel] = info; - bool connected = wiiuChannel != -1; - bool isGamepad = wiiuChannel == INT32_MAX; - - auto buttonColor = ImGui::GetStyleColorVec4(ImGuiCol_Button); - auto buttonHoveredColor = ImGui::GetStyleColorVec4(ImGuiCol_ButtonHovered); - GetButtonColorsForLUSDeviceIndex(lusIndex, buttonColor, buttonHoveredColor); - ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true); - ImGui::PushStyleColor(ImGuiCol_Button, buttonColor); - ImGui::Button(StringHelper::Sprintf("%s %s%s", connected ? ICON_FA_GAMEPAD : ICON_FA_CHAIN_BROKEN, - name.c_str(), - !connected ? " (Disconnected)" - : isGamepad ? "" - : StringHelper::Sprintf(" (%d)", wiiuChannel).c_str()) - .c_str()); - ImGui::PopStyleColor(); - ImGui::PopItemFlag(); - } - - ImGui::EndTabItem(); - } -} -#else void SohInputEditorWindow::DrawSetDefaultsButton(uint8_t portIndex) { ImGui::SameLine(); auto popupId = StringHelper::Sprintf("setDefaultsPopup##%d", portIndex); @@ -2192,55 +2144,6 @@ void SohInputEditorWindow::DrawSetDefaultsButton(uint8_t portIndex) { } } -void SohInputEditorWindow::DrawDevicesTab() { - if (ImGui::BeginTabItem("Devices")) { - std::map> indexMappings; - for (auto [lusIndex, mapping] : Ship::Context::GetInstance() - ->GetControlDeck() - ->GetDeviceIndexMappingManager() - ->GetAllDeviceIndexMappingsFromConfig()) { - auto sdlIndexMapping = std::static_pointer_cast(mapping); - if (sdlIndexMapping == nullptr) { - continue; - } - - indexMappings[lusIndex] = { sdlIndexMapping->GetSDLControllerName(), -1 }; - } - - for (auto [lusIndex, mapping] : Ship::Context::GetInstance() - ->GetControlDeck() - ->GetDeviceIndexMappingManager() - ->GetAllDeviceIndexMappings()) { - auto sdlIndexMapping = std::static_pointer_cast(mapping); - if (sdlIndexMapping == nullptr) { - continue; - } - - indexMappings[lusIndex] = { sdlIndexMapping->GetSDLControllerName(), sdlIndexMapping->GetSDLDeviceIndex() }; - } - - for (auto [lusIndex, info] : indexMappings) { - auto [name, sdlIndex] = info; - bool connected = sdlIndex != -1; - - auto buttonColor = ImGui::GetStyleColorVec4(ImGuiCol_Button); - auto buttonHoveredColor = ImGui::GetStyleColorVec4(ImGuiCol_ButtonHovered); - GetButtonColorsForLUSDeviceIndex(lusIndex, buttonColor, buttonHoveredColor); - ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true); - ImGui::PushStyleColor(ImGuiCol_Button, buttonColor); - ImGui::Button( - StringHelper::Sprintf("%s %s (%s)", connected ? ICON_FA_GAMEPAD : ICON_FA_CHAIN_BROKEN, name.c_str(), - connected ? StringHelper::Sprintf("SDL %d", sdlIndex).c_str() : "Disconnected") - .c_str()); - ImGui::PopStyleColor(); - ImGui::PopItemFlag(); - } - - ImGui::EndTabItem(); - } -} -#endif - void SohInputEditorWindow::DrawElement() { ImGui::Begin("Controller Configuration###sohControllerConfigWindowV1", &mIsVisible); ImGui::BeginTabBar("##ControllerConfigPortTabs"); @@ -2250,7 +2153,6 @@ void SohInputEditorWindow::DrawElement() { DrawDebugPortTab(2); DrawDebugPortTab(3); } - DrawDevicesTab(); ImGui::EndTabBar(); ImGui::End(); } diff --git a/soh/soh/Enhancements/controls/SohInputEditorWindow.h b/soh/soh/Enhancements/controls/SohInputEditorWindow.h index b418a041ea0..aa2c3f4f40b 100644 --- a/soh/soh/Enhancements/controls/SohInputEditorWindow.h +++ b/soh/soh/Enhancements/controls/SohInputEditorWindow.h @@ -92,7 +92,6 @@ class SohInputEditorWindow : public Ship::GuiWindow { void DrawLinkTab(); void DrawIvanTab(); void DrawDebugPortTab(uint8_t portIndex, std::string customName = ""); - void DrawDevicesTab(); std::set mButtonsBitmasks; std::set mDpadBitmasks; std::set mModifierButtonsBitmasks; @@ -104,4 +103,7 @@ class SohInputEditorWindow : public Ship::GuiWindow { bool mInputEditorPopupOpen; void DrawSetDefaultsButton(uint8_t portIndex); void DrawClearAllButton(uint8_t portIndex); + + std::map mDeviceIndexVisiblity; + void DrawDeviceVisibilityButtons(); }; From 736dccb00b161a007a387b04267bdc30ef91e0af Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Sun, 2 Jun 2024 15:34:53 -0400 Subject: [PATCH 39/59] update to latest LUS main (#4202) Includes supporting changes from: * https://github.com/HarbourMasters/Shipwright/pull/4197 (alt assets variable changes) * https://github.com/HarbourMasters/Shipwright/pull/4199 (WindowBackend enum changes) * https://github.com/HarbourMasters/Shipwright/pull/4200 (Extract gMtxClear) --------- Co-authored-by: Malkierian Co-authored-by: inspectredc --- CMake/lus-cvars.cmake | 1 - libultraship | 2 +- soh/assets/xml/GC_MQ_D/code/sys_matrix.xml | 5 +++ .../xml/GC_MQ_D/scenes/dungeons/bdan.xml | 1 + .../xml/GC_MQ_D/scenes/dungeons/bdan_boss.xml | 1 + .../xml/GC_MQ_PAL_F/code/sys_matrix.xml | 5 +++ .../xml/GC_MQ_PAL_F/scenes/dungeons/bdan.xml | 1 + .../GC_MQ_PAL_F/scenes/dungeons/bdan_boss.xml | 1 + soh/assets/xml/GC_NMQ_D/code/sys_matrix.xml | 5 +++ .../xml/GC_NMQ_D/scenes/dungeons/bdan.xml | 1 + .../GC_NMQ_D/scenes/dungeons/bdan_boss.xml | 1 + .../xml/GC_NMQ_PAL_F/code/sys_matrix.xml | 5 +++ .../xml/GC_NMQ_PAL_F/scenes/dungeons/bdan.xml | 1 + .../scenes/dungeons/bdan_boss.xml | 1 + soh/assets/xml/N64_PAL_10/code/sys_matrix.xml | 5 +++ .../xml/N64_PAL_10/scenes/dungeons/bdan.xml | 1 + .../N64_PAL_10/scenes/dungeons/bdan_boss.xml | 1 + soh/assets/xml/N64_PAL_11/code/sys_matrix.xml | 5 +++ .../xml/N64_PAL_11/scenes/dungeons/bdan.xml | 1 + .../N64_PAL_11/scenes/dungeons/bdan_boss.xml | 1 + soh/soh/OTRGlobals.cpp | 31 ++++++++++--------- soh/soh/OTRGlobals.h | 1 + soh/soh/SohGui.cpp | 1 - soh/soh/SohMenuBar.cpp | 27 ++++++---------- soh/soh/resource/type/Skeleton.cpp | 7 ++--- soh/src/code/game.c | 2 +- soh/src/code/gfxprint.c | 2 +- 27 files changed, 75 insertions(+), 41 deletions(-) create mode 100644 soh/assets/xml/GC_MQ_D/code/sys_matrix.xml create mode 100644 soh/assets/xml/GC_MQ_PAL_F/code/sys_matrix.xml create mode 100644 soh/assets/xml/GC_NMQ_D/code/sys_matrix.xml create mode 100644 soh/assets/xml/GC_NMQ_PAL_F/code/sys_matrix.xml create mode 100644 soh/assets/xml/N64_PAL_10/code/sys_matrix.xml create mode 100644 soh/assets/xml/N64_PAL_11/code/sys_matrix.xml diff --git a/CMake/lus-cvars.cmake b/CMake/lus-cvars.cmake index e7376cfe28d..dee8f8c084f 100644 --- a/CMake/lus-cvars.cmake +++ b/CMake/lus-cvars.cmake @@ -16,7 +16,6 @@ set(CVAR_STATS_WINDOW_OPEN "${CVAR_PREFIX_WINDOW}.Stats" CACHE STRING "") set(CVAR_ENABLE_MULTI_VIEWPORTS "${CVAR_PREFIX_SETTING}.EnableMultiViewports" CACHE STRING "") set(CVAR_LOW_RES_MODE "${CVAR_PREFIX_SETTING}.LowResMode" CACHE STRING "") set(CVAR_SIMULATED_INPUT_LAG "${CVAR_PREFIX_SETTING}.SimulatedInputLag" CACHE STRING "") -set(CVAR_ALT_ASSETS "${CVAR_PREFIX_ENHANCEMENT}.AltAssets" CACHE STRING "") set(CVAR_GAME_OVERLAY_FONT "${CVAR_PREFIX_SETTING}.OverlayFont" CACHE STRING "") set(CVAR_MENU_BAR_OPEN "${CVAR_PREFIX_SETTING}.OpenMenuBar" CACHE STRING "") set(CVAR_PREFIX_CONTROLLERS "${CVAR_PREFIX_SETTING}.Controllers" CACHE STRING "") diff --git a/libultraship b/libultraship index 9def18e6246..fb10cd2feb4 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit 9def18e62467b4225d26e206e0039a31ed406573 +Subproject commit fb10cd2feb488cf58899a7d5283195fc50b07b23 diff --git a/soh/assets/xml/GC_MQ_D/code/sys_matrix.xml b/soh/assets/xml/GC_MQ_D/code/sys_matrix.xml new file mode 100644 index 00000000000..b39033d5976 --- /dev/null +++ b/soh/assets/xml/GC_MQ_D/code/sys_matrix.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/soh/assets/xml/GC_MQ_D/scenes/dungeons/bdan.xml b/soh/assets/xml/GC_MQ_D/scenes/dungeons/bdan.xml index 18d39d57b0d..9eb1ee61aa2 100644 --- a/soh/assets/xml/GC_MQ_D/scenes/dungeons/bdan.xml +++ b/soh/assets/xml/GC_MQ_D/scenes/dungeons/bdan.xml @@ -1,4 +1,5 @@ + diff --git a/soh/assets/xml/GC_MQ_D/scenes/dungeons/bdan_boss.xml b/soh/assets/xml/GC_MQ_D/scenes/dungeons/bdan_boss.xml index b88d6eb03bc..9fccf2c3010 100644 --- a/soh/assets/xml/GC_MQ_D/scenes/dungeons/bdan_boss.xml +++ b/soh/assets/xml/GC_MQ_D/scenes/dungeons/bdan_boss.xml @@ -1,4 +1,5 @@ + diff --git a/soh/assets/xml/GC_MQ_PAL_F/code/sys_matrix.xml b/soh/assets/xml/GC_MQ_PAL_F/code/sys_matrix.xml new file mode 100644 index 00000000000..a3fed368bef --- /dev/null +++ b/soh/assets/xml/GC_MQ_PAL_F/code/sys_matrix.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/soh/assets/xml/GC_MQ_PAL_F/scenes/dungeons/bdan.xml b/soh/assets/xml/GC_MQ_PAL_F/scenes/dungeons/bdan.xml index 18d39d57b0d..9eb1ee61aa2 100644 --- a/soh/assets/xml/GC_MQ_PAL_F/scenes/dungeons/bdan.xml +++ b/soh/assets/xml/GC_MQ_PAL_F/scenes/dungeons/bdan.xml @@ -1,4 +1,5 @@ + diff --git a/soh/assets/xml/GC_MQ_PAL_F/scenes/dungeons/bdan_boss.xml b/soh/assets/xml/GC_MQ_PAL_F/scenes/dungeons/bdan_boss.xml index b88d6eb03bc..9fccf2c3010 100644 --- a/soh/assets/xml/GC_MQ_PAL_F/scenes/dungeons/bdan_boss.xml +++ b/soh/assets/xml/GC_MQ_PAL_F/scenes/dungeons/bdan_boss.xml @@ -1,4 +1,5 @@ + diff --git a/soh/assets/xml/GC_NMQ_D/code/sys_matrix.xml b/soh/assets/xml/GC_NMQ_D/code/sys_matrix.xml new file mode 100644 index 00000000000..ed2a859c655 --- /dev/null +++ b/soh/assets/xml/GC_NMQ_D/code/sys_matrix.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/soh/assets/xml/GC_NMQ_D/scenes/dungeons/bdan.xml b/soh/assets/xml/GC_NMQ_D/scenes/dungeons/bdan.xml index 41c009d7d5e..a9e520f4cf2 100644 --- a/soh/assets/xml/GC_NMQ_D/scenes/dungeons/bdan.xml +++ b/soh/assets/xml/GC_NMQ_D/scenes/dungeons/bdan.xml @@ -1,4 +1,5 @@ + diff --git a/soh/assets/xml/GC_NMQ_D/scenes/dungeons/bdan_boss.xml b/soh/assets/xml/GC_NMQ_D/scenes/dungeons/bdan_boss.xml index b88d6eb03bc..9fccf2c3010 100644 --- a/soh/assets/xml/GC_NMQ_D/scenes/dungeons/bdan_boss.xml +++ b/soh/assets/xml/GC_NMQ_D/scenes/dungeons/bdan_boss.xml @@ -1,4 +1,5 @@ + diff --git a/soh/assets/xml/GC_NMQ_PAL_F/code/sys_matrix.xml b/soh/assets/xml/GC_NMQ_PAL_F/code/sys_matrix.xml new file mode 100644 index 00000000000..d2143f4e488 --- /dev/null +++ b/soh/assets/xml/GC_NMQ_PAL_F/code/sys_matrix.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/soh/assets/xml/GC_NMQ_PAL_F/scenes/dungeons/bdan.xml b/soh/assets/xml/GC_NMQ_PAL_F/scenes/dungeons/bdan.xml index 41c009d7d5e..a9e520f4cf2 100644 --- a/soh/assets/xml/GC_NMQ_PAL_F/scenes/dungeons/bdan.xml +++ b/soh/assets/xml/GC_NMQ_PAL_F/scenes/dungeons/bdan.xml @@ -1,4 +1,5 @@ + diff --git a/soh/assets/xml/GC_NMQ_PAL_F/scenes/dungeons/bdan_boss.xml b/soh/assets/xml/GC_NMQ_PAL_F/scenes/dungeons/bdan_boss.xml index b88d6eb03bc..9fccf2c3010 100644 --- a/soh/assets/xml/GC_NMQ_PAL_F/scenes/dungeons/bdan_boss.xml +++ b/soh/assets/xml/GC_NMQ_PAL_F/scenes/dungeons/bdan_boss.xml @@ -1,4 +1,5 @@ + diff --git a/soh/assets/xml/N64_PAL_10/code/sys_matrix.xml b/soh/assets/xml/N64_PAL_10/code/sys_matrix.xml new file mode 100644 index 00000000000..706c249d454 --- /dev/null +++ b/soh/assets/xml/N64_PAL_10/code/sys_matrix.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/soh/assets/xml/N64_PAL_10/scenes/dungeons/bdan.xml b/soh/assets/xml/N64_PAL_10/scenes/dungeons/bdan.xml index 41c009d7d5e..a9e520f4cf2 100644 --- a/soh/assets/xml/N64_PAL_10/scenes/dungeons/bdan.xml +++ b/soh/assets/xml/N64_PAL_10/scenes/dungeons/bdan.xml @@ -1,4 +1,5 @@ + diff --git a/soh/assets/xml/N64_PAL_10/scenes/dungeons/bdan_boss.xml b/soh/assets/xml/N64_PAL_10/scenes/dungeons/bdan_boss.xml index b88d6eb03bc..9fccf2c3010 100644 --- a/soh/assets/xml/N64_PAL_10/scenes/dungeons/bdan_boss.xml +++ b/soh/assets/xml/N64_PAL_10/scenes/dungeons/bdan_boss.xml @@ -1,4 +1,5 @@ + diff --git a/soh/assets/xml/N64_PAL_11/code/sys_matrix.xml b/soh/assets/xml/N64_PAL_11/code/sys_matrix.xml new file mode 100644 index 00000000000..97b57a57c76 --- /dev/null +++ b/soh/assets/xml/N64_PAL_11/code/sys_matrix.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/soh/assets/xml/N64_PAL_11/scenes/dungeons/bdan.xml b/soh/assets/xml/N64_PAL_11/scenes/dungeons/bdan.xml index 41c009d7d5e..a9e520f4cf2 100644 --- a/soh/assets/xml/N64_PAL_11/scenes/dungeons/bdan.xml +++ b/soh/assets/xml/N64_PAL_11/scenes/dungeons/bdan.xml @@ -1,4 +1,5 @@ + diff --git a/soh/assets/xml/N64_PAL_11/scenes/dungeons/bdan_boss.xml b/soh/assets/xml/N64_PAL_11/scenes/dungeons/bdan_boss.xml index b88d6eb03bc..9fccf2c3010 100644 --- a/soh/assets/xml/N64_PAL_11/scenes/dungeons/bdan_boss.xml +++ b/soh/assets/xml/N64_PAL_11/scenes/dungeons/bdan_boss.xml @@ -1,4 +1,5 @@ + diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 12f94e5fd31..11ea494d5d2 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -149,6 +149,8 @@ Color_RGB8 zoraColor = { 0x00, 0xEC, 0x64 }; float previousImGuiScale; +bool prevAltAssets = false; + // Same as NaviColor type from OoT src (z_actor.c), but modified to be sans alpha channel for Controller LED. typedef struct { Color_RGB8 inner; @@ -320,6 +322,8 @@ OTRGlobals::OTRGlobals() { // tell LUS to reserve 3 SoH specific threads (Game, Audio, Save) context->InitResourceManager(OTRFiles, {}, 3); + prevAltAssets = CVarGetInteger(CVAR_ENHANCEMENT("AltAssets"), 0); + context->GetResourceManager()->SetAltAssetsEnabled(prevAltAssets); context->InitControlDeck({BTN_MODIFIER1, BTN_MODIFIER2}); context->GetControlDeck()->SetSinglePlayerMappingMode(true); @@ -468,7 +472,7 @@ bool OTRGlobals::HasOriginal() { } uint32_t OTRGlobals::GetInterpolationFPS() { - if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::DX11) { + if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::FAST3D_DXGI_DX11) { return CVarGetInteger(CVAR_SETTING("InterpolationFPS"), 20); } @@ -484,9 +488,6 @@ struct ExtensionEntry { std::string ext; }; -extern uintptr_t clearMtx; -extern "C" Mtx gMtxClear; -extern "C" MtxF gMtxFClear; extern "C" void OTRMessage_Init(); extern "C" void AudioMgr_CreateNextAudioBuffer(s16* samples, u32 num_samples); extern "C" void AudioPlayer_Play(const uint8_t* buf, uint32_t len); @@ -1145,7 +1146,6 @@ extern "C" void InitOTR() { GameInteractorSail::Instance = new GameInteractorSail(); #endif - clearMtx = (uintptr_t)&gMtxClear; OTRMessage_Init(); OTRAudio_Init(); OTRExtScanner(); @@ -1254,8 +1254,6 @@ extern "C" uint64_t GetUnixTimestamp() { return (uint64_t)millis.count(); } -extern bool ToggleAltAssetsAtEndOfFrame; - extern "C" void Graph_StartFrame() { #ifndef __WIIU__ using Ship::KbScancode; @@ -1337,7 +1335,7 @@ extern "C" void Graph_StartFrame() { } #endif case KbScancode::LUS_KB_TAB: { - ToggleAltAssetsAtEndOfFrame = true; + CVarSetInteger(CVAR_ENHANCEMENT("AltAssets"), !CVarGetInteger(CVAR_ENHANCEMENT("AltAssets"), 0)); break; } } @@ -1420,11 +1418,10 @@ extern "C" void Graph_ProcessGfxCommands(Gfx* commands) { } } - if (ToggleAltAssetsAtEndOfFrame) { - ToggleAltAssetsAtEndOfFrame = false; - - // Actually update the CVar now before runing the alt asset update listeners - CVarSetInteger(CVAR_ALT_ASSETS, !CVarGetInteger(CVAR_ALT_ASSETS, 0)); + bool curAltAssets = CVarGetInteger(CVAR_ENHANCEMENT("AltAssets"), 0); + if (prevAltAssets != curAltAssets) { + prevAltAssets = curAltAssets; + Ship::Context::GetInstance()->GetResourceManager()->SetAltAssetsEnabled(curAltAssets); gfx_texture_cache_clear(); SOH::SkeletonPatcher::UpdateSkeletons(); GameInteractor::Instance->ExecuteHooks(); @@ -1610,10 +1607,14 @@ extern "C" uint8_t ResourceMgr_FileAltExists(const char* filePath) { return ExtensionCache.contains(path); } +extern "C" bool ResourceMgr_IsAltAssetsEnabled() { + return Ship::Context::GetInstance()->GetResourceManager()->IsAltAssetsEnabled(); +} + // Unloads a resource if an alternate version exists when alt assets are enabled // The resource is only removed from the internal cache to prevent it from used in the next resource lookup extern "C" void ResourceMgr_UnloadOriginalWhenAltExists(const char* resName) { - if (CVarGetInteger(CVAR_ALT_ASSETS, 0) && ResourceMgr_FileAltExists((char*) resName)) { + if (ResourceMgr_IsAltAssetsEnabled() && ResourceMgr_FileAltExists((char*)resName)) { ResourceMgr_UnloadResource((char*) resName); } } @@ -1964,7 +1965,7 @@ extern "C" SkeletonHeader* ResourceMgr_LoadSkeletonByName(const char* path, Skel pathStr = pathStr.substr(sOtr.length()); } - bool isAlt = CVarGetInteger(CVAR_ALT_ASSETS, 0); + bool isAlt = ResourceMgr_IsAltAssetsEnabled(); if (isAlt) { pathStr = Ship::IResource::gAltAssetPrefix + pathStr; diff --git a/soh/soh/OTRGlobals.h b/soh/soh/OTRGlobals.h index e0b5c7a3816..d0001534a55 100644 --- a/soh/soh/OTRGlobals.h +++ b/soh/soh/OTRGlobals.h @@ -137,6 +137,7 @@ void Ctx_ReadSaveFile(uintptr_t addr, void* dramAddr, size_t size); void Ctx_WriteSaveFile(uintptr_t addr, void* dramAddr, size_t size); uint64_t GetPerfCounter(); +bool ResourceMgr_IsAltAssetsEnabled(); struct SkeletonHeader* ResourceMgr_LoadSkeletonByName(const char* path, SkelAnime* skelAnime); void ResourceMgr_UnregisterSkeleton(SkelAnime* skelAnime); void ResourceMgr_ClearSkeletons(); diff --git a/soh/soh/SohGui.cpp b/soh/soh/SohGui.cpp index 7fde4f351b0..25763525d64 100644 --- a/soh/soh/SohGui.cpp +++ b/soh/soh/SohGui.cpp @@ -43,7 +43,6 @@ #include "Enhancements/resolution-editor/ResolutionEditor.h" #include "Enhancements/debugger/MessageViewer.h" -bool ToggleAltAssetsAtEndOfFrame = false; bool isBetaQuestEnabled = false; extern "C" { diff --git a/soh/soh/SohMenuBar.cpp b/soh/soh/SohMenuBar.cpp index 9cd2c684416..00f7994f5b4 100644 --- a/soh/soh/SohMenuBar.cpp +++ b/soh/soh/SohMenuBar.cpp @@ -37,7 +37,6 @@ #include "Enhancements/randomizer/randomizer_settings_window.h" #include "Enhancements/resolution-editor/ResolutionEditor.h" -extern bool ToggleAltAssetsAtEndOfFrame; extern bool isBetaQuestEnabled; extern "C" PlayState* gPlayState; @@ -319,7 +318,7 @@ void DrawSettingsMenu() { { // FPS Slider const int minFps = 20; static int maxFps; - if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::DX11) { + if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::FAST3D_DXGI_DX11) { maxFps = 360; } else { maxFps = Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(); @@ -387,12 +386,12 @@ void DrawSettingsMenu() { Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); #else bool matchingRefreshRate = - CVarGetInteger(CVAR_SETTING("MatchRefreshRate"), 0) && Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() != Ship::WindowBackend::DX11; + CVarGetInteger(CVAR_SETTING("MatchRefreshRate"), 0) && Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() != Ship::WindowBackend::FAST3D_DXGI_DX11; UIWidgets::PaddedEnhancementSliderInt( (currentFps == 20) ? "Frame Rate: Original (20 fps)" : "Frame Rate: %d fps", "##FPSInterpolation", CVAR_SETTING("InterpolationFPS"), minFps, maxFps, "", 20, true, true, false, matchingRefreshRate); #endif - if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::DX11) { + if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::FAST3D_DXGI_DX11) { UIWidgets::Tooltip( "Uses Matrix Interpolation to create extra frames, resulting in smoother graphics.\n" "This is purely visual and does not impact game logic, execution of glitches etc.\n" @@ -407,7 +406,7 @@ void DrawSettingsMenu() { } } // END FPS Slider - if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::DX11) { + if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::FAST3D_DXGI_DX11) { UIWidgets::Spacer(0); if (ImGui::Button("Match Frame Rate to Refresh Rate")) { int hz = Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(); @@ -421,7 +420,7 @@ void DrawSettingsMenu() { } UIWidgets::Tooltip("Matches interpolation value to the game window's current refresh rate."); - if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::DX11) { + if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::FAST3D_DXGI_DX11) { UIWidgets::PaddedEnhancementSliderInt(CVarGetInteger(CVAR_SETTING("ExtraLatencyThreshold"), 80) == 0 ? "Jitter fix: Off" : "Jitter fix: >= %d FPS", "##ExtraLatencyThreshold", CVAR_SETTING("ExtraLatencyThreshold"), 0, 360, "", 80, true, true, false); UIWidgets::Tooltip( @@ -444,17 +443,16 @@ void DrawSettingsMenu() { UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); static std::unordered_map windowBackendNames = { - { Ship::WindowBackend::DX11, "DirectX" }, - { Ship::WindowBackend::SDL_OPENGL, "OpenGL"}, - { Ship::WindowBackend::SDL_METAL, "Metal" }, - { Ship::WindowBackend::GX2, "GX2"} + { Ship::WindowBackend::FAST3D_DXGI_DX11, "DirectX" }, + { Ship::WindowBackend::FAST3D_SDL_OPENGL, "OpenGL"}, + { Ship::WindowBackend::FAST3D_SDL_METAL, "Metal" } }; ImGui::Text("Renderer API (Needs reload)"); Ship::WindowBackend runningWindowBackend = Ship::Context::GetInstance()->GetWindow()->GetWindowBackend(); Ship::WindowBackend configWindowBackend; int configWindowBackendId = Ship::Context::GetInstance()->GetConfig()->GetInt("Window.Backend.Id", -1); - if (configWindowBackendId != -1 && configWindowBackendId < static_cast(Ship::WindowBackend::BACKEND_COUNT)) { + if (Ship::Context::GetInstance()->GetWindow()->IsAvailableWindowBackend(configWindowBackendId)) { configWindowBackend = static_cast(configWindowBackendId); } else { configWindowBackend = runningWindowBackend; @@ -1086,12 +1084,7 @@ void DrawEnhancementsMenu() { if (ImGui::BeginMenu("Graphics")) { if (ImGui::BeginMenu("Mods")) { - if (UIWidgets::PaddedEnhancementCheckbox("Use Alternate Assets", CVAR_ALT_ASSETS, false, false)) { - // The checkbox will flip the alt asset CVar, but we instead want it to change at the end of the game frame - // We toggle it back while setting the flag to update the CVar later - CVarSetInteger(CVAR_ALT_ASSETS, !CVarGetInteger(CVAR_ALT_ASSETS, 0)); - ToggleAltAssetsAtEndOfFrame = true; - } + UIWidgets::PaddedEnhancementCheckbox("Use Alternate Assets", CVAR_ENHANCEMENT("AltAssets"), false, false); UIWidgets::Tooltip("Toggle between standard assets and alternate assets. Usually mods will indicate if this setting has to be used or not."); UIWidgets::PaddedEnhancementCheckbox("Disable Bomb Billboarding", CVAR_ENHANCEMENT("DisableBombBillboarding"), true, false); UIWidgets::Tooltip("Disables bombs always rotating to face the camera. To be used in conjunction with mods that want to replace bombs with 3D objects."); diff --git a/soh/soh/resource/type/Skeleton.cpp b/soh/soh/resource/type/Skeleton.cpp index 8ac676c5557..057f24b6585 100644 --- a/soh/soh/resource/type/Skeleton.cpp +++ b/soh/soh/resource/type/Skeleton.cpp @@ -65,12 +65,11 @@ void SkeletonPatcher::ClearSkeletons() } void SkeletonPatcher::UpdateSkeletons() { - bool isHD = CVarGetInteger(CVAR_ALT_ASSETS, 0); + auto resourceMgr = Ship::Context::GetInstance()->GetResourceManager(); + bool isHD = resourceMgr->IsAltAssetsEnabled(); for (auto skel : skeletons) { Skeleton* newSkel = - (Skeleton*)Ship::Context::GetInstance()->GetResourceManager() - ->LoadResource((isHD ? Ship::IResource::gAltAssetPrefix : "") + skel.vanillaSkeletonPath, true) - .get(); + (Skeleton*)resourceMgr->LoadResource((isHD ? Ship::IResource::gAltAssetPrefix : "") + skel.vanillaSkeletonPath, true).get(); if (newSkel != nullptr) { skel.skelAnime->skeleton = newSkel->skeletonData.skeletonHeader.segment; diff --git a/soh/src/code/game.c b/soh/src/code/game.c index f0988c7c39d..aa0670a21ce 100644 --- a/soh/src/code/game.c +++ b/soh/src/code/game.c @@ -467,7 +467,7 @@ void GameState_Destroy(GameState* gameState) { // Performing clear skeletons before unload resources fixes an actor heap corruption crash due to the skeleton patching system. ResourceMgr_ClearSkeletons(); - if (CVarGetInteger(CVAR_ALT_ASSETS, 0)) { + if (ResourceMgr_IsAltAssetsEnabled()) { ResourceUnloadDirectory("alt/*"); gfx_texture_cache_clear(); } diff --git a/soh/src/code/gfxprint.c b/soh/src/code/gfxprint.c index 1717e46b3cc..6d8686074eb 100644 --- a/soh/src/code/gfxprint.c +++ b/soh/src/code/gfxprint.c @@ -141,7 +141,7 @@ static const ALIGN_ASSET(2) char rGfxPrintFontDataAlt[] = drGfxPrintFontDataAlt; // https://github.com/HarbourMasters/Shipwright/issues/2762 typedef enum {hardcoded, otrDefault, otrAlt} font_texture_t; font_texture_t GfxPrint_TextureToUse() { - if (CVarGetInteger(CVAR_ALT_ASSETS, 0) && ResourceMgr_FileExists(rGfxPrintFontDataAlt)) { + if (ResourceMgr_IsAltAssetsEnabled() && ResourceMgr_FileExists(rGfxPrintFontDataAlt)) { // If we have alt assets enabled, and we have alt prefixed font texture, use that return otrAlt; } else if (ResourceMgr_FileExists(rGfxPrintFontData)) { From 4441304dfd5706f335d2ee9418b6e4373262c752 Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Fri, 14 Jun 2024 13:40:39 -0400 Subject: [PATCH 40/59] support LUS not providing an array resource type/factory (#4204) * support LUS not providing an array resource type/factory * bump to latest upstream --- OTRExporter | 2 +- libultraship | 2 +- soh/soh/OTRGlobals.cpp | 13 ++-- soh/soh/resource/importer/ArrayFactory.cpp | 64 ++++++++++++++++ soh/soh/resource/importer/ArrayFactory.h | 11 +++ soh/soh/resource/type/Array.cpp | 45 ++++++++++++ soh/soh/resource/type/Array.h | 85 ++++++++++++++++++++++ soh/soh/resource/type/SohResourceType.h | 1 + 8 files changed, 214 insertions(+), 9 deletions(-) create mode 100644 soh/soh/resource/importer/ArrayFactory.cpp create mode 100644 soh/soh/resource/importer/ArrayFactory.h create mode 100644 soh/soh/resource/type/Array.cpp create mode 100644 soh/soh/resource/type/Array.h diff --git a/OTRExporter b/OTRExporter index d70db9806c0..2cfdb396090 160000 --- a/OTRExporter +++ b/OTRExporter @@ -1 +1 @@ -Subproject commit d70db9806c02c229ca3ed928ad0bdae128fe4ac7 +Subproject commit 2cfdb3960900ba059f570b2ded2fed3494a96a9b diff --git a/libultraship b/libultraship index fb10cd2feb4..c7974d6a258 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit fb10cd2feb488cf58899a7d5283195fc50b07b23 +Subproject commit c7974d6a25853d65b44905df728a0e0249636947 diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 11ea494d5d2..2d7e1fcd545 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -22,7 +22,6 @@ #else #include #endif -#include #include #include "Enhancements/speechsynthesizer/SpeechSynthesizer.h" #include "Enhancements/controls/SohInputEditorWindow.h" @@ -108,12 +107,12 @@ GameInteractorSail* GameInteractorSail::Instance; #include "soh/resource/type/Skeleton.h" #include "soh/resource/type/SkeletonLimb.h" #include "soh/resource/type/Text.h" -#include "resource/factory/ArrayFactory.h" #include "resource/factory/BlobFactory.h" #include "resource/factory/DisplayListFactory.h" #include "resource/factory/MatrixFactory.h" #include "resource/factory/TextureFactory.h" #include "resource/factory/VertexFactory.h" +#include "soh/resource/importer/ArrayFactory.h" #include "soh/resource/importer/AnimationFactory.h" #include "soh/resource/importer/AudioSampleFactory.h" #include "soh/resource/importer/AudioSequenceFactory.h" @@ -351,8 +350,8 @@ OTRGlobals::OTRGlobals() { loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "DisplayList", static_cast(LUS::ResourceType::DisplayList), 0); loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_XML, "DisplayList", static_cast(LUS::ResourceType::DisplayList), 0); loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Matrix", static_cast(LUS::ResourceType::Matrix), 0); - loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Array", static_cast(LUS::ResourceType::Array), 0); loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Blob", static_cast(LUS::ResourceType::Blob), 0); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Array", static_cast(SOH::ResourceType::SOH_Array), 0); loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Animation", static_cast(SOH::ResourceType::SOH_Animation), 0); loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "PlayerAnimation", static_cast(SOH::ResourceType::SOH_PlayerAnimation), 0); loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Room", static_cast(SOH::ResourceType::SOH_Room), 0); // Is room scene? maybe? @@ -1697,8 +1696,8 @@ extern "C" char* ResourceMgr_LoadTexOrDListByName(const char* filePath) { if (res->GetInitData()->Type == static_cast(LUS::ResourceType::DisplayList)) return (char*)&((std::static_pointer_cast(res))->Instructions[0]); - else if (res->GetInitData()->Type == static_cast(LUS::ResourceType::Array)) - return (char*)(std::static_pointer_cast(res))->Vertices.data(); + else if (res->GetInitData()->Type == static_cast(SOH::ResourceType::SOH_Array)) + return (char*)(std::static_pointer_cast(res))->Vertices.data(); else { return (char*)GetResourceDataByNameHandlingMQ(filePath); } @@ -1828,13 +1827,13 @@ extern "C" void ResourceMgr_UnpatchGfxByName(const char* path, const char* patch extern "C" char* ResourceMgr_LoadArrayByName(const char* path) { - auto res = std::static_pointer_cast(GetResourceByNameHandlingMQ(path)); + auto res = std::static_pointer_cast(GetResourceByNameHandlingMQ(path)); return (char*)res->Scalars.data(); } extern "C" char* ResourceMgr_LoadArrayByNameAsVec3s(const char* path) { - auto res = std::static_pointer_cast(GetResourceByNameHandlingMQ(path)); + auto res = std::static_pointer_cast(GetResourceByNameHandlingMQ(path)); // if (res->CachedGameAsset != nullptr) // return (char*)res->CachedGameAsset; diff --git a/soh/soh/resource/importer/ArrayFactory.cpp b/soh/soh/resource/importer/ArrayFactory.cpp new file mode 100644 index 00000000000..39be7c09377 --- /dev/null +++ b/soh/soh/resource/importer/ArrayFactory.cpp @@ -0,0 +1,64 @@ +#include "soh/resource/importer/ArrayFactory.h" +#include "soh/resource/type/Array.h" +#include "spdlog/spdlog.h" +#include "graphic/Fast3D/lus_gbi.h" + +namespace SOH { +std::shared_ptr ResourceFactoryBinaryArrayV0::ReadResource(std::shared_ptr file) { + if (!FileHasValidFormatAndReader(file)) { + return nullptr; + } + + auto array = std::make_shared(file->InitData); + auto reader = std::get>(file->Reader); + + array->ArrayType = (ArrayResourceType)reader->ReadUInt32(); + array->ArrayCount = reader->ReadUInt32(); + + for (uint32_t i = 0; i < array->ArrayCount; i++) { + if (array->ArrayType == ArrayResourceType::Vertex) { + // OTRTODO: Implement Vertex arrays as just a vertex resource. + F3DVtx data; + data.v.ob[0] = reader->ReadInt16(); + data.v.ob[1] = reader->ReadInt16(); + data.v.ob[2] = reader->ReadInt16(); + data.v.flag = reader->ReadUInt16(); + data.v.tc[0] = reader->ReadInt16(); + data.v.tc[1] = reader->ReadInt16(); + data.v.cn[0] = reader->ReadUByte(); + data.v.cn[1] = reader->ReadUByte(); + data.v.cn[2] = reader->ReadUByte(); + data.v.cn[3] = reader->ReadUByte(); + array->Vertices.push_back(data); + } else { + array->ArrayScalarType = (ScalarType)reader->ReadUInt32(); + + int iter = 1; + + if (array->ArrayType == ArrayResourceType::Vector) { + iter = reader->ReadUInt32(); + } + + for (int k = 0; k < iter; k++) { + ScalarData data; + + switch (array->ArrayScalarType) { + case ScalarType::ZSCALAR_S16: + data.s16 = reader->ReadInt16(); + break; + case ScalarType::ZSCALAR_U16: + data.u16 = reader->ReadUInt16(); + break; + default: + // OTRTODO: IMPLEMENT OTHER TYPES! + break; + } + + array->Scalars.push_back(data); + } + } + } + + return array; +} +} // namespace LUS diff --git a/soh/soh/resource/importer/ArrayFactory.h b/soh/soh/resource/importer/ArrayFactory.h new file mode 100644 index 00000000000..b9f5ca75b67 --- /dev/null +++ b/soh/soh/resource/importer/ArrayFactory.h @@ -0,0 +1,11 @@ +#pragma once + +#include "resource/Resource.h" +#include "resource/ResourceFactoryBinary.h" + +namespace SOH { +class ResourceFactoryBinaryArrayV0 : public Ship::ResourceFactoryBinary { + public: + std::shared_ptr ReadResource(std::shared_ptr file) override; +}; +} // namespace LUS diff --git a/soh/soh/resource/type/Array.cpp b/soh/soh/resource/type/Array.cpp new file mode 100644 index 00000000000..70d5d42baad --- /dev/null +++ b/soh/soh/resource/type/Array.cpp @@ -0,0 +1,45 @@ +#include "Array.h" +#include "graphic/Fast3D/lus_gbi.h" +namespace SOH { +Array::Array() : Resource(std::shared_ptr()) { +} + +void* Array::GetPointer() { + void* dataPointer = nullptr; + switch (ArrayType) { + case ArrayResourceType::Vertex: + dataPointer = Vertices.data(); + break; + case ArrayResourceType::Scalar: + default: + dataPointer = Scalars.data(); + break; + } + + return dataPointer; +} + +size_t Array::GetPointerSize() { + size_t typeSize = 0; + switch (ArrayType) { + case ArrayResourceType::Vertex: + typeSize = sizeof(F3DVtx); + break; + case ArrayResourceType::Scalar: + default: + switch (ArrayScalarType) { + case ScalarType::ZSCALAR_S16: + typeSize = sizeof(int16_t); + break; + case ScalarType::ZSCALAR_U16: + typeSize = sizeof(uint16_t); + break; + default: + // OTRTODO: IMPLEMENT OTHER TYPES! + break; + } + break; + } + return ArrayCount * typeSize; +} +} // namespace LUS diff --git a/soh/soh/resource/type/Array.h b/soh/soh/resource/type/Array.h new file mode 100644 index 00000000000..ba41ec0492c --- /dev/null +++ b/soh/soh/resource/type/Array.h @@ -0,0 +1,85 @@ +#pragma once + +#include "resource/Resource.h" + +union F3DVtx; +namespace SOH { +typedef union ScalarData { + uint8_t u8; + int8_t s8; + uint16_t u16; + int16_t s16; + uint32_t u32; + int32_t s32; + uint64_t u64; + int64_t s64; + float f32; + double f64; +} ScalarData; + +enum class ScalarType { + ZSCALAR_NONE, + ZSCALAR_S8, + ZSCALAR_U8, + ZSCALAR_X8, + ZSCALAR_S16, + ZSCALAR_U16, + ZSCALAR_X16, + ZSCALAR_S32, + ZSCALAR_U32, + ZSCALAR_X32, + ZSCALAR_S64, + ZSCALAR_U64, + ZSCALAR_X64, + ZSCALAR_F32, + ZSCALAR_F64 +}; + +// OTRTODO: Replace this with something that can be shared between the exporter and importer... +enum class ArrayResourceType { + Error, + Animation, + Array, + AltHeader, + Background, + Blob, + CollisionHeader, + Cutscene, + DisplayList, + Limb, + LimbTable, + Mtx, + Path, + PlayerAnimationData, + Room, + RoomCommand, + Scalar, + Scene, + Skeleton, + String, + Symbol, + Texture, + TextureAnimation, + TextureAnimationParams, + Vector, + Vertex, + Audio +}; + +class Array : public Ship::Resource { + public: + using Resource::Resource; + + Array(); + + void* GetPointer() override; + size_t GetPointerSize() override; + + ArrayResourceType ArrayType; + ScalarType ArrayScalarType; + size_t ArrayCount; + // OTRTODO: Should be a vector of resource pointers... + std::vector Scalars; + std::vector Vertices; +}; +} // namespace LUS diff --git a/soh/soh/resource/type/SohResourceType.h b/soh/soh/resource/type/SohResourceType.h index fdf39031e12..6455c28c7e0 100644 --- a/soh/soh/resource/type/SohResourceType.h +++ b/soh/soh/resource/type/SohResourceType.h @@ -2,6 +2,7 @@ namespace SOH { enum class ResourceType { + SOH_Array = 0x4F415252, // OARR SOH_Animation = 0x4F414E4D, // OANM SOH_PlayerAnimation = 0x4F50414D, // OPAM SOH_Room = 0x4F524F4D, // OROM From cd7c5ab316cb3f48bedea399e1adda2cd28f75e0 Mon Sep 17 00:00:00 2001 From: Archez Date: Sat, 15 Jun 2024 23:13:13 -0400 Subject: [PATCH 41/59] Clear the framebuffer for the pause menu link texture (#4213) * clear pause menu link framebuffer * cache bust * Add enums for pause menu link width/height and rename the framebuffer * revert cache bust --- libultraship | 2 +- soh/include/z64.h | 3 ++ soh/src/code/game.c | 11 +++--- soh/src/code/z_player_lib.c | 38 ++++++++++++++----- .../ovl_kaleido_scope/z_kaleido_equipment.c | 10 ++--- .../ovl_kaleido_scope/z_kaleido_scope_PAL.c | 4 +- 6 files changed, 45 insertions(+), 23 deletions(-) diff --git a/libultraship b/libultraship index c7974d6a258..9907ebfd66f 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit c7974d6a25853d65b44905df728a0e0249636947 +Subproject commit 9907ebfd66ff5bf903ecb7327cca69014993772b diff --git a/soh/include/z64.h b/soh/include/z64.h index bad2e1ca77a..7a4cb193dbf 100644 --- a/soh/include/z64.h +++ b/soh/include/z64.h @@ -841,6 +841,9 @@ typedef enum { #define PAUSE_CURSOR_PAGE_LEFT 10 #define PAUSE_CURSOR_PAGE_RIGHT 11 +#define PAUSE_EQUIP_PLAYER_WIDTH 64 +#define PAUSE_EQUIP_PLAYER_HEIGHT 112 + typedef enum { /* 0x00 */ PAUSE_ITEM, /* 0x01 */ PAUSE_MAP, diff --git a/soh/src/code/game.c b/soh/src/code/game.c index aa0670a21ce..e1974ed98c3 100644 --- a/soh/src/code/game.c +++ b/soh/src/code/game.c @@ -239,16 +239,15 @@ void GameState_ReqPadData(GameState* gameState) { PadMgr_RequestPadData(&gPadMgr, &gameState->input[0], 1); } -// OTRTODO -int fbTest = -1; +// Framebuffer for the Link preview on the pause menu equipment sub-screen +int gPauseLinkFrameBuffer = -1; void GameState_Update(GameState* gameState) { GraphicsContext* gfxCtx = gameState->gfxCtx; - if (fbTest == -1) - { - fbTest = gfx_create_framebuffer(64, 112, SCREEN_WIDTH, SCREEN_HEIGHT, true); - //fbTest = gfx_create_framebuffer(256, 512); + if (gPauseLinkFrameBuffer == -1) { + gPauseLinkFrameBuffer = gfx_create_framebuffer(PAUSE_EQUIP_PLAYER_WIDTH, PAUSE_EQUIP_PLAYER_HEIGHT, + PAUSE_EQUIP_PLAYER_WIDTH, PAUSE_EQUIP_PLAYER_HEIGHT, true); } GameState_SetFrameBuffer(gfxCtx); diff --git a/soh/src/code/z_player_lib.c b/soh/src/code/z_player_lib.c index b9ef17f6e82..4b790122f8a 100644 --- a/soh/src/code/z_player_lib.c +++ b/soh/src/code/z_player_lib.c @@ -2075,10 +2075,12 @@ void Pause_DrawTriforceSpot(PlayState* play, s32 showLightColumn) { rotation += 0x03E8; } -void Player_DrawPauseImpl(PlayState* play, void* seg04, void* seg06, SkelAnime* skelAnime, Vec3f* pos, Vec3s* rot, - f32 scale, s32 sword, s32 tunic, s32 shield, s32 boots, s32 width, s32 height, Vec3f* eye, Vec3f* at, - f32 fovy, void* img1, void* img2) { - static Vp viewport = { 128, 224, 511, 0, 128, 224, 511, 0 }; +void Player_DrawPauseImpl(PlayState* play, void* gameplayKeep, void* linkObject, SkelAnime* skelAnime, Vec3f* pos, + Vec3s* rot, f32 scale, s32 sword, s32 tunic, s32 shield, s32 boots, s32 width, s32 height, + Vec3f* eye, Vec3f* at, f32 fovy, void* colorFrameBuffer, void* depthFrameBuffer) { + // Note: the viewport x and y values are overwritten below, before usage + static Vp viewport = { (PAUSE_EQUIP_PLAYER_WIDTH / 2) << 2, (PAUSE_EQUIP_PLAYER_HEIGHT / 2) << 2, G_MAXZ / 2, 0, + (PAUSE_EQUIP_PLAYER_WIDTH / 2) << 2, (PAUSE_EQUIP_PLAYER_HEIGHT / 2) << 2, G_MAXZ / 2, 0 }; static Lights1 lights1 = gdSPDefLights1(80, 80, 80, 255, 255, 255, 84, 84, 172); static Vec3f lightDir = { 89.8f, 0.0f, 89.8f }; u8 playerSwordAndShield[2]; @@ -2106,6 +2108,24 @@ void Player_DrawPauseImpl(PlayState* play, void* seg04, void* seg06, SkelAnime* gDPSetScissor(POLY_OPA_DISP++, G_SC_NON_INTERLACE, 0, 0, width, height); gSPClipRatio(POLY_OPA_DISP++, FRUSTRATIO_1); + gDPSetColorImage(POLY_OPA_DISP++, G_IM_FMT_RGBA, G_IM_SIZ_16b, width, depthFrameBuffer); + gDPSetCycleType(POLY_OPA_DISP++, G_CYC_FILL); + gDPSetRenderMode(POLY_OPA_DISP++, G_RM_NOOP, G_RM_NOOP2); + gDPSetFillColor(POLY_OPA_DISP++, (GPACK_ZDZ(G_MAXFBZ, 0) << 16) | GPACK_ZDZ(G_MAXFBZ, 0)); + gDPFillRectangle(POLY_OPA_DISP++, 0, 0, width - 1, height - 1); + + gDPPipeSync(POLY_OPA_DISP++); + + gDPSetColorImage(POLY_OPA_DISP++, G_IM_FMT_RGBA, G_IM_SIZ_16b, width, colorFrameBuffer); + gDPSetCycleType(POLY_OPA_DISP++, G_CYC_FILL); + gDPSetRenderMode(POLY_OPA_DISP++, G_RM_NOOP, G_RM_NOOP2); + gDPSetFillColor(POLY_OPA_DISP++, (GPACK_RGBA5551(0, 0, 0, 1) << 16) | GPACK_RGBA5551(0, 0, 0, 1)); + gDPFillRectangle(POLY_OPA_DISP++, 0, 0, width - 1, height - 1); + + gDPPipeSync(POLY_OPA_DISP++); + + gDPSetDepthImage(POLY_OPA_DISP++, depthFrameBuffer); + viewport.vp.vscale[0] = viewport.vp.vtrans[0] = width * 2; viewport.vp.vscale[1] = viewport.vp.vtrans[1] = height * 2; gSPViewport(POLY_OPA_DISP++, &viewport); @@ -2126,8 +2146,8 @@ void Player_DrawPauseImpl(PlayState* play, void* seg04, void* seg06, SkelAnime* pos->y - (CVarGetInteger(CVAR_GENERAL("PauseTriforce"), 0) ? 16 : 0), pos->z, rot); Matrix_Scale(scale * (CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0) ? -1 : 1), scale, scale, MTXMODE_APPLY); - gSPSegment(POLY_OPA_DISP++, 0x04, seg04); - gSPSegment(POLY_OPA_DISP++, 0x06, seg06); + gSPSegment(POLY_OPA_DISP++, 0x04, gameplayKeep); + gSPSegment(POLY_OPA_DISP++, 0x06, linkObject); gSPSetLights1(POLY_OPA_DISP++, lights1); @@ -2401,8 +2421,8 @@ void Player_DrawPause(PlayState* play, u8* segment, SkelAnime* skelAnime, Vec3f* } } - Player_DrawPauseImpl(play, segment + 0x3800, segment + 0x8800, skelAnime, pos, rot, scale, sword, tunic, shield, - boots, 64, 112, &eye, &at, 60.0f, play->state.gfxCtx->curFrameBuffer, - play->state.gfxCtx->curFrameBuffer + 0x1C00); + boots, PAUSE_EQUIP_PLAYER_WIDTH, PAUSE_EQUIP_PLAYER_HEIGHT, &eye, &at, 60.0f, + play->state.gfxCtx->curFrameBuffer, + play->state.gfxCtx->curFrameBuffer + (PAUSE_EQUIP_PLAYER_WIDTH * PAUSE_EQUIP_PLAYER_HEIGHT)); } diff --git a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c index 99ba5df7212..116ad0c3cfb 100644 --- a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c +++ b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c @@ -27,6 +27,8 @@ static Vtx sStrengthAButtonVtx[] = { static s16 sEquipTimer = 0; +extern int gPauseLinkFrameBuffer; + void KaleidoScope_DrawEquipmentImage(PlayState* play, void* source, u32 width, u32 height) { PauseContext* pauseCtx = &play->pauseCtx; u8* curTexture; @@ -70,13 +72,12 @@ void KaleidoScope_DrawEquipmentImage(PlayState* play, void* source, u32 width, u for (i = 0; i < textureCount; i++) { gSPVertex(POLY_KAL_DISP++, &pauseCtx->equipVtx[vtxIndex], 4, 0); - extern int fbTest; gDPSetTextureImage(POLY_KAL_DISP++, G_IM_FMT_RGBA, G_IM_SIZ_16b, width, curTexture); gDPLoadSync(POLY_KAL_DISP++); gDPLoadTile(POLY_KAL_DISP++, G_TX_LOADTILE, 0, 0, (width - 1) << 2, (textureHeight - 1) << 2); - gDPSetTextureImageFB(POLY_KAL_DISP++, G_IM_FMT_RGBA, G_IM_SIZ_16b, width, fbTest); + gDPSetTextureImageFB(POLY_KAL_DISP++, G_IM_FMT_RGBA, G_IM_SIZ_16b, width, gPauseLinkFrameBuffer); gSP1Quadrangle(POLY_KAL_DISP++, 0, 2, 3, 1, 0); curTexture += textureSize; @@ -185,8 +186,7 @@ void KaleidoScope_DrawPlayerWork(PlayState* play) { link_kaleido_rot.x = 0; - extern int fbTest; - gsSPSetFB(play->state.gfxCtx->polyOpa.p++, fbTest); + gsSPSetFB(play->state.gfxCtx->polyOpa.p++, gPauseLinkFrameBuffer); Player_DrawPause(play, pauseCtx->playerSegment, &pauseCtx->playerSkelAnime, &pos, &link_kaleido_rot, scale, SWORD_EQUIP_TO_PLAYER(CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD)), TUNIC_EQUIP_TO_PLAYER(CUR_EQUIP_VALUE(EQUIP_TYPE_TUNIC)), @@ -852,7 +852,7 @@ void KaleidoScope_DrawEquipment(PlayState* play) { //gSPSegment(POLY_KAL_DISP++, 0x0C, pauseCtx->iconItemAltSegment); Gfx_SetupDL_42Kal(play->state.gfxCtx); - KaleidoScope_DrawEquipmentImage(play, pauseCtx->playerSegment, 64, 112); + KaleidoScope_DrawEquipmentImage(play, pauseCtx->playerSegment, PAUSE_EQUIP_PLAYER_WIDTH, PAUSE_EQUIP_PLAYER_HEIGHT); if (gUpgradeMasks[0]) {} diff --git a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c index 424c823d603..a8b7536f0fb 100644 --- a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c +++ b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c @@ -929,7 +929,6 @@ static void* sPromptChoiceTexs[][2] = { static u8 sButtonStatusSave[ARRAY_COUNT(gSaveContext.buttonStatus)]; static PreRender sPlayerPreRender; static void* sPreRenderCvg; -extern int fbTest; void KaleidoScope_ProcessPlayerPreRender(void) { PreRender_Calc(&sPlayerPreRender); @@ -3725,7 +3724,8 @@ void KaleidoScope_Update(PlayState* play) sPreRenderCvg = (void*)(((uintptr_t)pauseCtx->nameSegment + 0x400 + 0xA00 + 0xF) & ~0xF); PreRender_Init(&sPlayerPreRender); - PreRender_SetValuesSave(&sPlayerPreRender, 64, 112, pauseCtx->playerSegment, NULL, sPreRenderCvg); + PreRender_SetValuesSave(&sPlayerPreRender, PAUSE_EQUIP_PLAYER_WIDTH, PAUSE_EQUIP_PLAYER_HEIGHT, + pauseCtx->playerSegment, NULL, sPreRenderCvg); KaleidoScope_DrawPlayerWork(play); //KaleidoScope_SetupPlayerPreRender(play); From f99993af85c744eed8b298283178e8d9a87a043a Mon Sep 17 00:00:00 2001 From: GaryOderNichts <12049776+GaryOderNichts@users.noreply.github.com> Date: Sun, 16 Jun 2024 05:28:42 +0200 Subject: [PATCH 42/59] Reduce stack usage during static initialization (#4184) * Reduce stack usage during static initialization * Implement `ABS` macro for `TWO_ACTOR_PARAMS` --- soh/soh/ActorDB.cpp | 7 +++-- .../Enhancements/item-tables/ItemTableTypes.h | 2 +- .../Enhancements/randomizer/randomizer.cpp | 28 +++++++++---------- .../randomizer/randomizer_check_objects.cpp | 3 +- .../randomizer/randomizer_check_objects.h | 9 ++++-- .../randomizer/randomizer_check_tracker.cpp | 2 +- .../randomizer/randomizer_tricks.cpp | 3 +- .../randomizer/randomizer_tricks.h | 4 +-- 8 files changed, 32 insertions(+), 26 deletions(-) diff --git a/soh/soh/ActorDB.cpp b/soh/soh/ActorDB.cpp index ea8450ac450..de25388887d 100644 --- a/soh/soh/ActorDB.cpp +++ b/soh/soh/ActorDB.cpp @@ -16,7 +16,7 @@ ActorDB* ActorDB::Instance; #undef DEFINE_ACTOR_UNSET struct AddPair { - std::string name; + const char* name; ActorInit& init; }; @@ -24,7 +24,7 @@ struct AddPair { #define DEFINE_ACTOR(name, _1, allocType) { #name, name##_InitVars }, #define DEFINE_ACTOR_UNSET(_0) -static const std::vector initialActorTable = { +static constexpr AddPair initialActorTable[] = { #include "tables/actor_table.h" }; @@ -33,7 +33,7 @@ static const std::vector initialActorTable = { #undef DEFINE_ACTOR // https://wiki.cloudmodding.com/oot/Actor_List_(Variables) -static std::unordered_map actorDescriptions = { +static constexpr std::pair actorDescriptionData[] = { { ACTOR_PLAYER, "Link" }, { ACTOR_EN_TEST, "Stalfos" }, { ACTOR_EN_GIRLA, "Shop Items" }, @@ -464,6 +464,7 @@ static std::unordered_map actorDescriptions = { { ACTOR_BG_JYA_BLOCK, "Silver Block (Child Era)" }, { ACTOR_OBJ_WARP2BLOCK, "Navi Infospot (Green, Time Block)" } }; +static std::unordered_map actorDescriptions = std::unordered_map(std::begin(actorDescriptionData), std::end(actorDescriptionData)); ActorDB::ActorDB() { db.reserve(ACTOR_NUMBER_MAX); // reserve size for all initial entries so we don't do it for each diff --git a/soh/soh/Enhancements/item-tables/ItemTableTypes.h b/soh/soh/Enhancements/item-tables/ItemTableTypes.h index 6282275b1b8..28e70dc959e 100644 --- a/soh/soh/Enhancements/item-tables/ItemTableTypes.h +++ b/soh/soh/Enhancements/item-tables/ItemTableTypes.h @@ -59,4 +59,4 @@ typedef struct GetItemEntry { /* 0x10 */ uint16_t drawItemId; // Will be a copy of itemId unless the item is an ice trap. Needed for particles to function on ice traps. /* 0x11 */ uint16_t drawModIndex; // Will be a copy of modIndex unless the item is an ice trap. Needed for particles to function on ice traps. CustomDrawFunc drawFunc; -}; // size = 0x11 +} GetItemEntry; // size = 0x11 diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index 107e23e83d1..5ea7293eb38 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -4660,7 +4660,7 @@ void RandomizerSettingsWindow::DrawElement() { bool hasItems = false; for (auto& [randomizerCheck, rcObject] : rcObjects) { if (rcObject->visibleInImgui && !excludedLocations.count(rcObject->rc) && - locationSearch.PassFilter(rcObject->rcSpoilerName.c_str())) { + locationSearch.PassFilter(rcObject->rcSpoilerName)) { hasItems = true; break; @@ -4672,7 +4672,7 @@ void RandomizerSettingsWindow::DrawElement() { if (ImGui::TreeNode(RandomizerCheckObjects::GetRCAreaName(rcArea).c_str())) { for (auto& [randomizerCheck, rcObject] : rcObjects) { if (rcObject->visibleInImgui && !excludedLocations.count(rcObject->rc) && - locationSearch.PassFilter(rcObject->rcSpoilerName.c_str())) { + locationSearch.PassFilter(rcObject->rcSpoilerName)) { if (ImGui::ArrowButton(std::to_string(rcObject->rc).c_str(), ImGuiDir_Right)) { excludedLocations.insert(rcObject->rc); @@ -4686,7 +4686,7 @@ void RandomizerSettingsWindow::DrawElement() { Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } ImGui::SameLine(); - ImGui::Text("%s", rcObject->rcShortName.c_str()); + ImGui::Text("%s", rcObject->rcShortName); } } ImGui::TreePop(); @@ -4731,7 +4731,7 @@ void RandomizerSettingsWindow::DrawElement() { Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } ImGui::SameLine(); - ImGui::Text("%s", rcObject->rcShortName.c_str()); + ImGui::Text("%s", rcObject->rcShortName); } } ImGui::TreePop(); @@ -4997,7 +4997,7 @@ void RandomizerSettingsWindow::DrawElement() { if (ImGui::Button("Enable Visible")) { for (auto [rtArea, rtObjects] : RandomizerTricks::GetAllRTObjectsByArea()) { for (auto [randomizerTrick, rtObject] : rtObjects) { - if (!rtObject.rtGlitch && !enabledTricks.count(rtObject.rt) && trickSearch.PassFilter(rtObject.rtShortName.c_str()) && areaTreeDisabled[rtArea] && RandomizerTricks::CheckRTTags(showTag, *rtObject.rtTags)) { + if (!rtObject.rtGlitch && !enabledTricks.count(rtObject.rt) && trickSearch.PassFilter(rtObject.rtShortName) && areaTreeDisabled[rtArea] && RandomizerTricks::CheckRTTags(showTag, *rtObject.rtTags)) { enabledTricks.insert(randomizerTrick); } } @@ -5017,7 +5017,7 @@ void RandomizerSettingsWindow::DrawElement() { bool hasTricks = false; for (auto [randomizerTrick, rtObject] : rtObjects) { if (rtObject.visibleInImgui && - trickSearch.PassFilter(rtObject.rtShortName.c_str()) && + trickSearch.PassFilter(rtObject.rtShortName) && !enabledTricks.count(rtObject.rt) && RandomizerTricks::CheckRTTags(showTag, *rtObject.rtTags) && !rtObject.rtGlitch) { @@ -5032,7 +5032,7 @@ void RandomizerSettingsWindow::DrawElement() { if (ImGui::TreeNode(RandomizerTricks::GetRTAreaName(rtArea).c_str())) { for (auto [randomizerTrick, rtObject] : rtObjects) { if (rtObject.visibleInImgui && - trickSearch.PassFilter(rtObject.rtShortName.c_str()) && + trickSearch.PassFilter(rtObject.rtShortName) && !enabledTricks.count(rtObject.rt) && RandomizerTricks::CheckRTTags(showTag, *rtObject.rtTags) && !rtObject.rtGlitch) { @@ -5048,8 +5048,8 @@ void RandomizerSettingsWindow::DrawElement() { } DrawTagChips(*rtObject.rtTags); ImGui::SameLine(); - ImGui::Text("%s", rtObject.rtShortName.c_str()); - UIWidgets::InsertHelpHoverText(rtObject.rtDesc.c_str()); + ImGui::Text("%s", rtObject.rtShortName); + UIWidgets::InsertHelpHoverText(rtObject.rtDesc); } } areaTreeDisabled[rtArea] = true; @@ -5107,7 +5107,7 @@ void RandomizerSettingsWindow::DrawElement() { for (auto [rtArea, rtObjects] : RandomizerTricks::GetAllRTObjectsByArea()) { for (auto [randomizerTrick, rtObject] : rtObjects) { auto etfound = enabledTricks.find(randomizerTrick); - if (!rtObject.rtGlitch && etfound != enabledTricks.end() && trickSearch.PassFilter(rtObject.rtShortName.c_str()) && areaTreeEnabled[rtArea] && RandomizerTricks::CheckRTTags(showTag, *rtObject.rtTags)) { + if (!rtObject.rtGlitch && etfound != enabledTricks.end() && trickSearch.PassFilter(rtObject.rtShortName) && areaTreeEnabled[rtArea] && RandomizerTricks::CheckRTTags(showTag, *rtObject.rtTags)) { enabledTricks.erase(etfound); } } @@ -5127,7 +5127,7 @@ void RandomizerSettingsWindow::DrawElement() { bool hasTricks = false; for (auto [randomizerTrick, rtObject] : rtObjects) { if (rtObject.visibleInImgui && - trickSearch.PassFilter(rtObject.rtShortName.c_str()) && + trickSearch.PassFilter(rtObject.rtShortName) && enabledTricks.count(rtObject.rt) && RandomizerTricks::CheckRTTags(showTag, *rtObject.rtTags) && !rtObject.rtGlitch) { @@ -5143,7 +5143,7 @@ void RandomizerSettingsWindow::DrawElement() { for (auto [randomizerTrick, rtObject] : rtObjects) { auto etfound = enabledTricks.find(rtObject.rt); if (rtObject.visibleInImgui && - trickSearch.PassFilter(rtObject.rtShortName.c_str()) && + trickSearch.PassFilter(rtObject.rtShortName) && etfound != enabledTricks.end() && RandomizerTricks::CheckRTTags(showTag, *rtObject.rtTags) && !rtObject.rtGlitch) { @@ -5164,8 +5164,8 @@ void RandomizerSettingsWindow::DrawElement() { } DrawTagChips(*rtObject.rtTags); ImGui::SameLine(); - ImGui::Text("%s", rtObject.rtShortName.c_str()); - UIWidgets::InsertHelpHoverText(rtObject.rtDesc.c_str()); + ImGui::Text("%s", rtObject.rtShortName); + UIWidgets::InsertHelpHoverText(rtObject.rtDesc); } } areaTreeEnabled[rtArea] = true; diff --git a/soh/soh/Enhancements/randomizer/randomizer_check_objects.cpp b/soh/soh/Enhancements/randomizer/randomizer_check_objects.cpp index b97a6f33578..e3dcf46737e 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_check_objects.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_check_objects.cpp @@ -6,7 +6,7 @@ #include "soh/OTRGlobals.h" // RandomizerCheck, RCVORMQ, RCTYPE, RCAREA, ActorId, SceneId, ActorParams, OG ItemID, "Short name", "Spoiler name", vanillaCompletion -std::map rcObjects = { +static constexpr std::pair rcObjectsData[] = { RC_OBJECT(RC_KF_KOKIRI_SWORD_CHEST, RCVORMQ_BOTH, RCTYPE_STANDARD, RCAREA_KOKIRI_FOREST, ACTOR_EN_BOX, SCENE_KOKIRI_FOREST, 1248, GI_SWORD_KOKIRI, "Kokiri Sword Chest", "KF Kokiri Sword Chest", true), RC_OBJECT(RC_KF_MIDOS_TOP_LEFT_CHEST, RCVORMQ_BOTH, RCTYPE_STANDARD, RCAREA_KOKIRI_FOREST, ACTOR_EN_BOX, SCENE_MIDOS_HOUSE, 22944, GI_RUPEE_BLUE, "Mido Top Left Chest", "KF Mido Top Left Chest", false), RC_OBJECT(RC_KF_MIDOS_TOP_RIGHT_CHEST, RCVORMQ_BOTH, RCTYPE_STANDARD, RCAREA_KOKIRI_FOREST, ACTOR_EN_BOX, SCENE_MIDOS_HOUSE, 22945, GI_RUPEE_BLUE, "Mido Top Right Chest", "KF Mido Top Right Chest", false), @@ -775,6 +775,7 @@ std::map rcObjects = { RC_OBJECT(RC_UNKNOWN_CHECK, RCVORMQ_BOTH, RCTYPE_STANDARD, RCAREA_INVALID, ACTOR_ID_MAX, SCENE_ID_MAX, 0x00, GI_NONE, "Invalid Check", "Invalid Check", false), }; +std::map rcObjects = std::map(std::begin(rcObjectsData), std::end(rcObjectsData)); std::map rcAreaNames = { { RCAREA_KOKIRI_FOREST, "Kokiri Forest"}, diff --git a/soh/soh/Enhancements/randomizer/randomizer_check_objects.h b/soh/soh/Enhancements/randomizer/randomizer_check_objects.h index dc9bd201012..e2b78413578 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_check_objects.h +++ b/soh/soh/Enhancements/randomizer/randomizer_check_objects.h @@ -7,7 +7,10 @@ enum ActorID : int; enum SceneID : int; -#define TWO_ACTOR_PARAMS(a, b) (abs(a) << 16) | abs(b) +// ABS macro to use since `std::abs` is not constexpr yet +#define ABS(x) ((x) < 0 ? -(x) : (x)) + +#define TWO_ACTOR_PARAMS(a, b) (ABS(a) << 16) | ABS(b) #define RC_OBJECT(rc, rc_v_or_mq, rc_type, rc_area, actor_id, scene_id, actor_params, og_item_id, rc_shortname, rc_spoilername, vanillaCompletion) \ { rc, {rc, rc_v_or_mq, rc_type, rc_area, actor_id, scene_id, actor_params, og_item_id, false, rc_shortname, rc_spoilername, vanillaCompletion} } @@ -22,8 +25,8 @@ typedef struct { int32_t actorParams; GetItemID ogItemId; bool visibleInImgui; - std::string rcShortName; - std::string rcSpoilerName; + const char* rcShortName; + const char* rcSpoilerName; bool vanillaCompletion; } RandomizerCheckObject; diff --git a/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp b/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp index aca75ef93dc..02952a05278 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp @@ -1089,7 +1089,7 @@ bool ShouldShowCheck(RandomizerCheckObject check) { IsVisibleInCheckTracker(check) && (checkSearch.Filters.Size == 0 || checkSearch.PassFilter(RandomizerCheckObjects::GetRCAreaName(check.rcArea).c_str()) || - checkSearch.PassFilter(check.rcShortName.c_str())) + checkSearch.PassFilter(check.rcShortName)) ); } diff --git a/soh/soh/Enhancements/randomizer/randomizer_tricks.cpp b/soh/soh/Enhancements/randomizer/randomizer_tricks.cpp index 8a397f840ca..4b704ccc001 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_tricks.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_tricks.cpp @@ -21,7 +21,7 @@ std::vector extremeBase{RTTAG_EXTREME}; // Experimental - not implemented; these tricks may let you put the game into a softlockable state // Please see https://www.youtube.com/playlist?list=PLqsXSioZwQyoa23_27l5NZq5IZdKRi5Sm for reference on performing several of these tricks // RandomizerTrick, RTVORMQ, RTAREA, rt_tags rt_glitch (is it a glitch) "Short name", "Description" -std::unordered_map rtObjects = { +static constexpr std::pair rtObjectsData[] = { RT_OBJECT(RT_ACUTE_ANGLE_CLIP, RTVORMQ_BOTH, RTAREA_GENERAL, &advancedBase, true, "Acute angle clip", "Enables locations requiring jumpslash clips through walls which meet at an acute angle."), RT_OBJECT(RT_ADVANCED_CLIPS, RTVORMQ_BOTH, RTAREA_GENERAL, &advancedBase, true, "Advanced clips", "Enables locations requiring clips through walls and objects requiring precise jumps or other tricks."), RT_OBJECT(RT_BLANK_A, RTVORMQ_BOTH, RTAREA_GENERAL, &advancedBase, true, "Blank A", "Enables locations requiring blank A button; NOTE: this requires the 'Quick Putaway' restoration."), @@ -208,6 +208,7 @@ std::unordered_map rtObjects = { RT_OBJECT(RT_GANON_MQ_SHADOW_TRIAL, RTVORMQ_MQ, RTAREA_GANONS_CASTLE, &noviceBase, false, "Shadow Trial MQ Torch with Bow", "You can light the torch in this room without a fire source by shooting an arrow through the lit torch at the beginning of the room. Because the room is so dark and the unlit torch is so far away, it can be difficult to aim the shot correctly."), RT_OBJECT(RT_GANON_MQ_LIGHT_TRIAL, RTVORMQ_MQ, RTAREA_GANONS_CASTLE, &intermediateBase, /*todo*/ false, "Light Trial MQ without Hookshot", "If you move quickly you can sneak past the edge of a flame wall before it can rise up to block you. In this case to do it without taking damage is especially precise.") }; +std::unordered_map rtObjects = std::unordered_map(std::begin(rtObjectsData), std::end(rtObjectsData)); std::unordered_map rtAreaNames = { { RTAREA_GENERAL, "General Tricks"}, diff --git a/soh/soh/Enhancements/randomizer/randomizer_tricks.h b/soh/soh/Enhancements/randomizer/randomizer_tricks.h index 6fb4a43414b..5d1df34d4c6 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_tricks.h +++ b/soh/soh/Enhancements/randomizer/randomizer_tricks.h @@ -71,8 +71,8 @@ typedef struct { std::vector *rtTags; bool rtGlitch; bool visibleInImgui; - std::string rtShortName; - std::string rtDesc; + const char* rtShortName; + const char* rtDesc; } RandomizerTrickObject; namespace RandomizerTricks { From 79a29a62efc60865c9fe55eae8f665d4ca073249 Mon Sep 17 00:00:00 2001 From: inspectredc <78732756+inspectredc@users.noreply.github.com> Date: Sun, 16 Jun 2024 04:43:09 +0100 Subject: [PATCH 43/59] Use correct default value (#4194) --- soh/src/code/z_message_PAL.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/soh/src/code/z_message_PAL.c b/soh/src/code/z_message_PAL.c index 87cff43da7c..3c77c300c82 100644 --- a/soh/src/code/z_message_PAL.c +++ b/soh/src/code/z_message_PAL.c @@ -1115,7 +1115,7 @@ void Message_DrawText(PlayState* play, Gfx** gfxP) { } } if (msgCtx->textDelayTimer == 0) { - msgCtx->textDrawPos = i + CVarGetInteger("gTextSpeed", 2); + msgCtx->textDrawPos = i + CVarGetInteger("gTextSpeed", 1); msgCtx->textDelayTimer = msgCtx->textDelay; } else { msgCtx->textDelayTimer--; From 839fcffe17f00671baa6fb411cba74f42a7b5f5d Mon Sep 17 00:00:00 2001 From: Pepe20129 <72659707+Pepe20129@users.noreply.github.com> Date: Sun, 16 Jun 2024 05:47:35 +0200 Subject: [PATCH 44/59] Add Alternate Headers XML logger (#4207) --- .../importer/scenecommand/SetAlternateHeadersFactory.cpp | 3 ++- soh/soh/resource/logging/SceneCommandLoggers.cpp | 6 ++++++ soh/soh/resource/type/scenecommand/SetAlternateHeaders.h | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.cpp b/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.cpp index c04f717c379..f5ac8914e2f 100644 --- a/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.cpp @@ -17,6 +17,7 @@ std::shared_ptr SetAlternateHeadersFactory::ReadResource(std::s auto headerName = reader->ReadString(); if (!headerName.empty()) { setAlternateHeaders->headers.push_back(std::static_pointer_cast(Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(headerName.c_str()))); + setAlternateHeaders->headerFileNames.push_back(headerName); } else { setAlternateHeaders->headers.push_back(nullptr); } @@ -41,7 +42,7 @@ std::shared_ptr SetAlternateHeadersFactoryXML::ReadResource(std std::string childName = child->Name(); if (childName == "AlternateHeader") { for (uint32_t i = 0; i < setAlternateHeaders->numHeaders; i++) { - auto headerName = std::string(child->Attribute("HeaderName")); + auto headerName = std::string(child->Attribute("Path")); if (!headerName.empty()) { setAlternateHeaders->headers.push_back(std::static_pointer_cast(Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(headerName.c_str()))); } else { diff --git a/soh/soh/resource/logging/SceneCommandLoggers.cpp b/soh/soh/resource/logging/SceneCommandLoggers.cpp index 7c55bcaf057..805de9be027 100644 --- a/soh/soh/resource/logging/SceneCommandLoggers.cpp +++ b/soh/soh/resource/logging/SceneCommandLoggers.cpp @@ -73,6 +73,12 @@ void LogAlternateHeadersAsXML(std::shared_ptr resource) { tinyxml2::XMLElement* root = doc.NewElement("SetAlternateHeaders"); doc.InsertFirstChild(root); + for (size_t i = 0; i < setAlternateHeaders->headerFileNames.size(); i++) { + tinyxml2::XMLElement* entry = doc.NewElement("Header"); + entry->SetAttribute("Path", setAlternateHeaders->headerFileNames[i].c_str()); + root->InsertEndChild(entry); + } + tinyxml2::XMLPrinter printer; doc.Accept(&printer); diff --git a/soh/soh/resource/type/scenecommand/SetAlternateHeaders.h b/soh/soh/resource/type/scenecommand/SetAlternateHeaders.h index fdddee3f84e..596e0a22eaa 100644 --- a/soh/soh/resource/type/scenecommand/SetAlternateHeaders.h +++ b/soh/soh/resource/type/scenecommand/SetAlternateHeaders.h @@ -21,6 +21,7 @@ class SetAlternateHeaders : public SceneCommand { size_t GetPointerSize(); uint32_t numHeaders; + std::vector headerFileNames; std::vector> headers; }; }; // namespace LUS From 73be4e55591f547df1a27884fdddbae36f603e07 Mon Sep 17 00:00:00 2001 From: Archez Date: Mon, 15 Jul 2024 22:24:38 -0400 Subject: [PATCH 45/59] Bump LUS for 2cyc color combiner fix (#4221) --- CMakeLists.txt | 2 +- libultraship | 2 +- .../cosmetics/authenticGfxPatches.cpp | 16 ---------------- soh/soh/SohGui.cpp | 3 +++ 4 files changed, 5 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 490489f5576..02b7656229d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -88,7 +88,7 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON) # Set GBI version ################################################################################ -add_compile_definitions(F3DEX_GBI_2) +set(GBI_UCODE F3DEX_GBI_2) ################################################################################ # Sub-projects diff --git a/libultraship b/libultraship index 9907ebfd66f..31e9b009f94 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit 9907ebfd66ff5bf903ecb7327cca69014993772b +Subproject commit 31e9b009f94e7074a847c7954926cba354cd7c72 diff --git a/soh/soh/Enhancements/cosmetics/authenticGfxPatches.cpp b/soh/soh/Enhancements/cosmetics/authenticGfxPatches.cpp index f31eedd2cd3..6b74769c120 100644 --- a/soh/soh/Enhancements/cosmetics/authenticGfxPatches.cpp +++ b/soh/soh/Enhancements/cosmetics/authenticGfxPatches.cpp @@ -9,7 +9,6 @@ extern "C" { #include "objects/object_gi_soldout/object_gi_soldout.h" #include "objects/object_ik/object_ik.h" #include "objects/object_link_child/object_link_child.h" -#include "objects/object_ru2/object_ru2.h" uint32_t ResourceMgr_GameHasMasterQuest(); uint32_t ResourceMgr_GameHasOriginal(); @@ -189,25 +188,10 @@ void PatchIronKnuckleTextureOverflow() { } } -void PatchPrincessRutoEaring() { - // FAST3D: This is a hack for the issue of both TEXEL0 and TEXEL1 using the same texture with different settings. - // Ruto's earring uses both TEXEL0 and TEXEL1 to render. The issue is that it never loads anything into TEXEL1, so - // it reuses whatever happens to be there, which is the water temple brick texture. It just so happens that the - // earring texture loads into the same place in TMEM as the brick texture, so when it comes to rendering, TEXEL1 - // uses the earring texture with different clamp settings, and it displays without noticeable error. However, both - // texel samplers are not intended to be used for the same texture with different settings, so this misuse confuses - // our texture cache, and we load the wrong settings for the earrings texture. This patch is a hack that replaces - // TEXEL1 with TEXEL0, which is most likely the original intention, and all is well. - ResourceMgr_PatchGfxByName(gAdultRutoHeadDL, "RutoEaringTileFix", 162, - gsDPSetCombineLERP(TEXEL0, 0, PRIMITIVE, 0, TEXEL0, 0, ENVIRONMENT, 0, 0, 0, 0, COMBINED, - TEXEL0, 0, PRIM_LOD_FRAC, COMBINED)); -} - void ApplyAuthenticGfxPatches() { PatchDekuStickTextureOverflow(); PatchFreezardTextureOverflow(); PatchIronKnuckleTextureOverflow(); - PatchPrincessRutoEaring(); } // Patches the Sold Out GI DL to render the texture in the mirror boundary diff --git a/soh/soh/SohGui.cpp b/soh/soh/SohGui.cpp index 25763525d64..71a3660217f 100644 --- a/soh/soh/SohGui.cpp +++ b/soh/soh/SohGui.cpp @@ -206,6 +206,9 @@ namespace SohGui { } void Destroy() { + auto gui = Ship::Context::GetInstance()->GetWindow()->GetGui(); + gui->RemoveAllGuiWindows(); + mModalWindow = nullptr; mAdvancedResolutionSettingsWindow = nullptr; mRandomizerSettingsWindow = nullptr; From 134aba4aa0e0617a2082cb86db7e1a7eb116c8e0 Mon Sep 17 00:00:00 2001 From: Kenix3 Date: Wed, 17 Jul 2024 14:35:13 -0400 Subject: [PATCH 46/59] Fixes crashes on asan related to audio. (#4049) Found in MM --- soh/soh/mixer.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/soh/soh/mixer.c b/soh/soh/mixer.c index 2e80ffb1658..ba6a01bc1f4 100644 --- a/soh/soh/mixer.c +++ b/soh/soh/mixer.c @@ -99,8 +99,14 @@ void aClearBufferImpl(uint16_t addr, int nbytes) { memset(BUF_U8(addr), 0, nbytes); } -void aLoadBufferImpl(const void *source_addr, uint16_t dest_addr, uint16_t nbytes) { +void aLoadBufferImpl(const void* source_addr, uint16_t dest_addr, uint16_t nbytes) { +#if __SANITIZE_ADDRESS__ + for (size_t i = 0; i < ROUND_DOWN_16(nbytes); i++) { + BUF_U8(dest_addr)[i] = ((const unsigned char*)source_addr)[i]; + } +#else memcpy(BUF_U8(dest_addr), source_addr, ROUND_DOWN_16(nbytes)); +#endif } void aSaveBufferImpl(uint16_t source_addr, int16_t *dest_addr, uint16_t nbytes) { From 3d73faa9a0c75e13e25f0d8d73994ca6dbe71938 Mon Sep 17 00:00:00 2001 From: Malkierian Date: Wed, 17 Jul 2024 12:57:11 -0700 Subject: [PATCH 47/59] Port Graphics Menu lag fix from 2ship. (#4238) * Port Graphics Menu lag fix from 2ship. * tweak --------- Co-authored-by: Adam Bird --- soh/soh/SohMenuBar.cpp | 61 +++++++++++++++++++++++++----------------- soh/soh/SohMenuBar.h | 2 +- 2 files changed, 38 insertions(+), 25 deletions(-) diff --git a/soh/soh/SohMenuBar.cpp b/soh/soh/SohMenuBar.cpp index 0917b0c6d9b..575dcbc1a89 100644 --- a/soh/soh/SohMenuBar.cpp +++ b/soh/soh/SohMenuBar.cpp @@ -50,6 +50,13 @@ std::string GetWindowButtonText(const char* text, bool menuOpen) { if (!menuOpen) { strcat(buttonText, " "); } return buttonText; } + +static std::unordered_map windowBackendNames = { + { LUS::WindowBackend::DX11, "DirectX" }, + { LUS::WindowBackend::SDL_OPENGL, "OpenGL"}, + { LUS::WindowBackend::SDL_METAL, "Metal" }, + { LUS::WindowBackend::GX2, "GX2"} +}; static const char* imguiScaleOptions[4] = { "Small", "Normal", "Large", "X-Large" }; @@ -102,6 +109,24 @@ extern "C" SaveContext gSaveContext; namespace SohGui { +std::unordered_map availableWindowBackendsMap; +LUS::WindowBackend configWindowBackend; + +void UpdateWindowBackendObjects() { + LUS::WindowBackend runningWindowBackend = LUS::Context::GetInstance()->GetWindow()->GetWindowBackend(); + int32_t configWindowBackendId = LUS::Context::GetInstance()->GetConfig()->GetInt("Window.Backend.Id", -1); + if (configWindowBackendId != -1 && configWindowBackendId < static_cast(LUS::WindowBackend::BACKEND_COUNT)) { + configWindowBackend = static_cast(configWindowBackendId); + } else { + configWindowBackend = runningWindowBackend; + } + + auto availableWindowBackends = LUS::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends(); + for (auto& backend : *availableWindowBackends) { + availableWindowBackendsMap[backend] = windowBackendNames[backend]; + } +} + void DrawMenuBarIcon() { static bool gameIconLoaded = false; if (!gameIconLoaded) { @@ -391,40 +416,24 @@ void DrawSettingsMenu() { UIWidgets::Tooltip("Changes the scaling of the ImGui menu elements."); UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); - - static std::unordered_map windowBackendNames = { - { LUS::WindowBackend::DX11, "DirectX" }, - { LUS::WindowBackend::SDL_OPENGL, "OpenGL"}, - { LUS::WindowBackend::SDL_METAL, "Metal" }, - { LUS::WindowBackend::GX2, "GX2"} - }; ImGui::Text("Renderer API (Needs reload)"); - LUS::WindowBackend runningWindowBackend = LUS::Context::GetInstance()->GetWindow()->GetWindowBackend(); - LUS::WindowBackend configWindowBackend; - int configWindowBackendId = LUS::Context::GetInstance()->GetConfig()->GetInt("Window.Backend.Id", -1); - if (configWindowBackendId != -1 && configWindowBackendId < static_cast(LUS::WindowBackend::BACKEND_COUNT)) { - configWindowBackend = static_cast(configWindowBackendId); - } else { - configWindowBackend = runningWindowBackend; - } - if (LUS::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends()->size() <= 1) { + if (availableWindowBackendsMap.size() <= 1) { UIWidgets::DisableComponent(ImGui::GetStyle().Alpha * 0.5f); } - if (ImGui::BeginCombo("##RApi", windowBackendNames[configWindowBackend])) { - for (size_t i = 0; i < LUS::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends()->size(); i++) { - auto backend = LUS::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends()->data()[i]; - if (ImGui::Selectable(windowBackendNames[backend], backend == configWindowBackend)) { - LUS::Context::GetInstance()->GetConfig()->SetInt("Window.Backend.Id", static_cast(backend)); - LUS::Context::GetInstance()->GetConfig()->SetString("Window.Backend.Name", - windowBackendNames[backend]); + if (ImGui::BeginCombo("##RApi", availableWindowBackendsMap[configWindowBackend])) { + for (auto backend : availableWindowBackendsMap) { + if (ImGui::Selectable(backend.second, backend.first == configWindowBackend)) { + LUS::Context::GetInstance()->GetConfig()->SetInt("Window.Backend.Id", static_cast(backend.first)); + LUS::Context::GetInstance()->GetConfig()->SetString("Window.Backend.Name", backend.second); LUS::Context::GetInstance()->GetConfig()->Save(); + UpdateWindowBackendObjects(); } } ImGui::EndCombo(); } - if (LUS::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends()->size() <= 1) { + if (availableWindowBackendsMap.size() <= 1) { UIWidgets::ReEnableComponent(""); } @@ -1610,6 +1619,10 @@ void DrawRandomizerMenu() { } } +void SohMenuBar::InitElement() { + UpdateWindowBackendObjects(); +} + void SohMenuBar::DrawElement() { if (ImGui::BeginMenuBar()) { DrawMenuBarIcon(); diff --git a/soh/soh/SohMenuBar.h b/soh/soh/SohMenuBar.h index ce62344addf..238903f19e6 100644 --- a/soh/soh/SohMenuBar.h +++ b/soh/soh/SohMenuBar.h @@ -10,7 +10,7 @@ class SohMenuBar : public LUS::GuiMenuBar { using LUS::GuiMenuBar::GuiMenuBar; protected: void DrawElement() override; - void InitElement() override {}; + void InitElement() override; void UpdateElement() override {}; }; } // namespace SohGui \ No newline at end of file From 7bc2259c825597334c1ca02786f8acdc1e6984fb Mon Sep 17 00:00:00 2001 From: Malkierian Date: Sun, 21 Jul 2024 12:29:45 -0700 Subject: [PATCH 48/59] LUS bump and implement alt assets performance changes. (#4240) * LUS bump and implement alt assets performance changes. * LUS ref update. --- libultraship | 2 +- soh/soh/OTRGlobals.cpp | 23 +++++++++++++++-------- soh/soh/OTRGlobals.h | 1 + soh/soh/SohGui.cpp | 1 - soh/soh/SohMenuBar.cpp | 8 +------- soh/soh/resource/type/Skeleton.cpp | 7 +++---- soh/src/code/game.c | 2 +- soh/src/code/gfxprint.c | 2 +- 8 files changed, 23 insertions(+), 23 deletions(-) diff --git a/libultraship b/libultraship index 96c8a8929c1..275c741d5dd 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit 96c8a8929c18c1bffd7d92a35a589f74cf16fc59 +Subproject commit 275c741d5dd48d78b6a746c0709c75d095e48eeb diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index bb45fdba75c..136cb247321 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -137,6 +137,8 @@ Color_RGB8 zoraColor = { 0x00, 0xEC, 0x64 }; float previousImGuiScale; +bool prevAltAssets = false; + // Same as NaviColor type from OoT src (z_actor.c), but modified to be sans alpha channel for Controller LED. typedef struct { Color_RGB8 inner; @@ -297,6 +299,8 @@ OTRGlobals::OTRGlobals() { }; // tell LUS to reserve 3 SoH specific threads (Game, Audio, Save) context = LUS::Context::CreateInstance("Ship of Harkinian", appShortName, "shipofharkinian.json", OTRFiles, {}, 3); + prevAltAssets = CVarGetInteger("gAltAssets", 0); + context->GetResourceManager()->SetAltAssetsEnabled(prevAltAssets); SPDLOG_INFO("Starting Ship of Harkinian version {}", (char*)gBuildVersion); context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(LUS::ResourceType::SOH_Animation, "Animation", std::make_shared()); @@ -1235,7 +1239,7 @@ extern "C" void Graph_StartFrame() { } #endif case KbScancode::LUS_KB_TAB: { - ToggleAltAssetsAtEndOfFrame = true; + CVarSetInteger("gAltAssets", !CVarGetInteger("gAltAssets", 0)); break; } } @@ -1315,11 +1319,10 @@ extern "C" void Graph_ProcessGfxCommands(Gfx* commands) { } } - if (ToggleAltAssetsAtEndOfFrame) { - ToggleAltAssetsAtEndOfFrame = false; - - // Actually update the CVar now before runing the alt asset update listeners - CVarSetInteger("gAltAssets", !CVarGetInteger("gAltAssets", 0)); + bool curAltAssets = CVarGetInteger("gAltAssets", 0); + if (prevAltAssets != curAltAssets) { + prevAltAssets = curAltAssets; + LUS::Context::GetInstance()->GetResourceManager()->SetAltAssetsEnabled(curAltAssets); gfx_texture_cache_clear(); LUS::SkeletonPatcher::UpdateSkeletons(); GameInteractor::Instance->ExecuteHooks(); @@ -1495,10 +1498,14 @@ extern "C" uint8_t ResourceMgr_FileAltExists(const char* filePath) { return ExtensionCache.contains(path); } +extern "C" bool ResourceMgr_IsAltAssetsEnabled() { + return LUS::Context::GetInstance()->GetResourceManager()->IsAltAssetsEnabled(); +} + // Unloads a resource if an alternate version exists when alt assets are enabled // The resource is only removed from the internal cache to prevent it from used in the next resource lookup extern "C" void ResourceMgr_UnloadOriginalWhenAltExists(const char* resName) { - if (CVarGetInteger("gAltAssets", 0) && ResourceMgr_FileAltExists((char*) resName)) { + if (ResourceMgr_IsAltAssetsEnabled() && ResourceMgr_FileAltExists((char*) resName)) { ResourceMgr_UnloadResource((char*) resName); } } @@ -1868,7 +1875,7 @@ extern "C" SkeletonHeader* ResourceMgr_LoadSkeletonByName(const char* path, Skel pathStr = pathStr.substr(sOtr.length()); } - bool isAlt = CVarGetInteger("gAltAssets", 0); + bool isAlt = ResourceMgr_IsAltAssetsEnabled(); if (isAlt) { pathStr = LUS::IResource::gAltAssetPrefix + pathStr; diff --git a/soh/soh/OTRGlobals.h b/soh/soh/OTRGlobals.h index a93df7efbf2..639ba2c3498 100644 --- a/soh/soh/OTRGlobals.h +++ b/soh/soh/OTRGlobals.h @@ -120,6 +120,7 @@ void Ctx_ReadSaveFile(uintptr_t addr, void* dramAddr, size_t size); void Ctx_WriteSaveFile(uintptr_t addr, void* dramAddr, size_t size); uint64_t GetPerfCounter(); +bool ResourceMgr_IsAltAssetsEnabled(); struct SkeletonHeader* ResourceMgr_LoadSkeletonByName(const char* path, SkelAnime* skelAnime); void ResourceMgr_UnregisterSkeleton(SkelAnime* skelAnime); void ResourceMgr_ClearSkeletons(); diff --git a/soh/soh/SohGui.cpp b/soh/soh/SohGui.cpp index 90f6e59e5ea..6dda944b5a6 100644 --- a/soh/soh/SohGui.cpp +++ b/soh/soh/SohGui.cpp @@ -38,7 +38,6 @@ #include "Enhancements/game-interactor/GameInteractor.h" #include "Enhancements/cosmetics/authenticGfxPatches.h" -bool ToggleAltAssetsAtEndOfFrame = false; bool isBetaQuestEnabled = false; extern "C" { diff --git a/soh/soh/SohMenuBar.cpp b/soh/soh/SohMenuBar.cpp index 575dcbc1a89..ee9a2708d72 100644 --- a/soh/soh/SohMenuBar.cpp +++ b/soh/soh/SohMenuBar.cpp @@ -28,7 +28,6 @@ #include "Enhancements/randomizer/randomizer_item_tracker.h" #include "Enhancements/randomizer/randomizer_settings_window.h" -extern bool ToggleAltAssetsAtEndOfFrame; extern bool isBetaQuestEnabled; extern "C" PlayState* gPlayState; @@ -916,12 +915,7 @@ void DrawEnhancementsMenu() { if (ImGui::BeginMenu("Graphics")) { if (ImGui::BeginMenu("Mods")) { - if (UIWidgets::PaddedEnhancementCheckbox("Use Alternate Assets", "gAltAssets", false, false)) { - // The checkbox will flip the alt asset CVar, but we instead want it to change at the end of the game frame - // We toggle it back while setting the flag to update the CVar later - CVarSetInteger("gAltAssets", !CVarGetInteger("gAltAssets", 0)); - ToggleAltAssetsAtEndOfFrame = true; - } + UIWidgets::PaddedEnhancementCheckbox("Use Alternate Assets", "gAltAssets", false, false); UIWidgets::Tooltip("Toggle between standard assets and alternate assets. Usually mods will indicate if this setting has to be used or not."); UIWidgets::PaddedEnhancementCheckbox("Disable Bomb Billboarding", "gDisableBombBillboarding", true, false); UIWidgets::Tooltip("Disables bombs always rotating to face the camera. To be used in conjunction with mods that want to replace bombs with 3D objects."); diff --git a/soh/soh/resource/type/Skeleton.cpp b/soh/soh/resource/type/Skeleton.cpp index 13798d3c5bd..d83f8b91e44 100644 --- a/soh/soh/resource/type/Skeleton.cpp +++ b/soh/soh/resource/type/Skeleton.cpp @@ -65,12 +65,11 @@ void SkeletonPatcher::ClearSkeletons() } void SkeletonPatcher::UpdateSkeletons() { - bool isHD = CVarGetInteger("gAltAssets", 0); + auto resourceMgr = LUS::Context::GetInstance()->GetResourceManager(); + bool isHD = resourceMgr->IsAltAssetsEnabled(); for (auto skel : skeletons) { Skeleton* newSkel = - (Skeleton*)LUS::Context::GetInstance()->GetResourceManager() - ->LoadResource((isHD ? LUS::IResource::gAltAssetPrefix : "") + skel.vanillaSkeletonPath, true) - .get(); + (Skeleton*)resourceMgr->LoadResource((isHD ? LUS::IResource::gAltAssetPrefix : "") + skel.vanillaSkeletonPath, true).get(); if (newSkel != nullptr) { skel.skelAnime->skeleton = newSkel->skeletonData.skeletonHeader.segment; diff --git a/soh/src/code/game.c b/soh/src/code/game.c index b46aa4ebd83..46c212b7a92 100644 --- a/soh/src/code/game.c +++ b/soh/src/code/game.c @@ -467,7 +467,7 @@ void GameState_Destroy(GameState* gameState) { // Performing clear skeletons before unload resources fixes an actor heap corruption crash due to the skeleton patching system. ResourceMgr_ClearSkeletons(); - if (CVarGetInteger("gAltAssets", 0)) { + if (ResourceMgr_IsAltAssetsEnabled()) { ResourceUnloadDirectory("alt/*"); gfx_texture_cache_clear(); } diff --git a/soh/src/code/gfxprint.c b/soh/src/code/gfxprint.c index 8a0dbead434..cb33ec5666b 100644 --- a/soh/src/code/gfxprint.c +++ b/soh/src/code/gfxprint.c @@ -141,7 +141,7 @@ static const ALIGN_ASSET(2) char rGfxPrintFontDataAlt[] = drGfxPrintFontDataAlt; // https://github.com/HarbourMasters/Shipwright/issues/2762 typedef enum {hardcoded, otrDefault, otrAlt} font_texture_t; font_texture_t GfxPrint_TextureToUse() { - if (CVarGetInteger("gAltAssets", 0) && ResourceMgr_FileExists(rGfxPrintFontDataAlt)) { + if (ResourceMgr_IsAltAssetsEnabled() && ResourceMgr_FileExists(rGfxPrintFontDataAlt)) { // If we have alt assets enabled, and we have alt prefixed font texture, use that return otrAlt; } else if (ResourceMgr_FileExists(rGfxPrintFontData)) { From 7a00658be94d7ed9841c3377d166fde2364d88b9 Mon Sep 17 00:00:00 2001 From: Archez Date: Sun, 21 Jul 2024 15:30:18 -0400 Subject: [PATCH 49/59] Fix disable lod breaking certain effects (#4245) --- soh/src/code/z_fcurve_data_skelanime.c | 4 ---- soh/src/overlays/actors/ovl_player_actor/z_player.c | 4 ---- 2 files changed, 8 deletions(-) diff --git a/soh/src/code/z_fcurve_data_skelanime.c b/soh/src/code/z_fcurve_data_skelanime.c index b75c34a61f8..c75450be206 100644 --- a/soh/src/code/z_fcurve_data_skelanime.c +++ b/soh/src/code/z_fcurve_data_skelanime.c @@ -131,10 +131,6 @@ void SkelCurve_DrawLimb(PlayState* play, s32 limbIndex, SkelAnimeCurve* skelCurv Matrix_TranslateRotateZYX(&pos, &rot); Matrix_Scale(scale.x, scale.y, scale.z, MTXMODE_APPLY); - if (CVarGetInteger("gDisableLOD", 0)) { - lod = 0; - } - if (lod == 0) { s32 pad1; diff --git a/soh/src/overlays/actors/ovl_player_actor/z_player.c b/soh/src/overlays/actors/ovl_player_actor/z_player.c index 965389c40df..f4a072c40e2 100644 --- a/soh/src/overlays/actors/ovl_player_actor/z_player.c +++ b/soh/src/overlays/actors/ovl_player_actor/z_player.c @@ -11339,10 +11339,6 @@ void Player_Draw(Actor* thisx, PlayState* play2) { lod = 1; } - if (CVarGetInteger("gDisableLOD", 0)) { - lod = 0; - } - func_80093C80(play); Gfx_SetupDL_25Xlu(play->state.gfxCtx); From f11f97e84e508dfca79c1232ee39e746cb0afb1c Mon Sep 17 00:00:00 2001 From: Nicholas Estelami Date: Mon, 5 Aug 2024 15:20:40 -0400 Subject: [PATCH 50/59] Custom Skeleton Fixes for various bosses and enemies (#3436) * Skeleton Fixes for various bosses and enemies * cleanup * revert breakpart changes --------- Co-authored-by: Adam Bird --- soh/include/functions.h | 2 ++ soh/include/z64.h | 2 ++ soh/src/code/z_skelanime.c | 20 +++++++++++ .../actors/ovl_Boss_Dodongo/z_boss_dodongo.c | 17 +++++++-- .../actors/ovl_Boss_Goma/z_boss_goma.c | 36 ++++++++++++++++--- .../actors/ovl_Door_Warp1/z_door_warp1.c | 4 +-- .../overlays/actors/ovl_En_Bili/z_en_bili.c | 2 +- soh/src/overlays/actors/ovl_En_Box/z_en_box.c | 4 +-- soh/src/overlays/actors/ovl_En_Bw/z_en_bw.c | 4 +-- .../overlays/actors/ovl_En_Eiyer/z_en_eiyer.c | 4 +-- soh/src/overlays/actors/ovl_En_Elf/z_en_elf.c | 2 +- .../actors/ovl_En_Firefly/z_en_firefly.c | 7 ++-- .../actors/ovl_En_Partner/z_en_partner.c | 2 +- .../actors/ovl_En_Po_Desert/z_en_po_desert.c | 2 +- .../actors/ovl_En_Po_Field/z_en_po_field.c | 5 ++- .../ovl_En_Po_Sisters/z_en_po_sisters.c | 8 ++--- soh/src/overlays/actors/ovl_En_Poh/z_en_poh.c | 4 +-- .../overlays/actors/ovl_En_Vali/z_en_vali.c | 2 +- .../actors/ovl_En_Weiyer/z_en_weiyer.c | 6 ++-- soh/src/overlays/actors/ovl_En_Zf/z_en_zf.c | 4 +-- 20 files changed, 100 insertions(+), 37 deletions(-) diff --git a/soh/include/functions.h b/soh/include/functions.h index 3a1aa8ae24a..55363067228 100644 --- a/soh/include/functions.h +++ b/soh/include/functions.h @@ -1259,6 +1259,8 @@ void SkelAnime_DrawFlexLod(PlayState* play, void** skeleton, Vec3s* jointTable, s32 dListIndex); void SkelAnime_DrawSkeletonOpa(PlayState* play, SkelAnime* skelAnime, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, void* arg); +Gfx* SkelAnime_DrawSkeleton2(PlayState* play, SkelAnime* skelAnime, OverrideLimbDrawOpa overrideLimbDraw, + PostLimbDrawOpa postLimbDraw, void* arg, Gfx* gfx); void SkelAnime_DrawOpa(PlayState* play, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, void* arg); void SkelAnime_DrawFlexOpa(PlayState* play, void** skeleton, Vec3s* jointTable, s32 dListCount, diff --git a/soh/include/z64.h b/soh/include/z64.h index f790dddc759..be0bceed2a1 100644 --- a/soh/include/z64.h +++ b/soh/include/z64.h @@ -1405,6 +1405,8 @@ typedef struct PlayState { /* 0x1242B */ u8 unk_1242B; /* 0x1242C */ SceneTableEntry* loadedScene; /* 0x12430 */ char unk_12430[0xE8]; + // SOH [Custom Models] MTX tracker for flex based skeletons + Mtx** flexLimbOverrideMTX; } PlayState; // size = 0x12518 typedef struct { diff --git a/soh/src/code/z_skelanime.c b/soh/src/code/z_skelanime.c index 2123c2d3bbb..ae59e187bff 100644 --- a/soh/src/code/z_skelanime.c +++ b/soh/src/code/z_skelanime.c @@ -148,6 +148,8 @@ void SkelAnime_DrawFlexLimbLod(PlayState* play, s32 limbIndex, void** skeleton, newDList = limbDList = limb->dLists[lod]; + play->flexLimbOverrideMTX = mtx; + if ((overrideLimbDraw == NULL) || !overrideLimbDraw(play, limbIndex, &newDList, &pos, &rot, arg)) { Matrix_TranslateRotateZYX(&pos, &rot); if (newDList != NULL) { @@ -220,6 +222,8 @@ void SkelAnime_DrawFlexLod(PlayState* play, void** skeleton, Vec3s* jointTable, newDList = limbDList = rootLimb->dLists[lod]; + play->flexLimbOverrideMTX = &mtx; + if ((overrideLimbDraw == 0) || !overrideLimbDraw(play, 1, &newDList, &pos, &rot, arg)) { Matrix_TranslateRotateZYX(&pos, &rot); if (newDList != NULL) { @@ -306,6 +310,20 @@ void SkelAnime_DrawSkeletonOpa(PlayState* play, SkelAnime* skelAnime, OverrideLi } } +Gfx* SkelAnime_DrawSkeleton2(PlayState* play, SkelAnime* skelAnime, OverrideLimbDrawOpa overrideLimbDraw, + PostLimbDrawOpa postLimbDraw, void* arg, Gfx* gfx) +{ + if (skelAnime->skeletonHeader->skeletonType == SKELANIME_TYPE_NORMAL) { + return SkelAnime_Draw(play, skelAnime->skeleton, skelAnime->jointTable, overrideLimbDraw, postLimbDraw, arg, gfx); + } else if (skelAnime->skeletonHeader->skeletonType == SKELANIME_TYPE_FLEX) { + FlexSkeletonHeader* flexHeader = (FlexSkeletonHeader*)skelAnime->skeletonHeader; + return SkelAnime_DrawFlex(play, skelAnime->skeleton, skelAnime->jointTable, flexHeader->dListCount, + overrideLimbDraw, postLimbDraw, arg, gfx); + } + + return gfx; +} + /** * Draw all limbs of type `StandardLimb` in a given skeleton to the polyOpa buffer */ @@ -383,6 +401,8 @@ void SkelAnime_DrawFlexLimbOpa(PlayState* play, s32 limbIndex, void** skeleton, newDList = limbDList = limb->dList; + play->flexLimbOverrideMTX = limbMatricies; + if ((overrideLimbDraw == NULL) || !overrideLimbDraw(play, limbIndex, &newDList, &pos, &rot, arg)) { Matrix_TranslateRotateZYX(&pos, &rot); if (newDList != NULL) { diff --git a/soh/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c b/soh/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c index 1f279154070..3a8a8215f93 100644 --- a/soh/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c +++ b/soh/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c @@ -1288,6 +1288,10 @@ s32 BossDodongo_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Ve if (*dList != NULL) { OPEN_DISPS(play->state.gfxCtx); + if (this->skelAnime.skeletonHeader->skeletonType == SKELANIME_TYPE_FLEX) { + MATRIX_TOMTX(*play->flexLimbOverrideMTX); + } + mtxScaleZ = 1.0f; mtxScaleY = 1.0f; @@ -1308,11 +1312,20 @@ s32 BossDodongo_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Ve Matrix_RotateX(-(this->unk_25C[limbIndex] * 0.115f), MTXMODE_APPLY); } - gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + if (this->skelAnime.skeletonHeader->skeletonType == SKELANIME_TYPE_FLEX) { + gSPMatrix(POLY_OPA_DISP++, *play->flexLimbOverrideMTX, G_MTX_LOAD); + } else { + gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + } + gSPDisplayList(POLY_OPA_DISP++, *dList); Matrix_Pop(); + if (this->skelAnime.skeletonHeader->skeletonType == SKELANIME_TYPE_FLEX) { + (*play->flexLimbOverrideMTX)++; + } + CLOSE_DISPS(play->state.gfxCtx); } { s32 pad; } // Required to match diff --git a/soh/src/overlays/actors/ovl_Boss_Goma/z_boss_goma.c b/soh/src/overlays/actors/ovl_Boss_Goma/z_boss_goma.c index 6de72fd2dff..f6e2b3f3193 100644 --- a/soh/src/overlays/actors/ovl_Boss_Goma/z_boss_goma.c +++ b/soh/src/overlays/actors/ovl_Boss_Goma/z_boss_goma.c @@ -2015,12 +2015,26 @@ s32 BossGoma_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f Matrix_TranslateRotateZYX(pos, rot); if (*dList != NULL) { + if (this->skelanime.skeletonHeader->skeletonType == SKELANIME_TYPE_FLEX) { + MATRIX_TOMTX(*play->flexLimbOverrideMTX); + } + Matrix_Push(); Matrix_Scale(this->eyeIrisScaleX, this->eyeIrisScaleY, 1.0f, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + if (this->skelanime.skeletonHeader->skeletonType == SKELANIME_TYPE_FLEX) { + gSPMatrix(POLY_OPA_DISP++, *play->flexLimbOverrideMTX, G_MTX_LOAD); + } else { + gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + } + gSPDisplayList(POLY_OPA_DISP++, *dList); Matrix_Pop(); + + if (this->skelanime.skeletonHeader->skeletonType == SKELANIME_TYPE_FLEX) { + (*play->flexLimbOverrideMTX)++; + } } doNotDrawLimb = true; @@ -2034,14 +2048,28 @@ s32 BossGoma_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f Matrix_TranslateRotateZYX(pos, rot); if (*dList != NULL) { + if (this->skelanime.skeletonHeader->skeletonType == SKELANIME_TYPE_FLEX) { + MATRIX_TOMTX(*play->flexLimbOverrideMTX); + } + Matrix_Push(); Matrix_Scale(this->tailLimbsScale[limbIndex - BOSSGOMA_LIMB_TAIL4], this->tailLimbsScale[limbIndex - BOSSGOMA_LIMB_TAIL4], this->tailLimbsScale[limbIndex - BOSSGOMA_LIMB_TAIL4], MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + if (this->skelanime.skeletonHeader->skeletonType == SKELANIME_TYPE_FLEX) { + gSPMatrix(POLY_OPA_DISP++, *play->flexLimbOverrideMTX, G_MTX_LOAD); + } else { + gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + } + gSPDisplayList(POLY_OPA_DISP++, *dList); Matrix_Pop(); + + if (this->skelanime.skeletonHeader->skeletonType == SKELANIME_TYPE_FLEX) { + (*play->flexLimbOverrideMTX)++; + } } doNotDrawLimb = true; diff --git a/soh/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c b/soh/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c index 5940f8c03ab..08b9a0749d7 100644 --- a/soh/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c +++ b/soh/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c @@ -1055,7 +1055,7 @@ void DoorWarp1_DrawBlueCrystal(DoorWarp1* this, PlayState* play) { gDPSetPrimColor(POLY_XLU_DISP++, 0xFF, 0xFF, 200, 255, 255, (u8)this->crystalAlpha); gDPSetEnvColor(POLY_XLU_DISP++, 0, 100, 255, (u8)this->crystalAlpha); - POLY_XLU_DISP = SkelAnime_Draw(play, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, + POLY_XLU_DISP = SkelAnime_DrawSkeleton2(play, &this->skelAnime, NULL, NULL, &this->actor, POLY_XLU_DISP); CLOSE_DISPS(play->state.gfxCtx); @@ -1079,7 +1079,7 @@ void DoorWarp1_DrawPurpleCrystal(DoorWarp1* this, PlayState* play) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (u8)this->crystalAlpha); gDPSetEnvColor(POLY_XLU_DISP++, 150, 0, 100, (u8)this->crystalAlpha); - POLY_XLU_DISP = SkelAnime_Draw(play, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, + POLY_XLU_DISP = SkelAnime_DrawSkeleton2(play, &this->skelAnime, NULL, NULL, &this->actor, POLY_XLU_DISP); CLOSE_DISPS(play->state.gfxCtx); diff --git a/soh/src/overlays/actors/ovl_En_Bili/z_en_bili.c b/soh/src/overlays/actors/ovl_En_Bili/z_en_bili.c index 74f89cbe3ec..a50dabe0107 100644 --- a/soh/src/overlays/actors/ovl_En_Bili/z_en_bili.c +++ b/soh/src/overlays/actors/ovl_En_Bili/z_en_bili.c @@ -768,7 +768,7 @@ void EnBili_Draw(Actor* thisx, PlayState* play) { gSPSegment(POLY_XLU_DISP++, 0x09, D_809C1700); } - POLY_XLU_DISP = SkelAnime_Draw(play, this->skelAnime.skeleton, this->skelAnime.jointTable, + POLY_XLU_DISP = SkelAnime_DrawSkeleton2(play, &this->skelAnime, EnBili_OverrideLimbDraw, NULL, this, POLY_XLU_DISP); CLOSE_DISPS(play->state.gfxCtx); } diff --git a/soh/src/overlays/actors/ovl_En_Box/z_en_box.c b/soh/src/overlays/actors/ovl_En_Box/z_en_box.c index 4f1ef73626a..359c983e9dd 100644 --- a/soh/src/overlays/actors/ovl_En_Box/z_en_box.c +++ b/soh/src/overlays/actors/ovl_En_Box/z_en_box.c @@ -947,7 +947,7 @@ void EnBox_Draw(Actor* thisx, PlayState* play) { gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); gSPSegment(POLY_OPA_DISP++, 0x08, EnBox_EmptyDList(play->state.gfxCtx)); Gfx_SetupDL_25Opa(play->state.gfxCtx); - POLY_OPA_DISP = SkelAnime_Draw(play, this->skelanime.skeleton, this->skelanime.jointTable, NULL, + POLY_OPA_DISP = SkelAnime_DrawSkeleton2(play, &this->skelanime, NULL, EnBox_PostLimbDraw, this, POLY_OPA_DISP); } else if (this->alpha != 0) { gDPPipeSync(POLY_XLU_DISP++); @@ -958,7 +958,7 @@ void EnBox_Draw(Actor* thisx, PlayState* play) { } else { gSPSegment(POLY_XLU_DISP++, 0x08, func_809CA4A0(play->state.gfxCtx)); } - POLY_XLU_DISP = SkelAnime_Draw(play, this->skelanime.skeleton, this->skelanime.jointTable, NULL, + POLY_XLU_DISP = SkelAnime_DrawSkeleton2(play, &this->skelanime, NULL, EnBox_PostLimbDraw, this, POLY_XLU_DISP); } diff --git a/soh/src/overlays/actors/ovl_En_Bw/z_en_bw.c b/soh/src/overlays/actors/ovl_En_Bw/z_en_bw.c index a57594a0ffe..e64abd8df40 100644 --- a/soh/src/overlays/actors/ovl_En_Bw/z_en_bw.c +++ b/soh/src/overlays/actors/ovl_En_Bw/z_en_bw.c @@ -856,7 +856,7 @@ void EnBw_Draw(Actor* thisx, PlayState* play2) { Gfx_SetupDL_25Opa(play->state.gfxCtx); gDPSetEnvColor(POLY_OPA_DISP++, this->color1.r, this->color1.g, this->color1.b, this->color1.a); gSPSegment(POLY_OPA_DISP++, 0x08, &D_80116280[2]); - POLY_OPA_DISP = SkelAnime_Draw(play, this->skelAnime.skeleton, this->skelAnime.jointTable, + POLY_OPA_DISP = SkelAnime_DrawSkeleton2(play, &this->skelAnime, EnBw_OverrideLimbDraw, NULL, this, POLY_OPA_DISP); } else { Gfx_SetupDL_25Xlu(play->state.gfxCtx); @@ -864,7 +864,7 @@ void EnBw_Draw(Actor* thisx, PlayState* play2) { gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 0, 0, 0, this->color1.a); gDPSetEnvColor(POLY_XLU_DISP++, this->color1.r, this->color1.g, this->color1.b, this->color1.a); gSPSegment(POLY_XLU_DISP++, 0x08, &D_80116280[0]); - POLY_XLU_DISP = SkelAnime_Draw(play, this->skelAnime.skeleton, this->skelAnime.jointTable, + POLY_XLU_DISP = SkelAnime_DrawSkeleton2(play, &this->skelAnime, EnBw_OverrideLimbDraw, NULL, this, POLY_XLU_DISP); } diff --git a/soh/src/overlays/actors/ovl_En_Eiyer/z_en_eiyer.c b/soh/src/overlays/actors/ovl_En_Eiyer/z_en_eiyer.c index 04957071606..7340d9cf5d6 100644 --- a/soh/src/overlays/actors/ovl_En_Eiyer/z_en_eiyer.c +++ b/soh/src/overlays/actors/ovl_En_Eiyer/z_en_eiyer.c @@ -708,14 +708,14 @@ void EnEiyer_Draw(Actor* thisx, PlayState* play) { gSPSegment(POLY_OPA_DISP++, 0x08, &D_80116280[2]); gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); - POLY_OPA_DISP = SkelAnime_Draw(play, this->skelanime.skeleton, this->skelanime.jointTable, + POLY_OPA_DISP = SkelAnime_DrawSkeleton2(play, &this->skelanime, EnEiyer_OverrideLimbDraw, NULL, this, POLY_OPA_DISP); } else { Gfx_SetupDL_25Xlu(play->state.gfxCtx); gSPSegment(POLY_XLU_DISP++, 0x08, D_80116280); gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, this->actor.shape.shadowAlpha); - POLY_XLU_DISP = SkelAnime_Draw(play, this->skelanime.skeleton, this->skelanime.jointTable, + POLY_XLU_DISP = SkelAnime_DrawSkeleton2(play, &this->skelanime, EnEiyer_OverrideLimbDraw, NULL, this, POLY_XLU_DISP); } CLOSE_DISPS(play->state.gfxCtx); diff --git a/soh/src/overlays/actors/ovl_En_Elf/z_en_elf.c b/soh/src/overlays/actors/ovl_En_Elf/z_en_elf.c index 2191daeab25..ec288eed3b6 100644 --- a/soh/src/overlays/actors/ovl_En_Elf/z_en_elf.c +++ b/soh/src/overlays/actors/ovl_En_Elf/z_en_elf.c @@ -1540,7 +1540,7 @@ void EnElf_Draw(Actor* thisx, PlayState* play) { gSPEndDisplayList(dListHead++); gDPSetEnvColor(POLY_XLU_DISP++, (u8)this->outerColor.r, (u8)this->outerColor.g, (u8)this->outerColor.b, (u8)(envAlpha * alphaScale)); - POLY_XLU_DISP = SkelAnime_Draw(play, this->skelAnime.skeleton, this->skelAnime.jointTable, + POLY_XLU_DISP = SkelAnime_DrawSkeleton2(play, &this->skelAnime, EnElf_OverrideLimbDraw, NULL, this, POLY_XLU_DISP); CLOSE_DISPS(play->state.gfxCtx); diff --git a/soh/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c b/soh/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c index bf7b79b7fc7..f0fcf03a1de 100644 --- a/soh/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c +++ b/soh/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c @@ -837,8 +837,9 @@ void EnFirefly_Draw(Actor* thisx, PlayState* play) { gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); } - POLY_OPA_DISP = SkelAnime_Draw(play, this->skelAnime.skeleton, this->skelAnime.jointTable, - EnFirefly_OverrideLimbDraw, EnFirefly_PostLimbDraw, &this->actor, POLY_OPA_DISP); + POLY_OPA_DISP = SkelAnime_DrawSkeleton2(play, &this->skelAnime, EnFirefly_OverrideLimbDraw, EnFirefly_PostLimbDraw, + &this->actor, POLY_OPA_DISP); + CLOSE_DISPS(play->state.gfxCtx); } @@ -854,7 +855,7 @@ void EnFirefly_DrawInvisible(Actor* thisx, PlayState* play) { gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, 255); } - POLY_XLU_DISP = SkelAnime_Draw(play, this->skelAnime.skeleton, this->skelAnime.jointTable, + POLY_XLU_DISP = SkelAnime_DrawSkeleton2(play, &this->skelAnime, EnFirefly_OverrideLimbDraw, EnFirefly_PostLimbDraw, this, POLY_XLU_DISP); CLOSE_DISPS(play->state.gfxCtx); } diff --git a/soh/src/overlays/actors/ovl_En_Partner/z_en_partner.c b/soh/src/overlays/actors/ovl_En_Partner/z_en_partner.c index 8780ab10caa..7f7b92c55c5 100644 --- a/soh/src/overlays/actors/ovl_En_Partner/z_en_partner.c +++ b/soh/src/overlays/actors/ovl_En_Partner/z_en_partner.c @@ -858,7 +858,7 @@ void EnPartner_Draw(Actor* thisx, PlayState* play) { gSPEndDisplayList(dListHead++); gDPSetEnvColor(POLY_XLU_DISP++, (u8)this->outerColor.r, (u8)this->outerColor.g, (u8)this->outerColor.b, (u8)(envAlpha * alphaScale)); - POLY_XLU_DISP = SkelAnime_Draw(play, this->skelAnime.skeleton, this->skelAnime.jointTable, + POLY_XLU_DISP = SkelAnime_DrawSkeleton2(play, &this->skelAnime, EnPartner_OverrideLimbDraw, NULL, this, POLY_XLU_DISP); CLOSE_DISPS(play->state.gfxCtx); diff --git a/soh/src/overlays/actors/ovl_En_Po_Desert/z_en_po_desert.c b/soh/src/overlays/actors/ovl_En_Po_Desert/z_en_po_desert.c index 55155226b4a..2c00b284b79 100644 --- a/soh/src/overlays/actors/ovl_En_Po_Desert/z_en_po_desert.c +++ b/soh/src/overlays/actors/ovl_En_Po_Desert/z_en_po_desert.c @@ -267,7 +267,7 @@ void EnPoDesert_Draw(Actor* thisx, PlayState* play) { } else { gSPSegment(POLY_XLU_DISP++, 0x0C, D_80116280 + 2); } - POLY_XLU_DISP = SkelAnime_Draw(play, this->skelAnime.skeleton, this->skelAnime.jointTable, + POLY_XLU_DISP = SkelAnime_DrawSkeleton2(play, &this->skelAnime, EnPoDesert_OverrideLimbDraw, EnPoDesert_PostLimbDraw, &this->actor, POLY_XLU_DISP); CLOSE_DISPS(play->state.gfxCtx); } diff --git a/soh/src/overlays/actors/ovl_En_Po_Field/z_en_po_field.c b/soh/src/overlays/actors/ovl_En_Po_Field/z_en_po_field.c index c11feb327d9..eba331a0814 100644 --- a/soh/src/overlays/actors/ovl_En_Po_Field/z_en_po_field.c +++ b/soh/src/overlays/actors/ovl_En_Po_Field/z_en_po_field.c @@ -944,15 +944,14 @@ void EnPoField_Draw(Actor* thisx, PlayState* play) { this->lightColor.a)); gSPSegment(POLY_OPA_DISP++, 0x0C, D_80116280 + 2); POLY_OPA_DISP = - SkelAnime_Draw(play, this->skelAnime.skeleton, this->skelAnime.jointTable, + SkelAnime_DrawSkeleton2(play, &this->skelAnime, EnPoField_OverrideLimbDraw2, EnPoField_PostLimDraw2, &this->actor, POLY_OPA_DISP); } else { gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_EnvColor(play->state.gfxCtx, this->lightColor.r, this->lightColor.g, this->lightColor.b, this->lightColor.a)); gSPSegment(POLY_XLU_DISP++, 0x0C, D_80116280); - POLY_XLU_DISP = - SkelAnime_Draw(play, this->skelAnime.skeleton, this->skelAnime.jointTable, + POLY_XLU_DISP = SkelAnime_DrawSkeleton2(play, &this->skelAnime, EnPoField_OverrideLimbDraw2, EnPoField_PostLimDraw2, &this->actor, POLY_XLU_DISP); } gDPPipeSync(POLY_OPA_DISP++); diff --git a/soh/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c b/soh/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c index ea324c5a5db..8bd5c21123a 100644 --- a/soh/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c +++ b/soh/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c @@ -1373,14 +1373,12 @@ void EnPoSisters_Draw(Actor* thisx, PlayState* play) { if (this->unk_22E.a == 255 || this->unk_22E.a == 0) { gDPSetEnvColor(POLY_OPA_DISP++, this->unk_22E.r, this->unk_22E.g, this->unk_22E.b, this->unk_22E.a); gSPSegment(POLY_OPA_DISP++, 0x09, D_80116280 + 2); - POLY_OPA_DISP = - SkelAnime_Draw(play, this->skelAnime.skeleton, this->skelAnime.jointTable, - EnPoSisters_OverrideLimbDraw, EnPoSisters_PostLimbDraw, &this->actor, POLY_OPA_DISP); + POLY_OPA_DISP = SkelAnime_DrawSkeleton2(play, &this->skelAnime, EnPoSisters_OverrideLimbDraw, + EnPoSisters_PostLimbDraw, &this->actor, POLY_OPA_DISP); } else { gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, this->unk_22E.a); gSPSegment(POLY_XLU_DISP++, 0x09, D_80116280); - POLY_XLU_DISP = - SkelAnime_Draw(play, this->skelAnime.skeleton, this->skelAnime.jointTable, + POLY_XLU_DISP = SkelAnime_DrawSkeleton2(play, &this->skelAnime, EnPoSisters_OverrideLimbDraw, EnPoSisters_PostLimbDraw, &this->actor, POLY_XLU_DISP); } if (!(this->unk_199 & 0x80)) { diff --git a/soh/src/overlays/actors/ovl_En_Poh/z_en_poh.c b/soh/src/overlays/actors/ovl_En_Poh/z_en_poh.c index 809150fe630..2c7e904160a 100644 --- a/soh/src/overlays/actors/ovl_En_Poh/z_en_poh.c +++ b/soh/src/overlays/actors/ovl_En_Poh/z_en_poh.c @@ -1085,12 +1085,12 @@ void EnPoh_DrawRegular(Actor* thisx, PlayState* play) { if (this->lightColor.a == 255 || this->lightColor.a == 0) { gDPSetEnvColor(POLY_OPA_DISP++, this->lightColor.r, this->lightColor.g, this->lightColor.b, this->lightColor.a); gSPSegment(POLY_OPA_DISP++, 0x08, D_80116280 + 2); - POLY_OPA_DISP = SkelAnime_Draw(play, this->skelAnime.skeleton, this->skelAnime.jointTable, + POLY_OPA_DISP = SkelAnime_DrawSkeleton2(play, &this->skelAnime, EnPoh_OverrideLimbDraw, EnPoh_PostLimbDraw, &this->actor, POLY_OPA_DISP); } else { gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, this->lightColor.a); gSPSegment(POLY_XLU_DISP++, 0x08, D_80116280); - POLY_XLU_DISP = SkelAnime_Draw(play, this->skelAnime.skeleton, this->skelAnime.jointTable, + POLY_XLU_DISP = SkelAnime_DrawSkeleton2(play, &this->skelAnime, EnPoh_OverrideLimbDraw, EnPoh_PostLimbDraw, &this->actor, POLY_XLU_DISP); } gDPPipeSync(POLY_OPA_DISP++); diff --git a/soh/src/overlays/actors/ovl_En_Vali/z_en_vali.c b/soh/src/overlays/actors/ovl_En_Vali/z_en_vali.c index d7a838d8ab2..c1c4394cef6 100644 --- a/soh/src/overlays/actors/ovl_En_Vali/z_en_vali.c +++ b/soh/src/overlays/actors/ovl_En_Vali/z_en_vali.c @@ -814,7 +814,7 @@ void EnVali_Draw(Actor* thisx, PlayState* play) { EnVali_DrawBody(this, play); - POLY_XLU_DISP = SkelAnime_Draw(play, this->skelAnime.skeleton, this->skelAnime.jointTable, + POLY_XLU_DISP = SkelAnime_DrawSkeleton2(play, &this->skelAnime, EnVali_OverrideLimbDraw, EnVali_PostLimbDraw, this, POLY_XLU_DISP); CLOSE_DISPS(play->state.gfxCtx); diff --git a/soh/src/overlays/actors/ovl_En_Weiyer/z_en_weiyer.c b/soh/src/overlays/actors/ovl_En_Weiyer/z_en_weiyer.c index 4a267b001df..e3f19a3ed5b 100644 --- a/soh/src/overlays/actors/ovl_En_Weiyer/z_en_weiyer.c +++ b/soh/src/overlays/actors/ovl_En_Weiyer/z_en_weiyer.c @@ -640,13 +640,13 @@ void EnWeiyer_Draw(Actor* thisx, PlayState* play) { Gfx_SetupDL_25Opa(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, &D_80116280[2]); gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); - POLY_OPA_DISP = SkelAnime_Draw(play, this->skelAnime.skeleton, this->skelAnime.jointTable, - EnWeiyer_OverrideLimbDraw, NULL, &this->actor, POLY_OPA_DISP); + POLY_OPA_DISP = SkelAnime_DrawSkeleton2(play, &this->skelAnime, EnWeiyer_OverrideLimbDraw, NULL, &this->actor, + POLY_OPA_DISP); } else { Gfx_SetupDL_25Xlu(play->state.gfxCtx); gSPSegment(POLY_XLU_DISP++, 0x08, &D_80116280[0]); gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, this->actor.shape.shadowAlpha); - POLY_XLU_DISP = SkelAnime_Draw(play, this->skelAnime.skeleton, this->skelAnime.jointTable, + POLY_XLU_DISP = SkelAnime_DrawSkeleton2(play, &this->skelAnime, EnWeiyer_OverrideLimbDraw, NULL, &this->actor, POLY_XLU_DISP); } diff --git a/soh/src/overlays/actors/ovl_En_Zf/z_en_zf.c b/soh/src/overlays/actors/ovl_En_Zf/z_en_zf.c index 9aa8204dd9d..dca0af40531 100644 --- a/soh/src/overlays/actors/ovl_En_Zf/z_en_zf.c +++ b/soh/src/overlays/actors/ovl_En_Zf/z_en_zf.c @@ -2252,7 +2252,7 @@ void EnZf_Draw(Actor* thisx, PlayState* play) { gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, this->alpha); gSPSegment(POLY_OPA_DISP++, 0x09, &D_80116280[2]); - POLY_OPA_DISP = SkelAnime_Draw(play, this->skelAnime.skeleton, this->skelAnime.jointTable, + POLY_OPA_DISP = SkelAnime_DrawSkeleton2(play, &this->skelAnime, EnZf_OverrideLimbDraw, EnZf_PostLimbDraw, this, POLY_OPA_DISP); if (this->iceTimer != 0) { @@ -2271,7 +2271,7 @@ void EnZf_Draw(Actor* thisx, PlayState* play) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->alpha); gSPSegment(POLY_XLU_DISP++, 0x09, &D_80116280[0]); - POLY_XLU_DISP = SkelAnime_Draw(play, this->skelAnime.skeleton, this->skelAnime.jointTable, + POLY_XLU_DISP = SkelAnime_DrawSkeleton2(play, &this->skelAnime, EnZf_OverrideLimbDraw, EnZf_PostLimbDraw, this, POLY_XLU_DISP); } CLOSE_DISPS(play->state.gfxCtx); From 3971e3696ea022be0eb50c4f0a19f3c5a4806fe6 Mon Sep 17 00:00:00 2001 From: Spodi Date: Tue, 6 Aug 2024 01:31:20 +0200 Subject: [PATCH 51/59] Use manifest for windows DPI awareness (#3270) (#4256) * Use manifest for windows DPI awareness (#3270) * Update libultraship * Update libultraship --- libultraship | 2 +- soh/SHIPOFHARKINIAN.manifest | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/libultraship b/libultraship index 275c741d5dd..1ca7d0fa780 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit 275c741d5dd48d78b6a746c0709c75d095e48eeb +Subproject commit 1ca7d0fa78013e49450a4a9881236a19a6600d64 diff --git a/soh/SHIPOFHARKINIAN.manifest b/soh/SHIPOFHARKINIAN.manifest index 80d9f603619..6f47a937f1c 100644 --- a/soh/SHIPOFHARKINIAN.manifest +++ b/soh/SHIPOFHARKINIAN.manifest @@ -28,4 +28,10 @@ + + + true/pm + permonitorv2,permonitor + + From 16aaf2f93995d421d3a17a77106811f552f02012 Mon Sep 17 00:00:00 2001 From: Archez Date: Mon, 12 Aug 2024 19:39:44 -0400 Subject: [PATCH 52/59] Tweak: Implement better extended culling options (#4285) * implement better culling * change draw distance to a slider * remove testing code * tweak --- soh/include/functions.h | 2 + soh/soh/Enhancements/presets.h | 2 + soh/soh/SohMenuBar.cpp | 33 ++++- soh/src/code/z_actor.c | 122 ++++++++++++++---- .../actors/ovl_En_Wood02/z_en_wood02.c | 13 +- .../overlays/actors/ovl_Obj_Mure/z_obj_mure.c | 16 ++- .../actors/ovl_Obj_Mure2/z_obj_mure2.c | 24 +++- 7 files changed, 166 insertions(+), 46 deletions(-) diff --git a/soh/include/functions.h b/soh/include/functions.h index 55363067228..f0015a2c246 100644 --- a/soh/include/functions.h +++ b/soh/include/functions.h @@ -2460,6 +2460,8 @@ void Message_DrawText(PlayState* play, Gfx** gfxP); void Interface_CreateQuadVertexGroup(Vtx* vtxList, s32 xStart, s32 yStart, s32 width, s32 height, u8 flippedH); void Interface_RandoRestoreSwordless(void); +s32 Ship_CalcShouldDrawAndUpdate(PlayState* play, Actor* actor, Vec3f* projectedPos, f32 projectedW, bool* shouldDraw, + bool* shouldUpdate); // #endregion diff --git a/soh/soh/Enhancements/presets.h b/soh/soh/Enhancements/presets.h index cac60cdefe0..eb7c34e2a54 100644 --- a/soh/soh/Enhancements/presets.h +++ b/soh/soh/Enhancements/presets.h @@ -211,6 +211,8 @@ const std::vector enhancementsCvars = { "gDisableLOD", "gDisableDrawDistance", "gDisableKokiriDrawDistance", + "gEnhancements.WidescreenActorCulling", + "gEnhancements.ExtendedCullingExcludeGlitchActors", "gLowResMode", "gDrawLineupTick", "gQuickBongoKill", diff --git a/soh/soh/SohMenuBar.cpp b/soh/soh/SohMenuBar.cpp index ee9a2708d72..ade4f752380 100644 --- a/soh/soh/SohMenuBar.cpp +++ b/soh/soh/SohMenuBar.cpp @@ -928,16 +928,39 @@ void DrawEnhancementsMenu() { } UIWidgets::PaddedEnhancementCheckbox("Disable LOD", "gDisableLOD", true, false); UIWidgets::Tooltip("Turns off the Level of Detail setting, making models use their higher-poly variants at any distance"); - if (UIWidgets::PaddedEnhancementCheckbox("Disable Draw Distance", "gDisableDrawDistance", true, false)) { - if (CVarGetInteger("gDisableDrawDistance", 0) == 0) { + if (UIWidgets::EnhancementSliderInt("Increase Actor Draw Distance: %dx", "##IncreaseActorDrawDistance", + "gDisableDrawDistance", 1, 5, "", 1, true, false)) { + if (CVarGetInteger("gDisableDrawDistance", 1) <= 1) { CVarSetInteger("gDisableKokiriDrawDistance", 0); } } - UIWidgets::Tooltip("Turns off the objects draw distance, making objects being visible from a longer range"); - if (CVarGetInteger("gDisableDrawDistance", 0) == 1) { + UIWidgets::Tooltip("Increases the range in which actors/objects are drawn"); + if (CVarGetInteger("gDisableDrawDistance", 1) > 1) { UIWidgets::PaddedEnhancementCheckbox("Kokiri Draw Distance", "gDisableKokiriDrawDistance", true, false); - UIWidgets::Tooltip("The Kokiri are mystical beings that fade into view when approached\nEnabling this will remove their draw distance"); + UIWidgets::Tooltip("The Kokiri are mystical beings that fade into view when approached\nEnabling this " + "will remove their draw distance"); } + UIWidgets::PaddedEnhancementCheckbox("Widescreen Actor Culling", "gEnhancements.WidescreenActorCulling", + true, false); + UIWidgets::Tooltip("Adjusts the horizontal culling plane to account for widescreen resolutions"); + UIWidgets::PaddedEnhancementCheckbox( + "Cull Glitch Useful Actors", "gEnhancements.ExtendedCullingExcludeGlitchActors", true, false, + !CVarGetInteger("gEnhancements.WidescreenActorCulling", 0) && + CVarGetInteger("gDisableDrawDistance", 1) <= 1, + "Requires Actor Draw Distance to be increased or Widescreen Actor Culling enabled"); + UIWidgets::Tooltip( + "Exclude actors that are useful for glitches from the extended culling ranges.\n" + "Some actors may still draw in the extended ranges, but will not \"update\" so that certain " + "glitches that leverage the original culling requirements will still work.\n" + "\n" + "The following actors are excluded:\n" + "- White clothed Gerudos\n" + "- King Zora\n" + "- Gossip Stones\n" + "- Boulders\n" + "- Blue Warps\n" + "- Darunia\n" + "- Gold Skulltulas"); UIWidgets::PaddedEnhancementCheckbox("N64 Mode", "gLowResMode", true, false); UIWidgets::Tooltip("Sets aspect ratio to 4:3 and lowers resolution to 240p, the N64's native resolution"); UIWidgets::PaddedEnhancementCheckbox("Glitch line-up tick", "gDrawLineupTick", true, false); diff --git a/soh/src/code/z_actor.c b/soh/src/code/z_actor.c index 0accb49d03c..3ccb62bd796 100644 --- a/soh/src/code/z_actor.c +++ b/soh/src/code/z_actor.c @@ -1208,14 +1208,6 @@ void Actor_Init(Actor* actor, PlayState* play) { actor->uncullZoneForward = 1000.0f; actor->uncullZoneScale = 350.0f; actor->uncullZoneDownward = 700.0f; - if (CVarGetInteger("gDisableDrawDistance", 0) != 0 && actor->id != ACTOR_EN_TORCH2 && actor->id != ACTOR_EN_BLKOBJ // Extra check for Dark Link and his room - && actor->id != ACTOR_EN_HORSE // Check for Epona, else if we call her she will spawn at the other side of the map + we can hear her during the title screen sequence - && actor->id != ACTOR_EN_HORSE_GANON && actor->id != ACTOR_EN_HORSE_ZELDA // check for Zelda's and Ganondorf's horses that will always be scene during cinematic whith camera paning - && (play->sceneNum != SCENE_DODONGOS_CAVERN && actor->id != ACTOR_EN_ZF)) { // Check for DC and Lizalfos for the case where the miniboss music would still play under certains conditions and changing room - actor->uncullZoneForward = 32767.0f; - actor->uncullZoneScale = 32767.0f; - actor->uncullZoneDownward = 32767.0f; - } CollisionCheck_InitInfo(&actor->colChkInfo); actor->floorBgId = BGCHECK_SCENE; ActorShape_Init(&actor->shape, 0.0f, NULL, 0.0f); @@ -2857,33 +2849,92 @@ s32 func_800314B0(PlayState* play, Actor* actor) { s32 func_800314D4(PlayState* play, Actor* actor, Vec3f* arg2, f32 arg3) { f32 var; - if (CVarGetInteger("gDisableDrawDistance", 0) != 0 && actor->id != ACTOR_EN_TORCH2 && actor->id != ACTOR_EN_BLKOBJ // Extra check for Dark Link and his room - && actor->id != ACTOR_EN_HORSE // Check for Epona, else if we call her she will spawn at the other side of the map + we can hear her during the title screen sequence - && actor->id != ACTOR_EN_HORSE_GANON && actor->id != ACTOR_EN_HORSE_ZELDA // check for Zelda's and Ganondorf's horses that will always be scene during cinematic whith camera paning - && (play->sceneNum != SCENE_DODONGOS_CAVERN && actor->id != ACTOR_EN_ZF)) { // Check for DC and Lizalfos for the case where the miniboss music would still play under certains conditions and changing room + if ((arg2->z > -actor->uncullZoneScale) && (arg2->z < (actor->uncullZoneForward + actor->uncullZoneScale))) { + var = (arg3 < 1.0f) ? 1.0f : 1.0f / arg3; + + if ((((fabsf(arg2->x) - actor->uncullZoneScale) * var) < 1.0f) && + (((arg2->y + actor->uncullZoneDownward) * var) > -1.0f) && + (((arg2->y - actor->uncullZoneScale) * var) < 1.0f)) { + return true; + } + } + + return false; +} + +// #region SOH [Enhancements] Allows us to increase the draw and update distance independently, +// mostly a modified version of the function above and additional tweaks for some specfic actors +s32 Ship_CalcShouldDrawAndUpdate(PlayState* play, Actor* actor, Vec3f* projectedPos, f32 projectedW, bool* shouldDraw, + bool* shouldUpdate) { + f32 clampedProjectedW; + + // Check if the actor passes its original/vanilla culling requirements + if (func_800314D4(play, actor, projectedPos, projectedW)) { + *shouldUpdate = true; + *shouldDraw = true; return true; } - if ((arg2->z > -actor->uncullZoneScale) && (arg2->z < (actor->uncullZoneForward + actor->uncullZoneScale))) { - var = (arg3 < 1.0f) ? 1.0f : 1.0f / arg3; + // Skip cutscne actors that depend on culling to hide from camera pans + if (actor->id == ACTOR_EN_VIEWER) { + return false; + } - // #region SoH [Widescreen support] - // Doors will cull quite noticeably on wider screens. For these actors the zone is increased - f32 limit = 1.0f; - if (((actor->id == ACTOR_EN_DOOR) || (actor->id == ACTOR_DOOR_SHUTTER)) && CVarGetInteger("gIncreaseDoorUncullZones", 1)) { - limit = 2.0f; + s32 multiplier = CVarGetInteger("gDisableDrawDistance", 1); + multiplier = MAX(multiplier, 1); + + // Some actors have a really short forward value, so we need to add to it before the multiplier to increase the + // final strength of the forward culling + f32 adder = (actor->uncullZoneForward < 500) ? 1000.0f : 0.0f; + + if ((projectedPos->z > -actor->uncullZoneScale) && + (projectedPos->z < (((actor->uncullZoneForward + adder) * multiplier) + actor->uncullZoneScale))) { + clampedProjectedW = (projectedW < 1.0f) ? 1.0f : 1.0f / projectedW; + + f32 ratioAdjusted = 1.0f; + + if (CVarGetInteger("gEnhancements.WidescreenActorCulling", 0)) { + f32 originalAspectRatio = 4.0f / 3.0f; + f32 currentAspectRatio = OTRGetAspectRatio(); + ratioAdjusted = MAX(currentAspectRatio / originalAspectRatio, 1.0f); } - if ((((fabsf(arg2->x) - actor->uncullZoneScale) * var) < limit) && - (((arg2->y + actor->uncullZoneDownward) * var) > -limit) && - (((arg2->y - actor->uncullZoneScale) * var) < limit)) { + if ((((fabsf(projectedPos->x) - actor->uncullZoneScale) * (clampedProjectedW / ratioAdjusted)) < 1.0f) && + (((projectedPos->y + actor->uncullZoneDownward) * clampedProjectedW) > -1.0f) && + (((projectedPos->y - actor->uncullZoneScale) * clampedProjectedW) < 1.0f)) { + + if (CVarGetInteger("gEnhancements.ExtendedCullingExcludeGlitchActors", 0)) { + // These actors are safe to draw without impacting glitches + if ((actor->id == ACTOR_OBJ_BOMBIWA || actor->id == ACTOR_OBJ_HAMISHI || + actor->id == ACTOR_EN_ISHI) || // Boulders (hookshot through collision) + actor->id == ACTOR_EN_GS || // Gossip stones (text delay) + actor->id == ACTOR_EN_GE1 || // White gerudos (gate clip/archery room transition) + actor->id == ACTOR_EN_KZ || // King Zora (unfreeze glitch) + actor->id == ACTOR_EN_DU || // Darunia (Fire temple BK skip) + actor->id == ACTOR_DOOR_WARP1 // Blue warps (wrong warps) + ) { + *shouldDraw = true; + return true; + } + + // Skip these actors entirely as their draw funcs impacts glitches + if ((actor->id == ACTOR_EN_SW && + (((actor->params & 0xE000) >> 0xD) == 1 || + ((actor->params & 0xE000) >> 0xD) == 2)) // Gold Skulltulas (hitbox at 0,0) + ) { + return false; + } + } + + *shouldDraw = true; + *shouldUpdate = true; return true; } - // #endregion } return false; } +// #endregion void func_800315AC(PlayState* play, ActorContext* actorCtx) { s32 invisibleActorCounter; @@ -2920,18 +2971,35 @@ void func_800315AC(PlayState* play, ActorContext* actorCtx) { } } + // #region SOH [Enhancement] Extended culling updates + bool shipShouldDraw = false; + bool shipShouldUpdate = false; if ((HREG(64) != 1) || ((HREG(65) != -1) && (HREG(65) != HREG(66))) || (HREG(70) == 0)) { - if (func_800314B0(play, actor)) { - actor->flags |= ACTOR_FLAG_ACTIVE; + if (CVarGetInteger("gDisableDrawDistance", 1) > 1 || + CVarGetInteger("gEnhancements.WidescreenActorCulling", 0)) { + Ship_CalcShouldDrawAndUpdate(play, actor, &actor->projectedPos, actor->projectedW, &shipShouldDraw, + &shipShouldUpdate); + + if (shipShouldUpdate) { + actor->flags |= ACTOR_FLAG_ACTIVE; + } else { + actor->flags &= ~ACTOR_FLAG_ACTIVE; + } } else { - actor->flags &= ~ACTOR_FLAG_ACTIVE; + if (func_800314B0(play, actor)) { + actor->flags |= ACTOR_FLAG_ACTIVE; + } else { + actor->flags &= ~ACTOR_FLAG_ACTIVE; + } } } actor->isDrawn = false; if ((HREG(64) != 1) || ((HREG(65) != -1) && (HREG(65) != HREG(66))) || (HREG(71) == 0)) { - if ((actor->init == NULL) && (actor->draw != NULL) && (actor->flags & (ACTOR_FLAG_DRAW_WHILE_CULLED | ACTOR_FLAG_ACTIVE))) { + if ((actor->init == NULL) && (actor->draw != NULL) && + ((actor->flags & (ACTOR_FLAG_DRAW_WHILE_CULLED | ACTOR_FLAG_ACTIVE)) || shipShouldDraw)) { + // #endregion if ((actor->flags & ACTOR_FLAG_LENS) && ((play->roomCtx.curRoom.lensMode == LENS_MODE_HIDE_ACTORS) || play->actorCtx.lensActive || (actor->room != play->roomCtx.curRoom.num))) { diff --git a/soh/src/overlays/actors/ovl_En_Wood02/z_en_wood02.c b/soh/src/overlays/actors/ovl_En_Wood02/z_en_wood02.c index 4adb7afe761..0ff04f5dba9 100644 --- a/soh/src/overlays/actors/ovl_En_Wood02/z_en_wood02.c +++ b/soh/src/overlays/actors/ovl_En_Wood02/z_en_wood02.c @@ -101,13 +101,18 @@ static f32 sSpawnSin; s32 EnWood02_SpawnZoneCheck(EnWood02* this, PlayState* play, Vec3f* pos) { f32 phi_f12; - if (CVarGetInteger("gDisableDrawDistance", 0) != 0) { - return true; - } - SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, pos, &this->actor.projectedPos, &this->actor.projectedW); + // #region SOH [Enhancement] Use the extended culling calculation + if (CVarGetInteger("gDisableDrawDistance", 0) || CVarGetInteger("gEnhancements.WidescreenActorCulling", 0)) { + bool shipShouldDraw = false; + bool shipShouldUpdate = false; + return Ship_CalcShouldDrawAndUpdate(play, &this->actor, &this->actor.projectedPos, this->actor.projectedW, + &shipShouldDraw, &shipShouldUpdate); + } + // #endregion + phi_f12 = ((this->actor.projectedW == 0.0f) ? 1000.0f : fabsf(1.0f / this->actor.projectedW)); if ((-this->actor.uncullZoneScale < this->actor.projectedPos.z) && diff --git a/soh/src/overlays/actors/ovl_Obj_Mure/z_obj_mure.c b/soh/src/overlays/actors/ovl_Obj_Mure/z_obj_mure.c index 2f5cf4ee369..2821b47fed7 100644 --- a/soh/src/overlays/actors/ovl_Obj_Mure/z_obj_mure.c +++ b/soh/src/overlays/actors/ovl_Obj_Mure/z_obj_mure.c @@ -275,7 +275,12 @@ void ObjMure_InitialAction(ObjMure* this, PlayState* play) { } void ObjMure_CulledState(ObjMure* this, PlayState* play) { - if (fabsf(this->actor.projectedPos.z) < sZClip[this->type] || CVarGetInteger("gDisableDrawDistance", 0) != 0) { + // #region SOH [Enhancements] Extended draw distance + s32 distanceMultiplier = CVarGetInteger("gDisableDrawDistance", 1); + distanceMultiplier = MAX(distanceMultiplier, 1); + + if (fabsf(this->actor.projectedPos.z) < sZClip[this->type] * distanceMultiplier) { + // #endregion this->actionFunc = ObjMure_ActiveState; this->actor.flags |= ACTOR_FLAG_UPDATE_WHILE_CULLED; ObjMure_SpawnActors(this, play); @@ -398,8 +403,13 @@ static ObjMureActionFunc sTypeGroupBehaviorFunc[] = { void ObjMure_ActiveState(ObjMure* this, PlayState* play) { ObjMure_CheckChildren(this, play); - if (sZClip[this->type] + 40.0f <= fabsf(this->actor.projectedPos.z) && - CVarGetInteger("gDisableDrawDistance", 1) != 0) { + + // #region SOH [Enhancements] Extended draw distance + s32 distanceMultiplier = CVarGetInteger("gDisableDrawDistance", 1); + distanceMultiplier = MAX(distanceMultiplier, 1); + + if ((sZClip[this->type] + 40.0f) * distanceMultiplier <= fabsf(this->actor.projectedPos.z)) { + // #endregion this->actionFunc = ObjMure_CulledState; this->actor.flags &= ~ACTOR_FLAG_UPDATE_WHILE_CULLED; ObjMure_KillActors(this, play); diff --git a/soh/src/overlays/actors/ovl_Obj_Mure2/z_obj_mure2.c b/soh/src/overlays/actors/ovl_Obj_Mure2/z_obj_mure2.c index b883072b9da..1b8905ee27e 100644 --- a/soh/src/overlays/actors/ovl_Obj_Mure2/z_obj_mure2.c +++ b/soh/src/overlays/actors/ovl_Obj_Mure2/z_obj_mure2.c @@ -190,8 +190,7 @@ void func_80B9A658(ObjMure2* this) { void func_80B9A668(ObjMure2* this, PlayState* play) { if (Math3D_Dist1DSq(this->actor.projectedPos.x, this->actor.projectedPos.z) < - (sDistSquared1[this->actor.params & 3] * this->unk_184) || - CVarGetInteger("gDisableDrawDistance", 0) != 0) { + (sDistSquared1[this->actor.params & 3] * this->unk_184)) { this->actor.flags |= ACTOR_FLAG_UPDATE_WHILE_CULLED; ObjMure2_SpawnActors(this, play); func_80B9A6E8(this); @@ -205,12 +204,8 @@ void func_80B9A6E8(ObjMure2* this) { void func_80B9A6F8(ObjMure2* this, PlayState* play) { func_80B9A534(this); - if (CVarGetInteger("gDisableDrawDistance", 0) != 0) { - return; - } - if ((sDistSquared2[this->actor.params & 3] * this->unk_184) <= - Math3D_Dist1DSq(this->actor.projectedPos.x, this->actor.projectedPos.z)) { + Math3D_Dist1DSq(this->actor.projectedPos.x, this->actor.projectedPos.z)) { this->actor.flags &= ~ACTOR_FLAG_UPDATE_WHILE_CULLED; ObjMure2_CleanupAndDie(this, play); func_80B9A658(this); @@ -225,5 +220,20 @@ void ObjMure2_Update(Actor* thisx, PlayState* play) { } else { this->unk_184 = 4.0f; } + + // SOH [Enhancements] Extended draw distance + s32 distanceMultiplier = CVarGetInteger("gDisableDrawDistance", 1); + if (CVarGetInteger("gEnhancements.WidescreenActorCulling", 0) || distanceMultiplier > 1) { + f32 originalAspectRatio = 4.0f / 3.0f; + f32 currentAspectRatio = OTRGetAspectRatio(); + // Adjust ratio difference based on field of view testing + f32 ratioAdjusted = 1.0f + (MAX(currentAspectRatio / originalAspectRatio, 1.0f) / 1.5f); + // Distance multiplier is squared due to the checks above for squared distances + distanceMultiplier = SQ(MAX(distanceMultiplier, 1)); + + // Prefer the largest of the three values + this->unk_184 = MAX(MAX((f32)distanceMultiplier, ratioAdjusted), this->unk_184); + } + this->actionFunc(this, play); } From 0bc6ca08e0549ec2ce780e6dd1295f84a194cc25 Mon Sep 17 00:00:00 2001 From: Archez Date: Mon, 12 Aug 2024 23:26:30 -0400 Subject: [PATCH 53/59] Bump MacReady Golf (#4279) --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2c8644af4a1..6381f803ad5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,9 +5,9 @@ set(CMAKE_CXX_STANDARD 20 CACHE STRING "The C++ standard to use") set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X deployment version") -project(Ship VERSION 8.0.5 LANGUAGES C CXX) -set(PROJECT_BUILD_NAME "MacReady Foxtrot" CACHE STRING "") -set(PROJECT_TEAM "github.com/harbourmasters" CACHE STRING "") +project(Ship VERSION 8.0.6 LANGUAGES C CXX) +set(PROJECT_BUILD_NAME "MacReady Golf" CACHE STRING "" FORCE) +set(PROJECT_TEAM "github.com/harbourmasters" CACHE STRING "" FORCE) set_property(DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT soh) add_compile_options($<$:/MP>) From 01245ae81ce2752b3c74f66b60a135d00ee70d26 Mon Sep 17 00:00:00 2001 From: Archez Date: Sun, 18 Aug 2024 15:25:21 -0400 Subject: [PATCH 54/59] Bump LUS (#4301) * bump lus * remove undeclared methods --- libultraship | 2 +- soh/soh/Enhancements/controls/InputViewer.h | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/libultraship b/libultraship index 31e9b009f94..92bce011545 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit 31e9b009f94e7074a847c7954926cba354cd7c72 +Subproject commit 92bce01154589080e534c3c143913a196e161f02 diff --git a/soh/soh/Enhancements/controls/InputViewer.h b/soh/soh/Enhancements/controls/InputViewer.h index 3e1e9c98798..b4d6413e16a 100644 --- a/soh/soh/Enhancements/controls/InputViewer.h +++ b/soh/soh/Enhancements/controls/InputViewer.h @@ -28,8 +28,6 @@ class InputViewer : public Ship::GuiWindow { InputViewer(); ~InputViewer(); - void Draw(); - private: void RenderButton(std::string btn, std::string btnOutline, int state, ImVec2 size, int outlineMode); }; @@ -44,6 +42,4 @@ class InputViewerSettingsWindow : public Ship::GuiWindow { InputViewerSettingsWindow(); ~InputViewerSettingsWindow(); - - void Draw(); }; From e07fc59e55bf8041f0c752708acf0f8851b1d9aa Mon Sep 17 00:00:00 2001 From: Pepe20129 <72659707+Pepe20129@users.noreply.github.com> Date: Fri, 23 Aug 2024 16:17:45 +0200 Subject: [PATCH 55/59] Add git info to title screen & gameplay stats (#4053) * Add git info to title screen & gameplay stats * Change the branch criteria to starting with `develop` * Update z_title.c * Change the branch criteria to not having a tag * Always show both when not a release build * Only show build version in tagged releases --- CMakeLists.txt | 31 +++++++++++++++++++ soh/include/variables.h | 5 ++- soh/soh/CrashHandlerExt.cpp | 2 ++ soh/soh/Enhancements/gameplaystats.cpp | 8 ++++- .../randomizer/3drando/spoiler_log.cpp | 2 ++ soh/soh/OTRGlobals.cpp | 2 +- soh/src/boot/build.c.in | 4 +++ .../overlays/gamestates/ovl_title/z_title.c | 21 +++++++++++-- 8 files changed, 70 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2d200a2d771..64975a34b22 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,37 @@ include(CMake/lus-cvars.cmake) set(PROJECT_BUILD_NAME "MacReady Golf" CACHE STRING "" FORCE) set(PROJECT_TEAM "github.com/harbourmasters" CACHE STRING "" FORCE) +execute_process( + COMMAND git branch --show-current + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE GIT_BRANCH + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +set(CMAKE_PROJECT_GIT_BRANCH "${GIT_BRANCH}" CACHE STRING "Git branch" FORCE) + +execute_process( + COMMAND git rev-parse HEAD + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE GIT_COMMIT_HASH + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +set(CMAKE_PROJECT_GIT_COMMIT_HASH "${GIT_COMMIT_HASH}" CACHE STRING "Git commit hash" FORCE) + +execute_process( + COMMAND git describe --tags --abbrev=0 --exact-match HEAD + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE GIT_COMMIT_TAG + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +if(NOT GIT_COMMIT_TAG) + set(GIT_COMMIT_TAG "" CACHE STRING "Git commit tag" FORCE) +endif() + +set(CMAKE_PROJECT_GIT_COMMIT_TAG "${GIT_COMMIT_TAG}" CACHE STRING "Git commit tag" FORCE) + set_property(DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT soh) add_compile_options($<$:/MP>) add_compile_options($<$:/utf-8>) diff --git a/soh/include/variables.h b/soh/include/variables.h index 2c226f2c6b9..692d1b2f82e 100644 --- a/soh/include/variables.h +++ b/soh/include/variables.h @@ -49,7 +49,10 @@ extern "C" extern u16 gBuildVersionMajor; extern u16 gBuildVersionMinor; extern u16 gBuildVersionPatch; - extern u8 gBuildTeam[]; + extern u8 gGitBranch[]; + extern u8 gGitCommitHash[]; + extern u8 gGitCommitTag[]; + extern u8 gBuildTeam[]; extern u8 gBuildDate[]; extern u8 gBuildMakeOption[]; extern OSMesgQueue gPiMgrCmdQ; diff --git a/soh/soh/CrashHandlerExt.cpp b/soh/soh/CrashHandlerExt.cpp index 14f0714ffa9..c4a535f1216 100644 --- a/soh/soh/CrashHandlerExt.cpp +++ b/soh/soh/CrashHandlerExt.cpp @@ -69,6 +69,8 @@ extern "C" void CrashHandler_PrintSohData(char* buffer, size_t* pos) { char intCharBuffer[16]; append_line(buffer, pos, "Build Information:"); WRITE_VAR_LINE(buffer, pos, "Game Version: ", (const char*)gBuildVersion); + WRITE_VAR_LINE(buffer, pos, "Git Branch: ", (const char*)gGitBranch); + WRITE_VAR_LINE(buffer, pos, "Git Commit: ", (const char*)gGitCommitHash); WRITE_VAR_LINE(buffer, pos, "Build Date: ", (const char*)gBuildDate); if (gPlayState != nullptr) { diff --git a/soh/soh/Enhancements/gameplaystats.cpp b/soh/soh/Enhancements/gameplaystats.cpp index 61eb88a6f16..93cb672e3f3 100644 --- a/soh/soh/Enhancements/gameplaystats.cpp +++ b/soh/soh/Enhancements/gameplaystats.cpp @@ -437,7 +437,13 @@ void DrawGameplayStatsHeader() { ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, { 4.0f, 4.0f }); ImGui::BeginTable("gameplayStatsHeader", 1, ImGuiTableFlags_BordersOuter); ImGui::TableSetupColumn("stat", ImGuiTableColumnFlags_WidthStretch); - GameplayStatsRow("Build Version:", (char*) gBuildVersion); + //if tag is empty (not a release build) + if (gGitCommitTag[0] == 0) { + GameplayStatsRow("Git Branch:", (char*)gGitBranch); + GameplayStatsRow("Git Commit Hash:", (char*)gGitCommitHash); + } else { + GameplayStatsRow("Build Version:", (char*)gBuildVersion); + } if (gSaveContext.sohStats.rtaTiming) { GameplayStatsRow("Total Time (RTA):", formatTimestampGameplayStat(GAMEPLAYSTAT_TOTAL_TIME), gSaveContext.sohStats.gameComplete ? COLOR_GREEN : COLOR_WHITE); } else { diff --git a/soh/soh/Enhancements/randomizer/3drando/spoiler_log.cpp b/soh/soh/Enhancements/randomizer/3drando/spoiler_log.cpp index 23599627336..d03c735e6c2 100644 --- a/soh/soh/Enhancements/randomizer/3drando/spoiler_log.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/spoiler_log.cpp @@ -864,6 +864,8 @@ const char* SpoilerLog_Write(int language) { jsonData.clear(); jsonData["version"] = (char*) gBuildVersion; + jsonData["git_branch"] = (char*) gGitBranch; + jsonData["git_commit"] = (char*) gGitCommitHash; jsonData["seed"] = Settings::seedString; jsonData["finalSeed"] = Settings::seed; diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 456e07eaa0c..6e41eb7a8a8 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -340,7 +340,7 @@ OTRGlobals::OTRGlobals() { context->InitAudio(); - SPDLOG_INFO("Starting Ship of Harkinian version {}", (char*)gBuildVersion); + SPDLOG_INFO("Starting Ship of Harkinian version {} (Branch: {} | Commit: {})", (char*)gBuildVersion, (char*)gGitBranch, (char*)gGitCommitHash); auto loader = context->GetResourceManager()->GetResourceLoader(); loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Texture", static_cast(LUS::ResourceType::Texture), 0); diff --git a/soh/src/boot/build.c.in b/soh/src/boot/build.c.in index 4d6a07ce66b..4467d04c819 100644 --- a/soh/src/boot/build.c.in +++ b/soh/src/boot/build.c.in @@ -5,6 +5,10 @@ const u16 gBuildVersionMajor = @CMAKE_PROJECT_VERSION_MAJOR@; const u16 gBuildVersionMinor = @CMAKE_PROJECT_VERSION_MINOR@; const u16 gBuildVersionPatch = @CMAKE_PROJECT_VERSION_PATCH@; +const char gGitBranch[] = "@CMAKE_PROJECT_GIT_BRANCH@"; +const char gGitCommitHash[] = "@CMAKE_PROJECT_GIT_COMMIT_HASH@"; +const char gGitCommitTag[] = "@CMAKE_PROJECT_GIT_COMMIT_TAG@"; + const char gBuildTeam[] = "@PROJECT_TEAM@"; const char gBuildDate[] = __DATE__ " " __TIME__; const char gBuildMakeOption[] = ""; diff --git a/soh/src/overlays/gamestates/ovl_title/z_title.c b/soh/src/overlays/gamestates/ovl_title/z_title.c index 51d0ac62b3a..8893d9d5f5c 100644 --- a/soh/src/overlays/gamestates/ovl_title/z_title.c +++ b/soh/src/overlays/gamestates/ovl_title/z_title.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "time.h" @@ -30,8 +31,24 @@ void Title_PrintBuildInfo(Gfx** gfxp) { GfxPrint_Open(&printer, g); GfxPrint_SetColor(&printer, 131, 154, 255, 255); - GfxPrint_SetPos(&printer, 1, 25); - GfxPrint_Printf(&printer, "%s", gBuildVersion); + //if tag is empty (not a release build) + bool showGitInfo = gGitCommitTag[0] == 0; + + if (showGitInfo) { + GfxPrint_SetPos(&printer, 1, 24); + GfxPrint_Printf(&printer, "Git Branch: %s", gGitBranch); + + //truncate the commit to 7 characters + char gGitCommitHashTruncated[8]; + strncpy(gGitCommitHashTruncated, gGitCommitHash, 7); + gGitCommitHashTruncated[7] = 0; + + GfxPrint_SetPos(&printer, 1, 25); + GfxPrint_Printf(&printer, "Git Commit: %s", gGitCommitHashTruncated); + } else { + GfxPrint_SetPos(&printer, 1, 25); + GfxPrint_Printf(&printer, "%s", gBuildVersion); + } GfxPrint_SetPos(&printer, 1, 26); GfxPrint_Printf(&printer, "%s", gBuildDate); From 48663d74ac50fbe941986e21fa3aae4c74047e11 Mon Sep 17 00:00:00 2001 From: Malkierian Date: Fri, 30 Aug 2024 08:28:09 -0700 Subject: [PATCH 56/59] Change Recommended VS build tools from 142 to 143 (#4315) * Changed references for VS build tools 142 to 143 to reflect current state of development. * Remove VS 2019. --- docs/BUILDING.md | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/docs/BUILDING.md b/docs/BUILDING.md index eb5a6a3365c..471a493ac64 100644 --- a/docs/BUILDING.md +++ b/docs/BUILDING.md @@ -6,7 +6,7 @@ Requires: * At least 8GB of RAM (machines with 4GB have seen complier failures) * Visual Studio 2022 Community Edition with the C++ feature set * One of the Windows SDKs that comes with Visual Studio, for example the current Windows 10 version 10.0.19041.0 - * The `MSVC v142 - VS 2019 C++ build tools` component of Visual Studio + * The `MSVC v143 - VS 2022 C++ build tools` component of Visual Studio * Python 3 (can be installed manually or as part of Visual Studio) * Git (can be installed manually or as part of Visual Studio) * Cmake (can be installed via chocolatey or manually) @@ -14,12 +14,9 @@ Requires: During installation, check the "Desktop development with C++" feature set: ![image](https://user-images.githubusercontent.com/30329717/183511274-d11aceea-7900-46ec-acb6-3f2cc110021a.png) -Doing so should also check one of the Windows SDKs by default. Then, in the installation details in the right-hand column, make sure you also check the v142 toolset. +Doing so should also check one of the Windows SDKs by default. Then, in the installation details in the right-hand column, make sure you also check the v143 toolset. This is often done by default. -You can also find the v142 toolset by searching through the individual components tab: - -![image](https://user-images.githubusercontent.com/30329717/183521169-ead6a73b-a1bf-4e99-aab8-441746d8f08e.png) -While you're there, you can also install Python 3 and Git if needed. +It is recommended that you install Python and Git standalone, the install process in VS Installer has given some issues in the past. 1. Clone the Ship of Harkinian repository @@ -33,9 +30,7 @@ _Note: Instructions assume using powershell_ cd Shipwright # Setup cmake project -& 'C:\Program Files\CMake\bin\cmake' -S . -B "build/x64" -G "Visual Studio 17 2022" -T v142 -A x64 # -DCMAKE_BUILD_TYPE:STRING=Release (if you're packaging) -# or for VS2019 -& 'C:\Program Files\CMake\bin\cmake' -S . -B "build/x64" -G "Visual Studio 16 2019" -T v142 -A x64 +& 'C:\Program Files\CMake\bin\cmake' -S . -B "build/x64" -G "Visual Studio 17 2022" -T v143 -A x64 # -DCMAKE_BUILD_TYPE:STRING=Release (if you're packaging) # Extract assets & generate OTR (run this anytime you need to regenerate OTR) & 'C:\Program Files\CMake\bin\cmake.exe' --build .\build\x64 --target ExtractAssets # --config Release (if you're packaging) # Compile project @@ -60,9 +55,7 @@ With the cmake build system you have two options for working on the project: To develop using Visual Studio you only need to use cmake to generate the solution file: ```powershell # Generates Ship.sln at `build/x64` for Visual Studio 2022 -& 'C:\Program Files\CMake\bin\cmake' -S . -B "build/x64" -G "Visual Studio 17 2022" -T v142 -A x64 -# or for Visual Studio 2019 -& 'C:\Program Files\CMake\bin\cmake' -S . -B "build/x64" -G "Visual Studio 16 2019" -T v142 -A x64 +& 'C:\Program Files\CMake\bin\cmake' -S . -B "build/x64" -G "Visual Studio 17 2022" -T v143 -A x64 ``` #### Visual Studio Code or another editor From b5037a0856032d9f7a5b5b852c2dff0e510d793d Mon Sep 17 00:00:00 2001 From: Malkierian Date: Tue, 10 Sep 2024 12:42:57 -0700 Subject: [PATCH 57/59] Gui window rework (#4307) * Converted all GuiWindows to the new separate Begin/End format in current LUS except InputViewer, CheckTracker, ItemTracker and Modals. * Setup Check, Entrance, Item trackers and Input Viewer to override `Draw()` to bypass the ImGui Begin and End, as they're not intended to go in the modern menu. * Cleanup. --- soh/soh/Enhancements/audio/AudioEditor.cpp | 7 - soh/soh/Enhancements/controls/InputViewer.cpp | 656 ++++++++-------- soh/soh/Enhancements/controls/InputViewer.h | 1 + .../cosmetics/CosmeticsEditor.cpp | 7 - .../Enhancements/debugger/MessageViewer.cpp | 6 - soh/soh/Enhancements/debugger/actorViewer.cpp | 8 - soh/soh/Enhancements/debugger/colViewer.cpp | 7 - .../Enhancements/debugger/debugSaveEditor.cpp | 8 - soh/soh/Enhancements/debugger/dlViewer.cpp | 11 - soh/soh/Enhancements/debugger/valueViewer.cpp | 8 - soh/soh/Enhancements/gameplaystats.cpp | 8 - .../Enhancements/randomizer/randomizer.cpp | 8 - .../randomizer/randomizer_check_tracker.cpp | 26 +- .../randomizer/randomizer_check_tracker.h | 1 + .../randomizer_entrance_tracker.cpp | 11 +- .../randomizer/randomizer_entrance_tracker.h | 1 + .../randomizer/randomizer_item_tracker.cpp | 18 +- .../randomizer/randomizer_item_tracker.h | 1 + .../resolution-editor/ResolutionEditor.cpp | 718 +++++++++--------- soh/soh/SohGui.cpp | 28 +- soh/soh/SohModals.cpp | 9 + soh/soh/SohModals.h | 1 + 22 files changed, 748 insertions(+), 801 deletions(-) diff --git a/soh/soh/Enhancements/audio/AudioEditor.cpp b/soh/soh/Enhancements/audio/AudioEditor.cpp index 3b0c2bb123b..a9fefbe7197 100644 --- a/soh/soh/Enhancements/audio/AudioEditor.cpp +++ b/soh/soh/Enhancements/audio/AudioEditor.cpp @@ -424,12 +424,6 @@ void AudioEditor::InitElement() { void AudioEditor::DrawElement() { AudioCollection::Instance->InitializeShufflePool(); - ImGui::SetNextWindowSize(ImVec2(820, 630), ImGuiCond_FirstUseEver); - if (!ImGui::Begin("Audio Editor", &mIsVisible)) { - ImGui::End(); - return; - } - float buttonSegments = ImGui::GetContentRegionAvail().x / 4; if (ImGui::Button("Randomize All Groups", ImVec2(buttonSegments, 30.0f))) { AudioEditor_RandomizeAll(); @@ -700,7 +694,6 @@ void AudioEditor::DrawElement() { ImGui::EndTabBar(); } - ImGui::End(); } std::vector allTypes = { SEQ_BGM_WORLD, SEQ_BGM_EVENT, SEQ_BGM_BATTLE, SEQ_OCARINA, SEQ_FANFARE, SEQ_INSTRUMENT, SEQ_SFX, SEQ_VOICE }; diff --git a/soh/soh/Enhancements/controls/InputViewer.cpp b/soh/soh/Enhancements/controls/InputViewer.cpp index 106a08b53e7..d4bd5405c77 100644 --- a/soh/soh/Enhancements/controls/InputViewer.cpp +++ b/soh/soh/Enhancements/controls/InputViewer.cpp @@ -61,6 +61,15 @@ void InputViewer::RenderButton(std::string btnTexture, std::string btnOutlineTex } } +void InputViewer::Draw() { + if (!IsVisible()) { + return; + } + DrawElement(); + // Sync up the IsVisible flag if it was changed by ImGui + SyncVisibilityConsoleVariable(); +} + void InputViewer::DrawElement() { if (CVarGetInteger(CVAR_WINDOW("InputViewer"), 0)) { static bool sButtonTexturesLoaded = false; @@ -73,60 +82,60 @@ void InputViewer::DrawElement() { Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("R-Btn", "textures/buttons/RBtn.png"); Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Z-Btn", "textures/buttons/ZBtn.png"); Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Start-Btn", - "textures/buttons/StartBtn.png"); + "textures/buttons/StartBtn.png"); Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("C-Left", "textures/buttons/CLeft.png"); Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("C-Right", "textures/buttons/CRight.png"); Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("C-Up", "textures/buttons/CUp.png"); Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("C-Down", "textures/buttons/CDown.png"); Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Analog-Stick", - "textures/buttons/AnalogStick.png"); + "textures/buttons/AnalogStick.png"); Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Dpad-Left", - "textures/buttons/DPadLeft.png"); + "textures/buttons/DPadLeft.png"); Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Dpad-Right", - "textures/buttons/DPadRight.png"); + "textures/buttons/DPadRight.png"); Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Dpad-Up", "textures/buttons/DPadUp.png"); Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Dpad-Down", - "textures/buttons/DPadDown.png"); + "textures/buttons/DPadDown.png"); Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Modifier-1", "textures/buttons/Mod1.png"); Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Modifier-2", "textures/buttons/Mod2.png"); Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Right-Stick", - "textures/buttons/RightStick.png"); + "textures/buttons/RightStick.png"); Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("A-Btn Outline", - "textures/buttons/ABtnOutline.png"); + "textures/buttons/ABtnOutline.png"); Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("B-Btn Outline", - "textures/buttons/BBtnOutline.png"); + "textures/buttons/BBtnOutline.png"); Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("L-Btn Outline", - "textures/buttons/LBtnOutline.png"); + "textures/buttons/LBtnOutline.png"); Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("R-Btn Outline", - "textures/buttons/RBtnOutline.png"); + "textures/buttons/RBtnOutline.png"); Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Z-Btn Outline", - "textures/buttons/ZBtnOutline.png"); + "textures/buttons/ZBtnOutline.png"); Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Start-Btn Outline", - "textures/buttons/StartBtnOutline.png"); + "textures/buttons/StartBtnOutline.png"); Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("C-Left Outline", - "textures/buttons/CLeftOutline.png"); + "textures/buttons/CLeftOutline.png"); Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("C-Right Outline", - "textures/buttons/CRightOutline.png"); + "textures/buttons/CRightOutline.png"); Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("C-Up Outline", - "textures/buttons/CUpOutline.png"); + "textures/buttons/CUpOutline.png"); Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("C-Down Outline", - "textures/buttons/CDownOutline.png"); + "textures/buttons/CDownOutline.png"); Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Analog-Stick Outline", - "textures/buttons/AnalogStickOutline.png"); + "textures/buttons/AnalogStickOutline.png"); Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Dpad-Left Outline", - "textures/buttons/DPadLeftOutline.png"); + "textures/buttons/DPadLeftOutline.png"); Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Dpad-Right Outline", - "textures/buttons/DPadRightOutline.png"); + "textures/buttons/DPadRightOutline.png"); Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Dpad-Up Outline", - "textures/buttons/DPadUpOutline.png"); + "textures/buttons/DPadUpOutline.png"); Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Dpad-Down Outline", - "textures/buttons/DPadDownOutline.png"); + "textures/buttons/DPadDownOutline.png"); Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Modifier-1 Outline", - "textures/buttons/Mod1Outline.png"); + "textures/buttons/Mod1Outline.png"); Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Modifier-2 Outline", - "textures/buttons/Mod2Outline.png"); + "textures/buttons/Mod2Outline.png"); Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Right-Stick Outline", - "textures/buttons/RightStickOutline.png"); + "textures/buttons/RightStickOutline.png"); sButtonTexturesLoaded = true; } @@ -147,12 +156,12 @@ void InputViewer::DrawElement() { ImGui::SetNextWindowSize( ImVec2(scaledBGSize.x + 20, scaledBGSize.y + - (showAnalogAngles ? ImGui::CalcTextSize("X").y : 0) * scale * - CVarGetFloat(CVAR_INPUT_VIEWER("AnalogAngles.Scale"), 1.0f) + - 20)); + (showAnalogAngles ? ImGui::CalcTextSize("X").y : 0) * scale * + CVarGetFloat(CVAR_INPUT_VIEWER("AnalogAngles.Scale"), 1.0f) + + 20)); ImGui::SetNextWindowContentSize( ImVec2(scaledBGSize.x, scaledBGSize.y + (showAnalogAngles ? 15 : 0) * scale * - CVarGetFloat(CVAR_INPUT_VIEWER("AnalogAngles.Scale"), 1.0f))); + CVarGetFloat(CVAR_INPUT_VIEWER("AnalogAngles.Scale"), 1.0f))); ImGui::SetNextWindowPos( ImVec2(mainPos.x + size.x - scaledBGSize.x - 30, mainPos.y + size.y - scaledBGSize.y - 30), ImGuiCond_FirstUseEver); @@ -163,8 +172,8 @@ void InputViewer::DrawElement() { OSContPad* pads = Ship::Context::GetInstance()->GetControlDeck()->GetPads(); ImGuiWindowFlags windowFlags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoScrollbar | - ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoBackground | - ImGuiWindowFlags_NoFocusOnAppearing; + ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoBackground | + ImGuiWindowFlags_NoFocusOnAppearing; if (!CVarGetInteger(CVAR_INPUT_VIEWER("EnableDragging"), 1)) { windowFlags |= ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoMove; @@ -187,17 +196,17 @@ void InputViewer::DrawElement() { ImGui::SetNextItemAllowOverlap(); ImGui::SetCursorPos(aPos); RenderButton("B-Btn", "B-Btn Outline", pads[0].button & BTN_B, scaledBGSize, - useGlobalOutlineMode - ? buttonOutlineMode - : CVarGetInteger(CVAR_INPUT_VIEWER("BBtnOutlineMode"), BUTTON_OUTLINE_NOT_PRESSED)); + useGlobalOutlineMode + ? buttonOutlineMode + : CVarGetInteger(CVAR_INPUT_VIEWER("BBtnOutlineMode"), BUTTON_OUTLINE_NOT_PRESSED)); } if (CVarGetInteger(CVAR_INPUT_VIEWER("ABtn"), 1)) { ImGui::SetNextItemAllowOverlap(); ImGui::SetCursorPos(aPos); RenderButton("A-Btn", "A-Btn Outline", pads[0].button & BTN_A, scaledBGSize, - useGlobalOutlineMode - ? buttonOutlineMode - : CVarGetInteger(CVAR_INPUT_VIEWER("ABtnOutlineMode"), BUTTON_OUTLINE_NOT_PRESSED)); + useGlobalOutlineMode + ? buttonOutlineMode + : CVarGetInteger(CVAR_INPUT_VIEWER("ABtnOutlineMode"), BUTTON_OUTLINE_NOT_PRESSED)); } // C buttons @@ -205,33 +214,33 @@ void InputViewer::DrawElement() { ImGui::SetNextItemAllowOverlap(); ImGui::SetCursorPos(aPos); RenderButton("C-Up", "C-Up Outline", pads[0].button & BTN_CUP, scaledBGSize, - useGlobalOutlineMode - ? buttonOutlineMode - : CVarGetInteger(CVAR_INPUT_VIEWER("CUpOutlineMode"), BUTTON_OUTLINE_NOT_PRESSED)); + useGlobalOutlineMode + ? buttonOutlineMode + : CVarGetInteger(CVAR_INPUT_VIEWER("CUpOutlineMode"), BUTTON_OUTLINE_NOT_PRESSED)); } if (CVarGetInteger(CVAR_INPUT_VIEWER("CLeft"), 1)) { ImGui::SetNextItemAllowOverlap(); ImGui::SetCursorPos(aPos); RenderButton("C-Left", "C-Left Outline", pads[0].button & BTN_CLEFT, scaledBGSize, - useGlobalOutlineMode - ? buttonOutlineMode - : CVarGetInteger(CVAR_INPUT_VIEWER("CLeftOutlineMode"), BUTTON_OUTLINE_NOT_PRESSED)); + useGlobalOutlineMode + ? buttonOutlineMode + : CVarGetInteger(CVAR_INPUT_VIEWER("CLeftOutlineMode"), BUTTON_OUTLINE_NOT_PRESSED)); } if (CVarGetInteger(CVAR_INPUT_VIEWER("CRight"), 1)) { ImGui::SetNextItemAllowOverlap(); ImGui::SetCursorPos(aPos); RenderButton("C-Right", "C-Right Outline", pads[0].button & BTN_CRIGHT, scaledBGSize, - useGlobalOutlineMode - ? buttonOutlineMode - : CVarGetInteger(CVAR_INPUT_VIEWER("CRightOutlineMode"), BUTTON_OUTLINE_NOT_PRESSED)); + useGlobalOutlineMode + ? buttonOutlineMode + : CVarGetInteger(CVAR_INPUT_VIEWER("CRightOutlineMode"), BUTTON_OUTLINE_NOT_PRESSED)); } if (CVarGetInteger(CVAR_INPUT_VIEWER("CDown"), 1)) { ImGui::SetNextItemAllowOverlap(); ImGui::SetCursorPos(aPos); RenderButton("C-Down", "C-Down Outline", pads[0].button & BTN_CDOWN, scaledBGSize, - useGlobalOutlineMode - ? buttonOutlineMode - : CVarGetInteger(CVAR_INPUT_VIEWER("CDownOutlineMode"), BUTTON_OUTLINE_NOT_PRESSED)); + useGlobalOutlineMode + ? buttonOutlineMode + : CVarGetInteger(CVAR_INPUT_VIEWER("CDownOutlineMode"), BUTTON_OUTLINE_NOT_PRESSED)); } // L/R/Z @@ -239,25 +248,25 @@ void InputViewer::DrawElement() { ImGui::SetNextItemAllowOverlap(); ImGui::SetCursorPos(aPos); RenderButton("L-Btn", "L-Btn Outline", pads[0].button & BTN_L, scaledBGSize, - useGlobalOutlineMode - ? buttonOutlineMode - : CVarGetInteger(CVAR_INPUT_VIEWER("LBtnOutlineMode"), BUTTON_OUTLINE_NOT_PRESSED)); + useGlobalOutlineMode + ? buttonOutlineMode + : CVarGetInteger(CVAR_INPUT_VIEWER("LBtnOutlineMode"), BUTTON_OUTLINE_NOT_PRESSED)); } if (CVarGetInteger(CVAR_INPUT_VIEWER("RBtn"), 1)) { ImGui::SetNextItemAllowOverlap(); ImGui::SetCursorPos(aPos); RenderButton("R-Btn", "R-Btn Outline", pads[0].button & BTN_R, scaledBGSize, - useGlobalOutlineMode - ? buttonOutlineMode - : CVarGetInteger(CVAR_INPUT_VIEWER("RBtnOutlineMode"), BUTTON_OUTLINE_NOT_PRESSED)); + useGlobalOutlineMode + ? buttonOutlineMode + : CVarGetInteger(CVAR_INPUT_VIEWER("RBtnOutlineMode"), BUTTON_OUTLINE_NOT_PRESSED)); } if (CVarGetInteger(CVAR_INPUT_VIEWER("ZBtn"), 1)) { ImGui::SetNextItemAllowOverlap(); ImGui::SetCursorPos(aPos); RenderButton("Z-Btn", "Z-Btn Outline", pads[0].button & BTN_Z, scaledBGSize, - useGlobalOutlineMode - ? buttonOutlineMode - : CVarGetInteger(CVAR_INPUT_VIEWER("ZBtnOutlineMode"), BUTTON_OUTLINE_NOT_PRESSED)); + useGlobalOutlineMode + ? buttonOutlineMode + : CVarGetInteger(CVAR_INPUT_VIEWER("ZBtnOutlineMode"), BUTTON_OUTLINE_NOT_PRESSED)); } // Start @@ -265,9 +274,9 @@ void InputViewer::DrawElement() { ImGui::SetNextItemAllowOverlap(); ImGui::SetCursorPos(aPos); RenderButton("Start-Btn", "Start-Btn Outline", pads[0].button & BTN_START, scaledBGSize, - useGlobalOutlineMode - ? buttonOutlineMode - : CVarGetInteger(CVAR_INPUT_VIEWER("StartBtnOutlineMode"), BUTTON_OUTLINE_NOT_PRESSED)); + useGlobalOutlineMode + ? buttonOutlineMode + : CVarGetInteger(CVAR_INPUT_VIEWER("StartBtnOutlineMode"), BUTTON_OUTLINE_NOT_PRESSED)); } // Dpad @@ -275,27 +284,27 @@ void InputViewer::DrawElement() { ImGui::SetNextItemAllowOverlap(); ImGui::SetCursorPos(aPos); RenderButton("Dpad-Left", "Dpad-Left Outline", pads[0].button & BTN_DLEFT, scaledBGSize, - useGlobalOutlineMode - ? buttonOutlineMode - : CVarGetInteger(CVAR_INPUT_VIEWER("DpadOutlineMode"), BUTTON_OUTLINE_NOT_PRESSED)); + useGlobalOutlineMode + ? buttonOutlineMode + : CVarGetInteger(CVAR_INPUT_VIEWER("DpadOutlineMode"), BUTTON_OUTLINE_NOT_PRESSED)); ImGui::SetNextItemAllowOverlap(); ImGui::SetCursorPos(aPos); RenderButton("Dpad-Right", "Dpad-Right Outline", pads[0].button & BTN_DRIGHT, scaledBGSize, - useGlobalOutlineMode - ? buttonOutlineMode - : CVarGetInteger(CVAR_INPUT_VIEWER("DpadOutlineMode"), BUTTON_OUTLINE_NOT_PRESSED)); + useGlobalOutlineMode + ? buttonOutlineMode + : CVarGetInteger(CVAR_INPUT_VIEWER("DpadOutlineMode"), BUTTON_OUTLINE_NOT_PRESSED)); ImGui::SetNextItemAllowOverlap(); ImGui::SetCursorPos(aPos); RenderButton("Dpad-Up", "Dpad-Up Outline", pads[0].button & BTN_DUP, scaledBGSize, - useGlobalOutlineMode - ? buttonOutlineMode - : CVarGetInteger(CVAR_INPUT_VIEWER("DpadOutlineMode"), BUTTON_OUTLINE_NOT_PRESSED)); + useGlobalOutlineMode + ? buttonOutlineMode + : CVarGetInteger(CVAR_INPUT_VIEWER("DpadOutlineMode"), BUTTON_OUTLINE_NOT_PRESSED)); ImGui::SetNextItemAllowOverlap(); ImGui::SetCursorPos(aPos); RenderButton("Dpad-Down", "Dpad-Down Outline", pads[0].button & BTN_DDOWN, scaledBGSize, - useGlobalOutlineMode - ? buttonOutlineMode - : CVarGetInteger(CVAR_INPUT_VIEWER("DpadOutlineMode"), BUTTON_OUTLINE_NOT_PRESSED)); + useGlobalOutlineMode + ? buttonOutlineMode + : CVarGetInteger(CVAR_INPUT_VIEWER("DpadOutlineMode"), BUTTON_OUTLINE_NOT_PRESSED)); } // Modifier 1 @@ -303,18 +312,18 @@ void InputViewer::DrawElement() { ImGui::SetNextItemAllowOverlap(); ImGui::SetCursorPos(aPos); RenderButton("Modifier-1", "Modifier-1 Outline", pads[0].button & BTN_MODIFIER1, scaledBGSize, - useGlobalOutlineMode - ? buttonOutlineMode - : CVarGetInteger(CVAR_INPUT_VIEWER("Mod1OutlineMode"), BUTTON_OUTLINE_NOT_PRESSED)); + useGlobalOutlineMode + ? buttonOutlineMode + : CVarGetInteger(CVAR_INPUT_VIEWER("Mod1OutlineMode"), BUTTON_OUTLINE_NOT_PRESSED)); } // Modifier 2 if (CVarGetInteger(CVAR_INPUT_VIEWER("Mod2"), 0)) { ImGui::SetNextItemAllowOverlap(); ImGui::SetCursorPos(aPos); RenderButton("Modifier-2", "Modifier-2 Outline", pads[0].button & BTN_MODIFIER2, scaledBGSize, - useGlobalOutlineMode - ? buttonOutlineMode - : CVarGetInteger(CVAR_INPUT_VIEWER("Mod2OutlineMode"), BUTTON_OUTLINE_NOT_PRESSED)); + useGlobalOutlineMode + ? buttonOutlineMode + : CVarGetInteger(CVAR_INPUT_VIEWER("Mod2OutlineMode"), BUTTON_OUTLINE_NOT_PRESSED)); } const bool analogStickIsInDeadzone = !pads[0].stick_x && !pads[0].stick_y; @@ -339,9 +348,9 @@ void InputViewer::DrawElement() { ImGui::SetNextItemAllowOverlap(); ImGui::SetCursorPos( ImVec2(aPos.x + maxStickDistance * ((float)(pads[0].stick_x) / MAX_AXIS_RANGE) * scale, - aPos.y - maxStickDistance * ((float)(pads[0].stick_y) / MAX_AXIS_RANGE) * scale)); + aPos.y - maxStickDistance * ((float)(pads[0].stick_y) / MAX_AXIS_RANGE) * scale)); ImGui::Image(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Analog-Stick"), - scaledBGSize, ImVec2(0, 0), ImVec2(1.0f, 1.0f), ImVec4(255, 255, 255, 255)); + scaledBGSize, ImVec2(0, 0), ImVec2(1.0f, 1.0f), ImVec4(255, 255, 255, 255)); } // Right Stick @@ -363,15 +372,15 @@ void InputViewer::DrawElement() { ImGui::SetNextItemAllowOverlap(); ImGui::SetCursorPos( ImVec2(aPos.x + maxRightStickDistance * ((float)(pads[0].right_stick_x) / MAX_AXIS_RANGE) * scale, - aPos.y - maxRightStickDistance * ((float)(pads[0].right_stick_y) / MAX_AXIS_RANGE) * scale)); + aPos.y - maxRightStickDistance * ((float)(pads[0].right_stick_y) / MAX_AXIS_RANGE) * scale)); ImGui::Image(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Right-Stick"), - scaledBGSize, ImVec2(0, 0), ImVec2(1.0f, 1.0f), ImVec4(255, 255, 255, 255)); + scaledBGSize, ImVec2(0, 0), ImVec2(1.0f, 1.0f), ImVec4(255, 255, 255, 255)); } // Analog stick angle text if (showAnalogAngles) { ImGui::SetCursorPos(ImVec2(aPos.x + 10 + CVarGetInteger(CVAR_INPUT_VIEWER("AnalogAngles.Offset"), 0) * scale, - scaledBGSize.y + aPos.y + 10)); + scaledBGSize.y + aPos.y + 10)); // Scale font with input viewer scale float oldFontScale = ImGui::GetFont()->Scale; ImGui::GetFont()->Scale *= scale * CVarGetFloat(CVAR_INPUT_VIEWER("AnalogAngles.Scale"), 1.0f); @@ -393,14 +402,16 @@ void InputViewer::DrawElement() { ImGui::PushStyleColor( ImGuiCol_Text, color2Vec(CVarGetColor(CVAR_INPUT_VIEWER("AnalogAngles.Range1.Color"), vec2Color(range1Color)))); - } else if (CVarGetInteger(CVAR_INPUT_VIEWER("AnalogAngles.Range2.Enabled"), 0) && - (rSquared >= (range2Min * range2Min)) && (rSquared < (range2Max * range2Max))) { + } + else if (CVarGetInteger(CVAR_INPUT_VIEWER("AnalogAngles.Range2.Enabled"), 0) && + (rSquared >= (range2Min * range2Min)) && (rSquared < (range2Max * range2Max))) { ImGui::PushStyleColor( ImGuiCol_Text, color2Vec(CVarGetColor(CVAR_INPUT_VIEWER("AnalogAngles.Range2.Color"), vec2Color(range2Color)))); - } else { + } + else { ImGui::PushStyleColor(ImGuiCol_Text, color2Vec(CVarGetColor(CVAR_INPUT_VIEWER("AnalogAngles.TextColor"), - vec2Color(textColor)))); + vec2Color(textColor)))); } // Render text @@ -425,257 +436,250 @@ InputViewerSettingsWindow::~InputViewerSettingsWindow() { } void InputViewerSettingsWindow::DrawElement() { - ImGui::SetNextWindowSize(ImVec2(500, 525), ImGuiCond_FirstUseEver); - - if (ImGui::Begin("Input Viewer Settings", &mIsVisible, ImGuiWindowFlags_HorizontalScrollbar)) { - - // gInputViewer.Scale - UIWidgets::EnhancementSliderFloat("Input Viewer Scale: %.2f", "##Input", CVAR_INPUT_VIEWER("Scale"), 0.1f, 5.0f, "", - 1.0f, false, true); - UIWidgets::Tooltip("Sets the on screen size of the input viewer"); - - // gInputViewer.EnableDragging - UIWidgets::EnhancementCheckbox("Enable Dragging", CVAR_INPUT_VIEWER("EnableDragging"), false, "", - UIWidgets::CheckboxGraphics::Checkmark, true); + // gInputViewer.Scale + UIWidgets::EnhancementSliderFloat("Input Viewer Scale: %.2f", "##Input", CVAR_INPUT_VIEWER("Scale"), 0.1f, 5.0f, "", + 1.0f, false, true); + UIWidgets::Tooltip("Sets the on screen size of the input viewer"); + + // gInputViewer.EnableDragging + UIWidgets::EnhancementCheckbox("Enable Dragging", CVAR_INPUT_VIEWER("EnableDragging"), false, "", + UIWidgets::CheckboxGraphics::Checkmark, true); + + UIWidgets::PaddedSeparator(true, true); + + // gInputViewer.ShowBackground + UIWidgets::EnhancementCheckbox("Show Background Layer", CVAR_INPUT_VIEWER("ShowBackground"), false, "", + UIWidgets::CheckboxGraphics::Checkmark, true); + + UIWidgets::PaddedSeparator(true, true); + + if (ImGui::CollapsingHeader("Buttons")) { + + // gInputViewer.ButtonOutlineMode + UIWidgets::PaddedText("Button Outlines/Backgrounds", true, false); + UIWidgets::EnhancementCombobox( + CVAR_INPUT_VIEWER("ButtonOutlineMode"), buttonOutlineOptions, BUTTON_OUTLINE_NOT_PRESSED, + !CVarGetInteger(CVAR_INPUT_VIEWER("UseGlobalButtonOutlineMode"), 1), "", + CVarGetInteger(CVAR_INPUT_VIEWER("ButtonOutlineMode"), BUTTON_OUTLINE_NOT_PRESSED)); + UIWidgets::Tooltip( + "Sets the desired visibility behavior for the button outline/background layers. Useful for " + "custom input viewers."); + + // gInputViewer.UseGlobalButtonOutlineMode + UIWidgets::EnhancementCheckbox("Use for all buttons", CVAR_INPUT_VIEWER("UseGlobalButtonOutlineMode"), false, "", + UIWidgets::CheckboxGraphics::Checkmark, true); + + UIWidgets::PaddedSeparator(); + + bool useIndividualOutlines = !CVarGetInteger(CVAR_INPUT_VIEWER("UseGlobalButtonOutlineMode"), 1); + + // gInputViewer.ABtn + UIWidgets::EnhancementCheckbox("Show A-Button Layers", CVAR_INPUT_VIEWER("ABtn"), false, "", + UIWidgets::CheckboxGraphics::Checkmark, true); + if (useIndividualOutlines && CVarGetInteger(CVAR_INPUT_VIEWER("ABtn"), 1)) { + ImGui::Indent(); + UIWidgets::EnhancementCombobox(CVAR_INPUT_VIEWER("ABtnOutlineMode"), buttonOutlineOptionsVerbose, + BUTTON_OUTLINE_NOT_PRESSED); + ImGui::Unindent(); + } + // gInputViewer.BBtn + UIWidgets::EnhancementCheckbox("Show B-Button Layers", CVAR_INPUT_VIEWER("BBtn"), false, "", + UIWidgets::CheckboxGraphics::Checkmark, true); + if (useIndividualOutlines && CVarGetInteger(CVAR_INPUT_VIEWER("BBtn"), 1)) { + ImGui::Indent(); + UIWidgets::EnhancementCombobox(CVAR_INPUT_VIEWER("BBtnOutlineMode"), buttonOutlineOptionsVerbose, + BUTTON_OUTLINE_NOT_PRESSED); + ImGui::Unindent(); + } + // gInputViewer.CUp + UIWidgets::EnhancementCheckbox("Show C-Up Layers", CVAR_INPUT_VIEWER("CUp"), false, "", + UIWidgets::CheckboxGraphics::Checkmark, true); + if (useIndividualOutlines && CVarGetInteger(CVAR_INPUT_VIEWER("CUp"), 1)) { + ImGui::Indent(); + UIWidgets::EnhancementCombobox(CVAR_INPUT_VIEWER("CUpOutlineMode"), buttonOutlineOptionsVerbose, + BUTTON_OUTLINE_NOT_PRESSED); + ImGui::Unindent(); + } + // gInputViewer.CRight + UIWidgets::EnhancementCheckbox("Show C-Right Layers", CVAR_INPUT_VIEWER("CRight"), false, "", + UIWidgets::CheckboxGraphics::Checkmark, true); + if (useIndividualOutlines && CVarGetInteger(CVAR_INPUT_VIEWER("CRight"), 1)) { + ImGui::Indent(); + UIWidgets::EnhancementCombobox(CVAR_INPUT_VIEWER("CRightOutlineMode"), buttonOutlineOptionsVerbose, + BUTTON_OUTLINE_NOT_PRESSED); + ImGui::Unindent(); + } + // gInputViewer.CDown + UIWidgets::EnhancementCheckbox("Show C-Down Layers", CVAR_INPUT_VIEWER("CDown"), false, "", + UIWidgets::CheckboxGraphics::Checkmark, true); + if (useIndividualOutlines && CVarGetInteger(CVAR_INPUT_VIEWER("CDown"), 1)) { + ImGui::Indent(); + UIWidgets::EnhancementCombobox(CVAR_INPUT_VIEWER("CDownOutlineMode"), buttonOutlineOptionsVerbose, + BUTTON_OUTLINE_NOT_PRESSED); + ImGui::Unindent(); + } + // gInputViewer.CLeft + UIWidgets::EnhancementCheckbox("Show C-Left Layers", CVAR_INPUT_VIEWER("CLeft"), false, "", + UIWidgets::CheckboxGraphics::Checkmark, true); + if (useIndividualOutlines && CVarGetInteger(CVAR_INPUT_VIEWER("CLeft"), 1)) { + ImGui::Indent(); + UIWidgets::EnhancementCombobox(CVAR_INPUT_VIEWER("CLeftOutlineMode"), buttonOutlineOptionsVerbose, + BUTTON_OUTLINE_NOT_PRESSED); + ImGui::Unindent(); + } + // gInputViewer.LBtn + UIWidgets::EnhancementCheckbox("Show L-Button Layers", CVAR_INPUT_VIEWER("LBtn"), false, "", + UIWidgets::CheckboxGraphics::Checkmark, true); + if (useIndividualOutlines && CVarGetInteger(CVAR_INPUT_VIEWER("LBtn"), 1)) { + ImGui::Indent(); + UIWidgets::EnhancementCombobox(CVAR_INPUT_VIEWER("LBtnOutlineMode"), buttonOutlineOptionsVerbose, + BUTTON_OUTLINE_NOT_PRESSED); + ImGui::Unindent(); + } + // gInputViewer.RBtn + UIWidgets::EnhancementCheckbox("Show R-Button Layers", CVAR_INPUT_VIEWER("RBtn"), false, "", + UIWidgets::CheckboxGraphics::Checkmark, true); + if (useIndividualOutlines && CVarGetInteger(CVAR_INPUT_VIEWER("RBtn"), 1)) { + ImGui::Indent(); + UIWidgets::EnhancementCombobox(CVAR_INPUT_VIEWER("RBtnOutlineMode"), buttonOutlineOptionsVerbose, + BUTTON_OUTLINE_NOT_PRESSED); + ImGui::Unindent(); + } + // gInputViewer.ZBtn + UIWidgets::EnhancementCheckbox("Show Z-Button Layers", CVAR_INPUT_VIEWER("ZBtn"), false, "", + UIWidgets::CheckboxGraphics::Checkmark, true); + if (useIndividualOutlines && CVarGetInteger(CVAR_INPUT_VIEWER("ZBtn"), 1)) { + ImGui::Indent(); + UIWidgets::EnhancementCombobox(CVAR_INPUT_VIEWER("ZBtnOutlineMode"), buttonOutlineOptionsVerbose, + BUTTON_OUTLINE_NOT_PRESSED); + ImGui::Unindent(); + } + // gInputViewer.StartBtn + UIWidgets::EnhancementCheckbox("Show Start Button Layers", CVAR_INPUT_VIEWER("StartBtn"), false, "", + UIWidgets::CheckboxGraphics::Checkmark, true); + if (useIndividualOutlines && CVarGetInteger(CVAR_INPUT_VIEWER("StartBtn"), 1)) { + ImGui::Indent(); + UIWidgets::EnhancementCombobox(CVAR_INPUT_VIEWER("StartBtnOutlineMode"), buttonOutlineOptionsVerbose, + BUTTON_OUTLINE_NOT_PRESSED); + ImGui::Unindent(); + } + // gInputViewer.Dpad + UIWidgets::EnhancementCheckbox("Show D-Pad Layers", CVAR_INPUT_VIEWER("Dpad"), false, "", + UIWidgets::CheckboxGraphics::Checkmark, false); + if (useIndividualOutlines && CVarGetInteger(CVAR_INPUT_VIEWER("Dpad"), 0)) { + ImGui::Indent(); + UIWidgets::EnhancementCombobox(CVAR_INPUT_VIEWER("DpadOutlineMode"), buttonOutlineOptionsVerbose, + BUTTON_OUTLINE_NOT_PRESSED); + ImGui::Unindent(); + } + // gInputViewer.Mod1 + UIWidgets::EnhancementCheckbox("Show Modifier Button 1 Layers", CVAR_INPUT_VIEWER("Mod1"), false, "", + UIWidgets::CheckboxGraphics::Checkmark, false); + if (useIndividualOutlines && CVarGetInteger(CVAR_INPUT_VIEWER("Mod1"), 0)) { + ImGui::Indent(); + UIWidgets::EnhancementCombobox(CVAR_INPUT_VIEWER("Mod1OutlineMode"), buttonOutlineOptionsVerbose, + BUTTON_OUTLINE_NOT_PRESSED); + ImGui::Unindent(); + } + // gInputViewer.Mod2 + UIWidgets::EnhancementCheckbox("Show Modifier Button 2 Layers", CVAR_INPUT_VIEWER("Mod2"), false, "", + UIWidgets::CheckboxGraphics::Checkmark, false); + if (useIndividualOutlines && CVarGetInteger(CVAR_INPUT_VIEWER("Mod2"), 0)) { + ImGui::Indent(); + UIWidgets::EnhancementCombobox(CVAR_INPUT_VIEWER("Mod2OutlineMode"), buttonOutlineOptionsVerbose, + BUTTON_OUTLINE_NOT_PRESSED); + ImGui::Unindent(); + } UIWidgets::PaddedSeparator(true, true); + } - // gInputViewer.ShowBackground - UIWidgets::EnhancementCheckbox("Show Background Layer", CVAR_INPUT_VIEWER("ShowBackground"), false, "", - UIWidgets::CheckboxGraphics::Checkmark, true); - + if (ImGui::CollapsingHeader("Analog Stick")) { + // gInputViewer.AnalogStick.VisibilityMode + UIWidgets::PaddedText("Analog Stick Visibility", true, false); + UIWidgets::EnhancementCombobox(CVAR_INPUT_VIEWER("AnalogStick.VisibilityMode"), stickModeOptions, + STICK_MODE_ALWAYS_SHOWN); + UIWidgets::Tooltip( + "Determines the conditions under which the moving layer of the analog stick texture is visible."); + + // gInputViewer.AnalogStick.OutlineMode + UIWidgets::PaddedText("Analog Stick Outline/Background Visibility", true, false); + UIWidgets::EnhancementCombobox(CVAR_INPUT_VIEWER("AnalogStick.OutlineMode"), stickModeOptions, + STICK_MODE_ALWAYS_SHOWN); + UIWidgets::Tooltip( + "Determines the conditions under which the analog stick outline/background texture is visible."); + + // gInputViewer.AnalogStick.Movement + UIWidgets::EnhancementSliderInt("Analog Stick Movement: %dpx", "##AnalogMovement", + CVAR_INPUT_VIEWER("AnalogStick.Movement"), 0, 200, "", 12, true); + UIWidgets::Tooltip( + "Sets the distance to move the analog stick in the input viewer. Useful for custom input viewers."); UIWidgets::PaddedSeparator(true, true); + } - if (ImGui::CollapsingHeader("Buttons")) { - - // gInputViewer.ButtonOutlineMode - UIWidgets::PaddedText("Button Outlines/Backgrounds", true, false); - UIWidgets::EnhancementCombobox( - CVAR_INPUT_VIEWER("ButtonOutlineMode"), buttonOutlineOptions, BUTTON_OUTLINE_NOT_PRESSED, - !CVarGetInteger(CVAR_INPUT_VIEWER("UseGlobalButtonOutlineMode"), 1), "", - CVarGetInteger(CVAR_INPUT_VIEWER("ButtonOutlineMode"), BUTTON_OUTLINE_NOT_PRESSED)); - UIWidgets::Tooltip( - "Sets the desired visibility behavior for the button outline/background layers. Useful for " - "custom input viewers."); - - // gInputViewer.UseGlobalButtonOutlineMode - UIWidgets::EnhancementCheckbox("Use for all buttons", CVAR_INPUT_VIEWER("UseGlobalButtonOutlineMode"), false, "", - UIWidgets::CheckboxGraphics::Checkmark, true); - - UIWidgets::PaddedSeparator(); - - bool useIndividualOutlines = !CVarGetInteger(CVAR_INPUT_VIEWER("UseGlobalButtonOutlineMode"), 1); - - // gInputViewer.ABtn - UIWidgets::EnhancementCheckbox("Show A-Button Layers", CVAR_INPUT_VIEWER("ABtn"), false, "", - UIWidgets::CheckboxGraphics::Checkmark, true); - if (useIndividualOutlines && CVarGetInteger(CVAR_INPUT_VIEWER("ABtn"), 1)) { - ImGui::Indent(); - UIWidgets::EnhancementCombobox(CVAR_INPUT_VIEWER("ABtnOutlineMode"), buttonOutlineOptionsVerbose, - BUTTON_OUTLINE_NOT_PRESSED); - ImGui::Unindent(); - } - // gInputViewer.BBtn - UIWidgets::EnhancementCheckbox("Show B-Button Layers", CVAR_INPUT_VIEWER("BBtn"), false, "", - UIWidgets::CheckboxGraphics::Checkmark, true); - if (useIndividualOutlines && CVarGetInteger(CVAR_INPUT_VIEWER("BBtn"), 1)) { - ImGui::Indent(); - UIWidgets::EnhancementCombobox(CVAR_INPUT_VIEWER("BBtnOutlineMode"), buttonOutlineOptionsVerbose, - BUTTON_OUTLINE_NOT_PRESSED); - ImGui::Unindent(); - } - // gInputViewer.CUp - UIWidgets::EnhancementCheckbox("Show C-Up Layers", CVAR_INPUT_VIEWER("CUp"), false, "", - UIWidgets::CheckboxGraphics::Checkmark, true); - if (useIndividualOutlines && CVarGetInteger(CVAR_INPUT_VIEWER("CUp"), 1)) { - ImGui::Indent(); - UIWidgets::EnhancementCombobox(CVAR_INPUT_VIEWER("CUpOutlineMode"), buttonOutlineOptionsVerbose, - BUTTON_OUTLINE_NOT_PRESSED); - ImGui::Unindent(); - } - // gInputViewer.CRight - UIWidgets::EnhancementCheckbox("Show C-Right Layers", CVAR_INPUT_VIEWER("CRight"), false, "", - UIWidgets::CheckboxGraphics::Checkmark, true); - if (useIndividualOutlines && CVarGetInteger(CVAR_INPUT_VIEWER("CRight"), 1)) { - ImGui::Indent(); - UIWidgets::EnhancementCombobox(CVAR_INPUT_VIEWER("CRightOutlineMode"), buttonOutlineOptionsVerbose, - BUTTON_OUTLINE_NOT_PRESSED); - ImGui::Unindent(); - } - // gInputViewer.CDown - UIWidgets::EnhancementCheckbox("Show C-Down Layers", CVAR_INPUT_VIEWER("CDown"), false, "", - UIWidgets::CheckboxGraphics::Checkmark, true); - if (useIndividualOutlines && CVarGetInteger(CVAR_INPUT_VIEWER("CDown"), 1)) { - ImGui::Indent(); - UIWidgets::EnhancementCombobox(CVAR_INPUT_VIEWER("CDownOutlineMode"), buttonOutlineOptionsVerbose, - BUTTON_OUTLINE_NOT_PRESSED); - ImGui::Unindent(); - } - // gInputViewer.CLeft - UIWidgets::EnhancementCheckbox("Show C-Left Layers", CVAR_INPUT_VIEWER("CLeft"), false, "", - UIWidgets::CheckboxGraphics::Checkmark, true); - if (useIndividualOutlines && CVarGetInteger(CVAR_INPUT_VIEWER("CLeft"), 1)) { - ImGui::Indent(); - UIWidgets::EnhancementCombobox(CVAR_INPUT_VIEWER("CLeftOutlineMode"), buttonOutlineOptionsVerbose, - BUTTON_OUTLINE_NOT_PRESSED); - ImGui::Unindent(); - } - // gInputViewer.LBtn - UIWidgets::EnhancementCheckbox("Show L-Button Layers", CVAR_INPUT_VIEWER("LBtn"), false, "", - UIWidgets::CheckboxGraphics::Checkmark, true); - if (useIndividualOutlines && CVarGetInteger(CVAR_INPUT_VIEWER("LBtn"), 1)) { - ImGui::Indent(); - UIWidgets::EnhancementCombobox(CVAR_INPUT_VIEWER("LBtnOutlineMode"), buttonOutlineOptionsVerbose, - BUTTON_OUTLINE_NOT_PRESSED); - ImGui::Unindent(); - } - // gInputViewer.RBtn - UIWidgets::EnhancementCheckbox("Show R-Button Layers", CVAR_INPUT_VIEWER("RBtn"), false, "", - UIWidgets::CheckboxGraphics::Checkmark, true); - if (useIndividualOutlines && CVarGetInteger(CVAR_INPUT_VIEWER("RBtn"), 1)) { - ImGui::Indent(); - UIWidgets::EnhancementCombobox(CVAR_INPUT_VIEWER("RBtnOutlineMode"), buttonOutlineOptionsVerbose, - BUTTON_OUTLINE_NOT_PRESSED); - ImGui::Unindent(); - } - // gInputViewer.ZBtn - UIWidgets::EnhancementCheckbox("Show Z-Button Layers", CVAR_INPUT_VIEWER("ZBtn"), false, "", - UIWidgets::CheckboxGraphics::Checkmark, true); - if (useIndividualOutlines && CVarGetInteger(CVAR_INPUT_VIEWER("ZBtn"), 1)) { - ImGui::Indent(); - UIWidgets::EnhancementCombobox(CVAR_INPUT_VIEWER("ZBtnOutlineMode"), buttonOutlineOptionsVerbose, - BUTTON_OUTLINE_NOT_PRESSED); - ImGui::Unindent(); - } - // gInputViewer.StartBtn - UIWidgets::EnhancementCheckbox("Show Start Button Layers", CVAR_INPUT_VIEWER("StartBtn"), false, "", - UIWidgets::CheckboxGraphics::Checkmark, true); - if (useIndividualOutlines && CVarGetInteger(CVAR_INPUT_VIEWER("StartBtn"), 1)) { - ImGui::Indent(); - UIWidgets::EnhancementCombobox(CVAR_INPUT_VIEWER("StartBtnOutlineMode"), buttonOutlineOptionsVerbose, - BUTTON_OUTLINE_NOT_PRESSED); - ImGui::Unindent(); - } - // gInputViewer.Dpad - UIWidgets::EnhancementCheckbox("Show D-Pad Layers", CVAR_INPUT_VIEWER("Dpad"), false, "", - UIWidgets::CheckboxGraphics::Checkmark, false); - if (useIndividualOutlines && CVarGetInteger(CVAR_INPUT_VIEWER("Dpad"), 0)) { - ImGui::Indent(); - UIWidgets::EnhancementCombobox(CVAR_INPUT_VIEWER("DpadOutlineMode"), buttonOutlineOptionsVerbose, - BUTTON_OUTLINE_NOT_PRESSED); - ImGui::Unindent(); - } - // gInputViewer.Mod1 - UIWidgets::EnhancementCheckbox("Show Modifier Button 1 Layers", CVAR_INPUT_VIEWER("Mod1"), false, "", - UIWidgets::CheckboxGraphics::Checkmark, false); - if (useIndividualOutlines && CVarGetInteger(CVAR_INPUT_VIEWER("Mod1"), 0)) { - ImGui::Indent(); - UIWidgets::EnhancementCombobox(CVAR_INPUT_VIEWER("Mod1OutlineMode"), buttonOutlineOptionsVerbose, - BUTTON_OUTLINE_NOT_PRESSED); - ImGui::Unindent(); - } - // gInputViewer.Mod2 - UIWidgets::EnhancementCheckbox("Show Modifier Button 2 Layers", CVAR_INPUT_VIEWER("Mod2"), false, "", - UIWidgets::CheckboxGraphics::Checkmark, false); - if (useIndividualOutlines && CVarGetInteger(CVAR_INPUT_VIEWER("Mod2"), 0)) { - ImGui::Indent(); - UIWidgets::EnhancementCombobox(CVAR_INPUT_VIEWER("Mod2OutlineMode"), buttonOutlineOptionsVerbose, - BUTTON_OUTLINE_NOT_PRESSED); - ImGui::Unindent(); - } - - UIWidgets::PaddedSeparator(true, true); - } - - if (ImGui::CollapsingHeader("Analog Stick")) { - // gInputViewer.AnalogStick.VisibilityMode - UIWidgets::PaddedText("Analog Stick Visibility", true, false); - UIWidgets::EnhancementCombobox(CVAR_INPUT_VIEWER("AnalogStick.VisibilityMode"), stickModeOptions, - STICK_MODE_ALWAYS_SHOWN); - UIWidgets::Tooltip( - "Determines the conditions under which the moving layer of the analog stick texture is visible."); - - // gInputViewer.AnalogStick.OutlineMode - UIWidgets::PaddedText("Analog Stick Outline/Background Visibility", true, false); - UIWidgets::EnhancementCombobox(CVAR_INPUT_VIEWER("AnalogStick.OutlineMode"), stickModeOptions, - STICK_MODE_ALWAYS_SHOWN); - UIWidgets::Tooltip( - "Determines the conditions under which the analog stick outline/background texture is visible."); + if (ImGui::CollapsingHeader("Additional (\"Right\") Stick")) { + // gInputViewer.RightStick.VisibilityMode + UIWidgets::PaddedText("Right Stick Visibility", true, false); + UIWidgets::EnhancementCombobox(CVAR_INPUT_VIEWER("RightStick.VisibilityMode"), stickModeOptions, + STICK_MODE_HIDDEN_IN_DEADZONE); + UIWidgets::Tooltip( + "Determines the conditions under which the moving layer of the right stick texture is visible."); + + // gInputViewer.RightStick.OutlineMode + UIWidgets::PaddedText("Right Stick Outline/Background Visibility", true, false); + UIWidgets::EnhancementCombobox(CVAR_INPUT_VIEWER("RightStick.OutlineMode"), stickModeOptions, + STICK_MODE_HIDDEN_IN_DEADZONE); + UIWidgets::Tooltip( + "Determines the conditions under which the right stick outline/background texture is visible."); + + // gInputViewer.RightStick.Movement + UIWidgets::EnhancementSliderInt("Right Stick Movement: %dpx", "##RightMovement", + CVAR_INPUT_VIEWER("RightStick.Movement"), 0, 200, "", 7, true); + UIWidgets::Tooltip( + "Sets the distance to move the right stick in the input viewer. Useful for custom input viewers."); + UIWidgets::PaddedSeparator(true, true); + } - // gInputViewer.AnalogStick.Movement - UIWidgets::EnhancementSliderInt("Analog Stick Movement: %dpx", "##AnalogMovement", - CVAR_INPUT_VIEWER("AnalogStick.Movement"), 0, 200, "", 12, true); - UIWidgets::Tooltip( - "Sets the distance to move the analog stick in the input viewer. Useful for custom input viewers."); + if (ImGui::CollapsingHeader("Analog Angle Values")) { + // gAnalogAngles + UIWidgets::EnhancementCheckbox("Show Analog Stick Angle Values", CVAR_INPUT_VIEWER("AnalogAngles.Enabled")); + UIWidgets::Tooltip("Displays analog stick angle values in the input viewer"); + if (CVarGetInteger(CVAR_INPUT_VIEWER("AnalogAngles.Enabled"), 0)) { + // gInputViewer.AnalogAngles.TextColor + if (ImGui::ColorEdit4("Text Color", (float*)&textColor)) { + CVarSetColor(CVAR_INPUT_VIEWER("AnalogAngles.TextColor"), vec2Color(textColor)); + } + // gAnalogAngleScale + UIWidgets::EnhancementSliderFloat("Angle Text Scale: %.2f%%", "##AnalogAngleScale", + CVAR_INPUT_VIEWER("AnalogAngles.Scale"), 0.1f, 5.0f, "", 1.0f, true, true); + // gInputViewer.AnalogAngles.Offset + UIWidgets::EnhancementSliderInt("Angle Text Offset: %dpx", "##AnalogAngleOffset", + CVAR_INPUT_VIEWER("AnalogAngles.Offset"), 0, 400, "", 0, true); UIWidgets::PaddedSeparator(true, true); - } - - if (ImGui::CollapsingHeader("Additional (\"Right\") Stick")) { - // gInputViewer.RightStick.VisibilityMode - UIWidgets::PaddedText("Right Stick Visibility", true, false); - UIWidgets::EnhancementCombobox(CVAR_INPUT_VIEWER("RightStick.VisibilityMode"), stickModeOptions, - STICK_MODE_HIDDEN_IN_DEADZONE); - UIWidgets::Tooltip( - "Determines the conditions under which the moving layer of the right stick texture is visible."); - - // gInputViewer.RightStick.OutlineMode - UIWidgets::PaddedText("Right Stick Outline/Background Visibility", true, false); - UIWidgets::EnhancementCombobox(CVAR_INPUT_VIEWER("RightStick.OutlineMode"), stickModeOptions, - STICK_MODE_HIDDEN_IN_DEADZONE); + // gInputViewer.AnalogAngles.Range1.Enabled + UIWidgets::EnhancementCheckbox("Highlight ESS Position", CVAR_INPUT_VIEWER("AnalogAngles.Range1.Enabled")); UIWidgets::Tooltip( - "Determines the conditions under which the right stick outline/background texture is visible."); - - // gInputViewer.RightStick.Movement - UIWidgets::EnhancementSliderInt("Right Stick Movement: %dpx", "##RightMovement", - CVAR_INPUT_VIEWER("RightStick.Movement"), 0, 200, "", 7, true); - UIWidgets::Tooltip( - "Sets the distance to move the right stick in the input viewer. Useful for custom input viewers."); - UIWidgets::PaddedSeparator(true, true); - } - - if (ImGui::CollapsingHeader("Analog Angle Values")) { - // gAnalogAngles - UIWidgets::EnhancementCheckbox("Show Analog Stick Angle Values", CVAR_INPUT_VIEWER("AnalogAngles.Enabled")); - UIWidgets::Tooltip("Displays analog stick angle values in the input viewer"); - if (CVarGetInteger(CVAR_INPUT_VIEWER("AnalogAngles.Enabled"), 0)) { - // gInputViewer.AnalogAngles.TextColor - if (ImGui::ColorEdit4("Text Color", (float*)&textColor)) { - CVarSetColor(CVAR_INPUT_VIEWER("AnalogAngles.TextColor"), vec2Color(textColor)); - } - // gAnalogAngleScale - UIWidgets::EnhancementSliderFloat("Angle Text Scale: %.2f%%", "##AnalogAngleScale", - CVAR_INPUT_VIEWER("AnalogAngles.Scale"), 0.1f, 5.0f, "", 1.0f, true, true); - // gInputViewer.AnalogAngles.Offset - UIWidgets::EnhancementSliderInt("Angle Text Offset: %dpx", "##AnalogAngleOffset", - CVAR_INPUT_VIEWER("AnalogAngles.Offset"), 0, 400, "", 0, true); - UIWidgets::PaddedSeparator(true, true); - // gInputViewer.AnalogAngles.Range1.Enabled - UIWidgets::EnhancementCheckbox("Highlight ESS Position", CVAR_INPUT_VIEWER("AnalogAngles.Range1.Enabled")); - UIWidgets::Tooltip( - "Highlights the angle value text when the analog stick is in ESS position (on flat ground)"); - if (CVarGetInteger(CVAR_INPUT_VIEWER("AnalogAngles.Range1.Enabled"), 0)) { - // gInputViewer.AnalogAngles.Range1.Color - if (ImGui::ColorEdit4("ESS Color", (float*)&range1Color)) { - CVarSetColor(CVAR_INPUT_VIEWER("AnalogAngles.Range1.Color"), vec2Color(range1Color)); - } + "Highlights the angle value text when the analog stick is in ESS position (on flat ground)"); + if (CVarGetInteger(CVAR_INPUT_VIEWER("AnalogAngles.Range1.Enabled"), 0)) { + // gInputViewer.AnalogAngles.Range1.Color + if (ImGui::ColorEdit4("ESS Color", (float*)&range1Color)) { + CVarSetColor(CVAR_INPUT_VIEWER("AnalogAngles.Range1.Color"), vec2Color(range1Color)); } + } - UIWidgets::PaddedSeparator(true, true); - // gInputViewer.AnalogAngles.Range2.Enabled - UIWidgets::EnhancementCheckbox("Highlight Walking Speed Angles", - CVAR_INPUT_VIEWER("AnalogAngles.Range2.Enabled")); - UIWidgets::Tooltip("Highlights the angle value text when the analog stick is at an angle that would " - "produce a walking speed (on flat ground)\n\n" - "Useful for 1.0 Empty Jumpslash Quick Put Away"); - if (CVarGetInteger(CVAR_INPUT_VIEWER("AnalogAngles.Range2.Enabled"), 0)) { - // gInputViewer.AnalogAngles.Range2.Color - if (ImGui::ColorEdit4("Walking Speed Color", (float*)&range2Color)) { - CVarSetColor(CVAR_INPUT_VIEWER("AnalogAngles.Range2.Color"), vec2Color(range2Color)); - } + UIWidgets::PaddedSeparator(true, true); + // gInputViewer.AnalogAngles.Range2.Enabled + UIWidgets::EnhancementCheckbox("Highlight Walking Speed Angles", + CVAR_INPUT_VIEWER("AnalogAngles.Range2.Enabled")); + UIWidgets::Tooltip("Highlights the angle value text when the analog stick is at an angle that would " + "produce a walking speed (on flat ground)\n\n" + "Useful for 1.0 Empty Jumpslash Quick Put Away"); + if (CVarGetInteger(CVAR_INPUT_VIEWER("AnalogAngles.Range2.Enabled"), 0)) { + // gInputViewer.AnalogAngles.Range2.Color + if (ImGui::ColorEdit4("Walking Speed Color", (float*)&range2Color)) { + CVarSetColor(CVAR_INPUT_VIEWER("AnalogAngles.Range2.Color"), vec2Color(range2Color)); } } } - - ImGui::End(); } } diff --git a/soh/soh/Enhancements/controls/InputViewer.h b/soh/soh/Enhancements/controls/InputViewer.h index b4d6413e16a..a4b1cc44fce 100644 --- a/soh/soh/Enhancements/controls/InputViewer.h +++ b/soh/soh/Enhancements/controls/InputViewer.h @@ -21,6 +21,7 @@ class InputViewer : public Ship::GuiWindow { public: using GuiWindow::GuiWindow; + void Draw() override; void InitElement() override {}; void DrawElement() override; void UpdateElement() override {}; diff --git a/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp b/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp index 4badd827973..b0e81c16ca4 100644 --- a/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp +++ b/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp @@ -1687,12 +1687,6 @@ static const char* colorSchemes[2] = { }; void CosmeticsEditorWindow::DrawElement() { - ImGui::SetNextWindowSize(ImVec2(550, 520), ImGuiCond_FirstUseEver); - if (!ImGui::Begin("Cosmetics Editor", &mIsVisible)) { - ImGui::End(); - return; - } - ImGui::Text("Color Scheme"); ImGui::SameLine(); UIWidgets::EnhancementCombobox(CVAR_COSMETIC("DefaultColorScheme"), colorSchemes, COLORSCHEME_N64); @@ -1811,7 +1805,6 @@ void CosmeticsEditorWindow::DrawElement() { } ImGui::EndTabBar(); } - ImGui::End(); } void RegisterOnLoadGameHook() { diff --git a/soh/soh/Enhancements/debugger/MessageViewer.cpp b/soh/soh/Enhancements/debugger/MessageViewer.cpp index a9a6b613e91..46c596e9c37 100644 --- a/soh/soh/Enhancements/debugger/MessageViewer.cpp +++ b/soh/soh/Enhancements/debugger/MessageViewer.cpp @@ -20,11 +20,6 @@ void MessageViewer::InitElement() { } void MessageViewer::DrawElement() { - ImGui::SetNextWindowSize(ImVec2(520, 600), ImGuiCond_FirstUseEver); - if (!ImGui::Begin("Custom Message Debugger", &mIsVisible, ImGuiWindowFlags_NoFocusOnAppearing)) { - ImGui::End(); - return; - } ImGui::Text("Table ID"); ImGui::SameLine(); ImGui::InputText("##TableID", mTableIdBuf, MAX_STRING_SIZE, ImGuiInputTextFlags_CallbackCharFilter, UIWidgets::TextFilters::FilterAlphaNum); @@ -74,7 +69,6 @@ void MessageViewer::DrawElement() { if (ImGui::Button("Display Message##CustomMessage")) { mDisplayCustomMessageClicked = true; } - ImGui::End(); // ReSharper restore CppDFAUnreachableCode } diff --git a/soh/soh/Enhancements/debugger/actorViewer.cpp b/soh/soh/Enhancements/debugger/actorViewer.cpp index 3e4d271a827..84ecd5ff0ea 100644 --- a/soh/soh/Enhancements/debugger/actorViewer.cpp +++ b/soh/soh/Enhancements/debugger/actorViewer.cpp @@ -925,12 +925,6 @@ void ActorViewer_AddTagForAllActors() { } void ActorViewerWindow::DrawElement() { - ImGui::SetNextWindowSize(ImVec2(520, 600), ImGuiCond_FirstUseEver); - if (!ImGui::Begin("Actor Viewer", &mIsVisible, ImGuiWindowFlags_NoFocusOnAppearing)) { - ImGui::End(); - return; - } - static Actor* display; static Actor empty{}; static Actor* fetch = NULL; @@ -1235,8 +1229,6 @@ void ActorViewerWindow::DrawElement() { actors.clear(); } } - - ImGui::End(); } void ActorViewerWindow::InitElement() { diff --git a/soh/soh/Enhancements/debugger/colViewer.cpp b/soh/soh/Enhancements/debugger/colViewer.cpp index 3b5b7aa4758..8ce5f8b501a 100644 --- a/soh/soh/Enhancements/debugger/colViewer.cpp +++ b/soh/soh/Enhancements/debugger/colViewer.cpp @@ -53,11 +53,6 @@ static std::vector sphereVtx; // Draws the ImGui window for the collision viewer void ColViewerWindow::DrawElement() { - ImGui::SetNextWindowSize(ImVec2(520, 600), ImGuiCond_FirstUseEver); - if (!ImGui::Begin("Collision Viewer", &mIsVisible, ImGuiWindowFlags_NoFocusOnAppearing)) { - ImGui::End(); - return; - } UIWidgets::EnhancementCheckbox("Enabled", CVAR_DEVELOPER_TOOLS("ColViewer.Enabled")); UIWidgets::LabeledRightAlignedEnhancementCombobox("Scene", CVAR_DEVELOPER_TOOLS("ColViewer.Scene"), ColRenderSettingNames, COLVIEW_DISABLED); @@ -95,8 +90,6 @@ void ColViewerWindow::DrawElement() { } else { UIWidgets::InsertHelpHoverText(colorHelpText); } - - ImGui::End(); } // Calculates the normal for a triangle at the 3 specified points diff --git a/soh/soh/Enhancements/debugger/debugSaveEditor.cpp b/soh/soh/Enhancements/debugger/debugSaveEditor.cpp index daf08894251..a29174331a9 100644 --- a/soh/soh/Enhancements/debugger/debugSaveEditor.cpp +++ b/soh/soh/Enhancements/debugger/debugSaveEditor.cpp @@ -1747,12 +1747,6 @@ void DrawPlayerTab() { } void SaveEditorWindow::DrawElement() { - ImGui::SetNextWindowSize(ImVec2(520, 600), ImGuiCond_FirstUseEver); - if (!ImGui::Begin("Save Editor", &mIsVisible, ImGuiWindowFlags_NoFocusOnAppearing)) { - ImGui::End(); - return; - } - if (ImGui::BeginTabBar("SaveContextTabBar", ImGuiTabBarFlags_NoCloseWithMiddleMouseButton)) { if (ImGui::BeginTabItem("Info")) { DrawInfoTab(); @@ -1786,8 +1780,6 @@ void SaveEditorWindow::DrawElement() { ImGui::EndTabBar(); } - - ImGui::End(); } void SaveEditorWindow::InitElement() { diff --git a/soh/soh/Enhancements/debugger/dlViewer.cpp b/soh/soh/Enhancements/debugger/dlViewer.cpp index 790f426dfb6..42b005a8c2d 100644 --- a/soh/soh/Enhancements/debugger/dlViewer.cpp +++ b/soh/soh/Enhancements/debugger/dlViewer.cpp @@ -90,12 +90,6 @@ void PerformDisplayListSearch() { } void DLViewerWindow::DrawElement() { - ImGui::SetNextWindowSize(ImVec2(520, 600), ImGuiCond_FirstUseEver); - if (!ImGui::Begin("Display List Viewer", &mIsVisible, ImGuiWindowFlags_NoFocusOnAppearing)) { - ImGui::End(); - return; - } - // Debounce the search field as listing otr files is expensive if (ImGui::InputText("Search Display Lists", searchString, ARRAY_COUNT(searchString))) { doSearch = true; @@ -122,7 +116,6 @@ void DLViewerWindow::DrawElement() { } if (activeDisplayList == "") { - ImGui::End(); return; } @@ -131,7 +124,6 @@ void DLViewerWindow::DrawElement() { if (res->GetInitData()->Type != static_cast(LUS::ResourceType::DisplayList)) { ImGui::Text("Resource type is not a Display List. Please choose another."); - ImGui::End(); return; } @@ -325,11 +317,8 @@ void DLViewerWindow::DrawElement() { } } catch (const std::exception& e) { ImGui::Text("Error displaying DL instructions."); - ImGui::End(); return; } - - ImGui::End(); } void DLViewerWindow::InitElement() { diff --git a/soh/soh/Enhancements/debugger/valueViewer.cpp b/soh/soh/Enhancements/debugger/valueViewer.cpp index 97bf8516403..c2b27c79dc0 100644 --- a/soh/soh/Enhancements/debugger/valueViewer.cpp +++ b/soh/soh/Enhancements/debugger/valueViewer.cpp @@ -102,12 +102,6 @@ extern "C" void ValueViewer_Draw(GfxPrint* printer) { } void ValueViewerWindow::DrawElement() { - ImGui::SetNextWindowSize(ImVec2(520, 600), ImGuiCond_FirstUseEver); - if (!ImGui::Begin("Value Viewer", &mIsVisible, ImGuiWindowFlags_NoFocusOnAppearing)) { - ImGui::End(); - return; - } - UIWidgets::PaddedEnhancementCheckbox("Enable Printing", CVAR_DEVELOPER_TOOLS("ValueViewerEnablePrinting")); ImGui::BeginGroup(); @@ -212,8 +206,6 @@ void ValueViewerWindow::DrawElement() { } ImGui::EndGroup(); } - - ImGui::End(); } void ValueViewerWindow::InitElement() { diff --git a/soh/soh/Enhancements/gameplaystats.cpp b/soh/soh/Enhancements/gameplaystats.cpp index 93cb672e3f3..82a4b3b6e17 100644 --- a/soh/soh/Enhancements/gameplaystats.cpp +++ b/soh/soh/Enhancements/gameplaystats.cpp @@ -625,12 +625,6 @@ void DrawGameplayStatsOptionsTab() { } void GameplayStatsWindow::DrawElement() { - ImGui::SetNextWindowSize(ImVec2(480, 550), ImGuiCond_FirstUseEver); - if (!ImGui::Begin("Gameplay Stats", &mIsVisible, ImGuiWindowFlags_NoFocusOnAppearing)) { - ImGui::End(); - return; - } - DrawGameplayStatsHeader(); if (ImGui::BeginTabBar("Stats", ImGuiTabBarFlags_NoCloseWithMiddleMouseButton)) { @@ -654,8 +648,6 @@ void GameplayStatsWindow::DrawElement() { } ImGui::Text("Note: Gameplay stats are saved to the current file and will be\nlost if you quit without saving."); - - ImGui::End(); } void InitStats(bool isDebug) { gSaveContext.sohStats.heartPieces = isDebug ? 8 : 0; diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index 5ea7293eb38..487348c9db7 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -3137,13 +3137,6 @@ void RandomizerSettingsWindow::DrawElement() { static int maxKeyringCount; static bool disableGFKeyring = false; - - ImGui::SetNextWindowSize(ImVec2(920, 600), ImGuiCond_FirstUseEver); - if (!ImGui::Begin("Randomizer Editor", &mIsVisible, ImGuiWindowFlags_NoFocusOnAppearing)) { - ImGui::End(); - return; - } - bool disableEditingRandoSettings = CVarGetInteger(CVAR_GENERAL("RandoGenerating"), 0) || CVarGetInteger(CVAR_GENERAL("OnFileSelectNameEntry"), 0); if (disableEditingRandoSettings) { UIWidgets::DisableComponent(ImGui::GetStyle().Alpha * 0.5f); @@ -5284,7 +5277,6 @@ void RandomizerSettingsWindow::DrawElement() { if (disableEditingRandoSettings) { UIWidgets::ReEnableComponent(""); } - ImGui::End(); } CustomMessage Randomizer::GetWarpSongMessage(u16 textId, bool mysterious) { diff --git a/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp b/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp index 02952a05278..508cc5e425e 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp @@ -867,9 +867,16 @@ void UpdateCheck(uint32_t check, RandomizerCheckTrackerData data) { UpdateOrdering(area); } -void CheckTrackerWindow::DrawElement() { - ImGui::SetNextWindowSize(ImVec2(400, 540), ImGuiCond_FirstUseEver); +void CheckTrackerWindow::Draw() { + if (!IsVisible()) { + return; + } + DrawElement(); + // Sync up the IsVisible flag if it was changed by ImGui + SyncVisibilityConsoleVariable(); +} +void CheckTrackerWindow::DrawElement() { if (CVarGetInteger(CVAR_TRACKER_CHECK("WindowType"), TRACKER_WINDOW_WINDOW) == TRACKER_WINDOW_FLOATING) { if (CVarGetInteger(CVAR_TRACKER_CHECK("ShowOnlyPaused"), 0) && (gPlayState == nullptr || gPlayState->pauseCtx.state == 0)) { return; @@ -880,14 +887,16 @@ void CheckTrackerWindow::DrawElement() { int comboButton2Mask = buttons[CVarGetInteger(CVAR_TRACKER_CHECK("ComboButton2"), TRACKER_COMBO_BUTTON_R)]; OSContPad* trackerButtonsPressed = Ship::Context::GetInstance()->GetControlDeck()->GetPads(); bool comboButtonsHeld = trackerButtonsPressed != nullptr && - trackerButtonsPressed[0].button & comboButton1Mask && - trackerButtonsPressed[0].button & comboButton2Mask; + trackerButtonsPressed[0].button & comboButton1Mask && + trackerButtonsPressed[0].button & comboButton2Mask; if (!comboButtonsHeld) { return; } } } + ImGui::SetNextWindowSize(ImVec2(400, 540), ImGuiCond_FirstUseEver); + BeginFloatWindows("Check Tracker", mIsVisible, ImGuiWindowFlags_NoScrollbar); if (!GameInteractor::IsSaveLoaded() || !initialized) { @@ -1601,14 +1610,8 @@ static const char* windowType[] = { "Floating", "Window" }; static const char* displayType[] = { "Always", "Combo Button Hold" }; static const char* buttonStrings[] = { "A Button", "B Button", "C-Up", "C-Down", "C-Left", "C-Right", "L Button", "Z Button", "R Button", "Start", "D-Up", "D-Down", "D-Left", "D-Right" }; -void CheckTrackerSettingsWindow::DrawElement() { - ImGui::SetNextWindowSize(ImVec2(600, 375), ImGuiCond_FirstUseEver); - - if (!ImGui::Begin("Check Tracker Settings", &mIsVisible, ImGuiWindowFlags_NoFocusOnAppearing)) { - ImGui::End(); - return; - } +void CheckTrackerSettingsWindow::DrawElement() { ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, { 8.0f, 8.0f }); ImGui::BeginTable("CheckTrackerSettingsTable", 2, ImGuiTableFlags_BordersH | ImGuiTableFlags_BordersV); ImGui::TableSetupColumn("General settings", ImGuiTableColumnFlags_WidthStretch, 200.0f); @@ -1668,7 +1671,6 @@ void CheckTrackerSettingsWindow::DrawElement() { ImGui::PopStyleVar(1); ImGui::EndTable(); - ImGui::End(); } void CheckTrackerWindow::InitElement() { diff --git a/soh/soh/Enhancements/randomizer/randomizer_check_tracker.h b/soh/soh/Enhancements/randomizer/randomizer_check_tracker.h index be1ae441c0d..b1fab2a21eb 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_check_tracker.h +++ b/soh/soh/Enhancements/randomizer/randomizer_check_tracker.h @@ -21,6 +21,7 @@ class CheckTrackerSettingsWindow : public Ship::GuiWindow { class CheckTrackerWindow : public Ship::GuiWindow { public: using GuiWindow::GuiWindow; + void Draw() override; ~CheckTrackerWindow() {}; protected: diff --git a/soh/soh/Enhancements/randomizer/randomizer_entrance_tracker.cpp b/soh/soh/Enhancements/randomizer/randomizer_entrance_tracker.cpp index 31d92165708..dbf06f4ce5c 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_entrance_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_entrance_tracker.cpp @@ -636,7 +636,17 @@ void InitEntranceTrackingData() { SortEntranceListByType(destListSortedByType, 1); } +void EntranceTrackerWindow::Draw() { + if (!IsVisible()) { + return; + } + DrawElement(); + // Sync up the IsVisible flag if it was changed by ImGui + SyncVisibilityConsoleVariable(); +} + void EntranceTrackerWindow::DrawElement() { + // Begin tracker settings ImGui::SetNextWindowSize(ImVec2(600, 375), ImGuiCond_FirstUseEver); if (!ImGui::Begin("Entrance Tracker", &mIsVisible, ImGuiWindowFlags_NoFocusOnAppearing)) { @@ -644,7 +654,6 @@ void EntranceTrackerWindow::DrawElement() { return; } - // Begin tracker settings ImGui::SetNextItemOpen(false, ImGuiCond_Once); if (ImGui::TreeNode("Tracker Settings")) { // Reduce indentation from the tree node for the table diff --git a/soh/soh/Enhancements/randomizer/randomizer_entrance_tracker.h b/soh/soh/Enhancements/randomizer/randomizer_entrance_tracker.h index 87d73605833..e20aef76fa3 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_entrance_tracker.h +++ b/soh/soh/Enhancements/randomizer/randomizer_entrance_tracker.h @@ -89,6 +89,7 @@ class EntranceTrackerWindow : public Ship::GuiWindow { public: using GuiWindow::GuiWindow; + void Draw() override; void InitElement() override; void DrawElement() override; void UpdateElement() override {}; diff --git a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp index 5fd158d8f66..98633d597f0 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp @@ -1006,6 +1006,15 @@ void ItemTrackerLoadFile() { } } +void ItemTrackerWindow::Draw() { + if (!IsVisible()) { + return; + } + DrawElement(); + // Sync up the IsVisible flag if it was changed by ImGui + SyncVisibilityConsoleVariable(); +} + void ItemTrackerWindow::DrawElement() { UpdateVectors(); @@ -1122,13 +1131,6 @@ static const char* displayTypes[3] = { "Hidden", "Main Window", "Separate" }; static const char* extendedDisplayTypes[4] = { "Hidden", "Main Window", "Misc Window", "Separate" }; void ItemTrackerSettingsWindow::DrawElement() { - ImGui::SetNextWindowSize(ImVec2(733, 472), ImGuiCond_FirstUseEver); - - if (!ImGui::Begin("Item Tracker Settings", &mIsVisible, ImGuiWindowFlags_NoFocusOnAppearing)) { - ImGui::End(); - return; - } - ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, { 8.0f, 8.0f }); ImGui::BeginTable("itemTrackerSettingsTable", 2, ImGuiTableFlags_BordersH | ImGuiTableFlags_BordersV); ImGui::TableSetupColumn("General settings", ImGuiTableColumnFlags_WidthStretch, 200.0f); @@ -1255,8 +1257,6 @@ void ItemTrackerSettingsWindow::DrawElement() { ImGui::PopStyleVar(1); ImGui::EndTable(); - - ImGui::End(); } void ItemTrackerWindow::InitElement() { diff --git a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.h b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.h index cae869c5438..3293912594c 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.h +++ b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.h @@ -42,6 +42,7 @@ class ItemTrackerSettingsWindow : public Ship::GuiWindow { class ItemTrackerWindow : public Ship::GuiWindow { public: using GuiWindow::GuiWindow; + void Draw() override; protected: void InitElement() override; diff --git a/soh/soh/Enhancements/resolution-editor/ResolutionEditor.cpp b/soh/soh/Enhancements/resolution-editor/ResolutionEditor.cpp index f7eea08737b..21d99194ef7 100644 --- a/soh/soh/Enhancements/resolution-editor/ResolutionEditor.cpp +++ b/soh/soh/Enhancements/resolution-editor/ResolutionEditor.cpp @@ -59,424 +59,420 @@ void AdvancedResolutionSettingsWindow::InitElement() { } void AdvancedResolutionSettingsWindow::DrawElement() { - ImGui::SetNextWindowSize(ImVec2(497, 599), ImGuiCond_FirstUseEver); - if (ImGui::Begin("Advanced Resolution Settings", &mIsVisible)) { - // Initialise update flags. - bool update[3]; - for (uint8_t i = 0; i < sizeof(update); i++) - update[i] = false; - - // Initialise integer scale bounds. - short max_integerScaleFactor = default_maxIntegerScaleFactor; // default value, which may or may not get - // overridden depending on viewport res - - short integerScale_maximumBounds = 1; // can change when window is resized - // This is mostly just for UX purposes, as Fit Automatically logic is part of LUS. - if (((float)gfx_current_game_window_viewport.width / gfx_current_game_window_viewport.height) > - ((float)gfx_current_dimensions.width / gfx_current_dimensions.height)) { - // Scale to window height - integerScale_maximumBounds = gfx_current_game_window_viewport.height / gfx_current_dimensions.height; - } else { - // Scale to window width - integerScale_maximumBounds = gfx_current_game_window_viewport.width / gfx_current_dimensions.width; - } - // Lower-clamping maximum bounds value to 1 is no-longer necessary as that's accounted for in LUS. - // Letting it go below 1 in this Editor will even allow for checking if screen bounds are being exceeded. - if (default_maxIntegerScaleFactor < integerScale_maximumBounds) { - max_integerScaleFactor = - integerScale_maximumBounds + CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.ExceedBoundsBy", 0); - } + // Initialise update flags. + bool update[3]; + for (uint8_t i = 0; i < sizeof(update); i++) + update[i] = false; + + // Initialise integer scale bounds. + short max_integerScaleFactor = default_maxIntegerScaleFactor; // default value, which may or may not get + // overridden depending on viewport res + + short integerScale_maximumBounds = 1; // can change when window is resized + // This is mostly just for UX purposes, as Fit Automatically logic is part of LUS. + if (((float)gfx_current_game_window_viewport.width / gfx_current_game_window_viewport.height) > + ((float)gfx_current_dimensions.width / gfx_current_dimensions.height)) { + // Scale to window height + integerScale_maximumBounds = gfx_current_game_window_viewport.height / gfx_current_dimensions.height; + } else { + // Scale to window width + integerScale_maximumBounds = gfx_current_game_window_viewport.width / gfx_current_dimensions.width; + } + // Lower-clamping maximum bounds value to 1 is no-longer necessary as that's accounted for in LUS. + // Letting it go below 1 in this Editor will even allow for checking if screen bounds are being exceeded. + if (default_maxIntegerScaleFactor < integerScale_maximumBounds) { + max_integerScaleFactor = + integerScale_maximumBounds + CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.ExceedBoundsBy", 0); + } - // Combo List defaults - static int item_aspectRatio = CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".UIComboItem.AspectRatio", 3); - static int item_pixelCount = CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".UIComboItem.PixelCount", default_pixelCount); - // Stored Values for non-UIWidgets elements - static float aspectRatioX = - CVarGetFloat(CVAR_PREFIX_ADVANCED_RESOLUTION ".AspectRatioX", aspectRatioPresetsX[item_aspectRatio]); - static float aspectRatioY = - CVarGetFloat(CVAR_PREFIX_ADVANCED_RESOLUTION ".AspectRatioY", aspectRatioPresetsY[item_aspectRatio]); - static int verticalPixelCount = - CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".VerticalPixelCount", pixelCountPresets[item_pixelCount]); - // Additional settings - static bool showHorizontalResField = false; - static int horizontalPixelCount = (verticalPixelCount / aspectRatioY) * aspectRatioX; - // Disabling flags - const bool disabled_everything = !CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".Enabled", 0); - const bool disabled_pixelCount = !CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".VerticalResolutionToggle", 0); + // Combo List defaults + static int item_aspectRatio = CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".UIComboItem.AspectRatio", 3); + static int item_pixelCount = CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".UIComboItem.PixelCount", default_pixelCount); + // Stored Values for non-UIWidgets elements + static float aspectRatioX = + CVarGetFloat(CVAR_PREFIX_ADVANCED_RESOLUTION ".AspectRatioX", aspectRatioPresetsX[item_aspectRatio]); + static float aspectRatioY = + CVarGetFloat(CVAR_PREFIX_ADVANCED_RESOLUTION ".AspectRatioY", aspectRatioPresetsY[item_aspectRatio]); + static int verticalPixelCount = + CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".VerticalPixelCount", pixelCountPresets[item_pixelCount]); + // Additional settings + static bool showHorizontalResField = false; + static int horizontalPixelCount = (verticalPixelCount / aspectRatioY) * aspectRatioX; + // Disabling flags + const bool disabled_everything = !CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".Enabled", 0); + const bool disabled_pixelCount = !CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".VerticalResolutionToggle", 0); #ifdef __APPLE__ - // Display HiDPI warning. (Remove this once we can definitively say it's fixed.) - ImGui::TextColored(messageColor[MESSAGE_INFO], - ICON_FA_INFO_CIRCLE " These settings may behave incorrectly on Retina displays."); - UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); + // Display HiDPI warning. (Remove this once we can definitively say it's fixed.) + ImGui::TextColored(messageColor[MESSAGE_INFO], + ICON_FA_INFO_CIRCLE " These settings may behave incorrectly on Retina displays."); + UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); #endif - if (ImGui::CollapsingHeader("Original Settings", ImGuiTreeNodeFlags_DefaultOpen)) { - // The original resolution slider (for convenience) - const bool disabled_resolutionSlider = (CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".VerticalResolutionToggle", 0) && - CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".Enabled", 0)) || - CVarGetInteger(CVAR_LOW_RES_MODE, 0); - if (UIWidgets::EnhancementSliderFloat("Internal Resolution: %.1f%%", "##IMul", CVAR_INTERNAL_RESOLUTION, 0.5f, - 2.0f, "", 1.0f, true, true, disabled_resolutionSlider)) { - Ship::Context::GetInstance()->GetWindow()->SetResolutionMultiplier( - CVarGetFloat(CVAR_INTERNAL_RESOLUTION, 1)); - } - UIWidgets::Tooltip("Multiplies your output resolution by the value entered."); + if (ImGui::CollapsingHeader("Original Settings", ImGuiTreeNodeFlags_DefaultOpen)) { + // The original resolution slider (for convenience) + const bool disabled_resolutionSlider = (CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".VerticalResolutionToggle", 0) && + CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".Enabled", 0)) || + CVarGetInteger(CVAR_LOW_RES_MODE, 0); + if (UIWidgets::EnhancementSliderFloat("Internal Resolution: %.1f%%", "##IMul", CVAR_INTERNAL_RESOLUTION, 0.5f, + 2.0f, "", 1.0f, true, true, disabled_resolutionSlider)) { + Ship::Context::GetInstance()->GetWindow()->SetResolutionMultiplier( + CVarGetFloat(CVAR_INTERNAL_RESOLUTION, 1)); + } + UIWidgets::Tooltip("Multiplies your output resolution by the value entered."); - // The original MSAA slider (also for convenience) + // The original MSAA slider (also for convenience) #ifndef __WIIU__ - if (UIWidgets::PaddedEnhancementSliderInt("MSAA: %d", "##IMSAA", CVAR_MSAA_VALUE, 1, 8, "", 1, true, true, - false)) { - Ship::Context::GetInstance()->GetWindow()->SetMsaaLevel(CVarGetInteger(CVAR_MSAA_VALUE, 1)); - }; - UIWidgets::Tooltip( - "Activates multi-sample anti-aliasing when above 1x, up to 8x for 8 samples for every pixel.\n\n" - " " ICON_FA_INFO_CIRCLE - " (Higher MSAA with low resolution can approximate an authentic \"real N64\" look!)"); + if (UIWidgets::PaddedEnhancementSliderInt("MSAA: %d", "##IMSAA", CVAR_MSAA_VALUE, 1, 8, "", 1, true, true, + false)) { + Ship::Context::GetInstance()->GetWindow()->SetMsaaLevel(CVarGetInteger(CVAR_MSAA_VALUE, 1)); + }; + UIWidgets::Tooltip( + "Activates multi-sample anti-aliasing when above 1x, up to 8x for 8 samples for every pixel.\n\n" + " " ICON_FA_INFO_CIRCLE + " (Higher MSAA with low resolution can approximate an authentic \"real N64\" look!)"); #endif - // N64 Mode toggle (again for convenience) - // UIWidgets::PaddedEnhancementCheckbox("(Enhancements>Graphics) N64 Mode", CVAR_LOW_RES_MODE, false, false, false, "", UIWidgets::CheckboxGraphics::Cross, false); - } + // N64 Mode toggle (again for convenience) + // UIWidgets::PaddedEnhancementCheckbox("(Enhancements>Graphics) N64 Mode", CVAR_LOW_RES_MODE, false, false, false, "", UIWidgets::CheckboxGraphics::Cross, false); + } - UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); - // Activator - UIWidgets::PaddedEnhancementCheckbox("Enable advanced settings.", CVAR_PREFIX_ADVANCED_RESOLUTION ".Enabled", false, false, - false, "", UIWidgets::CheckboxGraphics::Cross, false); - // Error/Warning display - if (!CVarGetInteger(CVAR_LOW_RES_MODE, 0)) { - if (IsDroppingFrames()) { // Significant frame drop warning - ImGui::TextColored(messageColor[MESSAGE_WARNING], - ICON_FA_EXCLAMATION_TRIANGLE " Significant frame rate (FPS) drops may be occuring."); - UIWidgets::Spacer(2); - } else { // No warnings - UIWidgets::Spacer(enhancementSpacerHeight); - } - } else { // N64 Mode warning - ImGui::TextColored(messageColor[MESSAGE_QUESTION], - ICON_FA_QUESTION_CIRCLE " \"N64 Mode\" is overriding these settings."); - ImGui::SameLine(); - if (ImGui::Button("Click to disable")) { - CVarSetInteger(CVAR_LOW_RES_MODE, 0); - CVarSave(); - } - } - // Resolution visualiser - ImGui::Text("Viewport dimensions: %d x %d", gfx_current_game_window_viewport.width, - gfx_current_game_window_viewport.height); - ImGui::Text("Internal resolution: %d x %d", gfx_current_dimensions.width, gfx_current_dimensions.height); - - UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); - if (disabled_everything) { // Hide aspect ratio controls. - UIWidgets::DisableComponent(ImGui::GetStyle().Alpha * 0.5f); + UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); + // Activator + UIWidgets::PaddedEnhancementCheckbox("Enable advanced settings.", CVAR_PREFIX_ADVANCED_RESOLUTION ".Enabled", false, false, + false, "", UIWidgets::CheckboxGraphics::Cross, false); + // Error/Warning display + if (!CVarGetInteger(CVAR_LOW_RES_MODE, 0)) { + if (IsDroppingFrames()) { // Significant frame drop warning + ImGui::TextColored(messageColor[MESSAGE_WARNING], + ICON_FA_EXCLAMATION_TRIANGLE " Significant frame rate (FPS) drops may be occuring."); + UIWidgets::Spacer(2); + } else { // No warnings + UIWidgets::Spacer(enhancementSpacerHeight); } - - // Aspect Ratio - ImGui::Text("Force aspect ratio:"); + } else { // N64 Mode warning + ImGui::TextColored(messageColor[MESSAGE_QUESTION], + ICON_FA_QUESTION_CIRCLE " \"N64 Mode\" is overriding these settings."); ImGui::SameLine(); - ImGui::TextColored(messageColor[MESSAGE_GRAY_75], "(Select \"Off\" to disable.)"); - // Presets - if (ImGui::Combo(" ", &item_aspectRatio, aspectRatioPresetLabels, - IM_ARRAYSIZE(aspectRatioPresetLabels)) && - item_aspectRatio != default_aspectRatio) { // don't change anything if "Custom" is selected. - aspectRatioX = aspectRatioPresetsX[item_aspectRatio]; - aspectRatioY = aspectRatioPresetsY[item_aspectRatio]; - - if (showHorizontalResField) { - horizontalPixelCount = (verticalPixelCount / aspectRatioY) * aspectRatioX; - } - - CVarSetFloat(CVAR_PREFIX_ADVANCED_RESOLUTION ".AspectRatioX", aspectRatioX); - CVarSetFloat(CVAR_PREFIX_ADVANCED_RESOLUTION ".AspectRatioY", aspectRatioY); - CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".UIComboItem.AspectRatio", item_aspectRatio); + if (ImGui::Button("Click to disable")) { + CVarSetInteger(CVAR_LOW_RES_MODE, 0); CVarSave(); } - // Hide aspect ratio input fields if using one of the presets. - if (item_aspectRatio == default_aspectRatio && !showHorizontalResField) { - // Declare input interaction bools outside of IF statement to prevent Y field from disappearing. - const bool input_X = ImGui::InputFloat("X", &aspectRatioX, 0.1f, 1.0f, "%.3f"); - const bool input_Y = ImGui::InputFloat("Y", &aspectRatioY, 0.1f, 1.0f, "%.3f"); - if (input_X || input_Y) { - item_aspectRatio = default_aspectRatio; - update[UPDATE_aspectRatioX] = true; - update[UPDATE_aspectRatioY] = true; - } - } else if (showHorizontalResField) { // Show calculated aspect ratio - if (item_aspectRatio) { - UIWidgets::Spacer(2); - const float resolvedAspectRatio = (float)gfx_current_dimensions.width / gfx_current_dimensions.height; - ImGui::Text("Aspect ratio: %.2f:1", resolvedAspectRatio); - } else { - UIWidgets::Spacer(enhancementSpacerHeight); - } - } + } + // Resolution visualiser + ImGui::Text("Viewport dimensions: %d x %d", gfx_current_game_window_viewport.width, + gfx_current_game_window_viewport.height); + ImGui::Text("Internal resolution: %d x %d", gfx_current_dimensions.width, gfx_current_dimensions.height); + + UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); + if (disabled_everything) { // Hide aspect ratio controls. + UIWidgets::DisableComponent(ImGui::GetStyle().Alpha * 0.5f); + } + + // Aspect Ratio + ImGui::Text("Force aspect ratio:"); + ImGui::SameLine(); + ImGui::TextColored(messageColor[MESSAGE_GRAY_75], "(Select \"Off\" to disable.)"); + // Presets + if (ImGui::Combo(" ", &item_aspectRatio, aspectRatioPresetLabels, + IM_ARRAYSIZE(aspectRatioPresetLabels)) && + item_aspectRatio != default_aspectRatio) { // don't change anything if "Custom" is selected. + aspectRatioX = aspectRatioPresetsX[item_aspectRatio]; + aspectRatioY = aspectRatioPresetsY[item_aspectRatio]; - if (disabled_everything) { // Hide aspect ratio controls. - UIWidgets::ReEnableComponent("disabledTooltipText"); + if (showHorizontalResField) { + horizontalPixelCount = (verticalPixelCount / aspectRatioY) * aspectRatioX; } - UIWidgets::Spacer(0); - // Vertical Resolution - UIWidgets::PaddedEnhancementCheckbox("Set fixed vertical resolution (disables Resolution slider)", - CVAR_PREFIX_ADVANCED_RESOLUTION ".VerticalResolutionToggle", true, false, - disabled_everything, "", UIWidgets::CheckboxGraphics::Cross, false); - UIWidgets::Tooltip( - "Override the resolution scale slider and use the settings below, irrespective of window size."); - if (disabled_pixelCount || disabled_everything) { // Hide pixel count controls. - UIWidgets::DisableComponent(ImGui::GetStyle().Alpha * 0.5f); + CVarSetFloat(CVAR_PREFIX_ADVANCED_RESOLUTION ".AspectRatioX", aspectRatioX); + CVarSetFloat(CVAR_PREFIX_ADVANCED_RESOLUTION ".AspectRatioY", aspectRatioY); + CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".UIComboItem.AspectRatio", item_aspectRatio); + CVarSave(); + } + // Hide aspect ratio input fields if using one of the presets. + if (item_aspectRatio == default_aspectRatio && !showHorizontalResField) { + // Declare input interaction bools outside of IF statement to prevent Y field from disappearing. + const bool input_X = ImGui::InputFloat("X", &aspectRatioX, 0.1f, 1.0f, "%.3f"); + const bool input_Y = ImGui::InputFloat("Y", &aspectRatioY, 0.1f, 1.0f, "%.3f"); + if (input_X || input_Y) { + item_aspectRatio = default_aspectRatio; + update[UPDATE_aspectRatioX] = true; + update[UPDATE_aspectRatioY] = true; } - if (ImGui::Combo("Pixel Count Presets", &item_pixelCount, pixelCountPresetLabels, - IM_ARRAYSIZE(pixelCountPresetLabels)) && - item_pixelCount != default_pixelCount) { // don't change anything if "Custom" is selected. - verticalPixelCount = pixelCountPresets[item_pixelCount]; + } else if (showHorizontalResField) { // Show calculated aspect ratio + if (item_aspectRatio) { + UIWidgets::Spacer(2); + const float resolvedAspectRatio = (float)gfx_current_dimensions.width / gfx_current_dimensions.height; + ImGui::Text("Aspect ratio: %.2f:1", resolvedAspectRatio); + } else { + UIWidgets::Spacer(enhancementSpacerHeight); + } + } - if (showHorizontalResField) { - horizontalPixelCount = (verticalPixelCount / aspectRatioY) * aspectRatioX; - } + if (disabled_everything) { // Hide aspect ratio controls. + UIWidgets::ReEnableComponent("disabledTooltipText"); + } + UIWidgets::Spacer(0); + + // Vertical Resolution + UIWidgets::PaddedEnhancementCheckbox("Set fixed vertical resolution (disables Resolution slider)", + CVAR_PREFIX_ADVANCED_RESOLUTION ".VerticalResolutionToggle", true, false, + disabled_everything, "", UIWidgets::CheckboxGraphics::Cross, false); + UIWidgets::Tooltip( + "Override the resolution scale slider and use the settings below, irrespective of window size."); + if (disabled_pixelCount || disabled_everything) { // Hide pixel count controls. + UIWidgets::DisableComponent(ImGui::GetStyle().Alpha * 0.5f); + } + if (ImGui::Combo("Pixel Count Presets", &item_pixelCount, pixelCountPresetLabels, + IM_ARRAYSIZE(pixelCountPresetLabels)) && + item_pixelCount != default_pixelCount) { // don't change anything if "Custom" is selected. + verticalPixelCount = pixelCountPresets[item_pixelCount]; - CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".VerticalPixelCount", verticalPixelCount); - CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".UIComboItem.PixelCount", item_pixelCount); - CVarSave(); - } - // Horizontal Resolution, if visibility is enabled for it. if (showHorizontalResField) { - // Only show the field if Aspect Ratio is being enforced. - if ((aspectRatioX > 0.0f) && (aspectRatioY > 0.0f)) { - // So basically we're "faking" this one by setting aspectRatioX instead. - if (ImGui::InputInt("Horiz. Pixel Count", &horizontalPixelCount, 8, 320)) { - item_aspectRatio = default_aspectRatio; - if (horizontalPixelCount < SCREEN_WIDTH) { - horizontalPixelCount = SCREEN_WIDTH; - } - aspectRatioX = horizontalPixelCount; - aspectRatioY = verticalPixelCount; - update[UPDATE_aspectRatioX] = true; - update[UPDATE_aspectRatioY] = true; - } - } else { // Display a notice instead. - ImGui::TextColored(messageColor[MESSAGE_QUESTION], - ICON_FA_QUESTION_CIRCLE " \"Force aspect ratio\" required."); - // ImGui::Text(" "); - ImGui::SameLine(); - if (ImGui::Button("Click to resolve")) { - item_aspectRatio = default_aspectRatio; // Set it to Custom - aspectRatioX = aspectRatioPresetsX[2]; // but use the 4:3 defaults - aspectRatioY = aspectRatioPresetsY[2]; - update[UPDATE_aspectRatioX] = true; - update[UPDATE_aspectRatioY] = true; - horizontalPixelCount = (verticalPixelCount / aspectRatioY) * aspectRatioX; - } - } + horizontalPixelCount = (verticalPixelCount / aspectRatioY) * aspectRatioX; } - // Vertical Resolution part 2 - if (ImGui::InputInt("Vertical Pixel Count", &verticalPixelCount, 8, 240)) { - item_pixelCount = default_pixelCount; - update[UPDATE_verticalPixelCount] = true; - - // Account for the natural instinct to enter horizontal first. - // Ignore vertical resolutions that are below the lower clamp constant. - if (showHorizontalResField && !(verticalPixelCount < minVerticalPixelCount)) { + + CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".VerticalPixelCount", verticalPixelCount); + CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".UIComboItem.PixelCount", item_pixelCount); + CVarSave(); + } + // Horizontal Resolution, if visibility is enabled for it. + if (showHorizontalResField) { + // Only show the field if Aspect Ratio is being enforced. + if ((aspectRatioX > 0.0f) && (aspectRatioY > 0.0f)) { + // So basically we're "faking" this one by setting aspectRatioX instead. + if (ImGui::InputInt("Horiz. Pixel Count", &horizontalPixelCount, 8, 320)) { item_aspectRatio = default_aspectRatio; + if (horizontalPixelCount < SCREEN_WIDTH) { + horizontalPixelCount = SCREEN_WIDTH; + } aspectRatioX = horizontalPixelCount; aspectRatioY = verticalPixelCount; update[UPDATE_aspectRatioX] = true; update[UPDATE_aspectRatioY] = true; } + } else { // Display a notice instead. + ImGui::TextColored(messageColor[MESSAGE_QUESTION], + ICON_FA_QUESTION_CIRCLE " \"Force aspect ratio\" required."); + // ImGui::Text(" "); + ImGui::SameLine(); + if (ImGui::Button("Click to resolve")) { + item_aspectRatio = default_aspectRatio; // Set it to Custom + aspectRatioX = aspectRatioPresetsX[2]; // but use the 4:3 defaults + aspectRatioY = aspectRatioPresetsY[2]; + update[UPDATE_aspectRatioX] = true; + update[UPDATE_aspectRatioY] = true; + horizontalPixelCount = (verticalPixelCount / aspectRatioY) * aspectRatioX; + } } - if (disabled_pixelCount || disabled_everything) { // Hide pixel count controls. - UIWidgets::ReEnableComponent("disabledTooltipText"); + } + // Vertical Resolution part 2 + if (ImGui::InputInt("Vertical Pixel Count", &verticalPixelCount, 8, 240)) { + item_pixelCount = default_pixelCount; + update[UPDATE_verticalPixelCount] = true; + + // Account for the natural instinct to enter horizontal first. + // Ignore vertical resolutions that are below the lower clamp constant. + if (showHorizontalResField && !(verticalPixelCount < minVerticalPixelCount)) { + item_aspectRatio = default_aspectRatio; + aspectRatioX = horizontalPixelCount; + aspectRatioY = verticalPixelCount; + update[UPDATE_aspectRatioX] = true; + update[UPDATE_aspectRatioY] = true; } + } + if (disabled_pixelCount || disabled_everything) { // Hide pixel count controls. + UIWidgets::ReEnableComponent("disabledTooltipText"); + } - UIWidgets::Spacer(0); - - // Integer scaling settings group (Pixel-perfect Mode) - static const ImGuiTreeNodeFlags IntegerScalingResolvedImGuiFlag = - CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", 0) ? ImGuiTreeNodeFlags_DefaultOpen - : ImGuiTreeNodeFlags_None; - if (ImGui::CollapsingHeader("Integer Scaling Settings", IntegerScalingResolvedImGuiFlag)) { - const bool disabled_pixelPerfectMode = - !CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", 0) || disabled_everything; - // Pixel-perfect Mode - UIWidgets::PaddedEnhancementCheckbox("Pixel-perfect Mode", CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", true, - true, disabled_pixelCount || disabled_everything, "", - UIWidgets::CheckboxGraphics::Cross, false); - UIWidgets::Tooltip("Don't scale image to fill window."); - if (disabled_pixelCount && CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", 0)) { - CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", 0); - CVarSave(); - } + UIWidgets::Spacer(0); + + // Integer scaling settings group (Pixel-perfect Mode) + static const ImGuiTreeNodeFlags IntegerScalingResolvedImGuiFlag = + CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", 0) ? ImGuiTreeNodeFlags_DefaultOpen + : ImGuiTreeNodeFlags_None; + if (ImGui::CollapsingHeader("Integer Scaling Settings", IntegerScalingResolvedImGuiFlag)) { + const bool disabled_pixelPerfectMode = + !CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", 0) || disabled_everything; + // Pixel-perfect Mode + UIWidgets::PaddedEnhancementCheckbox("Pixel-perfect Mode", CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", true, + true, disabled_pixelCount || disabled_everything, "", + UIWidgets::CheckboxGraphics::Cross, false); + UIWidgets::Tooltip("Don't scale image to fill window."); + if (disabled_pixelCount && CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", 0)) { + CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", 0); + CVarSave(); + } - // Integer Scaling - UIWidgets::EnhancementSliderInt( - "Integer scale factor: %d", "##ARSIntScale", CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.Factor", 1, - max_integerScaleFactor, "%d", 1, true, - disabled_pixelPerfectMode || CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.FitAutomatically", 0)); - UIWidgets::Tooltip("Integer scales the image. Only available in pixel-perfect mode."); - // Display warning if size is being clamped or if framebuffer is larger than viewport. - if (!disabled_pixelPerfectMode && - (CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.NeverExceedBounds", 1) && - CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.Factor", 1) > integerScale_maximumBounds)) { - ImGui::SameLine(); - ImGui::TextColored(messageColor[MESSAGE_WARNING], ICON_FA_EXCLAMATION_TRIANGLE " Window exceeded."); - } + // Integer Scaling + UIWidgets::EnhancementSliderInt( + "Integer scale factor: %d", "##ARSIntScale", CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.Factor", 1, + max_integerScaleFactor, "%d", 1, true, + disabled_pixelPerfectMode || CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.FitAutomatically", 0)); + UIWidgets::Tooltip("Integer scales the image. Only available in pixel-perfect mode."); + // Display warning if size is being clamped or if framebuffer is larger than viewport. + if (!disabled_pixelPerfectMode && + (CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.NeverExceedBounds", 1) && + CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.Factor", 1) > integerScale_maximumBounds)) { + ImGui::SameLine(); + ImGui::TextColored(messageColor[MESSAGE_WARNING], ICON_FA_EXCLAMATION_TRIANGLE " Window exceeded."); + } - UIWidgets::PaddedEnhancementCheckbox( - "Automatically scale image to fit viewport", CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.FitAutomatically", true, - true, disabled_pixelPerfectMode, "", UIWidgets::CheckboxGraphics::Cross, false); - UIWidgets::Tooltip("Automatically sets scale factor to fit window. Only available in pixel-perfect mode."); - if (CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.FitAutomatically", 0)) { - // This is just here to update the value shown on the slider. - // The function in LUS to handle this setting will ignore IntegerScaleFactor while active. - CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.Factor", integerScale_maximumBounds); - // CVarSave(); - } - } // End of integer scaling settings + UIWidgets::PaddedEnhancementCheckbox( + "Automatically scale image to fit viewport", CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.FitAutomatically", true, + true, disabled_pixelPerfectMode, "", UIWidgets::CheckboxGraphics::Cross, false); + UIWidgets::Tooltip("Automatically sets scale factor to fit window. Only available in pixel-perfect mode."); + if (CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.FitAutomatically", 0)) { + // This is just here to update the value shown on the slider. + // The function in LUS to handle this setting will ignore IntegerScaleFactor while active. + CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.Factor", integerScale_maximumBounds); + // CVarSave(); + } + } // End of integer scaling settings - UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); + UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); - // Collapsible panel for additional settings - if (ImGui::CollapsingHeader("Additional Settings")) { - UIWidgets::Spacer(0); + // Collapsible panel for additional settings + if (ImGui::CollapsingHeader("Additional Settings")) { + UIWidgets::Spacer(0); #if defined(__SWITCH__) || defined(__WIIU__) - // Disable aspect correction, stretching the framebuffer to fill the viewport. - // This option is only really needed on systems limited to 16:9 TV resolutions, such as consoles. - // The associated cvar is still functional on PC platforms if you want to use it though. - UIWidgets::PaddedEnhancementCheckbox("Disable aspect correction and stretch the output image.\n" - "(Might be useful for 4:3 televisions!)\n" - "Not available in Pixel Perfect Mode.", - CVAR_PREFIX_ADVANCED_RESOLUTION ".IgnoreAspectCorrection", false, true, - CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", 0) || - disabled_everything, - "", UIWidgets::CheckboxGraphics::Cross, false); + // Disable aspect correction, stretching the framebuffer to fill the viewport. + // This option is only really needed on systems limited to 16:9 TV resolutions, such as consoles. + // The associated cvar is still functional on PC platforms if you want to use it though. + UIWidgets::PaddedEnhancementCheckbox("Disable aspect correction and stretch the output image.\n" + "(Might be useful for 4:3 televisions!)\n" + "Not available in Pixel Perfect Mode.", + CVAR_PREFIX_ADVANCED_RESOLUTION ".IgnoreAspectCorrection", false, true, + CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", 0) || + disabled_everything, + "", UIWidgets::CheckboxGraphics::Cross, false); #else - if (CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IgnoreAspectCorrection", 0)) { - // This setting is intentionally not exposed on PC platforms, - // but may be accidentally activated for varying reasons. - // Having this button should hopefully prevent support headaches. - ImGui::TextColored(messageColor[MESSAGE_QUESTION], ICON_FA_QUESTION_CIRCLE - " If the image is stretched and you don't know why, click this."); - if (ImGui::Button("Click to reenable aspect correction.")) { - CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IgnoreAspectCorrection", 0); - CVarSave(); - } - UIWidgets::Spacer(2); + if (CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IgnoreAspectCorrection", 0)) { + // This setting is intentionally not exposed on PC platforms, + // but may be accidentally activated for varying reasons. + // Having this button should hopefully prevent support headaches. + ImGui::TextColored(messageColor[MESSAGE_QUESTION], ICON_FA_QUESTION_CIRCLE + " If the image is stretched and you don't know why, click this."); + if (ImGui::Button("Click to reenable aspect correction.")) { + CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IgnoreAspectCorrection", 0); + CVarSave(); } + UIWidgets::Spacer(2); + } #endif - // A requested addition; an alternative way of displaying the resolution field. - if (ImGui::Checkbox("Show a horizontal resolution field, instead of aspect ratio.", &showHorizontalResField)) { - if (!showHorizontalResField && (aspectRatioX > 0.0f)) { // when turning this setting off - // Refresh relevant values - aspectRatioX = aspectRatioY * horizontalPixelCount / verticalPixelCount; + // A requested addition; an alternative way of displaying the resolution field. + if (ImGui::Checkbox("Show a horizontal resolution field, instead of aspect ratio.", &showHorizontalResField)) { + if (!showHorizontalResField && (aspectRatioX > 0.0f)) { // when turning this setting off + // Refresh relevant values + aspectRatioX = aspectRatioY * horizontalPixelCount / verticalPixelCount; + horizontalPixelCount = (verticalPixelCount / aspectRatioY) * aspectRatioX; + } else { // when turning this setting on + item_aspectRatio = default_aspectRatio; + if (aspectRatioX > 0.0f) { + // Refresh relevant values in the opposite order horizontalPixelCount = (verticalPixelCount / aspectRatioY) * aspectRatioX; - } else { // when turning this setting on - item_aspectRatio = default_aspectRatio; - if (aspectRatioX > 0.0f) { - // Refresh relevant values in the opposite order - horizontalPixelCount = (verticalPixelCount / aspectRatioY) * aspectRatioX; - aspectRatioX = aspectRatioY * horizontalPixelCount / verticalPixelCount; - } + aspectRatioX = aspectRatioY * horizontalPixelCount / verticalPixelCount; } - update[UPDATE_aspectRatioX] = true; } + update[UPDATE_aspectRatioX] = true; + } - // Beginning of Integer Scaling additional settings. - { - // UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); + // Beginning of Integer Scaling additional settings. + { + // UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); - // Integer Scaling - Never Exceed Bounds. - const bool disabled_neverExceedBounds = - !CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", 0) || - CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.FitAutomatically", 0) || disabled_everything; - const bool checkbox_neverExceedBounds = - UIWidgets::PaddedEnhancementCheckbox("Prevent integer scaling from exceeding screen bounds.\n" - "(Makes screen bounds take priority over specified factor.)", - CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.NeverExceedBounds", - true, false, disabled_neverExceedBounds, "", - UIWidgets::CheckboxGraphics::Cross, true); - UIWidgets::Tooltip( - "Prevents integer scaling factor from exceeding screen bounds.\n\n" - "Enabled: Will clamp the scaling factor and display a gentle warning in the resolution editor.\n" - "Disabled: Will allow scaling to exceed screen bounds, for users who want to crop overscan.\n\n" - " " ICON_FA_INFO_CIRCLE - " Please note that exceeding screen bounds may show a scroll bar on-screen."); - - // Initialise the (currently unused) "Exceed Bounds By" cvar if it's been changed. - if (checkbox_neverExceedBounds && - CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.ExceedBoundsBy", 0)) { - CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.ExceedBoundsBy", 0); - CVarSave(); - } + // Integer Scaling - Never Exceed Bounds. + const bool disabled_neverExceedBounds = + !CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", 0) || + CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.FitAutomatically", 0) || disabled_everything; + const bool checkbox_neverExceedBounds = + UIWidgets::PaddedEnhancementCheckbox("Prevent integer scaling from exceeding screen bounds.\n" + "(Makes screen bounds take priority over specified factor.)", + CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.NeverExceedBounds", + true, false, disabled_neverExceedBounds, "", + UIWidgets::CheckboxGraphics::Cross, true); + UIWidgets::Tooltip( + "Prevents integer scaling factor from exceeding screen bounds.\n\n" + "Enabled: Will clamp the scaling factor and display a gentle warning in the resolution editor.\n" + "Disabled: Will allow scaling to exceed screen bounds, for users who want to crop overscan.\n\n" + " " ICON_FA_INFO_CIRCLE + " Please note that exceeding screen bounds may show a scroll bar on-screen."); - // Integer Scaling - Exceed Bounds By 1x/Offset. - // A popular feature in some retro frontends/upscalers, sometimes called "crop overscan" or "1080p 5x". - /* - UIWidgets::PaddedEnhancementCheckbox("Allow integer scale factor to go +1 above maximum screen bounds.", CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.ExceedBoundsBy", false, false, !CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", 0) || disabled_everything, "", UIWidgets::CheckboxGraphics::Cross, false); - */ - // It does actually function as expected, but exceeding the bottom of the screen shows a scroll bar. - // I've ended up commenting this one out because of the scroll bar, and for simplicity. - - // Display an info message about the scroll bar. - if (!CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.NeverExceedBounds", 1) || - CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.ExceedBoundsBy", 0)) { - if (disabled_neverExceedBounds) { // Dim this help text accordingly - UIWidgets::DisableComponent(ImGui::GetStyle().Alpha * 0.5f); - } - ImGui::TextColored(messageColor[MESSAGE_INFO], - " " ICON_FA_INFO_CIRCLE - " A scroll bar may become visible if screen bounds are exceeded."); - if (disabled_neverExceedBounds) { // Dim this help text accordingly - UIWidgets::ReEnableComponent("disabledTooltipText"); - } + // Initialise the (currently unused) "Exceed Bounds By" cvar if it's been changed. + if (checkbox_neverExceedBounds && + CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.ExceedBoundsBy", 0)) { + CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.ExceedBoundsBy", 0); + CVarSave(); + } + + // Integer Scaling - Exceed Bounds By 1x/Offset. + // A popular feature in some retro frontends/upscalers, sometimes called "crop overscan" or "1080p 5x". + /* + UIWidgets::PaddedEnhancementCheckbox("Allow integer scale factor to go +1 above maximum screen bounds.", CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.ExceedBoundsBy", false, false, !CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", 0) || disabled_everything, "", UIWidgets::CheckboxGraphics::Cross, false); + */ + // It does actually function as expected, but exceeding the bottom of the screen shows a scroll bar. + // I've ended up commenting this one out because of the scroll bar, and for simplicity. + + // Display an info message about the scroll bar. + if (!CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.NeverExceedBounds", 1) || + CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.ExceedBoundsBy", 0)) { + if (disabled_neverExceedBounds) { // Dim this help text accordingly + UIWidgets::DisableComponent(ImGui::GetStyle().Alpha * 0.5f); + } + ImGui::TextColored(messageColor[MESSAGE_INFO], + " " ICON_FA_INFO_CIRCLE + " A scroll bar may become visible if screen bounds are exceeded."); + if (disabled_neverExceedBounds) { // Dim this help text accordingly + UIWidgets::ReEnableComponent("disabledTooltipText"); + } - // Another support helper button, to disable the unused "Exceed Bounds By" cvar. - // (Remove this button if uncommenting the checkbox.) - if (CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.ExceedBoundsBy", 0)) { - if (ImGui::Button("Click to reset a console variable that may be causing this.")) { - CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.ExceedBoundsBy", 0); - CVarSave(); - } + // Another support helper button, to disable the unused "Exceed Bounds By" cvar. + // (Remove this button if uncommenting the checkbox.) + if (CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.ExceedBoundsBy", 0)) { + if (ImGui::Button("Click to reset a console variable that may be causing this.")) { + CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.ExceedBoundsBy", 0); + CVarSave(); } - } else { - ImGui::Text(" "); } - // UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); - } // End of Integer Scaling additional settings. + } else { + ImGui::Text(" "); + } + // UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); + } // End of Integer Scaling additional settings. - } // End of additional settings + } // End of additional settings - // Clamp and update the cvars that don't use UIWidgets - if (update[UPDATE_aspectRatioX] || update[UPDATE_aspectRatioY] || update[UPDATE_verticalPixelCount]) { - if (update[UPDATE_aspectRatioX]) { - if (aspectRatioX < 0.0f) { - aspectRatioX = 0.0f; - } - CVarSetFloat(CVAR_PREFIX_ADVANCED_RESOLUTION ".AspectRatioX", aspectRatioX); + // Clamp and update the cvars that don't use UIWidgets + if (update[UPDATE_aspectRatioX] || update[UPDATE_aspectRatioY] || update[UPDATE_verticalPixelCount]) { + if (update[UPDATE_aspectRatioX]) { + if (aspectRatioX < 0.0f) { + aspectRatioX = 0.0f; } - if (update[UPDATE_aspectRatioY]) { - if (aspectRatioY < 0.0f) { - aspectRatioY = 0.0f; - } - CVarSetFloat(CVAR_PREFIX_ADVANCED_RESOLUTION ".AspectRatioY", aspectRatioY); + CVarSetFloat(CVAR_PREFIX_ADVANCED_RESOLUTION ".AspectRatioX", aspectRatioX); + } + if (update[UPDATE_aspectRatioY]) { + if (aspectRatioY < 0.0f) { + aspectRatioY = 0.0f; } - if (update[UPDATE_verticalPixelCount]) { - // There's a upper and lower clamp on the Libultraship side too, - // so clamping it here is entirely visual, so the vertical resolution field reflects it. - if (verticalPixelCount < minVerticalPixelCount) { - verticalPixelCount = minVerticalPixelCount; - } - if (verticalPixelCount > maxVerticalPixelCount) { - verticalPixelCount = maxVerticalPixelCount; - } - CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".VerticalPixelCount", verticalPixelCount); + CVarSetFloat(CVAR_PREFIX_ADVANCED_RESOLUTION ".AspectRatioY", aspectRatioY); + } + if (update[UPDATE_verticalPixelCount]) { + // There's a upper and lower clamp on the Libultraship side too, + // so clamping it here is entirely visual, so the vertical resolution field reflects it. + if (verticalPixelCount < minVerticalPixelCount) { + verticalPixelCount = minVerticalPixelCount; } - CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".UIComboItem.AspectRatio", item_aspectRatio); - CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".UIComboItem.PixelCount", item_pixelCount); - CVarSave(); + if (verticalPixelCount > maxVerticalPixelCount) { + verticalPixelCount = maxVerticalPixelCount; + } + CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".VerticalPixelCount", verticalPixelCount); } + CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".UIComboItem.AspectRatio", item_aspectRatio); + CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".UIComboItem.PixelCount", item_pixelCount); + CVarSave(); } - ImGui::End(); } void AdvancedResolutionSettingsWindow::UpdateElement() { diff --git a/soh/soh/SohGui.cpp b/soh/soh/SohGui.cpp index 71a3660217f..df475447d44 100644 --- a/soh/soh/SohGui.cpp +++ b/soh/soh/SohGui.cpp @@ -164,41 +164,41 @@ namespace SohGui { SPDLOG_ERROR("Could not find input editor window"); } - mAudioEditorWindow = std::make_shared(CVAR_WINDOW("AudioEditor"), "Audio Editor"); + mAudioEditorWindow = std::make_shared(CVAR_WINDOW("AudioEditor"), "Audio Editor", ImVec2(820, 630)); gui->AddGuiWindow(mAudioEditorWindow); mInputViewer = std::make_shared(CVAR_WINDOW("InputViewer"), "Input Viewer"); gui->AddGuiWindow(mInputViewer); - mInputViewerSettings = std::make_shared(CVAR_WINDOW("InputViewerSettings"), "Input Viewer Settings"); + mInputViewerSettings = std::make_shared(CVAR_WINDOW("InputViewerSettings"), "Input Viewer Settings", ImVec2(500, 525)); gui->AddGuiWindow(mInputViewerSettings); - mCosmeticsEditorWindow = std::make_shared(CVAR_WINDOW("CosmeticsEditor"), "Cosmetics Editor"); + mCosmeticsEditorWindow = std::make_shared(CVAR_WINDOW("CosmeticsEditor"), "Cosmetics Editor", ImVec2(550, 520)); gui->AddGuiWindow(mCosmeticsEditorWindow); - mActorViewerWindow = std::make_shared(CVAR_WINDOW("ActorViewer"), "Actor Viewer"); + mActorViewerWindow = std::make_shared(CVAR_WINDOW("ActorViewer"), "Actor Viewer", ImVec2(520, 600)); gui->AddGuiWindow(mActorViewerWindow); - mColViewerWindow = std::make_shared(CVAR_WINDOW("CollisionViewer"), "Collision Viewer"); + mColViewerWindow = std::make_shared(CVAR_WINDOW("CollisionViewer"), "Collision Viewer", ImVec2(520, 600)); gui->AddGuiWindow(mColViewerWindow); - mSaveEditorWindow = std::make_shared(CVAR_WINDOW("SaveEditor"), "Save Editor"); + mSaveEditorWindow = std::make_shared(CVAR_WINDOW("SaveEditor"), "Save Editor", ImVec2(520, 600)); gui->AddGuiWindow(mSaveEditorWindow); - mDLViewerWindow = std::make_shared(CVAR_WINDOW("DLViewer"), "Display List Viewer"); + mDLViewerWindow = std::make_shared(CVAR_WINDOW("DLViewer"), "Display List Viewer", ImVec2(520, 600)); gui->AddGuiWindow(mDLViewerWindow); - mValueViewerWindow = std::make_shared(CVAR_WINDOW("ValueViewer"), "Value Viewer"); + mValueViewerWindow = std::make_shared(CVAR_WINDOW("ValueViewer"), "Value Viewer", ImVec2(520, 600)); gui->AddGuiWindow(mValueViewerWindow); - mMessageViewerWindow = std::make_shared(CVAR_WINDOW("MessageViewer"), "Message Viewer"); + mMessageViewerWindow = std::make_shared(CVAR_WINDOW("MessageViewer"), "Message Viewer", ImVec2(520, 600)); gui->AddGuiWindow(mMessageViewerWindow); - mGameplayStatsWindow = std::make_shared(CVAR_WINDOW("GameplayStats"), "Gameplay Stats"); + mGameplayStatsWindow = std::make_shared(CVAR_WINDOW("GameplayStats"), "Gameplay Stats", ImVec2(480, 550)); gui->AddGuiWindow(mGameplayStatsWindow); mCheckTrackerWindow = std::make_shared(CVAR_WINDOW("CheckTracker"), "Check Tracker"); gui->AddGuiWindow(mCheckTrackerWindow); - mCheckTrackerSettingsWindow = std::make_shared(CVAR_WINDOW("CheckTrackerSettings"), "Check Tracker Settings"); + mCheckTrackerSettingsWindow = std::make_shared(CVAR_WINDOW("CheckTrackerSettings"), "Check Tracker Settings", ImVec2(600, 375)); gui->AddGuiWindow(mCheckTrackerSettingsWindow); mEntranceTrackerWindow = std::make_shared(CVAR_WINDOW("EntranceTracker"),"Entrance Tracker"); gui->AddGuiWindow(mEntranceTrackerWindow); mItemTrackerWindow = std::make_shared(CVAR_WINDOW("ItemTracker"), "Item Tracker"); gui->AddGuiWindow(mItemTrackerWindow); - mItemTrackerSettingsWindow = std::make_shared(CVAR_WINDOW("ItemTrackerSettings"), "Item Tracker Settings"); + mItemTrackerSettingsWindow = std::make_shared(CVAR_WINDOW("ItemTrackerSettings"), "Item Tracker Settings", ImVec2(733, 472)); gui->AddGuiWindow(mItemTrackerSettingsWindow); - mRandomizerSettingsWindow = std::make_shared(CVAR_WINDOW("RandomizerSettings"), "Randomizer Settings"); + mRandomizerSettingsWindow = std::make_shared(CVAR_WINDOW("RandomizerSettings"), "Randomizer Settings", ImVec2(920, 600)); gui->AddGuiWindow(mRandomizerSettingsWindow); - mAdvancedResolutionSettingsWindow = std::make_shared(CVAR_WINDOW("AdvancedResolutionEditor"), "Advanced Resolution Settings"); + mAdvancedResolutionSettingsWindow = std::make_shared(CVAR_WINDOW("AdvancedResolutionEditor"), "Advanced Resolution Settings", ImVec2(497, 599)); gui->AddGuiWindow(mAdvancedResolutionSettingsWindow); mModalWindow = std::make_shared(CVAR_WINDOW("ModalWindow"), "Modal Window"); gui->AddGuiWindow(mModalWindow); diff --git a/soh/soh/SohModals.cpp b/soh/soh/SohModals.cpp index 44dc93d743e..b77a5f47fc9 100644 --- a/soh/soh/SohModals.cpp +++ b/soh/soh/SohModals.cpp @@ -19,6 +19,15 @@ struct SohModal { }; std::vector modals; +void SohModalWindow::Draw() { + if (!IsVisible()) { + return; + } + DrawElement(); + // Sync up the IsVisible flag if it was changed by ImGui + SyncVisibilityConsoleVariable(); +} + void SohModalWindow::DrawElement() { if (modals.size() > 0) { SohModal curModal = modals.at(0); diff --git a/soh/soh/SohModals.h b/soh/soh/SohModals.h index b64e180b688..f584b954019 100644 --- a/soh/soh/SohModals.h +++ b/soh/soh/SohModals.h @@ -7,6 +7,7 @@ class SohModalWindow : public Ship::GuiWindow { public: using GuiWindow::GuiWindow; + void Draw() override; void InitElement() override {}; void DrawElement() override; From 7f503c33d22738c8781e5efbb8170ea4d6b2d83e Mon Sep 17 00:00:00 2001 From: Malkierian Date: Sat, 14 Sep 2024 19:38:22 -0700 Subject: [PATCH 58/59] Concurrency Fix (#4318) * Removed all CVarLoad uses from code to prevent thread concurrency issues. * Add mutext locks to save and load functions to prevent concurrent operations between those two. --- soh/soh/Enhancements/debugconsole.cpp | 3 +-- soh/soh/Enhancements/randomizer/3drando/rando_main.cpp | 3 +-- soh/soh/Enhancements/randomizer/randomizer.cpp | 3 +-- soh/soh/SaveManager.cpp | 5 +++++ soh/soh/SaveManager.h | 1 + 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/soh/soh/Enhancements/debugconsole.cpp b/soh/soh/Enhancements/debugconsole.cpp index ad51f1e4b01..f1f3ac76b0e 100644 --- a/soh/soh/Enhancements/debugconsole.cpp +++ b/soh/soh/Enhancements/debugconsole.cpp @@ -1590,6 +1590,5 @@ void DebugConsole_Init(void) { {"group_name", Ship::ArgumentType::TEXT, true}, }}); - CVarSave(); - CVarLoad(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } diff --git a/soh/soh/Enhancements/randomizer/3drando/rando_main.cpp b/soh/soh/Enhancements/randomizer/3drando/rando_main.cpp index 6f342535b00..9705d9a1430 100644 --- a/soh/soh/Enhancements/randomizer/3drando/rando_main.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/rando_main.cpp @@ -22,8 +22,7 @@ void RandoMain::GenerateRando(std::unordered_map cvarS std::string fileName = Ship::Context::GetPathRelativeToAppDirectory(GenerateRandomizer(cvarSettings, excludedLocations, enabledTricks, seedString).c_str()); CVarSetString(CVAR_GENERAL("SpoilerLog"), fileName.c_str()); - CVarSave(); - CVarLoad(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); CVarSetInteger(CVAR_GENERAL("NewSeedGenerated"), 1); } diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index 487348c9db7..d2a6c5029bf 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -3053,8 +3053,7 @@ void GenerateRandomizerImgui(std::string seed = "") { RandoMain::GenerateRando(cvarSettings, excludedLocations, enabledTricks, seed); CVarSetInteger(CVAR_GENERAL("RandoGenerating"), 0); - CVarSave(); - CVarLoad(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); generated = 1; } diff --git a/soh/soh/SaveManager.cpp b/soh/soh/SaveManager.cpp index b6fd0cb07c2..a1ea20b8a30 100644 --- a/soh/soh/SaveManager.cpp +++ b/soh/soh/SaveManager.cpp @@ -17,6 +17,7 @@ #include #include #include +#include extern "C" SaveContext gSaveContext; using namespace std::string_literals; @@ -909,6 +910,7 @@ int copy_file(const char* src, const char* dst) { // Threaded SaveFile takes copy of gSaveContext for local unmodified storage void SaveManager::SaveFileThreaded(int fileNum, SaveContext* saveContext, int sectionID) { + saveMtx.lock(); SPDLOG_INFO("Save File - fileNum: {}", fileNum); // Needed for first time save, hasn't changed in forever anyway saveBlock["version"] = 1; @@ -983,6 +985,7 @@ void SaveManager::SaveFileThreaded(int fileNum, SaveContext* saveContext, int se InitMeta(fileNum); GameInteractor::Instance->ExecuteHooks(fileNum); SPDLOG_INFO("Save File Finish - fileNum: {}", fileNum); + saveMtx.unlock(); } // SaveSection creates a copy of gSaveContext to prevent mid-save data modification, and passes its reference to SaveFileThreaded @@ -1025,6 +1028,7 @@ void SaveManager::SaveGlobal() { } void SaveManager::LoadFile(int fileNum) { + saveMtx.lock(); SPDLOG_INFO("Load File - fileNum: {}", fileNum); std::filesystem::path fileName = GetFileName(fileNum); assert(std::filesystem::exists(fileName)); @@ -1087,6 +1091,7 @@ void SaveManager::LoadFile(int fileNum) { SohGui::RegisterPopup("Error loading save file", "A problem occurred loading the save in slot " + std::to_string(fileNum + 1) + ".\nSave file corruption is suspected.\n" + "The file has been renamed to prevent further issues."); } + saveMtx.unlock(); } void SaveManager::ThreadPoolWait() { diff --git a/soh/soh/SaveManager.h b/soh/soh/SaveManager.h index 817fc6fbfb2..df54992778d 100644 --- a/soh/soh/SaveManager.h +++ b/soh/soh/SaveManager.h @@ -184,6 +184,7 @@ class SaveManager { nlohmann::json* currentJsonContext = nullptr; nlohmann::json::iterator currentJsonArrayContext; std::shared_ptr smThreadPool; + std::mutex saveMtx; }; #else From 19dc4dc0faa4a04b2d986e17b3e6dd2a79059baf Mon Sep 17 00:00:00 2001 From: Archez Date: Sat, 14 Sep 2024 23:13:46 -0400 Subject: [PATCH 59/59] Bump LUS (#4341) --- libultraship | 2 +- soh/soh/OTRGlobals.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libultraship b/libultraship index 92bce011545..0302eab051a 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit 92bce01154589080e534c3c143913a196e161f02 +Subproject commit 0302eab051a7e0e5a8dc208aca5b00899a91808c diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 6e41eb7a8a8..6ab2f658aa7 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -338,7 +338,7 @@ OTRGlobals::OTRGlobals() { overlay->LoadFont("Fipps", "fonts/Fipps-Regular.otf", 32.0f); overlay->SetCurrentFont(CVarGetString(CVAR_GAME_OVERLAY_FONT, "Press Start 2P")); - context->InitAudio(); + context->InitAudio({ .SampleRate = 44100, .SampleLength = 1024, .DesiredBuffered = 2480 }); SPDLOG_INFO("Starting Ship of Harkinian version {} (Branch: {} | Commit: {})", (char*)gBuildVersion, (char*)gGitBranch, (char*)gGitCommitHash);