From d28cb70984296f1c100ff02cb1d0d8baa8d8d25b Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Thu, 27 Feb 2025 17:25:08 -0500 Subject: [PATCH] Port Quit Fishing At Door and clean up unused stuff --- .../TimeSavers/QuitFishingAtDoor.cpp | 26 +++++++++++++++++++ soh/soh/OTRGlobals.cpp | 14 ---------- soh/soh/OTRGlobals.h | 2 -- soh/soh/z_message_OTR.cpp | 7 ----- 4 files changed, 26 insertions(+), 23 deletions(-) create mode 100644 soh/soh/Enhancements/TimeSavers/QuitFishingAtDoor.cpp diff --git a/soh/soh/Enhancements/TimeSavers/QuitFishingAtDoor.cpp b/soh/soh/Enhancements/TimeSavers/QuitFishingAtDoor.cpp new file mode 100644 index 000000000..4da206159 --- /dev/null +++ b/soh/soh/Enhancements/TimeSavers/QuitFishingAtDoor.cpp @@ -0,0 +1,26 @@ +#include + +extern "C" { +#include +} + +// TODO: Port the rest of the behavior for this enhancement here. + +void BuildQuitFishingMessage(uint16_t* textId, bool* loadFromMessageTable) { + // TODO: See about loading the vanilla message and manipulating that instead of + // a brand new one. Might not be worth it. + CustomMessage msg = CustomMessage( + "Hey! Hey!&You can't take the rod out of here!&I'm serious!^Do you want to quit?&\x1B&%gYes&No%w", + "Hey! Hey!&Du kannst die Angel doch nicht&einfach mitnehmen!&Ganz im Ernst!^Möchtest Du aufhören?&\x1B&%gJa&Nein%w", + "Holà! Holà!&Les cannes ne sortent pas d'ici!&Je suis sérieux!^Voulez-vous arrêter?&\x1B&%gOui&Non%w" + ); + msg.AutoFormat(); + msg.LoadIntoFont(); + *loadFromMessageTable = false; +} + +void QuitFishingAtDoor_Register() { + COND_ID_HOOK(OnOpenText, TEXT_FISHERMAN_LEAVE, CVarGetInteger(CVAR_ENHANCEMENT("QuitFishingAtDoor"), 0), BuildQuitFishingMessage); +} + +RegisterShipInitFunc initFunc(QuitFishingAtDoor_Register, { CVAR_ENHANCEMENT("QuitFishingAtDoor") }); \ No newline at end of file diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 0f0fd6571..3e723e1fc 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -2130,20 +2130,6 @@ extern "C" void Randomizer_ShowRandomizerMenu() { SohGui::ShowRandomizerSettingsMenu(); } -extern "C" int CustomMessage_RetrieveIfExists(PlayState* play) { - MessageContext* msgCtx = &play->msgCtx; - uint16_t textId = msgCtx->textId; - Font* font = &msgCtx->font; - char* buffer = font->msgBuf; - const int maxBufferSize = sizeof(font->msgBuf); - CustomMessage messageEntry; - s16 actorParams = 0; - if (textId == TEXT_FISHERMAN_LEAVE && CVarGetInteger(CVAR_ENHANCEMENT("QuitFishingAtDoor"), 0)) { - messageEntry = CustomMessageManager::Instance->RetrieveMessage(customMessageTableID, TEXT_FISHERMAN_LEAVE, MF_FORMATTED); - } - return false; -} - extern "C" void Overlay_DisplayText(float duration, const char* text) { Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGameOverlay()->TextDrawNotification(duration, true, text); } diff --git a/soh/soh/OTRGlobals.h b/soh/soh/OTRGlobals.h index 6b5b16b58..ba8a41ece 100644 --- a/soh/soh/OTRGlobals.h +++ b/soh/soh/OTRGlobals.h @@ -30,7 +30,6 @@ struct ExtensionEntry { extern std::unordered_map ExtensionCache; #include "Enhancements/randomizer/settings.h" -const std::string customMessageTableID = "BaseGameOverrides"; const std::string appShortName = "soh"; #ifdef __WIIU__ @@ -149,7 +148,6 @@ uint8_t Randomizer_IsSpoilerLoaded(); void Randomizer_SetSpoilerLoaded(bool spoilerLoaded); uint8_t Randomizer_GenerateRandomizer(); void Randomizer_ShowRandomizerMenu(); -int CustomMessage_RetrieveIfExists(PlayState* play); void Overlay_DisplayText(float duration, const char* text); void Overlay_DisplayText_Seconds(int seconds, const char* text); GetItemEntry ItemTable_Retrieve(int16_t getItemID); diff --git a/soh/soh/z_message_OTR.cpp b/soh/soh/z_message_OTR.cpp index a09157696..20c0f4762 100644 --- a/soh/soh/z_message_OTR.cpp +++ b/soh/soh/z_message_OTR.cpp @@ -111,11 +111,4 @@ extern "C" void OTRMessage_Init() { // Assert staff credits start at the first credits ID assert(sStaffMessageEntryTablePtr[0].textId == 0x0500); } - - CustomMessageManager::Instance->AddCustomMessageTable(customMessageTableID); - CustomMessageManager::Instance->CreateMessage( - customMessageTableID, TEXT_FISHERMAN_LEAVE, - CustomMessage("Hey! Hey!&You can't take the rod out of here!&I'm serious!^Do you want to quit?&\x1B&%gYes&No%w", - "Hey! Hey!&Du kannst die Angel doch nicht&einfach mitnehmen!&Ganz im Ernst!^Möchtest Du aufhören?&\x1B&%gJa&Nein%w", - "Holà! Holà!&Les cannes ne sortent pas d'ici!&Je suis sérieux!^Voulez-vous arrêter?&\x1B&%gOui&Non%w")); //TODO Used AI translation as placeholder }