From b4c9f4aa6ee71795bfc5fa6251c85123d2949cf8 Mon Sep 17 00:00:00 2001 From: Sarge-117 Date: Tue, 9 Aug 2022 16:07:58 -0700 Subject: [PATCH] Test switch to new message system Testing setting up the table and calling the messages --- soh/soh/Enhancements/randomizer/randomizer.cpp | 11 +++++++++++ soh/soh/Enhancements/randomizer/randomizer.h | 1 + soh/soh/OTRGlobals.cpp | 8 ++++++++ soh/src/code/z_message_PAL.c | 3 ++- soh/src/overlays/actors/ovl_player_actor/z_player.c | 6 +++--- 5 files changed, 25 insertions(+), 4 deletions(-) diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index 250f4e3f13..0c6a7530ad 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -27,6 +27,7 @@ u8 generated; const std::string Randomizer::getItemMessageTableID = "Randomizer"; const std::string Randomizer::hintMessageTableID = "RandomizerHints"; const std::string Randomizer::scrubMessageTableID = "RandomizerScrubs"; +const std::string Randomizer::NaviRandoMessageTableID = "RandomizerNavi"; Randomizer::Randomizer() { Sprite bowSprite = { dgFairyBowIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 0 }; @@ -4418,6 +4419,15 @@ void CreateScrubMessages() { } } +void CreateNaviRandoMessages() { + CustomMessageManager* customMessageManager = CustomMessageManager::Instance; + customMessageManager->AddCustomMessageTable(Randomizer::NaviRandoMessageTableID); + customMessageManager->CreateMessage(Randomizer::NaviRandoMessageTableID, 0x00, + { TEXTBOX_TYPE_BLACK, TEXTBOX_POS_BOTTOM, "Test Eng0", "Test Ger", "Test Fre" }); + customMessageManager->CreateMessage(Randomizer::NaviRandoMessageTableID, 0x01, + { TEXTBOX_TYPE_BLACK, TEXTBOX_POS_BOTTOM, "Test Eng1", "Test Ger", "Test Fre" }); +} + void Randomizer::CreateCustomMessages() { // RANDTODO: Translate into french and german and replace GIMESSAGE_UNTRANSLATED // with GIMESSAGE(getItemID, itemID, english, german, french). @@ -4446,6 +4456,7 @@ void Randomizer::CreateCustomMessages() { }; CreateGetItemMessages(getItemMessages); CreateScrubMessages(); + CreateNaviRandoMessages(); } void InitRando() { diff --git a/soh/soh/Enhancements/randomizer/randomizer.h b/soh/soh/Enhancements/randomizer/randomizer.h index 1994cfdc42..eb0ef5eddb 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.h +++ b/soh/soh/Enhancements/randomizer/randomizer.h @@ -29,6 +29,7 @@ class Randomizer { static const std::string getItemMessageTableID; static const std::string hintMessageTableID; static const std::string scrubMessageTableID; + static const std::string NaviRandoMessageTableID; static Sprite* GetSeedTexture(uint8_t index); s16 GetItemModelFromId(s16 itemId); diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index b85d092fb1..8630e0dcc4 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -1449,6 +1449,11 @@ extern "C" CustomMessageEntry Randomizer_GetScrubMessage(u16 scrubTextId) { return CustomMessageManager::Instance->RetrieveMessage(Randomizer::scrubMessageTableID, price); } +extern "C" CustomMessageEntry Randomizer_GetNaviMessage() { + u16 naviTextId = rand() % 2; + return CustomMessageManager::Instance->RetrieveMessage(Randomizer::NaviRandoMessageTableID, naviTextId); +} + extern "C" CustomMessageEntry Randomizer_GetAltarMessage() { return (LINK_IS_ADULT) ? CustomMessageManager::Instance->RetrieveMessage(Randomizer::hintMessageTableID, TEXT_ALTAR_ADULT) @@ -1542,7 +1547,10 @@ extern "C" int CustomMessage_RetrieveIfExists(GlobalContext* globalCtx) { } } else if (textId == TEXT_SCRUB_POH || textId == TEXT_SCRUB_STICK_UPGRADE || textId == TEXT_SCRUB_NUT_UPGRADE) { messageEntry = Randomizer_GetScrubMessage(textId); + } else if (textId >= 0x0140 && textId <= 0x015F) { + messageEntry = Randomizer_GetNaviMessage(); } + } if (textId == TEXT_GS_NO_FREEZE || textId == TEXT_GS_FREEZE) { if (CVar_GetS32("gInjectSkulltulaCount", 0) != 0) { diff --git a/soh/src/code/z_message_PAL.c b/soh/src/code/z_message_PAL.c index 07f80fba2b..430a7e3fa0 100644 --- a/soh/src/code/z_message_PAL.c +++ b/soh/src/code/z_message_PAL.c @@ -1682,11 +1682,12 @@ void Message_OpenText(GlobalContext* globalCtx, u16 textId) { memcpy(font->msgBuf, src, font->msgLength); } + /* // (From z_player.c) In rando, Navi gives rando-related advice if (textId == 0x0140 && gSaveContext.n64ddFlag) { RandoNaviTip(globalCtx); msgCtx->msgLength = font->msgLength = strlen(font->msgBuf); - } + }*/ msgCtx->textBoxProperties = font->charTexBuf[0]; msgCtx->textBoxType = msgCtx->textBoxProperties >> 4; 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 1b70d3e4f7..0694deb90f 100644 --- a/soh/src/overlays/actors/ovl_player_actor/z_player.c +++ b/soh/src/overlays/actors/ovl_player_actor/z_player.c @@ -15293,8 +15293,8 @@ void func_80853148(GlobalContext* globalCtx, Actor* actor) { this->naviActor->flags |= ACTOR_FLAG_8; func_80835EA4(globalCtx, 0xB); // If rando'd and Navi wants to give you a general quest tip, give a rando tip instead - if (actor->textId >= 0x0140 && actor->textId <= 0x015F && gSaveContext.n64ddFlag) { - Message_StartTextbox(globalCtx, 0x0140, NULL); - } + // if (actor->textId >= 0x0140 && actor->textId <= 0x015F && gSaveContext.n64ddFlag) { + // Message_StartTextbox(globalCtx, 0x0140, NULL); + // } } }