Skip to content

Commit

Permalink
Implements the custom text for gInjectSkulltulaCount.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
leggettc18 committed Jul 18, 2022
1 parent 1ed45e1 commit e04b2c8
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 29 deletions.
8 changes: 4 additions & 4 deletions soh/soh/Enhancements/custom_message/CustomMessage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand All @@ -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()) {
Expand Down
4 changes: 3 additions & 1 deletion soh/soh/Enhancements/custom_message/CustomMessage.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include <unordered_map>
#include "variables.h"

#undef MESSAGE_END

#define QM_WHITE 0x00
#define QM_RED 0x41
#define QM_GREEN 0x42
Expand All @@ -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);
Expand Down
15 changes: 15 additions & 0 deletions soh/soh/OTRGlobals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
18 changes: 18 additions & 0 deletions soh/soh/z_message_OTR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@
#include "global.h"
#include "vt.h"
#include <Text.h>
#include <soh/Enhancements/custom_message/CustomMessage.h>

extern "C" MessageTableEntry* sNesMessageEntryTablePtr;
extern "C" MessageTableEntry* sGerMessageEntryTablePtr;
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<Ship::Text>(OTRGlobals::Instance->context->GetResourceManager()->LoadResource(filePath));

Expand Down Expand Up @@ -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 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(
customMessageTableID, (GetItemID)0x00B5, ITEM_SKULL_TOKEN,
{ "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!" });
}
25 changes: 1 addition & 24 deletions soh/src/code/z_message_PAL.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
Expand Down

0 comments on commit e04b2c8

Please sign in to comment.