Skip to content

Commit

Permalink
Fixes storage of altar and ganon hints/text.
Browse files Browse the repository at this point in the history
Only one language is stored in gSaveContext at the moment so store the one language in all 3 CustomMessageEntry languages.
  • Loading branch information
leggettc18 committed Jul 24, 2022
1 parent a33c3d6 commit 780e9f4
Showing 1 changed file with 10 additions and 57 deletions.
67 changes: 10 additions & 57 deletions soh/soh/Enhancements/randomizer/randomizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1486,16 +1486,20 @@ void Randomizer::LoadHintLocations(const char* spoilerFileName) {

CustomMessage::Instance->CreateMessage(
Randomizer::hintMessageTableID, 0x7040,
{ TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, gSaveContext.childAltarText, "", "" });
{ TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, gSaveContext.childAltarText,
gSaveContext.childAltarText, gSaveContext.childAltarText });
CustomMessage::Instance->CreateMessage(
Randomizer::hintMessageTableID, 0x7088,
{ TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, gSaveContext.adultAltarText, "", "" });
{ TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, gSaveContext.adultAltarText,
gSaveContext.adultAltarText, gSaveContext.adultAltarText });
CustomMessage::Instance->CreateMessage(
Randomizer::hintMessageTableID, 0x70CC,
{ TEXTBOX_TYPE_BLACK, TEXTBOX_POS_BOTTOM, gSaveContext.ganonHintText, "", "" });
{ TEXTBOX_TYPE_BLACK, TEXTBOX_POS_BOTTOM, gSaveContext.ganonHintText,
gSaveContext.ganonHintText, gSaveContext.ganonHintText });
CustomMessage::Instance->CreateMessage(
Randomizer::hintMessageTableID, 0x70CD,
{ TEXTBOX_TYPE_BLACK, TEXTBOX_POS_BOTTOM, gSaveContext.ganonText, "", "" });
{ TEXTBOX_TYPE_BLACK, TEXTBOX_POS_BOTTOM, gSaveContext.ganonText,
gSaveContext.ganonText, gSaveContext.ganonText });

this->childAltarText = gSaveContext.childAltarText;
this->adultAltarText = gSaveContext.adultAltarText;
Expand All @@ -1506,7 +1510,7 @@ void Randomizer::LoadHintLocations(const char* spoilerFileName) {
if(hintLocation.check == RC_LINKS_POCKET) break;
this->hintLocations[hintLocation.check] = hintLocation.hintText;
CustomMessage::Instance->CreateMessage(
Randomizer::hintMessageTableID, hintLocation.check, { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, hintLocation.hintText, "", "" });
Randomizer::hintMessageTableID, hintLocation.check, { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, hintLocation.hintText, hintLocation.hintText, hintLocation.hintText });
}
}

Expand Down Expand Up @@ -1818,58 +1822,7 @@ std::string AltarIconString(char iconChar) {

std::string FormatJsonHintText(std::string jsonHint) {
std::string formattedHintMessage = jsonHint;
char newLine = 0x01;
char playerName = 0x0F;
char nextBox = 0x04;
std::replace(formattedHintMessage.begin(), formattedHintMessage.end(), '&', newLine);
std::replace(formattedHintMessage.begin(), formattedHintMessage.end(), '^', nextBox);
std::replace(formattedHintMessage.begin(), formattedHintMessage.end(), '@', playerName);

std::unordered_map<std::string, char> textBoxSpecialCharacters = {
{"À", 0x80 },
{"î", 0x81 },
{"Â", 0x82 },
{"Ä", 0x83 },
{"Ç", 0x84 },
{"È", 0x85 },
{"É", 0x86 },
{"Ê", 0x87 },
{"Ë", 0x88 },
{"Ï", 0x89 },
{"Ô", 0x8A },
{"Ö", 0x8B },
{"Ù", 0x8C },
{"Û", 0x8D },
{"Ü", 0x8E },
{"ß", 0x8F },
{"à", 0x90 },
{"á", 0x91 },
{"â", 0x92 },
{"ä", 0x93 },
{"ç", 0x94 },
{"è", 0x95 },
{"é", 0x96 },
{"ê", 0x97 },
{"ë", 0x98 },
{"ï", 0x99 },
{"ô", 0x9A },
{"ö", 0x9B },
{"ù", 0x9C },
{"û", 0x9D },
{"ü", 0x9E }
};

// add special characters
for (auto specialCharacterPair : textBoxSpecialCharacters) {
size_t start_pos = 0;
std::string textBoxSpecialCharacterString = "";
textBoxSpecialCharacterString += specialCharacterPair.second;
while((start_pos = formattedHintMessage.find(specialCharacterPair.first, start_pos)) != std::string::npos) {
formattedHintMessage.replace(start_pos, specialCharacterPair.first.length(), textBoxSpecialCharacterString);
start_pos += textBoxSpecialCharacterString.length();
}
}


// add icons to altar text
for (char iconChar : {'0', '1', '2', '3', '4', '5', '6', '7', '8', 'o', 'c', 'i', 'l', 'b', 'L', 'k'}) {
std::string textToReplace = "$";
Expand Down

0 comments on commit 780e9f4

Please sign in to comment.