Initial language support and setup for randomizing

This commit is contained in:
aMannus 2022-08-17 22:30:21 +02:00
parent 55f71457d8
commit f9766fa4a6
2 changed files with 32 additions and 9 deletions

View File

@ -4629,23 +4629,23 @@ void CreateRupeeMessages() {
for (u8 rupee : rupees) {
switch (rupee) {
case TEXT_BLUE_RUPEE:
rupeeText = "\x05\x03 5 BitCoin\x05\x00 ";
rupeeText = "\x05\x03 5 %RUPEE%\x05\x00";
break;
case TEXT_RED_RUPEE:
rupeeText = "\x05\x01 20 Moneys\x05\x00 ";
rupeeText = "\x05\x01 20 %RUPEE%\x05\x00";
break;
case TEXT_PURPLE_RUPEE:
rupeeText = "\x05\x05 50 Gummybears\x05\x00 ";
rupeeText = "\x05\x05 50 %RUPEE%\x05\x00";
break;
case TEXT_HUGE_RUPEE:
rupeeText = "\x05\x06 200 Cornflakes\x05\x00 ";
rupeeText = "\x05\x06 200 %RUPEE%\x05\x00";
break;
}
customMessageManager->CreateMessage(Randomizer::rupeeMessageTableID, rupee,
{ TEXTBOX_TYPE_BLACK, TEXTBOX_POS_BOTTOM,
"You found" + rupeeText + " !",
"You found" + rupeeText + "!",
"You found" + rupeeText + "!"
"Du fandest" + rupeeText + " !",
"Tu as trouvé" + rupeeText + " !"
});
}
}

View File

@ -1447,8 +1447,32 @@ extern "C" CustomMessageEntry Randomizer_GetScrubMessage(u16 scrubTextId) {
return CustomMessageManager::Instance->RetrieveMessage(Randomizer::scrubMessageTableID, price);
}
extern "C" std::string Randomizer_InsertRupeeName(std::string message, int language) {
std::string replaceWith;
switch (language) {
case LANGUAGE_ENG:
replaceWith = "Bananas";
break;
case LANGUAGE_GER:
replaceWith = "Sauerkraut";
break;
case LANGUAGE_FRA:
replaceWith = "Baguettes";
break;
}
std::string replaceString = "%RUPEE%";
size_t pos = message.find(replaceString);
size_t len = replaceString.length();
message.replace(pos, len, replaceWith);
return message;
}
extern "C" CustomMessageEntry Randomizer_GetRupeeMessage(u16 rupeeTextId) {
return CustomMessageManager::Instance->RetrieveMessage(Randomizer::rupeeMessageTableID, rupeeTextId);
CustomMessageEntry messageEntry = CustomMessageManager::Instance->RetrieveMessage(Randomizer::rupeeMessageTableID, rupeeTextId);
messageEntry.english = Randomizer_InsertRupeeName(messageEntry.english, LANGUAGE_ENG);
messageEntry.german = Randomizer_InsertRupeeName(messageEntry.german, LANGUAGE_GER);
messageEntry.french = Randomizer_InsertRupeeName(messageEntry.french, LANGUAGE_FRA);
return messageEntry;
}
extern "C" CustomMessageEntry Randomizer_GetAltarMessage() {
@ -1576,7 +1600,6 @@ extern "C" int CustomMessage_RetrieveIfExists(GlobalContext* globalCtx) {
case LANGUAGE_GER:
return msgCtx->msgLength = font->msgLength =
CopyStringToCharBuffer(messageEntry.german, buffer, maxBufferSize);
case LANGUAGE_ENG:
default:
return msgCtx->msgLength = font->msgLength =