Skip to content

Commit

Permalink
Factors away some raw textIDs into an enum with descriptive names.
Browse files Browse the repository at this point in the history
  • Loading branch information
leggettc18 committed Jul 27, 2022
1 parent d0968a9 commit 5a97e9f
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 26 deletions.
1 change: 1 addition & 0 deletions soh/soh.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,7 @@
<ItemGroup>
<ClInclude Include="soh\Enhancements\custom_message\CustomMessageManager.h" />
<ClInclude Include="soh\Enhancements\cosmetics\CosmeticsEditor.h" />
<ClInclude Include="soh\Enhancements\custom_message\CustomMessageTypes.h" />
<ClInclude Include="soh\Enhancements\debugger\actorViewer.h" />
<ClCompile Include="soh\Enhancements\randomizer\randomizer.h" />
<ClInclude Include="soh\Enhancements\gfx.h" />
Expand Down
3 changes: 3 additions & 0 deletions soh/soh.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -4073,6 +4073,9 @@
<ClInclude Include="soh\Enhancements\custom_message\CustomMessageManager.h">
<Filter>Header Files\soh\Enhancements\custom-message</Filter>
</ClInclude>
<ClInclude Include="soh\Enhancements\custom_message\CustomMessageTypes.h">
<Filter>Source Files\soh\Enhancements\custom-message</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Image Include="SHIPOFHARKINIAN.ico" />
Expand Down
14 changes: 14 additions & 0 deletions soh/soh/Enhancements/custom_message/CustomMessageTypes.h
Original file line number Diff line number Diff line change
@@ -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;
31 changes: 16 additions & 15 deletions soh/soh/OTRGlobals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
#endif

#include <Audio.h>
#include <soh/Enhancements/custom_message/CustomMessageTypes.h>

OTRGlobals* OTRGlobals::Instance;
SaveManager* SaveManager::Instance;
Expand Down Expand Up @@ -1412,28 +1413,29 @@ 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;
}
return CustomMessageManager::Instance->RetrieveMessage(Randomizer::scrubMessageTableID, price);
}

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) {
Expand Down Expand Up @@ -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 &&
Expand Down Expand Up @@ -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);
}
Expand Down
5 changes: 3 additions & 2 deletions soh/soh/z_message_OTR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "vt.h"
#include <Text.h>
#include <soh/Enhancements/custom_message/CustomMessageManager.h>
#include <soh/Enhancements/custom_message/CustomMessageTypes.h>

extern "C" MessageTableEntry* sNesMessageEntryTablePtr;
extern "C" MessageTableEntry* sGerMessageEntryTablePtr;
Expand Down Expand Up @@ -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",
Expand All @@ -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!",
Expand Down
19 changes: 10 additions & 9 deletions soh/src/overlays/actors/ovl_player_actor/z_player.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 5a97e9f

Please sign in to comment.