From e9ba8f734f0fb8652e67c6ec7e6f8edd69745c72 Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Wed, 13 Jul 2022 20:35:42 -0400 Subject: [PATCH 01/71] Early version of custom messages. --- soh/soh/Enhancements/randomizer/randomizer.cpp | 11 +++++++++++ soh/soh/Enhancements/randomizer/randomizer.h | 1 + soh/soh/OTRGlobals.cpp | 5 +++++ soh/soh/OTRGlobals.h | 1 + soh/src/code/z_message_PAL.c | 3 +++ 5 files changed, 21 insertions(+) diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index 43e278ab5..50f90ee5e 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -2419,6 +2419,17 @@ GetItemID Randomizer::GetRandomizedItemIdFromKnownCheck(RandomizerCheck randomiz return GetItemFromGet(this->itemLocations[randomizerCheck], ogId); } +std::string Randomizer::GetCustomGetItemMessage(GetItemID giid) { + if (!gSaveContext.n64ddFlag) { + return "Not Randomized."; + } + + switch (giid) { + default: + "There is no custom message for this item."; + } +} + RandomizerCheck Randomizer::GetCheckFromActor(s16 sceneNum, s16 actorId, s16 actorParams) { if (!gSaveContext.n64ddFlag) { return RC_UNKNOWN_CHECK; diff --git a/soh/soh/Enhancements/randomizer/randomizer.h b/soh/soh/Enhancements/randomizer/randomizer.h index 5fe2e0ae4..5d67c8692 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.h +++ b/soh/soh/Enhancements/randomizer/randomizer.h @@ -42,6 +42,7 @@ class Randomizer { std::string GetHintFromCheck(RandomizerCheck check); GetItemID GetRandomizedItemIdFromKnownCheck(RandomizerCheck randomizerCheck, GetItemID ogId); GetItemID GetRandomizedItemId(GetItemID ogId, s16 actorId, s16 actorParams, s16 sceneNum); + std::string GetCustomGetItemMessage(GetItemID giid); }; #ifdef __cplusplus diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 3a862d58a..265909e5c 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -1528,3 +1528,8 @@ extern "C" s32 GetRandomizedItemId(GetItemID ogId, s16 actorId, s16 actorParams, extern "C" s32 GetRandomizedItemIdFromKnownCheck(RandomizerCheck randomizerCheck, GetItemID ogId) { return OTRGlobals::Instance->gRandomizer->GetRandomizedItemIdFromKnownCheck(randomizerCheck, ogId); } + +extern "C" int Randomizer_GetCustomGetItemMessage(GetItemID giid, char* buffer, const int maxBufferSize) { + const std::string& getItemText = OTRGlobals::Instance->gRandomizer->GetCustomGetItemMessage(giid); + return CopyStringToCharBuffer(getItemText, buffer, maxBufferSize); +} diff --git a/soh/soh/OTRGlobals.h b/soh/soh/OTRGlobals.h index 7c56e54c1..bf0384be1 100644 --- a/soh/soh/OTRGlobals.h +++ b/soh/soh/OTRGlobals.h @@ -99,6 +99,7 @@ s16 GetItemModelFromId(s16 itemId); s32 GetItemIDFromGetItemID(s32 getItemId); s32 GetRandomizedItemId(GetItemID ogId, s16 actorId, s16 actorParams, s16 sceneNum); s32 GetRandomizedItemIdFromKnownCheck(RandomizerCheck randomizerCheck, GetItemID ogId); +int Randomizer_GetCustomGetItemMessage(GetItemID giid, char* buffer, const int maxBufferSize); #endif #endif diff --git a/soh/src/code/z_message_PAL.c b/soh/src/code/z_message_PAL.c index 9cf592e4f..46b8b7e94 100644 --- a/soh/src/code/z_message_PAL.c +++ b/soh/src/code/z_message_PAL.c @@ -1735,6 +1735,9 @@ void Message_OpenText(GlobalContext* globalCtx, u16 textId) { } else { msgCtx->msgLength = font->msgLength = CopyGanonHintText(font->msgBuf, sizeof(font->msgBuf)); } + } else if (gSaveContext.n64ddFlag && textId == 0xF8) { + msgCtx->msgLength = font->msgLength = Randomizer_GetCustomGetItemMessage( + GET_PLAYER(globalCtx)->getItemId, font->msgBuf, sizeof(font->msgBuf)); } else { msgCtx->msgLength = font->msgLength; char* src = (uintptr_t)font->msgOffset; From 14a87f83b3f93051fec0b2d7009f61bd5b4c736a Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Wed, 13 Jul 2022 21:24:20 -0400 Subject: [PATCH 02/71] Makes sure custom get item textboxes match. Specifically, they are all bottom of the screen and blue. --- soh/src/code/z_message_PAL.c | 1 + 1 file changed, 1 insertion(+) diff --git a/soh/src/code/z_message_PAL.c b/soh/src/code/z_message_PAL.c index 46b8b7e94..87bc255ab 100644 --- a/soh/src/code/z_message_PAL.c +++ b/soh/src/code/z_message_PAL.c @@ -1738,6 +1738,7 @@ void Message_OpenText(GlobalContext* globalCtx, u16 textId) { } else if (gSaveContext.n64ddFlag && textId == 0xF8) { msgCtx->msgLength = font->msgLength = Randomizer_GetCustomGetItemMessage( GET_PLAYER(globalCtx)->getItemId, font->msgBuf, sizeof(font->msgBuf)); + font->charTexBuf[0] = 0x23; } else { msgCtx->msgLength = font->msgLength; char* src = (uintptr_t)font->msgOffset; From d9277530a2d0fb2308bd00a617efbf728b6bfa70 Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Wed, 13 Jul 2022 23:35:45 -0400 Subject: [PATCH 03/71] Refactors custom message code to its own file --- .../randomizer/custom_messages.cpp | 39 +++++++++++++++++++ .../Enhancements/randomizer/custom_messages.h | 19 +++++++++ .../Enhancements/randomizer/randomizer.cpp | 11 ------ 3 files changed, 58 insertions(+), 11 deletions(-) create mode 100644 soh/soh/Enhancements/randomizer/custom_messages.cpp create mode 100644 soh/soh/Enhancements/randomizer/custom_messages.h diff --git a/soh/soh/Enhancements/randomizer/custom_messages.cpp b/soh/soh/Enhancements/randomizer/custom_messages.cpp new file mode 100644 index 000000000..389ae0e9e --- /dev/null +++ b/soh/soh/Enhancements/randomizer/custom_messages.cpp @@ -0,0 +1,39 @@ +#include "custom_messages.h" +#include + +using namespace std::literals::string_literals; + +std::string Randomizer::GetCustomGetItemMessage(GetItemID giid) { + if (!gSaveContext.n64ddFlag) { + return "Not Randomized."; + } + + switch (giid) { + default: + switch (gSaveContext.language) { + case LANGUAGE_FRA: + return "Il n'y a pas de message personnalis pour cet lment."; + case LANGUAGE_GER: + return "Fr diesen Artikel gibt es keine benutzerdefinierte Nachricht."; + case LANGUAGE_ENG: + default: + return "There is no custom message for this item."; + } + } +} + +std::string MESSAGE_END() { + return "\x02"s; +} + +std::string ITEM_OBTAINED(uint8_t x) { + return "\x08\x13"s + char(x); +} + +std::string NEWLINE() { + return "\x02"s; +} + +std::string COLOR(uint8_t x) { + return "\x05"s + char(x); +} \ No newline at end of file diff --git a/soh/soh/Enhancements/randomizer/custom_messages.h b/soh/soh/Enhancements/randomizer/custom_messages.h new file mode 100644 index 000000000..5e208f7e7 --- /dev/null +++ b/soh/soh/Enhancements/randomizer/custom_messages.h @@ -0,0 +1,19 @@ +#pragma once + +#include +#include "../../../include/z64item.h" +#include "randomizer.h" + +#define QM_WHITE 0x00 +#define QM_RED 0x41 +#define QM_GREEN 0x42 +#define QM_BLUE 0x43 +#define QM_LBLUE 0x44 +#define QM_PINK 0x45 +#define QM_YELLOW 0x46 +#define QM_BLACK 0x47 + +std::string MESSAGE_END(); +std::string ITEM_OBTAINED(uint8_t x); +std::string NEWLINE(); +std::string COLOR(uint8_t x); \ No newline at end of file diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index 50f90ee5e..43e278ab5 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -2419,17 +2419,6 @@ GetItemID Randomizer::GetRandomizedItemIdFromKnownCheck(RandomizerCheck randomiz return GetItemFromGet(this->itemLocations[randomizerCheck], ogId); } -std::string Randomizer::GetCustomGetItemMessage(GetItemID giid) { - if (!gSaveContext.n64ddFlag) { - return "Not Randomized."; - } - - switch (giid) { - default: - "There is no custom message for this item."; - } -} - RandomizerCheck Randomizer::GetCheckFromActor(s16 sceneNum, s16 actorId, s16 actorParams) { if (!gSaveContext.n64ddFlag) { return RC_UNKNOWN_CHECK; From a81ecfcfcca19841ea033d9c02788dc574b334ce Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Thu, 14 Jul 2022 00:41:04 -0400 Subject: [PATCH 04/71] Renames the separated custom messages files to prevent conflict. --- soh/soh.vcxproj | 2 ++ .../{custom_messages.cpp => randomizer_custom_messages.cpp} | 2 +- .../{custom_messages.h => randomizer_custom_messages.h} | 0 3 files changed, 3 insertions(+), 1 deletion(-) rename soh/soh/Enhancements/randomizer/{custom_messages.cpp => randomizer_custom_messages.cpp} (95%) rename soh/soh/Enhancements/randomizer/{custom_messages.h => randomizer_custom_messages.h} (100%) diff --git a/soh/soh.vcxproj b/soh/soh.vcxproj index 5f7ea818f..22c44a1b8 100644 --- a/soh/soh.vcxproj +++ b/soh/soh.vcxproj @@ -235,6 +235,7 @@ + @@ -983,6 +984,7 @@ + diff --git a/soh/soh/Enhancements/randomizer/custom_messages.cpp b/soh/soh/Enhancements/randomizer/randomizer_custom_messages.cpp similarity index 95% rename from soh/soh/Enhancements/randomizer/custom_messages.cpp rename to soh/soh/Enhancements/randomizer/randomizer_custom_messages.cpp index 389ae0e9e..b5caad7fc 100644 --- a/soh/soh/Enhancements/randomizer/custom_messages.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_custom_messages.cpp @@ -1,4 +1,4 @@ -#include "custom_messages.h" +#include "randomizer_custom_messages.h" #include using namespace std::literals::string_literals; diff --git a/soh/soh/Enhancements/randomizer/custom_messages.h b/soh/soh/Enhancements/randomizer/randomizer_custom_messages.h similarity index 100% rename from soh/soh/Enhancements/randomizer/custom_messages.h rename to soh/soh/Enhancements/randomizer/randomizer_custom_messages.h From cd096ce5e977f3e0098ec8b3740a6cddf4df3a47 Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Thu, 14 Jul 2022 00:56:47 -0400 Subject: [PATCH 05/71] Fixes newline function to return correct character. --- soh/soh/Enhancements/randomizer/randomizer_custom_messages.cpp | 3 ++- soh/soh/Enhancements/randomizer/randomizer_custom_messages.h | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/soh/soh/Enhancements/randomizer/randomizer_custom_messages.cpp b/soh/soh/Enhancements/randomizer/randomizer_custom_messages.cpp index b5caad7fc..b52721cff 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_custom_messages.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_custom_messages.cpp @@ -1,4 +1,5 @@ #include "randomizer_custom_messages.h" +#include "randomizer.h" #include using namespace std::literals::string_literals; @@ -31,7 +32,7 @@ std::string ITEM_OBTAINED(uint8_t x) { } std::string NEWLINE() { - return "\x02"s; + return "\x01"s; } std::string COLOR(uint8_t x) { diff --git a/soh/soh/Enhancements/randomizer/randomizer_custom_messages.h b/soh/soh/Enhancements/randomizer/randomizer_custom_messages.h index 5e208f7e7..15cd859af 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_custom_messages.h +++ b/soh/soh/Enhancements/randomizer/randomizer_custom_messages.h @@ -2,7 +2,6 @@ #include #include "../../../include/z64item.h" -#include "randomizer.h" #define QM_WHITE 0x00 #define QM_RED 0x41 From 46df17e29fbf2e18b92493ff0dc84d9a6ce16c84 Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Thu, 14 Jul 2022 11:17:43 -0400 Subject: [PATCH 06/71] Added an extra helper function and removed instant text control code from ITEM_OBTAINED --- .../Enhancements/randomizer/randomizer_custom_messages.cpp | 6 +++++- .../Enhancements/randomizer/randomizer_custom_messages.h | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/soh/soh/Enhancements/randomizer/randomizer_custom_messages.cpp b/soh/soh/Enhancements/randomizer/randomizer_custom_messages.cpp index b52721cff..a70461135 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_custom_messages.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_custom_messages.cpp @@ -28,7 +28,7 @@ std::string MESSAGE_END() { } std::string ITEM_OBTAINED(uint8_t x) { - return "\x08\x13"s + char(x); + return "\x13"s + char(x); } std::string NEWLINE() { @@ -37,4 +37,8 @@ std::string NEWLINE() { std::string COLOR(uint8_t x) { return "\x05"s + char(x); +} + +std::string WAIT_FOR_INPUT() { + return "\x04"s; } \ No newline at end of file diff --git a/soh/soh/Enhancements/randomizer/randomizer_custom_messages.h b/soh/soh/Enhancements/randomizer/randomizer_custom_messages.h index 15cd859af..cae3c65b5 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_custom_messages.h +++ b/soh/soh/Enhancements/randomizer/randomizer_custom_messages.h @@ -15,4 +15,5 @@ std::string MESSAGE_END(); std::string ITEM_OBTAINED(uint8_t x); std::string NEWLINE(); -std::string COLOR(uint8_t x); \ No newline at end of file +std::string COLOR(uint8_t x); +std::string WAIT_FOR_INPUT(); \ No newline at end of file From 3f2111a3e61169f95248a7e549f0e7466f429d91 Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Fri, 15 Jul 2022 19:48:49 -0400 Subject: [PATCH 07/71] Adds text for Bottle with Blue Fire as a demo. --- .../randomizer/randomizer_custom_messages.cpp | 10 ++++++++++ soh/src/overlays/actors/ovl_player_actor/z_player.c | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/soh/soh/Enhancements/randomizer/randomizer_custom_messages.cpp b/soh/soh/Enhancements/randomizer/randomizer_custom_messages.cpp index a70461135..659e68fe8 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_custom_messages.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_custom_messages.cpp @@ -10,6 +10,16 @@ std::string Randomizer::GetCustomGetItemMessage(GetItemID giid) { } switch (giid) { + case GI_BOTTLE_WITH_BLUE_FIRE: + switch (gSaveContext.language) { + case LANGUAGE_FRA: + case LANGUAGE_GER: + case LANGUAGE_ENG: + default: + return ITEM_OBTAINED(ITEM_BLUE_FIRE) + "You got a " + COLOR(QM_RED) + "Bottle with Blue " + + NEWLINE() + "Fire" + COLOR(QM_WHITE) + "! Use it to melt Red Ice!" + + MESSAGE_END(); + } default: switch (gSaveContext.language) { case LANGUAGE_FRA: 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 1973a09a4..c27b78ee8 100644 --- a/soh/src/overlays/actors/ovl_player_actor/z_player.c +++ b/soh/src/overlays/actors/ovl_player_actor/z_player.c @@ -657,7 +657,7 @@ static GetItemEntry sGetItemTable[] = { GET_ITEM(ITEM_BOTTLE_WITH_BLUE_POTION, OBJECT_GI_LIQUID, GID_POTION_BLUE, 0x45, 0x80, CHEST_ANIM_LONG), GET_ITEM(ITEM_BOTTLE_WITH_FAIRY, OBJECT_GI_BOTTLE, GID_BOTTLE, 0x46, 0x80, CHEST_ANIM_LONG), GET_ITEM(ITEM_BOTTLE_WITH_FISH, OBJECT_GI_FISH, GID_FISH, 0x47, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_BOTTLE_WITH_BLUE_FIRE, OBJECT_GI_FIRE, GID_BLUE_FIRE, 0x5D, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_BOTTLE_WITH_BLUE_FIRE, OBJECT_GI_FIRE, GID_BLUE_FIRE, 0xF8, 0x80, CHEST_ANIM_LONG), GET_ITEM(ITEM_BOTTLE_WITH_BUGS, OBJECT_GI_INSECT, GID_BUG, 0x7A, 0x80, CHEST_ANIM_LONG), GET_ITEM(ITEM_BOTTLE_WITH_POE, OBJECT_GI_GHOST, GID_POE, 0x97, 0x80, CHEST_ANIM_LONG), GET_ITEM(ITEM_BOTTLE_WITH_BIG_POE, OBJECT_GI_GHOST, GID_BIG_POE, 0xF9, 0x80, CHEST_ANIM_LONG), From 4eaf70b85901c10e9f3728ea17195d72c3fb21cd Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Sun, 17 Jul 2022 12:34:56 -0400 Subject: [PATCH 08/71] Refactors CustomMessages to not be rando specific. Pulls the Custom Message related code out into it's own class, which has an initialization phase where other enhancements / future features can create messages during an initialization phase to be stored and retrieved later. Along with this refactoring, the 4 bottle messages from the previous rando-specific system are now created and stored during intialization and retrieved by their getItemId. Now that it isn't rando specific, the goal is to move anything text changes that are hard-coded into z_message_PAL.c and refactor it so that future text additions/overrides can be done without modifying that file. --- soh/soh.vcxproj | 4 +- .../custom_message/CustomMessage.cpp | 108 ++++++++++++++++++ .../custom_message/CustomMessage.h | 39 +++++++ .../Enhancements/randomizer/randomizer.cpp | 1 + soh/soh/Enhancements/randomizer/randomizer.h | 2 + .../randomizer/randomizer_custom_messages.cpp | 67 ++++------- .../randomizer/randomizer_custom_messages.h | 19 --- soh/soh/OTRGlobals.cpp | 3 + soh/soh/OTRGlobals.h | 1 - .../actors/ovl_player_actor/z_player.c | 8 +- 10 files changed, 182 insertions(+), 70 deletions(-) create mode 100644 soh/soh/Enhancements/custom_message/CustomMessage.cpp create mode 100644 soh/soh/Enhancements/custom_message/CustomMessage.h delete mode 100644 soh/soh/Enhancements/randomizer/randomizer_custom_messages.h diff --git a/soh/soh.vcxproj b/soh/soh.vcxproj index 037539b2a..43054c711 100644 --- a/soh/soh.vcxproj +++ b/soh/soh.vcxproj @@ -179,6 +179,7 @@ + @@ -942,9 +943,9 @@ - + @@ -985,7 +986,6 @@ - diff --git a/soh/soh/Enhancements/custom_message/CustomMessage.cpp b/soh/soh/Enhancements/custom_message/CustomMessage.cpp new file mode 100644 index 000000000..1985a2bbc --- /dev/null +++ b/soh/soh/Enhancements/custom_message/CustomMessage.cpp @@ -0,0 +1,108 @@ +#include "CustomMessage.h" +#include + +using namespace std::literals::string_literals; + +CustomMessage::CustomMessage() { + this->textBoxSpecialCharacters = { { "", 0x80 }, { "", 0x81 }, { "", 0x82 }, { "", 0x83 }, { "", 0x84 }, + { "", 0x85 }, { "", 0x86 }, { "", 0x87 }, { "", 0x88 }, { "", 0x89 }, + { "", 0x8A }, { "", 0x8B }, { "", 0x8C }, { "", 0x8D }, { "", 0x8E }, + { "", 0x8F }, { "", 0x90 }, { "", 0x91 }, { "", 0x92 }, { "", 0x93 }, + { "", 0x94 }, { "", 0x95 }, { "", 0x96 }, { "", 0x97 }, { "", 0x98 }, + { "", 0x99 }, { "", 0x9A }, { "", 0x9B }, { "", 0x9C }, { "", 0x9D }, + { "", 0x9E } }; + this->colors = { { "w", QM_WHITE }, { "r", QM_RED }, { "g", QM_GREEN }, { "b", QM_BLUE }, + { "c", QM_LBLUE }, { "p", QM_PINK }, { "y", QM_YELLOW }, { "B", QM_BLACK } }; +} + +CustomMessage::~CustomMessage() { + this->textBoxSpecialCharacters.clear(); +} + +void CustomMessage::ReplaceSpecialCharacters(std::string& string) { + // add special characters + for (auto specialCharacterPair : textBoxSpecialCharacters) { + size_t start_pos = 0; + std::string textBoxSpecialCharacterString = ""; + textBoxSpecialCharacterString += specialCharacterPair.second; + while ((start_pos = string.find(specialCharacterPair.first, start_pos)) != std::string::npos) { + string.replace(start_pos, specialCharacterPair.first.length(), textBoxSpecialCharacterString); + start_pos += textBoxSpecialCharacterString.length(); + } + } +} + +void CustomMessage::ReplaceColors(std::string& string) { + for (auto colorPair : colors) { + std::string textToReplace = "%"; + textToReplace += colorPair.first; + size_t start_pos = 0; + while ((start_pos = string.find(textToReplace)) != std::string::npos) { + string.replace(start_pos, textToReplace.length(), COLOR(colorPair.second)); + start_pos += textToReplace.length(); + } + } +} + +void CustomMessage::CreateGetItemMessage(GetItemID giid, ItemID iid, std::string messages[LANGUAGE_MAX]) { + for (int i = 0; i < LANGUAGE_MAX; i++) { + if (!(messages[i].empty())) { + std::string message = messages[i]; + std::string formattedMessage = ITEM_OBTAINED(iid) + message; + size_t start_pos = 0; + std::replace(formattedMessage.begin(), formattedMessage.end(), '&', NEWLINE()[0]); + while ((start_pos = formattedMessage.find('^', start_pos)) != std::string::npos) { + formattedMessage.replace(start_pos, 1, WAIT_FOR_INPUT() + ITEM_OBTAINED(iid)); + start_pos += 3; + } + std::replace(formattedMessage.begin(), formattedMessage.end(), '@', PLAYER_NAME()[0]); + ReplaceSpecialCharacters(formattedMessage); + ReplaceColors(formattedMessage); + formattedMessage += MESSAGE_END(); + this->getItemMessageTable[i].emplace(giid, formattedMessage); + } else { + this->getItemMessageTable[i].emplace(giid, MESSAGE_END()); + } + } +} + +std::string CustomMessage::RetrieveGetItemMessage(GetItemID giid) { + std::unordered_map::const_iterator result = + getItemMessageTable[gSaveContext.language].find(giid); + if (result == getItemMessageTable[gSaveContext.language].end()) { + switch (gSaveContext.language) { + case LANGUAGE_FRA: + return "Il n'y a pas de message personnalis pour cet lment."; + case LANGUAGE_GER: + return "Fr diesen Artikel gibt es keine benutzerdefinierte Nachricht."; + case LANGUAGE_ENG: + default: + return "There is no custom message for this item."; + } + } + return result->second; +} + +std::string CustomMessage::MESSAGE_END() { + return "\x02"s; +} + +std::string CustomMessage::ITEM_OBTAINED(uint8_t x) { + return "\x13"s + char(x); +} + +std::string CustomMessage::NEWLINE() { + return "\x01"s; +} + +std::string CustomMessage::COLOR(uint8_t x) { + return "\x05"s + char(x); +} + +std::string CustomMessage::WAIT_FOR_INPUT() { + return "\x04"s; +} + +std::string CustomMessage::PLAYER_NAME() { + return "\x0F"s; +} \ No newline at end of file diff --git a/soh/soh/Enhancements/custom_message/CustomMessage.h b/soh/soh/Enhancements/custom_message/CustomMessage.h new file mode 100644 index 000000000..d8cfd8e0d --- /dev/null +++ b/soh/soh/Enhancements/custom_message/CustomMessage.h @@ -0,0 +1,39 @@ +#pragma once +#include +#include +#include "variables.h" + +#define QM_WHITE 0x00 +#define QM_RED 0x41 +#define QM_GREEN 0x42 +#define QM_BLUE 0x43 +#define QM_LBLUE 0x44 +#define QM_PINK 0x45 +#define QM_YELLOW 0x46 +#define QM_BLACK 0x47 + +class CustomMessage { + private: + std::unordered_map textBoxSpecialCharacters; + std::unordered_map colors; + std::unordered_map getItemMessageTable[LANGUAGE_MAX]; + + void ReplaceSpecialCharacters(std::string &string); + void ReplaceColors(std::string& string); + + std::string MESSAGE_END(); + std::string ITEM_OBTAINED(uint8_t x); + std::string NEWLINE(); + std::string COLOR(uint8_t x); + std::string WAIT_FOR_INPUT(); + std::string PLAYER_NAME(); + + public: + static CustomMessage* Instance; + + CustomMessage(); + ~CustomMessage(); + + void CreateGetItemMessage(GetItemID giid, ItemID iid, std::string messages[LANGUAGE_MAX]); + std::string RetrieveGetItemMessage(GetItemID giid); +}; \ No newline at end of file diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index 09704e867..4c589ea48 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -4748,6 +4748,7 @@ void DrawRandoEditor(bool& open) { void InitRando() { SohImGui::AddWindow("Randomizer", "Randomizer Settings", DrawRandoEditor); + Randomizer::CreateCustomMessages(); } extern "C" { diff --git a/soh/soh/Enhancements/randomizer/randomizer.h b/soh/soh/Enhancements/randomizer/randomizer.h index 180d91691..6f928bd66 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.h +++ b/soh/soh/Enhancements/randomizer/randomizer.h @@ -5,6 +5,7 @@ #include "../../../include/ultra64.h" #include "../../../include/z64item.h" #include +#include class Randomizer { private: @@ -42,6 +43,7 @@ class Randomizer { GetItemID GetRandomizedItemIdFromKnownCheck(RandomizerCheck randomizerCheck, GetItemID ogId); GetItemID GetRandomizedItemId(GetItemID ogId, s16 actorId, s16 actorParams, s16 sceneNum); std::string GetCustomGetItemMessage(GetItemID giid); + static void CreateCustomMessages(); }; #ifdef __cplusplus diff --git a/soh/soh/Enhancements/randomizer/randomizer_custom_messages.cpp b/soh/soh/Enhancements/randomizer/randomizer_custom_messages.cpp index 659e68fe8..a31edcbee 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_custom_messages.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_custom_messages.cpp @@ -1,54 +1,33 @@ -#include "randomizer_custom_messages.h" #include "randomizer.h" -#include +#include "soh/Enhancements/custom_message/CustomMessage.h" using namespace std::literals::string_literals; +#define MESSAGES(eng, ger, fra) (new std::string[]{eng, ger, fra}) + +void Randomizer::CreateCustomMessages() { + CustomMessage* customMessage = CustomMessage::Instance; + customMessage->CreateGetItemMessage( + GI_BOTTLE_WITH_BLUE_FIRE, ITEM_BLUE_FIRE, + MESSAGES("You got a %rBottle with Blue &Fire%w! Use it to melt Red Ice!", "", "")); + customMessage->CreateGetItemMessage( + GI_BOTTLE_WITH_BIG_POE, ITEM_BIG_POE, + MESSAGES("You got a %rBig Poe in a bottle%w!&Sell it to the Ghost Shop!", "", "")); + customMessage->CreateGetItemMessage( + GI_BOTTLE_WITH_BLUE_POTION, ITEM_POTION_BLUE, + MESSAGES("You got a %rBottle of Blue Potion%w!&Drink it to replenish your&%ghealth%w and %bmagic%w!", "", "")); + customMessage->CreateGetItemMessage( + GI_BOTTLE_WITH_FISH, ITEM_FISH, + MESSAGES("You got a %rFish in a bottle%w!&It looks fresh and delicious!&They say Jabu-Jabu loves them!", "", + "")); + + +} + std::string Randomizer::GetCustomGetItemMessage(GetItemID giid) { if (!gSaveContext.n64ddFlag) { return "Not Randomized."; } - switch (giid) { - case GI_BOTTLE_WITH_BLUE_FIRE: - switch (gSaveContext.language) { - case LANGUAGE_FRA: - case LANGUAGE_GER: - case LANGUAGE_ENG: - default: - return ITEM_OBTAINED(ITEM_BLUE_FIRE) + "You got a " + COLOR(QM_RED) + "Bottle with Blue " + - NEWLINE() + "Fire" + COLOR(QM_WHITE) + "! Use it to melt Red Ice!" + - MESSAGE_END(); - } - default: - switch (gSaveContext.language) { - case LANGUAGE_FRA: - return "Il n'y a pas de message personnalis pour cet lment."; - case LANGUAGE_GER: - return "Fr diesen Artikel gibt es keine benutzerdefinierte Nachricht."; - case LANGUAGE_ENG: - default: - return "There is no custom message for this item."; - } - } -} - -std::string MESSAGE_END() { - return "\x02"s; -} - -std::string ITEM_OBTAINED(uint8_t x) { - return "\x13"s + char(x); -} - -std::string NEWLINE() { - return "\x01"s; -} - -std::string COLOR(uint8_t x) { - return "\x05"s + char(x); -} - -std::string WAIT_FOR_INPUT() { - return "\x04"s; + return CustomMessage::Instance->RetrieveGetItemMessage(giid); } \ No newline at end of file diff --git a/soh/soh/Enhancements/randomizer/randomizer_custom_messages.h b/soh/soh/Enhancements/randomizer/randomizer_custom_messages.h deleted file mode 100644 index cae3c65b5..000000000 --- a/soh/soh/Enhancements/randomizer/randomizer_custom_messages.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once - -#include -#include "../../../include/z64item.h" - -#define QM_WHITE 0x00 -#define QM_RED 0x41 -#define QM_GREEN 0x42 -#define QM_BLUE 0x43 -#define QM_LBLUE 0x44 -#define QM_PINK 0x45 -#define QM_YELLOW 0x46 -#define QM_BLACK 0x47 - -std::string MESSAGE_END(); -std::string ITEM_OBTAINED(uint8_t x); -std::string NEWLINE(); -std::string COLOR(uint8_t x); -std::string WAIT_FOR_INPUT(); \ No newline at end of file diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 5ec051af0..6691127be 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -38,6 +38,7 @@ #include "Enhancements/debugger/debugger.h" #include "Enhancements/randomizer/randomizer.h" #include +#include #include "Enhancements/n64_weird_frame_data.inc" #include "soh/frame_interpolation.h" #include "Utils/BitConverter.h" @@ -55,6 +56,7 @@ OTRGlobals* OTRGlobals::Instance; SaveManager* SaveManager::Instance; +CustomMessage* CustomMessage::Instance; OTRGlobals::OTRGlobals() { context = Ship::GlobalCtx2::CreateInstance("Ship of Harkinian"); @@ -106,6 +108,7 @@ extern "C" void OTRExtScanner() { extern "C" void InitOTR() { OTRGlobals::Instance = new OTRGlobals(); SaveManager::Instance = new SaveManager(); + CustomMessage::Instance = new CustomMessage(); auto t = OTRGlobals::Instance->context->GetResourceManager()->LoadFile("version"); if (!t->bHasLoadError) diff --git a/soh/soh/OTRGlobals.h b/soh/soh/OTRGlobals.h index 1cb90fc91..d999f1bda 100644 --- a/soh/soh/OTRGlobals.h +++ b/soh/soh/OTRGlobals.h @@ -9,7 +9,6 @@ #ifdef __cplusplus #include "Enhancements/savestates.h" #include "Enhancements/randomizer/randomizer.h" - class OTRGlobals { public: 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 c27b78ee8..15ff2e7d8 100644 --- a/soh/src/overlays/actors/ovl_player_actor/z_player.c +++ b/soh/src/overlays/actors/ovl_player_actor/z_player.c @@ -654,13 +654,13 @@ static GetItemEntry sGetItemTable[] = { GET_ITEM(ITEM_BOTTLE_WITH_RED_POTION, OBJECT_GI_LIQUID, GID_POTION_RED, 0x43, 0x80, CHEST_ANIM_LONG), GET_ITEM(ITEM_BOTTLE_WITH_GREEN_POTION, OBJECT_GI_LIQUID, GID_POTION_GREEN, 0x44, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_BOTTLE_WITH_BLUE_POTION, OBJECT_GI_LIQUID, GID_POTION_BLUE, 0x45, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_BOTTLE_WITH_BLUE_POTION, OBJECT_GI_LIQUID, GID_POTION_BLUE, 0xF8, 0x80, CHEST_ANIM_LONG), GET_ITEM(ITEM_BOTTLE_WITH_FAIRY, OBJECT_GI_BOTTLE, GID_BOTTLE, 0x46, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_BOTTLE_WITH_FISH, OBJECT_GI_FISH, GID_FISH, 0x47, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_BOTTLE_WITH_FISH, OBJECT_GI_FISH, GID_FISH, 0xF8, 0x80, CHEST_ANIM_LONG), GET_ITEM(ITEM_BOTTLE_WITH_BLUE_FIRE, OBJECT_GI_FIRE, GID_BLUE_FIRE, 0xF8, 0x80, CHEST_ANIM_LONG), GET_ITEM(ITEM_BOTTLE_WITH_BUGS, OBJECT_GI_INSECT, GID_BUG, 0x7A, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_BOTTLE_WITH_POE, OBJECT_GI_GHOST, GID_POE, 0x97, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_BOTTLE_WITH_BIG_POE, OBJECT_GI_GHOST, GID_BIG_POE, 0xF9, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_BOTTLE_WITH_POE, OBJECT_GI_GHOST, GID_POE, 0xF8, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_BOTTLE_WITH_BIG_POE, OBJECT_GI_GHOST, GID_BIG_POE, 0xF8, 0x80, CHEST_ANIM_LONG), GET_ITEM_NONE, GET_ITEM_NONE, From f57a912ca12bde7f780d7c012c7af6b72ed3a7e7 Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Sun, 17 Jul 2022 13:31:38 -0400 Subject: [PATCH 09/71] Does some cleanup of unecessary code and cases of no string provided. --- .../Enhancements/custom_message/CustomMessage.cpp | 12 +----------- .../randomizer/randomizer_custom_messages.cpp | 2 -- soh/soh/OTRGlobals.cpp | 3 +++ 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/soh/soh/Enhancements/custom_message/CustomMessage.cpp b/soh/soh/Enhancements/custom_message/CustomMessage.cpp index 1985a2bbc..80340801d 100644 --- a/soh/soh/Enhancements/custom_message/CustomMessage.cpp +++ b/soh/soh/Enhancements/custom_message/CustomMessage.cpp @@ -60,8 +60,6 @@ void CustomMessage::CreateGetItemMessage(GetItemID giid, ItemID iid, std::string ReplaceColors(formattedMessage); formattedMessage += MESSAGE_END(); this->getItemMessageTable[i].emplace(giid, formattedMessage); - } else { - this->getItemMessageTable[i].emplace(giid, MESSAGE_END()); } } } @@ -70,15 +68,7 @@ std::string CustomMessage::RetrieveGetItemMessage(GetItemID giid) { std::unordered_map::const_iterator result = getItemMessageTable[gSaveContext.language].find(giid); if (result == getItemMessageTable[gSaveContext.language].end()) { - switch (gSaveContext.language) { - case LANGUAGE_FRA: - return "Il n'y a pas de message personnalis pour cet lment."; - case LANGUAGE_GER: - return "Fr diesen Artikel gibt es keine benutzerdefinierte Nachricht."; - case LANGUAGE_ENG: - default: - return "There is no custom message for this item."; - } + return ""; } return result->second; } diff --git a/soh/soh/Enhancements/randomizer/randomizer_custom_messages.cpp b/soh/soh/Enhancements/randomizer/randomizer_custom_messages.cpp index a31edcbee..61a2559ac 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_custom_messages.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_custom_messages.cpp @@ -1,8 +1,6 @@ #include "randomizer.h" #include "soh/Enhancements/custom_message/CustomMessage.h" -using namespace std::literals::string_literals; - #define MESSAGES(eng, ger, fra) (new std::string[]{eng, ger, fra}) void Randomizer::CreateCustomMessages() { diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 6691127be..4459e3b19 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -1507,5 +1507,8 @@ extern "C" s32 GetRandomizedItemIdFromKnownCheck(RandomizerCheck randomizerCheck extern "C" int Randomizer_GetCustomGetItemMessage(GetItemID giid, char* buffer, const int maxBufferSize) { const std::string& getItemText = OTRGlobals::Instance->gRandomizer->GetCustomGetItemMessage(giid); + if (getItemText == "") { + return false; + } return CopyStringToCharBuffer(getItemText, buffer, maxBufferSize); } From 69d2b5b3a32ae7a89caf907a6b5e329ab7a63b17 Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Sun, 17 Jul 2022 15:02:08 -0400 Subject: [PATCH 10/71] Implements function to return custom message if one exists. `CustomMessage_RetrieveIfExists` is placed at the very beginning of the z_message_PAL.c `Message_OpenText` if statement after any special changes to textIds are made. This function will either return either true or false and if true it will populate the necessary values of font and msgCtx to display said message. It's placement at the beginning also allows for overriding existing textIds to have new information, which will come in handy later. --- soh/soh/OTRGlobals.cpp | 29 +++++++++++++++++++++++++++++ soh/soh/OTRGlobals.h | 1 + soh/src/code/z_message_PAL.c | 8 +++++--- 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 4459e3b19..549b69ed1 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -1512,3 +1512,32 @@ extern "C" int Randomizer_GetCustomGetItemMessage(GetItemID giid, char* buffer, } return CopyStringToCharBuffer(getItemText, buffer, maxBufferSize); } + +extern "C" int CustomMessage_RetrieveIfExists(GlobalContext* globalCtx, char* buffer, const int maxBufferSize) { + MessageContext* msgCtx = &globalCtx->msgCtx; + Font* font = &msgCtx->font; + if (gSaveContext.n64ddFlag) { + if (msgCtx->textId == 0xF8) { + if (msgCtx->msgLength = font->msgLength = Randomizer_GetCustomGetItemMessage( + (GetItemID)GET_PLAYER(globalCtx)->getItemId, font->msgBuf, sizeof(font->msgBuf))) { + font->charTexBuf[0] = 0x23; + return true; + } else { + switch (gSaveContext.language) { + case LANGUAGE_FRA: + return msgCtx->msgLength = font->msgLength = CopyStringToCharBuffer( + "Il n'y a pas de message personnalisé pour cet élément.", buffer, maxBufferSize); + case LANGUAGE_GER: + return msgCtx->msgLength = font->msgLength = CopyStringToCharBuffer( + "Für diesen Artikel gibt es keine benutzerdefinierte Nachricht.", buffer, + maxBufferSize); + case LANGUAGE_ENG: + default: + return msgCtx->msgLength = font->msgLength = CopyStringToCharBuffer( + "There is no custom message for this item.", buffer, maxBufferSize); + } + } + } + } + return false; +} diff --git a/soh/soh/OTRGlobals.h b/soh/soh/OTRGlobals.h index d999f1bda..0110d7ad1 100644 --- a/soh/soh/OTRGlobals.h +++ b/soh/soh/OTRGlobals.h @@ -97,6 +97,7 @@ s32 GetItemIDFromGetItemID(s32 getItemId); s32 GetRandomizedItemId(GetItemID ogId, s16 actorId, s16 actorParams, s16 sceneNum); s32 GetRandomizedItemIdFromKnownCheck(RandomizerCheck randomizerCheck, GetItemID ogId); int Randomizer_GetCustomGetItemMessage(GetItemID giid, char* buffer, const int maxBufferSize); +int CustomMessage_RetrieveIfExists(GlobalContext* globalCtx, char* buffer, const int maxBufferSize); #endif #endif diff --git a/soh/src/code/z_message_PAL.c b/soh/src/code/z_message_PAL.c index 87bc255ab..432c05cfd 100644 --- a/soh/src/code/z_message_PAL.c +++ b/soh/src/code/z_message_PAL.c @@ -1662,7 +1662,9 @@ void Message_OpenText(GlobalContext* globalCtx, u16 textId) { gSaveContext.eventInf[0] = gSaveContext.eventInf[1] = gSaveContext.eventInf[2] = gSaveContext.eventInf[3] = 0; } - if (sTextIsCredits) { + if (CustomMessage_RetrieveIfExists(globalCtx, font->msgBuf, sizeof(font->msgBuf))) { + osSyncPrintf("Found custom message"); + } else if (sTextIsCredits) { Message_FindCreditsMessage(globalCtx, textId); msgCtx->msgLength = font->msgLength; char* src = (uintptr_t)font->msgOffset; @@ -1735,11 +1737,11 @@ void Message_OpenText(GlobalContext* globalCtx, u16 textId) { } else { msgCtx->msgLength = font->msgLength = CopyGanonHintText(font->msgBuf, sizeof(font->msgBuf)); } - } else if (gSaveContext.n64ddFlag && textId == 0xF8) { + } /*else if (gSaveContext.n64ddFlag && textId == 0xF8) { msgCtx->msgLength = font->msgLength = Randomizer_GetCustomGetItemMessage( GET_PLAYER(globalCtx)->getItemId, font->msgBuf, sizeof(font->msgBuf)); font->charTexBuf[0] = 0x23; - } else { + }*/ else { msgCtx->msgLength = font->msgLength; char* src = (uintptr_t)font->msgOffset; memcpy(font->msgBuf, src, font->msgLength); From 98c771cf2c35af469d84e018ac1987e56e524659 Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Sun, 17 Jul 2022 15:11:16 -0400 Subject: [PATCH 11/71] Simplifies the function signature of `CustomMessage_RetrieveIfExists`. --- soh/soh/OTRGlobals.cpp | 6 ++++-- soh/soh/OTRGlobals.h | 2 +- soh/src/code/z_message_PAL.c | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 549b69ed1..36101e05e 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -1513,13 +1513,15 @@ extern "C" int Randomizer_GetCustomGetItemMessage(GetItemID giid, char* buffer, return CopyStringToCharBuffer(getItemText, buffer, maxBufferSize); } -extern "C" int CustomMessage_RetrieveIfExists(GlobalContext* globalCtx, char* buffer, const int maxBufferSize) { +extern "C" int CustomMessage_RetrieveIfExists(GlobalContext* globalCtx) { MessageContext* msgCtx = &globalCtx->msgCtx; Font* font = &msgCtx->font; + char* buffer = font->msgBuf; + const int maxBufferSize = sizeof(font->msgBuf); if (gSaveContext.n64ddFlag) { if (msgCtx->textId == 0xF8) { if (msgCtx->msgLength = font->msgLength = Randomizer_GetCustomGetItemMessage( - (GetItemID)GET_PLAYER(globalCtx)->getItemId, font->msgBuf, sizeof(font->msgBuf))) { + (GetItemID)GET_PLAYER(globalCtx)->getItemId, buffer, maxBufferSize)) { font->charTexBuf[0] = 0x23; return true; } else { diff --git a/soh/soh/OTRGlobals.h b/soh/soh/OTRGlobals.h index 0110d7ad1..8f46d13fc 100644 --- a/soh/soh/OTRGlobals.h +++ b/soh/soh/OTRGlobals.h @@ -97,7 +97,7 @@ s32 GetItemIDFromGetItemID(s32 getItemId); s32 GetRandomizedItemId(GetItemID ogId, s16 actorId, s16 actorParams, s16 sceneNum); s32 GetRandomizedItemIdFromKnownCheck(RandomizerCheck randomizerCheck, GetItemID ogId); int Randomizer_GetCustomGetItemMessage(GetItemID giid, char* buffer, const int maxBufferSize); -int CustomMessage_RetrieveIfExists(GlobalContext* globalCtx, char* buffer, const int maxBufferSize); +int CustomMessage_RetrieveIfExists(GlobalContext* globalCtx); #endif #endif diff --git a/soh/src/code/z_message_PAL.c b/soh/src/code/z_message_PAL.c index 432c05cfd..f0ce90fbd 100644 --- a/soh/src/code/z_message_PAL.c +++ b/soh/src/code/z_message_PAL.c @@ -1662,7 +1662,7 @@ void Message_OpenText(GlobalContext* globalCtx, u16 textId) { gSaveContext.eventInf[0] = gSaveContext.eventInf[1] = gSaveContext.eventInf[2] = gSaveContext.eventInf[3] = 0; } - if (CustomMessage_RetrieveIfExists(globalCtx, font->msgBuf, sizeof(font->msgBuf))) { + if (CustomMessage_RetrieveIfExists(globalCtx)) { osSyncPrintf("Found custom message"); } else if (sTextIsCredits) { Message_FindCreditsMessage(globalCtx, textId); From ee1270f346b429d3c247cd4b4bb80fe29f9ba76f Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Sun, 17 Jul 2022 15:29:02 -0400 Subject: [PATCH 12/71] more cleanup --- soh/soh/OTRGlobals.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 36101e05e..d4a78fb34 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -1515,11 +1515,12 @@ extern "C" int Randomizer_GetCustomGetItemMessage(GetItemID giid, char* buffer, extern "C" int CustomMessage_RetrieveIfExists(GlobalContext* globalCtx) { MessageContext* msgCtx = &globalCtx->msgCtx; + uint16_t textId = msgCtx->textId; Font* font = &msgCtx->font; char* buffer = font->msgBuf; const int maxBufferSize = sizeof(font->msgBuf); if (gSaveContext.n64ddFlag) { - if (msgCtx->textId == 0xF8) { + if (textId == 0xF8) { if (msgCtx->msgLength = font->msgLength = Randomizer_GetCustomGetItemMessage( (GetItemID)GET_PLAYER(globalCtx)->getItemId, buffer, maxBufferSize)) { font->charTexBuf[0] = 0x23; @@ -1528,15 +1529,15 @@ extern "C" int CustomMessage_RetrieveIfExists(GlobalContext* globalCtx) { switch (gSaveContext.language) { case LANGUAGE_FRA: return msgCtx->msgLength = font->msgLength = CopyStringToCharBuffer( - "Il n'y a pas de message personnalisé pour cet élément.", buffer, maxBufferSize); + "Il n'y a pas de message personnalisé pour cet élément.\x02", buffer, maxBufferSize); case LANGUAGE_GER: return msgCtx->msgLength = font->msgLength = CopyStringToCharBuffer( - "Für diesen Artikel gibt es keine benutzerdefinierte Nachricht.", buffer, + "Für diesen Artikel gibt es keine benutzerdefinierte Nachricht.\x02", buffer, maxBufferSize); case LANGUAGE_ENG: default: return msgCtx->msgLength = font->msgLength = CopyStringToCharBuffer( - "There is no custom message for this item.", buffer, maxBufferSize); + "There is no custom message for this item.\x02", buffer, maxBufferSize); } } } From 1ed45e1433ab25b7e0487df837cd1ed2fae053cc Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Sun, 17 Jul 2022 21:03:32 -0400 Subject: [PATCH 13/71] Implements adding message tables and retrieving by an ID. Basically, some external code can choos a unique id and create a message table for itself. The idea is that modders can hook into this as well so they can get their own message table and don't have to worry about conflicting with the base game's textIDs. I have also implemented this setup for Randomizer so that the pre-filled bottles (which didn't exist in the original outside of Ruto's letter) have unique text as compared to the text for the item they are filled with. --- .../custom_message/CustomMessage.cpp | 78 +++++++++++++------ .../custom_message/CustomMessage.h | 16 +++- .../Enhancements/randomizer/randomizer.cpp | 2 + soh/soh/Enhancements/randomizer/randomizer.h | 1 + .../randomizer/randomizer_custom_messages.cpp | 35 ++++++--- soh/soh/OTRGlobals.cpp | 2 +- .../actors/ovl_player_actor/z_player.c | 8 +- 7 files changed, 99 insertions(+), 43 deletions(-) diff --git a/soh/soh/Enhancements/custom_message/CustomMessage.cpp b/soh/soh/Enhancements/custom_message/CustomMessage.cpp index 80340801d..d513c8286 100644 --- a/soh/soh/Enhancements/custom_message/CustomMessage.cpp +++ b/soh/soh/Enhancements/custom_message/CustomMessage.cpp @@ -17,6 +17,8 @@ CustomMessage::CustomMessage() { CustomMessage::~CustomMessage() { this->textBoxSpecialCharacters.clear(); + this->colors.clear(); + this->messageTables.clear(); } void CustomMessage::ReplaceSpecialCharacters(std::string& string) { @@ -44,33 +46,61 @@ void CustomMessage::ReplaceColors(std::string& string) { } } -void CustomMessage::CreateGetItemMessage(GetItemID giid, ItemID iid, std::string messages[LANGUAGE_MAX]) { - for (int i = 0; i < LANGUAGE_MAX; i++) { - if (!(messages[i].empty())) { - std::string message = messages[i]; - std::string formattedMessage = ITEM_OBTAINED(iid) + message; - size_t start_pos = 0; - std::replace(formattedMessage.begin(), formattedMessage.end(), '&', NEWLINE()[0]); - while ((start_pos = formattedMessage.find('^', start_pos)) != std::string::npos) { - formattedMessage.replace(start_pos, 1, WAIT_FOR_INPUT() + ITEM_OBTAINED(iid)); - start_pos += 3; - } - std::replace(formattedMessage.begin(), formattedMessage.end(), '@', PLAYER_NAME()[0]); - ReplaceSpecialCharacters(formattedMessage); - ReplaceColors(formattedMessage); - formattedMessage += MESSAGE_END(); - this->getItemMessageTable[i].emplace(giid, formattedMessage); - } +void CustomMessage::FormatMessage(std::string& message, ItemID iid) { + message.insert(0, ITEM_OBTAINED(iid)); + size_t start_pos = 0; + std::replace(message.begin(), message.end(), '&', NEWLINE()[0]); + while ((start_pos = message.find('^', start_pos)) != std::string::npos) { + message.replace(start_pos, 1, WAIT_FOR_INPUT() + ITEM_OBTAINED(iid)); + start_pos += 3; + } + std::replace(message.begin(), message.end(), '@', PLAYER_NAME()[0]); + ReplaceSpecialCharacters(message); + ReplaceColors(message); + message += MESSAGE_END(); +} + + + +bool CustomMessage::CreateGetItemMessage(std::string tableID, GetItemID giid, ItemID iid, CustomMessageEntry messages) { + FormatMessage(messages.english, iid); + FormatMessage(messages.german, iid); + FormatMessage(messages.french, iid); + const uint16_t textID = giid; + auto result = messageTables.find(tableID); + if (result == messageTables.end()) { + return false; + } + auto& messageTable = result->second; + auto success = messageTable.emplace(textID, messages); + return success.second; +} + +std::string CustomMessage::RetrieveMessage(std::string tableID, uint16_t textID) { + std::unordered_map::const_iterator result = messageTables.find(tableID); + if (result == messageTables.end()) { + return ""; + } + CustomMessageTable messageTable = result->second; + std::unordered_map::const_iterator message_pair = messageTable.find(textID); + if (message_pair == messageTable.end()) { + return ""; + } + CustomMessageEntry messages = message_pair->second; + switch (gSaveContext.language) { + case LANGUAGE_FRA: + return messages.french; + case LANGUAGE_GER: + return messages.german; + case LANGUAGE_ENG: + default: + return messages.english; } } -std::string CustomMessage::RetrieveGetItemMessage(GetItemID giid) { - std::unordered_map::const_iterator result = - getItemMessageTable[gSaveContext.language].find(giid); - if (result == getItemMessageTable[gSaveContext.language].end()) { - return ""; - } - return result->second; +bool CustomMessage::AddCustomMessageTable(std::string tableID) { + CustomMessageTable newMessageTable; + return messageTables.emplace(tableID, newMessageTable).second; } std::string CustomMessage::MESSAGE_END() { diff --git a/soh/soh/Enhancements/custom_message/CustomMessage.h b/soh/soh/Enhancements/custom_message/CustomMessage.h index d8cfd8e0d..d3d1d8849 100644 --- a/soh/soh/Enhancements/custom_message/CustomMessage.h +++ b/soh/soh/Enhancements/custom_message/CustomMessage.h @@ -12,14 +12,23 @@ #define QM_YELLOW 0x46 #define QM_BLACK 0x47 +typedef struct { + std::string english; + std::string german; + std::string french; +} CustomMessageEntry; + +typedef std::unordered_map CustomMessageTable; + class CustomMessage { private: std::unordered_map textBoxSpecialCharacters; std::unordered_map colors; - std::unordered_map getItemMessageTable[LANGUAGE_MAX]; + std::unordered_map messageTables; void ReplaceSpecialCharacters(std::string &string); void ReplaceColors(std::string& string); + void FormatMessage(std::string& message, ItemID iid); std::string MESSAGE_END(); std::string ITEM_OBTAINED(uint8_t x); @@ -34,6 +43,7 @@ class CustomMessage { CustomMessage(); ~CustomMessage(); - void CreateGetItemMessage(GetItemID giid, ItemID iid, std::string messages[LANGUAGE_MAX]); - std::string RetrieveGetItemMessage(GetItemID giid); + bool CreateGetItemMessage(std::string tableID, GetItemID giid, ItemID iid, CustomMessageEntry messages); + std::string RetrieveMessage(std::string tableID, uint16_t textID); + bool AddCustomMessageTable(std::string tableID); }; \ No newline at end of file diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index 4c589ea48..2e47c7c80 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -21,6 +21,8 @@ std::unordered_map gSeedTextures; u8 generated; +const std::string Randomizer::customMessageTableID = "Randomizer"; + Randomizer::Randomizer() { Sprite bowSprite = { dgFairyBowIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 0 }; gSeedTextures[0] = bowSprite; diff --git a/soh/soh/Enhancements/randomizer/randomizer.h b/soh/soh/Enhancements/randomizer/randomizer.h index 6f928bd66..22047a9d8 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.h +++ b/soh/soh/Enhancements/randomizer/randomizer.h @@ -16,6 +16,7 @@ class Randomizer { std::string ganonHintText; std::string ganonText; std::unordered_map randoSettings; + static const std::string customMessageTableID; GetItemID GetItemFromGet(RandomizerGet randoGet, GetItemID ogItemId); GetItemID GetItemFromActor(s16 actorId, s16 actorParams, s16 sceneNum, GetItemID ogItemId); void ParseRandomizerSettingsFile(const char* spoilerFileName); diff --git a/soh/soh/Enhancements/randomizer/randomizer_custom_messages.cpp b/soh/soh/Enhancements/randomizer/randomizer_custom_messages.cpp index 61a2559ac..62e213cda 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_custom_messages.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_custom_messages.cpp @@ -1,25 +1,38 @@ #include "randomizer.h" #include "soh/Enhancements/custom_message/CustomMessage.h" -#define MESSAGES(eng, ger, fra) (new std::string[]{eng, ger, fra}) +#define MESSAGES(eng, ger, fra) {eng, ger, fra} void Randomizer::CreateCustomMessages() { CustomMessage* customMessage = CustomMessage::Instance; + customMessage->AddCustomMessageTable(Randomizer::customMessageTableID); customMessage->CreateGetItemMessage( - GI_BOTTLE_WITH_BLUE_FIRE, ITEM_BLUE_FIRE, + Randomizer::customMessageTableID, GI_BOTTLE_WITH_BLUE_FIRE, ITEM_BLUE_FIRE, MESSAGES("You got a %rBottle with Blue &Fire%w! Use it to melt Red Ice!", "", "")); customMessage->CreateGetItemMessage( - GI_BOTTLE_WITH_BIG_POE, ITEM_BIG_POE, - MESSAGES("You got a %rBig Poe in a bottle%w!&Sell it to the Ghost Shop!", "", "")); + Randomizer::customMessageTableID, GI_BOTTLE_WITH_BIG_POE, ITEM_BIG_POE, + MESSAGES("You got a %rBig Poe in a Bottle%w!&Sell it to the Ghost Shop!", "", "")); customMessage->CreateGetItemMessage( - GI_BOTTLE_WITH_BLUE_POTION, ITEM_POTION_BLUE, + Randomizer::customMessageTableID, GI_BOTTLE_WITH_BLUE_POTION, ITEM_POTION_BLUE, MESSAGES("You got a %rBottle of Blue Potion%w!&Drink it to replenish your&%ghealth%w and %bmagic%w!", "", "")); customMessage->CreateGetItemMessage( - GI_BOTTLE_WITH_FISH, ITEM_FISH, - MESSAGES("You got a %rFish in a bottle%w!&It looks fresh and delicious!&They say Jabu-Jabu loves them!", "", - "")); - - + Randomizer::customMessageTableID, GI_BOTTLE_WITH_FISH, ITEM_FISH, + MESSAGES("You got a %rFish in a Bottle%w!&It looks fresh and delicious!&They say Jabu-Jabu loves them!", "", "")); + customMessage->CreateGetItemMessage( + Randomizer::customMessageTableID, GI_BOTTLE_WITH_BUGS, ITEM_BUG, + { "You got a %rBug in a Bottle%w!&They love to burrow in&dirt holes!", "", "" }); + customMessage->CreateGetItemMessage( + Randomizer::customMessageTableID, GI_BOTTLE_WITH_FAIRY, ITEM_FAIRY, + { "You got a %rFairy in a Bottle%w!&Use it wisely!", "", "" }); + customMessage->CreateGetItemMessage( + Randomizer::customMessageTableID, GI_BOTTLE_WITH_RED_POTION, ITEM_POTION_RED, + { "You got a %rBottle of Red Potion%w!&Drink it to replenish your&%ghealth%w!", "", "" }); + customMessage->CreateGetItemMessage( + Randomizer::customMessageTableID, GI_BOTTLE_WITH_GREEN_POTION, ITEM_POTION_GREEN, + { "You got a %rBottle of Green Potion%w!&Drink it to replenish your&%bmagic%w!", "", "" }); + customMessage->CreateGetItemMessage( + Randomizer::customMessageTableID, GI_BOTTLE_WITH_POE, ITEM_POE, + { "You got a %rPoe in a Bottle%w!&That creepy Ghost Shop might&be interested in this...", "", "" }); } std::string Randomizer::GetCustomGetItemMessage(GetItemID giid) { @@ -27,5 +40,5 @@ std::string Randomizer::GetCustomGetItemMessage(GetItemID giid) { return "Not Randomized."; } - return CustomMessage::Instance->RetrieveGetItemMessage(giid); + return CustomMessage::Instance->RetrieveMessage(Randomizer::customMessageTableID, giid); } \ No newline at end of file diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index d4a78fb34..2bd04a5e8 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -1521,9 +1521,9 @@ extern "C" int CustomMessage_RetrieveIfExists(GlobalContext* globalCtx) { const int maxBufferSize = sizeof(font->msgBuf); if (gSaveContext.n64ddFlag) { if (textId == 0xF8) { + font->charTexBuf[0] = 0x23; if (msgCtx->msgLength = font->msgLength = Randomizer_GetCustomGetItemMessage( (GetItemID)GET_PLAYER(globalCtx)->getItemId, buffer, maxBufferSize)) { - font->charTexBuf[0] = 0x23; return true; } else { switch (gSaveContext.language) { 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 15ff2e7d8..4d2c6e23b 100644 --- a/soh/src/overlays/actors/ovl_player_actor/z_player.c +++ b/soh/src/overlays/actors/ovl_player_actor/z_player.c @@ -652,13 +652,13 @@ static GetItemEntry sGetItemTable[] = { GET_ITEM(ITEM_DOUBLE_MAGIC, OBJECT_GI_MAGICPOT, GID_MAGIC_LARGE, 0xE8, 0x80, CHEST_ANIM_LONG), GET_ITEM(ITEM_DOUBLE_DEFENSE, OBJECT_GI_HEARTS, GID_HEART_CONTAINER, 0xE9, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_BOTTLE_WITH_RED_POTION, OBJECT_GI_LIQUID, GID_POTION_RED, 0x43, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_BOTTLE_WITH_GREEN_POTION, OBJECT_GI_LIQUID, GID_POTION_GREEN, 0x44, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_BOTTLE_WITH_RED_POTION, OBJECT_GI_LIQUID, GID_POTION_RED, 0xF8, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_BOTTLE_WITH_GREEN_POTION, OBJECT_GI_LIQUID, GID_POTION_GREEN, 0xF8, 0x80, CHEST_ANIM_LONG), GET_ITEM(ITEM_BOTTLE_WITH_BLUE_POTION, OBJECT_GI_LIQUID, GID_POTION_BLUE, 0xF8, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_BOTTLE_WITH_FAIRY, OBJECT_GI_BOTTLE, GID_BOTTLE, 0x46, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_BOTTLE_WITH_FAIRY, OBJECT_GI_BOTTLE, GID_BOTTLE, 0xF8, 0x80, CHEST_ANIM_LONG), GET_ITEM(ITEM_BOTTLE_WITH_FISH, OBJECT_GI_FISH, GID_FISH, 0xF8, 0x80, CHEST_ANIM_LONG), GET_ITEM(ITEM_BOTTLE_WITH_BLUE_FIRE, OBJECT_GI_FIRE, GID_BLUE_FIRE, 0xF8, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_BOTTLE_WITH_BUGS, OBJECT_GI_INSECT, GID_BUG, 0x7A, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_BOTTLE_WITH_BUGS, OBJECT_GI_INSECT, GID_BUG, 0xF8, 0x80, CHEST_ANIM_LONG), GET_ITEM(ITEM_BOTTLE_WITH_POE, OBJECT_GI_GHOST, GID_POE, 0xF8, 0x80, CHEST_ANIM_LONG), GET_ITEM(ITEM_BOTTLE_WITH_BIG_POE, OBJECT_GI_GHOST, GID_BIG_POE, 0xF8, 0x80, CHEST_ANIM_LONG), From e04b2c80b67c23114a4818b1e39298cbaaed9e1b Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Sun, 17 Jul 2022 22:02:22 -0400 Subject: [PATCH 14/71] Implements the custom text for gInjectSkulltulaCount. Also auto-dissmisses the textbox when gSkulltulaFreeze is on. When gInjectSkulltulaCount is off, text is not auto-dismissed just like before, since that is base game text still. --- .../custom_message/CustomMessage.cpp | 8 +++--- .../custom_message/CustomMessage.h | 4 ++- soh/soh/OTRGlobals.cpp | 15 +++++++++++ soh/soh/z_message_OTR.cpp | 18 +++++++++++++ soh/src/code/z_message_PAL.c | 25 +------------------ 5 files changed, 41 insertions(+), 29 deletions(-) diff --git a/soh/soh/Enhancements/custom_message/CustomMessage.cpp b/soh/soh/Enhancements/custom_message/CustomMessage.cpp index d513c8286..95e260cf8 100644 --- a/soh/soh/Enhancements/custom_message/CustomMessage.cpp +++ b/soh/soh/Enhancements/custom_message/CustomMessage.cpp @@ -46,7 +46,7 @@ void CustomMessage::ReplaceColors(std::string& string) { } } -void CustomMessage::FormatMessage(std::string& message, ItemID iid) { +void CustomMessage::FormatCustomMessage(std::string& message, ItemID iid) { message.insert(0, ITEM_OBTAINED(iid)); size_t start_pos = 0; std::replace(message.begin(), message.end(), '&', NEWLINE()[0]); @@ -63,9 +63,9 @@ void CustomMessage::FormatMessage(std::string& message, ItemID iid) { bool CustomMessage::CreateGetItemMessage(std::string tableID, GetItemID giid, ItemID iid, CustomMessageEntry messages) { - FormatMessage(messages.english, iid); - FormatMessage(messages.german, iid); - FormatMessage(messages.french, iid); + FormatCustomMessage(messages.english, iid); + FormatCustomMessage(messages.german, iid); + FormatCustomMessage(messages.french, iid); const uint16_t textID = giid; auto result = messageTables.find(tableID); if (result == messageTables.end()) { diff --git a/soh/soh/Enhancements/custom_message/CustomMessage.h b/soh/soh/Enhancements/custom_message/CustomMessage.h index d3d1d8849..4d35cfb9a 100644 --- a/soh/soh/Enhancements/custom_message/CustomMessage.h +++ b/soh/soh/Enhancements/custom_message/CustomMessage.h @@ -3,6 +3,8 @@ #include #include "variables.h" +#undef MESSAGE_END + #define QM_WHITE 0x00 #define QM_RED 0x41 #define QM_GREEN 0x42 @@ -28,7 +30,7 @@ class CustomMessage { void ReplaceSpecialCharacters(std::string &string); void ReplaceColors(std::string& string); - void FormatMessage(std::string& message, ItemID iid); + void FormatCustomMessage(std::string& message, ItemID iid); std::string MESSAGE_END(); std::string ITEM_OBTAINED(uint8_t x); diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 2bd04a5e8..14fa89f6c 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -1542,5 +1542,20 @@ extern "C" int CustomMessage_RetrieveIfExists(GlobalContext* globalCtx) { } } } + if (textId == 0x00B4 || textId == 0x00B5) { + if (CVar_GetS32("gInjectSkulltulaCount", 0) != 0) { + font->charTexBuf[0] = 0x03; + std::string message; + if (CVar_GetS32("gSkulltulaFreeze", 0) != 0) { + textId = 0x00B4; + } else { + textId = 0x00B5; + } + message = CustomMessage::Instance->RetrieveMessage("BaseGameOverrides", textId); + if (message != "") { + return msgCtx->msgLength = font->msgLength = CopyStringToCharBuffer(message, buffer, maxBufferSize); + } + } + } return false; } diff --git a/soh/soh/z_message_OTR.cpp b/soh/soh/z_message_OTR.cpp index 8c1d26a75..e6ef4bb76 100644 --- a/soh/soh/z_message_OTR.cpp +++ b/soh/soh/z_message_OTR.cpp @@ -6,6 +6,7 @@ #include "global.h" #include "vt.h" #include +#include extern "C" MessageTableEntry* sNesMessageEntryTablePtr; extern "C" MessageTableEntry* sGerMessageEntryTablePtr; @@ -13,6 +14,8 @@ extern "C" MessageTableEntry* sFraMessageEntryTablePtr; extern "C" MessageTableEntry* sStaffMessageEntryTablePtr; //extern "C" MessageTableEntry* _message_0xFFFC_nes; +const std::string customMessageTableID = "BaseGameOverrides"; + MessageTableEntry* OTRMessage_LoadTable(const char* filePath, bool isNES) { auto file = std::static_pointer_cast(OTRGlobals::Instance->context->GetResourceManager()->LoadResource(filePath)); @@ -92,4 +95,19 @@ extern "C" void OTRMessage_Init() sStaffMessageEntryTablePtr[i].segment = file2->messages[i].msg.c_str(); sStaffMessageEntryTablePtr[i].msgSize = file2->messages[i].msg.size(); } + + CustomMessage::Instance->AddCustomMessageTable(customMessageTableID); + CustomMessage::Instance->CreateGetItemMessage( + customMessageTableID, (GetItemID)0x00B4, ITEM_SKULL_TOKEN, + { + "You got a %rGold Skulltula Token%w!&You've collected %r\x19%w tokens&in total!\x0E\x3C", + "Du erhlst ein %rGoldene&Skulltula-Symbol%w! Du hast&insgesamt %r\x19%w symbol gesammelt!\x0E\x3C", + "Vous obtenez un %rSymbole de&Skulltula d'or%w! Vous avez&collect %r\x19\%w symboles en tout!\x0E\x3C" + } + ); + CustomMessage::Instance->CreateGetItemMessage( + customMessageTableID, (GetItemID)0x00B5, ITEM_SKULL_TOKEN, + { "You got a %rGold Skulltula Token%w!&You've collected %r\x19%w tokens&in total!", + "Du erhlst ein %rGoldene&Skulltula-Symbol%w! Du hast&insgesamt %r\x19%w symbol gesammelt!", + "Vous obtenez un %rSymbole de&Skulltula d'or%w! Vous avez&collect %r\x19\%w symboles en tout!" }); } \ No newline at end of file diff --git a/soh/src/code/z_message_PAL.c b/soh/src/code/z_message_PAL.c index f0ce90fbd..ad37aea16 100644 --- a/soh/src/code/z_message_PAL.c +++ b/soh/src/code/z_message_PAL.c @@ -1710,25 +1710,6 @@ void Message_OpenText(GlobalContext* globalCtx, u16 textId) { } else if (gSaveContext.n64ddFlag && (textId == 0x7040 || textId == 0x7088)) { // rando hints at altar msgCtx->msgLength = font->msgLength = CopyAltarMessage(font->msgBuf, sizeof(font->msgBuf)); - } else if (textId == 0x00b4 && CVar_GetS32("gInjectSkulltulaCount", 0) != 0) { - switch (gSaveContext.language) { - case LANGUAGE_FRA: - strcpy(font->msgBuf, "\x08\x13\x71Vous obtenez un \x05\x41Symbole de\x01Skulltula d'or\x05\x40! " - "Vous avez\x01\collect\x96 " - "\x05\x41\x19\x05\x40 symboles en tout!\x02"); - break; - case LANGUAGE_GER: - strcpy(font->msgBuf, "\x08\x13\x71\Du erh\x93lst ein \x05\x41Goldene\x01Skulltula-Symbol\x05\x40\! " - "Du hast\x01insgesamt " - "\x05\x41\x19\x05\x40 symbol gesammelt!\x02"); - break; - case LANGUAGE_ENG: default: - strcpy(font->msgBuf, - "\x08\x13\x71You got a \x05\x41Gold Skulltula Token\x05\x40!\x01You've collected " - "\x05\x41\x19\x05\x40 tokens\x01in total!\x02"); - break; - } - msgCtx->msgLength = font->msgLength = strlen(font->msgBuf); } else if (gSaveContext.n64ddFlag && (textId == 0x10A2 || textId == 0x10DC || textId == 0x10DD)) { msgCtx->msgLength = font->msgLength = CopyScrubMessage(textId, font->msgBuf, sizeof(font->msgBuf)); } else if (gSaveContext.n64ddFlag && textId == 0x70CC) { @@ -1737,11 +1718,7 @@ void Message_OpenText(GlobalContext* globalCtx, u16 textId) { } else { msgCtx->msgLength = font->msgLength = CopyGanonHintText(font->msgBuf, sizeof(font->msgBuf)); } - } /*else if (gSaveContext.n64ddFlag && textId == 0xF8) { - msgCtx->msgLength = font->msgLength = Randomizer_GetCustomGetItemMessage( - GET_PLAYER(globalCtx)->getItemId, font->msgBuf, sizeof(font->msgBuf)); - font->charTexBuf[0] = 0x23; - }*/ else { + } else { msgCtx->msgLength = font->msgLength; char* src = (uintptr_t)font->msgOffset; memcpy(font->msgBuf, src, font->msgLength); From 32abe61554472e37c5c67d3c5186097738c9df21 Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Tue, 19 Jul 2022 00:31:37 -0400 Subject: [PATCH 15/71] Implements a basic CreateMessage function for non-GetItem text. --- .../custom_message/CustomMessage.cpp | 36 +++++++++++++++---- .../custom_message/CustomMessage.h | 3 ++ 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/soh/soh/Enhancements/custom_message/CustomMessage.cpp b/soh/soh/Enhancements/custom_message/CustomMessage.cpp index 95e260cf8..437c16ac8 100644 --- a/soh/soh/Enhancements/custom_message/CustomMessage.cpp +++ b/soh/soh/Enhancements/custom_message/CustomMessage.cpp @@ -60,13 +60,20 @@ void CustomMessage::FormatCustomMessage(std::string& message, ItemID iid) { message += MESSAGE_END(); } +void CustomMessage::FormatCustomMessage(std::string& message) { + size_t start_pos = 0; + std::replace(message.begin(), message.end(), '&', NEWLINE()[0]); + while ((start_pos = message.find('^', start_pos)) != std::string::npos) { + message.replace(start_pos, 1, WAIT_FOR_INPUT()); + start_pos += 3; + } + std::replace(message.begin(), message.end(), '@', PLAYER_NAME()[0]); + ReplaceSpecialCharacters(message); + ReplaceColors(message); + message += MESSAGE_END(); +} - -bool CustomMessage::CreateGetItemMessage(std::string tableID, GetItemID giid, ItemID iid, CustomMessageEntry messages) { - FormatCustomMessage(messages.english, iid); - FormatCustomMessage(messages.german, iid); - FormatCustomMessage(messages.french, iid); - const uint16_t textID = giid; +bool CustomMessage::InsertCustomMessage(std::string tableID, uint16_t textID, CustomMessageEntry messages) { auto result = messageTables.find(tableID); if (result == messageTables.end()) { return false; @@ -76,6 +83,23 @@ bool CustomMessage::CreateGetItemMessage(std::string tableID, GetItemID giid, It return success.second; } + + +bool CustomMessage::CreateGetItemMessage(std::string tableID, GetItemID giid, ItemID iid, CustomMessageEntry messages) { + FormatCustomMessage(messages.english, iid); + FormatCustomMessage(messages.german, iid); + FormatCustomMessage(messages.french, iid); + const uint16_t textID = giid; + return InsertCustomMessage(tableID, textID, messages); +} + +bool CustomMessage::CreateMessage(std::string tableID, uint16_t textID, CustomMessageEntry messages) { + FormatCustomMessage(messages.english); + FormatCustomMessage(messages.german); + FormatCustomMessage(messages.french); + return InsertCustomMessage(tableID, textID, messages); +} + std::string CustomMessage::RetrieveMessage(std::string tableID, uint16_t textID) { std::unordered_map::const_iterator result = messageTables.find(tableID); if (result == messageTables.end()) { diff --git a/soh/soh/Enhancements/custom_message/CustomMessage.h b/soh/soh/Enhancements/custom_message/CustomMessage.h index 4d35cfb9a..66afaf15c 100644 --- a/soh/soh/Enhancements/custom_message/CustomMessage.h +++ b/soh/soh/Enhancements/custom_message/CustomMessage.h @@ -31,6 +31,8 @@ class CustomMessage { void ReplaceSpecialCharacters(std::string &string); void ReplaceColors(std::string& string); void FormatCustomMessage(std::string& message, ItemID iid); + void FormatCustomMessage(std::string& message); + bool InsertCustomMessage(std::string tableID, uint16_t textID, CustomMessageEntry messages); std::string MESSAGE_END(); std::string ITEM_OBTAINED(uint8_t x); @@ -46,6 +48,7 @@ class CustomMessage { ~CustomMessage(); bool CreateGetItemMessage(std::string tableID, GetItemID giid, ItemID iid, CustomMessageEntry messages); + bool CreateMessage(std::string tableID, uint16_t textID, CustomMessageEntry messages); std::string RetrieveMessage(std::string tableID, uint16_t textID); bool AddCustomMessageTable(std::string tableID); }; \ No newline at end of file From c5f66373c3b125497216eb4ca59b034ec344fc28 Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Tue, 19 Jul 2022 22:51:39 -0400 Subject: [PATCH 16/71] Adds ability to store and retrieve textbox size and position. --- soh/include/z64.h | 3 ++ .../custom_message/CustomMessage.cpp | 5 ++- .../custom_message/CustomMessage.h | 7 +++- soh/soh/Enhancements/randomizer/randomizer.h | 7 ++-- .../randomizer/randomizer_custom_messages.cpp | 42 +++++++++++-------- soh/soh/OTRGlobals.cpp | 8 ++-- soh/soh/z_message_OTR.cpp | 5 ++- soh/src/code/z_message_PAL.c | 2 +- 8 files changed, 50 insertions(+), 29 deletions(-) diff --git a/soh/include/z64.h b/soh/include/z64.h index fdc634e58..a16134f08 100644 --- a/soh/include/z64.h +++ b/soh/include/z64.h @@ -30,6 +30,9 @@ #include "ichain.h" #include "regs.h" +#define NOGDI +#define WIN32_LEAN_AND_MEAN + #if defined(_WIN64) || defined(__x86_64__) || defined(__arm64__) #define _SOH64 #endif diff --git a/soh/soh/Enhancements/custom_message/CustomMessage.cpp b/soh/soh/Enhancements/custom_message/CustomMessage.cpp index 437c16ac8..20170a7ba 100644 --- a/soh/soh/Enhancements/custom_message/CustomMessage.cpp +++ b/soh/soh/Enhancements/custom_message/CustomMessage.cpp @@ -100,7 +100,7 @@ bool CustomMessage::CreateMessage(std::string tableID, uint16_t textID, CustomMe return InsertCustomMessage(tableID, textID, messages); } -std::string CustomMessage::RetrieveMessage(std::string tableID, uint16_t textID) { +std::string CustomMessage::RetrieveMessage(GlobalContext* globalCtx, std::string tableID, uint16_t textID) { std::unordered_map::const_iterator result = messageTables.find(tableID); if (result == messageTables.end()) { return ""; @@ -111,6 +111,9 @@ std::string CustomMessage::RetrieveMessage(std::string tableID, uint16_t textID) return ""; } CustomMessageEntry messages = message_pair->second; + MessageContext* msgCtx = &globalCtx->msgCtx; + Font* font = &msgCtx->font; + font->charTexBuf[0] = (messages.textBoxType << 4) | messages.textBoxPos; switch (gSaveContext.language) { case LANGUAGE_FRA: return messages.french; diff --git a/soh/soh/Enhancements/custom_message/CustomMessage.h b/soh/soh/Enhancements/custom_message/CustomMessage.h index 66afaf15c..513cdaf60 100644 --- a/soh/soh/Enhancements/custom_message/CustomMessage.h +++ b/soh/soh/Enhancements/custom_message/CustomMessage.h @@ -1,7 +1,8 @@ #pragma once #include #include -#include "variables.h" +#include "z64.h" +#include #undef MESSAGE_END @@ -15,6 +16,8 @@ #define QM_BLACK 0x47 typedef struct { + TextBoxType textBoxType; + TextBoxPosition textBoxPos; std::string english; std::string german; std::string french; @@ -49,6 +52,6 @@ class CustomMessage { bool CreateGetItemMessage(std::string tableID, GetItemID giid, ItemID iid, CustomMessageEntry messages); bool CreateMessage(std::string tableID, uint16_t textID, CustomMessageEntry messages); - std::string RetrieveMessage(std::string tableID, uint16_t textID); + std::string RetrieveMessage(GlobalContext* globalCtx, std::string tableID, uint16_t textID); bool AddCustomMessageTable(std::string tableID); }; \ No newline at end of file diff --git a/soh/soh/Enhancements/randomizer/randomizer.h b/soh/soh/Enhancements/randomizer/randomizer.h index 22047a9d8..5f9f1f1bc 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.h +++ b/soh/soh/Enhancements/randomizer/randomizer.h @@ -4,8 +4,8 @@ #include #include "../../../include/ultra64.h" #include "../../../include/z64item.h" -#include #include +#include class Randomizer { private: @@ -16,7 +16,6 @@ class Randomizer { std::string ganonHintText; std::string ganonText; std::unordered_map randoSettings; - static const std::string customMessageTableID; GetItemID GetItemFromGet(RandomizerGet randoGet, GetItemID ogItemId); GetItemID GetItemFromActor(s16 actorId, s16 actorParams, s16 sceneNum, GetItemID ogItemId); void ParseRandomizerSettingsFile(const char* spoilerFileName); @@ -27,6 +26,8 @@ class Randomizer { Randomizer(); ~Randomizer(); + static const std::string customMessageTableID; + static Sprite* GetSeedTexture(uint8_t index); s16 GetItemModelFromId(s16 itemId); s32 GetItemIDFromGetItemID(s32 getItemId); @@ -43,7 +44,7 @@ class Randomizer { std::string GetHintFromCheck(RandomizerCheck check); GetItemID GetRandomizedItemIdFromKnownCheck(RandomizerCheck randomizerCheck, GetItemID ogId); GetItemID GetRandomizedItemId(GetItemID ogId, s16 actorId, s16 actorParams, s16 sceneNum); - std::string GetCustomGetItemMessage(GetItemID giid); + //std::string GetCustomGetItemMessage(GlobalContext* globalCtx, GetItemID giid); static void CreateCustomMessages(); }; diff --git a/soh/soh/Enhancements/randomizer/randomizer_custom_messages.cpp b/soh/soh/Enhancements/randomizer/randomizer_custom_messages.cpp index 62e213cda..8ac220fca 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_custom_messages.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_custom_messages.cpp @@ -1,44 +1,52 @@ #include "randomizer.h" #include "soh/Enhancements/custom_message/CustomMessage.h" +#include -#define MESSAGES(eng, ger, fra) {eng, ger, fra} +#define NOGDI +#define WIN32_LEAN_AND_MEAN void Randomizer::CreateCustomMessages() { CustomMessage* customMessage = CustomMessage::Instance; customMessage->AddCustomMessageTable(Randomizer::customMessageTableID); customMessage->CreateGetItemMessage( Randomizer::customMessageTableID, GI_BOTTLE_WITH_BLUE_FIRE, ITEM_BLUE_FIRE, - MESSAGES("You got a %rBottle with Blue &Fire%w! Use it to melt Red Ice!", "", "")); + { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, + "You got a %rBottle with Blue &Fire%w! Use it to melt Red Ice!", "", "" }); customMessage->CreateGetItemMessage( Randomizer::customMessageTableID, GI_BOTTLE_WITH_BIG_POE, ITEM_BIG_POE, - MESSAGES("You got a %rBig Poe in a Bottle%w!&Sell it to the Ghost Shop!", "", "")); + { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, + "You got a %rBig Poe in a Bottle%w!&Sell it to the Ghost Shop!", "", "" }); customMessage->CreateGetItemMessage( Randomizer::customMessageTableID, GI_BOTTLE_WITH_BLUE_POTION, ITEM_POTION_BLUE, - MESSAGES("You got a %rBottle of Blue Potion%w!&Drink it to replenish your&%ghealth%w and %bmagic%w!", "", "")); + { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, + "You got a %rBottle of Blue Potion%w!&Drink it to replenish your&%ghealth%w and %bmagic%w!", "", "" }); customMessage->CreateGetItemMessage( Randomizer::customMessageTableID, GI_BOTTLE_WITH_FISH, ITEM_FISH, - MESSAGES("You got a %rFish in a Bottle%w!&It looks fresh and delicious!&They say Jabu-Jabu loves them!", "", "")); + { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, + "You got a %rFish in a Bottle%w!&It looks fresh and delicious!&They say Jabu-Jabu loves them!", "", "" }); customMessage->CreateGetItemMessage( Randomizer::customMessageTableID, GI_BOTTLE_WITH_BUGS, ITEM_BUG, - { "You got a %rBug in a Bottle%w!&They love to burrow in&dirt holes!", "", "" }); + { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, "You got a %rBug in a Bottle%w!&They love to burrow in&dirt holes!", "", "" }); customMessage->CreateGetItemMessage( Randomizer::customMessageTableID, GI_BOTTLE_WITH_FAIRY, ITEM_FAIRY, - { "You got a %rFairy in a Bottle%w!&Use it wisely!", "", "" }); + { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, "You got a %rFairy in a Bottle%w!&Use it wisely!", "", "" }); customMessage->CreateGetItemMessage( Randomizer::customMessageTableID, GI_BOTTLE_WITH_RED_POTION, ITEM_POTION_RED, - { "You got a %rBottle of Red Potion%w!&Drink it to replenish your&%ghealth%w!", "", "" }); + { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, "You got a %rBottle of Red Potion%w!&Drink it to replenish your&%ghealth%w!", "", "" }); customMessage->CreateGetItemMessage( Randomizer::customMessageTableID, GI_BOTTLE_WITH_GREEN_POTION, ITEM_POTION_GREEN, - { "You got a %rBottle of Green Potion%w!&Drink it to replenish your&%bmagic%w!", "", "" }); + { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, + "You got a %rBottle of Green Potion%w!&Drink it to replenish your&%bmagic%w!", "", "" }); customMessage->CreateGetItemMessage( Randomizer::customMessageTableID, GI_BOTTLE_WITH_POE, ITEM_POE, - { "You got a %rPoe in a Bottle%w!&That creepy Ghost Shop might&be interested in this...", "", "" }); + { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, + "You got a %rPoe in a Bottle%w!&That creepy Ghost Shop might&be interested in this...", "", "" }); } -std::string Randomizer::GetCustomGetItemMessage(GetItemID giid) { - if (!gSaveContext.n64ddFlag) { - return "Not Randomized."; - } - - return CustomMessage::Instance->RetrieveMessage(Randomizer::customMessageTableID, giid); -} \ No newline at end of file +//std::string Randomizer::GetCustomGetItemMessage(GlobalContext* globalCtx, GetItemID giid) { +// if (!gSaveContext.n64ddFlag) { +// return "Not Randomized."; +// } +// +// return CustomMessage::Instance->RetrieveMessage(globalCtx, Randomizer::customMessageTableID, giid); +//} \ No newline at end of file diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 309c0a951..c048d3358 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -1505,8 +1505,8 @@ extern "C" s32 Randomizer_GetItemIdFromKnownCheck(RandomizerCheck randomizerChec return OTRGlobals::Instance->gRandomizer->GetRandomizedItemIdFromKnownCheck(randomizerCheck, ogId); } -extern "C" int Randomizer_GetCustomGetItemMessage(GetItemID giid, char* buffer, const int maxBufferSize) { - const std::string& getItemText = OTRGlobals::Instance->gRandomizer->GetCustomGetItemMessage(giid); +extern "C" int Randomizer_GetCustomGetItemMessage(GlobalContext* globalCtx, GetItemID giid, char* buffer, const int maxBufferSize) { + const std::string& getItemText = CustomMessage::Instance->RetrieveMessage(globalCtx, Randomizer::customMessageTableID, giid); if (getItemText == "") { return false; } @@ -1523,7 +1523,7 @@ extern "C" int CustomMessage_RetrieveIfExists(GlobalContext* globalCtx) { if (textId == 0xF8) { font->charTexBuf[0] = 0x23; if (msgCtx->msgLength = font->msgLength = Randomizer_GetCustomGetItemMessage( - (GetItemID)GET_PLAYER(globalCtx)->getItemId, buffer, maxBufferSize)) { + globalCtx, (GetItemID)GET_PLAYER(globalCtx)->getItemId, buffer, maxBufferSize)) { return true; } else { switch (gSaveContext.language) { @@ -1551,7 +1551,7 @@ extern "C" int CustomMessage_RetrieveIfExists(GlobalContext* globalCtx) { } else { textId = 0x00B5; } - message = CustomMessage::Instance->RetrieveMessage("BaseGameOverrides", textId); + message = CustomMessage::Instance->RetrieveMessage(globalCtx, "BaseGameOverrides", textId); if (message != "") { return msgCtx->msgLength = font->msgLength = CopyStringToCharBuffer(message, buffer, maxBufferSize); } diff --git a/soh/soh/z_message_OTR.cpp b/soh/soh/z_message_OTR.cpp index e6ef4bb76..503d3e14b 100644 --- a/soh/soh/z_message_OTR.cpp +++ b/soh/soh/z_message_OTR.cpp @@ -100,6 +100,7 @@ extern "C" void OTRMessage_Init() CustomMessage::Instance->CreateGetItemMessage( customMessageTableID, (GetItemID)0x00B4, ITEM_SKULL_TOKEN, { + TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, "You got a %rGold Skulltula Token%w!&You've collected %r\x19%w tokens&in total!\x0E\x3C", "Du erhlst ein %rGoldene&Skulltula-Symbol%w! Du hast&insgesamt %r\x19%w symbol gesammelt!\x0E\x3C", "Vous obtenez un %rSymbole de&Skulltula d'or%w! Vous avez&collect %r\x19\%w symboles en tout!\x0E\x3C" @@ -107,7 +108,9 @@ extern "C" void OTRMessage_Init() ); CustomMessage::Instance->CreateGetItemMessage( customMessageTableID, (GetItemID)0x00B5, ITEM_SKULL_TOKEN, - { "You got a %rGold Skulltula Token%w!&You've collected %r\x19%w tokens&in total!", + { + TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, + "You got a %rGold Skulltula Token%w!&You've collected %r\x19%w tokens&in total!", "Du erhlst ein %rGoldene&Skulltula-Symbol%w! Du hast&insgesamt %r\x19%w symbol gesammelt!", "Vous obtenez un %rSymbole de&Skulltula d'or%w! Vous avez&collect %r\x19\%w symboles en tout!" }); } \ No newline at end of file diff --git a/soh/src/code/z_message_PAL.c b/soh/src/code/z_message_PAL.c index 196821e9e..e44e5f325 100644 --- a/soh/src/code/z_message_PAL.c +++ b/soh/src/code/z_message_PAL.c @@ -1709,7 +1709,7 @@ void Message_OpenText(GlobalContext* globalCtx, u16 textId) { msgCtx->msgLength = font->msgLength = Randomizer_CopyHintFromCheck(hintCheck, font->msgBuf, sizeof(font->msgBuf)); } else if (gSaveContext.n64ddFlag && (textId == 0x7040 || textId == 0x7088)) { // rando hints at altar - msgCtx->msgLength = font->msgLength = CopyAltarMessage(font->msgBuf, sizeof(font->msgBuf)); + msgCtx->msgLength = font->msgLength = Randomizer_CopyAltarMessage(font->msgBuf, sizeof(font->msgBuf)); } else if (gSaveContext.n64ddFlag && (textId == 0x10A2 || textId == 0x10DC || textId == 0x10DD)) { msgCtx->msgLength = font->msgLength = CopyScrubMessage(textId, font->msgBuf, sizeof(font->msgBuf)); } else if (gSaveContext.n64ddFlag && textId == 0x70CC) { From b5dc097587dfe3f75362af9cbe6720991f3524d0 Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Thu, 21 Jul 2022 13:05:15 -0400 Subject: [PATCH 17/71] Cleanup and move most hint logic to CustomMessage. Haven't removed where rando stores the hints for itself and the ganon and altar hints are still pulled from the randomizer class' local storage, but gossip stone hints are pulled from the custom message table now. --- .../custom_message/CustomMessage.cpp | 28 +++--- .../custom_message/CustomMessage.h | 7 +- .../Enhancements/randomizer/randomizer.cpp | 68 ++++++++++++++- soh/soh/Enhancements/randomizer/randomizer.h | 5 +- soh/soh/OTRGlobals.cpp | 87 ++++++++++++------- soh/soh/OTRGlobals.h | 2 +- soh/soh/z_message_OTR.cpp | 1 - soh/src/code/z_message_PAL.c | 34 +------- 8 files changed, 141 insertions(+), 91 deletions(-) diff --git a/soh/soh/Enhancements/custom_message/CustomMessage.cpp b/soh/soh/Enhancements/custom_message/CustomMessage.cpp index 20170a7ba..7f26fb616 100644 --- a/soh/soh/Enhancements/custom_message/CustomMessage.cpp +++ b/soh/soh/Enhancements/custom_message/CustomMessage.cpp @@ -100,29 +100,27 @@ bool CustomMessage::CreateMessage(std::string tableID, uint16_t textID, CustomMe return InsertCustomMessage(tableID, textID, messages); } -std::string CustomMessage::RetrieveMessage(GlobalContext* globalCtx, std::string tableID, uint16_t textID) { +CustomMessageEntry CustomMessage::RetrieveMessage(std::string tableID, uint16_t textID) { std::unordered_map::const_iterator result = messageTables.find(tableID); if (result == messageTables.end()) { - return ""; + return NULL_CUSTOM_MESSAGE; } CustomMessageTable messageTable = result->second; std::unordered_map::const_iterator message_pair = messageTable.find(textID); if (message_pair == messageTable.end()) { - return ""; + return NULL_CUSTOM_MESSAGE; } - CustomMessageEntry messages = message_pair->second; - MessageContext* msgCtx = &globalCtx->msgCtx; - Font* font = &msgCtx->font; - font->charTexBuf[0] = (messages.textBoxType << 4) | messages.textBoxPos; - switch (gSaveContext.language) { - case LANGUAGE_FRA: - return messages.french; - case LANGUAGE_GER: - return messages.german; - case LANGUAGE_ENG: - default: - return messages.english; + CustomMessageEntry message = message_pair->second; + return message; +} + +bool CustomMessage::ClearMessageTable(std::string tableID) { + auto result = messageTables.find(tableID); + if (result == messageTables.end()) { + return false; } + auto& messageTable = result->second; + messageTable.clear(); } bool CustomMessage::AddCustomMessageTable(std::string tableID) { diff --git a/soh/soh/Enhancements/custom_message/CustomMessage.h b/soh/soh/Enhancements/custom_message/CustomMessage.h index 513cdaf60..465d1fafc 100644 --- a/soh/soh/Enhancements/custom_message/CustomMessage.h +++ b/soh/soh/Enhancements/custom_message/CustomMessage.h @@ -1,7 +1,6 @@ #pragma once #include #include -#include "z64.h" #include #undef MESSAGE_END @@ -23,6 +22,9 @@ typedef struct { std::string french; } CustomMessageEntry; +#define NULL_CUSTOM_MESSAGE \ + { (TextBoxType)(-1), (TextBoxPosition)(-1), "", "", "" } + typedef std::unordered_map CustomMessageTable; class CustomMessage { @@ -52,6 +54,7 @@ class CustomMessage { bool CreateGetItemMessage(std::string tableID, GetItemID giid, ItemID iid, CustomMessageEntry messages); bool CreateMessage(std::string tableID, uint16_t textID, CustomMessageEntry messages); - std::string RetrieveMessage(GlobalContext* globalCtx, std::string tableID, uint16_t textID); + CustomMessageEntry RetrieveMessage(std::string tableID, uint16_t textID); + bool ClearMessageTable(std::string tableID); bool AddCustomMessageTable(std::string tableID); }; \ No newline at end of file diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index 2e47c7c80..77e426baf 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -14,6 +14,7 @@ #include "3drando/rando_main.hpp" #include #include "Lib/ImGui/imgui_internal.h" +#include using json = nlohmann::json; @@ -21,7 +22,8 @@ std::unordered_map gSeedTextures; u8 generated; -const std::string Randomizer::customMessageTableID = "Randomizer"; +const std::string Randomizer::getItemMessageTableID = "Randomizer"; +const std::string Randomizer::hintMessageTableID = "RandomizerHints"; Randomizer::Randomizer() { Sprite bowSprite = { dgFairyBowIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 0 }; @@ -1479,6 +1481,22 @@ void Randomizer::LoadHintLocations(const char* spoilerFileName) { ParseHintLocationsFile(spoilerFileName); } + CustomMessage::Instance->ClearMessageTable(Randomizer::hintMessageTableID); + CustomMessage::Instance->AddCustomMessageTable(Randomizer::hintMessageTableID); + + CustomMessage::Instance->CreateMessage( + Randomizer::hintMessageTableID, 0x7040, + { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, gSaveContext.childAltarText, "", "" }); + CustomMessage::Instance->CreateMessage( + Randomizer::hintMessageTableID, 0x7088, + { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, gSaveContext.adultAltarText, "", "" }); + CustomMessage::Instance->CreateMessage( + Randomizer::hintMessageTableID, 0x70CC, + { TEXTBOX_TYPE_BLACK, TEXTBOX_POS_BOTTOM, gSaveContext.ganonHintText, "", "" }); + CustomMessage::Instance->CreateMessage( + Randomizer::hintMessageTableID, 0x70CD, + { TEXTBOX_TYPE_BLACK, TEXTBOX_POS_BOTTOM, gSaveContext.ganonText, "", "" }); + this->childAltarText = gSaveContext.childAltarText; this->adultAltarText = gSaveContext.adultAltarText; this->ganonHintText = gSaveContext.ganonHintText; @@ -1487,6 +1505,8 @@ void Randomizer::LoadHintLocations(const char* spoilerFileName) { for (auto hintLocation : gSaveContext.hintLocations) { if(hintLocation.check == RC_LINKS_POCKET) break; this->hintLocations[hintLocation.check] = hintLocation.hintText; + CustomMessage::Instance->CreateMessage( + Randomizer::hintMessageTableID, hintLocation.check, { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, hintLocation.hintText, "", "" }); } } @@ -2409,9 +2429,9 @@ std::string Randomizer::GetGanonHintText() const { return ganonHintText; } -std::string Randomizer::GetHintFromCheck(RandomizerCheck check) { - return this->hintLocations[check]; -} +//CustomMessageEntry Randomizer::GetHintFromCheck(RandomizerCheck check) { +// return CustomMessage::Instance->RetrieveMessage(hintMessageTableID, check); +//} u8 Randomizer::GetRandoSettingValue(RandomizerSettingKey randoSettingKey) { return this->randoSettings[randoSettingKey]; @@ -4748,6 +4768,46 @@ void DrawRandoEditor(bool& open) { }*/ +void Randomizer::CreateCustomMessages() { + CustomMessage* customMessage = CustomMessage::Instance; + customMessage->AddCustomMessageTable(Randomizer::getItemMessageTableID); + customMessage->CreateGetItemMessage(Randomizer::getItemMessageTableID, GI_BOTTLE_WITH_BLUE_FIRE, ITEM_BLUE_FIRE, + { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, + "You got a %rBottle with Blue &Fire%w! Use it to melt Red Ice!", "", + "" }); + customMessage->CreateGetItemMessage(Randomizer::getItemMessageTableID, GI_BOTTLE_WITH_BIG_POE, ITEM_BIG_POE, + { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, + "You got a %rBig Poe in a Bottle%w!&Sell it to the Ghost Shop!", "", + "" }); + customMessage->CreateGetItemMessage( + Randomizer::getItemMessageTableID, GI_BOTTLE_WITH_BLUE_POTION, ITEM_POTION_BLUE, + { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, + "You got a %rBottle of Blue Potion%w!&Drink it to replenish your&%ghealth%w and %bmagic%w!", "", "" }); + customMessage->CreateGetItemMessage( + Randomizer::getItemMessageTableID, GI_BOTTLE_WITH_FISH, ITEM_FISH, + { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, + "You got a %rFish in a Bottle%w!&It looks fresh and delicious!&They say Jabu-Jabu loves them!", "", "" }); + customMessage->CreateGetItemMessage(Randomizer::getItemMessageTableID, GI_BOTTLE_WITH_BUGS, ITEM_BUG, + { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, + "You got a %rBug in a Bottle%w!&They love to burrow in&dirt holes!", "", + "" }); + customMessage->CreateGetItemMessage( + Randomizer::getItemMessageTableID, GI_BOTTLE_WITH_FAIRY, ITEM_FAIRY, + { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, "You got a %rFairy in a Bottle%w!&Use it wisely!", "", "" }); + customMessage->CreateGetItemMessage( + Randomizer::getItemMessageTableID, GI_BOTTLE_WITH_RED_POTION, ITEM_POTION_RED, + { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, + "You got a %rBottle of Red Potion%w!&Drink it to replenish your&%ghealth%w!", "", "" }); + customMessage->CreateGetItemMessage( + Randomizer::getItemMessageTableID, GI_BOTTLE_WITH_GREEN_POTION, ITEM_POTION_GREEN, + { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, + "You got a %rBottle of Green Potion%w!&Drink it to replenish your&%bmagic%w!", "", "" }); + customMessage->CreateGetItemMessage( + Randomizer::getItemMessageTableID, GI_BOTTLE_WITH_POE, ITEM_POE, + { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, + "You got a %rPoe in a Bottle%w!&That creepy Ghost Shop might&be interested in this...", "", "" }); + } + void InitRando() { SohImGui::AddWindow("Randomizer", "Randomizer Settings", DrawRandoEditor); Randomizer::CreateCustomMessages(); diff --git a/soh/soh/Enhancements/randomizer/randomizer.h b/soh/soh/Enhancements/randomizer/randomizer.h index 5f9f1f1bc..ec27d684d 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.h +++ b/soh/soh/Enhancements/randomizer/randomizer.h @@ -26,7 +26,8 @@ class Randomizer { Randomizer(); ~Randomizer(); - static const std::string customMessageTableID; + static const std::string getItemMessageTableID; + static const std::string hintMessageTableID; static Sprite* GetSeedTexture(uint8_t index); s16 GetItemModelFromId(s16 itemId); @@ -41,7 +42,7 @@ class Randomizer { std::string GetAdultAltarText() const; std::string GetGanonText() const; std::string GetGanonHintText() const; - std::string GetHintFromCheck(RandomizerCheck check); + //CustomMessageEntry GetHintFromCheck(RandomizerCheck check); GetItemID GetRandomizedItemIdFromKnownCheck(RandomizerCheck randomizerCheck, GetItemID ogId); GetItemID GetRandomizedItemId(GetItemID ogId, s16 actorId, s16 actorParams, s16 sceneNum); //std::string GetCustomGetItemMessage(GlobalContext* globalCtx, GetItemID giid); diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index c048d3358..f570c3b10 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -36,15 +36,14 @@ #include "Enhancements/cosmetics/CosmeticsEditor.h" #include "Enhancements/debugconsole.h" #include "Enhancements/debugger/debugger.h" -#include "Enhancements/randomizer/randomizer.h" #include -#include #include "Enhancements/n64_weird_frame_data.inc" #include "soh/frame_interpolation.h" #include "Utils/BitConverter.h" #include "variables.h" #include "macros.h" #include +#include #ifdef __APPLE__ #include @@ -1490,11 +1489,11 @@ extern "C" int Randomizer_CopyGanonHintText(char* buffer, const int maxBufferSiz return CopyStringToCharBuffer(ganonText, buffer, maxBufferSize); } -extern "C" int Randomizer_CopyHintFromCheck(RandomizerCheck check, char* buffer, const int maxBufferSize) { +extern "C" CustomMessageEntry Randomizer_CopyHintFromCheck(RandomizerCheck check) { // we don't want to make a copy of the std::string returned from GetHintFromCheck // so we're just going to let RVO take care of it - const std::string& hintText = OTRGlobals::Instance->gRandomizer->GetHintFromCheck(check); - return CopyStringToCharBuffer(hintText, buffer, maxBufferSize); + const CustomMessageEntry hintText = CustomMessage::Instance->RetrieveMessage(Randomizer::hintMessageTableID, check); + return hintText; } extern "C" s32 Randomizer_GetRandomizedItemId(GetItemID ogId, s16 actorId, s16 actorParams, s16 sceneNum) { @@ -1505,12 +1504,9 @@ extern "C" s32 Randomizer_GetItemIdFromKnownCheck(RandomizerCheck randomizerChec return OTRGlobals::Instance->gRandomizer->GetRandomizedItemIdFromKnownCheck(randomizerCheck, ogId); } -extern "C" int Randomizer_GetCustomGetItemMessage(GlobalContext* globalCtx, GetItemID giid, char* buffer, const int maxBufferSize) { - const std::string& getItemText = CustomMessage::Instance->RetrieveMessage(globalCtx, Randomizer::customMessageTableID, giid); - if (getItemText == "") { - return false; - } - return CopyStringToCharBuffer(getItemText, buffer, maxBufferSize); +extern "C" CustomMessageEntry Randomizer_GetCustomGetItemMessage(GetItemID giid, char* buffer, const int maxBufferSize) { + const CustomMessageEntry getItemText = CustomMessage::Instance->RetrieveMessage(Randomizer::getItemMessageTableID, giid); + return getItemText; } extern "C" int CustomMessage_RetrieveIfExists(GlobalContext* globalCtx) { @@ -1519,42 +1515,67 @@ extern "C" int CustomMessage_RetrieveIfExists(GlobalContext* globalCtx) { Font* font = &msgCtx->font; char* buffer = font->msgBuf; const int maxBufferSize = sizeof(font->msgBuf); + CustomMessageEntry messageEntry; if (gSaveContext.n64ddFlag) { if (textId == 0xF8) { - font->charTexBuf[0] = 0x23; - if (msgCtx->msgLength = font->msgLength = Randomizer_GetCustomGetItemMessage( - globalCtx, (GetItemID)GET_PLAYER(globalCtx)->getItemId, buffer, maxBufferSize)) { - return true; - } else { - switch (gSaveContext.language) { - case LANGUAGE_FRA: - return msgCtx->msgLength = font->msgLength = CopyStringToCharBuffer( - "Il n'y a pas de message personnalisé pour cet élément.\x02", buffer, maxBufferSize); - case LANGUAGE_GER: - return msgCtx->msgLength = font->msgLength = CopyStringToCharBuffer( - "Für diesen Artikel gibt es keine benutzerdefinierte Nachricht.\x02", buffer, - maxBufferSize); - case LANGUAGE_ENG: - default: - return msgCtx->msgLength = font->msgLength = CopyStringToCharBuffer( - "There is no custom message for this item.\x02", buffer, maxBufferSize); + messageEntry = + Randomizer_GetCustomGetItemMessage((GetItemID)GET_PLAYER(globalCtx)->getItemId, buffer, maxBufferSize); + } + if (textId == 0x2053 && Randomizer_GetSettingValue(RSK_GOSSIP_STONE_HINTS) != 0 && + (Randomizer_GetSettingValue(RSK_GOSSIP_STONE_HINTS) == 1 || + (Randomizer_GetSettingValue(RSK_GOSSIP_STONE_HINTS) == 2 && + Player_GetMask(globalCtx) == PLAYER_MASK_TRUTH) || + (Randomizer_GetSettingValue(RSK_GOSSIP_STONE_HINTS) == 3 && CHECK_QUEST_ITEM(QUEST_STONE_OF_AGONY)))) { + + s16 actorParams = msgCtx->talkActor->params; + + // if we're in a generic grotto + if (globalCtx->sceneNum == 62 && actorParams == 14360) { + // look for the chest in the actorlist to determine + // which grotto we're in + int numOfActorLists = + sizeof(globalCtx->actorCtx.actorLists) / sizeof(globalCtx->actorCtx.actorLists[0]); + for (int i = 0; i < numOfActorLists; i++) { + if (globalCtx->actorCtx.actorLists[i].length) { + if (globalCtx->actorCtx.actorLists[i].head->id == 10) { + // set the params for the hint check to be negative chest params + actorParams = 0 - globalCtx->actorCtx.actorLists[i].head->params; + } + } } } + + RandomizerCheck hintCheck = + Randomizer_GetCheckFromActor(globalCtx->sceneNum, msgCtx->talkActor->id, actorParams); + + messageEntry = Randomizer_CopyHintFromCheck(hintCheck); } } if (textId == 0x00B4 || textId == 0x00B5) { if (CVar_GetS32("gInjectSkulltulaCount", 0) != 0) { font->charTexBuf[0] = 0x03; - std::string message; if (CVar_GetS32("gSkulltulaFreeze", 0) != 0) { textId = 0x00B4; } else { textId = 0x00B5; } - message = CustomMessage::Instance->RetrieveMessage(globalCtx, "BaseGameOverrides", textId); - if (message != "") { - return msgCtx->msgLength = font->msgLength = CopyStringToCharBuffer(message, buffer, maxBufferSize); - } + messageEntry = CustomMessage::Instance->RetrieveMessage("BaseGameOverrides", textId); + } + } + if (messageEntry.textBoxType != -1) { + font->charTexBuf[0] = (messageEntry.textBoxType << 4) | messageEntry.textBoxPos; + switch (gSaveContext.language) { + case LANGUAGE_FRA: + return msgCtx->msgLength = font->msgLength = + CopyStringToCharBuffer(messageEntry.french, buffer, maxBufferSize); + case LANGUAGE_GER: + return msgCtx->msgLength = font->msgLength = + CopyStringToCharBuffer(messageEntry.german, buffer, maxBufferSize); + + case LANGUAGE_ENG: + default: + return msgCtx->msgLength = font->msgLength = + CopyStringToCharBuffer(messageEntry.english, buffer, maxBufferSize); } } return false; diff --git a/soh/soh/OTRGlobals.h b/soh/soh/OTRGlobals.h index 83618f994..4a924ed61 100644 --- a/soh/soh/OTRGlobals.h +++ b/soh/soh/OTRGlobals.h @@ -9,6 +9,7 @@ #ifdef __cplusplus #include "Enhancements/savestates.h" #include "Enhancements/randomizer/randomizer.h" + class OTRGlobals { public: @@ -87,7 +88,6 @@ void Randomizer_LoadSettings(const char* spoilerFileName); u8 Randomizer_GetSettingValue(RandomizerSettingKey randoSettingKey); RandomizerCheck Randomizer_GetCheckFromActor(s16 actorId, s16 actorParams, s16 sceneNum); int Randomizer_CopyAltarMessage(char* buffer, const int maxBufferSize); -int Randomizer_CopyHintFromCheck(RandomizerCheck check, char* buffer, const int maxBufferSize); int Randomizer_CopyGanonText(char* buffer, const int maxBufferSize); int Randomizer_CopyGanonHintText(char* buffer, const int maxBufferSize); void Randomizer_LoadHintLocations(const char* spoilerFileName); diff --git a/soh/soh/z_message_OTR.cpp b/soh/soh/z_message_OTR.cpp index 503d3e14b..c09286fad 100644 --- a/soh/soh/z_message_OTR.cpp +++ b/soh/soh/z_message_OTR.cpp @@ -1,7 +1,6 @@ #include "OTRGlobals.h" #include "ResourceMgr.h" #include "Scene.h" -#include "message_data_static.h" #include "Utils/StringHelper.h" #include "global.h" #include "vt.h" diff --git a/soh/src/code/z_message_PAL.c b/soh/src/code/z_message_PAL.c index e44e5f325..7a0aed9b2 100644 --- a/soh/src/code/z_message_PAL.c +++ b/soh/src/code/z_message_PAL.c @@ -1675,39 +1675,7 @@ void Message_OpenText(GlobalContext* globalCtx, u16 textId) { //font->msgLength, __FILE__, __LINE__); } else { Message_FindMessage(globalCtx, textId); - // if we're rando'd and talking to a gossip stone - if (gSaveContext.n64ddFlag && - textId == 0x2053 && - Randomizer_GetSettingValue(RSK_GOSSIP_STONE_HINTS) != 0 && - (Randomizer_GetSettingValue(RSK_GOSSIP_STONE_HINTS) == 1 || - (Randomizer_GetSettingValue(RSK_GOSSIP_STONE_HINTS) == 2 && - Player_GetMask(globalCtx) == PLAYER_MASK_TRUTH) || - (Randomizer_GetSettingValue(RSK_GOSSIP_STONE_HINTS) == 3 && - CHECK_QUEST_ITEM(QUEST_STONE_OF_AGONY)))) { - - s16 actorParams = msgCtx->talkActor->params; - - // if we're in a generic grotto - if (globalCtx->sceneNum == 62 && actorParams == 14360) { - // look for the chest in the actorlist to determine - // which grotto we're in - int numOfActorLists = sizeof(globalCtx->actorCtx.actorLists)/sizeof(globalCtx->actorCtx.actorLists[0]); - for(int i = 0; i < numOfActorLists; i++) { - if(globalCtx->actorCtx.actorLists[i].length) { - if(globalCtx->actorCtx.actorLists[i].head->id == 10) { - // set the params for the hint check to be negative chest params - actorParams = 0 - globalCtx->actorCtx.actorLists[i].head->params; - } - } - } - } - - RandomizerCheck hintCheck = Randomizer_GetCheckFromActor(globalCtx->sceneNum, msgCtx->talkActor->id, actorParams); - - // Pass the sizeof the message buffer so we don't hardcode any sizes and can rely on globals. - // If no hint can be found, this just returns 0 size and doesn't modify the buffer, so no worries. - msgCtx->msgLength = font->msgLength = Randomizer_CopyHintFromCheck(hintCheck, font->msgBuf, sizeof(font->msgBuf)); - } else if (gSaveContext.n64ddFlag && (textId == 0x7040 || textId == 0x7088)) { + if (gSaveContext.n64ddFlag && (textId == 0x7040 || textId == 0x7088)) { // rando hints at altar msgCtx->msgLength = font->msgLength = Randomizer_CopyAltarMessage(font->msgBuf, sizeof(font->msgBuf)); } else if (gSaveContext.n64ddFlag && (textId == 0x10A2 || textId == 0x10DC || textId == 0x10DD)) { From 21c585b2cea03e5eaa5331b454fcf50cdacfafac Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Thu, 21 Jul 2022 13:10:04 -0400 Subject: [PATCH 18/71] Removes randomizer_custom_messages, as I relocated its logic elsewhere. --- soh/soh.vcxproj | 1 - .../randomizer/randomizer_custom_messages.cpp | 52 ------------------- 2 files changed, 53 deletions(-) delete mode 100644 soh/soh/Enhancements/randomizer/randomizer_custom_messages.cpp diff --git a/soh/soh.vcxproj b/soh/soh.vcxproj index 974fb25c8..1c1f3784a 100644 --- a/soh/soh.vcxproj +++ b/soh/soh.vcxproj @@ -236,7 +236,6 @@ - diff --git a/soh/soh/Enhancements/randomizer/randomizer_custom_messages.cpp b/soh/soh/Enhancements/randomizer/randomizer_custom_messages.cpp deleted file mode 100644 index 8ac220fca..000000000 --- a/soh/soh/Enhancements/randomizer/randomizer_custom_messages.cpp +++ /dev/null @@ -1,52 +0,0 @@ -#include "randomizer.h" -#include "soh/Enhancements/custom_message/CustomMessage.h" -#include - -#define NOGDI -#define WIN32_LEAN_AND_MEAN - -void Randomizer::CreateCustomMessages() { - CustomMessage* customMessage = CustomMessage::Instance; - customMessage->AddCustomMessageTable(Randomizer::customMessageTableID); - customMessage->CreateGetItemMessage( - Randomizer::customMessageTableID, GI_BOTTLE_WITH_BLUE_FIRE, ITEM_BLUE_FIRE, - { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, - "You got a %rBottle with Blue &Fire%w! Use it to melt Red Ice!", "", "" }); - customMessage->CreateGetItemMessage( - Randomizer::customMessageTableID, GI_BOTTLE_WITH_BIG_POE, ITEM_BIG_POE, - { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, - "You got a %rBig Poe in a Bottle%w!&Sell it to the Ghost Shop!", "", "" }); - customMessage->CreateGetItemMessage( - Randomizer::customMessageTableID, GI_BOTTLE_WITH_BLUE_POTION, ITEM_POTION_BLUE, - { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, - "You got a %rBottle of Blue Potion%w!&Drink it to replenish your&%ghealth%w and %bmagic%w!", "", "" }); - customMessage->CreateGetItemMessage( - Randomizer::customMessageTableID, GI_BOTTLE_WITH_FISH, ITEM_FISH, - { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, - "You got a %rFish in a Bottle%w!&It looks fresh and delicious!&They say Jabu-Jabu loves them!", "", "" }); - customMessage->CreateGetItemMessage( - Randomizer::customMessageTableID, GI_BOTTLE_WITH_BUGS, ITEM_BUG, - { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, "You got a %rBug in a Bottle%w!&They love to burrow in&dirt holes!", "", "" }); - customMessage->CreateGetItemMessage( - Randomizer::customMessageTableID, GI_BOTTLE_WITH_FAIRY, ITEM_FAIRY, - { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, "You got a %rFairy in a Bottle%w!&Use it wisely!", "", "" }); - customMessage->CreateGetItemMessage( - Randomizer::customMessageTableID, GI_BOTTLE_WITH_RED_POTION, ITEM_POTION_RED, - { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, "You got a %rBottle of Red Potion%w!&Drink it to replenish your&%ghealth%w!", "", "" }); - customMessage->CreateGetItemMessage( - Randomizer::customMessageTableID, GI_BOTTLE_WITH_GREEN_POTION, ITEM_POTION_GREEN, - { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, - "You got a %rBottle of Green Potion%w!&Drink it to replenish your&%bmagic%w!", "", "" }); - customMessage->CreateGetItemMessage( - Randomizer::customMessageTableID, GI_BOTTLE_WITH_POE, ITEM_POE, - { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, - "You got a %rPoe in a Bottle%w!&That creepy Ghost Shop might&be interested in this...", "", "" }); -} - -//std::string Randomizer::GetCustomGetItemMessage(GlobalContext* globalCtx, GetItemID giid) { -// if (!gSaveContext.n64ddFlag) { -// return "Not Randomized."; -// } -// -// return CustomMessage::Instance->RetrieveMessage(globalCtx, Randomizer::customMessageTableID, giid); -//} \ No newline at end of file From a21998c489518df35fd919efe21846360e534aca Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Sun, 24 Jul 2022 18:47:55 -0400 Subject: [PATCH 19/71] Does some refactoring of rando custom message registration The goal was less verbosity when adding new get-item messages later. --- .../custom_message/CustomMessage.h | 9 ++ .../Enhancements/randomizer/randomizer.cpp | 94 ++++++++++++------- 2 files changed, 67 insertions(+), 36 deletions(-) diff --git a/soh/soh/Enhancements/custom_message/CustomMessage.h b/soh/soh/Enhancements/custom_message/CustomMessage.h index 465d1fafc..69ddcbe61 100644 --- a/soh/soh/Enhancements/custom_message/CustomMessage.h +++ b/soh/soh/Enhancements/custom_message/CustomMessage.h @@ -22,6 +22,15 @@ typedef struct { std::string french; } CustomMessageEntry; +// Message Entry without the text type and position, useful for when +// you need an array of these to loop over for registration +// that will all have the same textbox type and position. +typedef struct { + std::string english; + std::string german; + std::string french; +} CustomMessageMinimal; + #define NULL_CUSTOM_MESSAGE \ { (TextBoxType)(-1), (TextBoxPosition)(-1), "", "", "" } diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index 77e426baf..14a729a41 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -4767,46 +4767,68 @@ void DrawRandoEditor(bool& open) { ImGui::End(); }*/ +typedef struct { + GetItemID giid; + ItemID iid; + std::string english; + std::string german; + std::string french; +} GetItemMessage; -void Randomizer::CreateCustomMessages() { - CustomMessage* customMessage = CustomMessage::Instance; - customMessage->AddCustomMessageTable(Randomizer::getItemMessageTableID); +void CreateGetItemMessages(std::vector messageEntries) { + CustomMessage* customMessage = CustomMessage::Instance; + customMessage->AddCustomMessageTable(Randomizer::getItemMessageTableID); + for (GetItemMessage messageEntry : messageEntries) { customMessage->CreateGetItemMessage(Randomizer::getItemMessageTableID, GI_BOTTLE_WITH_BLUE_FIRE, ITEM_BLUE_FIRE, { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, - "You got a %rBottle with Blue &Fire%w! Use it to melt Red Ice!", "", - "" }); - customMessage->CreateGetItemMessage(Randomizer::getItemMessageTableID, GI_BOTTLE_WITH_BIG_POE, ITEM_BIG_POE, - { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, - "You got a %rBig Poe in a Bottle%w!&Sell it to the Ghost Shop!", "", - "" }); - customMessage->CreateGetItemMessage( - Randomizer::getItemMessageTableID, GI_BOTTLE_WITH_BLUE_POTION, ITEM_POTION_BLUE, - { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, - "You got a %rBottle of Blue Potion%w!&Drink it to replenish your&%ghealth%w and %bmagic%w!", "", "" }); - customMessage->CreateGetItemMessage( - Randomizer::getItemMessageTableID, GI_BOTTLE_WITH_FISH, ITEM_FISH, - { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, - "You got a %rFish in a Bottle%w!&It looks fresh and delicious!&They say Jabu-Jabu loves them!", "", "" }); - customMessage->CreateGetItemMessage(Randomizer::getItemMessageTableID, GI_BOTTLE_WITH_BUGS, ITEM_BUG, - { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, - "You got a %rBug in a Bottle%w!&They love to burrow in&dirt holes!", "", - "" }); - customMessage->CreateGetItemMessage( - Randomizer::getItemMessageTableID, GI_BOTTLE_WITH_FAIRY, ITEM_FAIRY, - { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, "You got a %rFairy in a Bottle%w!&Use it wisely!", "", "" }); - customMessage->CreateGetItemMessage( - Randomizer::getItemMessageTableID, GI_BOTTLE_WITH_RED_POTION, ITEM_POTION_RED, - { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, - "You got a %rBottle of Red Potion%w!&Drink it to replenish your&%ghealth%w!", "", "" }); - customMessage->CreateGetItemMessage( - Randomizer::getItemMessageTableID, GI_BOTTLE_WITH_GREEN_POTION, ITEM_POTION_GREEN, - { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, - "You got a %rBottle of Green Potion%w!&Drink it to replenish your&%bmagic%w!", "", "" }); - customMessage->CreateGetItemMessage( - Randomizer::getItemMessageTableID, GI_BOTTLE_WITH_POE, ITEM_POE, - { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, - "You got a %rPoe in a Bottle%w!&That creepy Ghost Shop might&be interested in this...", "", "" }); + messageEntry.english, messageEntry.german, + messageEntry.french }); } +} + +#define GIMESSAGE(giid, iid, english, german, french) \ + { giid, iid, english, german, french } + +void Randomizer::CreateCustomMessages() { + const std::vector getItemMessages = { + GIMESSAGE(GI_BOTTLE_WITH_BLUE_FIRE, ITEM_BLUE_FIRE, + "You got a %rBottle with Blue &Fire%w! Use it to melt Red Ice!", + "You got a %rBottle with Blue &Fire%w! Use it to melt Red Ice!", + "You got a %rBottle with Blue &Fire%w! Use it to melt Red Ice!"), + GIMESSAGE(GI_BOTTLE_WITH_BIG_POE, ITEM_BIG_POE, + "You got a %rBig Poe in a Bottle%w!&Sell it to the Ghost Shop!", + "You got a %rBig Poe in a Bottle%w!&Sell it to the Ghost Shop!", + "You got a %rBig Poe in a Bottle%w!&Sell it to the Ghost Shop!"), + GIMESSAGE(GI_BOTTLE_WITH_BLUE_POTION, ITEM_POTION_BLUE, + "You got a %rBottle of Blue Potion%w!&Drink it to replenish your&%ghealth%w and %bmagic%w!", + "You got a %rBottle of Blue Potion%w!&Drink it to replenish your&%ghealth%w and %bmagic%w!", + "You got a %rBottle of Blue Potion%w!&Drink it to replenish your&%ghealth%w and %bmagic%w!"), + GIMESSAGE(GI_BOTTLE_WITH_FISH, ITEM_FISH, + "You got a %rFish in a Bottle%w!&It looks fresh and delicious!&They say Jabu-Jabu loves them!", + "You got a %rFish in a Bottle%w!&It looks fresh and delicious!&They say Jabu-Jabu loves them!", + "You got a %rFish in a Bottle%w!&It looks fresh and delicious!&They say Jabu-Jabu loves them!"), + GIMESSAGE(GI_BOTTLE_WITH_BUGS, ITEM_BUG, + "You got a %rBug in a Bottle%w!&They love to burrow in&dirt holes!", + "You got a %rBug in a Bottle%w!&They love to burrow in&dirt holes!", + "You got a %rBug in a Bottle%w!&They love to burrow in&dirt holes!"), + GIMESSAGE(GI_BOTTLE_WITH_FAIRY, ITEM_FAIRY, "You got a %rFairy in a Bottle%w!&Use it wisely!", + "You got a %rFairy in a Bottle%w!&Use it wisely!", + "You got a %rFairy in a Bottle%w!&Use it wisely!"), + GIMESSAGE(GI_BOTTLE_WITH_RED_POTION, ITEM_POTION_RED, + "You got a %rBottle of Red Potion%w!&Drink it to replenish your&%ghealth%w!", + "You got a %rBottle of Red Potion%w!&Drink it to replenish your&%ghealth%w!", + "You got a %rBottle of Red Potion%w!&Drink it to replenish your&%ghealth%w!"), + GIMESSAGE(GI_BOTTLE_WITH_GREEN_POTION, ITEM_POTION_GREEN, + "You got a %rBottle of Green Potion%w!&Drink it to replenish your&%bmagic%w!", + "You got a %rBottle of Green Potion%w!&Drink it to replenish your&%bmagic%w!", + "You got a %rBottle of Green Potion%w!&Drink it to replenish your&%bmagic%w!"), + GIMESSAGE(GI_BOTTLE_WITH_POE, ITEM_POE, + "You got a %rPoe in a Bottle%w!&That creepy Ghost Shop might&be interested in this...", + "You got a %rPoe in a Bottle%w!&That creepy Ghost Shop might&be interested in this...", + "You got a %rPoe in a Bottle%w!&That creepy Ghost Shop might&be interested in this..."), + }; + CreateGetItemMessages(getItemMessages); +} void InitRando() { SohImGui::AddWindow("Randomizer", "Randomizer Settings", DrawRandoEditor); From a33c3d606a906ef4fcc66532ef64758055d54068 Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Sun, 24 Jul 2022 18:54:05 -0400 Subject: [PATCH 20/71] Fixes minor oversight from previous commit. --- soh/soh/Enhancements/randomizer/randomizer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index 14a729a41..9a84d80b9 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -4779,7 +4779,7 @@ void CreateGetItemMessages(std::vector messageEntries) { CustomMessage* customMessage = CustomMessage::Instance; customMessage->AddCustomMessageTable(Randomizer::getItemMessageTableID); for (GetItemMessage messageEntry : messageEntries) { - customMessage->CreateGetItemMessage(Randomizer::getItemMessageTableID, GI_BOTTLE_WITH_BLUE_FIRE, ITEM_BLUE_FIRE, + customMessage->CreateGetItemMessage(Randomizer::getItemMessageTableID, messageEntry.giid, messageEntry.iid, { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, messageEntry.english, messageEntry.german, messageEntry.french }); From 780e9f4669d8d00b10437c36f95487d6f26cfb0f Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Sun, 24 Jul 2022 19:18:46 -0400 Subject: [PATCH 21/71] Fixes storage of altar and ganon hints/text. Only one language is stored in gSaveContext at the moment so store the one language in all 3 CustomMessageEntry languages. --- .../Enhancements/randomizer/randomizer.cpp | 67 +++---------------- 1 file changed, 10 insertions(+), 57 deletions(-) diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index 9a84d80b9..ec5914c07 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -1486,16 +1486,20 @@ void Randomizer::LoadHintLocations(const char* spoilerFileName) { CustomMessage::Instance->CreateMessage( Randomizer::hintMessageTableID, 0x7040, - { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, gSaveContext.childAltarText, "", "" }); + { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, gSaveContext.childAltarText, + gSaveContext.childAltarText, gSaveContext.childAltarText }); CustomMessage::Instance->CreateMessage( Randomizer::hintMessageTableID, 0x7088, - { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, gSaveContext.adultAltarText, "", "" }); + { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, gSaveContext.adultAltarText, + gSaveContext.adultAltarText, gSaveContext.adultAltarText }); CustomMessage::Instance->CreateMessage( Randomizer::hintMessageTableID, 0x70CC, - { TEXTBOX_TYPE_BLACK, TEXTBOX_POS_BOTTOM, gSaveContext.ganonHintText, "", "" }); + { TEXTBOX_TYPE_BLACK, TEXTBOX_POS_BOTTOM, gSaveContext.ganonHintText, + gSaveContext.ganonHintText, gSaveContext.ganonHintText }); CustomMessage::Instance->CreateMessage( Randomizer::hintMessageTableID, 0x70CD, - { TEXTBOX_TYPE_BLACK, TEXTBOX_POS_BOTTOM, gSaveContext.ganonText, "", "" }); + { TEXTBOX_TYPE_BLACK, TEXTBOX_POS_BOTTOM, gSaveContext.ganonText, + gSaveContext.ganonText, gSaveContext.ganonText }); this->childAltarText = gSaveContext.childAltarText; this->adultAltarText = gSaveContext.adultAltarText; @@ -1506,7 +1510,7 @@ void Randomizer::LoadHintLocations(const char* spoilerFileName) { if(hintLocation.check == RC_LINKS_POCKET) break; this->hintLocations[hintLocation.check] = hintLocation.hintText; CustomMessage::Instance->CreateMessage( - Randomizer::hintMessageTableID, hintLocation.check, { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, hintLocation.hintText, "", "" }); + Randomizer::hintMessageTableID, hintLocation.check, { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, hintLocation.hintText, hintLocation.hintText, hintLocation.hintText }); } } @@ -1818,58 +1822,7 @@ std::string AltarIconString(char iconChar) { std::string FormatJsonHintText(std::string jsonHint) { std::string formattedHintMessage = jsonHint; - char newLine = 0x01; - char playerName = 0x0F; - char nextBox = 0x04; - std::replace(formattedHintMessage.begin(), formattedHintMessage.end(), '&', newLine); - std::replace(formattedHintMessage.begin(), formattedHintMessage.end(), '^', nextBox); - std::replace(formattedHintMessage.begin(), formattedHintMessage.end(), '@', playerName); - - std::unordered_map textBoxSpecialCharacters = { - {"À", 0x80 }, - {"î", 0x81 }, - {"Â", 0x82 }, - {"Ä", 0x83 }, - {"Ç", 0x84 }, - {"È", 0x85 }, - {"É", 0x86 }, - {"Ê", 0x87 }, - {"Ë", 0x88 }, - {"Ï", 0x89 }, - {"Ô", 0x8A }, - {"Ö", 0x8B }, - {"Ù", 0x8C }, - {"Û", 0x8D }, - {"Ü", 0x8E }, - {"ß", 0x8F }, - {"à", 0x90 }, - {"á", 0x91 }, - {"â", 0x92 }, - {"ä", 0x93 }, - {"ç", 0x94 }, - {"è", 0x95 }, - {"é", 0x96 }, - {"ê", 0x97 }, - {"ë", 0x98 }, - {"ï", 0x99 }, - {"ô", 0x9A }, - {"ö", 0x9B }, - {"ù", 0x9C }, - {"û", 0x9D }, - {"ü", 0x9E } - }; - - // add special characters - for (auto specialCharacterPair : textBoxSpecialCharacters) { - size_t start_pos = 0; - std::string textBoxSpecialCharacterString = ""; - textBoxSpecialCharacterString += specialCharacterPair.second; - while((start_pos = formattedHintMessage.find(specialCharacterPair.first, start_pos)) != std::string::npos) { - formattedHintMessage.replace(start_pos, specialCharacterPair.first.length(), textBoxSpecialCharacterString); - start_pos += textBoxSpecialCharacterString.length(); - } - } - + // add icons to altar text for (char iconChar : {'0', '1', '2', '3', '4', '5', '6', '7', '8', 'o', 'c', 'i', 'l', 'b', 'L', 'k'}) { std::string textToReplace = "$"; From 661946b4f53ad6c2abdeeaee4234cfbd1c12e834 Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Sun, 24 Jul 2022 19:24:24 -0400 Subject: [PATCH 22/71] Pulls altar text from CustomMessageTable instead of gSaveContext. --- soh/soh/OTRGlobals.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index f570c3b10..e749eb286 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -1473,10 +1473,9 @@ extern "C" int CopyScrubMessage(u16 scrubTextId, char* buffer, const int maxBuff return CopyStringToCharBuffer(scrubText, buffer, maxBufferSize); } -extern "C" int Randomizer_CopyAltarMessage(char* buffer, const int maxBufferSize) { - const std::string& altarText = (LINK_IS_ADULT) ? OTRGlobals::Instance->gRandomizer->GetAdultAltarText() - : OTRGlobals::Instance->gRandomizer->GetChildAltarText(); - return CopyStringToCharBuffer(altarText, buffer, maxBufferSize); +extern "C" CustomMessageEntry Randomizer_CopyAltarMessage() { + return (LINK_IS_ADULT) ? CustomMessage::Instance->RetrieveMessage(Randomizer::hintMessageTableID, 0x7088) + : CustomMessage::Instance->RetrieveMessage(Randomizer::hintMessageTableID, 0x7040); } extern "C" int Randomizer_CopyGanonText(char* buffer, const int maxBufferSize) { @@ -1520,8 +1519,7 @@ extern "C" int CustomMessage_RetrieveIfExists(GlobalContext* globalCtx) { if (textId == 0xF8) { messageEntry = Randomizer_GetCustomGetItemMessage((GetItemID)GET_PLAYER(globalCtx)->getItemId, buffer, maxBufferSize); - } - if (textId == 0x2053 && Randomizer_GetSettingValue(RSK_GOSSIP_STONE_HINTS) != 0 && + } else if (textId == 0x2053 && Randomizer_GetSettingValue(RSK_GOSSIP_STONE_HINTS) != 0 && (Randomizer_GetSettingValue(RSK_GOSSIP_STONE_HINTS) == 1 || (Randomizer_GetSettingValue(RSK_GOSSIP_STONE_HINTS) == 2 && Player_GetMask(globalCtx) == PLAYER_MASK_TRUTH) || @@ -1549,6 +1547,9 @@ extern "C" int CustomMessage_RetrieveIfExists(GlobalContext* globalCtx) { Randomizer_GetCheckFromActor(globalCtx->sceneNum, msgCtx->talkActor->id, actorParams); messageEntry = Randomizer_CopyHintFromCheck(hintCheck); + } else if (textId == 0x7040 || textId == 0x7088) { + // rando hints at altar + messageEntry = Randomizer_CopyAltarMessage(); } } if (textId == 0x00B4 || textId == 0x00B5) { From c1155bb08c46d29fe2917b244ade1b618e19cdaa Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Sun, 24 Jul 2022 19:35:24 -0400 Subject: [PATCH 23/71] Cleans up unused z_message_PAL code. --- soh/src/code/z_message_PAL.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/soh/src/code/z_message_PAL.c b/soh/src/code/z_message_PAL.c index fa26cbad7..e85d4d3ce 100644 --- a/soh/src/code/z_message_PAL.c +++ b/soh/src/code/z_message_PAL.c @@ -1675,10 +1675,7 @@ void Message_OpenText(GlobalContext* globalCtx, u16 textId) { //font->msgLength, __FILE__, __LINE__); } else { Message_FindMessage(globalCtx, textId); - if (gSaveContext.n64ddFlag && (textId == 0x7040 || textId == 0x7088)) { - // rando hints at altar - msgCtx->msgLength = font->msgLength = Randomizer_CopyAltarMessage(font->msgBuf, sizeof(font->msgBuf)); - } else if (gSaveContext.n64ddFlag && (textId == 0x10A2 || textId == 0x10DC || textId == 0x10DD)) { + if (gSaveContext.n64ddFlag && (textId == 0x10A2 || textId == 0x10DC || textId == 0x10DD)) { msgCtx->msgLength = font->msgLength = CopyScrubMessage(textId, font->msgBuf, sizeof(font->msgBuf)); } else if (gSaveContext.n64ddFlag && textId == 0x70CC) { if (INV_CONTENT(ITEM_ARROW_LIGHT) == ITEM_ARROW_LIGHT) { From 9f2eb466635c155610ef7871b46ec6815402bb39 Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Sun, 24 Jul 2022 19:43:11 -0400 Subject: [PATCH 24/71] Takes Ganondor's text & hint from CustomMessageTable --- soh/soh/OTRGlobals.cpp | 16 ++++++++++------ soh/src/code/z_message_PAL.c | 6 ------ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index e749eb286..658ee9a5a 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -1478,14 +1478,12 @@ extern "C" CustomMessageEntry Randomizer_CopyAltarMessage() { : CustomMessage::Instance->RetrieveMessage(Randomizer::hintMessageTableID, 0x7040); } -extern "C" int Randomizer_CopyGanonText(char* buffer, const int maxBufferSize) { - const std::string& ganonText = OTRGlobals::Instance->gRandomizer->GetGanonText(); - return CopyStringToCharBuffer(ganonText, buffer, maxBufferSize); +extern "C" CustomMessageEntry Randomizer_CopyGanonText() { + return CustomMessage::Instance->RetrieveMessage(Randomizer::hintMessageTableID, 0x70CD); } -extern "C" int Randomizer_CopyGanonHintText(char* buffer, const int maxBufferSize) { - const std::string& ganonText = OTRGlobals::Instance->gRandomizer->GetGanonHintText(); - return CopyStringToCharBuffer(ganonText, buffer, maxBufferSize); +extern "C" CustomMessageEntry Randomizer_CopyGanonHintText() { + return CustomMessage::Instance->RetrieveMessage(Randomizer::hintMessageTableID, 0x70CC); } extern "C" CustomMessageEntry Randomizer_CopyHintFromCheck(RandomizerCheck check) { @@ -1550,6 +1548,12 @@ extern "C" int CustomMessage_RetrieveIfExists(GlobalContext* globalCtx) { } else if (textId == 0x7040 || textId == 0x7088) { // rando hints at altar messageEntry = Randomizer_CopyAltarMessage(); + } else if (gSaveContext.n64ddFlag && textId == 0x70CC) { + if (INV_CONTENT(ITEM_ARROW_LIGHT) == ITEM_ARROW_LIGHT) { + messageEntry = Randomizer_CopyGanonText(); + } else { + messageEntry = Randomizer_CopyGanonHintText(); + } } } if (textId == 0x00B4 || textId == 0x00B5) { diff --git a/soh/src/code/z_message_PAL.c b/soh/src/code/z_message_PAL.c index e85d4d3ce..57eafa1d7 100644 --- a/soh/src/code/z_message_PAL.c +++ b/soh/src/code/z_message_PAL.c @@ -1677,12 +1677,6 @@ void Message_OpenText(GlobalContext* globalCtx, u16 textId) { Message_FindMessage(globalCtx, textId); if (gSaveContext.n64ddFlag && (textId == 0x10A2 || textId == 0x10DC || textId == 0x10DD)) { msgCtx->msgLength = font->msgLength = CopyScrubMessage(textId, font->msgBuf, sizeof(font->msgBuf)); - } else if (gSaveContext.n64ddFlag && textId == 0x70CC) { - if (INV_CONTENT(ITEM_ARROW_LIGHT) == ITEM_ARROW_LIGHT) { - msgCtx->msgLength = font->msgLength = Randomizer_CopyGanonText(font->msgBuf, sizeof(font->msgBuf)); - } else { - msgCtx->msgLength = font->msgLength = Randomizer_CopyGanonHintText(font->msgBuf, sizeof(font->msgBuf)); - } } else { msgCtx->msgLength = font->msgLength; char* src = (uintptr_t)font->msgOffset; From cd01e8b7781d1b74ff7a77907666963691006d86 Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Mon, 25 Jul 2022 21:31:17 -0400 Subject: [PATCH 25/71] Moves deku scrub messages into CustomMessageTable. --- .../custom_message/CustomMessage.cpp | 25 ++++++------ .../Enhancements/randomizer/randomizer.cpp | 39 +++++++++++++++++++ soh/soh/Enhancements/randomizer/randomizer.h | 1 + soh/soh/OTRGlobals.cpp | 16 ++++++++ soh/src/code/z_message_PAL.c | 10 ++--- 5 files changed, 70 insertions(+), 21 deletions(-) diff --git a/soh/soh/Enhancements/custom_message/CustomMessage.cpp b/soh/soh/Enhancements/custom_message/CustomMessage.cpp index 7f26fb616..6ea820aa9 100644 --- a/soh/soh/Enhancements/custom_message/CustomMessage.cpp +++ b/soh/soh/Enhancements/custom_message/CustomMessage.cpp @@ -4,13 +4,13 @@ using namespace std::literals::string_literals; CustomMessage::CustomMessage() { - this->textBoxSpecialCharacters = { { "", 0x80 }, { "", 0x81 }, { "", 0x82 }, { "", 0x83 }, { "", 0x84 }, - { "", 0x85 }, { "", 0x86 }, { "", 0x87 }, { "", 0x88 }, { "", 0x89 }, - { "", 0x8A }, { "", 0x8B }, { "", 0x8C }, { "", 0x8D }, { "", 0x8E }, - { "", 0x8F }, { "", 0x90 }, { "", 0x91 }, { "", 0x92 }, { "", 0x93 }, - { "", 0x94 }, { "", 0x95 }, { "", 0x96 }, { "", 0x97 }, { "", 0x98 }, - { "", 0x99 }, { "", 0x9A }, { "", 0x9B }, { "", 0x9C }, { "", 0x9D }, - { "", 0x9E } }; + this->textBoxSpecialCharacters = { { "À", 0x80 }, { "î", 0x81 }, { "Â", 0x82 }, { "Ä", 0x83 }, { "Ç", 0x84 }, + { "È", 0x85 }, { "É", 0x86 }, { "Ê", 0x87 }, { "Ë", 0x88 }, { "Ï", 0x89 }, + { "Ô", 0x8A }, { "Ö", 0x8B }, { "Ù", 0x8C }, { "Û", 0x8D }, { "Ü", 0x8E }, + { "ß", 0x8F }, { "à", 0x90 }, { "á", 0x91 }, { "â", 0x92 }, { "ä", 0x93 }, + { "ç", 0x94 }, { "è", 0x95 }, { "é", 0x96 }, { "ê", 0x97 }, { "ë", 0x98 }, + { "ï", 0x99 }, { "ô", 0x9A }, { "ö", 0x9B }, { "ù", 0x9C }, { "û", 0x9D }, + { "ü", 0x9E } }; this->colors = { { "w", QM_WHITE }, { "r", QM_RED }, { "g", QM_GREEN }, { "b", QM_BLUE }, { "c", QM_LBLUE }, { "p", QM_PINK }, { "y", QM_YELLOW }, { "B", QM_BLACK } }; } @@ -23,11 +23,11 @@ CustomMessage::~CustomMessage() { void CustomMessage::ReplaceSpecialCharacters(std::string& string) { // add special characters - for (auto specialCharacterPair : textBoxSpecialCharacters) { + for (auto specialCharacterPair : this->textBoxSpecialCharacters) { size_t start_pos = 0; - std::string textBoxSpecialCharacterString = ""; + std::string textBoxSpecialCharacterString = ""s; textBoxSpecialCharacterString += specialCharacterPair.second; - while ((start_pos = string.find(specialCharacterPair.first, start_pos)) != std::string::npos) { + while ((start_pos = string.find(specialCharacterPair.first, 0)) != std::string::npos) { string.replace(start_pos, specialCharacterPair.first.length(), textBoxSpecialCharacterString); start_pos += textBoxSpecialCharacterString.length(); } @@ -63,10 +63,7 @@ void CustomMessage::FormatCustomMessage(std::string& message, ItemID iid) { void CustomMessage::FormatCustomMessage(std::string& message) { size_t start_pos = 0; std::replace(message.begin(), message.end(), '&', NEWLINE()[0]); - while ((start_pos = message.find('^', start_pos)) != std::string::npos) { - message.replace(start_pos, 1, WAIT_FOR_INPUT()); - start_pos += 3; - } + std::replace(message.begin(), message.end(), '^', WAIT_FOR_INPUT()[0]); std::replace(message.begin(), message.end(), '@', PLAYER_NAME()[0]); ReplaceSpecialCharacters(message); ReplaceColors(message); diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index ec5914c07..5159de0da 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -17,6 +17,7 @@ #include using json = nlohmann::json; +using namespace std::literals::string_literals; std::unordered_map gSeedTextures; @@ -24,6 +25,7 @@ u8 generated; const std::string Randomizer::getItemMessageTableID = "Randomizer"; const std::string Randomizer::hintMessageTableID = "RandomizerHints"; +const std::string Randomizer::scrubMessageTableID = "RandomizerScrubs"; Randomizer::Randomizer() { Sprite bowSprite = { dgFairyBowIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 0 }; @@ -1822,6 +1824,25 @@ std::string AltarIconString(char iconChar) { std::string FormatJsonHintText(std::string jsonHint) { std::string formattedHintMessage = jsonHint; + + std::unordered_map textBoxSpecialCharacters = { + { "À", 0x80 }, { "î", 0x81 }, { "Â", 0x82 }, { "Ä", 0x83 }, { "Ç", 0x84 }, { "È", 0x85 }, { "É", 0x86 }, + { "Ê", 0x87 }, { "Ë", 0x88 }, { "Ï", 0x89 }, { "Ô", 0x8A }, { "Ö", 0x8B }, { "Ù", 0x8C }, { "Û", 0x8D }, + { "Ü", 0x8E }, { "ß", 0x8F }, { "à", 0x90 }, { "á", 0x91 }, { "â", 0x92 }, { "ä", 0x93 }, { "ç", 0x94 }, + { "è", 0x95 }, { "é", 0x96 }, { "ê", 0x97 }, { "ë", 0x98 }, { "ï", 0x99 }, { "ô", 0x9A }, { "ö", 0x9B }, + { "ù", 0x9C }, { "û", 0x9D }, { "ü", 0x9E } + }; + + // add special characters + for (auto specialCharacterPair : textBoxSpecialCharacters) { + size_t start_pos = 0; + std::string textBoxSpecialCharacterString = ""; + textBoxSpecialCharacterString += specialCharacterPair.second; + while ((start_pos = formattedHintMessage.find(specialCharacterPair.first, start_pos)) != std::string::npos) { + formattedHintMessage.replace(start_pos, specialCharacterPair.first.length(), textBoxSpecialCharacterString); + start_pos += textBoxSpecialCharacterString.length(); + } + } // add icons to altar text for (char iconChar : {'0', '1', '2', '3', '4', '5', '6', '7', '8', 'o', 'c', 'i', 'l', 'b', 'L', 'k'}) { @@ -4739,6 +4760,23 @@ void CreateGetItemMessages(std::vector messageEntries) { } } +void CreateScrubMessages() { + CustomMessage* customMessage = CustomMessage::Instance; + customMessage->AddCustomMessageTable(Randomizer::scrubMessageTableID); + const std::vector prices = { 10, 40 }; + for (u8 price : prices) { + customMessage->CreateMessage(Randomizer::scrubMessageTableID, price, + { TEXTBOX_TYPE_BLACK, TEXTBOX_POS_BOTTOM, + "\x12\x38\x82\All right! You win! In return for&sparing me, I will sell you a&%gmysterious item%w!&%r" + + std::to_string(price) + " Rupees%w it is!\x07\x10\xA3", + "\x12\x38\x82\All right! You win! In return for&sparing me, I will sell you a&%gmysterious item%w!&%r" + + std::to_string(price) + " Rupees%w it is!\x07\x10\xA3", + "\x12\x38\x82J'abandonne! Tu veux bien m'acheter&un %gobjet mystérieux%w?&Ça fera %r" + + std::to_string(price) + " Rubis%w!\x07\x10\xA3" + }); + } +} + #define GIMESSAGE(giid, iid, english, german, french) \ { giid, iid, english, german, french } @@ -4781,6 +4819,7 @@ void Randomizer::CreateCustomMessages() { "You got a %rPoe in a Bottle%w!&That creepy Ghost Shop might&be interested in this..."), }; CreateGetItemMessages(getItemMessages); + CreateScrubMessages(); } void InitRando() { diff --git a/soh/soh/Enhancements/randomizer/randomizer.h b/soh/soh/Enhancements/randomizer/randomizer.h index ec27d684d..a89c1f706 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.h +++ b/soh/soh/Enhancements/randomizer/randomizer.h @@ -28,6 +28,7 @@ class Randomizer { static const std::string getItemMessageTableID; static const std::string hintMessageTableID; + static const std::string scrubMessageTableID; static Sprite* GetSeedTexture(uint8_t index); s16 GetItemModelFromId(s16 itemId); diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 658ee9a5a..156fb4d77 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -1401,6 +1401,20 @@ extern "C" RandomizerCheck Randomizer_GetCheckFromActor(s16 sceneNum, s16 actorI return OTRGlobals::Instance->gRandomizer->GetCheckFromActor(sceneNum, actorId, actorParams); } +extern "C" CustomMessageEntry Randomizer_CopyScrubMessage(u16 scrubTextId) { + int price = 0; + switch (scrubTextId) { + case 0x10A2: + price = 10; + break; + case 0x10DC: + case 0x10DD: + price = 40; + break; + } + return CustomMessage::Instance->RetrieveMessage(Randomizer::scrubMessageTableID, price); +} + extern "C" int CopyScrubMessage(u16 scrubTextId, char* buffer, const int maxBufferSize) { std::string scrubText(""); int language = CVar_GetS32("gLanguages", 0); @@ -1554,6 +1568,8 @@ extern "C" int CustomMessage_RetrieveIfExists(GlobalContext* globalCtx) { } else { messageEntry = Randomizer_CopyGanonHintText(); } + } else if (textId == 0x10A2 || textId == 0x10DC || textId == 0x10DD) { + messageEntry = Randomizer_CopyScrubMessage(textId); } } if (textId == 0x00B4 || textId == 0x00B5) { diff --git a/soh/src/code/z_message_PAL.c b/soh/src/code/z_message_PAL.c index 57eafa1d7..3da2a0fc8 100644 --- a/soh/src/code/z_message_PAL.c +++ b/soh/src/code/z_message_PAL.c @@ -1675,13 +1675,9 @@ void Message_OpenText(GlobalContext* globalCtx, u16 textId) { //font->msgLength, __FILE__, __LINE__); } else { Message_FindMessage(globalCtx, textId); - if (gSaveContext.n64ddFlag && (textId == 0x10A2 || textId == 0x10DC || textId == 0x10DD)) { - msgCtx->msgLength = font->msgLength = CopyScrubMessage(textId, font->msgBuf, sizeof(font->msgBuf)); - } else { - msgCtx->msgLength = font->msgLength; - char* src = (uintptr_t)font->msgOffset; - memcpy(font->msgBuf, src, font->msgLength); - } + msgCtx->msgLength = font->msgLength; + char* src = (uintptr_t)font->msgOffset; + memcpy(font->msgBuf, src, font->msgLength); } msgCtx->textBoxProperties = font->charTexBuf[0]; From 4c9e4b2d842b9e608ba683fb36ddfc74b5b1d2cc Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Mon, 25 Jul 2022 22:04:53 -0400 Subject: [PATCH 26/71] Puts CustomMessage files in filters in Visual Studio --- soh/soh.vcxproj.filters | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/soh/soh.vcxproj.filters b/soh/soh.vcxproj.filters index 5f48ff042..f31a5171c 100644 --- a/soh/soh.vcxproj.filters +++ b/soh/soh.vcxproj.filters @@ -82,6 +82,12 @@ {04fc1c52-49ff-48e2-ae23-2c00867374f8} + + {8f355b3b-15ba-4e0a-be8b-2a6ec0ff4ec7} + + + {34b196e2-95d6-49b1-822d-0297d8114050} + @@ -2373,6 +2379,9 @@ Source Files\src + + Source Files\soh\Enhancements\custom-message + @@ -4061,6 +4070,9 @@ Source Files\src + + Header Files\soh\Enhancements\custom-message + @@ -4073,4 +4085,4 @@ - + \ No newline at end of file From 822476373bb42c5c94eeaaf13178f6bfcb839124 Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Mon, 25 Jul 2022 22:33:38 -0400 Subject: [PATCH 27/71] Renames CustomMessage to CustomMessageManager --- soh/soh.vcxproj | 4 +- soh/soh.vcxproj.filters | 4 +- ...omMessage.cpp => CustomMessageManager.cpp} | 38 +++++++++---------- ...CustomMessage.h => CustomMessageManager.h} | 8 ++-- .../Enhancements/randomizer/randomizer.cpp | 20 +++++----- soh/soh/OTRGlobals.cpp | 22 +++++------ soh/soh/z_message_OTR.cpp | 16 ++++---- 7 files changed, 56 insertions(+), 56 deletions(-) rename soh/soh/Enhancements/custom_message/{CustomMessage.cpp => CustomMessageManager.cpp} (77%) rename soh/soh/Enhancements/custom_message/{CustomMessage.h => CustomMessageManager.h} (94%) diff --git a/soh/soh.vcxproj b/soh/soh.vcxproj index 1c1f3784a..27c1571da 100644 --- a/soh/soh.vcxproj +++ b/soh/soh.vcxproj @@ -179,7 +179,7 @@ - + @@ -944,7 +944,7 @@ - + diff --git a/soh/soh.vcxproj.filters b/soh/soh.vcxproj.filters index f31a5171c..ed0a1f200 100644 --- a/soh/soh.vcxproj.filters +++ b/soh/soh.vcxproj.filters @@ -2379,7 +2379,7 @@ Source Files\src - + Source Files\soh\Enhancements\custom-message @@ -4070,7 +4070,7 @@ Source Files\src - + Header Files\soh\Enhancements\custom-message diff --git a/soh/soh/Enhancements/custom_message/CustomMessage.cpp b/soh/soh/Enhancements/custom_message/CustomMessageManager.cpp similarity index 77% rename from soh/soh/Enhancements/custom_message/CustomMessage.cpp rename to soh/soh/Enhancements/custom_message/CustomMessageManager.cpp index 6ea820aa9..4f69102da 100644 --- a/soh/soh/Enhancements/custom_message/CustomMessage.cpp +++ b/soh/soh/Enhancements/custom_message/CustomMessageManager.cpp @@ -1,9 +1,9 @@ -#include "CustomMessage.h" +#include "CustomMessageManager.h" #include using namespace std::literals::string_literals; -CustomMessage::CustomMessage() { +CustomMessageManager::CustomMessageManager() { this->textBoxSpecialCharacters = { { "À", 0x80 }, { "î", 0x81 }, { "Â", 0x82 }, { "Ä", 0x83 }, { "Ç", 0x84 }, { "È", 0x85 }, { "É", 0x86 }, { "Ê", 0x87 }, { "Ë", 0x88 }, { "Ï", 0x89 }, { "Ô", 0x8A }, { "Ö", 0x8B }, { "Ù", 0x8C }, { "Û", 0x8D }, { "Ü", 0x8E }, @@ -15,13 +15,13 @@ CustomMessage::CustomMessage() { { "c", QM_LBLUE }, { "p", QM_PINK }, { "y", QM_YELLOW }, { "B", QM_BLACK } }; } -CustomMessage::~CustomMessage() { +CustomMessageManager::~CustomMessageManager() { this->textBoxSpecialCharacters.clear(); this->colors.clear(); this->messageTables.clear(); } -void CustomMessage::ReplaceSpecialCharacters(std::string& string) { +void CustomMessageManager::ReplaceSpecialCharacters(std::string& string) { // add special characters for (auto specialCharacterPair : this->textBoxSpecialCharacters) { size_t start_pos = 0; @@ -34,7 +34,7 @@ void CustomMessage::ReplaceSpecialCharacters(std::string& string) { } } -void CustomMessage::ReplaceColors(std::string& string) { +void CustomMessageManager::ReplaceColors(std::string& string) { for (auto colorPair : colors) { std::string textToReplace = "%"; textToReplace += colorPair.first; @@ -46,7 +46,7 @@ void CustomMessage::ReplaceColors(std::string& string) { } } -void CustomMessage::FormatCustomMessage(std::string& message, ItemID iid) { +void CustomMessageManager::FormatCustomMessage(std::string& message, ItemID iid) { message.insert(0, ITEM_OBTAINED(iid)); size_t start_pos = 0; std::replace(message.begin(), message.end(), '&', NEWLINE()[0]); @@ -60,7 +60,7 @@ void CustomMessage::FormatCustomMessage(std::string& message, ItemID iid) { message += MESSAGE_END(); } -void CustomMessage::FormatCustomMessage(std::string& message) { +void CustomMessageManager::FormatCustomMessage(std::string& message) { size_t start_pos = 0; std::replace(message.begin(), message.end(), '&', NEWLINE()[0]); std::replace(message.begin(), message.end(), '^', WAIT_FOR_INPUT()[0]); @@ -70,7 +70,7 @@ void CustomMessage::FormatCustomMessage(std::string& message) { message += MESSAGE_END(); } -bool CustomMessage::InsertCustomMessage(std::string tableID, uint16_t textID, CustomMessageEntry messages) { +bool CustomMessageManager::InsertCustomMessage(std::string tableID, uint16_t textID, CustomMessageEntry messages) { auto result = messageTables.find(tableID); if (result == messageTables.end()) { return false; @@ -82,7 +82,7 @@ bool CustomMessage::InsertCustomMessage(std::string tableID, uint16_t textID, Cu -bool CustomMessage::CreateGetItemMessage(std::string tableID, GetItemID giid, ItemID iid, CustomMessageEntry messages) { +bool CustomMessageManager::CreateGetItemMessage(std::string tableID, GetItemID giid, ItemID iid, CustomMessageEntry messages) { FormatCustomMessage(messages.english, iid); FormatCustomMessage(messages.german, iid); FormatCustomMessage(messages.french, iid); @@ -90,14 +90,14 @@ bool CustomMessage::CreateGetItemMessage(std::string tableID, GetItemID giid, It return InsertCustomMessage(tableID, textID, messages); } -bool CustomMessage::CreateMessage(std::string tableID, uint16_t textID, CustomMessageEntry messages) { +bool CustomMessageManager::CreateMessage(std::string tableID, uint16_t textID, CustomMessageEntry messages) { FormatCustomMessage(messages.english); FormatCustomMessage(messages.german); FormatCustomMessage(messages.french); return InsertCustomMessage(tableID, textID, messages); } -CustomMessageEntry CustomMessage::RetrieveMessage(std::string tableID, uint16_t textID) { +CustomMessageEntry CustomMessageManager::RetrieveMessage(std::string tableID, uint16_t textID) { std::unordered_map::const_iterator result = messageTables.find(tableID); if (result == messageTables.end()) { return NULL_CUSTOM_MESSAGE; @@ -111,7 +111,7 @@ CustomMessageEntry CustomMessage::RetrieveMessage(std::string tableID, uint16_t return message; } -bool CustomMessage::ClearMessageTable(std::string tableID) { +bool CustomMessageManager::ClearMessageTable(std::string tableID) { auto result = messageTables.find(tableID); if (result == messageTables.end()) { return false; @@ -120,31 +120,31 @@ bool CustomMessage::ClearMessageTable(std::string tableID) { messageTable.clear(); } -bool CustomMessage::AddCustomMessageTable(std::string tableID) { +bool CustomMessageManager::AddCustomMessageTable(std::string tableID) { CustomMessageTable newMessageTable; return messageTables.emplace(tableID, newMessageTable).second; } -std::string CustomMessage::MESSAGE_END() { +std::string CustomMessageManager::MESSAGE_END() { return "\x02"s; } -std::string CustomMessage::ITEM_OBTAINED(uint8_t x) { +std::string CustomMessageManager::ITEM_OBTAINED(uint8_t x) { return "\x13"s + char(x); } -std::string CustomMessage::NEWLINE() { +std::string CustomMessageManager::NEWLINE() { return "\x01"s; } -std::string CustomMessage::COLOR(uint8_t x) { +std::string CustomMessageManager::COLOR(uint8_t x) { return "\x05"s + char(x); } -std::string CustomMessage::WAIT_FOR_INPUT() { +std::string CustomMessageManager::WAIT_FOR_INPUT() { return "\x04"s; } -std::string CustomMessage::PLAYER_NAME() { +std::string CustomMessageManager::PLAYER_NAME() { return "\x0F"s; } \ No newline at end of file diff --git a/soh/soh/Enhancements/custom_message/CustomMessage.h b/soh/soh/Enhancements/custom_message/CustomMessageManager.h similarity index 94% rename from soh/soh/Enhancements/custom_message/CustomMessage.h rename to soh/soh/Enhancements/custom_message/CustomMessageManager.h index 69ddcbe61..207d515e3 100644 --- a/soh/soh/Enhancements/custom_message/CustomMessage.h +++ b/soh/soh/Enhancements/custom_message/CustomMessageManager.h @@ -36,7 +36,7 @@ typedef struct { typedef std::unordered_map CustomMessageTable; -class CustomMessage { +class CustomMessageManager { private: std::unordered_map textBoxSpecialCharacters; std::unordered_map colors; @@ -56,10 +56,10 @@ class CustomMessage { std::string PLAYER_NAME(); public: - static CustomMessage* Instance; + static CustomMessageManager* Instance; - CustomMessage(); - ~CustomMessage(); + CustomMessageManager(); + ~CustomMessageManager(); bool CreateGetItemMessage(std::string tableID, GetItemID giid, ItemID iid, CustomMessageEntry messages); bool CreateMessage(std::string tableID, uint16_t textID, CustomMessageEntry messages); diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index 5159de0da..00bcadaf1 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -14,7 +14,7 @@ #include "3drando/rando_main.hpp" #include #include "Lib/ImGui/imgui_internal.h" -#include +#include using json = nlohmann::json; using namespace std::literals::string_literals; @@ -1483,22 +1483,22 @@ void Randomizer::LoadHintLocations(const char* spoilerFileName) { ParseHintLocationsFile(spoilerFileName); } - CustomMessage::Instance->ClearMessageTable(Randomizer::hintMessageTableID); - CustomMessage::Instance->AddCustomMessageTable(Randomizer::hintMessageTableID); + CustomMessageManager::Instance->ClearMessageTable(Randomizer::hintMessageTableID); + CustomMessageManager::Instance->AddCustomMessageTable(Randomizer::hintMessageTableID); - CustomMessage::Instance->CreateMessage( + CustomMessageManager::Instance->CreateMessage( Randomizer::hintMessageTableID, 0x7040, { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, gSaveContext.childAltarText, gSaveContext.childAltarText, gSaveContext.childAltarText }); - CustomMessage::Instance->CreateMessage( + CustomMessageManager::Instance->CreateMessage( Randomizer::hintMessageTableID, 0x7088, { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, gSaveContext.adultAltarText, gSaveContext.adultAltarText, gSaveContext.adultAltarText }); - CustomMessage::Instance->CreateMessage( + CustomMessageManager::Instance->CreateMessage( Randomizer::hintMessageTableID, 0x70CC, { TEXTBOX_TYPE_BLACK, TEXTBOX_POS_BOTTOM, gSaveContext.ganonHintText, gSaveContext.ganonHintText, gSaveContext.ganonHintText }); - CustomMessage::Instance->CreateMessage( + CustomMessageManager::Instance->CreateMessage( Randomizer::hintMessageTableID, 0x70CD, { TEXTBOX_TYPE_BLACK, TEXTBOX_POS_BOTTOM, gSaveContext.ganonText, gSaveContext.ganonText, gSaveContext.ganonText }); @@ -1511,7 +1511,7 @@ void Randomizer::LoadHintLocations(const char* spoilerFileName) { for (auto hintLocation : gSaveContext.hintLocations) { if(hintLocation.check == RC_LINKS_POCKET) break; this->hintLocations[hintLocation.check] = hintLocation.hintText; - CustomMessage::Instance->CreateMessage( + CustomMessageManager::Instance->CreateMessage( Randomizer::hintMessageTableID, hintLocation.check, { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, hintLocation.hintText, hintLocation.hintText, hintLocation.hintText }); } } @@ -4750,7 +4750,7 @@ typedef struct { } GetItemMessage; void CreateGetItemMessages(std::vector messageEntries) { - CustomMessage* customMessage = CustomMessage::Instance; + CustomMessageManager* customMessage = CustomMessageManager::Instance; customMessage->AddCustomMessageTable(Randomizer::getItemMessageTableID); for (GetItemMessage messageEntry : messageEntries) { customMessage->CreateGetItemMessage(Randomizer::getItemMessageTableID, messageEntry.giid, messageEntry.iid, @@ -4761,7 +4761,7 @@ void CreateGetItemMessages(std::vector messageEntries) { } void CreateScrubMessages() { - CustomMessage* customMessage = CustomMessage::Instance; + CustomMessageManager* customMessage = CustomMessageManager::Instance; customMessage->AddCustomMessageTable(Randomizer::scrubMessageTableID); const std::vector prices = { 10, 40 }; for (u8 price : prices) { diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 03a3eb7f5..c931edbd0 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -43,7 +43,7 @@ #include "variables.h" #include "macros.h" #include -#include +#include #ifdef __APPLE__ #include @@ -59,7 +59,7 @@ OTRGlobals* OTRGlobals::Instance; SaveManager* SaveManager::Instance; -CustomMessage* CustomMessage::Instance; +CustomMessageManager* CustomMessageManager::Instance; OTRGlobals::OTRGlobals() { context = Ship::GlobalCtx2::CreateInstance("Ship of Harkinian"); @@ -114,7 +114,7 @@ extern "C" void InitOTR() { #endif OTRGlobals::Instance = new OTRGlobals(); SaveManager::Instance = new SaveManager(); - CustomMessage::Instance = new CustomMessage(); + CustomMessageManager::Instance = new CustomMessageManager(); auto t = OTRGlobals::Instance->context->GetResourceManager()->LoadFile("version"); if (!t->bHasLoadError) @@ -1420,7 +1420,7 @@ extern "C" CustomMessageEntry Randomizer_CopyScrubMessage(u16 scrubTextId) { price = 40; break; } - return CustomMessage::Instance->RetrieveMessage(Randomizer::scrubMessageTableID, price); + return CustomMessageManager::Instance->RetrieveMessage(Randomizer::scrubMessageTableID, price); } extern "C" int CopyScrubMessage(u16 scrubTextId, char* buffer, const int maxBufferSize) { @@ -1496,22 +1496,22 @@ extern "C" int CopyScrubMessage(u16 scrubTextId, char* buffer, const int maxBuff } extern "C" CustomMessageEntry Randomizer_CopyAltarMessage() { - return (LINK_IS_ADULT) ? CustomMessage::Instance->RetrieveMessage(Randomizer::hintMessageTableID, 0x7088) - : CustomMessage::Instance->RetrieveMessage(Randomizer::hintMessageTableID, 0x7040); + return (LINK_IS_ADULT) ? CustomMessageManager::Instance->RetrieveMessage(Randomizer::hintMessageTableID, 0x7088) + : CustomMessageManager::Instance->RetrieveMessage(Randomizer::hintMessageTableID, 0x7040); } extern "C" CustomMessageEntry Randomizer_CopyGanonText() { - return CustomMessage::Instance->RetrieveMessage(Randomizer::hintMessageTableID, 0x70CD); + return CustomMessageManager::Instance->RetrieveMessage(Randomizer::hintMessageTableID, 0x70CD); } extern "C" CustomMessageEntry Randomizer_CopyGanonHintText() { - return CustomMessage::Instance->RetrieveMessage(Randomizer::hintMessageTableID, 0x70CC); + return CustomMessageManager::Instance->RetrieveMessage(Randomizer::hintMessageTableID, 0x70CC); } extern "C" CustomMessageEntry Randomizer_CopyHintFromCheck(RandomizerCheck check) { // we don't want to make a copy of the std::string returned from GetHintFromCheck // so we're just going to let RVO take care of it - const CustomMessageEntry hintText = CustomMessage::Instance->RetrieveMessage(Randomizer::hintMessageTableID, check); + const CustomMessageEntry hintText = CustomMessageManager::Instance->RetrieveMessage(Randomizer::hintMessageTableID, check); return hintText; } @@ -1524,7 +1524,7 @@ extern "C" s32 Randomizer_GetItemIdFromKnownCheck(RandomizerCheck randomizerChec } extern "C" CustomMessageEntry Randomizer_GetCustomGetItemMessage(GetItemID giid, char* buffer, const int maxBufferSize) { - const CustomMessageEntry getItemText = CustomMessage::Instance->RetrieveMessage(Randomizer::getItemMessageTableID, giid); + const CustomMessageEntry getItemText = CustomMessageManager::Instance->RetrieveMessage(Randomizer::getItemMessageTableID, giid); return getItemText; } @@ -1588,7 +1588,7 @@ extern "C" int CustomMessage_RetrieveIfExists(GlobalContext* globalCtx) { } else { textId = 0x00B5; } - messageEntry = CustomMessage::Instance->RetrieveMessage("BaseGameOverrides", textId); + messageEntry = CustomMessageManager::Instance->RetrieveMessage("BaseGameOverrides", textId); } } if (messageEntry.textBoxType != -1) { diff --git a/soh/soh/z_message_OTR.cpp b/soh/soh/z_message_OTR.cpp index c09286fad..64652189a 100644 --- a/soh/soh/z_message_OTR.cpp +++ b/soh/soh/z_message_OTR.cpp @@ -5,7 +5,7 @@ #include "global.h" #include "vt.h" #include -#include +#include extern "C" MessageTableEntry* sNesMessageEntryTablePtr; extern "C" MessageTableEntry* sGerMessageEntryTablePtr; @@ -95,21 +95,21 @@ extern "C" void OTRMessage_Init() sStaffMessageEntryTablePtr[i].msgSize = file2->messages[i].msg.size(); } - CustomMessage::Instance->AddCustomMessageTable(customMessageTableID); - CustomMessage::Instance->CreateGetItemMessage( + CustomMessageManager::Instance->AddCustomMessageTable(customMessageTableID); + CustomMessageManager::Instance->CreateGetItemMessage( customMessageTableID, (GetItemID)0x00B4, ITEM_SKULL_TOKEN, { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, "You got a %rGold Skulltula Token%w!&You've collected %r\x19%w tokens&in total!\x0E\x3C", - "Du erhlst ein %rGoldene&Skulltula-Symbol%w! Du hast&insgesamt %r\x19%w symbol gesammelt!\x0E\x3C", - "Vous obtenez un %rSymbole de&Skulltula d'or%w! Vous avez&collect %r\x19\%w symboles en tout!\x0E\x3C" + "Du erhälst ein %rGoldene&Skulltula-Symbol%w! Du hast&insgesamt %r\x19%w symbol gesammelt!\x0E\x3C", + "Vous obtenez un %rSymbole de&Skulltula d'or%w! Vous avez&collecté %r\x19\%w symboles en tout!\x0E\x3C" } ); - CustomMessage::Instance->CreateGetItemMessage( + CustomMessageManager::Instance->CreateGetItemMessage( customMessageTableID, (GetItemID)0x00B5, ITEM_SKULL_TOKEN, { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, "You got a %rGold Skulltula Token%w!&You've collected %r\x19%w tokens&in total!", - "Du erhlst ein %rGoldene&Skulltula-Symbol%w! Du hast&insgesamt %r\x19%w symbol gesammelt!", - "Vous obtenez un %rSymbole de&Skulltula d'or%w! Vous avez&collect %r\x19\%w symboles en tout!" }); + "Du erhälst ein %rGoldene&Skulltula-Symbol%w! Du hast&insgesamt %r\x19%w symbol gesammelt!", + "Vous obtenez un %rSymbole de&Skulltula d'or%w! Vous avez&collecté %r\x19\%w symboles en tout!" }); } \ No newline at end of file From 59dc52f3940fd236bbd8403f9be6957106f3bd1e Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Tue, 26 Jul 2022 18:44:52 -0400 Subject: [PATCH 28/71] Moves the NOGDI define to CustomMessageManager.h --- soh/include/z64.h | 3 --- soh/soh/Enhancements/custom_message/CustomMessageManager.h | 6 ++++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/soh/include/z64.h b/soh/include/z64.h index a16134f08..fdc634e58 100644 --- a/soh/include/z64.h +++ b/soh/include/z64.h @@ -30,9 +30,6 @@ #include "ichain.h" #include "regs.h" -#define NOGDI -#define WIN32_LEAN_AND_MEAN - #if defined(_WIN64) || defined(__x86_64__) || defined(__arm64__) #define _SOH64 #endif diff --git a/soh/soh/Enhancements/custom_message/CustomMessageManager.h b/soh/soh/Enhancements/custom_message/CustomMessageManager.h index 207d515e3..aed3fbf9a 100644 --- a/soh/soh/Enhancements/custom_message/CustomMessageManager.h +++ b/soh/soh/Enhancements/custom_message/CustomMessageManager.h @@ -1,6 +1,12 @@ #pragma once #include #include + + +#define NOGDI +#define WIN32_LEAN_AND_MEAN + + #include #undef MESSAGE_END From 0ed8c277e8c24357bf7e26db9b5bf8be049c6ce2 Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Tue, 26 Jul 2022 19:07:54 -0400 Subject: [PATCH 29/71] Renames some variables for clarity --- .../custom_message/CustomMessageManager.cpp | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/soh/soh/Enhancements/custom_message/CustomMessageManager.cpp b/soh/soh/Enhancements/custom_message/CustomMessageManager.cpp index 4f69102da..f5c31aa5b 100644 --- a/soh/soh/Enhancements/custom_message/CustomMessageManager.cpp +++ b/soh/soh/Enhancements/custom_message/CustomMessageManager.cpp @@ -71,43 +71,43 @@ void CustomMessageManager::FormatCustomMessage(std::string& message) { } bool CustomMessageManager::InsertCustomMessage(std::string tableID, uint16_t textID, CustomMessageEntry messages) { - auto result = messageTables.find(tableID); - if (result == messageTables.end()) { + auto foundMessageTable = messageTables.find(tableID); + if (foundMessageTable == messageTables.end()) { return false; } - auto& messageTable = result->second; - auto success = messageTable.emplace(textID, messages); - return success.second; + auto& messageTable = foundMessageTable->second; + auto messageInsertResult = messageTable.emplace(textID, messages); + return messageInsertResult.second; } -bool CustomMessageManager::CreateGetItemMessage(std::string tableID, GetItemID giid, ItemID iid, CustomMessageEntry messages) { - FormatCustomMessage(messages.english, iid); - FormatCustomMessage(messages.german, iid); - FormatCustomMessage(messages.french, iid); +bool CustomMessageManager::CreateGetItemMessage(std::string tableID, GetItemID giid, ItemID iid, CustomMessageEntry messageEntry) { + FormatCustomMessage(messageEntry.english, iid); + FormatCustomMessage(messageEntry.german, iid); + FormatCustomMessage(messageEntry.french, iid); const uint16_t textID = giid; - return InsertCustomMessage(tableID, textID, messages); + return InsertCustomMessage(tableID, textID, messageEntry); } -bool CustomMessageManager::CreateMessage(std::string tableID, uint16_t textID, CustomMessageEntry messages) { - FormatCustomMessage(messages.english); - FormatCustomMessage(messages.german); - FormatCustomMessage(messages.french); - return InsertCustomMessage(tableID, textID, messages); +bool CustomMessageManager::CreateMessage(std::string tableID, uint16_t textID, CustomMessageEntry messageEntry) { + FormatCustomMessage(messageEntry.english); + FormatCustomMessage(messageEntry.german); + FormatCustomMessage(messageEntry.french); + return InsertCustomMessage(tableID, textID, messageEntry); } CustomMessageEntry CustomMessageManager::RetrieveMessage(std::string tableID, uint16_t textID) { - std::unordered_map::const_iterator result = messageTables.find(tableID); - if (result == messageTables.end()) { + std::unordered_map::const_iterator foundMessageTable = messageTables.find(tableID); + if (foundMessageTable == messageTables.end()) { return NULL_CUSTOM_MESSAGE; } - CustomMessageTable messageTable = result->second; - std::unordered_map::const_iterator message_pair = messageTable.find(textID); - if (message_pair == messageTable.end()) { + CustomMessageTable messageTable = foundMessageTable->second; + std::unordered_map::const_iterator foundMessage = messageTable.find(textID); + if (foundMessage == messageTable.end()) { return NULL_CUSTOM_MESSAGE; } - CustomMessageEntry message = message_pair->second; + CustomMessageEntry message = foundMessage->second; return message; } From d0968a99c154e1409f80d6428910c28d2ff20af6 Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Tue, 26 Jul 2022 19:25:17 -0400 Subject: [PATCH 30/71] Removes some unneeded function definitions (some of which were already commented out). --- soh/soh/Enhancements/randomizer/randomizer.h | 2 - soh/soh/OTRGlobals.cpp | 72 -------------------- soh/soh/OTRGlobals.h | 3 - 3 files changed, 77 deletions(-) diff --git a/soh/soh/Enhancements/randomizer/randomizer.h b/soh/soh/Enhancements/randomizer/randomizer.h index a89c1f706..1994cfdc4 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.h +++ b/soh/soh/Enhancements/randomizer/randomizer.h @@ -43,10 +43,8 @@ class Randomizer { std::string GetAdultAltarText() const; std::string GetGanonText() const; std::string GetGanonHintText() const; - //CustomMessageEntry GetHintFromCheck(RandomizerCheck check); GetItemID GetRandomizedItemIdFromKnownCheck(RandomizerCheck randomizerCheck, GetItemID ogId); GetItemID GetRandomizedItemId(GetItemID ogId, s16 actorId, s16 actorParams, s16 sceneNum); - //std::string GetCustomGetItemMessage(GlobalContext* globalCtx, GetItemID giid); static void CreateCustomMessages(); }; diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index c931edbd0..6d379ef35 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -1423,78 +1423,6 @@ extern "C" CustomMessageEntry Randomizer_CopyScrubMessage(u16 scrubTextId) { return CustomMessageManager::Instance->RetrieveMessage(Randomizer::scrubMessageTableID, price); } -extern "C" int CopyScrubMessage(u16 scrubTextId, char* buffer, const int maxBufferSize) { - std::string scrubText(""); - int language = CVar_GetS32("gLanguages", 0); - int price = 0; - switch (scrubTextId) { - case 0x10A2: - price = 10; - break; - case 0x10DC: - case 0x10DD: - price = 40; - break; - } - switch (language) { - case 0: default: - scrubText += 0x12; // add the sound - scrubText += 0x38; // sound id - scrubText += 0x82; // sound id - scrubText += "All right! You win! In return for"; - scrubText += 0x01; // newline - scrubText += "sparing me, I will sell you a"; - scrubText += 0x01; // newline - scrubText += 0x05; // change the color - scrubText += 0x42; // green - scrubText += "mysterious item"; - scrubText += 0x05; // change the color - scrubText += 0x40; // white - scrubText += "!"; - scrubText += 0x01; // newline - scrubText += 0x05; // change the color - scrubText += 0x41; // red - scrubText += std::to_string(price); - scrubText += price > 1 ? " Rupees" : " Rupee"; - scrubText += 0x05; // change the color - scrubText += 0x40; // white - scrubText += " it is!"; - scrubText += 0x07; // go to a new message - scrubText += 0x10; // message id - scrubText += 0xA3; // message id - break; - case 2: - scrubText += 0x12; // add the sound - scrubText += 0x38; // sound id - scrubText += 0x82; // sound id - scrubText += "J'abandonne! Tu veux bien m'acheter"; - scrubText += 0x01; // newline - scrubText += "un "; - scrubText += 0x05; // change the color - scrubText += 0x42; // green - scrubText += "objet myst\x96rieux"; - //scrubText += "; - scrubText += 0x05; // change the color - scrubText += 0x40; // white - scrubText += "?"; - scrubText += 0x01; // newline - scrubText += "\x84"; - scrubText += "a fera "; - scrubText += 0x05; // change the color - scrubText += 0x41; // red - scrubText += std::to_string(price) + " Rubis"; - scrubText += 0x05; // change the color - scrubText += 0x40; // white - scrubText += "!"; - scrubText += 0x07; // go to a new message - scrubText += 0x10; // message id - scrubText += 0xA3; // message id - break; - } - - return CopyStringToCharBuffer(scrubText, buffer, maxBufferSize); -} - extern "C" CustomMessageEntry Randomizer_CopyAltarMessage() { return (LINK_IS_ADULT) ? CustomMessageManager::Instance->RetrieveMessage(Randomizer::hintMessageTableID, 0x7088) : CustomMessageManager::Instance->RetrieveMessage(Randomizer::hintMessageTableID, 0x7040); diff --git a/soh/soh/OTRGlobals.h b/soh/soh/OTRGlobals.h index 4a924ed61..76212c676 100644 --- a/soh/soh/OTRGlobals.h +++ b/soh/soh/OTRGlobals.h @@ -87,9 +87,6 @@ Sprite* GetSeedTexture(uint8_t index); void Randomizer_LoadSettings(const char* spoilerFileName); u8 Randomizer_GetSettingValue(RandomizerSettingKey randoSettingKey); RandomizerCheck Randomizer_GetCheckFromActor(s16 actorId, s16 actorParams, s16 sceneNum); -int Randomizer_CopyAltarMessage(char* buffer, const int maxBufferSize); -int Randomizer_CopyGanonText(char* buffer, const int maxBufferSize); -int Randomizer_CopyGanonHintText(char* buffer, const int maxBufferSize); void Randomizer_LoadHintLocations(const char* spoilerFileName); void Randomizer_LoadItemLocations(const char* spoilerFileName, bool silent); s16 Randomizer_GetItemModelFromId(s16 itemId); From 5a97e9f0dea1faf45504e09330b03a38b7bf61e1 Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Tue, 26 Jul 2022 20:11:17 -0400 Subject: [PATCH 31/71] Factors away some raw textIDs into an enum with descriptive names. --- soh/soh.vcxproj | 1 + soh/soh.vcxproj.filters | 3 ++ .../custom_message/CustomMessageTypes.h | 14 +++++++++ soh/soh/OTRGlobals.cpp | 31 ++++++++++--------- soh/soh/z_message_OTR.cpp | 5 +-- .../actors/ovl_player_actor/z_player.c | 19 ++++++------ 6 files changed, 47 insertions(+), 26 deletions(-) create mode 100644 soh/soh/Enhancements/custom_message/CustomMessageTypes.h diff --git a/soh/soh.vcxproj b/soh/soh.vcxproj index 27c1571da..12148eae6 100644 --- a/soh/soh.vcxproj +++ b/soh/soh.vcxproj @@ -946,6 +946,7 @@ + diff --git a/soh/soh.vcxproj.filters b/soh/soh.vcxproj.filters index ed0a1f200..554f6a754 100644 --- a/soh/soh.vcxproj.filters +++ b/soh/soh.vcxproj.filters @@ -4073,6 +4073,9 @@ Header Files\soh\Enhancements\custom-message + + Source Files\soh\Enhancements\custom-message + diff --git a/soh/soh/Enhancements/custom_message/CustomMessageTypes.h b/soh/soh/Enhancements/custom_message/CustomMessageTypes.h new file mode 100644 index 000000000..dac9362d9 --- /dev/null +++ b/soh/soh/Enhancements/custom_message/CustomMessageTypes.h @@ -0,0 +1,14 @@ +#pragma once + +typedef enum { + TEXT_GS_NO_FREEZE = 0xB4, + TEXT_GS_FREEZE = 0xB5, + TEXT_RANDOMIZER_GI_ESCAPE_HATCH = 0xF8, + TEXT_SCRUB_POH = 0x10A2, + TEXT_SCRUB_STICK_UPGRADE = 0x10DC, + TEXT_SCRUB_NUT_UPGRADE = 0x10DD, + TEXT_RANDOMIZER_GOSSIP_STONE_HINTS = 0x2053, + TEXT_ALTAR_CHILD = 0x7040, + TEXT_ALTAR_ADULT = 0x7088, + TEXT_GANONDORF = 0x70CC, +} TextIDs; \ No newline at end of file diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 6d379ef35..29c763998 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -56,6 +56,7 @@ #endif #include +#include OTRGlobals* OTRGlobals::Instance; SaveManager* SaveManager::Instance; @@ -1412,11 +1413,11 @@ extern "C" RandomizerCheck Randomizer_GetCheckFromActor(s16 sceneNum, s16 actorI extern "C" CustomMessageEntry Randomizer_CopyScrubMessage(u16 scrubTextId) { int price = 0; switch (scrubTextId) { - case 0x10A2: + case TEXT_SCRUB_POH: price = 10; break; - case 0x10DC: - case 0x10DD: + case TEXT_SCRUB_STICK_UPGRADE: + case TEXT_SCRUB_NUT_UPGRADE: price = 40; break; } @@ -1424,16 +1425,17 @@ extern "C" CustomMessageEntry Randomizer_CopyScrubMessage(u16 scrubTextId) { } extern "C" CustomMessageEntry Randomizer_CopyAltarMessage() { - return (LINK_IS_ADULT) ? CustomMessageManager::Instance->RetrieveMessage(Randomizer::hintMessageTableID, 0x7088) - : CustomMessageManager::Instance->RetrieveMessage(Randomizer::hintMessageTableID, 0x7040); + return (LINK_IS_ADULT) + ? CustomMessageManager::Instance->RetrieveMessage(Randomizer::hintMessageTableID, TEXT_ALTAR_ADULT) + : CustomMessageManager::Instance->RetrieveMessage(Randomizer::hintMessageTableID, TEXT_ALTAR_CHILD); } extern "C" CustomMessageEntry Randomizer_CopyGanonText() { - return CustomMessageManager::Instance->RetrieveMessage(Randomizer::hintMessageTableID, 0x70CD); + return CustomMessageManager::Instance->RetrieveMessage(Randomizer::hintMessageTableID, TEXT_GANONDORF + 1); } extern "C" CustomMessageEntry Randomizer_CopyGanonHintText() { - return CustomMessageManager::Instance->RetrieveMessage(Randomizer::hintMessageTableID, 0x70CC); + return CustomMessageManager::Instance->RetrieveMessage(Randomizer::hintMessageTableID, TEXT_GANONDORF); } extern "C" CustomMessageEntry Randomizer_CopyHintFromCheck(RandomizerCheck check) { @@ -1464,7 +1466,7 @@ extern "C" int CustomMessage_RetrieveIfExists(GlobalContext* globalCtx) { const int maxBufferSize = sizeof(font->msgBuf); CustomMessageEntry messageEntry; if (gSaveContext.n64ddFlag) { - if (textId == 0xF8) { + if (textId == TEXT_RANDOMIZER_GI_ESCAPE_HATCH) { messageEntry = Randomizer_GetCustomGetItemMessage((GetItemID)GET_PLAYER(globalCtx)->getItemId, buffer, maxBufferSize); } else if (textId == 0x2053 && Randomizer_GetSettingValue(RSK_GOSSIP_STONE_HINTS) != 0 && @@ -1495,26 +1497,25 @@ extern "C" int CustomMessage_RetrieveIfExists(GlobalContext* globalCtx) { Randomizer_GetCheckFromActor(globalCtx->sceneNum, msgCtx->talkActor->id, actorParams); messageEntry = Randomizer_CopyHintFromCheck(hintCheck); - } else if (textId == 0x7040 || textId == 0x7088) { + } else if (textId == TEXT_ALTAR_CHILD || textId == TEXT_ALTAR_ADULT) { // rando hints at altar messageEntry = Randomizer_CopyAltarMessage(); - } else if (gSaveContext.n64ddFlag && textId == 0x70CC) { + } else if (textId == TEXT_GANONDORF) { if (INV_CONTENT(ITEM_ARROW_LIGHT) == ITEM_ARROW_LIGHT) { messageEntry = Randomizer_CopyGanonText(); } else { messageEntry = Randomizer_CopyGanonHintText(); } - } else if (textId == 0x10A2 || textId == 0x10DC || textId == 0x10DD) { + } else if (textId == TEXT_SCRUB_POH || textId == TEXT_SCRUB_STICK_UPGRADE || textId == TEXT_SCRUB_NUT_UPGRADE) { messageEntry = Randomizer_CopyScrubMessage(textId); } } - if (textId == 0x00B4 || textId == 0x00B5) { + if (textId == TEXT_GS_NO_FREEZE || textId == TEXT_GS_FREEZE) { if (CVar_GetS32("gInjectSkulltulaCount", 0) != 0) { - font->charTexBuf[0] = 0x03; if (CVar_GetS32("gSkulltulaFreeze", 0) != 0) { - textId = 0x00B4; + textId = TEXT_GS_NO_FREEZE; } else { - textId = 0x00B5; + textId = TEXT_GS_FREEZE; } messageEntry = CustomMessageManager::Instance->RetrieveMessage("BaseGameOverrides", textId); } diff --git a/soh/soh/z_message_OTR.cpp b/soh/soh/z_message_OTR.cpp index 64652189a..188e569bb 100644 --- a/soh/soh/z_message_OTR.cpp +++ b/soh/soh/z_message_OTR.cpp @@ -6,6 +6,7 @@ #include "vt.h" #include #include +#include extern "C" MessageTableEntry* sNesMessageEntryTablePtr; extern "C" MessageTableEntry* sGerMessageEntryTablePtr; @@ -97,7 +98,7 @@ extern "C" void OTRMessage_Init() CustomMessageManager::Instance->AddCustomMessageTable(customMessageTableID); CustomMessageManager::Instance->CreateGetItemMessage( - customMessageTableID, (GetItemID)0x00B4, ITEM_SKULL_TOKEN, + customMessageTableID, (GetItemID)TEXT_GS_NO_FREEZE, ITEM_SKULL_TOKEN, { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, "You got a %rGold Skulltula Token%w!&You've collected %r\x19%w tokens&in total!\x0E\x3C", @@ -106,7 +107,7 @@ extern "C" void OTRMessage_Init() } ); CustomMessageManager::Instance->CreateGetItemMessage( - customMessageTableID, (GetItemID)0x00B5, ITEM_SKULL_TOKEN, + customMessageTableID, (GetItemID)TEXT_GS_FREEZE, ITEM_SKULL_TOKEN, { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, "You got a %rGold Skulltula Token%w!&You've collected %r\x19%w tokens&in total!", 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 ee13e0261..e1e3813f5 100644 --- a/soh/src/overlays/actors/ovl_player_actor/z_player.c +++ b/soh/src/overlays/actors/ovl_player_actor/z_player.c @@ -20,6 +20,7 @@ #include "objects/gameplay_keep/gameplay_keep.h" #include "objects/object_link_child/object_link_child.h" #include "textures/icon_item_24_static/icon_item_24_static.h" +#include "../../../../soh/Enhancements/custom_message/CustomMessageTypes.h" typedef struct { /* 0x00 */ u8 itemId; @@ -652,15 +653,15 @@ static GetItemEntry sGetItemTable[] = { GET_ITEM(ITEM_DOUBLE_MAGIC, OBJECT_GI_MAGICPOT, GID_MAGIC_LARGE, 0xE8, 0x80, CHEST_ANIM_LONG), GET_ITEM(ITEM_DOUBLE_DEFENSE, OBJECT_GI_HEARTS, GID_HEART_CONTAINER, 0xE9, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_BOTTLE_WITH_RED_POTION, OBJECT_GI_LIQUID, GID_POTION_RED, 0xF8, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_BOTTLE_WITH_GREEN_POTION, OBJECT_GI_LIQUID, GID_POTION_GREEN, 0xF8, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_BOTTLE_WITH_BLUE_POTION, OBJECT_GI_LIQUID, GID_POTION_BLUE, 0xF8, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_BOTTLE_WITH_FAIRY, OBJECT_GI_BOTTLE, GID_BOTTLE, 0xF8, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_BOTTLE_WITH_FISH, OBJECT_GI_FISH, GID_FISH, 0xF8, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_BOTTLE_WITH_BLUE_FIRE, OBJECT_GI_FIRE, GID_BLUE_FIRE, 0xF8, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_BOTTLE_WITH_BUGS, OBJECT_GI_INSECT, GID_BUG, 0xF8, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_BOTTLE_WITH_POE, OBJECT_GI_GHOST, GID_POE, 0xF8, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_BOTTLE_WITH_BIG_POE, OBJECT_GI_GHOST, GID_BIG_POE, 0xF8, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_BOTTLE_WITH_RED_POTION, OBJECT_GI_LIQUID, GID_POTION_RED, TEXT_RANDOMIZER_GI_ESCAPE_HATCH, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_BOTTLE_WITH_GREEN_POTION, OBJECT_GI_LIQUID, GID_POTION_GREEN, TEXT_RANDOMIZER_GI_ESCAPE_HATCH, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_BOTTLE_WITH_BLUE_POTION, OBJECT_GI_LIQUID, GID_POTION_BLUE, TEXT_RANDOMIZER_GI_ESCAPE_HATCH, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_BOTTLE_WITH_FAIRY, OBJECT_GI_BOTTLE, GID_BOTTLE, TEXT_RANDOMIZER_GI_ESCAPE_HATCH, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_BOTTLE_WITH_FISH, OBJECT_GI_FISH, GID_FISH, TEXT_RANDOMIZER_GI_ESCAPE_HATCH, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_BOTTLE_WITH_BLUE_FIRE, OBJECT_GI_FIRE, GID_BLUE_FIRE, TEXT_RANDOMIZER_GI_ESCAPE_HATCH, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_BOTTLE_WITH_BUGS, OBJECT_GI_INSECT, GID_BUG, TEXT_RANDOMIZER_GI_ESCAPE_HATCH, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_BOTTLE_WITH_POE, OBJECT_GI_GHOST, GID_POE, TEXT_RANDOMIZER_GI_ESCAPE_HATCH, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_BOTTLE_WITH_BIG_POE, OBJECT_GI_GHOST, GID_BIG_POE, TEXT_RANDOMIZER_GI_ESCAPE_HATCH, 0x80, CHEST_ANIM_LONG), GET_ITEM_NONE, GET_ITEM_NONE, From e8d2b0cceb651a7874e18f6edd49412a89f7458a Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Tue, 26 Jul 2022 20:46:49 -0400 Subject: [PATCH 32/71] Hopefully fixes build errors on Linux-CI. --- .../custom_message/CustomMessageManager.h | 33 +++++++++++++++---- soh/soh/OTRGlobals.cpp | 1 + soh/soh/z_message_OTR.cpp | 1 + 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/soh/soh/Enhancements/custom_message/CustomMessageManager.h b/soh/soh/Enhancements/custom_message/CustomMessageManager.h index aed3fbf9a..c08aaf07d 100644 --- a/soh/soh/Enhancements/custom_message/CustomMessageManager.h +++ b/soh/soh/Enhancements/custom_message/CustomMessageManager.h @@ -1,13 +1,7 @@ #pragma once #include #include - - -#define NOGDI -#define WIN32_LEAN_AND_MEAN - - -#include +#include "z64item.h" #undef MESSAGE_END @@ -20,6 +14,31 @@ #define QM_YELLOW 0x46 #define QM_BLACK 0x47 +#ifndef MESSAGE_DATA_STATIC_H + +typedef enum { + /* 0 */ TEXTBOX_TYPE_BLACK, + /* 1 */ TEXTBOX_TYPE_WOODEN, + /* 2 */ TEXTBOX_TYPE_BLUE, + /* 3 */ TEXTBOX_TYPE_OCARINA, + /* 4 */ TEXTBOX_TYPE_NONE_BOTTOM, + /* 5 */ TEXTBOX_TYPE_NONE_NO_SHADOW, + /* 11 */ TEXTBOX_TYPE_CREDITS = 11 +} TextBoxType; + +typedef enum { + /* 0 */ TEXTBOX_BG_CROSS +} TextBoxBackground; + +typedef enum { + /* 0 */ TEXTBOX_POS_VARIABLE, + /* 1 */ TEXTBOX_POS_TOP, + /* 2 */ TEXTBOX_POS_MIDDLE, + /* 3 */ TEXTBOX_POS_BOTTOM +} TextBoxPosition; + +#endif + typedef struct { TextBoxType textBoxType; TextBoxPosition textBoxPos; diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 29c763998..aa28b5e98 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -57,6 +57,7 @@ #include #include +#include OTRGlobals* OTRGlobals::Instance; SaveManager* SaveManager::Instance; diff --git a/soh/soh/z_message_OTR.cpp b/soh/soh/z_message_OTR.cpp index 188e569bb..f4c836d94 100644 --- a/soh/soh/z_message_OTR.cpp +++ b/soh/soh/z_message_OTR.cpp @@ -5,6 +5,7 @@ #include "global.h" #include "vt.h" #include +#include #include #include From 2f9874c68f2a8e37839be4e382c686a7a56d3136 Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Sun, 31 Jul 2022 19:31:22 -0400 Subject: [PATCH 33/71] Cleanup. --- .../custom_message/CustomMessageManager.cpp | 6 +++--- soh/soh/Enhancements/randomizer/randomizer.cpp | 18 +++++++----------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/soh/soh/Enhancements/custom_message/CustomMessageManager.cpp b/soh/soh/Enhancements/custom_message/CustomMessageManager.cpp index f5c31aa5b..e4e190c5c 100644 --- a/soh/soh/Enhancements/custom_message/CustomMessageManager.cpp +++ b/soh/soh/Enhancements/custom_message/CustomMessageManager.cpp @@ -112,11 +112,11 @@ CustomMessageEntry CustomMessageManager::RetrieveMessage(std::string tableID, ui } bool CustomMessageManager::ClearMessageTable(std::string tableID) { - auto result = messageTables.find(tableID); - if (result == messageTables.end()) { + auto foundMessageTable = messageTables.find(tableID); + if (foundMessageTable == messageTables.end()) { return false; } - auto& messageTable = result->second; + auto& messageTable = foundMessageTable->second; messageTable.clear(); } diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index 00bcadaf1..dcfa36675 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -1843,7 +1843,7 @@ std::string FormatJsonHintText(std::string jsonHint) { start_pos += textBoxSpecialCharacterString.length(); } } - + // add icons to altar text for (char iconChar : {'0', '1', '2', '3', '4', '5', '6', '7', '8', 'o', 'c', 'i', 'l', 'b', 'L', 'k'}) { std::string textToReplace = "$"; @@ -2403,10 +2403,6 @@ std::string Randomizer::GetGanonHintText() const { return ganonHintText; } -//CustomMessageEntry Randomizer::GetHintFromCheck(RandomizerCheck check) { -// return CustomMessage::Instance->RetrieveMessage(hintMessageTableID, check); -//} - u8 Randomizer::GetRandoSettingValue(RandomizerSettingKey randoSettingKey) { return this->randoSettings[randoSettingKey]; } @@ -4750,10 +4746,10 @@ typedef struct { } GetItemMessage; void CreateGetItemMessages(std::vector messageEntries) { - CustomMessageManager* customMessage = CustomMessageManager::Instance; - customMessage->AddCustomMessageTable(Randomizer::getItemMessageTableID); + CustomMessageManager* customMessageManager = CustomMessageManager::Instance; + customMessageManager->AddCustomMessageTable(Randomizer::getItemMessageTableID); for (GetItemMessage messageEntry : messageEntries) { - customMessage->CreateGetItemMessage(Randomizer::getItemMessageTableID, messageEntry.giid, messageEntry.iid, + customMessageManager->CreateGetItemMessage(Randomizer::getItemMessageTableID, messageEntry.giid, messageEntry.iid, { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, messageEntry.english, messageEntry.german, messageEntry.french }); @@ -4761,11 +4757,11 @@ void CreateGetItemMessages(std::vector messageEntries) { } void CreateScrubMessages() { - CustomMessageManager* customMessage = CustomMessageManager::Instance; - customMessage->AddCustomMessageTable(Randomizer::scrubMessageTableID); + CustomMessageManager* customMessageManager = CustomMessageManager::Instance; + customMessageManager->AddCustomMessageTable(Randomizer::scrubMessageTableID); const std::vector prices = { 10, 40 }; for (u8 price : prices) { - customMessage->CreateMessage(Randomizer::scrubMessageTableID, price, + customMessageManager->CreateMessage(Randomizer::scrubMessageTableID, price, { TEXTBOX_TYPE_BLACK, TEXTBOX_POS_BOTTOM, "\x12\x38\x82\All right! You win! In return for&sparing me, I will sell you a&%gmysterious item%w!&%r" + std::to_string(price) + " Rupees%w it is!\x07\x10\xA3", From 4d30cc50a1cbde78132f4f79f49cdd2765c818d4 Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Mon, 1 Aug 2022 21:21:29 -0400 Subject: [PATCH 34/71] Adds newlines to the ends of some files. --- soh/soh/Enhancements/custom_message/CustomMessageManager.cpp | 2 +- soh/soh/Enhancements/custom_message/CustomMessageManager.h | 2 +- soh/soh/Enhancements/custom_message/CustomMessageTypes.h | 2 +- soh/soh/z_message_OTR.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/soh/soh/Enhancements/custom_message/CustomMessageManager.cpp b/soh/soh/Enhancements/custom_message/CustomMessageManager.cpp index e4e190c5c..d7dd08991 100644 --- a/soh/soh/Enhancements/custom_message/CustomMessageManager.cpp +++ b/soh/soh/Enhancements/custom_message/CustomMessageManager.cpp @@ -147,4 +147,4 @@ std::string CustomMessageManager::WAIT_FOR_INPUT() { std::string CustomMessageManager::PLAYER_NAME() { return "\x0F"s; -} \ No newline at end of file +} diff --git a/soh/soh/Enhancements/custom_message/CustomMessageManager.h b/soh/soh/Enhancements/custom_message/CustomMessageManager.h index c08aaf07d..6156f2ef8 100644 --- a/soh/soh/Enhancements/custom_message/CustomMessageManager.h +++ b/soh/soh/Enhancements/custom_message/CustomMessageManager.h @@ -91,4 +91,4 @@ class CustomMessageManager { CustomMessageEntry RetrieveMessage(std::string tableID, uint16_t textID); bool ClearMessageTable(std::string tableID); bool AddCustomMessageTable(std::string tableID); -}; \ No newline at end of file +}; diff --git a/soh/soh/Enhancements/custom_message/CustomMessageTypes.h b/soh/soh/Enhancements/custom_message/CustomMessageTypes.h index dac9362d9..fd065f354 100644 --- a/soh/soh/Enhancements/custom_message/CustomMessageTypes.h +++ b/soh/soh/Enhancements/custom_message/CustomMessageTypes.h @@ -11,4 +11,4 @@ typedef enum { TEXT_ALTAR_CHILD = 0x7040, TEXT_ALTAR_ADULT = 0x7088, TEXT_GANONDORF = 0x70CC, -} TextIDs; \ No newline at end of file +} TextIDs; diff --git a/soh/soh/z_message_OTR.cpp b/soh/soh/z_message_OTR.cpp index f4c836d94..cdc1c79e8 100644 --- a/soh/soh/z_message_OTR.cpp +++ b/soh/soh/z_message_OTR.cpp @@ -114,4 +114,4 @@ extern "C" void OTRMessage_Init() "You got a %rGold Skulltula Token%w!&You've collected %r\x19%w tokens&in total!", "Du erhälst ein %rGoldene&Skulltula-Symbol%w! Du hast&insgesamt %r\x19%w symbol gesammelt!", "Vous obtenez un %rSymbole de&Skulltula d'or%w! Vous avez&collecté %r\x19\%w symboles en tout!" }); -} \ No newline at end of file +} From eae97cff798dd259eedfc0dbc7cf63e92145037b Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Mon, 1 Aug 2022 21:44:28 -0400 Subject: [PATCH 35/71] Addresses most of bria's comments. --- .../custom_message/CustomMessageTypes.h | 21 ++++++- .../Enhancements/randomizer/randomizer.cpp | 59 ++++++------------- soh/soh/OTRGlobals.cpp | 26 ++++---- .../actors/ovl_player_actor/z_player.c | 18 +++--- 4 files changed, 59 insertions(+), 65 deletions(-) diff --git a/soh/soh/Enhancements/custom_message/CustomMessageTypes.h b/soh/soh/Enhancements/custom_message/CustomMessageTypes.h index fd065f354..d2f30f123 100644 --- a/soh/soh/Enhancements/custom_message/CustomMessageTypes.h +++ b/soh/soh/Enhancements/custom_message/CustomMessageTypes.h @@ -3,7 +3,7 @@ typedef enum { TEXT_GS_NO_FREEZE = 0xB4, TEXT_GS_FREEZE = 0xB5, - TEXT_RANDOMIZER_GI_ESCAPE_HATCH = 0xF8, + TEXT_RANDOMIZER_CUSTOM_ITEM = 0xF8, TEXT_SCRUB_POH = 0x10A2, TEXT_SCRUB_STICK_UPGRADE = 0x10DC, TEXT_SCRUB_NUT_UPGRADE = 0x10DD, @@ -11,4 +11,23 @@ typedef enum { TEXT_ALTAR_CHILD = 0x7040, TEXT_ALTAR_ADULT = 0x7088, TEXT_GANONDORF = 0x70CC, + TEXT_GANONDORF_NOHINT = 0x70CD } TextIDs; + +#ifdef __cplusplus + +typedef struct { + GetItemID giid; + ItemID iid; + std::string english; + std::string german; + std::string french; +} GetItemMessage; + +#define GIMESSAGE(giid, iid, english, german, french) \ + { giid, iid, english, german, french } + +#define GIMESSAGE_UNTRANSLATED(giid, iid, message) \ + { giid, iid, message, message, message } + +#endif diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index dcfa36675..c0077a97e 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -15,6 +15,7 @@ #include #include "Lib/ImGui/imgui_internal.h" #include +#include using json = nlohmann::json; using namespace std::literals::string_literals; @@ -1487,19 +1488,19 @@ void Randomizer::LoadHintLocations(const char* spoilerFileName) { CustomMessageManager::Instance->AddCustomMessageTable(Randomizer::hintMessageTableID); CustomMessageManager::Instance->CreateMessage( - Randomizer::hintMessageTableID, 0x7040, + Randomizer::hintMessageTableID, TEXT_ALTAR_CHILD, { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, gSaveContext.childAltarText, gSaveContext.childAltarText, gSaveContext.childAltarText }); CustomMessageManager::Instance->CreateMessage( - Randomizer::hintMessageTableID, 0x7088, + Randomizer::hintMessageTableID, TEXT_ALTAR_ADULT, { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, gSaveContext.adultAltarText, gSaveContext.adultAltarText, gSaveContext.adultAltarText }); CustomMessageManager::Instance->CreateMessage( - Randomizer::hintMessageTableID, 0x70CC, + Randomizer::hintMessageTableID, TEXT_GANONDORF, { TEXTBOX_TYPE_BLACK, TEXTBOX_POS_BOTTOM, gSaveContext.ganonHintText, gSaveContext.ganonHintText, gSaveContext.ganonHintText }); CustomMessageManager::Instance->CreateMessage( - Randomizer::hintMessageTableID, 0x70CD, + Randomizer::hintMessageTableID, TEXT_GANONDORF_NOHINT, { TEXTBOX_TYPE_BLACK, TEXTBOX_POS_BOTTOM, gSaveContext.ganonText, gSaveContext.ganonText, gSaveContext.ganonText }); @@ -4737,14 +4738,6 @@ void DrawRandoEditor(bool& open) { ImGui::End(); }*/ -typedef struct { - GetItemID giid; - ItemID iid; - std::string english; - std::string german; - std::string french; -} GetItemMessage; - void CreateGetItemMessages(std::vector messageEntries) { CustomMessageManager* customMessageManager = CustomMessageManager::Instance; customMessageManager->AddCustomMessageTable(Randomizer::getItemMessageTableID); @@ -4765,6 +4758,7 @@ void CreateScrubMessages() { { TEXTBOX_TYPE_BLACK, TEXTBOX_POS_BOTTOM, "\x12\x38\x82\All right! You win! In return for&sparing me, I will sell you a&%gmysterious item%w!&%r" + std::to_string(price) + " Rupees%w it is!\x07\x10\xA3", + // RANDTODO: Translate the below string to German. "\x12\x38\x82\All right! You win! In return for&sparing me, I will sell you a&%gmysterious item%w!&%r" + std::to_string(price) + " Rupees%w it is!\x07\x10\xA3", "\x12\x38\x82J'abandonne! Tu veux bien m'acheter&un %gobjet mystérieux%w?&Ça fera %r" + @@ -4773,45 +4767,26 @@ void CreateScrubMessages() { } } -#define GIMESSAGE(giid, iid, english, german, french) \ - { giid, iid, english, german, french } - void Randomizer::CreateCustomMessages() { + // RANDTODO: Translate into french and german and replace GIMESSAGE_UNTRANSLATED + // with GIMESSAGE(getItemID, itemID, english, german, french). const std::vector getItemMessages = { - GIMESSAGE(GI_BOTTLE_WITH_BLUE_FIRE, ITEM_BLUE_FIRE, - "You got a %rBottle with Blue &Fire%w! Use it to melt Red Ice!", - "You got a %rBottle with Blue &Fire%w! Use it to melt Red Ice!", + GIMESSAGE_UNTRANSLATED(GI_BOTTLE_WITH_BLUE_FIRE, ITEM_BLUE_FIRE, "You got a %rBottle with Blue &Fire%w! Use it to melt Red Ice!"), - GIMESSAGE(GI_BOTTLE_WITH_BIG_POE, ITEM_BIG_POE, - "You got a %rBig Poe in a Bottle%w!&Sell it to the Ghost Shop!", - "You got a %rBig Poe in a Bottle%w!&Sell it to the Ghost Shop!", + GIMESSAGE_UNTRANSLATED(GI_BOTTLE_WITH_BIG_POE, ITEM_BIG_POE, "You got a %rBig Poe in a Bottle%w!&Sell it to the Ghost Shop!"), - GIMESSAGE(GI_BOTTLE_WITH_BLUE_POTION, ITEM_POTION_BLUE, - "You got a %rBottle of Blue Potion%w!&Drink it to replenish your&%ghealth%w and %bmagic%w!", - "You got a %rBottle of Blue Potion%w!&Drink it to replenish your&%ghealth%w and %bmagic%w!", + GIMESSAGE_UNTRANSLATED(GI_BOTTLE_WITH_BLUE_POTION, ITEM_POTION_BLUE, "You got a %rBottle of Blue Potion%w!&Drink it to replenish your&%ghealth%w and %bmagic%w!"), - GIMESSAGE(GI_BOTTLE_WITH_FISH, ITEM_FISH, - "You got a %rFish in a Bottle%w!&It looks fresh and delicious!&They say Jabu-Jabu loves them!", - "You got a %rFish in a Bottle%w!&It looks fresh and delicious!&They say Jabu-Jabu loves them!", + GIMESSAGE_UNTRANSLATED(GI_BOTTLE_WITH_FISH, ITEM_FISH, "You got a %rFish in a Bottle%w!&It looks fresh and delicious!&They say Jabu-Jabu loves them!"), - GIMESSAGE(GI_BOTTLE_WITH_BUGS, ITEM_BUG, - "You got a %rBug in a Bottle%w!&They love to burrow in&dirt holes!", - "You got a %rBug in a Bottle%w!&They love to burrow in&dirt holes!", + GIMESSAGE_UNTRANSLATED(GI_BOTTLE_WITH_BUGS, ITEM_BUG, "You got a %rBug in a Bottle%w!&They love to burrow in&dirt holes!"), - GIMESSAGE(GI_BOTTLE_WITH_FAIRY, ITEM_FAIRY, "You got a %rFairy in a Bottle%w!&Use it wisely!", - "You got a %rFairy in a Bottle%w!&Use it wisely!", - "You got a %rFairy in a Bottle%w!&Use it wisely!"), - GIMESSAGE(GI_BOTTLE_WITH_RED_POTION, ITEM_POTION_RED, - "You got a %rBottle of Red Potion%w!&Drink it to replenish your&%ghealth%w!", - "You got a %rBottle of Red Potion%w!&Drink it to replenish your&%ghealth%w!", + GIMESSAGE_UNTRANSLATED(GI_BOTTLE_WITH_FAIRY, ITEM_FAIRY, "You got a %rFairy in a Bottle%w!&Use it wisely!"), + GIMESSAGE_UNTRANSLATED(GI_BOTTLE_WITH_RED_POTION, ITEM_POTION_RED, "You got a %rBottle of Red Potion%w!&Drink it to replenish your&%ghealth%w!"), - GIMESSAGE(GI_BOTTLE_WITH_GREEN_POTION, ITEM_POTION_GREEN, - "You got a %rBottle of Green Potion%w!&Drink it to replenish your&%bmagic%w!", - "You got a %rBottle of Green Potion%w!&Drink it to replenish your&%bmagic%w!", + GIMESSAGE_UNTRANSLATED(GI_BOTTLE_WITH_GREEN_POTION, ITEM_POTION_GREEN, "You got a %rBottle of Green Potion%w!&Drink it to replenish your&%bmagic%w!"), - GIMESSAGE(GI_BOTTLE_WITH_POE, ITEM_POE, - "You got a %rPoe in a Bottle%w!&That creepy Ghost Shop might&be interested in this...", - "You got a %rPoe in a Bottle%w!&That creepy Ghost Shop might&be interested in this...", + GIMESSAGE_UNTRANSLATED(GI_BOTTLE_WITH_POE, ITEM_POE, "You got a %rPoe in a Bottle%w!&That creepy Ghost Shop might&be interested in this..."), }; CreateGetItemMessages(getItemMessages); diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index aa28b5e98..088e589fa 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -1411,7 +1411,7 @@ extern "C" RandomizerCheck Randomizer_GetCheckFromActor(s16 sceneNum, s16 actorI return OTRGlobals::Instance->gRandomizer->GetCheckFromActor(sceneNum, actorId, actorParams); } -extern "C" CustomMessageEntry Randomizer_CopyScrubMessage(u16 scrubTextId) { +extern "C" CustomMessageEntry Randomizer_GetScrubMessage(u16 scrubTextId) { int price = 0; switch (scrubTextId) { case TEXT_SCRUB_POH: @@ -1425,21 +1425,21 @@ extern "C" CustomMessageEntry Randomizer_CopyScrubMessage(u16 scrubTextId) { return CustomMessageManager::Instance->RetrieveMessage(Randomizer::scrubMessageTableID, price); } -extern "C" CustomMessageEntry Randomizer_CopyAltarMessage() { +extern "C" CustomMessageEntry Randomizer_GetAltarMessage() { return (LINK_IS_ADULT) ? CustomMessageManager::Instance->RetrieveMessage(Randomizer::hintMessageTableID, TEXT_ALTAR_ADULT) : CustomMessageManager::Instance->RetrieveMessage(Randomizer::hintMessageTableID, TEXT_ALTAR_CHILD); } -extern "C" CustomMessageEntry Randomizer_CopyGanonText() { - return CustomMessageManager::Instance->RetrieveMessage(Randomizer::hintMessageTableID, TEXT_GANONDORF + 1); +extern "C" CustomMessageEntry Randomizer_GetGanonText() { + return CustomMessageManager::Instance->RetrieveMessage(Randomizer::hintMessageTableID, TEXT_GANONDORF_NOHINT); } -extern "C" CustomMessageEntry Randomizer_CopyGanonHintText() { +extern "C" CustomMessageEntry Randomizer_GetGanonHintText() { return CustomMessageManager::Instance->RetrieveMessage(Randomizer::hintMessageTableID, TEXT_GANONDORF); } -extern "C" CustomMessageEntry Randomizer_CopyHintFromCheck(RandomizerCheck check) { +extern "C" CustomMessageEntry Randomizer_GetHintFromCheck(RandomizerCheck check) { // we don't want to make a copy of the std::string returned from GetHintFromCheck // so we're just going to let RVO take care of it const CustomMessageEntry hintText = CustomMessageManager::Instance->RetrieveMessage(Randomizer::hintMessageTableID, check); @@ -1467,10 +1467,10 @@ extern "C" int CustomMessage_RetrieveIfExists(GlobalContext* globalCtx) { const int maxBufferSize = sizeof(font->msgBuf); CustomMessageEntry messageEntry; if (gSaveContext.n64ddFlag) { - if (textId == TEXT_RANDOMIZER_GI_ESCAPE_HATCH) { + if (textId == TEXT_RANDOMIZER_CUSTOM_ITEM) { messageEntry = Randomizer_GetCustomGetItemMessage((GetItemID)GET_PLAYER(globalCtx)->getItemId, buffer, maxBufferSize); - } else if (textId == 0x2053 && Randomizer_GetSettingValue(RSK_GOSSIP_STONE_HINTS) != 0 && + } else if (textId == TEXT_RANDOMIZER_GOSSIP_STONE_HINTS && Randomizer_GetSettingValue(RSK_GOSSIP_STONE_HINTS) != 0 && (Randomizer_GetSettingValue(RSK_GOSSIP_STONE_HINTS) == 1 || (Randomizer_GetSettingValue(RSK_GOSSIP_STONE_HINTS) == 2 && Player_GetMask(globalCtx) == PLAYER_MASK_TRUTH) || @@ -1497,18 +1497,18 @@ extern "C" int CustomMessage_RetrieveIfExists(GlobalContext* globalCtx) { RandomizerCheck hintCheck = Randomizer_GetCheckFromActor(globalCtx->sceneNum, msgCtx->talkActor->id, actorParams); - messageEntry = Randomizer_CopyHintFromCheck(hintCheck); + messageEntry = Randomizer_GetHintFromCheck(hintCheck); } else if (textId == TEXT_ALTAR_CHILD || textId == TEXT_ALTAR_ADULT) { // rando hints at altar - messageEntry = Randomizer_CopyAltarMessage(); + messageEntry = Randomizer_GetAltarMessage(); } else if (textId == TEXT_GANONDORF) { if (INV_CONTENT(ITEM_ARROW_LIGHT) == ITEM_ARROW_LIGHT) { - messageEntry = Randomizer_CopyGanonText(); + messageEntry = Randomizer_GetGanonText(); } else { - messageEntry = Randomizer_CopyGanonHintText(); + messageEntry = Randomizer_GetGanonHintText(); } } else if (textId == TEXT_SCRUB_POH || textId == TEXT_SCRUB_STICK_UPGRADE || textId == TEXT_SCRUB_NUT_UPGRADE) { - messageEntry = Randomizer_CopyScrubMessage(textId); + messageEntry = Randomizer_GetScrubMessage(textId); } } if (textId == TEXT_GS_NO_FREEZE || textId == TEXT_GS_FREEZE) { 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 e1e3813f5..707851ce3 100644 --- a/soh/src/overlays/actors/ovl_player_actor/z_player.c +++ b/soh/src/overlays/actors/ovl_player_actor/z_player.c @@ -653,15 +653,15 @@ static GetItemEntry sGetItemTable[] = { GET_ITEM(ITEM_DOUBLE_MAGIC, OBJECT_GI_MAGICPOT, GID_MAGIC_LARGE, 0xE8, 0x80, CHEST_ANIM_LONG), GET_ITEM(ITEM_DOUBLE_DEFENSE, OBJECT_GI_HEARTS, GID_HEART_CONTAINER, 0xE9, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_BOTTLE_WITH_RED_POTION, OBJECT_GI_LIQUID, GID_POTION_RED, TEXT_RANDOMIZER_GI_ESCAPE_HATCH, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_BOTTLE_WITH_GREEN_POTION, OBJECT_GI_LIQUID, GID_POTION_GREEN, TEXT_RANDOMIZER_GI_ESCAPE_HATCH, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_BOTTLE_WITH_BLUE_POTION, OBJECT_GI_LIQUID, GID_POTION_BLUE, TEXT_RANDOMIZER_GI_ESCAPE_HATCH, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_BOTTLE_WITH_FAIRY, OBJECT_GI_BOTTLE, GID_BOTTLE, TEXT_RANDOMIZER_GI_ESCAPE_HATCH, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_BOTTLE_WITH_FISH, OBJECT_GI_FISH, GID_FISH, TEXT_RANDOMIZER_GI_ESCAPE_HATCH, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_BOTTLE_WITH_BLUE_FIRE, OBJECT_GI_FIRE, GID_BLUE_FIRE, TEXT_RANDOMIZER_GI_ESCAPE_HATCH, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_BOTTLE_WITH_BUGS, OBJECT_GI_INSECT, GID_BUG, TEXT_RANDOMIZER_GI_ESCAPE_HATCH, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_BOTTLE_WITH_POE, OBJECT_GI_GHOST, GID_POE, TEXT_RANDOMIZER_GI_ESCAPE_HATCH, 0x80, CHEST_ANIM_LONG), - GET_ITEM(ITEM_BOTTLE_WITH_BIG_POE, OBJECT_GI_GHOST, GID_BIG_POE, TEXT_RANDOMIZER_GI_ESCAPE_HATCH, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_BOTTLE_WITH_RED_POTION, OBJECT_GI_LIQUID, GID_POTION_RED, TEXT_RANDOMIZER_CUSTOM_ITEM, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_BOTTLE_WITH_GREEN_POTION, OBJECT_GI_LIQUID, GID_POTION_GREEN, TEXT_RANDOMIZER_CUSTOM_ITEM, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_BOTTLE_WITH_BLUE_POTION, OBJECT_GI_LIQUID, GID_POTION_BLUE, TEXT_RANDOMIZER_CUSTOM_ITEM, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_BOTTLE_WITH_FAIRY, OBJECT_GI_BOTTLE, GID_BOTTLE, TEXT_RANDOMIZER_CUSTOM_ITEM, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_BOTTLE_WITH_FISH, OBJECT_GI_FISH, GID_FISH, TEXT_RANDOMIZER_CUSTOM_ITEM, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_BOTTLE_WITH_BLUE_FIRE, OBJECT_GI_FIRE, GID_BLUE_FIRE, TEXT_RANDOMIZER_CUSTOM_ITEM, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_BOTTLE_WITH_BUGS, OBJECT_GI_INSECT, GID_BUG, TEXT_RANDOMIZER_CUSTOM_ITEM, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_BOTTLE_WITH_POE, OBJECT_GI_GHOST, GID_POE, TEXT_RANDOMIZER_CUSTOM_ITEM, 0x80, CHEST_ANIM_LONG), + GET_ITEM(ITEM_BOTTLE_WITH_BIG_POE, OBJECT_GI_GHOST, GID_BIG_POE, TEXT_RANDOMIZER_CUSTOM_ITEM, 0x80, CHEST_ANIM_LONG), GET_ITEM_NONE, GET_ITEM_NONE, From 480053dfaab3b374d5d66275fe7d81ba1b9b037e Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Mon, 1 Aug 2022 23:05:29 -0400 Subject: [PATCH 36/71] Exposes FormatCustomMessage and uses it in FormatJsonHintText. --- .../custom_message/CustomMessageManager.h | 4 ++-- .../Enhancements/randomizer/randomizer.cpp | 19 +------------------ 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/soh/soh/Enhancements/custom_message/CustomMessageManager.h b/soh/soh/Enhancements/custom_message/CustomMessageManager.h index 6156f2ef8..35a1d5eb4 100644 --- a/soh/soh/Enhancements/custom_message/CustomMessageManager.h +++ b/soh/soh/Enhancements/custom_message/CustomMessageManager.h @@ -69,8 +69,6 @@ class CustomMessageManager { void ReplaceSpecialCharacters(std::string &string); void ReplaceColors(std::string& string); - void FormatCustomMessage(std::string& message, ItemID iid); - void FormatCustomMessage(std::string& message); bool InsertCustomMessage(std::string tableID, uint16_t textID, CustomMessageEntry messages); std::string MESSAGE_END(); @@ -91,4 +89,6 @@ class CustomMessageManager { CustomMessageEntry RetrieveMessage(std::string tableID, uint16_t textID); bool ClearMessageTable(std::string tableID); bool AddCustomMessageTable(std::string tableID); + void FormatCustomMessage(std::string& message, ItemID iid); + void FormatCustomMessage(std::string& message); }; diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index c0077a97e..1163da8b3 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -1826,24 +1826,7 @@ std::string AltarIconString(char iconChar) { std::string FormatJsonHintText(std::string jsonHint) { std::string formattedHintMessage = jsonHint; - std::unordered_map textBoxSpecialCharacters = { - { "À", 0x80 }, { "î", 0x81 }, { "Â", 0x82 }, { "Ä", 0x83 }, { "Ç", 0x84 }, { "È", 0x85 }, { "É", 0x86 }, - { "Ê", 0x87 }, { "Ë", 0x88 }, { "Ï", 0x89 }, { "Ô", 0x8A }, { "Ö", 0x8B }, { "Ù", 0x8C }, { "Û", 0x8D }, - { "Ü", 0x8E }, { "ß", 0x8F }, { "à", 0x90 }, { "á", 0x91 }, { "â", 0x92 }, { "ä", 0x93 }, { "ç", 0x94 }, - { "è", 0x95 }, { "é", 0x96 }, { "ê", 0x97 }, { "ë", 0x98 }, { "ï", 0x99 }, { "ô", 0x9A }, { "ö", 0x9B }, - { "ù", 0x9C }, { "û", 0x9D }, { "ü", 0x9E } - }; - - // add special characters - for (auto specialCharacterPair : textBoxSpecialCharacters) { - size_t start_pos = 0; - std::string textBoxSpecialCharacterString = ""; - textBoxSpecialCharacterString += specialCharacterPair.second; - while ((start_pos = formattedHintMessage.find(specialCharacterPair.first, start_pos)) != std::string::npos) { - formattedHintMessage.replace(start_pos, specialCharacterPair.first.length(), textBoxSpecialCharacterString); - start_pos += textBoxSpecialCharacterString.length(); - } - } + CustomMessageManager::Instance->FormatCustomMessage(formattedHintMessage); // add icons to altar text for (char iconChar : {'0', '1', '2', '3', '4', '5', '6', '7', '8', 'o', 'c', 'i', 'l', 'b', 'L', 'k'}) { From bb8152b3763f1d92319a31c184af865bcb343517 Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Mon, 1 Aug 2022 23:16:16 -0400 Subject: [PATCH 37/71] Replaces string literal for BaseGameOverrides with const variable. --- soh/soh/OTRGlobals.cpp | 2 +- soh/soh/OTRGlobals.h | 2 ++ soh/soh/z_message_OTR.cpp | 2 -- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 088e589fa..5662d4895 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -1518,7 +1518,7 @@ extern "C" int CustomMessage_RetrieveIfExists(GlobalContext* globalCtx) { } else { textId = TEXT_GS_FREEZE; } - messageEntry = CustomMessageManager::Instance->RetrieveMessage("BaseGameOverrides", textId); + messageEntry = CustomMessageManager::Instance->RetrieveMessage(customMessageTableID, textId); } } if (messageEntry.textBoxType != -1) { diff --git a/soh/soh/OTRGlobals.h b/soh/soh/OTRGlobals.h index 76212c676..4f3b2a7b6 100644 --- a/soh/soh/OTRGlobals.h +++ b/soh/soh/OTRGlobals.h @@ -10,6 +10,8 @@ #include "Enhancements/savestates.h" #include "Enhancements/randomizer/randomizer.h" +const std::string customMessageTableID = "BaseGameOverrides"; + class OTRGlobals { public: diff --git a/soh/soh/z_message_OTR.cpp b/soh/soh/z_message_OTR.cpp index cdc1c79e8..4fd74e497 100644 --- a/soh/soh/z_message_OTR.cpp +++ b/soh/soh/z_message_OTR.cpp @@ -15,8 +15,6 @@ extern "C" MessageTableEntry* sFraMessageEntryTablePtr; extern "C" MessageTableEntry* sStaffMessageEntryTablePtr; //extern "C" MessageTableEntry* _message_0xFFFC_nes; -const std::string customMessageTableID = "BaseGameOverrides"; - MessageTableEntry* OTRMessage_LoadTable(const char* filePath, bool isNES) { auto file = std::static_pointer_cast(OTRGlobals::Instance->context->GetResourceManager()->LoadResource(filePath)); From d80742d882c0f439ccc353056f7b4b462129b958 Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Tue, 2 Aug 2022 19:32:59 -0400 Subject: [PATCH 38/71] Adds documentation comments to CustomMessageManager.h --- .../custom_message/CustomMessageManager.h | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/soh/soh/Enhancements/custom_message/CustomMessageManager.h b/soh/soh/Enhancements/custom_message/CustomMessageManager.h index 35a1d5eb4..c5590dc00 100644 --- a/soh/soh/Enhancements/custom_message/CustomMessageManager.h +++ b/soh/soh/Enhancements/custom_message/CustomMessageManager.h @@ -84,11 +84,50 @@ class CustomMessageManager { CustomMessageManager(); ~CustomMessageManager(); + /* + Formats the provided Custom Message Entry and inserts it into the table with the provided tableID, + with the provided giid (getItemID) as its key. This function also inserts the icon corresponding to + the provided iid (itemID) at the beginning of each page of the textbox. + */ bool CreateGetItemMessage(std::string tableID, GetItemID giid, ItemID iid, CustomMessageEntry messages); + + /* + Formats the provided Custom Message Entry and inserts it into the table with the provided tableID, + with the provided textID as its key. + */ bool CreateMessage(std::string tableID, uint16_t textID, CustomMessageEntry messages); + + /* + Retrieves a message from the table with id tableID with the provided textID. + Returns a NULL_CUSTOM_MESSAGE if the message or table does not exist. + */ CustomMessageEntry RetrieveMessage(std::string tableID, uint16_t textID); + + /* + Empties out the message table identified by tableID. + Returns true if successful and false if not (for instance + if a table with the provided tableID does not exist). + */ bool ClearMessageTable(std::string tableID); + + /* + Creates an empty CustomMessageTable accessible at the provided + tableID, returns true if creation was successful and false + if not. + */ bool AddCustomMessageTable(std::string tableID); + + /* + Replaces special characters and certain symbols with control codes + & for newline, ^ for wait-for-input, and @ for the player name, + as well as % for colors (i.e. %r for red and %w for white). + */ void FormatCustomMessage(std::string& message, ItemID iid); + + /* + Replaces special characters and certain symbols with control codes + & for newline, ^ for wait-for-input, and @ for the player name, + as well as % for colors (i.e. %r for red and %w for white). + */ void FormatCustomMessage(std::string& message); }; From facd1723f83f0948ec4a8d0006ffa5ea2f545479 Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Thu, 4 Aug 2022 17:32:23 -0400 Subject: [PATCH 39/71] don't use signed ints for epochs (#1044) Co-authored-by: briaguya --- soh/include/z64effect.h | 4 ++-- soh/src/code/z_actor.c | 2 +- soh/src/code/z_kankyo.c | 6 +++--- soh/src/code/z_lifemeter.c | 2 +- .../overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.h | 2 +- .../overlays/actors/ovl_Bg_Jya_Megami/z_bg_jya_megami.h | 2 +- .../actors/ovl_Bg_Spot00_Hanebasi/z_bg_spot00_hanebasi.c | 2 +- soh/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.h | 2 +- soh/src/overlays/actors/ovl_Boss_Fd/z_boss_fd.c | 2 +- soh/src/overlays/actors/ovl_Boss_Fd2/z_boss_fd2.h | 2 +- soh/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c | 6 +++--- soh/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.c | 8 ++++---- soh/src/overlays/actors/ovl_Boss_Mo/z_boss_mo.c | 2 +- soh/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.c | 2 +- soh/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.h | 2 +- soh/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c | 6 +++--- soh/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.h | 2 +- soh/src/overlays/actors/ovl_Boss_Va/z_boss_va.c | 2 +- soh/src/overlays/actors/ovl_Demo_6K/z_demo_6k.c | 4 ++-- soh/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c | 8 ++++---- soh/src/overlays/actors/ovl_Efc_Erupc/z_efc_erupc.h | 2 +- soh/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c | 4 ++-- .../actors/ovl_En_Anubice_Fire/z_en_anubice_fire.h | 2 +- soh/src/overlays/actors/ovl_En_Ba/z_en_ba.h | 2 +- soh/src/overlays/actors/ovl_En_Bx/z_en_bx.h | 2 +- soh/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.h | 2 +- soh/src/overlays/actors/ovl_En_Encount2/z_en_encount2.h | 2 +- soh/src/overlays/actors/ovl_En_Fd/z_en_fd.h | 2 +- soh/src/overlays/actors/ovl_En_Fw/z_en_fw.h | 2 +- soh/src/overlays/actors/ovl_En_Fz/z_en_fz.h | 2 +- soh/src/overlays/actors/ovl_En_G_Switch/z_en_g_switch.h | 2 +- soh/src/overlays/actors/ovl_En_Gb/z_en_gb.h | 2 +- soh/src/overlays/actors/ovl_En_Go/z_en_go.h | 2 +- soh/src/overlays/actors/ovl_En_Niw/z_en_niw.h | 2 +- soh/src/overlays/actors/ovl_En_Nwc/z_en_nwc.h | 2 +- soh/src/overlays/actors/ovl_En_Ny/z_en_ny.h | 2 +- .../overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.h | 2 +- .../overlays/actors/ovl_En_Syateki_Niw/z_en_syateki_niw.h | 2 +- soh/src/overlays/actors/ovl_En_Tk/z_en_tk.h | 2 +- soh/src/overlays/actors/ovl_En_Viewer/z_en_viewer.h | 2 +- soh/src/overlays/actors/ovl_Fishing/z_fishing.c | 6 +++--- soh/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c | 2 +- .../overlays/effects/ovl_Effect_Ss_Bomb2/z_eff_ss_bomb2.h | 2 +- 43 files changed, 60 insertions(+), 60 deletions(-) diff --git a/soh/include/z64effect.h b/soh/include/z64effect.h index 8dce5b6a3..861eb9070 100644 --- a/soh/include/z64effect.h +++ b/soh/include/z64effect.h @@ -25,7 +25,7 @@ typedef struct { /* 0x0C */ Vec3f position; /* 0x18 */ Vec3s unkVelocity; /* 0x1E */ Vec3s unkPosition; - /* 0x24 */ s32 epoch; + /* 0x24 */ u32 epoch; } EffectSparkElement; // size = 0x28 typedef struct { @@ -118,7 +118,7 @@ typedef struct { /* 0x10 */ f32 startX; /* 0x14 */ s16 yaw; /* 0x16 */ s16 pitch; - /* 0x18 */ s32 epoch; + /* 0x18 */ u32 epoch; } EffectShieldParticleElement; // size = 0x1C typedef struct { diff --git a/soh/src/code/z_actor.c b/soh/src/code/z_actor.c index fc6e10825..8f132b2c0 100644 --- a/soh/src/code/z_actor.c +++ b/soh/src/code/z_actor.c @@ -3973,7 +3973,7 @@ void Actor_DrawDoorLock(GlobalContext* globalCtx, s32 frame, s32 type) { f32 chainsTranslateX; f32 chainsTranslateY; f32 rotZStep; - static s32 epoch = 0; + static u32 epoch = 0; epoch++; entry = &sDoorLocksInfo[type]; diff --git a/soh/src/code/z_kankyo.c b/soh/src/code/z_kankyo.c index de8634f32..7fd9a7480 100644 --- a/soh/src/code/z_kankyo.c +++ b/soh/src/code/z_kankyo.c @@ -1459,7 +1459,7 @@ void Environment_DrawLensFlare(GlobalContext* globalCtx, EnvironmentContext* env LENS_FLARE_RING, LENS_FLARE_CIRCLE1, LENS_FLARE_CIRCLE1, LENS_FLARE_CIRCLE1, LENS_FLARE_CIRCLE1, LENS_FLARE_CIRCLE1, LENS_FLARE_CIRCLE1, LENS_FLARE_CIRCLE1, LENS_FLARE_CIRCLE1, LENS_FLARE_CIRCLE1, }; - static s32 epoch = 0; + static u32 epoch = 0; epoch++; OPEN_DISPS(gfxCtx); @@ -1642,7 +1642,7 @@ void Environment_DrawRain(GlobalContext* globalCtx, View* view, GraphicsContext* Vec3f unused = { 0.0f, 0.0f, 0.0f }; Vec3f windDirection = { 0.0f, 0.0f, 0.0f }; Player* player = GET_PLAYER(globalCtx); - static s32 epoch = 0; + static u32 epoch = 0; epoch++; if (!(globalCtx->cameraPtrs[0]->unk_14C & 0x100) && (globalCtx->envCtx.unk_EE[2] == 0)) { @@ -1925,7 +1925,7 @@ void Environment_DrawLightning(GlobalContext* globalCtx, s32 unused) { s32 pad[2]; Vec3f unused1 = { 0.0f, 0.0f, 0.0f }; Vec3f unused2 = { 0.0f, 0.0f, 0.0f }; - static s32 epoch = 0; + static u32 epoch = 0; epoch++; OPEN_DISPS(globalCtx->state.gfxCtx); diff --git a/soh/src/code/z_lifemeter.c b/soh/src/code/z_lifemeter.c index 400f0a275..071cc18a7 100644 --- a/soh/src/code/z_lifemeter.c +++ b/soh/src/code/z_lifemeter.c @@ -413,7 +413,7 @@ void HealthMeter_Draw(GlobalContext* globalCtx) { s32 curCombineModeSet = 0; u8* curBgImgLoaded = NULL; s32 ddHeartCountMinusOne = gSaveContext.inventory.defenseHearts - 1; - static s32 epoch = 0; + static u32 epoch = 0; epoch++; OPEN_DISPS(gfxCtx); diff --git a/soh/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.h b/soh/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.h index 401eb8b22..c25205729 100644 --- a/soh/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.h +++ b/soh/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.h @@ -24,7 +24,7 @@ typedef struct { /* 0x36 */ f32 pitch; /* 0x36 */ f32 yaw; /* 0x40 */ f32 roll; - /* 0x44 */ s32 epoch; + /* 0x44 */ u32 epoch; } BgDyYoseizoParticle; // size = 0x48 typedef struct BgDyYoseizo { diff --git a/soh/src/overlays/actors/ovl_Bg_Jya_Megami/z_bg_jya_megami.h b/soh/src/overlays/actors/ovl_Bg_Jya_Megami/z_bg_jya_megami.h index 4198781b0..8ccac6a95 100644 --- a/soh/src/overlays/actors/ovl_Bg_Jya_Megami/z_bg_jya_megami.h +++ b/soh/src/overlays/actors/ovl_Bg_Jya_Megami/z_bg_jya_megami.h @@ -13,7 +13,7 @@ typedef struct { /* 0x0C */ Vec3f vel; /* 0x18 */ s16 rotVelX; /* 0x1A */ s16 rotVelY; - /* 0x1C */ s32 epoch; + /* 0x1C */ u32 epoch; } BgJyaMegamiPiece; // size = 0x20 typedef struct BgJyaMegami { diff --git a/soh/src/overlays/actors/ovl_Bg_Spot00_Hanebasi/z_bg_spot00_hanebasi.c b/soh/src/overlays/actors/ovl_Bg_Spot00_Hanebasi/z_bg_spot00_hanebasi.c index d74a39624..50b3e1fc4 100644 --- a/soh/src/overlays/actors/ovl_Bg_Spot00_Hanebasi/z_bg_spot00_hanebasi.c +++ b/soh/src/overlays/actors/ovl_Bg_Spot00_Hanebasi/z_bg_spot00_hanebasi.c @@ -261,7 +261,7 @@ void BgSpot00Hanebasi_DrawTorches(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; f32 angle; s32 i; - static s32 epoch = 0; + static u32 epoch = 0; epoch++; OPEN_DISPS(globalCtx->state.gfxCtx); diff --git a/soh/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.h b/soh/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.h index f920b44a6..ddc76960c 100644 --- a/soh/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.h +++ b/soh/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.h @@ -17,7 +17,7 @@ typedef struct { /* 0x26 */ Color_RGB8 color; /* 0x2A */ s16 alpha; /* 0x2C */ f32 unk_2C; - /* 0x30 */ s32 epoch; + /* 0x30 */ u32 epoch; } BossDodongoEffect; // Size = 0x34 typedef struct BossDodongo { diff --git a/soh/src/overlays/actors/ovl_Boss_Fd/z_boss_fd.c b/soh/src/overlays/actors/ovl_Boss_Fd/z_boss_fd.c index 8afb08ba1..b1bfeb5de 100644 --- a/soh/src/overlays/actors/ovl_Boss_Fd/z_boss_fd.c +++ b/soh/src/overlays/actors/ovl_Boss_Fd/z_boss_fd.c @@ -1835,7 +1835,7 @@ void BossFd_DrawBody(GlobalContext* globalCtx, BossFd* this) { s16 i; f32 temp_float; Mtx* tempMat = Graph_Alloc(globalCtx->state.gfxCtx, 18 * sizeof(Mtx)); - static s32 epoch = 0; + static u32 epoch = 0; epoch++; OPEN_DISPS(globalCtx->state.gfxCtx); diff --git a/soh/src/overlays/actors/ovl_Boss_Fd2/z_boss_fd2.h b/soh/src/overlays/actors/ovl_Boss_Fd2/z_boss_fd2.h index 3bc77b0b7..7133b78a6 100644 --- a/soh/src/overlays/actors/ovl_Boss_Fd2/z_boss_fd2.h +++ b/soh/src/overlays/actors/ovl_Boss_Fd2/z_boss_fd2.h @@ -87,7 +87,7 @@ typedef struct BossFd2 { /* 0x1394 */ BossFd2Cam camData; /* 0x141C */ ColliderJntSph collider; /* 0x143C */ ColliderJntSphElement elements[9]; - /* 0x167C */ s32 epoch; + /* 0x167C */ u32 epoch; } BossFd2; // size = 0x1680 #endif diff --git a/soh/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c b/soh/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c index 10e118c17..da84d0f5e 100644 --- a/soh/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c +++ b/soh/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c @@ -3356,7 +3356,7 @@ void BossGanon_DrawShock(BossGanon* this, GlobalContext* globalCtx) { s32 pad; GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; s16 i; - static s32 epoch = 0; + static u32 epoch = 0; epoch++; OPEN_DISPS(gfxCtx); @@ -3463,7 +3463,7 @@ void BossGanon_DrawBigMagicCharge(BossGanon* this, GlobalContext* globalCtx) { f32 yRot; GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; s16 i; - static s32 epoch = 0; + static u32 epoch = 0; epoch++; OPEN_DISPS(gfxCtx); @@ -4158,7 +4158,7 @@ void BossGanon_LightBall_Draw(Actor* thisx, GlobalContext* globalCtx) { s16 i; f32 alpha; s32 pad; - static s32 epoch = 0; + static u32 epoch = 0; epoch++; OPEN_DISPS(globalCtx->state.gfxCtx); diff --git a/soh/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.c b/soh/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.c index ecc084be3..1f5455e24 100644 --- a/soh/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.c +++ b/soh/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.c @@ -2464,7 +2464,7 @@ void func_80904340(BossGanon2* this, GlobalContext* globalCtx) { f32 angle; f32 sin; f32 cos; - static s32 epoch = 0; + static u32 epoch = 0; epoch++; OPEN_DISPS(globalCtx->state.gfxCtx); @@ -2637,7 +2637,7 @@ void BossGanon2_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis void func_80904D88(BossGanon2* this, GlobalContext* globalCtx) { s32 pad; s16 i; - static s32 epoch = 0; + static u32 epoch = 0; epoch++; OPEN_DISPS(globalCtx->state.gfxCtx); @@ -2701,7 +2701,7 @@ void func_80904FC8(BossGanon2* this, GlobalContext* globalCtx) { void func_8090523C(BossGanon2* this, GlobalContext* globalCtx) { Player* player; f32 phi_f20; - static s32 epoch = 0; + static u32 epoch = 0; epoch++; OPEN_DISPS(globalCtx->state.gfxCtx); @@ -2933,7 +2933,7 @@ void func_809060E8(GlobalContext* globalCtx) { BossGanon2Effect* effect; s16 i; BossGanon2Effect* effects; - static s32 epoch = 0; + static u32 epoch = 0; epoch++; effects = effect = globalCtx->specialEffects; diff --git a/soh/src/overlays/actors/ovl_Boss_Mo/z_boss_mo.c b/soh/src/overlays/actors/ovl_Boss_Mo/z_boss_mo.c index b7756765a..ae326d696 100644 --- a/soh/src/overlays/actors/ovl_Boss_Mo/z_boss_mo.c +++ b/soh/src/overlays/actors/ovl_Boss_Mo/z_boss_mo.c @@ -2443,7 +2443,7 @@ void BossMo_DrawTentacle(BossMo* this, GlobalContext* globalCtx) { f32 phi_f20; f32 phi_f22; Vec3f sp110; - static s32 epoch = 0; + static u32 epoch = 0; epoch++; OPEN_DISPS(globalCtx->state.gfxCtx); diff --git a/soh/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.c b/soh/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.c index 1a1a93b07..31d1488a7 100644 --- a/soh/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.c +++ b/soh/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.c @@ -2706,7 +2706,7 @@ s32 BossSst_OverrideHandTrailDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** void BossSst_DrawHand(Actor* thisx, GlobalContext* globalCtx) { BossSst* this = (BossSst*)thisx; - static s32 epoch = 0; + static u32 epoch = 0; epoch++; OPEN_DISPS(globalCtx->state.gfxCtx); diff --git a/soh/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.h b/soh/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.h index 32c12b7fd..ea287fb1b 100644 --- a/soh/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.h +++ b/soh/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.h @@ -17,7 +17,7 @@ typedef struct { /* 0x0020 */ s16 move; /* 0x0022 */ s16 status; /* 0x0024 */ u8 alpha; - /* 0x0028 */ s32 epoch; + /* 0x0028 */ u32 epoch; } BossSstEffect; // size = 0x2C typedef struct { diff --git a/soh/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c b/soh/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c index 1252df4bf..533420b06 100644 --- a/soh/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c +++ b/soh/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c @@ -3329,7 +3329,7 @@ void func_80942180(BossTw* this, GlobalContext* globalCtx) { void func_809426F0(BossTw* this, GlobalContext* globalCtx) { s32 pad; s16 i; - static s32 epoch = 0; + static u32 epoch = 0; epoch++; OPEN_DISPS(globalCtx->state.gfxCtx); @@ -4418,7 +4418,7 @@ void BossTw_BlastDraw(Actor* thisx, GlobalContext* globalCtx2) { f32 scaleFactor; s16 tailIdx; s16 i; - static s32 epoch = 0; + static u32 epoch = 0; epoch++; OPEN_DISPS(globalCtx->state.gfxCtx); @@ -4492,7 +4492,7 @@ void BossTw_DrawDeathBall(Actor* thisx, GlobalContext* globalCtx2) { f32 scaleFactor; s16 tailIdx; s16 i; - static s32 epoch = 0; + static u32 epoch = 0; epoch++; OPEN_DISPS(globalCtx->state.gfxCtx); diff --git a/soh/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.h b/soh/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.h index 1a4a31438..5560f58d7 100644 --- a/soh/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.h +++ b/soh/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.h @@ -43,7 +43,7 @@ typedef struct { /* 0x002E */ s16 work[EFF_WORK_MAX]; /* 0x0034 */ f32 workf[EFF_FWORK_MAX]; /* 0x0044 */ Actor* target; - s32 epoch; + u32 epoch; } BossTwEffect; typedef enum { diff --git a/soh/src/overlays/actors/ovl_Boss_Va/z_boss_va.c b/soh/src/overlays/actors/ovl_Boss_Va/z_boss_va.c index b4236ef25..c8134866a 100644 --- a/soh/src/overlays/actors/ovl_Boss_Va/z_boss_va.c +++ b/soh/src/overlays/actors/ovl_Boss_Va/z_boss_va.c @@ -4006,7 +4006,7 @@ void BossVa_DrawDoor(GlobalContext* globalCtx, s16 scale) { f32 yScale; f32 segAngle = 0.0f; s32 i; - static s32 epoch = 0; + static u32 epoch = 0; epoch++; OPEN_DISPS(globalCtx->state.gfxCtx); diff --git a/soh/src/overlays/actors/ovl_Demo_6K/z_demo_6k.c b/soh/src/overlays/actors/ovl_Demo_6K/z_demo_6k.c index fd131a244..bd1bafc0a 100644 --- a/soh/src/overlays/actors/ovl_Demo_6K/z_demo_6k.c +++ b/soh/src/overlays/actors/ovl_Demo_6K/z_demo_6k.c @@ -564,7 +564,7 @@ void func_80967FFC(Actor* thisx, GlobalContext* globalCtx) { Demo6K* this = (Demo6K*)thisx; s32 pad; u16 timer1 = this->timer1; - static s32 epoch = 0; + static u32 epoch = 0; epoch++; OPEN_DISPS(globalCtx->state.gfxCtx); @@ -695,7 +695,7 @@ void func_809688C4(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; u32 frames = globalCtx->state.frames; s32 i; - static s32 epoch = 0; + static u32 epoch = 0; epoch++; if ((i = (globalCtx->csCtx.state != CS_STATE_IDLE) && (globalCtx->csCtx.npcActions[1] != NULL)) && diff --git a/soh/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c b/soh/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c index 6ca6a025b..ca162f584 100644 --- a/soh/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c +++ b/soh/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c @@ -522,7 +522,7 @@ void DemoKankyo_DrawRain(Actor* thisx, GlobalContext* globalCtx) { f32 translateY; f32 translateZ; s16 j; - static s32 epoch = 0; + static u32 epoch = 0; epoch++; OPEN_DISPS(globalCtx->state.gfxCtx); @@ -663,7 +663,7 @@ void DemoKankyo_DrawClouds(Actor* thisx, GlobalContext* globalCtx) { f32 dx; f32 dy; f32 dz; - static s32 epoch = 0; + static u32 epoch = 0; epoch++; OPEN_DISPS(globalCtx->state.gfxCtx); @@ -784,7 +784,7 @@ void DemoKankyo_DrawWarpSparkles(Actor* thisx, GlobalContext* globalCtx) { f32 translateZ; PosRot posRot; u8 linkAge = gSaveContext.linkAge; - static s32 epoch = 0; + static u32 epoch = 0; epoch++; OPEN_DISPS(globalCtx->state.gfxCtx); @@ -933,7 +933,7 @@ void DemoKankyo_DrawSparkles(Actor* thisx, GlobalContext* globalCtx) { f32 scale; s16 i; PosRot posRot; - static s32 epoch = 0; + static u32 epoch = 0; epoch++; OPEN_DISPS(globalCtx->state.gfxCtx); diff --git a/soh/src/overlays/actors/ovl_Efc_Erupc/z_efc_erupc.h b/soh/src/overlays/actors/ovl_Efc_Erupc/z_efc_erupc.h index 6e7fa6693..596159815 100644 --- a/soh/src/overlays/actors/ovl_Efc_Erupc/z_efc_erupc.h +++ b/soh/src/overlays/actors/ovl_Efc_Erupc/z_efc_erupc.h @@ -19,7 +19,7 @@ typedef struct { /* 0x30 */ char unk_2C[4]; /* 0x34 */ f32 scale; /* 0x38 */ char unk_34[8]; - /* 0x3C */ s32 epoch; + /* 0x3C */ u32 epoch; } EfcErupcParticles; // size 0x40 #define EFC_ERUPC_NUM_PARTICLES 100 diff --git a/soh/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c b/soh/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c index e3af7ba4d..b9bd8e311 100644 --- a/soh/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c +++ b/soh/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c @@ -269,7 +269,7 @@ void EffDust_DrawFunc_8099E4F4(Actor* thisx, GlobalContext* globalCtx2) { f32* distanceTraveled; s32 i; f32 aux; - static s32 epoch = 0; + static u32 epoch = 0; epoch++; OPEN_DISPS(gfxCtx); @@ -321,7 +321,7 @@ void EffDust_DrawFunc_8099E784(Actor* thisx, GlobalContext* globalCtx2) { s32 i; f32 aux; Player* player = GET_PLAYER(globalCtx); - static s32 epoch = 0; + static u32 epoch = 0; epoch++; OPEN_DISPS(gfxCtx); diff --git a/soh/src/overlays/actors/ovl_En_Anubice_Fire/z_en_anubice_fire.h b/soh/src/overlays/actors/ovl_En_Anubice_Fire/z_en_anubice_fire.h index 848bcdae9..aa6359c48 100644 --- a/soh/src/overlays/actors/ovl_En_Anubice_Fire/z_en_anubice_fire.h +++ b/soh/src/overlays/actors/ovl_En_Anubice_Fire/z_en_anubice_fire.h @@ -19,7 +19,7 @@ typedef struct EnAnubiceFire { /* 0x015E */ s16 unk_15E; /* 0x0178 */ Vec3f unk_160[6]; /* 0x01A8 */ ColliderCylinder cylinder; - /* 0x01F4 */ s32 epoch; + /* 0x01F4 */ u32 epoch; } EnAnubiceFire; // size = 0x01F8 #endif diff --git a/soh/src/overlays/actors/ovl_En_Ba/z_en_ba.h b/soh/src/overlays/actors/ovl_En_Ba/z_en_ba.h index a43c33e81..1996a09bc 100644 --- a/soh/src/overlays/actors/ovl_En_Ba/z_en_ba.h +++ b/soh/src/overlays/actors/ovl_En_Ba/z_en_ba.h @@ -32,7 +32,7 @@ typedef struct EnBa { /* 0x031C */ s16 unk31C; /* 0x0320 */ ColliderJntSph collider; /* 0x0340 */ ColliderJntSphElement colliderItems[2]; - /* 0x03C0 */ s32 epoch; + /* 0x03C0 */ u32 epoch; } EnBa; // size = 0x03C4 #endif diff --git a/soh/src/overlays/actors/ovl_En_Bx/z_en_bx.h b/soh/src/overlays/actors/ovl_En_Bx/z_en_bx.h index e842ce3a0..87f9370d6 100644 --- a/soh/src/overlays/actors/ovl_En_Bx/z_en_bx.h +++ b/soh/src/overlays/actors/ovl_En_Bx/z_en_bx.h @@ -16,7 +16,7 @@ typedef struct EnBx { /* 0x01B4 */ Vec3s unk_1B4[4]; /* 0x01CC */ ColliderCylinder collider; /* 0x0218 */ ColliderQuad colliderQuad; - /* 0x0298 */ s32 epoch; + /* 0x0298 */ u32 epoch; } EnBx; // size = 0x029C #endif diff --git a/soh/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.h b/soh/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.h index 4c9b92584..f6328ea8d 100644 --- a/soh/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.h +++ b/soh/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.h @@ -88,7 +88,7 @@ typedef struct EnClearTagEffect { /* 0x0058 */ f32 rotationX; /* 0x005C */ f32 floorHeight; /* 0x0060 */ Vec3f floorTangent; - /* 0x006C */ s32 epoch; + /* 0x006C */ u32 epoch; } EnClearTagEffect; // size = 0x70 #define CLEAR_TAG_EFFECT_MAX_COUNT 100 diff --git a/soh/src/overlays/actors/ovl_En_Encount2/z_en_encount2.h b/soh/src/overlays/actors/ovl_En_Encount2/z_en_encount2.h index b4c7db491..9e3aca0eb 100644 --- a/soh/src/overlays/actors/ovl_En_Encount2/z_en_encount2.h +++ b/soh/src/overlays/actors/ovl_En_Encount2/z_en_encount2.h @@ -14,7 +14,7 @@ typedef struct { /* 0x0010 */ u8 isAlive; /* 0x0014 */ Vec3f moveDirection; /* 0x0020 */ Vec3f rot; - /* 0x002C */ s32 epoch; + /* 0x002C */ u32 epoch; } EnEncount2Particle; // size = 0x30 typedef struct EnEncount2 { diff --git a/soh/src/overlays/actors/ovl_En_Fd/z_en_fd.h b/soh/src/overlays/actors/ovl_En_Fd/z_en_fd.h index 7dc990a7e..0ee372369 100644 --- a/soh/src/overlays/actors/ovl_En_Fd/z_en_fd.h +++ b/soh/src/overlays/actors/ovl_En_Fd/z_en_fd.h @@ -25,7 +25,7 @@ typedef struct { /* 0x0014 */ Vec3f pos; /* 0x0020 */ Vec3f velocity; /* 0x002C */ Vec3f accel; - s32 epoch; + u32 epoch; } EnFdEffect; // size = 0x38 typedef struct EnFd { diff --git a/soh/src/overlays/actors/ovl_En_Fw/z_en_fw.h b/soh/src/overlays/actors/ovl_En_Fw/z_en_fw.h index 0230a2c3d..79279a71f 100644 --- a/soh/src/overlays/actors/ovl_En_Fw/z_en_fw.h +++ b/soh/src/overlays/actors/ovl_En_Fw/z_en_fw.h @@ -19,7 +19,7 @@ typedef struct { /* 0x0014 */ Vec3f pos; /* 0x0020 */ Vec3f velocity; /* 0x002C */ Vec3f accel; - s32 epoch; + u32 epoch; } EnFwEffect; typedef struct EnFw { diff --git a/soh/src/overlays/actors/ovl_En_Fz/z_en_fz.h b/soh/src/overlays/actors/ovl_En_Fz/z_en_fz.h index 471a2fce2..7dab02bbc 100644 --- a/soh/src/overlays/actors/ovl_En_Fz/z_en_fz.h +++ b/soh/src/overlays/actors/ovl_En_Fz/z_en_fz.h @@ -21,7 +21,7 @@ typedef struct { /* 0x0030 */ f32 xyScale; // /* 0x0034 */ f32 xyScaleTarget; /* 0x0038 */ u8 isTimerMod8; // conditional, used to run CollisionCheck_SetAT - s32 epoch; + u32 epoch; } EnFzEffectSsIceSmoke; // size = 0x3C typedef struct EnFz { diff --git a/soh/src/overlays/actors/ovl_En_G_Switch/z_en_g_switch.h b/soh/src/overlays/actors/ovl_En_G_Switch/z_en_g_switch.h index 366a7d120..38b6de292 100644 --- a/soh/src/overlays/actors/ovl_En_G_Switch/z_en_g_switch.h +++ b/soh/src/overlays/actors/ovl_En_G_Switch/z_en_g_switch.h @@ -32,7 +32,7 @@ typedef struct { /* 0x12 */ u8 flag; /* 0x14 */ Vec3f velocity; /* 0x20 */ Vec3f rot; - s32 epoch; + u32 epoch; } EnGSwitchEffect; // size = 0x2C typedef struct EnGSwitch { diff --git a/soh/src/overlays/actors/ovl_En_Gb/z_en_gb.h b/soh/src/overlays/actors/ovl_En_Gb/z_en_gb.h index 48908d7e5..e72a33f14 100644 --- a/soh/src/overlays/actors/ovl_En_Gb/z_en_gb.h +++ b/soh/src/overlays/actors/ovl_En_Gb/z_en_gb.h @@ -27,7 +27,7 @@ typedef struct { /* 0x20 */ f32 unk_20; /* 0x24 */ f32 unk_24; /* 0x28 */ f32 unk_28; - s32 epoch; + u32 epoch; } EnGbCagedSoul; // size = 0x2C typedef struct EnGb { diff --git a/soh/src/overlays/actors/ovl_En_Go/z_en_go.h b/soh/src/overlays/actors/ovl_En_Go/z_en_go.h index 94bad5bab..e54d45bfc 100644 --- a/soh/src/overlays/actors/ovl_En_Go/z_en_go.h +++ b/soh/src/overlays/actors/ovl_En_Go/z_en_go.h @@ -34,7 +34,7 @@ typedef struct { /* 0x0014 */ Vec3f pos; /* 0x0020 */ Vec3f velocity; /* 0x002C */ Vec3f accel; - s32 epoch; + u32 epoch; } EnGoEffect; // size = 0x38 typedef struct EnGo { diff --git a/soh/src/overlays/actors/ovl_En_Niw/z_en_niw.h b/soh/src/overlays/actors/ovl_En_Niw/z_en_niw.h index 78d52af33..5c481e5e6 100644 --- a/soh/src/overlays/actors/ovl_En_Niw/z_en_niw.h +++ b/soh/src/overlays/actors/ovl_En_Niw/z_en_niw.h @@ -18,7 +18,7 @@ typedef struct { /* 0x002C */ f32 scale; /* 0x0030 */ f32 unk_30; /* 0x0034 */ u8 timer; - s32 epoch; + u32 epoch; } EnNiwFeather; // size = 0x0038 typedef struct EnNiw { diff --git a/soh/src/overlays/actors/ovl_En_Nwc/z_en_nwc.h b/soh/src/overlays/actors/ovl_En_Nwc/z_en_nwc.h index fa57bb2f3..eb4d9fb1d 100644 --- a/soh/src/overlays/actors/ovl_En_Nwc/z_en_nwc.h +++ b/soh/src/overlays/actors/ovl_En_Nwc/z_en_nwc.h @@ -23,7 +23,7 @@ typedef struct EnNwcChick { /* 0x36 */ u16 height; /* 0x38 */ CollisionPoly* floorPoly; /* 0x44 */ char unk_3C[0x20]; - s32 epoch; + u32 epoch; } EnNwcChick; // size = 0x5C typedef struct EnNwc { diff --git a/soh/src/overlays/actors/ovl_En_Ny/z_en_ny.h b/soh/src/overlays/actors/ovl_En_Ny/z_en_ny.h index ebc358254..407a2d761 100644 --- a/soh/src/overlays/actors/ovl_En_Ny/z_en_ny.h +++ b/soh/src/overlays/actors/ovl_En_Ny/z_en_ny.h @@ -30,7 +30,7 @@ typedef struct EnNy { /* 0x01F0 */ f32 unk_1F0; /* 0x01F4 */ f32 unk_1F4; /* 0x01F8 */ Vec3f unk_1F8[16]; - s32 epoch; + u32 epoch; } EnNy; // size = 0x02B8 #endif diff --git a/soh/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.h b/soh/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.h index cc55a1dc9..0e9464738 100644 --- a/soh/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.h +++ b/soh/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.h @@ -29,7 +29,7 @@ typedef struct EnPoSisters { /* 0x029C */ LightInfo lightInfo; /* 0x02AC */ ColliderCylinder collider; /* 0x02F8 */ MtxF unk_2F8; - s32 epoch; + u32 epoch; } EnPoSisters; // size = 0x0338 #endif diff --git a/soh/src/overlays/actors/ovl_En_Syateki_Niw/z_en_syateki_niw.h b/soh/src/overlays/actors/ovl_En_Syateki_Niw/z_en_syateki_niw.h index dfa493817..aa9b5dde8 100644 --- a/soh/src/overlays/actors/ovl_En_Syateki_Niw/z_en_syateki_niw.h +++ b/soh/src/overlays/actors/ovl_En_Syateki_Niw/z_en_syateki_niw.h @@ -18,7 +18,7 @@ typedef struct { /* 0x2C */ f32 unk_2C; /* 0x30 */ f32 unk_30; /* 0x34 */ u8 unk_34; - s32 epoch; + u32 epoch; } EnSyatekiNiw_1; // size = 0x38 typedef struct EnSyatekiNiw { diff --git a/soh/src/overlays/actors/ovl_En_Tk/z_en_tk.h b/soh/src/overlays/actors/ovl_En_Tk/z_en_tk.h index 82fb6eef3..1dff6a252 100644 --- a/soh/src/overlays/actors/ovl_En_Tk/z_en_tk.h +++ b/soh/src/overlays/actors/ovl_En_Tk/z_en_tk.h @@ -17,7 +17,7 @@ typedef struct EnTkEff { /* 0x0014 */ Vec3f pos; /* 0x0020 */ Vec3f speed; /* 0x002C */ Vec3f accel; - s32 epoch; + u32 epoch; } EnTkEff; // size = 0x0038 struct EnTk; diff --git a/soh/src/overlays/actors/ovl_En_Viewer/z_en_viewer.h b/soh/src/overlays/actors/ovl_En_Viewer/z_en_viewer.h index d16613fcf..c6ca0eb80 100644 --- a/soh/src/overlays/actors/ovl_En_Viewer/z_en_viewer.h +++ b/soh/src/overlays/actors/ovl_En_Viewer/z_en_viewer.h @@ -56,7 +56,7 @@ typedef struct { /* 0x28 */ f32 scale; /* 0x2C */ f32 lerpFactor; /* 0x30 */ u8 state; - s32 epoch; + u32 epoch; } EnViewerFireEffect; // size = 0x34 typedef struct EnViewer { diff --git a/soh/src/overlays/actors/ovl_Fishing/z_fishing.c b/soh/src/overlays/actors/ovl_Fishing/z_fishing.c index 5f404c4ad..1cb3b53e9 100644 --- a/soh/src/overlays/actors/ovl_Fishing/z_fishing.c +++ b/soh/src/overlays/actors/ovl_Fishing/z_fishing.c @@ -90,7 +90,7 @@ typedef struct { /* 0x32 */ s16 timer; /* 0x34 */ u8 shouldDraw; /* 0x38 */ f32 drawDistance; - s32 epoch; + u32 epoch; } FishingProp; // size = 0x3C typedef enum { @@ -116,7 +116,7 @@ typedef struct { /* 0x40 */ s16 unk_40; /* 0x42 */ s16 unk_42; /* 0x44 */ u8 shouldDraw; - s32 epoch; + u32 epoch; } FishingGroupFish; // size = 0x48 #define LINE_SEG_COUNT 200 @@ -1766,7 +1766,7 @@ static f32 sSinkingLureSizes[] = { void Fishing_DrawSinkingLure(GlobalContext* globalCtx) { s16 i; f32 scale; - static s32 epoch = 0; + static u32 epoch = 0; epoch++; OPEN_DISPS(globalCtx->state.gfxCtx); diff --git a/soh/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c b/soh/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c index c332590dd..9ea675b55 100644 --- a/soh/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c +++ b/soh/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c @@ -482,7 +482,7 @@ void MirRay_Draw(Actor* thisx, GlobalContext* globalCtx) { s32 i; MirRayShieldReflection reflection[6]; s32 temp; - static s32 epoch = 0; + static u32 epoch = 0; epoch++; this->reflectIntensity = 0.0f; diff --git a/soh/src/overlays/effects/ovl_Effect_Ss_Bomb2/z_eff_ss_bomb2.h b/soh/src/overlays/effects/ovl_Effect_Ss_Bomb2/z_eff_ss_bomb2.h index 93dc28031..8fe9efc02 100644 --- a/soh/src/overlays/effects/ovl_Effect_Ss_Bomb2/z_eff_ss_bomb2.h +++ b/soh/src/overlays/effects/ovl_Effect_Ss_Bomb2/z_eff_ss_bomb2.h @@ -11,7 +11,7 @@ typedef struct { /* 0x24 */ s16 scale; /* 0x26 */ s16 scaleStep; /* 0x28 */ u8 drawMode; - /* 0x29 */ s32 epoch; + /* 0x29 */ u32 epoch; } EffectSsBomb2InitParams; // size = 0x30 #endif From d397c1d8718f64e25e438e2348d9c4b71b749af1 Mon Sep 17 00:00:00 2001 From: Kenix3 Date: Thu, 4 Aug 2022 17:35:49 -0400 Subject: [PATCH 40/71] Increment version --- soh/src/boot/build.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/soh/src/boot/build.c b/soh/src/boot/build.c index 84a73076d..5fb08f18a 100644 --- a/soh/src/boot/build.c +++ b/soh/src/boot/build.c @@ -1,4 +1,4 @@ -const char gBuildVersion[] = "RACHAEL ALFA (3.0.0)"; +const char gBuildVersion[] = "RACHAEL BRAVO (3.0.1)"; const char gBuildTeam[] = "github.com/harbourmasters"; const char gBuildDate[] = __DATE__ " " __TIME__; const char gBuildMakeOption[] = ""; From 7f233de502cdbeb4a39f51a63bfc572adafa44f0 Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Mon, 8 Aug 2022 04:31:47 -0400 Subject: [PATCH 41/71] Fixes CMake to explicity launch python interpreter on Windows. (#1089) --- CMakeLists.txt | 2 +- Jenkinsfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d6b44d786..cb372700f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -141,7 +141,7 @@ find_package(Python3 COMPONENTS Interpreter) add_custom_target( ExtractAssets COMMAND ${CMAKE_COMMAND} -E rm -f oot.otr - COMMAND ${Python_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter/extract_assets_cmake2.py + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter/extract_assets_cmake2.py COMMAND ${CMAKE_COMMAND} -E copy oot.otr ${CMAKE_SOURCE_DIR} COMMAND ${CMAKE_COMMAND} -E copy oot.otr ${CMAKE_BINARY_DIR}/soh WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter diff --git a/Jenkinsfile b/Jenkinsfile index a15b2ac12..67766a45d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -38,7 +38,7 @@ pipeline { xcopy "..\\..\\ZELOOTD.z64" "OTRExporter\\" - "${env.CMAKE}" -S . -B "build\\${env.PLATFORM}" -G "Visual Studio 17 2022" -T ${env.TOOLSET} -A ${env.PLATFORM} -D Python_EXECUTABLE=${env.PYTHON} -D CMAKE_BUILD_TYPE:STRING=Release + "${env.CMAKE}" -S . -B "build\\${env.PLATFORM}" -G "Visual Studio 17 2022" -T ${env.TOOLSET} -A ${env.PLATFORM} -D Python3_EXECUTABLE=${env.PYTHON} -D CMAKE_BUILD_TYPE:STRING=Release "${env.CMAKE}" --build ".\\build\\${env.PLATFORM}" --target ExtractAssets --config Release "${env.CMAKE}" --build ".\\build\\${env.PLATFORM}" --config Release cd ".\\build\\${env.PLATFORM}" From 9afbe4272088570d57e70337d292c02323096535 Mon Sep 17 00:00:00 2001 From: David Chavez Date: Mon, 8 Aug 2022 12:01:45 +0200 Subject: [PATCH 42/71] Use -O2 for Release config builds (#1083) --- CMakeLists.txt | 15 ++++++++++----- soh/CMakeLists.txt | 1 - 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cb372700f..c9698c68f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,11 +45,16 @@ endif() ################################################################################ # Global configuration types ################################################################################ -set(CMAKE_CONFIGURATION_TYPES - "Debug" - "Release" - CACHE STRING "" FORCE -) +if (CMAKE_SYSTEM_NAME STREQUAL "NintendoSwitch") +set(CMAKE_C_FLAGS_DEBUG "-O3 -ffast-math") +set(CMAKE_CXX_FLAGS_DEBUG "-O3 -ffast-math") +set(CMAKE_C_FLAGS_RELEASE "-O3 -ffast-math -DNDEBUG") +set(CMAKE_CXX_FLAGS_RELEASE "-O3 -ffast-math -DNDEBUG") +else() +set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG") +set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG") +set(CMAKE_OBJCXX_FLAGS_RELEASE "-O2 -DNDEBUG") +endif() if(NOT CMAKE_BUILD_TYPE ) set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build." FORCE) diff --git a/soh/CMakeLists.txt b/soh/CMakeLists.txt index 36b30e602..67d5db850 100644 --- a/soh/CMakeLists.txt +++ b/soh/CMakeLists.txt @@ -1805,7 +1805,6 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|AppleClang") $<$:-fpermissive> $<$:-Wno-deprecated-enum-enum-conversion> -pthread - -O3 -ffast-math ) target_link_options(${PROJECT_NAME} PRIVATE From 9b33827d0226955315b8e380f8cc6092b9d78a13 Mon Sep 17 00:00:00 2001 From: David Chavez Date: Tue, 9 Aug 2022 00:02:35 +0200 Subject: [PATCH 43/71] [ci] Share Generated Assets Across All Platforms (#1074) --- Jenkinsfile | 56 +++++++++++++++++++-------------- ZAPDTR/ZAPD/ZResource.cpp | 7 +++-- scripts/linux/appimage/build.sh | 1 - scripts/switch/build.sh | 3 -- 4 files changed, 38 insertions(+), 29 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 67766a45d..5f976bb4e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -8,12 +8,35 @@ pipeline { } stages { + stage('Generate Assets') { + options { + timeout(time: 10) + } + agent { + label "SoH-Mac-Builders" + } + steps { + checkout([ + $class: 'GitSCM', + branches: scm.branches, + doGenerateSubmoduleConfigurations: scm.doGenerateSubmoduleConfigurations, + extensions: scm.extensions, + userRemoteConfigs: scm.userRemoteConfigs + ]) + catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { + sh ''' + cp ../../ZELOOTD.z64 OTRExporter/baserom_non_mq.z64 + + cmake --no-warn-unused-cli -H. -Bbuild-cmake -GNinja -DCMAKE_BUILD_TYPE:STRING=Release + cmake --build build-cmake --target ExtractAssets --config Release + ''' + stash includes: 'soh/assets/**/*', name: 'assets' + } + } + } stage('Build SoH') { parallel { stage ('Build Windows') { - options { - timeout(time: 20) - } environment { PLATFORM='x64' PYTHON='C:\\Users\\jenkins\\AppData\\Local\\Programs\\Python\\Python310\\python.exe' @@ -34,12 +57,9 @@ pipeline { ]) catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { - bat """ - - xcopy "..\\..\\ZELOOTD.z64" "OTRExporter\\" - - "${env.CMAKE}" -S . -B "build\\${env.PLATFORM}" -G "Visual Studio 17 2022" -T ${env.TOOLSET} -A ${env.PLATFORM} -D Python3_EXECUTABLE=${env.PYTHON} -D CMAKE_BUILD_TYPE:STRING=Release - "${env.CMAKE}" --build ".\\build\\${env.PLATFORM}" --target ExtractAssets --config Release + unstash 'assets' + bat """ + "${env.CMAKE}" -S . -B "build\\${env.PLATFORM}" -G "Visual Studio 17 2022" -T ${env.TOOLSET} -A ${env.PLATFORM} -D Python_EXECUTABLE=${env.PYTHON} -D CMAKE_BUILD_TYPE:STRING=Release "${env.CMAKE}" --build ".\\build\\${env.PLATFORM}" --config Release cd ".\\build\\${env.PLATFORM}" "${env.CPACK}" -G ZIP @@ -57,9 +77,6 @@ pipeline { } } stage ('Build Linux') { - options { - timeout(time: 20) - } agent { label "SoH-Linux-Builders" } @@ -72,9 +89,8 @@ pipeline { userRemoteConfigs: scm.userRemoteConfigs ]) catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { + unstash 'assets' sh ''' - - cp ../../ZELOOTD.z64 OTRExporter/baserom_non_mq.z64 docker build . -t soh docker run --name sohcont -dit --rm -v $(pwd):/soh soh /bin/bash docker exec sohcont scripts/linux/appimage/build.sh @@ -108,11 +124,9 @@ pipeline { userRemoteConfigs: scm.userRemoteConfigs ]) catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { + unstash 'assets' sh ''' - cp ../../ZELOOTD.z64 OTRExporter/baserom_non_mq.z64 - cmake --no-warn-unused-cli -H. -Bbuild-cmake -GNinja -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" - cmake --build build-cmake --target ExtractAssets -- cmake --build build-cmake --config Release -- (cd build-cmake && cpack) @@ -131,9 +145,6 @@ pipeline { } } stage ('Build Switch') { - options { - timeout(time: 20) - } agent { label "SoH-Linux-Builders" } @@ -146,9 +157,8 @@ pipeline { userRemoteConfigs: scm.userRemoteConfigs ]) catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { - sh ''' - - cp ../../ZELOOTD.z64 OTRExporter/baserom_non_mq.z64 + unstash 'assets' + sh ''' docker build . -t sohswitch docker run --name sohcont -dit --rm -v $(pwd):/soh sohswitch /bin/bash docker exec sohcont scripts/switch/build.sh diff --git a/ZAPDTR/ZAPD/ZResource.cpp b/ZAPDTR/ZAPD/ZResource.cpp index 89238d9a0..7536fa019 100644 --- a/ZAPDTR/ZAPD/ZResource.cpp +++ b/ZAPDTR/ZAPD/ZResource.cpp @@ -348,11 +348,14 @@ std::string ZResource::GetSourceOutputHeader([[maybe_unused]] const std::string& str += StringHelper::Sprintf("#define d%s \"__OTR__%s/%s\"", name.c_str(), outName.c_str(), nameStr.c_str()); if (nameSet && nameSet->find(name) == nameSet->end()) { + str += StringHelper::Sprintf(R"( #ifdef _WIN32 - str += StringHelper::Sprintf("\nstatic const __declspec(align(2)) char %s[] = d%s;", name.c_str(), name.c_str()); +static const __declspec(align(2)) char %s[] = d%s; #else - str += StringHelper::Sprintf("\nstatic const char %s[] __attribute__((aligned (2))) = d%s;", name.c_str(), name.c_str()); +static const char %s[] __attribute__((aligned (2))) = d%s; #endif + )", name.c_str(), name.c_str(), name.c_str(), name.c_str()); + if (nameSet) { nameSet->insert(name); } diff --git a/scripts/linux/appimage/build.sh b/scripts/linux/appimage/build.sh index bad6b00c5..86f46fb90 100755 --- a/scripts/linux/appimage/build.sh +++ b/scripts/linux/appimage/build.sh @@ -1,7 +1,6 @@ #!/bin/bash cmake --no-warn-unused-cli -H. -Bbuild-cmake -GNinja -DCMAKE_BUILD_TYPE:STRING=Release -cmake --build build-cmake --target ExtractAssets -- cmake --build build-cmake --config Release -- (cd build-cmake && cpack -G External) diff --git a/scripts/switch/build.sh b/scripts/switch/build.sh index b5b137652..2a208dd43 100755 --- a/scripts/switch/build.sh +++ b/scripts/switch/build.sh @@ -1,7 +1,4 @@ #!/bin/bash -cmake --no-warn-unused-cli -H. -Bbuild-linux -GNinja -cmake --build build-linux --target ExtractAssets - cmake -H. -Bbuild-switch -GNinja -DCMAKE_TOOLCHAIN_FILE=/opt/devkitpro/cmake/Switch.cmake cmake --build build-switch --target soh_nro From cf639b1d51b27187f6c5186a07f4414000fd7522 Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Mon, 8 Aug 2022 19:46:37 -0400 Subject: [PATCH 44/71] SDL/OpenGL - actually use the window resolution from the json (#1082) * actually use the window resolution from the json * switch fix Co-authored-by: briaguya --- libultraship/libultraship/Lib/Fast3D/gfx_sdl2.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libultraship/libultraship/Lib/Fast3D/gfx_sdl2.cpp b/libultraship/libultraship/Lib/Fast3D/gfx_sdl2.cpp index 23cff4698..76573c084 100644 --- a/libultraship/libultraship/Lib/Fast3D/gfx_sdl2.cpp +++ b/libultraship/libultraship/Lib/Fast3D/gfx_sdl2.cpp @@ -166,10 +166,12 @@ static void gfx_sdl_init(const char *game_name, bool start_in_fullscreen, uint32 #ifdef __SWITCH__ // For Switch we need to set the window width before creating the window Ship::Switch::GetDisplaySize(&window_width, &window_height); + width = window_width; + height = window_height; #endif wnd = SDL_CreateWindow(title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, - window_width, window_height, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI); + width, height, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI); #ifndef __SWITCH__ SDL_GL_GetDrawableSize(wnd, &window_width, &window_height); From 1f5d323d892a2f54bc4e79ef0f26e221073a1553 Mon Sep 17 00:00:00 2001 From: Dog <5172592+Dog@users.noreply.github.com> Date: Mon, 8 Aug 2022 16:48:53 -0700 Subject: [PATCH 45/71] Randomizer: Skip Cutscenes (#846) * Skip Jabu Jabu's fishy feeding time if rando is enabled Issue #757 Also skip the ganon tower fall cutscene if you died to ganon during the ganon fight for issue #773 * Immediately give control back to player when talon running cutscene starts. * Fix case of not skipping Gannon --- soh/src/code/z_demo.c | 16 ++++++++++------ soh/src/overlays/actors/ovl_En_Ta/z_en_ta.c | 5 ++++- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/soh/src/code/z_demo.c b/soh/src/code/z_demo.c index 885446271..a447f549c 100644 --- a/soh/src/code/z_demo.c +++ b/soh/src/code/z_demo.c @@ -492,9 +492,10 @@ void Cutscene_Command_Terminator(GlobalContext* globalCtx, CutsceneContext* csCt s32 temp = 0; // Automatically skip certain cutscenes when in rando - // cmd->base == 33: Zelda escaping with impa cutscene // cmd->base == 8: Traveling back/forward in time cutscene - bool randoCsSkip = (gSaveContext.n64ddFlag && (cmd->base == 33 || cmd->base == 8)); + // cmd->base == 24: Dropping a fish for Jabu Jabu + // cmd->base == 33: Zelda escaping with impa cutscene + bool randoCsSkip = (gSaveContext.n64ddFlag && (cmd->base == 8 || cmd->base == 24 || cmd->base == 33)); bool debugCsSkip = (CHECK_BTN_ALL(globalCtx->state.input[0].press.button, BTN_START) && (gSaveContext.fileNum != 0xFEDC) && CVar_GetS32("gDebugEnabled", 0)); @@ -2090,6 +2091,8 @@ void Cutscene_HandleConditionalTriggers(GlobalContext* globalCtx) { osSyncPrintf("\ngame_info.mode=[%d] restart_flag", ((void)0, gSaveContext.respawnFlag)); if ((gSaveContext.gameMode == 0) && (gSaveContext.respawnFlag <= 0) && (gSaveContext.cutsceneIndex < 0xFFF0)) { + const bool bShouldTowerRandoSkip = + (gSaveContext.n64ddFlag && Randomizer_GetSettingValue(RSK_SKIP_TOWER_ESCAPE)); if ((gSaveContext.entranceIndex == 0x01E1) && !Flags_GetEventChkInf(0xAC)) { if (!gSaveContext.n64ddFlag) { Flags_SetEventChkInf(0xAC); @@ -2118,14 +2121,15 @@ void Cutscene_HandleConditionalTriggers(GlobalContext* globalCtx) { gSaveContext.entranceIndex = 0x0053; gSaveContext.cutsceneIndex = 0xFFF8; } - } else if (!Flags_GetEventChkInf(0xC7) && - (gEntranceTable[((void)0, gSaveContext.entranceIndex)].scene == SCENE_GANON_DEMO)) { + } else if ((!Flags_GetEventChkInf(0xC7) && + gEntranceTable[((void)0, gSaveContext.entranceIndex)].scene == SCENE_GANON_DEMO) || + (bShouldTowerRandoSkip && + gEntranceTable[((void)0, gSaveContext.entranceIndex)].scene == SCENE_GANON_FINAL)) { Flags_SetEventChkInf(0xC7); gSaveContext.entranceIndex = 0x0517; - // If we are rando and tower escape skip is on, then set the flag to say we saw the towers fall // and exit. - if (gSaveContext.n64ddFlag && Randomizer_GetSettingValue(RSK_SKIP_TOWER_ESCAPE)) { + if (bShouldTowerRandoSkip) { return; } gSaveContext.cutsceneIndex = 0xFFF0; diff --git a/soh/src/overlays/actors/ovl_En_Ta/z_en_ta.c b/soh/src/overlays/actors/ovl_En_Ta/z_en_ta.c index dad7d25e5..85e47a7e7 100644 --- a/soh/src/overlays/actors/ovl_En_Ta/z_en_ta.c +++ b/soh/src/overlays/actors/ovl_En_Ta/z_en_ta.c @@ -460,10 +460,13 @@ void func_80B14AF4(EnTa* this, GlobalContext* globalCtx) { void func_80B14B6C(EnTa* this, GlobalContext* globalCtx) { if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) { - OnePointCutscene_Init(globalCtx, 4175, -99, &this->actor, MAIN_CAM); + s16 csCamIdx = OnePointCutscene_Init(globalCtx, 4175, -99, &this->actor, MAIN_CAM); func_80B13AA0(this, func_80B14AF4, func_80B167C0); this->unk_2CC = 5; gSaveContext.eventChkInf[1] |= 0x10; + if (gSaveContext.n64ddFlag) { + OnePointCutscene_EndCutscene(globalCtx, csCamIdx); + } Animation_PlayOnce(&this->skelAnime, &gTalonRunTransitionAnim); this->currentAnimation = &gTalonRunAnim; } From a8fea61bda44c1061005d9d8f08f3fc83ab5df70 Mon Sep 17 00:00:00 2001 From: aMannus Date: Tue, 9 Aug 2022 01:52:34 +0200 Subject: [PATCH 46/71] ADD: Enhancement presets (#926) * Proof of concept * Finished default preset * Added v1 presets * Overhauled implementation Function has been moved out of ImGuilmpl.cpp, and all presets have been put in their own functions so they can be applied in a cascading manner. Also did some slight changes to the presets themselves. * Fixed link animation settings * Deleted unneccesary change * Fixed missing newlines * Moved functions back to ImGuilmpl.cpp * Removed Ironman preset --- libultraship/libultraship/ImGuiImpl.cpp | 331 ++++++++++++++++++++++++ libultraship/libultraship/ImGuiImpl.h | 6 + 2 files changed, 337 insertions(+) diff --git a/libultraship/libultraship/ImGuiImpl.cpp b/libultraship/libultraship/ImGuiImpl.cpp index 032ca119c..b73b65886 100644 --- a/libultraship/libultraship/ImGuiImpl.cpp +++ b/libultraship/libultraship/ImGuiImpl.cpp @@ -1008,6 +1008,24 @@ namespace SohImGui { if (ImGui::BeginMenu("Enhancements")) { + + const char* enhancementPresets[4] = { "Default", "Vanilla Plus", "Enhanced", "Randomizer"}; + ImGui::Text("Enhancement Presets"); + SohImGui::EnhancementCombobox("gSelectEnhancementPresets", enhancementPresets, 4, 0); + Tooltip( + "Default - Set all enhancements to their default values. The true vanilla SoH experience.\n" + "\n" + "Vanilla Plus - Adds Quality of Life features that enhance your experience, but don't alter gameplay. Recommended for a first playthrough of OoT.\n" + "\n" + "Enhanced - The \"Vanilla Plus\" preset, but with more quality of life enhancements that might alter gameplay slightly. Recommended for returning players.\n" + "\n" + "Randomizer - The \"Enhanced\" preset, plus any other enhancements that are recommended for playing Randomizer." + ); + if (ImGui::Button("Apply Preset")) { + applyEnhancementPresets(); + } + ImGui::Separator(); + if (ImGui::BeginMenu("Gameplay")) { if (ImGui::BeginMenu("Time Savers")) @@ -1724,6 +1742,319 @@ namespace SohImGui { } } + void applyEnhancementPresets(void) { + + switch (CVar_GetS32("gSelectEnhancementPresets", 0)) { + // Default + case 0: + applyEnhancementPresetDefault(); + break; + + // Vanilla Plus + case 1: + applyEnhancementPresetDefault(); + applyEnhancementPresetVanillaPlus(); + break; + + // Enhanced + case 2: + applyEnhancementPresetDefault(); + applyEnhancementPresetVanillaPlus(); + applyEnhancementPresetEnhanced(); + break; + + // Randomizer + case 3: + applyEnhancementPresetDefault(); + applyEnhancementPresetVanillaPlus(); + applyEnhancementPresetEnhanced(); + applyEnhancementPresetRandomizer(); + break; + } + } + + void applyEnhancementPresetDefault(void) { + // Text Speed (1 to 5) + CVar_SetS32("gTextSpeed", 1); + // King Zora Speed (1 to 5) + CVar_SetS32("gMweepSpeed", 1); + // Biggoron Forge Time (0 to 3) + CVar_SetS32("gForgeTime", 3); + // Vine/Ladder Climb speed (+0 to +12) + CVar_SetS32("gClimbSpeed", 0); + // Faster Block Push + CVar_SetS32("gFasterBlockPush", 0); + // No Forced Navi + CVar_SetS32("gNoForcedNavi", 0); + // No Skulltula Freeze + CVar_SetS32("gSkulltulaFreeze", 0); + // MM Bunny Hood + CVar_SetS32("gMMBunnyHood", 0); + // Fast Chests + CVar_SetS32("gFastChests", 0); + // Fast Drops + CVar_SetS32("gFastDrops", 0); + // Better Owl + CVar_SetS32("gBetterOwl", 0); + // Fast Ocarina Playback + CVar_SetS32("gFastOcarinaPlayback", 0); + // Prevent Dropped Ocarina Inputs + CVar_SetS32("gDpadNoDropOcarinaInput", 0); + // Instant Putaway + CVar_SetS32("gInstantPutaway", 0); + // Mask Select in Inventory + CVar_SetS32("gMaskSelect", 0); + + // Damage Multiplier (0 to 8) + CVar_SetS32("gDamageMul", 0); + // Fall Damage Multiplier (0 to 7) + CVar_SetS32("gFallDamageMul", 0); + // Void Damage Multiplier (0 to 6) + CVar_SetS32("gVoidDamageMul", 0); + // No Random Drops + CVar_SetS32("gNoRandomDrops", 0); + // No Heart Drops + CVar_SetS32("gNoHeartDrops", 0); + // Always Win Goron Pot + CVar_SetS32("gGoronPot", 0); + + // Change Red Potion Effect + CVar_SetS32("gRedPotionEffect", 0); + // Red Potion Health (1 to 100) + CVar_SetS32("gRedPotionHealth", 1); + // Red Potion Percent Restore + CVar_SetS32("gRedPercentRestore", 0); + // Change Green Potion Effect + CVar_SetS32("gGreenPotionEffect", 0); + // Green Potion Mana (1 to 100) + CVar_SetS32("gGreenPotionMana", 1); + // Green Potion Percent Restore + CVar_SetS32("gGreenPercentRestore", 0); + // Change Blue Potion Effects + CVar_SetS32("gBluePotionEffects", 0); + // Blue Potion Health (1 to 100) + CVar_SetS32("gBluePotionHealth", 1); + // Blue Potion Health Percent Restore + CVar_SetS32("gBlueHealthPercentRestore", 0); + // Blue Potion Mana (1 to 100) + CVar_SetS32("gBluePotionMana", 1); + // Blue Potion Mana Percent Restore + CVar_SetS32("gBlueManaPercentRestore", 0); + // Change Milk Effect + CVar_SetS32("gMilkEffect", 0); + // Milk Health (1 to 100) + CVar_SetS32("gMilkHealth", 1); + // Milk Percent Restore + CVar_SetS32("gMilkPercentRestore", 0); + // Separate Half Milk Effect + CVar_SetS32("gSeparateHalfMilkEffect", 0); + // Half Milk Health (1 to 100) + CVar_SetS32("gHalfMilkHealth", 0); + // Half Milk Percent Restore + CVar_SetS32("gHalfMilkPercentRestore", 0); + // Change Fairy Effect + CVar_SetS32("gFairyEffect", 0); + // Fairy (1 to 100) + CVar_SetS32("gFairyHealth", 1); + // Fairy Percent Restore + CVar_SetS32("gFairyPercentRestore", 0); + // Change Fairy Revive Effect + CVar_SetS32("gFairyReviveEffect", 0); + // Fairy Revival (1 to 100) + CVar_SetS32("gFairyReviveHealth", 1); + // Fairy Revive Percent Restore + CVar_SetS32("gFairyRevivePercentRestore", 0); + + // Instant Fishing + CVar_SetS32("gInstantFishing", 0); + // Guarantee Bite + CVar_SetS32("gGuaranteeFishingBite", 0); + // Child Minimum Weight (6 to 10) + CVar_SetS32("gChildMinimumWeightFish", 10); + // Adult Minimum Weight (8 to 13) + CVar_SetS32("gAdultMinimumWeightFish", 13); + + // Mute Low HP Alarm + CVar_SetS32("gLowHpAlarm", 0); + // Minimal UI + CVar_SetS32("gMinimalUI", 0); + // Disable Navi Call Audio + CVar_SetS32("gDisableNaviCallAudio", 0); + + // Visual Stone of Agony + CVar_SetS32("gVisualAgony", 0); + // Assignable Tunics and Boots + CVar_SetS32("gAssignableTunicsAndBoots", 0); + // Link's Cow in Both Time Periods + CVar_SetS32("gCowOfTime", 0); + // Enable visible guard vision + CVar_SetS32("gGuardVision", 0); + // Enable passage of time on file select + CVar_SetS32("gTimeFlowFileSelect", 0); + // Allow the cursor to be on any slot + CVar_SetS32("gPauseAnyCursor", 0); + // Count Golden Skulltulas + CVar_SetS32("gInjectSkulltulaCount", 0); + // Pull grave during the day + CVar_SetS32("gDayGravePull", 0); + + // Rotate link (0 to 2) + CVar_SetS32("gPauseLiveLinkRotation", 0); + // Pause link animation (0 to 16) + CVar_SetS32("gPauseLiveLink", 0); + // Frames to wait + CVar_SetS32("gMinFrameCount", 1); + + // N64 Mode + CVar_SetS32("gN64Mode", 0); + // Enable 3D Dropped items/projectiles + CVar_SetS32("gNewDrops", 0); + // Disable Black Bar Letterboxes + CVar_SetS32("gDisableBlackBars", 0); + // Dynamic Wallet Icon + CVar_SetS32("gDynamicWalletIcon", 0); + // Always show dungeon entrances + CVar_SetS32("gAlwaysShowDungeonMinimapIcon", 0); + + // Fix L&R Pause menu + CVar_SetS32("gUniformLR", 0); + // Fix L&Z Page switch in Pause menu + CVar_SetS32("gNGCKaleidoSwitcher", 0); + // Fix Dungeon entrances + CVar_SetS32("gFixDungeonMinimapIcon", 0); + // Fix Two Handed idle animations + CVar_SetS32("gTwoHandedIdle", 0); + // Fix the Gravedigging Tour Glitch + CVar_SetS32("gGravediggingTourFix", 0); + // Fix Deku Nut upgrade + CVar_SetS32("gDekuNutUpgradeFix", 0); + // Fix Navi text HUD position + CVar_SetS32("gNaviTextFix", 0); + // Fix Anubis fireballs + CVar_SetS32("gAnubisFix", 0); + // Fix Megaton Hammer crouch stab + CVar_SetS32("gCrouchStabHammerFix", 0); + // Fix all crouch stab + CVar_SetS32("gCrouchStabFix", 0); + + // Red Ganon blood + CVar_SetS32("gRedGanonBlood", 0); + // Fish while hovering + CVar_SetS32("gHoverFishing", 0); + // N64 Weird Frames + CVar_SetS32("gN64WeirdFrames", 0); + // Bombchus out of bounds + CVar_SetS32("gBombchusOOB", 0); + } + + void applyEnhancementPresetVanillaPlus(void) { + // Text Speed (1 to 5) + CVar_SetS32("gTextSpeed", 5); + // King Zora Speed (1 to 5) + CVar_SetS32("gMweepSpeed", 2); + // Faster Block Push + CVar_SetS32("gFasterBlockPush", 1); + // Better Owl + CVar_SetS32("gBetterOwl", 1); + // Prevent Dropped Ocarina Inputs + CVar_SetS32("gDpadNoDropOcarinaInput", 1); + + // Assignable Tunics and Boots + CVar_SetS32("gAssignableTunicsAndBoots", 1); + // Enable passage of time on file select + CVar_SetS32("gTimeFlowFileSelect", 1); + // Count Golden Skulltulas + CVar_SetS32("gInjectSkulltulaCount", 1); + + // Pause link animation (0 to 16) + CVar_SetS32("gPauseLiveLink", 1); + + // Dynamic Wallet Icon + CVar_SetS32("gDynamicWalletIcon", 1); + // Always show dungeon entrances + CVar_SetS32("gAlwaysShowDungeonMinimapIcon", 1); + + // Fix L&R Pause menu + CVar_SetS32("gUniformLR", 1); + // Fix Dungeon entrances + CVar_SetS32("gFixDungeonMinimapIcon", 1); + // Fix Two Handed idle animations + CVar_SetS32("gTwoHandedIdle", 1); + // Fix the Gravedigging Tour Glitch + CVar_SetS32("gGravediggingTourFix", 1); + // Fix Deku Nut upgrade + CVar_SetS32("gDekuNutUpgradeFix", 1); + + // Red Ganon blood + CVar_SetS32("gRedGanonBlood", 1); + // Fish while hovering + CVar_SetS32("gHoverFishing", 1); + // N64 Weird Frames + CVar_SetS32("gN64WeirdFrames", 1); + // Bombchus out of bounds + CVar_SetS32("gBombchusOOB", 1); + } + + void applyEnhancementPresetEnhanced(void) { + // King Zora Speed (1 to 5) + CVar_SetS32("gMweepSpeed", 5); + // Biggoron Forge Time (0 to 3) + CVar_SetS32("gForgeTime", 0); + // Vine/Ladder Climb speed (+0 to +12) + CVar_SetS32("gClimbSpeed", 1); + // No Forced Navi + CVar_SetS32("gNoForcedNavi", 1); + // No Skulltula Freeze + CVar_SetS32("gSkulltulaFreeze", 1); + // MM Bunny Hood + CVar_SetS32("gMMBunnyHood", 1); + // Fast Chests + CVar_SetS32("gFastChests", 1); + // Fast Drops + CVar_SetS32("gFastDrops", 1); + // Fast Ocarina Playback + CVar_SetS32("gFastOcarinaPlayback", 1); + // Instant Putaway + CVar_SetS32("gInstantPutaway", 1); + // Mask Select in Inventory + CVar_SetS32("gMaskSelect", 1); + + // Disable Navi Call Audio + CVar_SetS32("gDisableNaviCallAudio", 1); + + // Count Golden Skulltulas + CVar_SetS32("gInjectSkulltulaCount", 1); + + // Enable 3D Dropped items/projectiles + CVar_SetS32("gNewDrops", 1); + + // Fix Anubis fireballs + CVar_SetS32("gAnubisFix", 1); + } + + void applyEnhancementPresetRandomizer(void) { + // Instant Fishing + CVar_SetS32("gInstantFishing", 1); + // Guarantee Bite + CVar_SetS32("gGuaranteeFishingBite", 1); + // Child Minimum Weight (6 to 10) + CVar_SetS32("gChildMinimumWeightFish", 6); + // Adult Minimum Weight (8 to 13) + CVar_SetS32("gAdultMinimumWeightFish", 8); + + // Visual Stone of Agony + CVar_SetS32("gVisualAgony", 1); + // Allow the cursor to be on any slot + CVar_SetS32("gPauseAnyCursor", 1); + // Pull grave during the day + CVar_SetS32("gDayGravePull", 1); + + // Pause link animation (0 to 16) + CVar_SetS32("gPauseLiveLink", 16); + // Frames to wait + CVar_SetS32("gMinFrameCount", 200); + } + void Render() { ImGui::Render(); ImGuiRenderDrawData(ImGui::GetDrawData()); diff --git a/libultraship/libultraship/ImGuiImpl.h b/libultraship/libultraship/ImGuiImpl.h index 6913fce61..5358e2028 100644 --- a/libultraship/libultraship/ImGuiImpl.h +++ b/libultraship/libultraship/ImGuiImpl.h @@ -86,6 +86,12 @@ namespace SohImGui { void EnhancementColor(const char* text, const char* cvarName, ImVec4 ColorRGBA, ImVec4 default_colors, bool allow_rainbow = true, bool has_alpha=false, bool TitleSameLine=false); void EnhancementCombo(const std::string& name, const char* cvarName, const std::vector& items, int defaultValue = 0); + void applyEnhancementPresets(void); + void applyEnhancementPresetDefault(void); + void applyEnhancementPresetVanillaPlus(void); + void applyEnhancementPresetEnhanced(void); + void applyEnhancementPresetRandomizer(void); + void DrawMainMenuAndCalculateGameSize(void); void DrawFramebufferAndGameInput(void); From a4334ecb02e9d340c3f094e46bd4d84659559755 Mon Sep 17 00:00:00 2001 From: KiritoDev <36680385+KiritoDv@users.noreply.github.com> Date: Mon, 8 Aug 2022 18:53:43 -0500 Subject: [PATCH 47/71] Changed input disable to only be forced on switch (#941) * Changed input disable to only be forced on switch * Inverted if * Finally fixed validation * Removed enhancement if its a switch build * Input now only gets blocked when the device is not a keyboard or its on switch * Input gets blocked when the controller view is opened * gControlNav is enabled by default on switch * Fixed compilation issues --- libultraship/libultraship/ControlDeck.cpp | 38 ++++++++++++++++------- libultraship/libultraship/ImGuiImpl.cpp | 13 ++++++-- libultraship/libultraship/Window.cpp | 7 ++--- 3 files changed, 39 insertions(+), 19 deletions(-) diff --git a/libultraship/libultraship/ControlDeck.cpp b/libultraship/libultraship/ControlDeck.cpp index 31eb90067..7437afeee 100644 --- a/libultraship/libultraship/ControlDeck.cpp +++ b/libultraship/libultraship/ControlDeck.cpp @@ -6,6 +6,7 @@ #include "KeyboardController.h" #include "SDLController.h" #include +#include "Cvar.h" namespace Ship { uint8_t* controllerBits; @@ -51,18 +52,31 @@ namespace Ship { *controllerBits |= (backend->Connected()) << slot; } - void ControlDeck::WriteToPad(OSContPad* pad) const { - for (size_t i = 0; i < virtualDevices.size(); i++) { - const std::shared_ptr backend = physicalDevices[virtualDevices[i]]; - if (backend->GetGuid() == "Auto") { - for (const auto& device : physicalDevices) { - device->Read(&pad[i], i); - } - continue; - } - backend->Read(&pad[i], i); - } - } + void ControlDeck::WriteToPad(OSContPad* pad) const { + + #ifdef __SWITCH__ + bool shouldBlockGameInput = CVar_GetS32("gOpenMenuBar", 0); + #else + bool shouldBlockGameInput = CVar_GetS32("gOpenMenuBar", 0) && CVar_GetS32("gControlNav", 0); + #endif + + for (size_t i = 0; i < virtualDevices.size(); i++) { + const std::shared_ptr backend = physicalDevices[virtualDevices[i]]; + if (backend->GetGuid() == "Auto") { + for (const auto& device : physicalDevices) { + if(shouldBlockGameInput && device->GetGuid() != "Keyboard") { + continue; + } + device->Read(&pad[i], i); + } + continue; + } + if(shouldBlockGameInput && backend->GetGuid() != "Keyboard") { + continue; + } + backend->Read(&pad[i], i); + } + } #define NESTED(key, ...) StringHelper::Sprintf("Controllers.%s.Slot_%d." key, device->GetGuid().c_str(), slot, __VA_ARGS__) diff --git a/libultraship/libultraship/ImGuiImpl.cpp b/libultraship/libultraship/ImGuiImpl.cpp index b73b65886..0d00ec32c 100644 --- a/libultraship/libultraship/ImGuiImpl.cpp +++ b/libultraship/libultraship/ImGuiImpl.cpp @@ -822,7 +822,12 @@ namespace SohImGui { GlobalCtx2::GetInstance()->GetWindow()->SetMenuBar(menu_bar); ShowCursor(menu_bar, Dialogues::dMenubar); GlobalCtx2::GetInstance()->GetWindow()->GetControlDeck()->SaveControllerSettings(); - if (CVar_GetS32("gControlNav", 0)) { + #ifdef __SWITCH__ + bool enableControllerNavigation = true; + #else + bool enableControllerNavigation = CVar_GetS32("gControlNav", 0); + #endif + if (enableControllerNavigation) { if (CVar_GetS32("gOpenMenuBar", 0)) { io->ConfigFlags |=ImGuiConfigFlags_NavEnableGamepad | ImGuiConfigFlags_NavEnableKeyboard; } else { @@ -892,9 +897,11 @@ namespace SohImGui { if (ImGui::BeginMenu("Controller")) { + + #ifndef __SWITCH__ EnhancementCheckbox("Use Controller Navigation", "gControlNav"); Tooltip("Allows controller navigation of the menu bar\nD-pad to move between items, A to select, and X to grab focus on the menu bar"); - + #endif EnhancementCheckbox("Controller Configuration", "gControllerConfigurationEnabled"); controller->Opened = CVar_GetS32("gControllerConfigurationEnabled", 0); @@ -1365,7 +1372,7 @@ namespace SohImGui { { val = 20; } - + CVar_SetS32(fps_cvar, val); needs_save = true; } diff --git a/libultraship/libultraship/Window.cpp b/libultraship/libultraship/Window.cpp index 0db33792e..f4f047428 100644 --- a/libultraship/libultraship/Window.cpp +++ b/libultraship/libultraship/Window.cpp @@ -19,7 +19,7 @@ #include #include #include "Console.h" -#include "Cvar.h" +#include "ImGuiImpl.h" #include @@ -67,10 +67,9 @@ extern "C" { pad->gyro_x = 0; pad->gyro_y = 0; - if (!CVar_GetS32("gOpenMenuBar", 0)) { - Ship::GlobalCtx2::GetInstance()->GetWindow()->GetControlDeck()->WriteToPad(pad); - } + if (SohImGui::controller->Opened) return; + Ship::GlobalCtx2::GetInstance()->GetWindow()->GetControlDeck()->WriteToPad(pad); Ship::ExecuteHooks(pad); } From f80ba4102a4d7919a7aa1a68809cebda9e3389df Mon Sep 17 00:00:00 2001 From: lilDavid <1337lilDavid@gmail.com> Date: Mon, 8 Aug 2022 18:55:07 -0500 Subject: [PATCH 48/71] Add instant boomerang recall (#1006) --- libultraship/libultraship/ImGuiImpl.cpp | 2 ++ soh/include/z64player.h | 3 ++- soh/src/overlays/actors/ovl_En_Boom/z_en_boom.c | 7 ++++--- .../overlays/actors/ovl_player_actor/z_player.c | 17 +++++++++++------ 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/libultraship/libultraship/ImGuiImpl.cpp b/libultraship/libultraship/ImGuiImpl.cpp index 0d00ec32c..8a85909c3 100644 --- a/libultraship/libultraship/ImGuiImpl.cpp +++ b/libultraship/libultraship/ImGuiImpl.cpp @@ -1062,6 +1062,8 @@ namespace SohImGui { Tooltip("Skip the part where the Ocarina playback is called when you play a song"); EnhancementCheckbox("Prevent Dropped Ocarina Inputs", "gDpadNoDropOcarinaInput"); Tooltip("Prevent dropping inputs when playing the ocarina quickly"); + EnhancementCheckbox("Instant Boomerang Recall", "gFastBoomerang"); + Tooltip("Instantly return the boomerang to Link by pressing its item button while it's in the air"); EnhancementCheckbox("Instant Putaway", "gInstantPutaway"); Tooltip("Allow Link to put items away without having to wait around"); EnhancementCheckbox("Mask Select in Inventory", "gMaskSelect"); diff --git a/soh/include/z64player.h b/soh/include/z64player.h index 3c2c7c3cd..a5caa174d 100644 --- a/soh/include/z64player.h +++ b/soh/include/z64player.h @@ -626,6 +626,7 @@ typedef struct Player { /* 0x0A87 */ u8 unk_A87; /* 0x0A88 */ Vec3f unk_A88; // previous body part 0 position /* 0x0A94 */ PendingFlag pendingFlag; -} Player; // size = 0xAA0 + /* 0x0AA0 */ u8 boomerangQuickRecall; // Has the player pressed the boomerang button while it's in the air still? +} Player; // size = 0xAA1 #endif diff --git a/soh/src/overlays/actors/ovl_En_Boom/z_en_boom.c b/soh/src/overlays/actors/ovl_En_Boom/z_en_boom.c index f041d55bd..e79d14109 100644 --- a/soh/src/overlays/actors/ovl_En_Boom/z_en_boom.c +++ b/soh/src/overlays/actors/ovl_En_Boom/z_en_boom.c @@ -167,12 +167,12 @@ void EnBoom_Fly(EnBoom* this, GlobalContext* globalCtx) { // Decrement the return timer and check if it's 0. If it is, check if Link can catch it and handle accordingly. // Otherwise handle grabbing and colliding. - if (DECR(this->returnTimer) == 0) { + if (DECR(this->returnTimer) == 0 || player->boomerangQuickRecall) { distFromLink = Math_Vec3f_DistXYZ(&this->actor.world.pos, &player->actor.focus.pos); this->moveTo = &player->actor; // If the boomerang is less than 40 units away from Link, he can catch it. - if (distFromLink < 40.0f) { + if (distFromLink < 40.0f || player->boomerangQuickRecall) { target = this->grabbed; if (target != NULL) { Math_Vec3f_Copy(&target->world.pos, &player->actor.world.pos); @@ -187,7 +187,8 @@ void EnBoom_Fly(EnBoom* this, GlobalContext* globalCtx) { } } // Set player flags and kill the boomerang beacause Link caught it. - player->stateFlags1 &= ~0x02000000; + player->stateFlags1 &= ~PLAYER_STATE1_25; + player->boomerangQuickRecall = false; Actor_Kill(&this->actor); } } 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 aa875a373..c2327d0c5 100644 --- a/soh/src/overlays/actors/ovl_player_actor/z_player.c +++ b/soh/src/overlays/actors/ovl_player_actor/z_player.c @@ -146,10 +146,10 @@ s32 func_808353D8(Player* this, GlobalContext* globalCtx); s32 func_80835588(Player* this, GlobalContext* globalCtx); s32 func_808356E8(Player* this, GlobalContext* globalCtx); s32 func_80835800(Player* this, GlobalContext* globalCtx); -s32 func_80835884(Player* this, GlobalContext* globalCtx); -s32 func_808358F0(Player* this, GlobalContext* globalCtx); -s32 func_808359FC(Player* this, GlobalContext* globalCtx); -s32 func_80835B60(Player* this, GlobalContext* globalCtx); +s32 func_80835884(Player* this, GlobalContext* globalCtx); // Start aiming boomerang +s32 func_808358F0(Player* this, GlobalContext* globalCtx); // Aim boomerang +s32 func_808359FC(Player* this, GlobalContext* globalCtx); // Throw boomerang +s32 func_80835B60(Player* this, GlobalContext* globalCtx); // Boomerang active s32 func_80835C08(Player* this, GlobalContext* globalCtx); void func_80835F44(GlobalContext* globalCtx, Player* this, s32 item); void func_80839F90(Player* this, GlobalContext* globalCtx); @@ -487,8 +487,8 @@ static s32 D_80853604 = 0; static s32 D_80853608 = 0; static s32 D_8085360C = 0; static s16 D_80853610 = 0; -static s32 D_80853614 = 0; -static s32 D_80853618 = 0; +static s32 D_80853614 = 0; // Held item button just pressed? +static s32 D_80853618 = 0; // Held item button currently down? static u16 D_8085361C[] = { NA_SE_VO_LI_SWEAT, @@ -955,6 +955,7 @@ static s8 sItemActionParams[] = { static u8 sMaskMemory; +// Used to map action params to update functions static s32(*D_80853EDC[])(Player* this, GlobalContext* globalCtx) = { func_8083485C, func_8083485C, func_8083485C, func_808349DC, func_808349DC, func_808349DC, func_8083485C, func_8083485C, func_8083501C, func_8083501C, func_8083501C, func_8083501C, func_8083501C, func_8083501C, @@ -2729,6 +2730,10 @@ s32 func_80835B60(Player* this, GlobalContext* globalCtx) { return 1; } + if (D_80853614 && CVar_GetS32("gFastBoomerang", 0)) { + this->boomerangQuickRecall = true; + } + return 0; } From 4bf4ad33598f2974341ef719928b89ab188beb47 Mon Sep 17 00:00:00 2001 From: InfoManiac742 <26778801+InfoManiac742@users.noreply.github.com> Date: Mon, 8 Aug 2022 16:56:56 -0700 Subject: [PATCH 49/71] Update z_en_ru1.c (#1042) --- soh/src/overlays/actors/ovl_En_Ru1/z_en_ru1.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/soh/src/overlays/actors/ovl_En_Ru1/z_en_ru1.c b/soh/src/overlays/actors/ovl_En_Ru1/z_en_ru1.c index 4b55990da..0abbb4cd3 100644 --- a/soh/src/overlays/actors/ovl_En_Ru1/z_en_ru1.c +++ b/soh/src/overlays/actors/ovl_En_Ru1/z_en_ru1.c @@ -760,6 +760,14 @@ void func_80AEC2C0(EnRu1* this, GlobalContext* globalCtx) { func_80AEC070(this, globalCtx, something); } +// Convenience function used so that Ruto always spawns in Jabu in rando, even after she's been kidnapped +// Equivalent to !(gSaveContext.infTable[20] & 0x20) in vanilla +bool shouldSpawnRuto() { + // gSaveContext.infTable[20] & 0x40 check is to prevent Ruto from spawning during the short period of time when + // she's on the Zora's Sapphire pedestal but hasn't been kidnapped yet (would result in multiple Rutos otherwise) + return !(gSaveContext.infTable[20] & 0x20) || (gSaveContext.n64ddFlag && (gSaveContext.infTable[20] & 0x40)); +} + void func_80AEC320(EnRu1* this, GlobalContext* globalCtx) { s8 actorRoom; @@ -767,8 +775,7 @@ void func_80AEC320(EnRu1* this, GlobalContext* globalCtx) { func_80AEB264(this, &gRutoChildWait2Anim, 0, 0, 0); this->action = 7; EnRu1_SetMouthIndex(this, 1); - } else if ((gSaveContext.infTable[20] & 0x80) && !(gSaveContext.infTable[20] & 1) && - !(gSaveContext.infTable[20] & 0x20)) { + } else if ((gSaveContext.infTable[20] & 0x80) && !(gSaveContext.infTable[20] & 1) && shouldSpawnRuto()) { if (!func_80AEB020(this, globalCtx)) { func_80AEB264(this, &gRutoChildWait2Anim, 0, 0, 0); actorRoom = this->actor.room; @@ -1172,7 +1179,7 @@ void func_80AED414(EnRu1* this, GlobalContext* globalCtx) { void func_80AED44C(EnRu1* this, GlobalContext* globalCtx) { s8 actorRoom; - if ((gSaveContext.infTable[20] & 2) && !(gSaveContext.infTable[20] & 0x20) && !(gSaveContext.infTable[20] & 1) && + if ((gSaveContext.infTable[20] & 2) && shouldSpawnRuto() && !(gSaveContext.infTable[20] & 1) && !(gSaveContext.infTable[20] & 0x80)) { if (!func_80AEB020(this, globalCtx)) { func_80AEB264(this, &gRutoChildWait2Anim, 0, 0, 0); @@ -2179,7 +2186,7 @@ void func_80AEFF40(EnRu1* this, GlobalContext* globalCtx) { void func_80AEFF94(EnRu1* this, GlobalContext* globalCtx) { s8 actorRoom; - if ((gSaveContext.infTable[20] & 2) && (gSaveContext.infTable[20] & 1) && !(gSaveContext.infTable[20] & 0x20) && + if ((gSaveContext.infTable[20] & 2) && (gSaveContext.infTable[20] & 1) && shouldSpawnRuto() && (!(func_80AEB020(this, globalCtx)))) { func_80AEB264(this, &gRutoChildWait2Anim, 0, 0, 0); actorRoom = this->actor.room; From 0e10b593070cff0d79a85b4cf42578f4d78e2009 Mon Sep 17 00:00:00 2001 From: InfoManiac742 <26778801+InfoManiac742@users.noreply.github.com> Date: Mon, 8 Aug 2022 16:58:01 -0700 Subject: [PATCH 50/71] Update z_kaleido_item.c (#1046) --- .../overlays/misc/ovl_kaleido_scope/z_kaleido_item.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 6a0e32bea..eca607ac0 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 @@ -11,12 +11,12 @@ static s16 sEquipAnimTimer = 0; static s16 sEquipMoveTimer = 10; static s16 sAmmoVtxOffset[] = { - 0, 2, 4, 6, 99, 99, 8, 99, 99, 10, 99, 99, 99, 99, 99, 99, 12, + 0, 2, 4, 6, 99, 99, 8, 99, 10, 99, 99, 99, 99, 99, 12, }; extern const char* _gAmmoDigit0Tex[]; -void KaleidoScope_DrawAmmoCount(PauseContext* pauseCtx, GraphicsContext* gfxCtx, s16 item) { +void KaleidoScope_DrawAmmoCount(PauseContext* pauseCtx, GraphicsContext* gfxCtx, s16 item, int slot) { s16 ammo; s16 i; @@ -50,7 +50,7 @@ void KaleidoScope_DrawAmmoCount(PauseContext* pauseCtx, GraphicsContext* gfxCtx, gDPPipeSync(POLY_KAL_DISP++); if (i != 0) { - gSPVertex(POLY_KAL_DISP++, &pauseCtx->itemVtx[(sAmmoVtxOffset[item] + 31) * 4], 4, 0); + gSPVertex(POLY_KAL_DISP++, &pauseCtx->itemVtx[(sAmmoVtxOffset[slot] + 31) * 4], 4, 0); gDPLoadTextureBlock(POLY_KAL_DISP++, ((u8*)_gAmmoDigit0Tex[i]), G_IM_FMT_IA, G_IM_SIZ_8b, 8, 8, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, @@ -59,7 +59,7 @@ void KaleidoScope_DrawAmmoCount(PauseContext* pauseCtx, GraphicsContext* gfxCtx, gSP1Quadrangle(POLY_KAL_DISP++, 0, 2, 3, 1, 0); } - gSPVertex(POLY_KAL_DISP++, &pauseCtx->itemVtx[(sAmmoVtxOffset[item] + 32) * 4], 4, 0); + gSPVertex(POLY_KAL_DISP++, &pauseCtx->itemVtx[(sAmmoVtxOffset[slot] + 32) * 4], 4, 0); gDPLoadTextureBlock(POLY_KAL_DISP++, ((u8*)_gAmmoDigit0Tex[ammo]), G_IM_FMT_IA, G_IM_SIZ_8b, 8, 8, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, @@ -464,7 +464,7 @@ void KaleidoScope_DrawItemSelect(GlobalContext* globalCtx) { for (i = 0; i < 15; i++) { if ((gAmmoItems[i] != ITEM_NONE) && (gSaveContext.inventory.items[i] != ITEM_NONE)) { - KaleidoScope_DrawAmmoCount(pauseCtx, globalCtx->state.gfxCtx, gSaveContext.inventory.items[i]); + KaleidoScope_DrawAmmoCount(pauseCtx, globalCtx->state.gfxCtx, gSaveContext.inventory.items[i], i); } } From c803ff65cee0001e405dce30b3716ae6e40222a1 Mon Sep 17 00:00:00 2001 From: th-2021 <90853655+th-2021@users.noreply.github.com> Date: Tue, 9 Aug 2022 01:58:43 +0200 Subject: [PATCH 51/71] fix path to ZAPD (#1092) --- CMake/genscript.cmake | 5 +++++ CMakeLists.txt | 10 ++-------- 2 files changed, 7 insertions(+), 8 deletions(-) create mode 100644 CMake/genscript.cmake diff --git a/CMake/genscript.cmake b/CMake/genscript.cmake new file mode 100644 index 000000000..10089a4fd --- /dev/null +++ b/CMake/genscript.cmake @@ -0,0 +1,5 @@ +file(READ ${CMAKE_CURRENT_SOURCE_DIR}/extract_assets.py filedata) +string(REGEX REPLACE "zapd_exe = .*exec_cmd =" "zapd_exe = \"${program}\"\n exec_cmd =" filedata "${filedata}") +file(WRITE "${CMAKE_CURRENT_SOURCE_DIR}/extract_assets_cmake2.py" "${filedata}") +file(CHMOD "${CMAKE_CURRENT_SOURCE_DIR}/extract_assets_cmake2.py" PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) + diff --git a/CMakeLists.txt b/CMakeLists.txt index c9698c68f..ef21271f5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -134,17 +134,11 @@ if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") INSTALL(PROGRAMS "${CMAKE_SOURCE_DIR}/scripts/linux/appimage/soh.sh" DESTINATION . COMPONENT appimage) endif() -file(READ ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter/extract_assets.py filedata) -string(REGEX REPLACE "../ZAPDTR/ZAPD.out" "${CMAKE_BINARY_DIR}/ZAPD/ZAPD.out" filedata "${filedata}") -string(REGEX REPLACE "x64" "..\\\\\\\\x64" filedata "${filedata}") -string(REGEX REPLACE "Release" "${CMAKE_BUILD_TYPE}" filedata "${filedata}") -file(WRITE "${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter/extract_assets_cmake2.py" "${filedata}") -file(CHMOD "${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter/extract_assets_cmake2.py" PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) - find_package(Python3 COMPONENTS Interpreter) add_custom_target( ExtractAssets + COMMAND ${CMAKE_COMMAND} -Dprogram=$ -P ${CMAKE_SOURCE_DIR}/CMake/genscript.cmake COMMAND ${CMAKE_COMMAND} -E rm -f oot.otr COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter/extract_assets_cmake2.py COMMAND ${CMAKE_COMMAND} -E copy oot.otr ${CMAKE_SOURCE_DIR} @@ -152,7 +146,7 @@ add_custom_target( WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter COMMENT "Running asset extraction..." DEPENDS ZAPD - + BYPRODUCTS oot.otr ${CMAKE_SOURCE_DIR}/oot.otr ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter/extract_assets_cmake2.py ) if(CMAKE_SYSTEM_NAME MATCHES "Linux") From 4ea7f8371f3673a880d8937e6fec108ef2679135 Mon Sep 17 00:00:00 2001 From: aMannus Date: Tue, 9 Aug 2022 01:59:06 +0200 Subject: [PATCH 52/71] Rando: Zelda sequence fixes (#1095) * Fixed zelda sequence oddities * Fixed code inconsistency * Adressed review comments * Adressed review comments, removed unneccesary entrance skip * Addressed some more review comments * tiny cleanup --- soh/soh/Enhancements/randomizer/randomizer.cpp | 5 ++++- soh/src/code/z_play.c | 10 +++++++--- soh/src/code/z_sram.c | 6 +++--- .../overlays/actors/ovl_En_Heishi1/z_en_heishi1.c | 13 +++++++++++-- 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index 09704e867..ed3c6182e 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -3251,7 +3251,10 @@ void GenerateRandomizerImgui() { cvarSettings[RSK_CUCCO_COUNT] = CVar_GetS32("gRandomizeCuccosToReturn", 7); cvarSettings[RSK_BIG_POE_COUNT] = CVar_GetS32("gRandomizeBigPoeTargetCount", 10); - cvarSettings[RSK_SKIP_CHILD_STEALTH] = CVar_GetS32("gRandomizeSkipChildStealth", 0); + // If we skip child zelda, skip child stealth is pointless, so this needs to be reflected in the spoiler log + cvarSettings[RSK_SKIP_CHILD_STEALTH] = + !CVar_GetS32("gRandomizeSkipChildZelda", 0) && CVar_GetS32("gRandomizeSkipChildStealth", 0); + cvarSettings[RSK_SKIP_EPONA_RACE] = CVar_GetS32("gRandomizeSkipEponaRace", 0); cvarSettings[RSK_SKIP_TOWER_ESCAPE] = CVar_GetS32("gRandomizeSkipTowerEscape", 0); diff --git a/soh/src/code/z_play.c b/soh/src/code/z_play.c index a42fb2f78..ae8791bd4 100644 --- a/soh/src/code/z_play.c +++ b/soh/src/code/z_play.c @@ -273,11 +273,15 @@ void Gameplay_Init(GameState* thisx) { u8 tempSetupIndex; s32 pad[2]; - if (gSaveContext.n64ddFlag && Randomizer_GetSettingValue(RSK_SKIP_CHILD_STEALTH)) { + // Skip Child Stealth when option is enabled, Zelda's Letter isn't obtained and Impa's reward hasn't been received + // eventChkInf[4] & 1 = Got Zelda's Letter + // eventChkInf[5] & 0x200 = Got Impa's reward + // entranceIndex 0x7A, Castle Courtyard - Day from crawlspace + // entranceIndex 0x400, Zelda's Courtyard + if (gSaveContext.n64ddFlag && Randomizer_GetSettingValue(RSK_SKIP_CHILD_STEALTH) && + !(gSaveContext.eventChkInf[4] & 1) && !(gSaveContext.eventChkInf[5] & 0x200)) { if (gSaveContext.entranceIndex == 0x7A) { gSaveContext.entranceIndex = 0x400; - } else if (gSaveContext.entranceIndex == 0x296) { - gSaveContext.entranceIndex = 0x23D; } } diff --git a/soh/src/code/z_sram.c b/soh/src/code/z_sram.c index 7670762c5..caf250a4a 100644 --- a/soh/src/code/z_sram.c +++ b/soh/src/code/z_sram.c @@ -790,12 +790,12 @@ void Sram_InitSave(FileChooseContext* fileChooseCtx) { gSaveContext.eventChkInf[1] |= (1 << 3); gSaveContext.eventChkInf[1] |= (1 << 4); + // Set "Got Zelda's Letter" flag. Also ensures Saria is back at SFM. TODO: Is this flag used for anything else? + gSaveContext.eventChkInf[4] |= 1; + // Got item from impa gSaveContext.eventChkInf[5] |= 0x200; - // make sure saria is at SFM - gSaveContext.eventChkInf[4] |= (1 << 0); - // set this at the end to ensure we always start with the letter // this is for the off chance we got the weird egg from impa (which should never happen) INV_CONTENT(ITEM_LETTER_ZELDA) = ITEM_LETTER_ZELDA; diff --git a/soh/src/overlays/actors/ovl_En_Heishi1/z_en_heishi1.c b/soh/src/overlays/actors/ovl_En_Heishi1/z_en_heishi1.c index d2d9fac4b..5a313a07f 100644 --- a/soh/src/overlays/actors/ovl_En_Heishi1/z_en_heishi1.c +++ b/soh/src/overlays/actors/ovl_En_Heishi1/z_en_heishi1.c @@ -112,14 +112,23 @@ void EnHeishi1_Init(Actor* thisx, GlobalContext* globalCtx) { } } + // eventChkInf[4] & 1 = Got Zelda's Letter + // eventChkInf[5] & 0x200 = Got item from impa + // eventChkInf[8] & 1 = Ocarina thrown in moat + bool metZelda = (gSaveContext.eventChkInf[4] & 1) && (gSaveContext.eventChkInf[5] & 0x200); + if (this->type != 5) { - if (((gSaveContext.dayTime < 0xB888) || IS_DAY) && (gSaveContext.n64ddFlag || !(gSaveContext.eventChkInf[8] & 1))) { + if ((gSaveContext.dayTime < 0xB888 || IS_DAY) && + ((!gSaveContext.n64ddFlag && !(gSaveContext.eventChkInf[8] & 1)) || + (gSaveContext.n64ddFlag && !metZelda))) { this->actionFunc = EnHeishi1_SetupWalk; } else { Actor_Kill(&this->actor); } } else { - if ((gSaveContext.dayTime >= 0xB889) || !IS_DAY || (!gSaveContext.n64ddFlag && (gSaveContext.eventChkInf[8] & 1))) { + if ((gSaveContext.dayTime >= 0xB889) || !IS_DAY || + (!gSaveContext.n64ddFlag && gSaveContext.eventChkInf[8] & 1) || + (gSaveContext.n64ddFlag && metZelda)) { this->actionFunc = EnHeishi1_SetupWaitNight; } else { Actor_Kill(&this->actor); From 5453c68399f25ee49c7300d54c2b83997b5b964a Mon Sep 17 00:00:00 2001 From: sholdee <102821812+sholdee@users.noreply.github.com> Date: Mon, 8 Aug 2022 18:59:43 -0500 Subject: [PATCH 53/71] [ci] docker improvements (#1101) --- Jenkinsfile | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 5f976bb4e..80df7b0cc 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -67,8 +67,8 @@ pipeline { move "_packages\\*.zip" "soh.zip" """ - archiveArtifacts artifacts: 'soh.zip', followSymlinks: false, onlyIfSuccessful: true } + archiveArtifacts artifacts: 'soh.zip', followSymlinks: false, onlyIfSuccessful: true } post { always { @@ -91,6 +91,7 @@ pipeline { catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { unstash 'assets' sh ''' + if docker ps -aq --filter "name=sohcont" | grep -q .; then docker rm -f sohcont; fi docker build . -t soh docker run --name sohcont -dit --rm -v $(pwd):/soh soh /bin/bash docker exec sohcont scripts/linux/appimage/build.sh @@ -102,11 +103,12 @@ pipeline { ''' } - sh 'sudo docker container stop sohcont' archiveArtifacts artifacts: 'soh-linux.7z', followSymlinks: false, onlyIfSuccessful: true } post { always { + sh 'sudo docker container stop sohcont' + sh 'docker images --quiet --filter=dangling=true | xargs --no-run-if-empty docker rmi' // Clean dangling docker images step([$class: 'WsCleanup']) // Clean workspace } } @@ -159,9 +161,10 @@ pipeline { catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { unstash 'assets' sh ''' + if docker ps -aq --filter "name=sohswitchcont" | grep -q .; then docker rm -f sohswitchcont; fi docker build . -t sohswitch - docker run --name sohcont -dit --rm -v $(pwd):/soh sohswitch /bin/bash - docker exec sohcont scripts/switch/build.sh + docker run --name sohswitchcont -dit --rm -v $(pwd):/soh sohswitch /bin/bash + docker exec sohswitchcont scripts/switch/build.sh mv build-switch/soh/*.nro soh.nro mv README.md readme.txt @@ -170,11 +173,12 @@ pipeline { ''' } - sh 'sudo docker container stop sohcont' archiveArtifacts artifacts: 'soh-switch.7z', followSymlinks: false, onlyIfSuccessful: true } post { always { + sh 'sudo docker container stop sohswitchcont' + sh 'docker images --quiet --filter=dangling=true | xargs --no-run-if-empty docker rmi' // Clean dangling docker images step([$class: 'WsCleanup']) // Clean workspace } } From b6934b34db519f37d7e59b16cd72558b543b3cde Mon Sep 17 00:00:00 2001 From: Josh Bodner <30329717+jbodner09@users.noreply.github.com> Date: Mon, 8 Aug 2022 17:04:55 -0700 Subject: [PATCH 54/71] Re-add Windows dependencies to build instructions (#1102) --- BUILDING.md | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/BUILDING.md b/BUILDING.md index 7606032ba..f11db6f3e 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -2,9 +2,27 @@ ## Windows -1. Requires Visual Studio 2022 Community Edition && `python3, cmake, git` (can be installed via chocolatey or manually) -2. Clone the Ship of Harkinian repository -3. Place one or more [compatible](#compatible-roms) roms in the `OTRExporter` directory with namings of your choice +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 + * 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) + +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. + +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. + +1. Clone the Ship of Harkinian repository +2. Place one or more [compatible](#compatible-roms) roms in the `OTRExporter` directory with namings of your choice _Note: Instructions assume using powershell_ ```powershell @@ -53,7 +71,7 @@ cd "build/x64" ``` ## Linux -1. Requires `gcc >= 10, x11, curl, python3, sdl2 >= 2.0.22, libpng, glew >= 2.2, ninja, cmake, lld` +Requires `gcc >= 10, x11, curl, python3, sdl2 >= 2.0.22, libpng, glew >= 2.2, ninja, cmake, lld` **Important: For maximum performance make sure you have ninja build tools installed!** @@ -91,7 +109,7 @@ cpack -G External (creates appimage) ``` ## macOS -1. Requires Xcode (or xcode-tools) && `sdl2, libpng, glew, ninja, cmake` (can be installed via homebrew, macports, etc) +Requires Xcode (or xcode-tools) && `sdl2, libpng, glew, ninja, cmake` (can be installed via homebrew, macports, etc) **Important: For maximum performance make sure you have ninja build tools installed!** From 5581f45050263915229cec77a61cb7aa4c5bed27 Mon Sep 17 00:00:00 2001 From: Kenix3 Date: Mon, 8 Aug 2022 21:01:46 -0400 Subject: [PATCH 55/71] Adds instructions for Visuals Studio 2019 --- BUILDING.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/BUILDING.md b/BUILDING.md index f11db6f3e..f68794783 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -48,8 +48,10 @@ With the cmake build system you have two options for working on the project: #### Visual Studio To develop using Visual Studio you only need to use cmake to generate the solution file: ```powershell -# Generates Ship.sln at `build/x64` +# 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 ``` #### Visual Studio Code or another editor From e63d84bd7dc57b8d420ae6e548cdc832b746b126 Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Mon, 8 Aug 2022 21:14:29 -0400 Subject: [PATCH 56/71] Adapts this branch for cmake building. --- soh/CMakeLists.txt | 15 +++++++++++++++ .../CustomMessageManager.cpp | 0 .../CustomMessageManager.h | 2 +- .../CustomMessageTypes.h | 0 soh/soh/Enhancements/randomizer/randomizer.cpp | 4 ++-- soh/soh/OTRGlobals.cpp | 4 ++-- soh/soh/z_message_OTR.cpp | 4 ++-- .../overlays/actors/ovl_player_actor/z_player.c | 2 +- 8 files changed, 23 insertions(+), 8 deletions(-) rename soh/soh/Enhancements/{custom_message => custom-message}/CustomMessageManager.cpp (100%) rename soh/soh/Enhancements/{custom_message => custom-message}/CustomMessageManager.h (99%) rename soh/soh/Enhancements/{custom_message => custom-message}/CustomMessageTypes.h (100%) diff --git a/soh/CMakeLists.txt b/soh/CMakeLists.txt index 67d5db850..5342374f0 100644 --- a/soh/CMakeLists.txt +++ b/soh/CMakeLists.txt @@ -215,6 +215,13 @@ set(Header_Files__soh__Enhancements__randomizer__3drando ) source_group("Header Files\\soh\\Enhancements\\randomizer\\3drando" FILES ${Header_Files__soh__Enhancements__randomizer__3drando}) +set(Header_Files__soh__Enhancements__custom_message + "soh/Enhancements/custom-message/CustomMessageTypes.h" + "soh/Enhancements/custom-message/CustomMessageManager.h" +) + +source_group("Header Files\\soh\\Enhancements\\custom-message" FILES ${Header_Files__soh__Enhancements__custom_message}) + set(Source_Files__soh "soh/GbiWrap.cpp" "soh/OTRAudio.h" @@ -326,6 +333,12 @@ set(Source_Files__soh__Enhancements__randomizer__3drando__location_access ) source_group("Source Files\\soh\\Enhancements\\randomizer\\3drando\\location_access" FILES ${Source_Files__soh__Enhancements__randomizer__3drando__location_access}) +set(Source_Files__soh__Enhancements__custom_message + "soh/Enhancements/custom-message/CustomMessageManager.cpp" +) + +source_group("Source Files\\soh\\Enhancements\\custom-message" FILES ${Source_Files__soh__Enhancements__custom_message}) + set(Source_Files__src__boot "src/boot/assert.c" "src/boot/boot_main.c" @@ -1534,6 +1547,7 @@ set(ALL_FILES ${Header_Files__soh__Enhancements__debugger} ${Header_Files__soh__Enhancements__randomizer} ${Header_Files__soh__Enhancements__randomizer__3drando} + ${Header_Files__soh__Enhancements__custom_message} ${Source_Files__soh} ${Source_Files__soh__Enhancements} ${Source_Files__soh__Enhancements__cosmetics} @@ -1542,6 +1556,7 @@ set(ALL_FILES ${Source_Files__soh__Enhancements__randomizer__3drando} ${Source_Files__soh__Enhancements__randomizer__3drando__hint_list} ${Source_Files__soh__Enhancements__randomizer__3drando__location_access} + ${Source_Files__soh__Enhancements__custom_message} ${Source_Files__src__boot} ${Source_Files__src__buffers} ${Source_Files__src__code} diff --git a/soh/soh/Enhancements/custom_message/CustomMessageManager.cpp b/soh/soh/Enhancements/custom-message/CustomMessageManager.cpp similarity index 100% rename from soh/soh/Enhancements/custom_message/CustomMessageManager.cpp rename to soh/soh/Enhancements/custom-message/CustomMessageManager.cpp diff --git a/soh/soh/Enhancements/custom_message/CustomMessageManager.h b/soh/soh/Enhancements/custom-message/CustomMessageManager.h similarity index 99% rename from soh/soh/Enhancements/custom_message/CustomMessageManager.h rename to soh/soh/Enhancements/custom-message/CustomMessageManager.h index c5590dc00..0681073b8 100644 --- a/soh/soh/Enhancements/custom_message/CustomMessageManager.h +++ b/soh/soh/Enhancements/custom-message/CustomMessageManager.h @@ -1,7 +1,7 @@ #pragma once #include #include -#include "z64item.h" +#include "../../../include/z64item.h" #undef MESSAGE_END diff --git a/soh/soh/Enhancements/custom_message/CustomMessageTypes.h b/soh/soh/Enhancements/custom-message/CustomMessageTypes.h similarity index 100% rename from soh/soh/Enhancements/custom_message/CustomMessageTypes.h rename to soh/soh/Enhancements/custom-message/CustomMessageTypes.h diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index 18e73c230..eaf9f3098 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -13,8 +13,8 @@ #include "3drando/rando_main.hpp" #include #include "Lib/ImGui/imgui_internal.h" -#include -#include +#include +#include using json = nlohmann::json; using namespace std::literals::string_literals; diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 6470a49b3..ba61805f0 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -39,7 +39,7 @@ #include "macros.h" #include #include "Hooks.h" -#include +#include #ifdef __APPLE__ #include @@ -52,7 +52,7 @@ #endif #include -#include +#include #include OTRGlobals* OTRGlobals::Instance; diff --git a/soh/soh/z_message_OTR.cpp b/soh/soh/z_message_OTR.cpp index 4fd74e497..c6be43964 100644 --- a/soh/soh/z_message_OTR.cpp +++ b/soh/soh/z_message_OTR.cpp @@ -6,8 +6,8 @@ #include "vt.h" #include #include -#include -#include +#include +#include extern "C" MessageTableEntry* sNesMessageEntryTablePtr; extern "C" MessageTableEntry* sGerMessageEntryTablePtr; 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 17b738949..139c8a6e0 100644 --- a/soh/src/overlays/actors/ovl_player_actor/z_player.c +++ b/soh/src/overlays/actors/ovl_player_actor/z_player.c @@ -20,7 +20,7 @@ #include "objects/gameplay_keep/gameplay_keep.h" #include "objects/object_link_child/object_link_child.h" #include "textures/icon_item_24_static/icon_item_24_static.h" -#include "../../../../soh/Enhancements/custom_message/CustomMessageTypes.h" +#include typedef struct { /* 0x00 */ u8 itemId; From 0d9c3905261afb82520b723a9fd37a00cfcfb9cc Mon Sep 17 00:00:00 2001 From: Kenix3 Date: Mon, 8 Aug 2022 21:53:36 -0400 Subject: [PATCH 57/71] Removes no longer desired commented code. (#1105) --- libultraship/libultraship/ResourceMgr.cpp | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/libultraship/libultraship/ResourceMgr.cpp b/libultraship/libultraship/ResourceMgr.cpp index bcc783993..4c517b39d 100644 --- a/libultraship/libultraship/ResourceMgr.cpp +++ b/libultraship/libultraship/ResourceMgr.cpp @@ -82,19 +82,14 @@ namespace Ship { break; } - //Lock.lock(); std::shared_ptr ToLoad = FileLoadQueue.front(); FileLoadQueue.pop(); - //Lock.unlock(); OTR->LoadFile(ToLoad->path, true, ToLoad); - //Lock.lock(); if (!ToLoad->bHasLoadError) FileCache[ToLoad->path] = ToLoad->bIsLoaded && !ToLoad->bHasLoadError ? ToLoad : nullptr; - //Lock.unlock(); - SPDLOG_DEBUG("Loaded File {} on ResourceMgr thread", ToLoad->path); ToLoad->FileLoadNotifier.notify_all(); @@ -117,10 +112,8 @@ namespace Ship { } std::shared_ptr ToLoad = nullptr; - //ResLock.lock(); ToLoad = ResourceLoadQueue.front(); ResourceLoadQueue.pop(); - //ResLock.unlock(); // Wait for the underlying File to complete loading { @@ -148,9 +141,6 @@ namespace Ship { SPDLOG_DEBUG("Loaded Resource {} on ResourceMgr thread", ToLoad->file->path); - // Disabled for now because it can cause random crashes - //FileCache[Res->File->path] = nullptr; - //FileCache.erase(FileCache.find(Res->File->path)); Res->file = nullptr; } else { @@ -159,9 +149,6 @@ namespace Ship { SPDLOG_ERROR("Resource load FAILED {} on ResourceMgr thread", ToLoad->file->path); } - - //ResLock.lock(); - //ResLock.unlock(); } } else From e4b58e5a0ce29eeed4e3fb82dbb02961758098b0 Mon Sep 17 00:00:00 2001 From: aMannus Date: Tue, 9 Aug 2022 08:16:45 +0200 Subject: [PATCH 58/71] TWEAK: Layout/styling overhaul for the F1 menu (#1026) * First pass of UX changes * More padding/styling/layout * More styling * Moar styling * Some more styling * Implemented padding helpers * More styling, added closing buttons to windows * Fixed merge conflict mistake * Fixed new enhancements * Hopefully fix jenkins errors * Changed button behaviour, more styling * Tiny code cleanup * Change buttons from close/open to > when open * Small button spacing fix * Small styling changes after merge * Small fix after merge mistake --- libultraship/libultraship/Console.cpp | 8 +- libultraship/libultraship/ImGuiImpl.cpp | 733 +++++++++++------- libultraship/libultraship/ImGuiImpl.h | 8 +- .../cosmetics/CosmeticsEditor.cpp | 8 +- 4 files changed, 489 insertions(+), 268 deletions(-) diff --git a/libultraship/libultraship/Console.cpp b/libultraship/libultraship/Console.cpp index b7158bd3b..83737e738 100644 --- a/libultraship/libultraship/Console.cpp +++ b/libultraship/libultraship/Console.cpp @@ -100,11 +100,15 @@ namespace Ship { } void Console::Draw() { + if (!this->opened) { + CVar_SetS32("gConsoleEnabled", 0); + return; + } + bool input_focus = false; - if (!this->opened) return; ImGui::SetNextWindowSize(ImVec2(520, 600), ImGuiCond_FirstUseEver); - ImGui::Begin("Console", nullptr, ImGuiWindowFlags_NoFocusOnAppearing); + ImGui::Begin("Console", &this->opened, ImGuiWindowFlags_NoFocusOnAppearing); const ImVec2 pos = ImGui::GetWindowPos(); const ImVec2 size = ImGui::GetWindowSize(); // SohImGui::ShowCursor(ImGui::IsWindowHovered(ImGuiHoveredFlags_RootAndChildWindows | ImGuiHoveredFlags_RectOnly), SohImGui::Dialogues::dConsole); diff --git a/libultraship/libultraship/ImGuiImpl.cpp b/libultraship/libultraship/ImGuiImpl.cpp index 8a85909c3..a583b3d9c 100644 --- a/libultraship/libultraship/ImGuiImpl.cpp +++ b/libultraship/libultraship/ImGuiImpl.cpp @@ -60,9 +60,10 @@ bool oldCursorState = true; #define EXPERIMENTAL() \ ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(255, 50, 50, 255)); \ + InsertPadding(3.0f); \ ImGui::Text("Experimental"); \ ImGui::PopStyleColor(); \ - ImGui::Separator(); + PaddedSeparator(false, true); #define TOGGLE_BTN ImGuiKey_F1 #define TOGGLE_PAD_BTN ImGuiKey_GamepadBack #define HOOK(b) if(b) needs_save = true; @@ -97,6 +98,7 @@ namespace SohImGui { bool p_open = false; bool needs_save = false; int lastBackendID = 0; + bool statsWindowOpen; const char* filters[3] = { "Three-Point", @@ -384,6 +386,7 @@ namespace SohImGui { io = &ImGui::GetIO(); io->ConfigFlags |= ImGuiConfigFlags_DockingEnable; io->Fonts->AddFontDefault(); + statsWindowOpen = CVar_GetS32("gStatsEnabled", 0); #ifdef __SWITCH__ Ship::Switch::SetupFont(io->Fonts); #endif @@ -592,31 +595,43 @@ namespace SohImGui { else ImGui::Text(text, static_cast(100 * val)); + InsertPadding(); + if(PlusMinusButton) { std::string MinusBTNName = " - ##"; MinusBTNName += cvarName; if (ImGui::Button(MinusBTNName.c_str())) { - val -= 0.1f; + if (!isPercentage) + val -= 0.1f; + else + val -= 0.01f; CVar_SetFloat(cvarName, val); needs_save = true; } ImGui::SameLine(); ImGui::SetCursorPosX(ImGui::GetCursorPosX() - 7.0f); } - + if (PlusMinusButton) { + ImGui::PushItemWidth(ImGui::GetWindowSize().x - 79.0f); + } if (ImGui::SliderFloat(id, &val, min, max, format)) { CVar_SetFloat(cvarName, val); needs_save = true; } - + if (PlusMinusButton) { + ImGui::PopItemWidth(); + } if(PlusMinusButton) { std::string PlusBTNName = " + ##"; PlusBTNName += cvarName; ImGui::SameLine(); ImGui::SetCursorPosX(ImGui::GetCursorPosX() - 7.0f); if (ImGui::Button(PlusBTNName.c_str())) { - val += 0.1f; + if (!isPercentage) + val += 0.1f; + else + val += 0.01f; CVar_SetFloat(cvarName, val); needs_save = true; } @@ -865,6 +880,9 @@ namespace SohImGui { ImGui::SetCursorPos(ImVec2(25, 0)); } + static ImVec2 windowPadding(8.0f, 8.0f); + + ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, windowPadding); if (ImGui::BeginMenu("Shipwright")) { if (ImGui::MenuItem("Reset", #if __APPLE__ @@ -878,136 +896,145 @@ namespace SohImGui { ImGui::EndMenu(); } - ImGui::Separator(); - ImGui::SetCursorPosY(0.0f); - if (ImGui::BeginMenu("Audio")) { - EnhancementSliderFloat("Master Volume: %d %%", "##Master_Vol", "gGameMasterVolume", 0.0f, 1.0f, "", 1.0f, true); - - BindAudioSlider("Main Music Volume: %d %%", "gMainMusicVolume", 1.0f, SEQ_BGM_MAIN); - BindAudioSlider("Sub Music Volume: %d %%", "gSubMusicVolume", 1.0f, SEQ_BGM_SUB); - BindAudioSlider("Sound Effects Volume: %d %%", "gSFXMusicVolume", 1.0f, SEQ_SFX); - BindAudioSlider("Fanfare Volume: %d %%", "gFanfareVolume", 1.0f, SEQ_FANFARE); - - ImGui::EndMenu(); - } - - ImGui::SetCursorPosY(0.0f); - - if (ImGui::BeginMenu("Controller")) + if (ImGui::BeginMenu("Settings")) { + if (ImGui::BeginMenu("Audio")) { + EnhancementSliderFloat("Master Volume: %d %%", "##Master_Vol", "gGameMasterVolume", 0.0f, 1.0f, "", 1.0f, true); + InsertPadding(); + BindAudioSlider("Main Music Volume: %d %%", "gMainMusicVolume", 1.0f, SEQ_BGM_MAIN); + InsertPadding(); + BindAudioSlider("Sub Music Volume: %d %%", "gSubMusicVolume", 1.0f, SEQ_BGM_SUB); + InsertPadding(); + BindAudioSlider("Sound Effects Volume: %d %%", "gSFXMusicVolume", 1.0f, SEQ_SFX); + InsertPadding(); + BindAudioSlider("Fanfare Volume: %d %%", "gFanfareVolume", 1.0f, SEQ_FANFARE); - #ifndef __SWITCH__ - EnhancementCheckbox("Use Controller Navigation", "gControlNav"); - Tooltip("Allows controller navigation of the menu bar\nD-pad to move between items, A to select, and X to grab focus on the menu bar"); - #endif - EnhancementCheckbox("Controller Configuration", "gControllerConfigurationEnabled"); - controller->Opened = CVar_GetS32("gControllerConfigurationEnabled", 0); - - ImGui::Separator(); - - // TODO mutual exclusions -- There should be some system to prevent conclifting enhancements from being selected - EnhancementCheckbox("D-pad Support on Pause and File Select", "gDpadPauseName"); - Tooltip("Enables Pause and File Select screen navigation with the D-pad\nIf used with D-pad as Equip Items, you must hold C-Up to equip instead of navigate"); - EnhancementCheckbox("D-pad Support in Ocarina and Text Choice", "gDpadOcarinaText"); - EnhancementCheckbox("D-pad Support for Browsing Shop Items", "gDpadShop"); - EnhancementCheckbox("D-pad as Equip Items", "gDpadEquips"); - Tooltip("Allows the D-pad to be used as extra C buttons"); - EnhancementCheckbox("Answer Navi Prompt with L Button", "gNaviOnL"); - Tooltip("Speak to Navi with L but enter first-person camera with C-Up"); - ImGui::Separator(); - - EnhancementCheckbox("Show Inputs", "gInputEnabled"); - Tooltip("Shows currently pressed inputs on the bottom right of the screen"); - - EnhancementSliderFloat("Input Scale: %.1f", "##Input", "gInputScale", 1.0f, 3.0f, "", 1.0f, false); - Tooltip("Sets the on screen size of the displayed inputs from the Show Inputs setting"); - - ImGui::EndMenu(); - } - - ImGui::SetCursorPosY(0.0f); - - if (ImGui::BeginMenu("Graphics")) - { -#ifndef __APPLE__ - EnhancementSliderFloat("Internal Resolution: %d %%", "##IMul", "gInternalResolution", 0.5f, 2.0f, "", 1.0f, true); - Tooltip("Multiplies your output resolution by the value inputted, as a more intensive but effective form of anti-aliasing"); - gfx_current_dimensions.internal_mul = CVar_GetFloat("gInternalResolution", 1); -#endif - EnhancementSliderInt("MSAA: %d", "##IMSAA", "gMSAAValue", 1, 8, "", 1, true); - Tooltip("Activates multi-sample anti-aliasing when above 1x up to 8x for 8 samples for every pixel"); - gfx_msaa_level = CVar_GetS32("gMSAAValue", 1); - - if (impl.backend == Backend::DX11) - { - const char* cvar = "gExtraLatencyThreshold"; - int val = CVar_GetS32(cvar, 80); - val = MAX(MIN(val, 360), 0); - int fps = val; - - if (fps == 0) - { - ImGui::Text("Jitter fix: Off"); - } - else - { - ImGui::Text("Jitter fix: >= %d FPS", fps); - } - - std::string MinusBTNELT = " - ##ExtraLatencyThreshold"; - std::string PlusBTNELT = " + ##ExtraLatencyThreshold"; - if (ImGui::Button(MinusBTNELT.c_str())) { - val--; - CVar_SetS32(cvar, val); - needs_save = true; - } - ImGui::SameLine(); - ImGui::SetCursorPosX(ImGui::GetCursorPosX() - 7.0f); - - if (ImGui::SliderInt("##ExtraLatencyThreshold", &val, 0, 360, "", ImGuiSliderFlags_AlwaysClamp)) - { - CVar_SetS32(cvar, val); - needs_save = true; - } - - Tooltip("When Interpolation FPS setting is at least this threshold, add one frame of input lag (e.g. 16.6 ms for 60 FPS) in order to avoid jitter. This setting allows the CPU to work on one frame while GPU works on the previous frame.\nThis setting should be used when your computer is too slow to do CPU + GPU work in time."); - - ImGui::SameLine(); - ImGui::SetCursorPosX(ImGui::GetCursorPosX() - 7.0f); - if (ImGui::Button(PlusBTNELT.c_str())) { - val++; - CVar_SetS32(cvar, val); - needs_save = true; - } + ImGui::EndMenu(); } + InsertPadding(); - ImGui::Text("Renderer API (Needs reload)"); - if (ImGui::BeginCombo("##RApi", backends[lastBackendID].second)) { - for (uint8_t i = 0; i < sizeof(backends) / sizeof(backends[0]); i++) { - if (ImGui::Selectable(backends[i].second, i == lastBackendID)) { - pConf->setString("Window.GfxBackend", backends[i].first); - lastBackendID = i; + if (ImGui::BeginMenu("Controller")) { + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2 (12.0f, 6.0f)); + ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0, 0)); + ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f); + ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.22f, 0.38f, 0.56f, 1.0f)); + if (ImGui::Button(GetWindowButtonText("Controller Configuration", CVar_GetS32("gControllerConfigurationEnabled", 0)).c_str())) + { + bool currentValue = CVar_GetS32("gControllerConfigurationEnabled", 0); + CVar_SetS32("gControllerConfigurationEnabled", !currentValue); + needs_save = true; + controller->Opened = CVar_GetS32("gControllerConfigurationEnabled", 0); + } + ImGui::PopStyleColor(1); + ImGui::PopStyleVar(3); + #ifndef __SWITCH__ + PaddedEnhancementCheckbox("Use Controller Navigation", "gControlNav", true, false); + Tooltip("Allows controller navigation of the menu bar\nD-pad to move between items, A to select, and X to grab focus on the menu bar"); + #endif + PaddedEnhancementCheckbox("Show Inputs", "gInputEnabled", true, false); + Tooltip("Shows currently pressed inputs on the bottom right of the screen"); + InsertPadding(); + ImGui::PushItemWidth(ImGui::GetWindowSize().x - 20.0f); + EnhancementSliderFloat("Input Scale: %.1f", "##Input", "gInputScale", 1.0f, 3.0f, "", 1.0f, false); + Tooltip("Sets the on screen size of the displayed inputs from the Show Inputs setting"); + ImGui::PopItemWidth(); + + ImGui::EndMenu(); + } + + InsertPadding(); + + if (ImGui::BeginMenu("Graphics")) { + #ifndef __APPLE__ + EnhancementSliderFloat("Internal Resolution: %d %%", "##IMul", "gInternalResolution", 0.5f, 2.0f, "", 1.0f, true, true); + Tooltip("Multiplies your output resolution by the value inputted, as a more intensive but effective form of anti-aliasing"); + gfx_current_dimensions.internal_mul = CVar_GetFloat("gInternalResolution", 1); + #endif + PaddedEnhancementSliderInt("MSAA: %d", "##IMSAA", "gMSAAValue", 1, 8, "", 1, false, true, false); + Tooltip("Activates multi-sample anti-aliasing when above 1x up to 8x for 8 samples for every pixel"); + gfx_msaa_level = CVar_GetS32("gMSAAValue", 1); + + if (impl.backend == Backend::DX11) + { + const char* cvar = "gExtraLatencyThreshold"; + int val = CVar_GetS32(cvar, 80); + val = MAX(MIN(val, 360), 0); + int fps = val; + + InsertPadding(); + + if (fps == 0) + { + ImGui::Text("Jitter fix: Off"); } + else + { + ImGui::Text("Jitter fix: >= %d FPS", fps); + } + + std::string MinusBTNELT = " - ##ExtraLatencyThreshold"; + std::string PlusBTNELT = " + ##ExtraLatencyThreshold"; + if (ImGui::Button(MinusBTNELT.c_str())) { + val--; + CVar_SetS32(cvar, val); + needs_save = true; + } + ImGui::SameLine(); + ImGui::SetCursorPosX(ImGui::GetCursorPosX() - 7.0f); + ImGui::PushItemWidth(ImGui::GetWindowSize().x - 79.0f); + if (ImGui::SliderInt("##ExtraLatencyThreshold", &val, 0, 360, "", ImGuiSliderFlags_AlwaysClamp)) + { + CVar_SetS32(cvar, val); + needs_save = true; + } + ImGui::PopItemWidth(); + Tooltip("When Interpolation FPS setting is at least this threshold, add one frame of input lag (e.g. 16.6 ms for 60 FPS) in order to avoid jitter. This setting allows the CPU to work on one frame while GPU works on the previous frame.\nThis setting should be used when your computer is too slow to do CPU + GPU work in time."); + + ImGui::SameLine(); + ImGui::SetCursorPosX(ImGui::GetCursorPosX() - 7.0f); + if (ImGui::Button(PlusBTNELT.c_str())) { + val++; + CVar_SetS32(cvar, val); + needs_save = true; + } + + InsertPadding(); } - ImGui::EndCombo(); + + ImGui::Text("Renderer API (Needs reload)"); + if (ImGui::BeginCombo("##RApi", backends[lastBackendID].second)) { + for (uint8_t i = 0; i < sizeof(backends) / sizeof(backends[0]); i++) { + if (ImGui::Selectable(backends[i].second, i == lastBackendID)) { + pConf->setString("Window.GfxBackend", backends[i].first); + lastBackendID = i; + } + } + ImGui::EndCombo(); + } + + EXPERIMENTAL(); + + ImGui::Text("Texture Filter (Needs reload)"); + EnhancementCombobox("gTextureFilter", filters, 3, 0); + + InsertPadding(); + + overlay->DrawSettings(); + + ImGui::EndMenu(); } - EXPERIMENTAL(); - ImGui::Text("Texture Filter (Needs reload)"); - EnhancementCombobox("gTextureFilter", filters, 3, 0); - overlay->DrawSettings(); - ImGui::EndMenu(); - } + InsertPadding(); - ImGui::SetCursorPosY(0.0f); - - if (ImGui::BeginMenu("Languages")) { - EnhancementRadioButton("English", "gLanguages", 0); - EnhancementRadioButton("German", "gLanguages", 1); - EnhancementRadioButton("French", "gLanguages", 2); + if (ImGui::BeginMenu("Languages")) { + EnhancementRadioButton("English", "gLanguages", 0); + EnhancementRadioButton("German", "gLanguages", 1); + EnhancementRadioButton("French", "gLanguages", 2); + ImGui::EndMenu(); + } ImGui::EndMenu(); } @@ -1017,7 +1044,7 @@ namespace SohImGui { { const char* enhancementPresets[4] = { "Default", "Vanilla Plus", "Enhanced", "Randomizer"}; - ImGui::Text("Enhancement Presets"); + PaddedText("Enhancement Presets", false, true); SohImGui::EnhancementCombobox("gSelectEnhancementPresets", enhancementPresets, 4, 0); Tooltip( "Default - Set all enhancements to their default values. The true vanilla SoH experience.\n" @@ -1028,91 +1055,121 @@ namespace SohImGui { "\n" "Randomizer - The \"Enhanced\" preset, plus any other enhancements that are recommended for playing Randomizer." ); + + InsertPadding(); + + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(6.0f, 4.0f)); if (ImGui::Button("Apply Preset")) { applyEnhancementPresets(); } - ImGui::Separator(); + ImGui::PopStyleVar(1); + + PaddedSeparator(); + + if (ImGui::BeginMenu("Controls")) { + // TODO mutual exclusions -- There should be some system to prevent conclifting enhancements from being selected + EnhancementCheckbox("D-pad Support on Pause and File Select", "gDpadPauseName"); + Tooltip("Enables Pause and File Select screen navigation with the D-pad\nIf used with D-pad as Equip Items, you must hold C-Up to equip instead of navigate"); + PaddedEnhancementCheckbox("D-pad Support in Ocarina and Text Choice", "gDpadOcarinaText", true, false); + PaddedEnhancementCheckbox("D-pad Support for Browsing Shop Items", "gDpadShop", true, false); + PaddedEnhancementCheckbox("D-pad as Equip Items", "gDpadEquips", true, false); + Tooltip("Allows the D-pad to be used as extra C buttons"); + PaddedEnhancementCheckbox("Allow the cursor to be on any slot", "gPauseAnyCursor", true, false); + Tooltip("Allows the cursor on the pause menu to be over any slot\nSimilar to Rando and Spaceworld 97"); + PaddedEnhancementCheckbox("Prevent Dropped Ocarina Inputs", "gDpadNoDropOcarinaInput", true, false); + Tooltip("Prevent dropping inputs when playing the ocarina quickly"); + PaddedEnhancementCheckbox("Answer Navi Prompt with L Button", "gNaviOnL", true, false); + Tooltip("Speak to Navi with L but enter first-person camera with C-Up"); + ImGui::EndMenu(); + } + + InsertPadding(); if (ImGui::BeginMenu("Gameplay")) { if (ImGui::BeginMenu("Time Savers")) { - EnhancementSliderInt("Text Speed: %dx", "##TEXTSPEED", "gTextSpeed", 1, 5, ""); - EnhancementSliderInt("King Zora Speed: %dx", "##MWEEPSPEED", "gMweepSpeed", 1, 5, ""); - EnhancementSliderInt("Biggoron Forge Time: %d days", "##FORGETIME", "gForgeTime", 0, 3, ""); + PaddedEnhancementSliderInt("Text Speed: %dx", "##TEXTSPEED", "gTextSpeed", 1, 5, "", 1, false, false, true); + PaddedEnhancementSliderInt("King Zora Speed: %dx", "##MWEEPSPEED", "gMweepSpeed", 1, 5, "", 1, false, false, true); + EnhancementSliderInt("Biggoron Forge Time: %d days", "##FORGETIME", "gForgeTime", 0, 3, "", 3); Tooltip("Allows you to change the number of days it takes for Biggoron to forge the Biggoron Sword"); - EnhancementSliderInt("Vine/Ladder Climb speed +%d", "##CLIMBSPEED", "gClimbSpeed", 0, 12, ""); - + PaddedEnhancementSliderInt("Vine/Ladder Climb speed +%d", "##CLIMBSPEED", "gClimbSpeed", 0, 12, "", 0); EnhancementCheckbox("Faster Block Push", "gFasterBlockPush"); - EnhancementCheckbox("Faster Heavy Block Lift", "gFasterHeavyBlockLift"); + PaddedEnhancementCheckbox("Faster Heavy Block Lift", "gFasterHeavyBlockLift", true, false); Tooltip("Speeds up lifting silver rocks and obelisks"); - EnhancementCheckbox("No Forced Navi", "gNoForcedNavi"); + PaddedEnhancementCheckbox("No Forced Navi", "gNoForcedNavi", true, false); Tooltip("Prevent forced Navi conversations"); - EnhancementCheckbox("No Skulltula Freeze", "gSkulltulaFreeze"); + PaddedEnhancementCheckbox("No Skulltula Freeze", "gSkulltulaFreeze", true, false); Tooltip("Stops the game from freezing the player when picking up Gold Skulltulas"); - EnhancementCheckbox("MM Bunny Hood", "gMMBunnyHood"); + PaddedEnhancementCheckbox("MM Bunny Hood", "gMMBunnyHood", true, false); Tooltip("Wearing the Bunny Hood grants a speed increase like in Majora's Mask"); - EnhancementCheckbox("Fast Chests", "gFastChests"); + PaddedEnhancementCheckbox("Fast Chests", "gFastChests", true, false); Tooltip("Kick open every chest"); - EnhancementCheckbox("Skip Pickup Messages", "gFastDrops"); + PaddedEnhancementCheckbox("Skip Pickup Messages", "gFastDrops", true, false); Tooltip("Skip pickup messages for new consumable items and bottle swipes"); - EnhancementCheckbox("Better Owl", "gBetterOwl"); + PaddedEnhancementCheckbox("Better Owl", "gBetterOwl", true, false); Tooltip("The default response to Kaepora Gaebora is always that you understood what he said"); - EnhancementCheckbox("Fast Ocarina Playback", "gFastOcarinaPlayback"); + PaddedEnhancementCheckbox("Fast Ocarina Playback", "gFastOcarinaPlayback", true, false); Tooltip("Skip the part where the Ocarina playback is called when you play a song"); - EnhancementCheckbox("Prevent Dropped Ocarina Inputs", "gDpadNoDropOcarinaInput"); - Tooltip("Prevent dropping inputs when playing the ocarina quickly"); - EnhancementCheckbox("Instant Boomerang Recall", "gFastBoomerang"); - Tooltip("Instantly return the boomerang to Link by pressing its item button while it's in the air"); - EnhancementCheckbox("Instant Putaway", "gInstantPutaway"); + PaddedEnhancementCheckbox("Instant Putaway", "gInstantPutaway", true, false); Tooltip("Allow Link to put items away without having to wait around"); - EnhancementCheckbox("Mask Select in Inventory", "gMaskSelect"); + PaddedEnhancementCheckbox("Instant Boomerang Recall", "gFastBoomerang", true, false); + Tooltip("Instantly return the boomerang to Link by pressing its item button while it's in the air"); + PaddedEnhancementCheckbox("Mask Select in Inventory", "gMaskSelect", true, false); Tooltip("After completing the mask trading sub-quest, press A and any direction on the mask slot to change masks"); - EnhancementCheckbox("Remember Save Location", "gRememberSaveLocation"); + PaddedEnhancementCheckbox("Remember Save Location", "gRememberSaveLocation", true, false); Tooltip("When loading a save, places Link at the last entrance he went through.\n" "This doesn't work if the save was made in a grotto."); ImGui::EndMenu(); } + InsertPadding(); + if (ImGui::BeginMenu("Difficulty Options")) { ImGui::Text("Damage Multiplier"); EnhancementCombobox("gDamageMul", powers, 9, 0); - Tooltip("Modifies all sources of damage not affected by other sliders\n\ -2x: Can survive all common attacks from the start of the game\n\ -4x: Dies in 1 hit to any substantial attack from the start of the game\n\ -8x: Can only survive trivial damage from the start of the game\n\ -16x: Can survive all common attacks with max health without double defense\n\ -32x: Can survive all common attacks with max health and double defense\n\ -64x: Can survive trivial damage with max health without double defense\n\ -128x: Can survive trivial damage with max health and double defense\n\ -256x: Cannot survive damage"); - ImGui::Text("Fall Damage Multiplier"); + Tooltip( + "Modifies all sources of damage not affected by other sliders\n\ + 2x: Can survive all common attacks from the start of the game\n\ + 4x: Dies in 1 hit to any substantial attack from the start of the game\n\ + 8x: Can only survive trivial damage from the start of the game\n\ + 16x: Can survive all common attacks with max health without double defense\n\ + 32x: Can survive all common attacks with max health and double defense\n\ + 64x: Can survive trivial damage with max health without double defense\n\ + 128x: Can survive trivial damage with max health and double defense\n\ + 256x: Cannot survive damage" + ); + PaddedText("Fall Damage Multiplier", true, false); EnhancementCombobox("gFallDamageMul", powers, 8, 0); - Tooltip("Modifies all fall damage\n\ -2x: Can survive all fall damage from the start of the game\n\ -4x: Can only survive short fall damage from the start of the game\n\ -8x: Cannot survive any fall damage from the start of the game\n\ -16x: Can survive all fall damage with max health without double defense\n\ -32x: Can survive all fall damage with max health and double defense\n\ -64x: Can survive short fall damage with double defense\n\ -128x: Cannot survive fall damage"); - ImGui::Text("Void Damage Multiplier"); + Tooltip( + "Modifies all fall damage\n\ + 2x: Can survive all fall damage from the start of the game\n\ + 4x: Can only survive short fall damage from the start of the game\n\ + 8x: Cannot survive any fall damage from the start of the game\n\ + 16x: Can survive all fall damage with max health without double defense\n\ + 32x: Can survive all fall damage with max health and double defense\n\ + 64x: Can survive short fall damage with double defense\n\ + 128x: Cannot survive fall damage" + ); + PaddedText("Void Damage Multiplier", true, false); EnhancementCombobox("gVoidDamageMul", powers, 7, 0); - Tooltip("Modifies damage taken after falling into a void\n\ -2x: Can survive void damage from the start of the game\n\ -4x: Cannot survive void damage from the start of the game\n\ -8x: Can survive void damage twice with max health without double defense\n\ -16x: Can survive void damage with max health without double defense\n\ -32x: Can survive void damage with max health and double defense\n\ -64x: Cannot survive void damage"); - - EnhancementCheckbox("No Random Drops", "gNoRandomDrops"); + Tooltip( + "Modifies damage taken after falling into a void\n\ + 2x: Can survive void damage from the start of the game\n\ + 4x: Cannot survive void damage from the start of the game\n\ + 8x: Can survive void damage twice with max health without double defense\n\ + 16x: Can survive void damage with max health without double defense\n\ + 32x: Can survive void damage with max health and double defense\n\ + 64x: Cannot survive void damage" + ); + PaddedEnhancementCheckbox("No Random Drops", "gNoRandomDrops", true, false); Tooltip("Disables random drops, except from the Goron Pot, Dampe, and bosses"); - EnhancementCheckbox("No Heart Drops", "gNoHeartDrops"); + PaddedEnhancementCheckbox("No Heart Drops", "gNoHeartDrops", true, false); Tooltip("Disables heart drops, but not heart placements, like from a Deku Scrub running off\nThis simulates Hero Mode from other games in the series"); - EnhancementCheckbox("Always Win Goron Pot", "gGoronPot"); + PaddedEnhancementCheckbox("Always Win Goron Pot", "gGoronPot", true, false); Tooltip("Always get the heart piece/purple rupee from the spinning Goron pot"); + InsertPadding(); if (ImGui::BeginMenu("Potion Values")) { @@ -1123,6 +1180,8 @@ namespace SohImGui { EnhancementCheckbox("Red Potion Percent Restore", "gRedPercentRestore"); Tooltip("Toggles from Red Potions restoring a fixed amount of health to a percent of the player's current max health"); + ImGui::Separator(); + EnhancementCheckbox("Change Green Potion Effect", "gGreenPotionEffect"); Tooltip("Enable the following changes to the amount of mana restored by Green Potions"); EnhancementSliderInt("Green Potion Mana: %d", "##GREENPOTIONMANA", "gGreenPotionMana", 1, 100, "", 0, true); @@ -1130,6 +1189,8 @@ namespace SohImGui { EnhancementCheckbox("Green Potion Percent Restore", "gGreenPercentRestore"); Tooltip("Toggles from Green Potions restoring a fixed amount of mana to a percent of the player's current max mana"); + ImGui::Separator(); + EnhancementCheckbox("Change Blue Potion Effects", "gBluePotionEffects"); Tooltip("Enable the following changes to the amount of health and mana restored by Blue Potions"); EnhancementSliderInt("Blue Potion Health: %d", "##BLUEPOTIONHEALTH", "gBluePotionHealth", 1, 100, "", 0, true); @@ -1137,11 +1198,15 @@ namespace SohImGui { EnhancementCheckbox("Blue Potion Health Percent Restore", "gBlueHealthPercentRestore"); Tooltip("Toggles from Blue Potions restoring a fixed amount of health to a percent of the player's current max health"); + ImGui::Separator(); + EnhancementSliderInt("Blue Potion Mana: %d", "##BLUEPOTIONMANA", "gBluePotionMana", 1, 100, "", 0, true); Tooltip("Changes the amount of mana restored by Blue Potions, base max mana is 48, max upgraded mana is 96"); EnhancementCheckbox("Blue Potion Mana Percent Restore", "gBlueManaPercentRestore"); Tooltip("Toggles from Blue Potions restoring a fixed amount of mana to a percent of the player's current max mana"); + ImGui::Separator(); + EnhancementCheckbox("Change Milk Effect", "gMilkEffect"); Tooltip("Enable the following changes to the amount of health restored by Milk"); EnhancementSliderInt("Milk Health: %d", "##MILKHEALTH", "gMilkHealth", 1, 100, "", 0, true); @@ -1149,12 +1214,16 @@ namespace SohImGui { EnhancementCheckbox("Milk Percent Restore", "gMilkPercentRestore"); Tooltip("Toggles from Milk restoring a fixed amount of health to a percent of the player's current max health"); + ImGui::Separator(); + EnhancementCheckbox("Separate Half Milk Effect", "gSeparateHalfMilkEffect"); Tooltip("Enable the following changes to the amount of health restored by Half Milk\nIf this is disabled, Half Milk will behave the same as Full Milk."); EnhancementSliderInt("Half Milk Health: %d", "##HALFMILKHEALTH", "gHalfMilkHealth", 1, 100, "", 0, true); Tooltip("Changes the amount of health restored by Half Milk"); EnhancementCheckbox("Half Milk Percent Restore", "gHalfMilkPercentRestore"); Tooltip("Toggles from Half Milk restoring a fixed amount of health to a percent of the player's current max health"); + + ImGui::Separator(); EnhancementCheckbox("Change Fairy Effect", "gFairyEffect"); Tooltip("Enable the following changes to the amount of health restored by Fairies"); @@ -1162,6 +1231,8 @@ namespace SohImGui { Tooltip("Changes the amount of health restored by Fairies"); EnhancementCheckbox("Fairy Percent Restore", "gFairyPercentRestore"); Tooltip("Toggles from Fairies restoring a fixed amount of health to a percent of the player's current max health"); + + ImGui::Separator(); EnhancementCheckbox("Change Fairy Revive Effect", "gFairyReviveEffect"); Tooltip("Enable the following changes to the amount of health restored by Fairy Revivals"); @@ -1173,14 +1244,16 @@ namespace SohImGui { ImGui::EndMenu(); } + InsertPadding(); + if (ImGui::BeginMenu("Fishing")) { EnhancementCheckbox("Instant Fishing", "gInstantFishing"); Tooltip("All fish will be caught instantly"); - EnhancementCheckbox("Guarantee Bite", "gGuaranteeFishingBite"); + PaddedEnhancementCheckbox("Guarantee Bite", "gGuaranteeFishingBite", true, false); Tooltip("When a line is stable, guarantee bite. Otherwise use default logic"); - EnhancementSliderInt("Child Minimum Weight: %d", "##cMinimumWeight", "gChildMinimumWeightFish", 6, 10, "", 10); + PaddedEnhancementSliderInt("Child Minimum Weight: %d", "##cMinimumWeight", "gChildMinimumWeightFish", 6, 10, "", 10, false, true, false); Tooltip("The minimum weight for the unique fishing reward as a child"); - EnhancementSliderInt("Adult Minimum Weight: %d", "##aMinimumWeight", "gAdultMinimumWeightFish", 8, 13, "", 13); + PaddedEnhancementSliderInt("Adult Minimum Weight: %d", "##aMinimumWeight", "gAdultMinimumWeightFish", 8, 13, "", 13, false, true, false); Tooltip("The minimum weight for the unique fishing reward as an adult"); ImGui::EndMenu(); } @@ -1188,37 +1261,41 @@ namespace SohImGui { ImGui::EndMenu(); } + InsertPadding(); + if (ImGui::BeginMenu("Reduced Clutter")) { EnhancementCheckbox("Mute Low HP Alarm", "gLowHpAlarm"); Tooltip("Disable the low HP beeping sound"); - EnhancementCheckbox("Minimal UI", "gMinimalUI"); + PaddedEnhancementCheckbox("Minimal UI", "gMinimalUI", true, false); Tooltip("Hides most of the UI when not needed\nNote: Doesn't activate until after loading a new scene"); - EnhancementCheckbox("Disable Navi Call Audio", "gDisableNaviCallAudio"); + PaddedEnhancementCheckbox("Disable Navi Call Audio", "gDisableNaviCallAudio", true, false); Tooltip("Disables the voice audio when Navi calls you"); ImGui::EndMenu(); } + InsertPadding(); + EnhancementCheckbox("Visual Stone of Agony", "gVisualAgony"); Tooltip("Displays an icon and plays a sound when Stone of Agony should be activated, for those without rumble"); - EnhancementCheckbox("Assignable Tunics and Boots", "gAssignableTunicsAndBoots"); + PaddedEnhancementCheckbox("Assignable Tunics and Boots", "gAssignableTunicsAndBoots", true, false); Tooltip("Allows equipping the tunic and boots to c-buttons"); - EnhancementCheckbox("Equipment Toggle", "gEquipmentCanBeRemoved"); + PaddedEnhancementCheckbox("Equipment Toggle", "gEquipmentCanBeRemoved", true, false); Tooltip("Allows equipment to be removed by toggling it off on\nthe equipment subscreen."); - EnhancementCheckbox("Link's Cow in Both Time Periods", "gCowOfTime"); + PaddedEnhancementCheckbox("Link's Cow in Both Time Periods", "gCowOfTime", true, false); Tooltip("Allows the Lon Lon Ranch obstacle course reward to be shared across time periods"); - EnhancementCheckbox("Enable visible guard vision", "gGuardVision"); - EnhancementCheckbox("Enable passage of time on file select", "gTimeFlowFileSelect"); - EnhancementCheckbox("Allow the cursor to be on any slot", "gPauseAnyCursor"); - Tooltip("Allows the cursor on the pause menu to be over any slot\nSimilar to Rando and Spaceworld 97"); - EnhancementCheckbox("Count Golden Skulltulas", "gInjectSkulltulaCount"); + PaddedEnhancementCheckbox("Enable visible guard vision", "gGuardVision", true, false); + PaddedEnhancementCheckbox("Enable passage of time on file select", "gTimeFlowFileSelect", true, false); + PaddedEnhancementCheckbox("Count Golden Skulltulas", "gInjectSkulltulaCount", true, false); Tooltip("Injects Golden Skulltula total count in pickup messages"); - EnhancementCheckbox("Pull grave during the day", "gDayGravePull"); + PaddedEnhancementCheckbox("Pull grave during the day", "gDayGravePull", true, false); Tooltip("Allows graves to be pulled when child during the day"); ImGui::EndMenu(); } + InsertPadding(); + if (ImGui::BeginMenu("Graphics")) { if (ImGui::BeginMenu("Animated Link in Pause Menu")) { @@ -1230,11 +1307,10 @@ namespace SohImGui { Tooltip("Allow you to rotate Link on the Equipment menu with the C-buttons\nUse C-Up or C-Down to reset Link's rotation"); EnhancementRadioButton("Rotate Link with Right Stick", "gPauseLiveLinkRotation", 3); Tooltip("Allow you to rotate Link on the Equipment menu with the Right Stick\nYou can zoom in by pointing up and reset Link's rotation by pointing down"); - if (CVar_GetS32("gPauseLiveLinkRotation", 0) != 0) { EnhancementSliderInt("Rotation Speed: %d", "##MinRotationSpeed", "gPauseLiveLinkRotationSpeed", 1, 20, ""); } - ImGui::Separator(); + PaddedSeparator(); ImGui::Text("Static loop"); EnhancementRadioButton("Disabled", "gPauseLiveLink", 0); EnhancementRadioButton("Idle (standing)", "gPauseLiveLink", 1); @@ -1251,7 +1327,7 @@ namespace SohImGui { EnhancementRadioButton("Hand on hip", "gPauseLiveLink", 12); EnhancementRadioButton("Spin attack charge", "gPauseLiveLink", 13); EnhancementRadioButton("Look at hand", "gPauseLiveLink", 14); - ImGui::Separator(); + PaddedSeparator(); ImGui::Text("Randomize"); EnhancementRadioButton("Random", "gPauseLiveLink", 15); Tooltip("Randomize the animation played each time you open the menu"); @@ -1265,70 +1341,91 @@ namespace SohImGui { ImGui::EndMenu(); } - EnhancementCheckbox("N64 Mode", "gN64Mode"); + PaddedEnhancementCheckbox("N64 Mode", "gN64Mode", true, false); Tooltip("Sets aspect ratio to 4:3 and lowers resolution to 240p, the N64's native resolution"); - EnhancementCheckbox("Enable 3D Dropped items/projectiles", "gNewDrops"); + PaddedEnhancementCheckbox("Enable 3D Dropped items/projectiles", "gNewDrops", true, false); Tooltip("Change most 2D items and projectiles on the overworld to their 3D versions"); - EnhancementCheckbox("Disable Black Bar Letterboxes", "gDisableBlackBars"); + PaddedEnhancementCheckbox("Disable Black Bar Letterboxes", "gDisableBlackBars", true, false); Tooltip("Disables Black Bar Letterboxes during cutscenes and Z-targeting\nNote: there may be minor visual glitches that were covered up by the black bars\nPlease disable this setting before reporting a bug"); - EnhancementCheckbox("Dynamic Wallet Icon", "gDynamicWalletIcon"); + PaddedEnhancementCheckbox("Dynamic Wallet Icon", "gDynamicWalletIcon", true, false); Tooltip("Changes the rupee in the wallet icon to match the wallet size you currently have"); - EnhancementCheckbox("Always show dungeon entrances", "gAlwaysShowDungeonMinimapIcon"); + PaddedEnhancementCheckbox("Always show dungeon entrances", "gAlwaysShowDungeonMinimapIcon", true, false); Tooltip("Always shows dungeon entrance icons on the minimap"); ImGui::EndMenu(); } + InsertPadding(); + if (ImGui::BeginMenu("Fixes")) { EnhancementCheckbox("Fix L&R Pause menu", "gUniformLR"); Tooltip("Makes the L and R buttons in the pause menu the same color"); - EnhancementCheckbox("Fix L&Z Page switch in Pause menu", "gNGCKaleidoSwitcher"); + PaddedEnhancementCheckbox("Fix L&Z Page switch in Pause menu", "gNGCKaleidoSwitcher", true, false); Tooltip("Makes L and R switch pages like on the GameCube\nZ opens the Debug Menu instead"); - EnhancementCheckbox("Fix Dungeon entrances", "gFixDungeonMinimapIcon"); + PaddedEnhancementCheckbox("Fix Dungeon entrances", "gFixDungeonMinimapIcon", true, false); Tooltip("Removes the dungeon entrance icon on the top-left corner of the screen when no dungeon is present on the current map"); - EnhancementCheckbox("Fix Two Handed idle animations", "gTwoHandedIdle"); + PaddedEnhancementCheckbox("Fix Two Handed idle animations", "gTwoHandedIdle", true, false); Tooltip("Re-enables the two-handed idle animation, a seemingly finished animation that was disabled on accident in the original game"); - EnhancementCheckbox("Fix the Gravedigging Tour Glitch", "gGravediggingTourFix"); + PaddedEnhancementCheckbox("Fix the Gravedigging Tour Glitch", "gGravediggingTourFix", true, false); Tooltip("Fixes a bug where the Gravedigging Tour Heart Piece disappears if the area reloads"); - EnhancementCheckbox("Fix Deku Nut upgrade", "gDekuNutUpgradeFix"); + PaddedEnhancementCheckbox("Fix Deku Nut upgrade", "gDekuNutUpgradeFix", true, false); Tooltip("Prevents the Forest Stage Deku Nut upgrade from becoming unobtainable after receiving the Poacher's Saw"); - EnhancementCheckbox("Fix Navi text HUD position", "gNaviTextFix"); + PaddedEnhancementCheckbox("Fix Navi text HUD position", "gNaviTextFix", true, false); Tooltip("Correctly centers the Navi text prompt on the HUD's C-Up button"); - EnhancementCheckbox("Fix Anubis fireballs", "gAnubisFix"); + PaddedEnhancementCheckbox("Fix Anubis fireballs", "gAnubisFix", true, false); Tooltip("Make Anubis fireballs do fire damage when reflected back at them with the Mirror Shield"); - EnhancementCheckbox("Fix Megaton Hammer crouch stab", "gCrouchStabHammerFix"); + PaddedEnhancementCheckbox("Fix Megaton Hammer crouch stab", "gCrouchStabHammerFix", true, false); Tooltip("Make the Megaton Hammer's crouch stab able to destroy rocks without first swinging it normally"); if (CVar_GetS32("gCrouchStabHammerFix", 0) == 0) { CVar_SetS32("gCrouchStabFix", 0); } else { - EnhancementCheckbox("Remove power crouch stab", "gCrouchStabFix"); + PaddedEnhancementCheckbox("Remove power crouch stab", "gCrouchStabFix", true, false); Tooltip("Make crouch stabbing always do the same damage as a regular slash"); } ImGui::EndMenu(); } + InsertPadding(); + if (ImGui::BeginMenu("Restoration")) { EnhancementCheckbox("Red Ganon blood", "gRedGanonBlood"); Tooltip("Restore the original red blood from NTSC 1.0/1.1. Disable for green blood"); - EnhancementCheckbox("Fish while hovering", "gHoverFishing"); + PaddedEnhancementCheckbox("Fish while hovering", "gHoverFishing", true, false); Tooltip("Restore a bug from NTSC 1.0 that allows casting the Fishing Rod while using the Hover Boots"); - EnhancementCheckbox("N64 Weird Frames", "gN64WeirdFrames"); + PaddedEnhancementCheckbox("N64 Weird Frames", "gN64WeirdFrames", true, false); Tooltip("Restores N64 Weird Frames allowing weirdshots to behave the same as N64"); - EnhancementCheckbox("Bombchus out of bounds", "gBombchusOOB"); + PaddedEnhancementCheckbox("Bombchus out of bounds", "gBombchusOOB", true, false); Tooltip("Allows bombchus to explode out of bounds\nSimilar to GameCube and Wii VC"); ImGui::EndMenu(); } - EnhancementCheckbox("Autosave", "gAutosave"); + PaddedEnhancementCheckbox("Autosave", "gAutosave", true, false); Tooltip("Automatically save the game every time a new area is entered or item is obtained\n" "To disable saving when obtaining an item, manually set gAutosaveAllItems and gAutosaveMajorItems to 0\n" "gAutosaveAllItems takes priority over gAutosaveMajorItems if both are set to 1\n" "gAutosaveMajorItems excludes rupees and health/magic/ammo refills (but includes bombchus)"); + InsertPadding(); + + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(12.0f, 6.0f)); + ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0, 0)); + ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f); + ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.22f, 0.38f, 0.56f, 1.0f)); + static ImVec2 buttonSize(200.0f, 0.0f); + if (ImGui::Button(GetWindowButtonText("Cosmetics Editor", CVar_GetS32("gCosmeticsEditorEnabled", 0)).c_str(), buttonSize)) + { + bool currentValue = CVar_GetS32("gCosmeticsEditorEnabled", 0); + CVar_SetS32("gCosmeticsEditorEnabled", !currentValue); + needs_save = true; + customWindows["Cosmetics Editor"].enabled = CVar_GetS32("gCosmeticsEditorEnabled", 0); + } + ImGui::PopStyleVar(3); + ImGui::PopStyleColor(1); + EXPERIMENTAL(); const char* fps_cvar = "gInterpolationFPS"; @@ -1363,7 +1460,7 @@ namespace SohImGui { } ImGui::SameLine(); ImGui::SetCursorPosX(ImGui::GetCursorPosX() - 7.0f); - + ImGui::PushItemWidth(ImGui::GetWindowSize().x - 79.0f); if (ImGui::SliderInt("##FPSInterpolation", &val, minFps, maxFps, "", ImGuiSliderFlags_AlwaysClamp)) { if (val > 360) @@ -1378,7 +1475,7 @@ namespace SohImGui { CVar_SetS32(fps_cvar, val); needs_save = true; } - + ImGui::PopItemWidth(); Tooltip("Interpolate extra frames to get smoother graphics\n" "Set to match your monitor's refresh rate, or a divisor of it\n" "A higher target FPS than your monitor's refresh rate will just waste resources, " @@ -1394,8 +1491,11 @@ namespace SohImGui { needs_save = true; } } + if (impl.backend == Backend::DX11) { + InsertPadding(); + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(6.0f, 4.0f)); if (ImGui::Button("Match Refresh Rate")) { int hz = roundf(gfx_get_detected_hz()); @@ -1405,24 +1505,26 @@ namespace SohImGui { needs_save = true; } } + ImGui::PopStyleVar(1); + InsertPadding(); } EnhancementCheckbox("Disable LOD", "gDisableLOD"); Tooltip("Turns off the Level of Detail setting, making models use their higher-poly variants at any distance"); - EnhancementCheckbox("Disable Draw Distance", "gDisableDrawDistance"); + PaddedEnhancementCheckbox("Disable Draw Distance", "gDisableDrawDistance", true, false); Tooltip("Turns off the objects draw distance, making objects being visible from a longer range"); if (CVar_GetS32("gDisableDrawDistance", 0) == 0) { CVar_SetS32("gDisableKokiriDrawDistance", 0); } else if (CVar_GetS32("gDisableDrawDistance", 0) == 1) { - EnhancementCheckbox("Kokiri Draw Distance", "gDisableKokiriDrawDistance"); + PaddedEnhancementCheckbox("Kokiri Draw Distance", "gDisableKokiriDrawDistance", true, false); Tooltip("The Kokiri are mystical beings that fade into view when approached\nEnabling this will remove their draw distance"); } - EnhancementCheckbox("Skip Text", "gSkipText"); + PaddedEnhancementCheckbox("Skip Text", "gSkipText", true, false); Tooltip("Holding down B skips text\nKnown to cause a cutscene softlock in Water Temple\nSoftlock can be fixed by pressing D-Right in Debug mode"); - - EnhancementCheckbox("Free Camera", "gFreeCamera"); + PaddedEnhancementCheckbox("Free Camera", "gFreeCamera", true, false); Tooltip("Enables 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."); #ifdef __SWITCH__ + InsertPadding(); int slot = CVar_GetS32("gSwitchPerfMode", (int)SwitchProfiles::STOCK); ImGui::Text("Switch performance mode"); if (ImGui::BeginCombo("##perf", SWITCH_CPU_PROFILES[slot])) { @@ -1448,37 +1550,36 @@ namespace SohImGui { { if (ImGui::BeginMenu("Infinite...")) { EnhancementCheckbox("Money", "gInfiniteMoney"); - EnhancementCheckbox("Health", "gInfiniteHealth"); - EnhancementCheckbox("Ammo", "gInfiniteAmmo"); - EnhancementCheckbox("Magic", "gInfiniteMagic"); - EnhancementCheckbox("Nayru's Love", "gInfiniteNayru"); - EnhancementCheckbox("Epona Boost", "gInfiniteEpona"); + PaddedEnhancementCheckbox("Health", "gInfiniteHealth", true, false); + PaddedEnhancementCheckbox("Ammo", "gInfiniteAmmo", true, false); + PaddedEnhancementCheckbox("Magic", "gInfiniteMagic", true, false); + PaddedEnhancementCheckbox("Nayru's Love", "gInfiniteNayru", true, false); + PaddedEnhancementCheckbox("Epona Boost", "gInfiniteEpona", true, false); ImGui::EndMenu(); } - EnhancementCheckbox("No Clip", "gNoClip"); + PaddedEnhancementCheckbox("No Clip", "gNoClip", true, false); Tooltip("Allows you to walk through walls"); - EnhancementCheckbox("Climb Everything", "gClimbEverything"); + PaddedEnhancementCheckbox("Climb Everything", "gClimbEverything", true, false); Tooltip("Makes every surface in the game climbable"); - EnhancementCheckbox("Moon Jump on L", "gMoonJumpOnL"); + PaddedEnhancementCheckbox("Moon Jump on L", "gMoonJumpOnL", true, false); Tooltip("Holding L makes you float into the air"); - EnhancementCheckbox("Super Tunic", "gSuperTunic"); + PaddedEnhancementCheckbox("Super Tunic", "gSuperTunic", true, false); Tooltip("Makes every tunic have the effects of every other tunic"); - EnhancementCheckbox("Easy ISG", "gEzISG"); + PaddedEnhancementCheckbox("Easy ISG", "gEzISG", true, false); Tooltip("Passive Infinite Sword Glitch\nIt makes your sword's swing effect and hitbox stay active indefinitely"); - EnhancementCheckbox("Unrestricted Items", "gNoRestrictItems"); + PaddedEnhancementCheckbox("Unrestricted Items", "gNoRestrictItems", true, false); Tooltip("Allows you to use any item at any location"); - EnhancementCheckbox("Freeze Time", "gFreezeTime"); + PaddedEnhancementCheckbox("Freeze Time", "gFreezeTime", true, false); Tooltip("Freezes the time of day"); - EnhancementCheckbox("Drops Don't Despawn", "gDropsDontDie"); + PaddedEnhancementCheckbox("Drops Don't Despawn", "gDropsDontDie", true, false); Tooltip("Drops from enemies, grass, etc. don't disappear after a set amount of time"); - EnhancementCheckbox("Fireproof Deku Shield", "gFireproofDekuShield"); + PaddedEnhancementCheckbox("Fireproof Deku Shield", "gFireproofDekuShield", true, false); Tooltip("Prevents the Deku Shield from burning on contact with fire"); - EnhancementCheckbox("Shield with Two-Handed Weapons", "gShieldTwoHanded"); + PaddedEnhancementCheckbox("Shield with Two-Handed Weapons", "gShieldTwoHanded", true, false); Tooltip("This allows you to put up your shield with any two-handed weapon in hand except for Deku Sticks"); - Tooltip("This allows you to put up your shield with any two-handed weapon in hand\nexcept for Deku Sticks"); - EnhancementCheckbox("Time Sync", "gTimeSync"); + PaddedEnhancementCheckbox("Time Sync", "gTimeSync", true, false); Tooltip("This syncs the ingame time with the real world time"); { @@ -1492,7 +1593,7 @@ namespace SohImGui { ImGui::PushStyleVar(ImGuiStyleVar_Alpha, ImGui::GetStyle().Alpha * 0.5f); } - EnhancementCheckbox("Enable Beta Quest", "gEnableBetaQuest"); + PaddedEnhancementCheckbox("Enable Beta Quest", "gEnableBetaQuest", true, false); Tooltip("Turns on OoT Beta Quest. *WARNING* This will reset your game."); betaQuestEnabled = CVar_GetS32("gEnableBetaQuest", 0); if (betaQuestEnabled) { @@ -1511,9 +1612,6 @@ namespace SohImGui { ImGui::SliderInt("##BetaQuest", &betaQuestWorld, 0, 8, "", ImGuiSliderFlags_AlwaysClamp); Tooltip("Set the Beta Quest world to explore. *WARNING* Changing this will reset your game.\nCtrl+Click to type in a value."); - ImGui::Text("After Slider Beta Quest World: %d", betaQuestWorld); - - ImGui::SameLine(); ImGui::SetCursorPosX(ImGui::GetCursorPosX() - 7.0f); if (ImGui::Button(" + ##BetaQuest")) { @@ -1526,8 +1624,6 @@ namespace SohImGui { else if (betaQuestWorld < 0) { betaQuestWorld = 0; } - - ImGui::Text("After Clamp Beta Quest World: %d", betaQuestWorld); } else { lastBetaQuestWorld = betaQuestWorld = 0xFFEF; @@ -1549,7 +1645,7 @@ namespace SohImGui { if (!isBetaQuestEnabled) { ImGui::PopItemFlag(); - ImGui::PopStyleVar(); + ImGui::PopStyleVar(1); } } @@ -1562,9 +1658,9 @@ namespace SohImGui { { EnhancementCheckbox("OoT Debug Mode", "gDebugEnabled"); Tooltip("Enables Debug Mode, allowing you to select maps with L + R + Z, noclip with L + D-pad Right, and open the debug menu with L on the pause screen"); - EnhancementCheckbox("OoT Skulltula Debug", "gSkulltulaDebugEnabled"); + PaddedEnhancementCheckbox("OoT Skulltula Debug", "gSkulltulaDebugEnabled", true, false); Tooltip("Enables Skulltula Debug, when moving the cursor in the menu above various map icons (boss key, compass, map screen locations, etc) will set the GS bits in that area.\nUSE WITH CAUTION AS IT DOES NOT UPDATE THE GS COUNT."); - EnhancementCheckbox("Fast File Select", "gSkipLogoTitle"); + PaddedEnhancementCheckbox("Fast File Select", "gSkipLogoTitle", true, false); Tooltip("Load the game to the selected menu or file\n\"Zelda Map Select\" require debug mode else you will fallback to File choose menu\nUsing a file number that don't have save will create a save file only if you toggle on \"Create a new save if none ?\" else it will bring you to the File choose menu"); if (CVar_GetS32("gSkipLogoTitle", 0)) { const char* FastFileSelect[5] = { @@ -1576,34 +1672,93 @@ namespace SohImGui { }; ImGui::Text("Loading :"); EnhancementCombobox("gSaveFileID", FastFileSelect, 5, 0); - EnhancementCheckbox("Create a new save if none", "gCreateNewSave"); + PaddedEnhancementCheckbox("Create a new save if none", "gCreateNewSave", true, false); Tooltip("Enable the creation of a new save file if none exist in the File number selected\nNo file name will be assigned please do in Save editor once you see the first text else your save file name will be named \"00000000\"\nIf disabled you will fall back in File select menu"); }; - ImGui::Separator(); - EnhancementCheckbox("Stats", "gStatsEnabled"); + PaddedSeparator(); + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(12.0f, 6.0f)); + ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0,0)); + ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f); + ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.22f, 0.38f, 0.56f, 1.0f)); + static ImVec2 buttonSize(160.0f, 0.0f); + if (ImGui::Button(GetWindowButtonText("Stats", CVar_GetS32("gStatsEnabled", 0)).c_str(), buttonSize)) + { + bool currentValue = CVar_GetS32("gStatsEnabled", 0); + CVar_SetS32("gStatsEnabled", !currentValue); + statsWindowOpen = true; + needs_save = true; + } Tooltip("Shows the stats window, with your FPS and frametimes, and the OS you're playing on"); - EnhancementCheckbox("Console", "gConsoleEnabled"); + InsertPadding(); + if (ImGui::Button(GetWindowButtonText("Console", CVar_GetS32("gConsoleEnabled", 0)).c_str(), buttonSize)) + { + bool currentValue = CVar_GetS32("gConsoleEnabled", 0); + CVar_SetS32("gConsoleEnabled", !currentValue); + needs_save = true; + console->opened = CVar_GetS32("gConsoleEnabled", 0); + } Tooltip("Enables the console window, allowing you to input commands, type help for some examples"); - console->opened = CVar_GetS32("gConsoleEnabled", 0); + InsertPadding(); + if (ImGui::Button(GetWindowButtonText("Save Editor", CVar_GetS32("gSaveEditorEnabled", 0)).c_str(), buttonSize)) + { + bool currentValue = CVar_GetS32("gSaveEditorEnabled", 0); + CVar_SetS32("gSaveEditorEnabled", !currentValue); + needs_save = true; + customWindows["Save Editor"].enabled = CVar_GetS32("gSaveEditorEnabled", 0); + } + InsertPadding(); + if (ImGui::Button(GetWindowButtonText("Collision Viewer", CVar_GetS32("gCollisionViewerEnabled", 0)).c_str(), buttonSize)) + { + bool currentValue = CVar_GetS32("gCollisionViewerEnabled", 0); + CVar_SetS32("gCollisionViewerEnabled", !currentValue); + needs_save = true; + customWindows["Collision Viewer"].enabled = CVar_GetS32("gCollisionViewerEnabled", 0); + } + InsertPadding(); + if (ImGui::Button(GetWindowButtonText("Actor Viewer", CVar_GetS32("gActorViewerEnabled", 0)).c_str(), buttonSize)) + { + bool currentValue = CVar_GetS32("gActorViewerEnabled", 0); + CVar_SetS32("gActorViewerEnabled", !currentValue); + needs_save = true; + customWindows["Actor Viewer"].enabled = CVar_GetS32("gActorViewerEnabled", 0); + } + ImGui::PopStyleVar(3); + ImGui::PopStyleColor(1); ImGui::EndMenu(); } - for (const auto& category : windowCategories) { - ImGui::SetCursorPosY(0.0f); - if (ImGui::BeginMenu(category.first.c_str())) { - for (const std::string& name : category.second) { - std::string varName(name); - varName.erase(std::remove_if(varName.begin(), varName.end(), [](unsigned char x) { return std::isspace(x); }), varName.end()); - std::string toggleName = "g" + varName + "Enabled"; + ImGui::SetCursorPosY(0.0f); - EnhancementCheckbox(name.c_str(), toggleName.c_str()); - customWindows[name].enabled = CVar_GetS32(toggleName.c_str(), 0); - } - ImGui::EndMenu(); + if (ImGui::BeginMenu("Randomizer")) + { + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(12.0f, 6.0f)); + ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0, 0)); + ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f); + ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.22f, 0.38f, 0.56f, 1.0f)); + static ImVec2 buttonSize(200.0f, 0.0f); + if (ImGui::Button(GetWindowButtonText("Randomizer Settings", CVar_GetS32("gRandomizerSettingsEnabled", 0)).c_str(), buttonSize)) + { + bool currentValue = CVar_GetS32("gRandomizerSettingsEnabled", 0); + CVar_SetS32("gRandomizerSettingsEnabled", !currentValue); + needs_save = true; + customWindows["Randomizer Settings"].enabled = CVar_GetS32("gRandomizerSettingsEnabled", 0); } + InsertPadding(); + if (ImGui::Button(GetWindowButtonText("Item Tracker", CVar_GetS32("gItemTrackerEnabled", 0)).c_str(), buttonSize)) + { + bool currentValue = CVar_GetS32("gItemTrackerEnabled", 0); + CVar_SetS32("gItemTrackerEnabled", !currentValue); + needs_save = true; + customWindows["Item Tracker"].enabled = CVar_GetS32("gItemTrackerEnabled", 0); + } + ImGui::PopStyleVar(3); + ImGui::PopStyleColor(1); + + ImGui::EndMenu(); } + ImGui::PopStyleVar(1); ImGui::EndMenuBar(); } @@ -1619,10 +1774,14 @@ namespace SohImGui { ImGui::End(); ImGui::PopStyleColor(); } + if (CVar_GetS32("gStatsEnabled", 0)) { + if (!statsWindowOpen) { + CVar_SetS32("gStatsEnabled", 0); + } const float framerate = ImGui::GetIO().Framerate; ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0, 0, 0, 0)); - ImGui::Begin("Debug Stats", nullptr, ImGuiWindowFlags_NoFocusOnAppearing); + ImGui::Begin("Debug Stats", &statsWindowOpen, ImGuiWindowFlags_NoFocusOnAppearing); #ifdef _WIN32 ImGui::Text("Platform: Windows"); @@ -2232,7 +2391,7 @@ namespace SohImGui { #endif ImGui::GetCurrentWindow()->Size.x += frameHeight; - ImGui::Dummy(ImVec2(0.0f, 0.0f)); + InsertPadding(); ImGui::EndGroup(); } @@ -2268,4 +2427,56 @@ namespace SohImGui { std::string BreakTooltip(const std::string& text, int lineLength) { return BreakTooltip(text.c_str(), lineLength); } + + void InsertPadding(float extraVerticalPadding) { + ImGui::Dummy(ImVec2(0.0f, extraVerticalPadding)); + } + + void PaddedSeparator(bool padTop, bool padBottom, float extraVerticalTopPadding, float extraVerticalBottomPadding) { + if (padTop) { + ImGui::Dummy(ImVec2(0.0f, extraVerticalTopPadding)); + } + ImGui::Separator(); + if (padBottom) { + ImGui::Dummy(ImVec2(0.0f, extraVerticalBottomPadding)); + } + } + + void PaddedEnhancementSliderInt(const char* text, const char* id, const char* cvarName, int min, int max, const char* format, int defaultValue, bool PlusMinusButton, bool padTop, bool padBottom) { + if (padTop) { + ImGui::Dummy(ImVec2(0.0f, 0.0f)); + } + EnhancementSliderInt(text, id, cvarName, min, max, format, defaultValue, PlusMinusButton); + if (padBottom) { + ImGui::Dummy(ImVec2(0.0f, 0.0f)); + } + } + + void PaddedEnhancementCheckbox(const char* text, const char* cvarName, bool padTop, bool padBottom) { + if (padTop) { + ImGui::Dummy(ImVec2(0.0f, 0.0f)); + } + EnhancementCheckbox(text, cvarName); + if (padBottom) { + ImGui::Dummy(ImVec2(0.0f, 0.0f)); + } + } + + void PaddedText(const char* text, bool padTop, bool padBottom) { + if (padTop) { + ImGui::Dummy(ImVec2(0.0f, 0.0f)); + } + ImGui::Text("%s", text); + if (padBottom) { + ImGui::Dummy(ImVec2(0.0f, 0.0f)); + } + } + + std::string GetWindowButtonText(const char* text, bool menuOpen) { + char buttonText[100] = ""; + if(menuOpen) { strcat(buttonText,"> "); } + strcat(buttonText, text); + if (!menuOpen) { strcat(buttonText, " "); } + return buttonText; + } } diff --git a/libultraship/libultraship/ImGuiImpl.h b/libultraship/libultraship/ImGuiImpl.h index 5358e2028..fd0aced6a 100644 --- a/libultraship/libultraship/ImGuiImpl.h +++ b/libultraship/libultraship/ImGuiImpl.h @@ -112,6 +112,12 @@ namespace SohImGui { void EndGroupPanel(float minHeight = 0.0f); std::string BreakTooltip(const char* text, int lineLength = 60); std::string BreakTooltip(const std::string& text, int lineLength = 60); + void InsertPadding(float extraVerticalPadding = 0.0f); + void PaddedSeparator(bool padTop = true, bool padBottom = true, float extraVerticalTopPadding = 0.0f, float extraVerticalBottomPadding = 0.0f); + void PaddedEnhancementSliderInt(const char* text, const char* id, const char* cvarName, int min, int max, const char* format, int defaultValue = 0, bool PlusMinusButton = false, bool padTop = true, bool padBottom = true); + void PaddedEnhancementCheckbox(const char* text, const char* cvarName, bool padTop = true, bool padBottom = true); + void PaddedText(const char* text, bool padTop = true, bool padBottom = true); + std::string GetWindowButtonText(const char* text, bool menuOpen); } -#endif \ No newline at end of file +#endif diff --git a/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp b/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp index c565ce52b..52e81ea24 100644 --- a/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp +++ b/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp @@ -1124,7 +1124,7 @@ void DrawCosmeticsEditor(bool& open) { return; } ImGui::SetNextWindowSize(ImVec2(465, 430), ImGuiCond_FirstUseEver); - if (!ImGui::Begin("Cosmetics Editor", &open, ImGuiWindowFlags_NoFocusOnAppearing)) { + if (!ImGui::Begin("Cosmetics Editor", &open)) { ImGui::End(); return; } @@ -1162,7 +1162,7 @@ void InitCosmeticsEditor() { //This allow to hide a window without disturbing the player nor adding things in menu //LoadRainbowColor() will this way run in background once it's window is activated //ImGui::SetNextItemWidth(0.0f); - SohImGui::AddWindow("Cosmetics", "Rainbowfunction", LoadRainbowColor, true, true); + SohImGui::AddWindow("Enhancements", "Rainbowfunction", LoadRainbowColor, true, true); //Draw the bar in the menu. - SohImGui::AddWindow("Cosmetics", "Cosmetics Editor", DrawCosmeticsEditor); -} \ No newline at end of file + SohImGui::AddWindow("Enhancements", "Cosmetics Editor", DrawCosmeticsEditor); +} From 1f351418e17e14cf62af009fbaa3f2553d6d50b1 Mon Sep 17 00:00:00 2001 From: Kenix3 Date: Mon, 8 Aug 2022 22:20:43 -0400 Subject: [PATCH 59/71] Removes a couple printf in favour of SPDLOG calls. --- libultraship/libultraship/Cutscene.cpp | 4 +--- libultraship/libultraship/Resource.cpp | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/libultraship/libultraship/Cutscene.cpp b/libultraship/libultraship/Cutscene.cpp index a1e2421eb..5ccadbb7b 100644 --- a/libultraship/libultraship/Cutscene.cpp +++ b/libultraship/libultraship/Cutscene.cpp @@ -511,9 +511,7 @@ void Ship::CutsceneV0::ParseFileBinary(BinaryReader* reader, Resource* res) return; } default: -#ifdef _DEBUG - printf("CutsceneV0: Unknown command %x\n", commandId); -#endif + SPDLOG_TRACE("CutsceneV0: Unknown command {}\n", commandId); // error? break; } diff --git a/libultraship/libultraship/Resource.cpp b/libultraship/libultraship/Resource.cpp index 3de83ed3f..d3af20667 100644 --- a/libultraship/libultraship/Resource.cpp +++ b/libultraship/libultraship/Resource.cpp @@ -56,9 +56,7 @@ namespace Ship patches.clear(); -#if _DEBUG if (file != nullptr) - printf("Deconstructor called on file %s\n", file->path.c_str()); -#endif + SPDLOG_TRACE("Deconstructor called on file %s\n", file->path.c_str()); } } \ No newline at end of file From c7ccd6dbff2ebe07ff046ad74aefded6523bb14f Mon Sep 17 00:00:00 2001 From: Kenix3 Date: Tue, 9 Aug 2022 21:47:39 -0400 Subject: [PATCH 60/71] LUS Cleanup: Strips out the logging system created for the console Properly routes SPDLog to the console. Creates an API to be able to send command responses back to the console. Cleans up the console UI, hiding options when not needed. Removes stdout console sink for Windows. --- libultraship/libultraship/Console.cpp | 158 +++++++++++------- libultraship/libultraship/Console.h | 44 ++--- libultraship/libultraship/Cutscene.cpp | 1 + libultraship/libultraship/GameOverlay.cpp | 11 +- libultraship/libultraship/GlobalCtx2.cpp | 14 +- .../include/spdlog/sinks/sohconsole_sink.h | 37 +--- libultraship/libultraship/Resource.cpp | 1 + soh/soh/Enhancements/debugconsole.cpp | 85 +++++----- .../randomizer/3drando/entrance.cpp | 40 ++--- .../Enhancements/randomizer/3drando/fill.cpp | 28 ++-- .../Enhancements/randomizer/3drando/hints.cpp | 116 ++++++------- .../randomizer/3drando/item_location.cpp | 38 ++--- .../randomizer/3drando/item_pool.cpp | 2 +- .../Enhancements/randomizer/3drando/menu.cpp | 16 +- 14 files changed, 309 insertions(+), 282 deletions(-) diff --git a/libultraship/libultraship/Console.cpp b/libultraship/libultraship/Console.cpp index 83737e738..6990d4343 100644 --- a/libultraship/libultraship/Console.cpp +++ b/libultraship/libultraship/Console.cpp @@ -15,9 +15,9 @@ namespace Ship { std::map BindingToggle; static bool HelpCommand(const std::vector&) { - INFO("SoH Commands:"); + SohImGui::console->SendInfoMessage("SoH Commands:"); for (const auto& cmd : SohImGui::console->Commands) { - INFO("%s", (" - " + cmd.first).c_str()); + SohImGui::console->SendInfoMessage(" - " + cmd.first); } return CMD_SUCCESS; } @@ -45,7 +45,7 @@ namespace Ship { std::ostringstream imploded; std::copy(args.begin() + 2, args.end(), std::ostream_iterator(imploded, delim)); Bindings[k] = imploded.str(); - INFO("Binding '%s' to %s", args[1].c_str(), Bindings[k].c_str()); + SohImGui::console->SendInfoMessage("Binding '%s' to %s", args[1], Bindings[k]); break; } } @@ -61,7 +61,7 @@ namespace Ship { if (toLowerCase(args[1]) == toLowerCase(key)) { BindingToggle[k] = args[2]; - INFO("Binding toggle '%s' to %s", args[1].c_str(), BindingToggle[k].c_str()); + SohImGui::console->SendInfoMessage("Binding toggle '%s' to %s", args[1].c_str(), BindingToggle[k].c_str()); break; } } @@ -159,29 +159,39 @@ namespace Ship { // Renders top bar filters if (ImGui::Button("Clear")) this->Log[this->selected_channel].clear(); - ImGui::SameLine(); - ImGui::SetNextItemWidth(150); - if (ImGui::BeginCombo("##channel", this->selected_channel.c_str())) { - for (const auto& channel : log_channels) { - const bool is_selected = (channel == std::string(this->selected_channel)); - if (ImGui::Selectable(channel.c_str(), is_selected)) - this->selected_channel = channel; - if (is_selected) ImGui::SetItemDefaultFocus(); + + if (CVar_GetS32("gSinkEnabled", 0)) { + ImGui::SameLine(); + ImGui::SetNextItemWidth(150); + if (ImGui::BeginCombo("##channel", this->selected_channel.c_str())) { + for (const auto& channel : log_channels) { + const bool is_selected = (channel == std::string(this->selected_channel)); + if (ImGui::Selectable(channel.c_str(), is_selected)) + this->selected_channel = channel; + if (is_selected) ImGui::SetItemDefaultFocus(); + } + ImGui::EndCombo(); } - ImGui::EndCombo(); + } else { + this->selected_channel = "Console"; } ImGui::SameLine(); ImGui::SetNextItemWidth(150); - if (ImGui::BeginCombo("##level", this->level_filter.c_str())) { - for (const auto& filter : priority_filters) { - const bool is_selected = (filter == std::string(this->level_filter)); - if (ImGui::Selectable(filter.c_str(), is_selected)) - { - this->level_filter = filter; - if (is_selected) ImGui::SetItemDefaultFocus(); + + if (this->selected_channel != "Console") { + if (ImGui::BeginCombo("##level", spdlog::level::to_string_view(this->level_filter).data())) { + for (const auto& priority_filter : priority_filters) { + const bool is_selected = priority_filter == this->level_filter; + if (ImGui::Selectable(spdlog::level::to_string_view(priority_filter).data(), is_selected)) + { + this->level_filter = priority_filter; + if (is_selected) ImGui::SetItemDefaultFocus(); + } } + ImGui::EndCombo(); } - ImGui::EndCombo(); + } else { + this->level_filter = spdlog::level::trace; } ImGui::SameLine(); ImGui::PushItemWidth(-1); @@ -203,7 +213,7 @@ namespace Ship { for (int i = 0; i < static_cast(channel.size()); i++) { ConsoleLine line = channel[i]; if (!this->filter.empty() && line.text.find(this->filter) == std::string::npos) continue; - if (this->level_filter != NULLSTR && line.priority != (std::find(priority_filters.begin(), priority_filters.end(), this->level_filter) - priority_filters.begin()) - 1) continue; + if (this->level_filter > line.priority) continue; std::string id = line.text + "##" + std::to_string(i); ImGui::TableNextRow(); ImGui::TableSetColumnIndex(0); @@ -226,54 +236,56 @@ namespace Ship { ImGui::SetScrollHereY(1.0f); ImGui::EndChild(); - // Renders input textfield - constexpr ImGuiInputTextFlags flags = ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_CallbackEdit | - ImGuiInputTextFlags_CallbackCompletion | ImGuiInputTextFlags_CallbackHistory; - ImGui::PushItemWidth(-53); - if (ImGui::InputTextWithHint("##CMDInput", ">", this->InputBuffer, MAX_BUFFER_SIZE, flags, &Console::CallbackStub, this)) { - input_focus = true; - if (this->InputBuffer[0] != '\0' && this->InputBuffer[0] != ' ') - this->Dispatch(std::string(this->InputBuffer)); - memset(this->InputBuffer, 0, MAX_BUFFER_SIZE); - } - - if (this->CMDHint != NULLSTR) { - if (ImGui::IsItemFocused()) { - ImGui::SetNextWindowPos(ImVec2(pos.x, pos.y + size.y)); - ImGui::SameLine(); - ImGui::BeginTooltip(); - ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f); - ImGui::TextUnformatted(this->CMDHint.c_str()); - ImGui::PopTextWrapPos(); - ImGui::EndTooltip(); + if (this->selected_channel == "Console") { + // Renders input textfield + constexpr ImGuiInputTextFlags flags = ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_CallbackEdit | + ImGuiInputTextFlags_CallbackCompletion | ImGuiInputTextFlags_CallbackHistory; + ImGui::PushItemWidth(-53); + if (ImGui::InputTextWithHint("##CMDInput", ">", this->InputBuffer, MAX_BUFFER_SIZE, flags, &Console::CallbackStub, this)) { + input_focus = true; + if (this->InputBuffer[0] != '\0' && this->InputBuffer[0] != ' ') + this->Dispatch(std::string(this->InputBuffer)); + memset(this->InputBuffer, 0, MAX_BUFFER_SIZE); } - } - ImGui::SameLine(); - ImGui::SetCursorPosX(ImGui::GetCursorPosX() + ImGui::GetContentRegionAvail().x - 50); - if (ImGui::Button("Submit") && !input_focus && this->InputBuffer[0] != '\0' && this->InputBuffer[0] != ' ') { - this->Dispatch(std::string(this->InputBuffer)); - memset(this->InputBuffer, 0, MAX_BUFFER_SIZE); - } + if (this->CMDHint != NULLSTR) { + if (ImGui::IsItemFocused()) { + ImGui::SetNextWindowPos(ImVec2(pos.x, pos.y + size.y)); + ImGui::SameLine(); + ImGui::BeginTooltip(); + ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f); + ImGui::TextUnformatted(this->CMDHint.c_str()); + ImGui::PopTextWrapPos(); + ImGui::EndTooltip(); + } + } - ImGui::SetItemDefaultFocus(); - if (input_focus) ImGui::SetKeyboardFocusHere(-1); - ImGui::PopItemWidth(); + ImGui::SameLine(); + ImGui::SetCursorPosX(ImGui::GetCursorPosX() + ImGui::GetContentRegionAvail().x - 50); + if (ImGui::Button("Submit") && !input_focus && this->InputBuffer[0] != '\0' && this->InputBuffer[0] != ' ') { + this->Dispatch(std::string(this->InputBuffer)); + memset(this->InputBuffer, 0, MAX_BUFFER_SIZE); + } + + ImGui::SetItemDefaultFocus(); + if (input_focus) ImGui::SetKeyboardFocusHere(-1); + ImGui::PopItemWidth(); + } ImGui::End(); } void Console::Dispatch(const std::string& line) { this->CMDHint = NULLSTR; this->History.push_back(line); - this->Log[this->selected_channel].push_back({ "> " + line }); + SendInfoMessage("> " + line); const std::vector cmd_args = StringHelper::Split(line, " "); if (this->Commands.contains(cmd_args[0])) { const CommandEntry entry = this->Commands[cmd_args[0]]; if (!entry.handler(cmd_args) && !entry.arguments.empty()) - this->Log[this->selected_channel].push_back({ "[SOH] Usage: " + cmd_args[0] + " " + BuildUsage(entry), ERROR_LVL }); + SendErrorMessage("[SOH] Usage: " + cmd_args[0] + " " + BuildUsage(entry)); return; } - this->Log[this->selected_channel].push_back({ "[SOH] Command not found", ERROR_LVL }); + SendErrorMessage("[SOH] Command not found"); } int Console::CallbackStub(ImGuiInputTextCallbackData* data) { @@ -325,13 +337,39 @@ namespace Ship { return 0; } - void Console::Append(const std::string& channel, Priority priority, const char* fmt, ...) { - char buf[1024]; - va_list args; - va_start(args, fmt); + void Console::Append(const std::string& channel, spdlog::level::level_enum priority, const char* fmt, va_list args) { + char buf[2048]; vsnprintf(buf, IM_ARRAYSIZE(buf), fmt, args); buf[IM_ARRAYSIZE(buf) - 1] = 0; - va_end(args); this->Log[channel].push_back({ std::string(buf), priority }); } + + void Console::Append(const std::string& channel, spdlog::level::level_enum priority, const char* fmt, ...) { + va_list args; + va_start(args, fmt); + Append(channel, priority, fmt, args); + va_end(args); + } + + void Console::SendInfoMessage(const char* fmt, ...) { + va_list args; + va_start(args, fmt); + Append("Console", spdlog::level::info, fmt, args); + va_end(args); + } + + void Console::SendErrorMessage(const char* fmt, ...) { + va_list args; + va_start(args, fmt); + Append("Console", spdlog::level::err, fmt, args); + va_end(args); + } + + void Console::SendInfoMessage(const std::string& str) { + Append("Console", spdlog::level::info, str.c_str()); + } + + void Console::SendErrorMessage(const std::string& str) { + Append("Console", spdlog::level::err, str.c_str()); + } } \ No newline at end of file diff --git a/libultraship/libultraship/Console.h b/libultraship/libultraship/Console.h index a174450e1..4a99e5b5b 100644 --- a/libultraship/libultraship/Console.h +++ b/libultraship/libultraship/Console.h @@ -6,12 +6,11 @@ #include #include "Lib/ImGui/imgui.h" +#define NOGDI +#define WIN32_LEAN_AND_MEAN +#include "spdlog/spdlog.h" namespace Ship { - #define LOG(msg, ...) SohImGui::console->Append("Main", Ship::Priority::LOG_LVL, msg, ##__VA_ARGS__) - #define INFO(msg, ...) SohImGui::console->Append("Main", Ship::Priority::INFO_LVL, msg, ##__VA_ARGS__) - #define WARNING(msg, ...) SohImGui::console->Append("Main", Ship::Priority::WARNING_LVL, msg, ##__VA_ARGS__) - #define ERROR(msg, ...) SohImGui::console->Append("Main", Ship::Priority::ERROR_LVL, msg, ##__VA_ARGS__) #define CMD_SUCCESS true #define CMD_FAILED false #define MAX_BUFFER_SIZE 255 @@ -19,13 +18,6 @@ namespace Ship { typedef std::function args)> CommandHandler; - enum Priority { - INFO_LVL, - LOG_LVL, - WARNING_LVL, - ERROR_LVL - }; - enum class ArgumentType { TEXT, NUMBER, PLAYER_POS, PLAYER_ROT }; @@ -44,7 +36,7 @@ namespace Ship { struct ConsoleLine { std::string text; - Priority priority = Priority::INFO_LVL; + spdlog::level::level_enum priority = spdlog::level::info; std::string channel = "Main"; }; @@ -52,15 +44,21 @@ namespace Ship { int selectedId = -1; std::vector selectedEntries; std::string filter; - std::string level_filter = NULLSTR; - std::vector log_channels = { "Main", "SoH Logging" }; - std::vector priority_filters = { "None", "Info", "Log", "Warning", "Error" }; + spdlog::level::level_enum level_filter = spdlog::level::trace; + std::vector log_channels = { "Console", "Logs" }; + std::vector priority_filters = { spdlog::level::off, spdlog::level::critical, spdlog::level::err, spdlog::level::warn, spdlog::level::info, spdlog::level::debug, spdlog::level::trace }; std::vector priority_colors = { - ImVec4(1.0f, 1.0f, 1.0f, 1.0f), - ImVec4(0.2f, 1.0f, 0.2f, 1.0f), - ImVec4(0.9f, 0.8f, 0.4f, 0.01f), - ImVec4(1.0f, 0.2f, 0.2f, 1.0f) + ImVec4(0.8f, 0.8f, 0.8f, 1.0f), // TRACE + ImVec4(0.9f, 0.9f, 0.9f, 1.0f), // DEBUG + ImVec4(1.0f, 1.0f, 1.0f, 1.0f), // INFO + ImVec4(1.0f, 0.875f, 0.125f, 1.0f), // WARN + ImVec4(0.65f, 0.18f, 0.25, 1.0f), // ERROR + ImVec4(0.95f, 0.11f, 0.25, 1.0f), // CRITICAL + ImVec4(0.0f, 0.0f, 0.0f, 0.0f) // OFF }; + protected: + void Append(const std::string& channel, spdlog::level::level_enum priority, const char* fmt, va_list args); + public: std::map> Log; std::map Commands; @@ -71,13 +69,17 @@ namespace Ship { char* InputBuffer = nullptr; bool OpenAutocomplete = false; int HistoryIndex = -1; - std::string selected_channel = "Main"; + std::string selected_channel = "Console"; bool opened = false; void Init(); void Update(); void Draw(); - void Append(const std::string& channel, Priority priority, const char* fmt, ...) IM_FMTARGS(4); void Dispatch(const std::string& line); static int CallbackStub(ImGuiInputTextCallbackData* data); + void SendInfoMessage(const char* fmt, ...); + void SendErrorMessage(const char* fmt, ...); + void SendInfoMessage(const std::string& str); + void SendErrorMessage(const std::string& str); + void Append(const std::string& channel, spdlog::level::level_enum priority, const char* fmt, ...); }; } \ No newline at end of file diff --git a/libultraship/libultraship/Cutscene.cpp b/libultraship/libultraship/Cutscene.cpp index 5ccadbb7b..79b42b3f1 100644 --- a/libultraship/libultraship/Cutscene.cpp +++ b/libultraship/libultraship/Cutscene.cpp @@ -1,4 +1,5 @@ #include "Cutscene.h" +#include "spdlog/spdlog.h" enum class CutsceneCommands { diff --git a/libultraship/libultraship/GameOverlay.cpp b/libultraship/libultraship/GameOverlay.cpp index 00bab575f..e13fbb9fd 100644 --- a/libultraship/libultraship/GameOverlay.cpp +++ b/libultraship/libultraship/GameOverlay.cpp @@ -4,7 +4,6 @@ #include "File.h" #include "Archive.h" #include "ResourceMgr.h" -#include "Console.h" #include "ImGuiImpl.h" #include "Lib/ImGui/imgui_internal.h" #include "Utils/StringHelper.h" @@ -209,24 +208,24 @@ namespace Ship { if (args[1] == "add") { if (!overlay->RegisteredOverlays.contains(key)) { overlay->RegisteredOverlays[key] = new Overlay({ OverlayType::TEXT, ImStrdup(key), -1.0f }); - INFO("Added overlay: %s ", key); + SPDLOG_INFO("Added overlay: {} ", key); } else { - ERROR("Overlay already exists: %s", key); + SPDLOG_ERROR("Overlay already exists: %s", key); } } else if (args[1] == "remove") { if (overlay->RegisteredOverlays.contains(key)) { overlay->RegisteredOverlays.erase(key); - INFO("Removed overlay: %s ", key); + SPDLOG_INFO("Removed overlay: {} ", key); } else { - ERROR("Overlay not found: %s ", key); + SPDLOG_ERROR("Overlay not found: %s ", key); } } } else { - ERROR("CVar %s does not exist", args[2].c_str()); + SPDLOG_ERROR("CVar %s does not exist", args[2].c_str()); } return CMD_SUCCESS; diff --git a/libultraship/libultraship/GlobalCtx2.cpp b/libultraship/libultraship/GlobalCtx2.cpp index 4d6046de3..c5597d7c9 100644 --- a/libultraship/libultraship/GlobalCtx2.cpp +++ b/libultraship/libultraship/GlobalCtx2.cpp @@ -90,12 +90,20 @@ namespace Ship { // Setup Logging spdlog::init_thread_pool(8192, 1); auto SohConsoleSink = std::make_shared(); - auto ConsoleSink = std::make_shared(); - auto FileSink = std::make_shared(logPath, 1024 * 1024 * 10, 10); SohConsoleSink->set_level(spdlog::level::trace); +#if defined(__linux__) + auto ConsoleSink = std::make_shared(); ConsoleSink->set_level(spdlog::level::trace); +#endif + auto FileSink = std::make_shared(logPath, 1024 * 1024 * 10, 10); FileSink->set_level(spdlog::level::trace); - std::vector Sinks{ ConsoleSink, FileSink, SohConsoleSink }; + std::vector Sinks{ +#if defined(__linux__) + ConsoleSink, +#endif + FileSink, + SohConsoleSink + }; Logger = std::make_shared(GetName(), Sinks.begin(), Sinks.end(), spdlog::thread_pool(), spdlog::async_overflow_policy::block); GetLogger()->set_level(spdlog::level::trace); GetLogger()->set_pattern("[%Y-%m-%d %H:%M:%S.%e] [%@] [%l] %v"); diff --git a/libultraship/libultraship/Lib/spdlog/include/spdlog/sinks/sohconsole_sink.h b/libultraship/libultraship/Lib/spdlog/include/spdlog/sinks/sohconsole_sink.h index 7b5da63fd..65e98610a 100644 --- a/libultraship/libultraship/Lib/spdlog/include/spdlog/sinks/sohconsole_sink.h +++ b/libultraship/libultraship/Lib/spdlog/include/spdlog/sinks/sohconsole_sink.h @@ -31,47 +31,24 @@ public: {} protected: - void sink_it_(const details::log_msg &msg) override - { - const Ship::Priority priority = convert_to_soh(msg.level); + void sink_it_(const details::log_msg &msg) override { memory_buf_t formatted; - if (use_raw_msg_) - { + if (use_raw_msg_) { details::fmt_helper::append_string_view(msg.payload, formatted); } - else - { + else { base_sink::formatter_->format(msg, formatted); } formatted.push_back('\0'); - const char *msg_output = formatted.data(); - if (CVar_GetS32("gSinkEnabled", 0) && SohImGui::console->opened) - SohImGui::console->Append("SoH Logging", priority, "%s", msg_output); + const char* msg_output = formatted.data(); + if (CVar_GetS32("gSinkEnabled", 0) && SohImGui::console->opened) { + SohImGui::console->Append("Logs", msg.level, "%s", msg_output); + } } void flush_() override {} private: - static Ship::Priority convert_to_soh(spdlog::level::level_enum level) - { - switch (level) { - case spdlog::level::trace: - return Ship::Priority::INFO_LVL; - case spdlog::level::debug: - return Ship::Priority::LOG_LVL; - case spdlog::level::info: - return Ship::Priority::LOG_LVL; - case spdlog::level::warn: - return Ship::Priority::WARNING_LVL; - case spdlog::level::err: - return Ship::Priority::ERROR_LVL; - case spdlog::level::critical: - return Ship::Priority::ERROR_LVL; - default: - break; - } - return Ship::Priority::LOG_LVL; - } std::string tag_; bool use_raw_msg_; diff --git a/libultraship/libultraship/Resource.cpp b/libultraship/libultraship/Resource.cpp index d3af20667..cbeedb44b 100644 --- a/libultraship/libultraship/Resource.cpp +++ b/libultraship/libultraship/Resource.cpp @@ -1,6 +1,7 @@ #include "Resource.h" #include "DisplayList.h" #include "ResourceMgr.h" +#include "spdlog/spdlog.h" #include "Utils/BinaryReader.h" #include "Lib/tinyxml2/tinyxml2.h" #include "Lib/Fast3D/U64/PR/ultra64/gbi.h" diff --git a/soh/soh/Enhancements/debugconsole.cpp b/soh/soh/Enhancements/debugconsole.cpp index b50c8c9d6..afebd064b 100644 --- a/soh/soh/Enhancements/debugconsole.cpp +++ b/soh/soh/Enhancements/debugconsole.cpp @@ -34,12 +34,12 @@ extern GlobalContext* gGlobalCtx; static bool ActorSpawnHandler(const std::vector& args) { if ((args.size() != 9) && (args.size() != 3) && (args.size() != 6)) { - ERROR("Not enough arguments passed to actorspawn"); + SPDLOG_ERROR("Not enough arguments passed to actorspawn"); return CMD_FAILED; } if (gGlobalCtx == nullptr) { - ERROR("GlobalCtx == nullptr"); + SPDLOG_ERROR("GlobalCtx == nullptr"); return CMD_FAILED; } @@ -75,7 +75,7 @@ static bool ActorSpawnHandler(const std::vector& args) { if (Actor_Spawn(&gGlobalCtx->actorCtx, gGlobalCtx, actorId, spawnPoint.pos.x, spawnPoint.pos.y, spawnPoint.pos.z, spawnPoint.rot.x, spawnPoint.rot.y, spawnPoint.rot.z, params) == NULL) { - ERROR("Failed to spawn actor. Actor_Spawn returned NULL"); + SPDLOG_ERROR("Failed to spawn actor. Actor_Spawn returned NULL"); return CMD_FAILED; } return CMD_SUCCESS; @@ -85,13 +85,13 @@ static bool ActorSpawnHandler(const std::vector& args) { static bool KillPlayerHandler([[maybe_unused]] const std::vector&) { gSaveContext.health = 0; - INFO("[SOH] You've met with a terrible fate, haven't you?"); + SPDLOG_INFO("[SOH] You've met with a terrible fate, haven't you?"); return CMD_SUCCESS; } static bool SetPlayerHealthHandler(const std::vector& args) { if (args.size() != 2) { - ERROR("[SOH] Unexpected arguments passed"); + SPDLOG_ERROR("[SOH] Unexpected arguments passed"); return CMD_FAILED; } @@ -100,18 +100,18 @@ static bool SetPlayerHealthHandler(const std::vector& args) { try { health = std::stoi(args[1]); } catch (std::invalid_argument const& ex) { - ERROR("[SOH] Health value must be an integer."); + SPDLOG_ERROR("[SOH] Health value must be an integer."); return CMD_FAILED; } if (health < 0) { - ERROR("[SOH] Health value must be a positive integer"); + SPDLOG_ERROR("[SOH] Health value must be a positive integer"); return CMD_SUCCESS; } gSaveContext.health = health * 0x10; - INFO("[SOH] Player health updated to %d", health); + SPDLOG_INFO("[SOH] Player health updated to %d", health); return CMD_SUCCESS; } @@ -133,31 +133,31 @@ static bool RuppeHandler(const std::vector& args) { rupeeAmount = std::stoi(args[1]); } catch (std::invalid_argument const& ex) { - ERROR("[SOH] Rupee count must be an integer."); + SPDLOG_ERROR("[SOH] Rupee count must be an integer."); return CMD_FAILED; } if (rupeeAmount < 0) { - ERROR("[SOH] Rupee count must be positive"); + SPDLOG_ERROR("[SOH] Rupee count must be positive"); return CMD_FAILED; } gSaveContext.rupees = rupeeAmount; - INFO("Set rupee count to %u", rupeeAmount); + SPDLOG_INFO("Set rupee count to {}", rupeeAmount); return CMD_SUCCESS; } static bool SetPosHandler(const std::vector args) { if (gGlobalCtx == nullptr) { - ERROR("GlobalCtx == nullptr"); + SPDLOG_ERROR("GlobalCtx == nullptr"); return CMD_FAILED; } Player* player = GET_PLAYER(gGlobalCtx); if (args.size() == 1) { - INFO("Player position is [ %.2f, %.2f, %.2f ]", player->actor.world.pos.x, player->actor.world.pos.y, + SPDLOG_INFO("Player position is [ {:.2f}, {:.2f}, {:.2f} ]", player->actor.world.pos.x, player->actor.world.pos.y, player->actor.world.pos.z); return CMD_SUCCESS; } @@ -168,14 +168,14 @@ static bool SetPosHandler(const std::vector args) { player->actor.world.pos.y = std::stof(args[2]); player->actor.world.pos.z = std::stof(args[3]); - INFO("Set player position to [ %.2f, %.2f, %.2f ]", player->actor.world.pos.x, player->actor.world.pos.y, + SPDLOG_INFO("Set player position to [ {:.2f}, {:.2f}, {:.2f} ]", player->actor.world.pos.x, player->actor.world.pos.y, player->actor.world.pos.z); return CMD_SUCCESS; } static bool ResetHandler(std::vector args) { if (gGlobalCtx == nullptr) { - ERROR("GlobalCtx == nullptr"); + SPDLOG_ERROR("GlobalCtx == nullptr"); return CMD_FAILED; } @@ -196,7 +196,7 @@ const static std::map ammoItems{ static bool AmmoHandler(const std::vector& args) { if (args.size() != 3) { - ERROR("[SOH] Unexpected arguments passed"); + SPDLOG_ERROR("[SOH] Unexpected arguments passed"); return CMD_FAILED; } @@ -205,19 +205,19 @@ static bool AmmoHandler(const std::vector& args) { try { count = std::stoi(args[2]); } catch (std::invalid_argument const& ex) { - ERROR("Ammo count must be an integer"); + SPDLOG_ERROR("Ammo count must be an integer"); return CMD_FAILED; } if (count < 0) { - ERROR("Ammo count must be positive"); + SPDLOG_ERROR("Ammo count must be positive"); return CMD_FAILED; } const auto& it = ammoItems.find(args[1]); if (it == ammoItems.end()) { - ERROR("Invalid item passed"); + SPDLOG_ERROR("Invalid item passed"); return CMD_FAILED; } @@ -239,7 +239,7 @@ const static std::map bottleItems{ static bool BottleHandler(const std::vector& args) { if (args.size() != 3) { - ERROR("[SOH] Unexpected arguments passed"); + SPDLOG_ERROR("[SOH] Unexpected arguments passed"); return CMD_FAILED; } @@ -247,19 +247,19 @@ static bool BottleHandler(const std::vector& args) { try { slot = std::stoi(args[2]); } catch (std::invalid_argument const& ex) { - ERROR("[SOH] Bottle slot must be an integer."); + SPDLOG_ERROR("[SOH] Bottle slot must be an integer."); return CMD_FAILED; } if ((slot < 1) || (slot > 4)) { - ERROR("Invalid slot passed"); + SPDLOG_ERROR("Invalid slot passed"); return CMD_FAILED; } const auto& it = bottleItems.find(args[1]); if (it == bottleItems.end()) { - ERROR("Invalid item passed"); + SPDLOG_ERROR("Invalid item passed"); return CMD_FAILED; } @@ -271,7 +271,7 @@ static bool BottleHandler(const std::vector& args) { static bool BHandler(const std::vector& args) { if (args.size() != 2) { - ERROR("[SOH] Unexpected arguments passed"); + SPDLOG_ERROR("[SOH] Unexpected arguments passed"); return CMD_FAILED; } @@ -281,7 +281,7 @@ static bool BHandler(const std::vector& args) { static bool ItemHandler(const std::vector& args) { if (args.size() != 3) { - ERROR("[SOH] Unexpected arguments passed"); + SPDLOG_ERROR("[SOH] Unexpected arguments passed"); return CMD_FAILED; } @@ -292,7 +292,7 @@ static bool ItemHandler(const std::vector& args) { static bool EntranceHandler(const std::vector& args) { if (args.size() != 2) { - ERROR("[SOH] Unexpected arguments passed"); + SPDLOG_ERROR("[SOH] Unexpected arguments passed"); return CMD_FAILED; } @@ -301,7 +301,7 @@ static bool EntranceHandler(const std::vector& args) { try { entrance = std::stoi(args[1], nullptr, 16); } catch (std::invalid_argument const& ex) { - ERROR("[SOH] Entrance value must be a Hex number."); + SPDLOG_ERROR("[SOH] Entrance value must be a Hex number."); return CMD_FAILED; } gGlobalCtx->nextEntranceIndex = entrance; @@ -317,10 +317,10 @@ static bool SaveStateHandler(const std::vector& args) { switch (rtn) { case SaveStateReturn::SUCCESS: - INFO("[SOH] Saved state to slot %u", slot); + SPDLOG_INFO("[SOH] Saved state to slot {}", slot); return CMD_SUCCESS; case SaveStateReturn::FAIL_WRONG_GAMESTATE: - ERROR("[SOH] Can not save a state outside of \"GamePlay\""); + SPDLOG_ERROR("[SOH] Can not save a state outside of \"GamePlay\""); return CMD_FAILED; } @@ -332,16 +332,16 @@ static bool LoadStateHandler(const std::vector& args) { switch (rtn) { case SaveStateReturn::SUCCESS: - INFO("[SOH] Loaded state from slot %u", slot); + SPDLOG_INFO("[SOH] Loaded state from slot ({})", slot); return CMD_SUCCESS; case SaveStateReturn::FAIL_INVALID_SLOT: - ERROR("[SOH] Invalid State Slot Number (%u)", slot); + SPDLOG_ERROR("[SOH] Invalid State Slot Number ({})", slot); return CMD_FAILED; case SaveStateReturn::FAIL_STATE_EMPTY: - ERROR("[SOH] State Slot (%u) is empty", slot); + SPDLOG_ERROR("[SOH] State Slot ({}) is empty", slot); return CMD_FAILED; case SaveStateReturn::FAIL_WRONG_GAMESTATE: - ERROR("[SOH] Can not load a state outside of \"GamePlay\""); + SPDLOG_ERROR("[SOH] Can not load a state outside of \"GamePlay\""); return CMD_FAILED; } @@ -349,7 +349,7 @@ static bool LoadStateHandler(const std::vector& args) { static bool StateSlotSelectHandler(const std::vector& args) { if (args.size() != 2) { - ERROR("[SOH] Unexpected arguments passed"); + SPDLOG_ERROR("[SOH] Unexpected arguments passed"); return CMD_FAILED; } int slot; @@ -357,17 +357,17 @@ static bool StateSlotSelectHandler(const std::vector& args) { try { slot = std::stoi(args[1], nullptr, 10); } catch (std::invalid_argument const& ex) { - ERROR("[SOH] SaveState slot value must be a number."); + SPDLOG_ERROR("[SOH] SaveState slot value must be a number."); return CMD_FAILED; } if (slot < 0) { - ERROR("[SOH] Invalid slot passed. Slot must be between 0 and 2"); + SPDLOG_ERROR("[SOH] Invalid slot passed. Slot must be between 0 and 2"); return CMD_FAILED; } OTRGlobals::Instance->gSaveStateMgr->SetCurrentSlot(slot); - INFO("[SOH] Slot %u selected", OTRGlobals::Instance->gSaveStateMgr->GetCurrentSlot()); + SPDLOG_INFO("[SOH] Slot {} selected", OTRGlobals::Instance->gSaveStateMgr->GetCurrentSlot()); return CMD_SUCCESS; } @@ -441,17 +441,18 @@ static bool GetCVarHandler(const std::vector& args) { if (cvar != nullptr) { if (cvar->type == CVarType::S32) - INFO("[SOH] Variable %s is %i", args[1].c_str(), cvar->value.valueS32); + SPDLOG_INFO("[SOH] Variable {} is {}", args[1], cvar->value.valueS32); else if (cvar->type == CVarType::Float) - INFO("[SOH] Variable %s is %f", args[1].c_str(), cvar->value.valueFloat); + SPDLOG_INFO("[SOH] Variable {} is {}", args[1], cvar->value.valueFloat); else if (cvar->type == CVarType::String) - INFO("[SOH] Variable %s is %s", args[1].c_str(), cvar->value.valueStr); + SPDLOG_INFO("[SOH] Variable {} is {}", args[1], cvar->value.valueStr); else if (cvar->type == CVarType::RGBA) - INFO("[SOH] Variable %s is %08X", args[1].c_str(), cvar->value.valueRGBA); + SPDLOG_INFO("[SOH] Variable {} is ({}, {}, {}, {})", args[1], cvar->value.valueRGBA.r, + cvar->value.valueRGBA.g, cvar->value.valueRGBA.b, cvar->value.valueRGBA.a); } else { - INFO("[SOH] Could not find variable %s", args[1].c_str()); + SPDLOG_INFO("[SOH] Could not find variable %s", args[1]); } diff --git a/soh/soh/Enhancements/randomizer/3drando/entrance.cpp b/soh/soh/Enhancements/randomizer/3drando/entrance.cpp index 51be29bdf..144759e29 100644 --- a/soh/soh/Enhancements/randomizer/3drando/entrance.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/entrance.cpp @@ -156,7 +156,7 @@ static bool AreEntrancesCompatible(Entrance* entrance, Entrance* target, std::ve //Entrances shouldn't connect to their own scene, fail in this situation if (entrance->GetParentRegion()->scene != "" && entrance->GetParentRegion()->scene == target->GetConnectedRegion()->scene) { auto message = "Entrance " + entrance->GetName() + " attempted to connect with own scene target " + target->to_string() + ". Connection failed.\n"; - SPDLOG_INFO(message); + SPDLOG_DEBUG(message); return false; } @@ -168,7 +168,7 @@ static bool AreEntrancesCompatible(Entrance* entrance, Entrance* target, std::ve //Change connections between an entrance and a target assumed entrance, in order to test the connections afterwards if necessary static void ChangeConnections(Entrance* entrance, Entrance* targetEntrance) { auto message = "Attempting to connect " + entrance->GetName() + " to " + targetEntrance->to_string() + "\n"; - SPDLOG_INFO(message); + SPDLOG_DEBUG(message); entrance->Connect(targetEntrance->Disconnect()); entrance->SetReplacement(targetEntrance->GetReplacement()); if (entrance->GetReverse() != nullptr /*&& entrances aren't decoupled*/) { @@ -208,7 +208,7 @@ static void ConfirmReplacement(Entrance* entrance, Entrance* targetEntrance) { static bool EntranceUnreachableAs(Entrance* entrance, uint8_t age, std::vector& alreadyChecked) { if (entrance == nullptr) { - SPDLOG_INFO("Entrance is nullptr in EntranceUnreachableAs()"); + SPDLOG_DEBUG("Entrance is nullptr in EntranceUnreachableAs()"); return true; } @@ -247,7 +247,7 @@ static bool EntranceUnreachableAs(Entrance* entrance, uint8_t age, std::vectorHasAccess() && !AreaTable(KAKARIKO_VILLAGE)->HasAccess()) { - SPDLOG_INFO("Invalid starting area\n"); + SPDLOG_DEBUG("Invalid starting area\n"); return false; } // Check that a region where time passes is always reachable as both ages without having collected any items if (!Areas::HasTimePassAccess(AGE_CHILD) || !Areas::HasTimePassAccess(AGE_ADULT)) { - SPDLOG_INFO("Time passing is not guaranteed as both ages\n"); + SPDLOG_DEBUG("Time passing is not guaranteed as both ages\n"); return false; } // The player should be able to get back to ToT after going through time, without having collected any items // This is important to ensure that the player never loses access to the pedestal after going through time if (Settings::ResolvedStartingAge == AGE_CHILD && !AreaTable(TEMPLE_OF_TIME)->Adult()) { - SPDLOG_INFO("Path to Temple of Time as adult is not guaranteed\n"); + SPDLOG_DEBUG("Path to Temple of Time as adult is not guaranteed\n"); return false; } else if (Settings::ResolvedStartingAge == AGE_ADULT && !AreaTable(TEMPLE_OF_TIME)->Child()) { - SPDLOG_INFO("Path to Temple of Time as child is not guaranteed\n"); + SPDLOG_DEBUG("Path to Temple of Time as child is not guaranteed\n"); return false; } } @@ -353,11 +353,11 @@ static bool ValidateWorld(Entrance* entrancePlaced) { // This is important to ensure that players can never lock their only bottles by filling them with Big Poes they can't sell if (checkPoeCollectorAccess) { if (!AreaTable(MARKET_GUARD_HOUSE)->Adult()) { - SPDLOG_INFO("Big Poe Shop access is not guarenteed as adult\n"); + SPDLOG_DEBUG("Big Poe Shop access is not guarenteed as adult\n"); return false; } } - SPDLOG_INFO("All Locations NOT REACHABLE\n"); + SPDLOG_DEBUG("All Locations NOT REACHABLE\n"); return false; } return true; @@ -476,7 +476,7 @@ static void ShuffleEntrancePool(std::vector& entrancePool, std::vecto } if (retries <= 0) { - SPDLOG_INFO("Entrance placement attempt count exceeded. Restarting randomization completely"); + SPDLOG_DEBUG("Entrance placement attempt count exceeded. Restarting randomization completely"); entranceShuffleFailure = true; } } @@ -840,7 +840,7 @@ void CreateEntranceOverrides() { if (noRandomEntrances) { return; } - SPDLOG_INFO("\nCREATING ENTRANCE OVERRIDES\n"); + SPDLOG_DEBUG("\nCREATING ENTRANCE OVERRIDES\n"); auto allShuffleableEntrances = GetShuffleableEntrances(EntranceType::All, false); for (Entrance* entrance : allShuffleableEntrances) { @@ -851,7 +851,7 @@ void CreateEntranceOverrides() { } auto message = "Setting " + entrance->to_string() + "\n"; - SPDLOG_INFO(message); + SPDLOG_DEBUG(message); int16_t originalIndex = entrance->GetIndex(); int16_t destinationIndex = entrance->GetReverse()->GetIndex(); @@ -868,9 +868,9 @@ void CreateEntranceOverrides() { }); message = "\tOriginal: " + std::to_string(originalIndex) + "\n"; - SPDLOG_INFO(message); + SPDLOG_DEBUG(message); message = "\tReplacement " + std::to_string(replacementIndex) + "\n"; - SPDLOG_INFO(message); + SPDLOG_DEBUG(message); } } diff --git a/soh/soh/Enhancements/randomizer/3drando/fill.cpp b/soh/soh/Enhancements/randomizer/3drando/fill.cpp index b9cf75518..14bf594c2 100644 --- a/soh/soh/Enhancements/randomizer/3drando/fill.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/fill.cpp @@ -420,7 +420,7 @@ std::vector GetAccessibleLocations(const std::vector& allowe if (!Location(loc)->IsAddedToPool()) { allLocationsReachable = false; auto message = "Location " + Location(loc)->GetName() + " not reachable\n"; - SPDLOG_INFO(message); + SPDLOG_DEBUG(message); #ifndef ENABLE_DEBUG break; #endif @@ -567,17 +567,17 @@ static void AssumedFill(const std::vector& items, const std::vector allowedLocations.size()) { printf("\x1b[2;2HERROR: MORE ITEMS THAN LOCATIONS IN GIVEN LISTS"); - SPDLOG_INFO("Items:\n"); + SPDLOG_DEBUG("Items:\n"); for (const uint32_t item : items) { - SPDLOG_INFO("\t"); - SPDLOG_INFO(ItemTable(item).GetName().GetEnglish()); - SPDLOG_INFO("\n"); + SPDLOG_DEBUG("\t"); + SPDLOG_DEBUG(ItemTable(item).GetName().GetEnglish()); + SPDLOG_DEBUG("\n"); } - SPDLOG_INFO("\nAllowed Locations:\n"); + SPDLOG_DEBUG("\nAllowed Locations:\n"); for (const uint32_t loc : allowedLocations) { - SPDLOG_INFO("\t"); - SPDLOG_INFO(Location(loc)->GetName()); - SPDLOG_INFO("\n"); + SPDLOG_DEBUG("\t"); + SPDLOG_DEBUG(Location(loc)->GetName()); + SPDLOG_DEBUG("\n"); } placementFailure = true; return; @@ -627,9 +627,9 @@ static void AssumedFill(const std::vector& items, const std::vector& items, const std::vector& possibleHintLocations) { //return if there aren't any hintable locations or gossip stones available if (possibleHintLocations.empty()) { - SPDLOG_INFO("\tNO LOCATIONS TO HINT\n\n"); + SPDLOG_DEBUG("\tNO LOCATIONS TO HINT\n\n"); return; } uint32_t hintedLocation = RandomElement(possibleHintLocations); const std::vector accessibleGossipStones = GetAccessibleGossipStones(hintedLocation); - SPDLOG_INFO("\tLocation: "); - SPDLOG_INFO(Location(hintedLocation)->GetName()); - SPDLOG_INFO("\n"); + SPDLOG_DEBUG("\tLocation: "); + SPDLOG_DEBUG(Location(hintedLocation)->GetName()); + SPDLOG_DEBUG("\n"); - SPDLOG_INFO("\tItem: "); - SPDLOG_INFO(Location(hintedLocation)->GetPlacedItemName().GetEnglish()); - SPDLOG_INFO("\n"); + SPDLOG_DEBUG("\tItem: "); + SPDLOG_DEBUG(Location(hintedLocation)->GetPlacedItemName().GetEnglish()); + SPDLOG_DEBUG("\n"); if (accessibleGossipStones.empty()) { - SPDLOG_INFO("\tNO GOSSIP STONES TO PLACE HINT\n\n"); + SPDLOG_DEBUG("\tNO GOSSIP STONES TO PLACE HINT\n\n"); return; } @@ -235,9 +235,9 @@ static void CreateLocationHint(const std::vector& possibleHintLocation Text prefix = Hint(PREFIX).GetText(); Text finalHint = prefix + locationHintText + " #"+itemHintText+"#."; - SPDLOG_INFO("\tMessage: "); - SPDLOG_INFO(finalHint.english); - SPDLOG_INFO("\n\n"); + SPDLOG_DEBUG("\tMessage: "); + SPDLOG_DEBUG(finalHint.english); + SPDLOG_DEBUG("\n\n"); AddHint(finalHint, gossipStone, {QM_GREEN, QM_RED}); } @@ -258,24 +258,24 @@ static void CreateWothHint(uint8_t* remainingDungeonWothHints) { // If no more locations can be hinted at for woth, then just try to get another hint if (possibleHintLocations.empty()) { - SPDLOG_INFO("\tNO LOCATIONS TO HINT\n\n"); + SPDLOG_DEBUG("\tNO LOCATIONS TO HINT\n\n"); return; } uint32_t hintedLocation = RandomElement(possibleHintLocations); - SPDLOG_INFO("\tLocation: "); - SPDLOG_INFO(Location(hintedLocation)->GetName()); - SPDLOG_INFO("\n"); + SPDLOG_DEBUG("\tLocation: "); + SPDLOG_DEBUG(Location(hintedLocation)->GetName()); + SPDLOG_DEBUG("\n"); - SPDLOG_INFO("\tItem: "); - SPDLOG_INFO(Location(hintedLocation)->GetPlacedItemName().GetEnglish()); - SPDLOG_INFO("\n"); + SPDLOG_DEBUG("\tItem: "); + SPDLOG_DEBUG(Location(hintedLocation)->GetPlacedItemName().GetEnglish()); + SPDLOG_DEBUG("\n"); // get an accessible gossip stone const std::vector gossipStoneLocations = GetAccessibleGossipStones(hintedLocation); if (gossipStoneLocations.empty()) { - SPDLOG_INFO("\tNO GOSSIP STONES TO PLACE HINT\n\n"); + SPDLOG_DEBUG("\tNO GOSSIP STONES TO PLACE HINT\n\n"); return; } Location(hintedLocation)->SetAsHinted(); @@ -293,9 +293,9 @@ static void CreateWothHint(uint8_t* remainingDungeonWothHints) { locationText = GetHintRegion(parentRegion)->GetHint().GetText(); } Text finalWothHint = Hint(PREFIX).GetText() + "#" + locationText + "#" + Hint(WAY_OF_THE_HERO).GetText(); - SPDLOG_INFO("\tMessage: "); - SPDLOG_INFO(finalWothHint.english); - SPDLOG_INFO("\n\n"); + SPDLOG_DEBUG("\tMessage: "); + SPDLOG_DEBUG(finalWothHint.english); + SPDLOG_DEBUG("\n\n"); AddHint(finalWothHint, gossipStone, { QM_LBLUE }); } @@ -312,18 +312,18 @@ static void CreateBarrenHint(uint8_t* remainingDungeonBarrenHints, std::vectorGetName()); - SPDLOG_INFO("\n"); + SPDLOG_DEBUG("\tLocation: "); + SPDLOG_DEBUG(Location(hintedLocation)->GetName()); + SPDLOG_DEBUG("\n"); - SPDLOG_INFO("\tItem: "); - SPDLOG_INFO(Location(hintedLocation)->GetPlacedItemName().GetEnglish()); - SPDLOG_INFO("\n"); + SPDLOG_DEBUG("\tItem: "); + SPDLOG_DEBUG(Location(hintedLocation)->GetPlacedItemName().GetEnglish()); + SPDLOG_DEBUG("\n"); // get an accessible gossip stone const std::vector gossipStoneLocations = GetAccessibleGossipStones(hintedLocation); if (gossipStoneLocations.empty()) { - SPDLOG_INFO("\tNO GOSSIP STONES TO PLACE HINT\n\n"); + SPDLOG_DEBUG("\tNO GOSSIP STONES TO PLACE HINT\n\n"); return; } Location(hintedLocation)->SetAsHinted(); @@ -341,9 +341,9 @@ static void CreateBarrenHint(uint8_t* remainingDungeonBarrenHints, std::vectorGetName()); - SPDLOG_INFO("\n"); + SPDLOG_DEBUG("\tLocation: "); + SPDLOG_DEBUG(Location(hintedLocation)->GetName()); + SPDLOG_DEBUG("\n"); - SPDLOG_INFO("\tItem: "); - SPDLOG_INFO(Location(hintedLocation)->GetPlacedItemName().GetEnglish()); - SPDLOG_INFO("\n"); + SPDLOG_DEBUG("\tItem: "); + SPDLOG_DEBUG(Location(hintedLocation)->GetPlacedItemName().GetEnglish()); + SPDLOG_DEBUG("\n"); //get an acessible gossip stone const std::vector gossipStoneLocations = GetAccessibleGossipStones(hintedLocation); if (gossipStoneLocations.empty()) { - SPDLOG_INFO("\tNO GOSSIP STONES TO PLACE HINT\n\n"); + SPDLOG_DEBUG("\tNO GOSSIP STONES TO PLACE HINT\n\n"); return; } Location(hintedLocation)->SetAsHinted(); @@ -387,16 +387,16 @@ static void CreateRandomLocationHint(const bool goodItem = false) { uint32_t parentRegion = Location(hintedLocation)->GetParentRegionKey(); Text locationText = AreaTable(parentRegion)->GetHint().GetText(); Text finalHint = Hint(PREFIX).GetText()+"#"+locationText+"# "+Hint(HOARDS).GetText()+" #"+itemText+"#."; - SPDLOG_INFO("\tMessage: "); - SPDLOG_INFO(finalHint.english); - SPDLOG_INFO("\n\n"); + SPDLOG_DEBUG("\tMessage: "); + SPDLOG_DEBUG(finalHint.english); + SPDLOG_DEBUG("\n\n"); AddHint(finalHint, gossipStone, {QM_GREEN, QM_RED}); } else { Text locationText = GetHintRegion(Location(hintedLocation)->GetParentRegionKey())->GetHint().GetText(); Text finalHint = Hint(PREFIX).GetText()+"#"+itemText+"# "+Hint(CAN_BE_FOUND_AT).GetText()+" #"+locationText+"#."; - SPDLOG_INFO("\tMessage: "); - SPDLOG_INFO(finalHint.english); - SPDLOG_INFO("\n\n"); + SPDLOG_DEBUG("\tMessage: "); + SPDLOG_DEBUG(finalHint.english); + SPDLOG_DEBUG("\n\n"); AddHint(finalHint, gossipStone, {QM_RED, QM_GREEN}); } } @@ -411,15 +411,15 @@ static void CreateJunkHint() { LogicReset(); const std::vector gossipStones = GetAccessibleLocations(gossipStoneLocations); if (gossipStones.empty()) { - SPDLOG_INFO("\tNO GOSSIP STONES TO PLACE HINT\n\n"); + SPDLOG_DEBUG("\tNO GOSSIP STONES TO PLACE HINT\n\n"); return; } uint32_t gossipStone = RandomElement(gossipStones); Text hint = junkHint.GetText(); - SPDLOG_INFO("\tMessage: "); - SPDLOG_INFO(hint.english); - SPDLOG_INFO("\n\n"); + SPDLOG_DEBUG("\tMessage: "); + SPDLOG_DEBUG(hint.english); + SPDLOG_DEBUG("\n\n"); AddHint(hint, gossipStone, {QM_PINK}); } @@ -711,7 +711,7 @@ void CreateAllHints() { CreateGanonText(); CreateAltarText(); - SPDLOG_INFO("\nNOW CREATING HINTS\n"); + SPDLOG_DEBUG("\nNOW CREATING HINTS\n"); const HintSetting& hintSetting = hintSettingTable[Settings::HintDistribution.Value()]; uint8_t remainingDungeonWothHints = hintSetting.dungeonsWothLimit; @@ -768,9 +768,9 @@ void CreateAllHints() { barrenDungeons.push_back(barrenRegion); } } - SPDLOG_INFO("\nBarren Dungeons:\n"); + SPDLOG_DEBUG("\nBarren Dungeons:\n"); for (std::string barrenDungeon : barrenDungeons) { - SPDLOG_INFO(barrenDungeon + "\n"); + SPDLOG_DEBUG(barrenDungeon + "\n"); } //Get list of all woth dungeons @@ -783,9 +783,9 @@ void CreateAllHints() { wothDungeons.push_back(wothRegion); } } - SPDLOG_INFO("\nWoth Dungeons:\n"); + SPDLOG_DEBUG("\nWoth Dungeons:\n"); for (std::string wothDungeon : wothDungeons) { - SPDLOG_INFO(wothDungeon + "\n"); + SPDLOG_DEBUG(wothDungeon + "\n"); } //Set DungeonInfo array for each dungeon @@ -827,9 +827,9 @@ void CreateAllHints() { //get a random hint type from the remaining hints HintType type = RandomElement(remainingHintTypes, true); - SPDLOG_INFO("Attempting to make hint of type: "); - SPDLOG_INFO(hintTypeNames[static_cast(type)]); - SPDLOG_INFO("\n"); + SPDLOG_DEBUG("Attempting to make hint of type: "); + SPDLOG_DEBUG(hintTypeNames[static_cast(type)]); + SPDLOG_DEBUG("\n"); //create the appropriate hint for the type if (type == HintType::Woth) { diff --git a/soh/soh/Enhancements/randomizer/3drando/item_location.cpp b/soh/soh/Enhancements/randomizer/3drando/item_location.cpp index 18e5e8acf..27101864b 100644 --- a/soh/soh/Enhancements/randomizer/3drando/item_location.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/item_location.cpp @@ -1460,11 +1460,11 @@ void GenerateLocationPool() { void PlaceItemInLocation(uint32_t locKey, uint32_t item, bool applyEffectImmediately /*= false*/, bool setHidden /*= false*/) { auto loc = Location(locKey); - SPDLOG_INFO("\n"); - SPDLOG_INFO(ItemTable(item).GetName().GetEnglish()); - SPDLOG_INFO(" placed at "); - SPDLOG_INFO(loc->GetName()); - SPDLOG_INFO("\n\n"); + SPDLOG_DEBUG("\n"); + SPDLOG_DEBUG(ItemTable(item).GetName().GetEnglish()); + SPDLOG_DEBUG(" placed at "); + SPDLOG_DEBUG(loc->GetName()); + SPDLOG_DEBUG("\n\n"); if (applyEffectImmediately || Settings::Logic.Is(LOGIC_NONE) || Settings::Logic.Is(LOGIC_VANILLA)) { ItemTable(item).ApplyEffect(); @@ -1551,7 +1551,7 @@ void AddExcludedOptions() { } void CreateItemOverrides() { - SPDLOG_INFO("NOW CREATING OVERRIDES\n\n"); + SPDLOG_DEBUG("NOW CREATING OVERRIDES\n\n"); for (uint32_t locKey : allLocations) { auto loc = Location(locKey); ItemOverride_Value val = ItemTable(loc->GetPlaceduint32_t()).Value(); @@ -1563,18 +1563,18 @@ void CreateItemOverrides() { .key = loc->Key(), .value = val, }); - SPDLOG_INFO("\tScene: "); - SPDLOG_INFO(std::to_string(loc->Key().scene)); - SPDLOG_INFO("\tType: "); - SPDLOG_INFO(std::to_string(loc->Key().type)); - SPDLOG_INFO("\tFlag: "); - SPDLOG_INFO(std::to_string(loc->Key().flag)); - SPDLOG_INFO("\t"); - SPDLOG_INFO(loc->GetName()); - SPDLOG_INFO(": "); - SPDLOG_INFO(loc->GetPlacedItemName().GetEnglish()); - SPDLOG_INFO("\n"); + SPDLOG_DEBUG("\tScene: "); + SPDLOG_DEBUG(std::to_string(loc->Key().scene)); + SPDLOG_DEBUG("\tType: "); + SPDLOG_DEBUG(std::to_string(loc->Key().type)); + SPDLOG_DEBUG("\tFlag: "); + SPDLOG_DEBUG(std::to_string(loc->Key().flag)); + SPDLOG_DEBUG("\t"); + SPDLOG_DEBUG(loc->GetName()); + SPDLOG_DEBUG(": "); + SPDLOG_DEBUG(loc->GetPlacedItemName().GetEnglish()); + SPDLOG_DEBUG("\n"); } - SPDLOG_INFO("Overrides Created: "); - SPDLOG_INFO(std::to_string(overrides.size())); + SPDLOG_DEBUG("Overrides Created: "); + SPDLOG_DEBUG(std::to_string(overrides.size())); } \ No newline at end of file diff --git a/soh/soh/Enhancements/randomizer/3drando/item_pool.cpp b/soh/soh/Enhancements/randomizer/3drando/item_pool.cpp index b46ad395f..b7ed68ea6 100644 --- a/soh/soh/Enhancements/randomizer/3drando/item_pool.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/item_pool.cpp @@ -1174,6 +1174,6 @@ void GenerateItemPool() { } void AddJunk() { - SPDLOG_INFO("HAD TO PLACE EXTRA JUNK "); + SPDLOG_DEBUG("HAD TO PLACE EXTRA JUNK "); AddItemToMainPool(GetPendingJunkItem()); } diff --git a/soh/soh/Enhancements/randomizer/3drando/menu.cpp b/soh/soh/Enhancements/randomizer/3drando/menu.cpp index 7a0c16def..f7699b754 100644 --- a/soh/soh/Enhancements/randomizer/3drando/menu.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/menu.cpp @@ -26,13 +26,13 @@ Menu* currentMenu; } // namespace void PrintTopScreen() { - SPDLOG_INFO("\x1b[2;11H%sOcarina of Time 3D Randomizer%s", CYAN, RESET); - SPDLOG_INFO("\x1b[3;18H%s%s-%s%s", CYAN, RANDOMIZER_VERSION, COMMIT_NUMBER, RESET); - SPDLOG_INFO("\x1b[4;10HA/B/D-pad: Navigate Menu\n"); - SPDLOG_INFO(" Select: Exit to Homebrew Menu\n"); - SPDLOG_INFO(" Y: New Random Seed\n"); - SPDLOG_INFO(" X: Input Custom Seed\n"); - SPDLOG_INFO("\x1b[11;7HCurrent Seed: %s", Settings::seed.c_str()); + SPDLOG_DEBUG("\x1b[2;11H%sOcarina of Time 3D Randomizer%s", CYAN, RESET); + SPDLOG_DEBUG("\x1b[3;18H%s%s-%s%s", CYAN, RANDOMIZER_VERSION, COMMIT_NUMBER, RESET); + SPDLOG_DEBUG("\x1b[4;10HA/B/D-pad: Navigate Menu\n"); + SPDLOG_DEBUG(" Select: Exit to Homebrew Menu\n"); + SPDLOG_DEBUG(" Y: New Random Seed\n"); + SPDLOG_DEBUG(" X: Input Custom Seed\n"); + SPDLOG_DEBUG("\x1b[11;7HCurrent Seed: %s", Settings::seed.c_str()); } void MenuInit() { @@ -526,7 +526,7 @@ std::string GenerateRandomizer(std::unordered_map if (ret == -1) { // Failed to generate after 5 tries printf("\n\nFailed to generate after 5 tries.\nPress B to go back to the menu.\nA different seed might be " "successful."); - SPDLOG_INFO("\nRANDOMIZATION FAILED COMPLETELY. PLZ FIX\n"); + SPDLOG_DEBUG("\nRANDOMIZATION FAILED COMPLETELY. PLZ FIX\n"); return ""; } else { printf("\n\nError %d with fill.\nPress Select to exit or B to go back to the menu.\n", ret); From f97f9ae4226fbb51c715015f7f12a47d4adaad9b Mon Sep 17 00:00:00 2001 From: Kenix3 Date: Tue, 9 Aug 2022 21:53:22 -0400 Subject: [PATCH 61/71] Sets default value of ConsoleLine channel to "Console" --- libultraship/libultraship/Console.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libultraship/libultraship/Console.h b/libultraship/libultraship/Console.h index 4a99e5b5b..00ca518e2 100644 --- a/libultraship/libultraship/Console.h +++ b/libultraship/libultraship/Console.h @@ -37,7 +37,7 @@ namespace Ship { struct ConsoleLine { std::string text; spdlog::level::level_enum priority = spdlog::level::info; - std::string channel = "Main"; + std::string channel = "Console"; }; class Console { From 5751b5c278e29be6e8a22ba03d952b4ead258f39 Mon Sep 17 00:00:00 2001 From: Kenix3 Date: Tue, 9 Aug 2022 22:09:20 -0400 Subject: [PATCH 62/71] debugconsole now uses console output functions. --- libultraship/libultraship/GameOverlay.cpp | 7 +- soh/soh/Enhancements/debugconsole.cpp | 93 ++++++++++++----------- 2 files changed, 51 insertions(+), 49 deletions(-) diff --git a/libultraship/libultraship/GameOverlay.cpp b/libultraship/libultraship/GameOverlay.cpp index e13fbb9fd..8fe028667 100644 --- a/libultraship/libultraship/GameOverlay.cpp +++ b/libultraship/libultraship/GameOverlay.cpp @@ -209,9 +209,10 @@ namespace Ship { if (!overlay->RegisteredOverlays.contains(key)) { overlay->RegisteredOverlays[key] = new Overlay({ OverlayType::TEXT, ImStrdup(key), -1.0f }); SPDLOG_INFO("Added overlay: {} ", key); + SohImGui::console->SendInfoMessage("Added overlay: %s", key); } else { - SPDLOG_ERROR("Overlay already exists: %s", key); + SPDLOG_ERROR("Overlay already exists: {}", key); } } else if (args[1] == "remove") { @@ -220,12 +221,12 @@ namespace Ship { SPDLOG_INFO("Removed overlay: {} ", key); } else { - SPDLOG_ERROR("Overlay not found: %s ", key); + SPDLOG_ERROR("Overlay not found: {}", key); } } } else { - SPDLOG_ERROR("CVar %s does not exist", args[2].c_str()); + SPDLOG_ERROR("CVar {} does not exist", args[2].c_str()); } return CMD_SUCCESS; diff --git a/soh/soh/Enhancements/debugconsole.cpp b/soh/soh/Enhancements/debugconsole.cpp index afebd064b..203e5521a 100644 --- a/soh/soh/Enhancements/debugconsole.cpp +++ b/soh/soh/Enhancements/debugconsole.cpp @@ -34,12 +34,12 @@ extern GlobalContext* gGlobalCtx; static bool ActorSpawnHandler(const std::vector& args) { if ((args.size() != 9) && (args.size() != 3) && (args.size() != 6)) { - SPDLOG_ERROR("Not enough arguments passed to actorspawn"); + SohImGui::console->SendErrorMessage("Not enough arguments passed to actorspawn"); return CMD_FAILED; } if (gGlobalCtx == nullptr) { - SPDLOG_ERROR("GlobalCtx == nullptr"); + SohImGui::console->SendErrorMessage("GlobalCtx == nullptr"); return CMD_FAILED; } @@ -75,7 +75,7 @@ static bool ActorSpawnHandler(const std::vector& args) { if (Actor_Spawn(&gGlobalCtx->actorCtx, gGlobalCtx, actorId, spawnPoint.pos.x, spawnPoint.pos.y, spawnPoint.pos.z, spawnPoint.rot.x, spawnPoint.rot.y, spawnPoint.rot.z, params) == NULL) { - SPDLOG_ERROR("Failed to spawn actor. Actor_Spawn returned NULL"); + SohImGui::console->SendErrorMessage("Failed to spawn actor. Actor_Spawn returned NULL"); return CMD_FAILED; } return CMD_SUCCESS; @@ -84,14 +84,13 @@ static bool ActorSpawnHandler(const std::vector& args) { static bool KillPlayerHandler([[maybe_unused]] const std::vector&) { gSaveContext.health = 0; - - SPDLOG_INFO("[SOH] You've met with a terrible fate, haven't you?"); + SohImGui::console->SendInfoMessage("[SOH] You've met with a terrible fate, haven't you?"); return CMD_SUCCESS; } static bool SetPlayerHealthHandler(const std::vector& args) { if (args.size() != 2) { - SPDLOG_ERROR("[SOH] Unexpected arguments passed"); + SohImGui::console->SendErrorMessage("[SOH] Unexpected arguments passed"); return CMD_FAILED; } @@ -100,18 +99,18 @@ static bool SetPlayerHealthHandler(const std::vector& args) { try { health = std::stoi(args[1]); } catch (std::invalid_argument const& ex) { - SPDLOG_ERROR("[SOH] Health value must be an integer."); + SohImGui::console->SendErrorMessage("[SOH] Health value must be an integer."); return CMD_FAILED; } if (health < 0) { - SPDLOG_ERROR("[SOH] Health value must be a positive integer"); + SohImGui::console->SendErrorMessage("[SOH] Health value must be a positive integer"); return CMD_SUCCESS; } gSaveContext.health = health * 0x10; - SPDLOG_INFO("[SOH] Player health updated to %d", health); + SohImGui::console->SendInfoMessage("[SOH] Player health updated to %d", health); return CMD_SUCCESS; } @@ -133,31 +132,32 @@ static bool RuppeHandler(const std::vector& args) { rupeeAmount = std::stoi(args[1]); } catch (std::invalid_argument const& ex) { - SPDLOG_ERROR("[SOH] Rupee count must be an integer."); + SohImGui::console->SendErrorMessage("[SOH] Rupee count must be an integer."); return CMD_FAILED; } if (rupeeAmount < 0) { - SPDLOG_ERROR("[SOH] Rupee count must be positive"); + SohImGui::console->SendErrorMessage("[SOH] Rupee count must be positive"); return CMD_FAILED; } gSaveContext.rupees = rupeeAmount; - SPDLOG_INFO("Set rupee count to {}", rupeeAmount); + SohImGui::console->SendInfoMessage("Set rupee count to %u", rupeeAmount); return CMD_SUCCESS; } static bool SetPosHandler(const std::vector args) { if (gGlobalCtx == nullptr) { - SPDLOG_ERROR("GlobalCtx == nullptr"); + SohImGui::console->SendErrorMessage("GlobalCtx == nullptr"); return CMD_FAILED; } Player* player = GET_PLAYER(gGlobalCtx); if (args.size() == 1) { - SPDLOG_INFO("Player position is [ {:.2f}, {:.2f}, {:.2f} ]", player->actor.world.pos.x, player->actor.world.pos.y, + SohImGui::console->SendInfoMessage("Player position is [ %.2f, %.2f, %.2f ]", player->actor.world.pos.x, + player->actor.world.pos.y, player->actor.world.pos.z); return CMD_SUCCESS; } @@ -168,14 +168,15 @@ static bool SetPosHandler(const std::vector args) { player->actor.world.pos.y = std::stof(args[2]); player->actor.world.pos.z = std::stof(args[3]); - SPDLOG_INFO("Set player position to [ {:.2f}, {:.2f}, {:.2f} ]", player->actor.world.pos.x, player->actor.world.pos.y, + SohImGui::console->SendInfoMessage("Set player position to [ %.2f, %.2f, %.2f ]", player->actor.world.pos.x, + player->actor.world.pos.y, player->actor.world.pos.z); return CMD_SUCCESS; } static bool ResetHandler(std::vector args) { if (gGlobalCtx == nullptr) { - SPDLOG_ERROR("GlobalCtx == nullptr"); + SohImGui::console->SendErrorMessage("GlobalCtx == nullptr"); return CMD_FAILED; } @@ -196,7 +197,7 @@ const static std::map ammoItems{ static bool AmmoHandler(const std::vector& args) { if (args.size() != 3) { - SPDLOG_ERROR("[SOH] Unexpected arguments passed"); + SohImGui::console->SendErrorMessage("[SOH] Unexpected arguments passed"); return CMD_FAILED; } @@ -205,19 +206,19 @@ static bool AmmoHandler(const std::vector& args) { try { count = std::stoi(args[2]); } catch (std::invalid_argument const& ex) { - SPDLOG_ERROR("Ammo count must be an integer"); + SohImGui::console->SendErrorMessage("Ammo count must be an integer"); return CMD_FAILED; } if (count < 0) { - SPDLOG_ERROR("Ammo count must be positive"); + SohImGui::console->SendErrorMessage("Ammo count must be positive"); return CMD_FAILED; } const auto& it = ammoItems.find(args[1]); if (it == ammoItems.end()) { - SPDLOG_ERROR("Invalid item passed"); + SohImGui::console->SendErrorMessage("Invalid item passed"); return CMD_FAILED; } @@ -239,7 +240,7 @@ const static std::map bottleItems{ static bool BottleHandler(const std::vector& args) { if (args.size() != 3) { - SPDLOG_ERROR("[SOH] Unexpected arguments passed"); + SohImGui::console->SendErrorMessage("[SOH] Unexpected arguments passed"); return CMD_FAILED; } @@ -247,19 +248,19 @@ static bool BottleHandler(const std::vector& args) { try { slot = std::stoi(args[2]); } catch (std::invalid_argument const& ex) { - SPDLOG_ERROR("[SOH] Bottle slot must be an integer."); + SohImGui::console->SendErrorMessage("[SOH] Bottle slot must be an integer."); return CMD_FAILED; } if ((slot < 1) || (slot > 4)) { - SPDLOG_ERROR("Invalid slot passed"); + SohImGui::console->SendErrorMessage("Invalid slot passed"); return CMD_FAILED; } const auto& it = bottleItems.find(args[1]); if (it == bottleItems.end()) { - SPDLOG_ERROR("Invalid item passed"); + SohImGui::console->SendErrorMessage("Invalid item passed"); return CMD_FAILED; } @@ -271,7 +272,7 @@ static bool BottleHandler(const std::vector& args) { static bool BHandler(const std::vector& args) { if (args.size() != 2) { - SPDLOG_ERROR("[SOH] Unexpected arguments passed"); + SohImGui::console->SendErrorMessage("[SOH] Unexpected arguments passed"); return CMD_FAILED; } @@ -281,7 +282,7 @@ static bool BHandler(const std::vector& args) { static bool ItemHandler(const std::vector& args) { if (args.size() != 3) { - SPDLOG_ERROR("[SOH] Unexpected arguments passed"); + SohImGui::console->SendErrorMessage("[SOH] Unexpected arguments passed"); return CMD_FAILED; } @@ -292,7 +293,7 @@ static bool ItemHandler(const std::vector& args) { static bool EntranceHandler(const std::vector& args) { if (args.size() != 2) { - SPDLOG_ERROR("[SOH] Unexpected arguments passed"); + SohImGui::console->SendErrorMessage("[SOH] Unexpected arguments passed"); return CMD_FAILED; } @@ -301,11 +302,11 @@ static bool EntranceHandler(const std::vector& args) { try { entrance = std::stoi(args[1], nullptr, 16); } catch (std::invalid_argument const& ex) { - SPDLOG_ERROR("[SOH] Entrance value must be a Hex number."); + SohImGui::console->SendErrorMessage("[SOH] Entrance value must be a Hex number."); return CMD_FAILED; } - gGlobalCtx->nextEntranceIndex = entrance; + gGlobalCtx->nextEntranceIndex = entrance; gGlobalCtx->sceneLoadFlag = 0x14; gGlobalCtx->fadeTransition = 11; gSaveContext.nextTransition = 11; @@ -317,10 +318,10 @@ static bool SaveStateHandler(const std::vector& args) { switch (rtn) { case SaveStateReturn::SUCCESS: - SPDLOG_INFO("[SOH] Saved state to slot {}", slot); + SohImGui::console->SendInfoMessage("[SOH] Saved state to slot %u", slot); return CMD_SUCCESS; case SaveStateReturn::FAIL_WRONG_GAMESTATE: - SPDLOG_ERROR("[SOH] Can not save a state outside of \"GamePlay\""); + SohImGui::console->SendErrorMessage("[SOH] Can not save a state outside of \"GamePlay\""); return CMD_FAILED; } @@ -332,16 +333,16 @@ static bool LoadStateHandler(const std::vector& args) { switch (rtn) { case SaveStateReturn::SUCCESS: - SPDLOG_INFO("[SOH] Loaded state from slot ({})", slot); + SohImGui::console->SendInfoMessage("[SOH] Loaded state from slot (%u)", slot); return CMD_SUCCESS; case SaveStateReturn::FAIL_INVALID_SLOT: - SPDLOG_ERROR("[SOH] Invalid State Slot Number ({})", slot); + SohImGui::console->SendErrorMessage("[SOH] Invalid State Slot Number (%u)", slot); return CMD_FAILED; case SaveStateReturn::FAIL_STATE_EMPTY: - SPDLOG_ERROR("[SOH] State Slot ({}) is empty", slot); + SohImGui::console->SendErrorMessage("[SOH] State Slot (%u) is empty", slot); return CMD_FAILED; case SaveStateReturn::FAIL_WRONG_GAMESTATE: - SPDLOG_ERROR("[SOH] Can not load a state outside of \"GamePlay\""); + SohImGui::console->SendErrorMessage("[SOH] Can not load a state outside of \"GamePlay\""); return CMD_FAILED; } @@ -349,7 +350,7 @@ static bool LoadStateHandler(const std::vector& args) { static bool StateSlotSelectHandler(const std::vector& args) { if (args.size() != 2) { - SPDLOG_ERROR("[SOH] Unexpected arguments passed"); + SohImGui::console->SendErrorMessage("[SOH] Unexpected arguments passed"); return CMD_FAILED; } int slot; @@ -357,17 +358,18 @@ static bool StateSlotSelectHandler(const std::vector& args) { try { slot = std::stoi(args[1], nullptr, 10); } catch (std::invalid_argument const& ex) { - SPDLOG_ERROR("[SOH] SaveState slot value must be a number."); + SohImGui::console->SendErrorMessage("[SOH] SaveState slot value must be a number."); return CMD_FAILED; } if (slot < 0) { - SPDLOG_ERROR("[SOH] Invalid slot passed. Slot must be between 0 and 2"); + SohImGui::console->SendErrorMessage("[SOH] Invalid slot passed. Slot must be between 0 and 2"); return CMD_FAILED; } OTRGlobals::Instance->gSaveStateMgr->SetCurrentSlot(slot); - SPDLOG_INFO("[SOH] Slot {} selected", OTRGlobals::Instance->gSaveStateMgr->GetCurrentSlot()); + SohImGui::console->SendInfoMessage("[SOH] Slot %u selected", + OTRGlobals::Instance->gSaveStateMgr->GetCurrentSlot()); return CMD_SUCCESS; } @@ -427,7 +429,7 @@ static bool SetCVarHandler(const std::vector& args) { CVar_Save(); - //INFO("[SOH] Updated player position to [ %.2f, %.2f, %.2f ]", pos.x, pos.y, pos.z); + //SohImGui::console->SendInfoMessage("[SOH] Updated player position to [ %.2f, %.2f, %.2f ]", pos.x, pos.y, pos.z); return CMD_SUCCESS; } @@ -441,18 +443,17 @@ static bool GetCVarHandler(const std::vector& args) { if (cvar != nullptr) { if (cvar->type == CVarType::S32) - SPDLOG_INFO("[SOH] Variable {} is {}", args[1], cvar->value.valueS32); + SohImGui::console->SendInfoMessage("[SOH] Variable %s is %i", args[1].c_str(), cvar->value.valueS32); else if (cvar->type == CVarType::Float) - SPDLOG_INFO("[SOH] Variable {} is {}", args[1], cvar->value.valueFloat); + SohImGui::console->SendInfoMessage("[SOH] Variable %s is %f", args[1].c_str(), cvar->value.valueFloat); else if (cvar->type == CVarType::String) - SPDLOG_INFO("[SOH] Variable {} is {}", args[1], cvar->value.valueStr); + SohImGui::console->SendInfoMessage("[SOH] Variable %s is %s", args[1].c_str(), cvar->value.valueStr); else if (cvar->type == CVarType::RGBA) - SPDLOG_INFO("[SOH] Variable {} is ({}, {}, {}, {})", args[1], cvar->value.valueRGBA.r, - cvar->value.valueRGBA.g, cvar->value.valueRGBA.b, cvar->value.valueRGBA.a); + SohImGui::console->SendInfoMessage("[SOH] Variable %s is %08X", args[1].c_str(), cvar->value.valueRGBA); } else { - SPDLOG_INFO("[SOH] Could not find variable %s", args[1]); + SohImGui::console->SendInfoMessage("[SOH] Could not find variable %s", args[1].c_str()); } From a4804d72905e7eb84d2f7ec4bce4f9157bf69188 Mon Sep 17 00:00:00 2001 From: Kenix3 Date: Tue, 9 Aug 2022 22:16:14 -0400 Subject: [PATCH 63/71] No longer passing in C strings to SendInfoMessage formatted overload. --- libultraship/libultraship/Console.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libultraship/libultraship/Console.cpp b/libultraship/libultraship/Console.cpp index 6990d4343..efc13ca2c 100644 --- a/libultraship/libultraship/Console.cpp +++ b/libultraship/libultraship/Console.cpp @@ -45,7 +45,7 @@ namespace Ship { std::ostringstream imploded; std::copy(args.begin() + 2, args.end(), std::ostream_iterator(imploded, delim)); Bindings[k] = imploded.str(); - SohImGui::console->SendInfoMessage("Binding '%s' to %s", args[1], Bindings[k]); + SohImGui::console->SendInfoMessage("Binding '%s' to %s", args[1].c_str(), Bindings[k].c_str()); break; } } From 7b115090101316b7072f87a2271fec3387f62bed Mon Sep 17 00:00:00 2001 From: Kenix3 Date: Tue, 9 Aug 2022 22:25:55 -0400 Subject: [PATCH 64/71] Fixes missed Switch specific invocation of old Console logging macros. --- libultraship/libultraship/ImGuiImpl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libultraship/libultraship/ImGuiImpl.cpp b/libultraship/libultraship/ImGuiImpl.cpp index a583b3d9c..cd2ca1af3 100644 --- a/libultraship/libultraship/ImGuiImpl.cpp +++ b/libultraship/libultraship/ImGuiImpl.cpp @@ -1530,7 +1530,7 @@ namespace SohImGui { if (ImGui::BeginCombo("##perf", SWITCH_CPU_PROFILES[slot])) { for (int sId = 0; sId <= SwitchProfiles::POWERSAVINGM3; sId++) { if (ImGui::Selectable(SWITCH_CPU_PROFILES[sId], sId == slot)) { - INFO("Profile:: %s", SWITCH_CPU_PROFILES[sId]); + SPDLOG_INFO("Profile:: %s", SWITCH_CPU_PROFILES[sId]); CVar_SetS32("gSwitchPerfMode", sId); Switch::ApplyOverclock(); needs_save = true; From 96c20333619751318b97e9fd0a22df5d68186145 Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Tue, 9 Aug 2022 22:50:25 -0400 Subject: [PATCH 65/71] fix linux release mode crash (#1124) Co-authored-by: briaguya --- soh/soh/Enhancements/custom-message/CustomMessageManager.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/soh/soh/Enhancements/custom-message/CustomMessageManager.cpp b/soh/soh/Enhancements/custom-message/CustomMessageManager.cpp index d7dd08991..8a42bef95 100644 --- a/soh/soh/Enhancements/custom-message/CustomMessageManager.cpp +++ b/soh/soh/Enhancements/custom-message/CustomMessageManager.cpp @@ -118,6 +118,7 @@ bool CustomMessageManager::ClearMessageTable(std::string tableID) { } auto& messageTable = foundMessageTable->second; messageTable.clear(); + return true; } bool CustomMessageManager::AddCustomMessageTable(std::string tableID) { From 797d9fab7cbf300af1d10fc25ca10e5fff737755 Mon Sep 17 00:00:00 2001 From: Kenix3 Date: Tue, 9 Aug 2022 23:14:31 -0400 Subject: [PATCH 66/71] GameOverlay command handler no longer uses SPDLOG and prints to console. --- libultraship/libultraship/GameOverlay.cpp | 70 +++++++++++------------ libultraship/libultraship/GameOverlay.h | 2 - 2 files changed, 34 insertions(+), 38 deletions(-) diff --git a/libultraship/libultraship/GameOverlay.cpp b/libultraship/libultraship/GameOverlay.cpp index 8fe028667..1a3a1e3bb 100644 --- a/libultraship/libultraship/GameOverlay.cpp +++ b/libultraship/libultraship/GameOverlay.cpp @@ -9,6 +9,40 @@ #include "Utils/StringHelper.h" namespace Ship { + bool OverlayCommand(std::shared_ptr Console, const std::vector& args) { + if (args.size() < 3) { + return CMD_FAILED; + } + + if (CVar_Get(args[2].c_str()) != nullptr) { + const char* key = args[2].c_str(); + GameOverlay* overlay = SohImGui::overlay; + if (args[1] == "add") { + if (!overlay->RegisteredOverlays.contains(key)) { + overlay->RegisteredOverlays[key] = new Overlay({ OverlayType::TEXT, ImStrdup(key), -1.0f }); + SohImGui::console->SendInfoMessage("Added overlay: %s", key); + } + else { + SohImGui::console->SendErrorMessage("Overlay already exists: %s", key); + } + } + else if (args[1] == "remove") { + if (overlay->RegisteredOverlays.contains(key)) { + overlay->RegisteredOverlays.erase(key); + SohImGui::console->SendInfoMessage("Removed overlay: %s", key); + } + else { + SohImGui::console->SendErrorMessage("Overlay not found: %s", key); + } + } + } + else { + SohImGui::console->SendErrorMessage("CVar {} does not exist", args[2].c_str()); + } + + return CMD_SUCCESS; + } + void GameOverlay::LoadFont(const std::string& name, const std::string& path, float fontSize) { ImGuiIO& io = ImGui::GetIO(); std::shared_ptr base = GlobalCtx2::GetInstance()->GetResourceManager()->GetArchive(); @@ -195,40 +229,4 @@ namespace Ship { ImGui::End(); } - - - bool OverlayCommand(const std::vector& args) { - if (args.size() < 3) { - return CMD_FAILED; - } - - if (CVar_Get(args[2].c_str()) != nullptr) { - const char* key = args[2].c_str(); - GameOverlay* overlay = SohImGui::overlay; - if (args[1] == "add") { - if (!overlay->RegisteredOverlays.contains(key)) { - overlay->RegisteredOverlays[key] = new Overlay({ OverlayType::TEXT, ImStrdup(key), -1.0f }); - SPDLOG_INFO("Added overlay: {} ", key); - SohImGui::console->SendInfoMessage("Added overlay: %s", key); - } - else { - SPDLOG_ERROR("Overlay already exists: {}", key); - } - } - else if (args[1] == "remove") { - if (overlay->RegisteredOverlays.contains(key)) { - overlay->RegisteredOverlays.erase(key); - SPDLOG_INFO("Removed overlay: {} ", key); - } - else { - SPDLOG_ERROR("Overlay not found: {}", key); - } - } - } - else { - SPDLOG_ERROR("CVar {} does not exist", args[2].c_str()); - } - - return CMD_SUCCESS; - } } diff --git a/libultraship/libultraship/GameOverlay.h b/libultraship/libultraship/GameOverlay.h index 061d259ba..57bc41864 100644 --- a/libultraship/libultraship/GameOverlay.h +++ b/libultraship/libultraship/GameOverlay.h @@ -37,6 +37,4 @@ namespace Ship { void CleanupNotifications(); void LoadFont(const std::string& name, const std::string& path, float fontSize); }; - - bool OverlayCommand(const std::vector& args); } From 81cd5947045fb73a7f169a966618769c43896708 Mon Sep 17 00:00:00 2001 From: Kenix3 Date: Tue, 9 Aug 2022 23:15:07 -0400 Subject: [PATCH 67/71] Console now exposes commands with a reference to itself. --- libultraship/libultraship/Console.cpp | 45 ++++++++++--------------- libultraship/libultraship/Console.h | 16 +++++---- libultraship/libultraship/ImGuiImpl.cpp | 8 ++--- libultraship/libultraship/ImGuiImpl.h | 2 +- libultraship/libultraship/Utils.cpp | 7 ++++ libultraship/libultraship/Utils.h | 1 + soh/soh/Enhancements/debugconsole.cpp | 36 ++++++++++---------- 7 files changed, 59 insertions(+), 56 deletions(-) diff --git a/libultraship/libultraship/Console.cpp b/libultraship/libultraship/Console.cpp index efc13ca2c..d93a4e500 100644 --- a/libultraship/libultraship/Console.cpp +++ b/libultraship/libultraship/Console.cpp @@ -1,20 +1,22 @@ #include "Console.h" -#include -#include - #include "Cvar.h" #include "GlobalCtx2.h" #include "ImGuiImpl.h" #include "Lib/ImGui/imgui.h" #include "Utils/StringHelper.h" #include "Lib/ImGui/imgui_internal.h" +#include "Utils.h" namespace Ship { - std::map Bindings; - std::map BindingToggle; + std::string BuildUsage(const CommandEntry& entry) { + std::string usage; + for (const auto& arg : entry.arguments) + usage += StringHelper::Sprintf(arg.optional ? "[%s] " : "<%s> ", arg.info.c_str()); + return usage; + } - static bool HelpCommand(const std::vector&) { + static bool HelpCommand(std::shared_ptr Console, const std::vector& args) { SohImGui::console->SendInfoMessage("SoH Commands:"); for (const auto& cmd : SohImGui::console->Commands) { SohImGui::console->SendInfoMessage(" - " + cmd.first); @@ -22,18 +24,12 @@ namespace Ship { return CMD_SUCCESS; } - static bool ClearCommand(const std::vector&) { + static bool ClearCommand(std::shared_ptr Console, const std::vector& args) { SohImGui::console->Log[SohImGui::console->selected_channel].clear(); return CMD_SUCCESS; } - std::string toLowerCase(std::string in) { - std::string cpy(in); - std::transform(cpy.begin(), cpy.end(), cpy.begin(), ::tolower); - return cpy; - } - - static bool BindCommand(const std::vector& args) { + static bool BindCommand(std::shared_ptr Console, const std::vector& args) { if (args.size() > 2) { const ImGuiIO* io = &ImGui::GetIO();; for (size_t k = 0; k < std::size(io->KeysData); k++) { @@ -44,8 +40,8 @@ namespace Ship { const char* const delim = " "; std::ostringstream imploded; std::copy(args.begin() + 2, args.end(), std::ostream_iterator(imploded, delim)); - Bindings[k] = imploded.str(); - SohImGui::console->SendInfoMessage("Binding '%s' to %s", args[1].c_str(), Bindings[k].c_str()); + Console->Bindings[k] = imploded.str(); + SohImGui::console->SendInfoMessage("Binding '%s' to %s", args[1].c_str(), Console->Bindings[k].c_str()); break; } } @@ -53,15 +49,15 @@ namespace Ship { return CMD_SUCCESS; } - static bool BindToggleCommand(const std::vector& args) { + static bool BindToggleCommand(std::shared_ptr Console, const std::vector& args) { if (args.size() > 2) { const ImGuiIO* io = &ImGui::GetIO();; for (size_t k = 0; k < std::size(io->KeysData); k++) { std::string key(ImGui::GetKeyName(k)); if (toLowerCase(args[1]) == toLowerCase(key)) { - BindingToggle[k] = args[2]; - SohImGui::console->SendInfoMessage("Binding toggle '%s' to %s", args[1].c_str(), BindingToggle[k].c_str()); + Console->BindingToggle[k] = args[2]; + SohImGui::console->SendInfoMessage("Binding toggle '%s' to %s", args[1].c_str(), Console->BindingToggle[k].c_str()); break; } } @@ -69,13 +65,6 @@ namespace Ship { return CMD_SUCCESS; } - std::string BuildUsage(const CommandEntry& entry) { - std::string usage; - for (const auto& arg : entry.arguments) - usage += StringHelper::Sprintf(arg.optional ? "[%s] " : "<%s> ", arg.info.c_str()); - return usage; - } - void Console::Init() { this->InputBuffer = new char[MAX_BUFFER_SIZE]; strcpy(this->InputBuffer, ""); @@ -281,8 +270,10 @@ namespace Ship { const std::vector cmd_args = StringHelper::Split(line, " "); if (this->Commands.contains(cmd_args[0])) { const CommandEntry entry = this->Commands[cmd_args[0]]; - if (!entry.handler(cmd_args) && !entry.arguments.empty()) + if (!entry.handler(shared_from_this(), cmd_args) && !entry.arguments.empty()) { SendErrorMessage("[SOH] Usage: " + cmd_args[0] + " " + BuildUsage(entry)); + } + return; } SendErrorMessage("[SOH] Command not found"); diff --git a/libultraship/libultraship/Console.h b/libultraship/libultraship/Console.h index 00ca518e2..e81964aee 100644 --- a/libultraship/libultraship/Console.h +++ b/libultraship/libultraship/Console.h @@ -16,7 +16,8 @@ namespace Ship { #define MAX_BUFFER_SIZE 255 #define NULLSTR "None" - typedef std::function args)> CommandHandler; + class Console; + typedef std::function Console, std::vector args)> CommandHandler; enum class ArgumentType { TEXT, NUMBER, PLAYER_POS, PLAYER_ROT @@ -40,14 +41,15 @@ namespace Ship { std::string channel = "Console"; }; - class Console { + class Console : public std::enable_shared_from_this { + private: int selectedId = -1; std::vector selectedEntries; std::string filter; spdlog::level::level_enum level_filter = spdlog::level::trace; - std::vector log_channels = { "Console", "Logs" }; - std::vector priority_filters = { spdlog::level::off, spdlog::level::critical, spdlog::level::err, spdlog::level::warn, spdlog::level::info, spdlog::level::debug, spdlog::level::trace }; - std::vector priority_colors = { + const std::vector log_channels = { "Console", "Logs" }; + const std::vector priority_filters = { spdlog::level::off, spdlog::level::critical, spdlog::level::err, spdlog::level::warn, spdlog::level::info, spdlog::level::debug, spdlog::level::trace }; + const std::vector priority_colors = { ImVec4(0.8f, 0.8f, 0.8f, 1.0f), // TRACE ImVec4(0.9f, 0.9f, 0.9f, 1.0f), // DEBUG ImVec4(1.0f, 1.0f, 1.0f, 1.0f), // INFO @@ -60,6 +62,8 @@ namespace Ship { void Append(const std::string& channel, spdlog::level::level_enum priority, const char* fmt, va_list args); public: + std::map Bindings; + std::map BindingToggle; std::map> Log; std::map Commands; std::vector Autocomplete; @@ -69,8 +73,8 @@ namespace Ship { char* InputBuffer = nullptr; bool OpenAutocomplete = false; int HistoryIndex = -1; - std::string selected_channel = "Console"; bool opened = false; + std::string selected_channel = "Console"; void Init(); void Update(); void Draw(); diff --git a/libultraship/libultraship/ImGuiImpl.cpp b/libultraship/libultraship/ImGuiImpl.cpp index cd2ca1af3..b76739e7a 100644 --- a/libultraship/libultraship/ImGuiImpl.cpp +++ b/libultraship/libultraship/ImGuiImpl.cpp @@ -91,7 +91,7 @@ namespace SohImGui { WindowImpl impl; ImGuiIO* io; - Console* console = new Console; + std::shared_ptr console = std::make_shared(); GameOverlay* overlay = new GameOverlay; InputEditor* controller = new InputEditor; static ImVector s_GroupPanelLabelStack; @@ -863,7 +863,7 @@ namespace SohImGui { if ((ImGui::IsKeyDown(ImGuiKey_LeftCtrl) || ImGui::IsKeyDown(ImGuiKey_RightCtrl)) && ImGui::IsKeyPressed(ImGuiKey_R, false)) { - console->Commands["reset"].handler(emptyArgs); + console->Commands["reset"].handler(console, emptyArgs); } #endif @@ -891,7 +891,7 @@ namespace SohImGui { "Ctrl+R" #endif )) { - console->Commands["reset"].handler(emptyArgs); + console->Commands["reset"].handler(console, emptyArgs); } ImGui::EndMenu(); } @@ -1638,7 +1638,7 @@ namespace SohImGui { CVar_SetS32("gEnableBetaQuest", betaQuestEnabled); CVar_SetS32("gBetaQuestWorld", betaQuestWorld); - console->Commands["reset"].handler(emptyArgs); + console->Commands["reset"].handler(console, emptyArgs); needs_save = true; } diff --git a/libultraship/libultraship/ImGuiImpl.h b/libultraship/libultraship/ImGuiImpl.h index fd0aced6a..8e20d415c 100644 --- a/libultraship/libultraship/ImGuiImpl.h +++ b/libultraship/libultraship/ImGuiImpl.h @@ -69,7 +69,7 @@ namespace SohImGui { WindowDrawFunc drawFunc; } CustomWindow; - extern Ship::Console* console; + extern std::shared_ptr console; extern Ship::InputEditor* controller; extern Ship::GameOverlay* overlay; extern bool needs_save; diff --git a/libultraship/libultraship/Utils.cpp b/libultraship/libultraship/Utils.cpp index 185c21c24..6d0e50f5c 100644 --- a/libultraship/libultraship/Utils.cpp +++ b/libultraship/libultraship/Utils.cpp @@ -1,5 +1,6 @@ #include "Utils.h" #include +#include #ifdef _MSC_VER #define strdup _strdup @@ -58,4 +59,10 @@ namespace Ship { return args; } + + std::string toLowerCase(std::string in) { + std::string cpy(in); + std::transform(cpy.begin(), cpy.end(), cpy.begin(), ::tolower); + return cpy; + } } diff --git a/libultraship/libultraship/Utils.h b/libultraship/libultraship/Utils.h index 1dc3d3491..256db35e7 100644 --- a/libultraship/libultraship/Utils.h +++ b/libultraship/libultraship/Utils.h @@ -10,4 +10,5 @@ namespace Ship { } std::vector SplitText(const std::string& text, char separator, bool keep_quotes); + std::string toLowerCase(std::string in); } \ No newline at end of file diff --git a/soh/soh/Enhancements/debugconsole.cpp b/soh/soh/Enhancements/debugconsole.cpp index 203e5521a..8e72392ca 100644 --- a/soh/soh/Enhancements/debugconsole.cpp +++ b/soh/soh/Enhancements/debugconsole.cpp @@ -5,6 +5,7 @@ #include "debugconsole.h" #include "../libultraship/ImGuiImpl.h" #include "savestates.h" +#include "Console.h" #include #include @@ -32,7 +33,7 @@ extern GlobalContext* gGlobalCtx; #define CMD_REGISTER SohImGui::BindCmd -static bool ActorSpawnHandler(const std::vector& args) { +static bool ActorSpawnHandler(std::shared_ptr Console, const std::vector& args) { if ((args.size() != 9) && (args.size() != 3) && (args.size() != 6)) { SohImGui::console->SendErrorMessage("Not enough arguments passed to actorspawn"); return CMD_FAILED; @@ -82,13 +83,13 @@ static bool ActorSpawnHandler(const std::vector& args) { } -static bool KillPlayerHandler([[maybe_unused]] const std::vector&) { +static bool KillPlayerHandler(std::shared_ptr Console, const std::vector&) { gSaveContext.health = 0; SohImGui::console->SendInfoMessage("[SOH] You've met with a terrible fate, haven't you?"); return CMD_SUCCESS; } -static bool SetPlayerHealthHandler(const std::vector& args) { +static bool SetPlayerHealthHandler(std::shared_ptr Console, const std::vector& args) { if (args.size() != 2) { SohImGui::console->SendErrorMessage("[SOH] Unexpected arguments passed"); return CMD_FAILED; @@ -115,7 +116,7 @@ static bool SetPlayerHealthHandler(const std::vector& args) { } -static bool LoadSceneHandler(const std::vector&) { +static bool LoadSceneHandler(std::shared_ptr Console, const std::vector&) { gSaveContext.respawnFlag = 0; gSaveContext.seqId = 0xFF; gSaveContext.gameMode = 0; @@ -123,7 +124,7 @@ static bool LoadSceneHandler(const std::vector&) { return CMD_SUCCESS; } -static bool RuppeHandler(const std::vector& args) { +static bool RuppeHandler(std::shared_ptr Console, const std::vector& args) { if (args.size() < 2) return CMD_FAILED; @@ -147,7 +148,7 @@ static bool RuppeHandler(const std::vector& args) { return CMD_SUCCESS; } -static bool SetPosHandler(const std::vector args) { +static bool SetPosHandler(std::shared_ptr Console, const std::vector args) { if (gGlobalCtx == nullptr) { SohImGui::console->SendErrorMessage("GlobalCtx == nullptr"); return CMD_FAILED; @@ -174,7 +175,7 @@ static bool SetPosHandler(const std::vector args) { return CMD_SUCCESS; } -static bool ResetHandler(std::vector args) { +static bool ResetHandler(std::shared_ptr Console, std::vector args) { if (gGlobalCtx == nullptr) { SohImGui::console->SendErrorMessage("GlobalCtx == nullptr"); return CMD_FAILED; @@ -195,7 +196,7 @@ const static std::map ammoItems{ { "magic_beans", ITEM_BEAN }, }; -static bool AmmoHandler(const std::vector& args) { +static bool AmmoHandler(std::shared_ptr Console, const std::vector& args) { if (args.size() != 3) { SohImGui::console->SendErrorMessage("[SOH] Unexpected arguments passed"); return CMD_FAILED; @@ -238,7 +239,7 @@ const static std::map bottleItems{ { "big_poe", ITEM_BIG_POE }, { "blue_fire", ITEM_BLUE_FIRE }, { "rutos_letter", ITEM_LETTER_RUTO }, }; -static bool BottleHandler(const std::vector& args) { +static bool BottleHandler(std::shared_ptr Console, const std::vector& args) { if (args.size() != 3) { SohImGui::console->SendErrorMessage("[SOH] Unexpected arguments passed"); return CMD_FAILED; @@ -270,7 +271,7 @@ static bool BottleHandler(const std::vector& args) { return CMD_SUCCESS; } -static bool BHandler(const std::vector& args) { +static bool BHandler(std::shared_ptr Console, const std::vector& args) { if (args.size() != 2) { SohImGui::console->SendErrorMessage("[SOH] Unexpected arguments passed"); return CMD_FAILED; @@ -280,7 +281,7 @@ static bool BHandler(const std::vector& args) { return CMD_SUCCESS; } -static bool ItemHandler(const std::vector& args) { +static bool ItemHandler(std::shared_ptr Console, const std::vector& args) { if (args.size() != 3) { SohImGui::console->SendErrorMessage("[SOH] Unexpected arguments passed"); return CMD_FAILED; @@ -291,7 +292,7 @@ static bool ItemHandler(const std::vector& args) { return CMD_SUCCESS; } -static bool EntranceHandler(const std::vector& args) { +static bool EntranceHandler(std::shared_ptr Console, const std::vector& args) { if (args.size() != 2) { SohImGui::console->SendErrorMessage("[SOH] Unexpected arguments passed"); return CMD_FAILED; @@ -312,7 +313,7 @@ static bool EntranceHandler(const std::vector& args) { gSaveContext.nextTransition = 11; } -static bool SaveStateHandler(const std::vector& args) { +static bool SaveStateHandler(std::shared_ptr Console, const std::vector& args) { unsigned int slot = OTRGlobals::Instance->gSaveStateMgr->GetCurrentSlot(); const SaveStateReturn rtn = OTRGlobals::Instance->gSaveStateMgr->AddRequest({ slot, RequestType::SAVE }); @@ -323,11 +324,10 @@ static bool SaveStateHandler(const std::vector& args) { case SaveStateReturn::FAIL_WRONG_GAMESTATE: SohImGui::console->SendErrorMessage("[SOH] Can not save a state outside of \"GamePlay\""); return CMD_FAILED; - } } -static bool LoadStateHandler(const std::vector& args) { +static bool LoadStateHandler(std::shared_ptr Console, const std::vector& args) { unsigned int slot = OTRGlobals::Instance->gSaveStateMgr->GetCurrentSlot(); const SaveStateReturn rtn = OTRGlobals::Instance->gSaveStateMgr->AddRequest({ slot, RequestType::LOAD }); @@ -348,7 +348,7 @@ static bool LoadStateHandler(const std::vector& args) { } -static bool StateSlotSelectHandler(const std::vector& args) { +static bool StateSlotSelectHandler(std::shared_ptr Console, const std::vector& args) { if (args.size() != 2) { SohImGui::console->SendErrorMessage("[SOH] Unexpected arguments passed"); return CMD_FAILED; @@ -404,7 +404,7 @@ static int CheckVarType(const std::string& input) return result; } -static bool SetCVarHandler(const std::vector& args) { +static bool SetCVarHandler(std::shared_ptr Console, const std::vector& args) { if (args.size() < 3) return CMD_FAILED; @@ -434,7 +434,7 @@ static bool SetCVarHandler(const std::vector& args) { } -static bool GetCVarHandler(const std::vector& args) { +static bool GetCVarHandler(std::shared_ptr Console, const std::vector& args) { if (args.size() < 2) return CMD_FAILED; From 23fb885e09e03226b7a966b0242707488c4f4fe9 Mon Sep 17 00:00:00 2001 From: Kenix3 Date: Tue, 9 Aug 2022 23:50:21 -0400 Subject: [PATCH 68/71] Console class is now a proper object oriented class. --- libultraship/libultraship/Console.cpp | 146 +++++++++++------- libultraship/libultraship/Console.h | 51 +++--- libultraship/libultraship/GameOverlay.cpp | 3 +- libultraship/libultraship/ImGuiImpl.cpp | 20 ++- .../include/spdlog/sinks/sohconsole_sink.h | 2 +- 5 files changed, 136 insertions(+), 86 deletions(-) diff --git a/libultraship/libultraship/Console.cpp b/libultraship/libultraship/Console.cpp index d93a4e500..5780453e7 100644 --- a/libultraship/libultraship/Console.cpp +++ b/libultraship/libultraship/Console.cpp @@ -16,7 +16,7 @@ namespace Ship { return usage; } - static bool HelpCommand(std::shared_ptr Console, const std::vector& args) { + bool Console::HelpCommand(std::shared_ptr Console, const std::vector& args) { SohImGui::console->SendInfoMessage("SoH Commands:"); for (const auto& cmd : SohImGui::console->Commands) { SohImGui::console->SendInfoMessage(" - " + cmd.first); @@ -24,12 +24,12 @@ namespace Ship { return CMD_SUCCESS; } - static bool ClearCommand(std::shared_ptr Console, const std::vector& args) { - SohImGui::console->Log[SohImGui::console->selected_channel].clear(); + bool Console::ClearCommand(std::shared_ptr Console, const std::vector& args) { + Console->ClearLogs(Console->GetCurrentChannel()); return CMD_SUCCESS; } - static bool BindCommand(std::shared_ptr Console, const std::vector& args) { + bool Console::BindCommand(std::shared_ptr Console, const std::vector& args) { if (args.size() > 2) { const ImGuiIO* io = &ImGui::GetIO();; for (size_t k = 0; k < std::size(io->KeysData); k++) { @@ -49,7 +49,7 @@ namespace Ship { return CMD_SUCCESS; } - static bool BindToggleCommand(std::shared_ptr Console, const std::vector& args) { + bool Console::BindToggleCommand(std::shared_ptr Console, const std::vector& args) { if (args.size() > 2) { const ImGuiIO* io = &ImGui::GetIO();; for (size_t k = 0; k < std::size(io->KeysData); k++) { @@ -66,14 +66,14 @@ namespace Ship { } void Console::Init() { - this->InputBuffer = new char[MAX_BUFFER_SIZE]; - strcpy(this->InputBuffer, ""); - this->FilterBuffer = new char[MAX_BUFFER_SIZE]; - strcpy(this->FilterBuffer, ""); - this->Commands["help"] = { HelpCommand, "Shows all the commands" }; - this->Commands["clear"] = { ClearCommand, "Clear the console history" }; - this->Commands["bind"] = { BindCommand, "Binds key to commands" }; - this->Commands["bind-toggle"] = { BindToggleCommand, "Bind key as a bool toggle" }; + this->inputBuffer = new char[MAX_BUFFER_SIZE]; + strcpy(this->inputBuffer, ""); + this->filterBuffer = new char[MAX_BUFFER_SIZE]; + strcpy(this->filterBuffer, ""); + AddCommand("help", { HelpCommand, "Shows all the commands" }); + AddCommand("help", { ClearCommand, "Clear the console history" }); + AddCommand("help", { BindCommand, "Binds key to commands" }); + AddCommand("help", { BindToggleCommand, "Bind key as a bool toggle" }); } void Console::Update() { @@ -103,7 +103,7 @@ namespace Ship { // SohImGui::ShowCursor(ImGui::IsWindowHovered(ImGuiHoveredFlags_RootAndChildWindows | ImGuiHoveredFlags_RectOnly), SohImGui::Dialogues::dConsole); // Renders autocomplete window - if (this->OpenAutocomplete) { + if (this->openAutocomplete) { ImGui::SetNextWindowSize(ImVec2(350, std::min(static_cast(this->Autocomplete.size()), 3) * 20.f), ImGuiCond_Once); ImGui::SetNextWindowPos(ImVec2(pos.x + 8, pos.y + size.y - 1)); ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(3, 3)); @@ -118,16 +118,16 @@ namespace Ship { ImGui::TableNextRow(); ImGui::TableSetColumnIndex(0); if (ImGui::Selectable(preview.c_str())) { - memset(this->InputBuffer, 0, MAX_BUFFER_SIZE); - memcpy(this->InputBuffer, autocomplete.c_str(), sizeof(char) * autocomplete.size()); - this->OpenAutocomplete = false; + memset(this->inputBuffer, 0, MAX_BUFFER_SIZE); + memcpy(this->inputBuffer, autocomplete.c_str(), sizeof(char) * autocomplete.size()); + this->openAutocomplete = false; input_focus = true; } } ImGui::EndTable(); } if (ImGui::IsKeyPressed(ImGuiKey_Escape)) { - this->OpenAutocomplete = false; + this->openAutocomplete = false; } ImGui::PopStyleColor(); ImGui::EndChild(); @@ -137,7 +137,7 @@ namespace Ship { if (ImGui::BeginPopupContextWindow("Context Menu")) { if (ImGui::MenuItem("Copy Text")) { - ImGui::SetClipboardText(this->Log[this->selected_channel][this->selectedId].text.c_str()); + ImGui::SetClipboardText(this->Log[this->currentChannel][this->selectedId].text.c_str()); this->selectedId = -1; } ImGui::EndPopup(); @@ -147,44 +147,44 @@ namespace Ship { } // Renders top bar filters - if (ImGui::Button("Clear")) this->Log[this->selected_channel].clear(); + if (ImGui::Button("Clear")) this->Log[this->currentChannel].clear(); if (CVar_GetS32("gSinkEnabled", 0)) { ImGui::SameLine(); ImGui::SetNextItemWidth(150); - if (ImGui::BeginCombo("##channel", this->selected_channel.c_str())) { - for (const auto& channel : log_channels) { - const bool is_selected = (channel == std::string(this->selected_channel)); + if (ImGui::BeginCombo("##channel", this->currentChannel.c_str())) { + for (const auto& channel : LogChannels) { + const bool is_selected = (channel == std::string(this->currentChannel)); if (ImGui::Selectable(channel.c_str(), is_selected)) - this->selected_channel = channel; + this->currentChannel = channel; if (is_selected) ImGui::SetItemDefaultFocus(); } ImGui::EndCombo(); } } else { - this->selected_channel = "Console"; + this->currentChannel = "Console"; } ImGui::SameLine(); ImGui::SetNextItemWidth(150); - if (this->selected_channel != "Console") { - if (ImGui::BeginCombo("##level", spdlog::level::to_string_view(this->level_filter).data())) { - for (const auto& priority_filter : priority_filters) { - const bool is_selected = priority_filter == this->level_filter; + if (this->currentChannel != "Console") { + if (ImGui::BeginCombo("##level", spdlog::level::to_string_view(this->levelFilter).data())) { + for (const auto& priority_filter : PriorityFilters) { + const bool is_selected = priority_filter == this->levelFilter; if (ImGui::Selectable(spdlog::level::to_string_view(priority_filter).data(), is_selected)) { - this->level_filter = priority_filter; + this->levelFilter = priority_filter; if (is_selected) ImGui::SetItemDefaultFocus(); } } ImGui::EndCombo(); } } else { - this->level_filter = spdlog::level::trace; + this->levelFilter = spdlog::level::trace; } ImGui::SameLine(); ImGui::PushItemWidth(-1); - if (ImGui::InputTextWithHint("##input", "Filter", this->FilterBuffer, MAX_BUFFER_SIZE))this->filter = std::string(this->FilterBuffer); + if (ImGui::InputTextWithHint("##input", "Filter", this->filterBuffer, MAX_BUFFER_SIZE))this->filter = std::string(this->filterBuffer); ImGui::PopItemWidth(); // Renders console history @@ -198,16 +198,16 @@ namespace Ship { if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_UpArrow))) if (this->selectedId > 0)--this->selectedId; - const std::vector channel = this->Log[this->selected_channel]; + const std::vector channel = this->Log[this->currentChannel]; for (int i = 0; i < static_cast(channel.size()); i++) { ConsoleLine line = channel[i]; if (!this->filter.empty() && line.text.find(this->filter) == std::string::npos) continue; - if (this->level_filter > line.priority) continue; + if (this->levelFilter > line.priority) continue; std::string id = line.text + "##" + std::to_string(i); ImGui::TableNextRow(); ImGui::TableSetColumnIndex(0); const bool is_selected = (this->selectedId == i) || std::find(this->selectedEntries.begin(), this->selectedEntries.end(), i) != this->selectedEntries.end(); - ImGui::PushStyleColor(ImGuiCol_Text, this->priority_colors[line.priority]); + ImGui::PushStyleColor(ImGuiCol_Text, this->PriorityColours[line.priority]); if (ImGui::Selectable(id.c_str(), is_selected)) { if (ImGui::IsKeyDown(ImGui::GetKeyIndex(ImGuiKey_LeftCtrl)) && !is_selected) this->selectedEntries.push_back(i); @@ -225,25 +225,25 @@ namespace Ship { ImGui::SetScrollHereY(1.0f); ImGui::EndChild(); - if (this->selected_channel == "Console") { + if (this->currentChannel == "Console") { // Renders input textfield constexpr ImGuiInputTextFlags flags = ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_CallbackEdit | ImGuiInputTextFlags_CallbackCompletion | ImGuiInputTextFlags_CallbackHistory; ImGui::PushItemWidth(-53); - if (ImGui::InputTextWithHint("##CMDInput", ">", this->InputBuffer, MAX_BUFFER_SIZE, flags, &Console::CallbackStub, this)) { + if (ImGui::InputTextWithHint("##CMDInput", ">", this->inputBuffer, MAX_BUFFER_SIZE, flags, &Console::CallbackStub, this)) { input_focus = true; - if (this->InputBuffer[0] != '\0' && this->InputBuffer[0] != ' ') - this->Dispatch(std::string(this->InputBuffer)); - memset(this->InputBuffer, 0, MAX_BUFFER_SIZE); + if (this->inputBuffer[0] != '\0' && this->inputBuffer[0] != ' ') + this->Dispatch(std::string(this->inputBuffer)); + memset(this->inputBuffer, 0, MAX_BUFFER_SIZE); } - if (this->CMDHint != NULLSTR) { + if (this->cmdHint != NULLSTR) { if (ImGui::IsItemFocused()) { ImGui::SetNextWindowPos(ImVec2(pos.x, pos.y + size.y)); ImGui::SameLine(); ImGui::BeginTooltip(); ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f); - ImGui::TextUnformatted(this->CMDHint.c_str()); + ImGui::TextUnformatted(this->cmdHint.c_str()); ImGui::PopTextWrapPos(); ImGui::EndTooltip(); } @@ -251,9 +251,9 @@ namespace Ship { ImGui::SameLine(); ImGui::SetCursorPosX(ImGui::GetCursorPosX() + ImGui::GetContentRegionAvail().x - 50); - if (ImGui::Button("Submit") && !input_focus && this->InputBuffer[0] != '\0' && this->InputBuffer[0] != ' ') { - this->Dispatch(std::string(this->InputBuffer)); - memset(this->InputBuffer, 0, MAX_BUFFER_SIZE); + if (ImGui::Button("Submit") && !input_focus && this->inputBuffer[0] != '\0' && this->inputBuffer[0] != ' ') { + this->Dispatch(std::string(this->inputBuffer)); + memset(this->inputBuffer, 0, MAX_BUFFER_SIZE); } ImGui::SetItemDefaultFocus(); @@ -264,7 +264,7 @@ namespace Ship { } void Console::Dispatch(const std::string& line) { - this->CMDHint = NULLSTR; + this->cmdHint = NULLSTR; this->History.push_back(line); SendInfoMessage("> " + line); const std::vector cmd_args = StringHelper::Split(line, " "); @@ -282,7 +282,7 @@ namespace Ship { int Console::CallbackStub(ImGuiInputTextCallbackData* data) { const auto instance = static_cast(data->UserData); const bool empty_history = instance->History.empty(); - const int history_index = instance->HistoryIndex; + const int history_index = instance->historyIndex; std::string history; switch (data->EventKey) { @@ -290,39 +290,39 @@ namespace Ship { instance->Autocomplete.clear(); for (auto& [cmd, entry] : instance->Commands) if (cmd.find(std::string(data->Buf)) != std::string::npos) instance->Autocomplete.push_back(cmd); - instance->OpenAutocomplete = !instance->Autocomplete.empty(); - instance->CMDHint = NULLSTR; + instance->openAutocomplete = !instance->Autocomplete.empty(); + instance->cmdHint = NULLSTR; break; case ImGuiKey_UpArrow: if (empty_history) break; - if (history_index < static_cast(instance->History.size()) - 1) instance->HistoryIndex += 1; + if (history_index < static_cast(instance->History.size()) - 1) instance->historyIndex += 1; data->DeleteChars(0, data->BufTextLen); - data->InsertChars(0, instance->History[instance->HistoryIndex].c_str()); - instance->CMDHint = NULLSTR; + data->InsertChars(0, instance->History[instance->historyIndex].c_str()); + instance->cmdHint = NULLSTR; break; case ImGuiKey_DownArrow: if (empty_history) break; - if (history_index > -1) instance->HistoryIndex -= 1; + if (history_index > -1) instance->historyIndex -= 1; data->DeleteChars(0, data->BufTextLen); if (history_index >= 0) data->InsertChars(0, instance->History[history_index].c_str()); - instance->CMDHint = NULLSTR; + instance->cmdHint = NULLSTR; break; case ImGuiKey_Escape: - instance->HistoryIndex = -1; + instance->historyIndex = -1; data->DeleteChars(0, data->BufTextLen); - instance->OpenAutocomplete = false; - instance->CMDHint = NULLSTR; + instance->openAutocomplete = false; + instance->cmdHint = NULLSTR; break; default: - instance->OpenAutocomplete = false; + instance->openAutocomplete = false; for (auto& [cmd, entry] : instance->Commands) { const std::vector cmd_args = StringHelper::Split(std::string(data->Buf), " "); if (data->BufTextLen > 2 && !cmd_args.empty() && cmd.find(cmd_args[0]) != std::string::npos) { - instance->CMDHint = cmd + " " + BuildUsage(entry); + instance->cmdHint = cmd + " " + BuildUsage(entry); break; } - instance->CMDHint = NULLSTR; + instance->cmdHint = NULLSTR; } } return 0; @@ -363,4 +363,30 @@ namespace Ship { void Console::SendErrorMessage(const std::string& str) { Append("Console", spdlog::level::err, str.c_str()); } + + void Console::ClearLogs(std::string channel) { + Log[channel].clear(); + } + + void Console::ClearLogs() { + for (auto [key, var] : Log) { + var.clear(); + } + } + + bool Console::HasCommand(const std::string& command) { + for (const auto& Command : Commands) { + if (Command.first == command) { + return true; + } + } + + return false; + } + + void Console::AddCommand(const std::string& command, CommandEntry entry) { + if (!HasCommand(command)) { + Commands[command] = entry; + } + } } \ No newline at end of file diff --git a/libultraship/libultraship/Console.h b/libultraship/libultraship/Console.h index e81964aee..f0b78aac9 100644 --- a/libultraship/libultraship/Console.h +++ b/libultraship/libultraship/Console.h @@ -43,13 +43,33 @@ namespace Ship { class Console : public std::enable_shared_from_this { private: + static int CallbackStub(ImGuiInputTextCallbackData* data); + static bool ClearCommand(std::shared_ptr Console, const std::vector& args); + static bool HelpCommand(std::shared_ptr Console, const std::vector& args); + static bool BindCommand(std::shared_ptr Console, const std::vector& args); + static bool BindToggleCommand(std::shared_ptr Console, const std::vector& args); + + bool opened = false; int selectedId = -1; + int historyIndex = -1; std::vector selectedEntries; std::string filter; - spdlog::level::level_enum level_filter = spdlog::level::trace; - const std::vector log_channels = { "Console", "Logs" }; - const std::vector priority_filters = { spdlog::level::off, spdlog::level::critical, spdlog::level::err, spdlog::level::warn, spdlog::level::info, spdlog::level::debug, spdlog::level::trace }; - const std::vector priority_colors = { + std::string currentChannel = "Console"; + bool openAutocomplete = false; + char* inputBuffer = nullptr; + char* filterBuffer = nullptr; + std::string cmdHint = NULLSTR; + spdlog::level::level_enum levelFilter = spdlog::level::trace; + + std::vector History; + std::vector Autocomplete; + std::map Bindings; + std::map BindingToggle; + std::map Commands; + std::map> Log; + const std::vector LogChannels = { "Console", "Logs" }; + const std::vector PriorityFilters = { spdlog::level::off, spdlog::level::critical, spdlog::level::err, spdlog::level::warn, spdlog::level::info, spdlog::level::debug, spdlog::level::trace }; + const std::vector PriorityColours = { ImVec4(0.8f, 0.8f, 0.8f, 1.0f), // TRACE ImVec4(0.9f, 0.9f, 0.9f, 1.0f), // DEBUG ImVec4(1.0f, 1.0f, 1.0f, 1.0f), // INFO @@ -62,28 +82,23 @@ namespace Ship { void Append(const std::string& channel, spdlog::level::level_enum priority, const char* fmt, va_list args); public: - std::map Bindings; - std::map BindingToggle; - std::map> Log; - std::map Commands; - std::vector Autocomplete; - std::vector History; - std::string CMDHint = NULLSTR; - char* FilterBuffer = nullptr; - char* InputBuffer = nullptr; - bool OpenAutocomplete = false; - int HistoryIndex = -1; - bool opened = false; - std::string selected_channel = "Console"; + void ClearLogs(std::string channel); + void ClearLogs(); void Init(); void Update(); void Draw(); void Dispatch(const std::string& line); - static int CallbackStub(ImGuiInputTextCallbackData* data); void SendInfoMessage(const char* fmt, ...); void SendErrorMessage(const char* fmt, ...); void SendInfoMessage(const std::string& str); void SendErrorMessage(const std::string& str); void Append(const std::string& channel, spdlog::level::level_enum priority, const char* fmt, ...); + bool HasCommand(const std::string& command); + void AddCommand(const std::string& command, CommandEntry entry); + + std::string GetCurrentChannel() { return currentChannel; } + bool IsOpened() { return opened; } + void Close() { opened = false; } + void Open() { opened = true; } }; } \ No newline at end of file diff --git a/libultraship/libultraship/GameOverlay.cpp b/libultraship/libultraship/GameOverlay.cpp index 1a3a1e3bb..051669577 100644 --- a/libultraship/libultraship/GameOverlay.cpp +++ b/libultraship/libultraship/GameOverlay.cpp @@ -156,7 +156,8 @@ namespace Ship { this->CurrentFont = DefaultFont; } } - SohImGui::console->Commands["overlay"] = { OverlayCommand, "Draw an overlay using a cvar value" }; + + SohImGui::console->AddCommand("overlay", { OverlayCommand, "Draw an overlay using a cvar value" }); } void GameOverlay::DrawSettings() { diff --git a/libultraship/libultraship/ImGuiImpl.cpp b/libultraship/libultraship/ImGuiImpl.cpp index b76739e7a..cc16b071c 100644 --- a/libultraship/libultraship/ImGuiImpl.cpp +++ b/libultraship/libultraship/ImGuiImpl.cpp @@ -141,7 +141,11 @@ namespace SohImGui { Ship::RegisterHook(UpdateAudio); Ship::RegisterHook([] { gfx_get_current_rendering_api()->set_texture_filter((FilteringMode)CVar_GetS32("gTextureFilter", FILTER_THREE_POINT)); - SohImGui::console->opened = CVar_GetS32("gConsoleEnabled", 0); + if (CVar_GetS32("gConsoleEnabled", 0)) { + console->Open(); + } else { + console->Close(); + } SohImGui::controller->Opened = CVar_GetS32("gControllerConfigurationEnabled", 0); UpdateAudio(); }); @@ -863,7 +867,7 @@ namespace SohImGui { if ((ImGui::IsKeyDown(ImGuiKey_LeftCtrl) || ImGui::IsKeyDown(ImGuiKey_RightCtrl)) && ImGui::IsKeyPressed(ImGuiKey_R, false)) { - console->Commands["reset"].handler(console, emptyArgs); + console->Dispatch("reset"); } #endif @@ -891,7 +895,7 @@ namespace SohImGui { "Ctrl+R" #endif )) { - console->Commands["reset"].handler(console, emptyArgs); + console->Dispatch("reset"); } ImGui::EndMenu(); } @@ -1638,7 +1642,7 @@ namespace SohImGui { CVar_SetS32("gEnableBetaQuest", betaQuestEnabled); CVar_SetS32("gBetaQuestWorld", betaQuestWorld); - console->Commands["reset"].handler(console, emptyArgs); + console->Dispatch("reset"); needs_save = true; } @@ -1695,7 +1699,11 @@ namespace SohImGui { bool currentValue = CVar_GetS32("gConsoleEnabled", 0); CVar_SetS32("gConsoleEnabled", !currentValue); needs_save = true; - console->opened = CVar_GetS32("gConsoleEnabled", 0); + if(CVar_GetS32("gConsoleEnabled", 0)){ + console->Open(); + } else { + console->Close(); + } } Tooltip("Enables the console window, allowing you to input commands, type help for some examples"); InsertPadding(); @@ -2240,7 +2248,7 @@ namespace SohImGui { } void BindCmd(const std::string& cmd, CommandEntry entry) { - console->Commands[cmd] = std::move(entry); + console->AddCommand(cmd, entry); } void AddWindow(const std::string& category, const std::string& name, WindowDrawFunc drawFunc, bool isEnabled, bool isHidden) { diff --git a/libultraship/libultraship/Lib/spdlog/include/spdlog/sinks/sohconsole_sink.h b/libultraship/libultraship/Lib/spdlog/include/spdlog/sinks/sohconsole_sink.h index 65e98610a..8a629aa1a 100644 --- a/libultraship/libultraship/Lib/spdlog/include/spdlog/sinks/sohconsole_sink.h +++ b/libultraship/libultraship/Lib/spdlog/include/spdlog/sinks/sohconsole_sink.h @@ -41,7 +41,7 @@ protected: } formatted.push_back('\0'); const char* msg_output = formatted.data(); - if (CVar_GetS32("gSinkEnabled", 0) && SohImGui::console->opened) { + if (CVar_GetS32("gSinkEnabled", 0) && SohImGui::console->IsOpened()) { SohImGui::console->Append("Logs", msg.level, "%s", msg_output); } } From 6484d9354de23c4b7ff2e7aac0a0c9a625ba99c0 Mon Sep 17 00:00:00 2001 From: Kenix3 Date: Tue, 9 Aug 2022 23:52:31 -0400 Subject: [PATCH 69/71] Fixes incorrect command string when adding basic console commands. --- libultraship/libultraship/Console.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libultraship/libultraship/Console.cpp b/libultraship/libultraship/Console.cpp index 5780453e7..cef037bba 100644 --- a/libultraship/libultraship/Console.cpp +++ b/libultraship/libultraship/Console.cpp @@ -71,9 +71,9 @@ namespace Ship { this->filterBuffer = new char[MAX_BUFFER_SIZE]; strcpy(this->filterBuffer, ""); AddCommand("help", { HelpCommand, "Shows all the commands" }); - AddCommand("help", { ClearCommand, "Clear the console history" }); - AddCommand("help", { BindCommand, "Binds key to commands" }); - AddCommand("help", { BindToggleCommand, "Bind key as a bool toggle" }); + AddCommand("clear", { ClearCommand, "Clear the console history" }); + AddCommand("bind", { BindCommand, "Binds key to commands" }); + AddCommand("bind-toggle", { BindToggleCommand, "Bind key as a bool toggle" }); } void Console::Update() { From 676671996919fdc34e8d611c611237413ccaa26e Mon Sep 17 00:00:00 2001 From: Kenix3 Date: Tue, 9 Aug 2022 23:57:55 -0400 Subject: [PATCH 70/71] Fixes issue in Apple builds where imgui was referring directly to Console.Commands --- libultraship/libultraship/ImGuiImpl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libultraship/libultraship/ImGuiImpl.cpp b/libultraship/libultraship/ImGuiImpl.cpp index cc16b071c..870bfd532 100644 --- a/libultraship/libultraship/ImGuiImpl.cpp +++ b/libultraship/libultraship/ImGuiImpl.cpp @@ -861,7 +861,7 @@ namespace SohImGui { if ((ImGui::IsKeyDown(ImGuiKey_LeftSuper) || ImGui::IsKeyDown(ImGuiKey_RightSuper)) && ImGui::IsKeyPressed(ImGuiKey_R, false)) { - console->Commands["reset"].handler(emptyArgs); + console->Dispatch("reset"); } #else if ((ImGui::IsKeyDown(ImGuiKey_LeftCtrl) || From 15fba979490ec5a2db50c747aa724ff1f2772ca1 Mon Sep 17 00:00:00 2001 From: Kenix3 Date: Wed, 10 Aug 2022 00:02:28 -0400 Subject: [PATCH 71/71] Fixes some missed conversions of Console class singleton within the class itself. --- libultraship/libultraship/Console.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libultraship/libultraship/Console.cpp b/libultraship/libultraship/Console.cpp index cef037bba..79064838e 100644 --- a/libultraship/libultraship/Console.cpp +++ b/libultraship/libultraship/Console.cpp @@ -17,9 +17,9 @@ namespace Ship { } bool Console::HelpCommand(std::shared_ptr Console, const std::vector& args) { - SohImGui::console->SendInfoMessage("SoH Commands:"); - for (const auto& cmd : SohImGui::console->Commands) { - SohImGui::console->SendInfoMessage(" - " + cmd.first); + Console->SendInfoMessage("SoH Commands:"); + for (const auto& cmd : Console->Commands) { + Console->SendInfoMessage(" - " + cmd.first); } return CMD_SUCCESS; } @@ -41,7 +41,7 @@ namespace Ship { std::ostringstream imploded; std::copy(args.begin() + 2, args.end(), std::ostream_iterator(imploded, delim)); Console->Bindings[k] = imploded.str(); - SohImGui::console->SendInfoMessage("Binding '%s' to %s", args[1].c_str(), Console->Bindings[k].c_str()); + Console->SendInfoMessage("Binding '%s' to %s", args[1].c_str(), Console->Bindings[k].c_str()); break; } } @@ -57,7 +57,7 @@ namespace Ship { if (toLowerCase(args[1]) == toLowerCase(key)) { Console->BindingToggle[k] = args[2]; - SohImGui::console->SendInfoMessage("Binding toggle '%s' to %s", args[1].c_str(), Console->BindingToggle[k].c_str()); + Console->SendInfoMessage("Binding toggle '%s' to %s", args[1].c_str(), Console->BindingToggle[k].c_str()); break; } }