Skip to content

Commit

Permalink
Early version of custom messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
leggettc18 committed Jul 14, 2022
1 parent 248f49b commit e9ba8f7
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 0 deletions.
11 changes: 11 additions & 0 deletions soh/soh/Enhancements/randomizer/randomizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions soh/soh/Enhancements/randomizer/randomizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions soh/soh/OTRGlobals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
1 change: 1 addition & 0 deletions soh/soh/OTRGlobals.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions soh/src/code/z_message_PAL.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit e9ba8f7

Please sign in to comment.