mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-01-10 21:48:17 -05:00
Moves deku scrub messages into CustomMessageTable.
This commit is contained in:
parent
9f2eb46663
commit
cd01e8b778
@ -4,13 +4,13 @@
|
||||
using namespace std::literals::string_literals;
|
||||
|
||||
CustomMessage::CustomMessage() {
|
||||
this->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 } };
|
||||
this->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 } };
|
||||
this->colors = { { "w", QM_WHITE }, { "r", QM_RED }, { "g", QM_GREEN }, { "b", QM_BLUE },
|
||||
{ "c", QM_LBLUE }, { "p", QM_PINK }, { "y", QM_YELLOW }, { "B", QM_BLACK } };
|
||||
}
|
||||
@ -23,11 +23,11 @@ CustomMessage::~CustomMessage() {
|
||||
|
||||
void CustomMessage::ReplaceSpecialCharacters(std::string& string) {
|
||||
// add special characters
|
||||
for (auto specialCharacterPair : textBoxSpecialCharacters) {
|
||||
for (auto specialCharacterPair : this->textBoxSpecialCharacters) {
|
||||
size_t start_pos = 0;
|
||||
std::string textBoxSpecialCharacterString = "";
|
||||
std::string textBoxSpecialCharacterString = ""s;
|
||||
textBoxSpecialCharacterString += specialCharacterPair.second;
|
||||
while ((start_pos = string.find(specialCharacterPair.first, start_pos)) != std::string::npos) {
|
||||
while ((start_pos = string.find(specialCharacterPair.first, 0)) != std::string::npos) {
|
||||
string.replace(start_pos, specialCharacterPair.first.length(), textBoxSpecialCharacterString);
|
||||
start_pos += textBoxSpecialCharacterString.length();
|
||||
}
|
||||
@ -63,10 +63,7 @@ void CustomMessage::FormatCustomMessage(std::string& message, ItemID iid) {
|
||||
void CustomMessage::FormatCustomMessage(std::string& message) {
|
||||
size_t start_pos = 0;
|
||||
std::replace(message.begin(), message.end(), '&', NEWLINE()[0]);
|
||||
while ((start_pos = message.find('^', start_pos)) != std::string::npos) {
|
||||
message.replace(start_pos, 1, WAIT_FOR_INPUT());
|
||||
start_pos += 3;
|
||||
}
|
||||
std::replace(message.begin(), message.end(), '^', WAIT_FOR_INPUT()[0]);
|
||||
std::replace(message.begin(), message.end(), '@', PLAYER_NAME()[0]);
|
||||
ReplaceSpecialCharacters(message);
|
||||
ReplaceColors(message);
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include <soh/Enhancements/custom_message/CustomMessage.h>
|
||||
|
||||
using json = nlohmann::json;
|
||||
using namespace std::literals::string_literals;
|
||||
|
||||
std::unordered_map<uint8_t, Sprite> gSeedTextures;
|
||||
|
||||
@ -24,6 +25,7 @@ u8 generated;
|
||||
|
||||
const std::string Randomizer::getItemMessageTableID = "Randomizer";
|
||||
const std::string Randomizer::hintMessageTableID = "RandomizerHints";
|
||||
const std::string Randomizer::scrubMessageTableID = "RandomizerScrubs";
|
||||
|
||||
Randomizer::Randomizer() {
|
||||
Sprite bowSprite = { dgFairyBowIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 0 };
|
||||
@ -1822,6 +1824,25 @@ std::string AltarIconString(char iconChar) {
|
||||
|
||||
std::string FormatJsonHintText(std::string jsonHint) {
|
||||
std::string formattedHintMessage = jsonHint;
|
||||
|
||||
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'}) {
|
||||
@ -4739,6 +4760,23 @@ void CreateGetItemMessages(std::vector<GetItemMessage> messageEntries) {
|
||||
}
|
||||
}
|
||||
|
||||
void CreateScrubMessages() {
|
||||
CustomMessage* customMessage = CustomMessage::Instance;
|
||||
customMessage->AddCustomMessageTable(Randomizer::scrubMessageTableID);
|
||||
const std::vector<u8> prices = { 10, 40 };
|
||||
for (u8 price : prices) {
|
||||
customMessage->CreateMessage(Randomizer::scrubMessageTableID, price,
|
||||
{ TEXTBOX_TYPE_BLACK, TEXTBOX_POS_BOTTOM,
|
||||
"\x12\x38\x82\All right! You win! In return for&sparing me, I will sell you a&%gmysterious item%w!&%r" +
|
||||
std::to_string(price) + " Rupees%w it is!\x07\x10\xA3",
|
||||
"\x12\x38\x82\All right! You win! In return for&sparing me, I will sell you a&%gmysterious item%w!&%r" +
|
||||
std::to_string(price) + " Rupees%w it is!\x07\x10\xA3",
|
||||
"\x12\x38\x82J'abandonne! Tu veux bien m'acheter&un %gobjet mystérieux%w?&Ça fera %r" +
|
||||
std::to_string(price) + " Rubis%w!\x07\x10\xA3"
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
#define GIMESSAGE(giid, iid, english, german, french) \
|
||||
{ giid, iid, english, german, french }
|
||||
|
||||
@ -4781,6 +4819,7 @@ void Randomizer::CreateCustomMessages() {
|
||||
"You got a %rPoe in a Bottle%w!&That creepy Ghost Shop might&be interested in this..."),
|
||||
};
|
||||
CreateGetItemMessages(getItemMessages);
|
||||
CreateScrubMessages();
|
||||
}
|
||||
|
||||
void InitRando() {
|
||||
|
@ -28,6 +28,7 @@ class Randomizer {
|
||||
|
||||
static const std::string getItemMessageTableID;
|
||||
static const std::string hintMessageTableID;
|
||||
static const std::string scrubMessageTableID;
|
||||
|
||||
static Sprite* GetSeedTexture(uint8_t index);
|
||||
s16 GetItemModelFromId(s16 itemId);
|
||||
|
@ -1401,6 +1401,20 @@ extern "C" RandomizerCheck Randomizer_GetCheckFromActor(s16 sceneNum, s16 actorI
|
||||
return OTRGlobals::Instance->gRandomizer->GetCheckFromActor(sceneNum, actorId, actorParams);
|
||||
}
|
||||
|
||||
extern "C" CustomMessageEntry Randomizer_CopyScrubMessage(u16 scrubTextId) {
|
||||
int price = 0;
|
||||
switch (scrubTextId) {
|
||||
case 0x10A2:
|
||||
price = 10;
|
||||
break;
|
||||
case 0x10DC:
|
||||
case 0x10DD:
|
||||
price = 40;
|
||||
break;
|
||||
}
|
||||
return CustomMessage::Instance->RetrieveMessage(Randomizer::scrubMessageTableID, price);
|
||||
}
|
||||
|
||||
extern "C" int CopyScrubMessage(u16 scrubTextId, char* buffer, const int maxBufferSize) {
|
||||
std::string scrubText("");
|
||||
int language = CVar_GetS32("gLanguages", 0);
|
||||
@ -1554,6 +1568,8 @@ extern "C" int CustomMessage_RetrieveIfExists(GlobalContext* globalCtx) {
|
||||
} else {
|
||||
messageEntry = Randomizer_CopyGanonHintText();
|
||||
}
|
||||
} else if (textId == 0x10A2 || textId == 0x10DC || textId == 0x10DD) {
|
||||
messageEntry = Randomizer_CopyScrubMessage(textId);
|
||||
}
|
||||
}
|
||||
if (textId == 0x00B4 || textId == 0x00B5) {
|
||||
|
@ -1675,13 +1675,9 @@ void Message_OpenText(GlobalContext* globalCtx, u16 textId) {
|
||||
//font->msgLength, __FILE__, __LINE__);
|
||||
} else {
|
||||
Message_FindMessage(globalCtx, textId);
|
||||
if (gSaveContext.n64ddFlag && (textId == 0x10A2 || textId == 0x10DC || textId == 0x10DD)) {
|
||||
msgCtx->msgLength = font->msgLength = CopyScrubMessage(textId, font->msgBuf, sizeof(font->msgBuf));
|
||||
} else {
|
||||
msgCtx->msgLength = font->msgLength;
|
||||
char* src = (uintptr_t)font->msgOffset;
|
||||
memcpy(font->msgBuf, src, font->msgLength);
|
||||
}
|
||||
msgCtx->msgLength = font->msgLength;
|
||||
char* src = (uintptr_t)font->msgOffset;
|
||||
memcpy(font->msgBuf, src, font->msgLength);
|
||||
}
|
||||
|
||||
msgCtx->textBoxProperties = font->charTexBuf[0];
|
||||
|
Loading…
Reference in New Issue
Block a user