From 822476373bb42c5c94eeaaf13178f6bfcb839124 Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Mon, 25 Jul 2022 22:33:38 -0400 Subject: [PATCH] Renames CustomMessage to CustomMessageManager --- soh/soh.vcxproj | 4 +- soh/soh.vcxproj.filters | 4 +- ...omMessage.cpp => CustomMessageManager.cpp} | 38 +++++++++---------- ...CustomMessage.h => CustomMessageManager.h} | 8 ++-- .../Enhancements/randomizer/randomizer.cpp | 20 +++++----- soh/soh/OTRGlobals.cpp | 22 +++++------ soh/soh/z_message_OTR.cpp | 16 ++++---- 7 files changed, 56 insertions(+), 56 deletions(-) rename soh/soh/Enhancements/custom_message/{CustomMessage.cpp => CustomMessageManager.cpp} (77%) rename soh/soh/Enhancements/custom_message/{CustomMessage.h => CustomMessageManager.h} (94%) diff --git a/soh/soh.vcxproj b/soh/soh.vcxproj index 1c1f3784a..27c1571da 100644 --- a/soh/soh.vcxproj +++ b/soh/soh.vcxproj @@ -179,7 +179,7 @@ - + @@ -944,7 +944,7 @@ - + diff --git a/soh/soh.vcxproj.filters b/soh/soh.vcxproj.filters index f31a5171c..ed0a1f200 100644 --- a/soh/soh.vcxproj.filters +++ b/soh/soh.vcxproj.filters @@ -2379,7 +2379,7 @@ Source Files\src - + Source Files\soh\Enhancements\custom-message @@ -4070,7 +4070,7 @@ Source Files\src - + Header Files\soh\Enhancements\custom-message diff --git a/soh/soh/Enhancements/custom_message/CustomMessage.cpp b/soh/soh/Enhancements/custom_message/CustomMessageManager.cpp similarity index 77% rename from soh/soh/Enhancements/custom_message/CustomMessage.cpp rename to soh/soh/Enhancements/custom_message/CustomMessageManager.cpp index 6ea820aa9..4f69102da 100644 --- a/soh/soh/Enhancements/custom_message/CustomMessage.cpp +++ b/soh/soh/Enhancements/custom_message/CustomMessageManager.cpp @@ -1,9 +1,9 @@ -#include "CustomMessage.h" +#include "CustomMessageManager.h" #include using namespace std::literals::string_literals; -CustomMessage::CustomMessage() { +CustomMessageManager::CustomMessageManager() { this->textBoxSpecialCharacters = { { "À", 0x80 }, { "î", 0x81 }, { "Â", 0x82 }, { "Ä", 0x83 }, { "Ç", 0x84 }, { "È", 0x85 }, { "É", 0x86 }, { "Ê", 0x87 }, { "Ë", 0x88 }, { "Ï", 0x89 }, { "Ô", 0x8A }, { "Ö", 0x8B }, { "Ù", 0x8C }, { "Û", 0x8D }, { "Ü", 0x8E }, @@ -15,13 +15,13 @@ CustomMessage::CustomMessage() { { "c", QM_LBLUE }, { "p", QM_PINK }, { "y", QM_YELLOW }, { "B", QM_BLACK } }; } -CustomMessage::~CustomMessage() { +CustomMessageManager::~CustomMessageManager() { this->textBoxSpecialCharacters.clear(); this->colors.clear(); this->messageTables.clear(); } -void CustomMessage::ReplaceSpecialCharacters(std::string& string) { +void CustomMessageManager::ReplaceSpecialCharacters(std::string& string) { // add special characters for (auto specialCharacterPair : this->textBoxSpecialCharacters) { size_t start_pos = 0; @@ -34,7 +34,7 @@ void CustomMessage::ReplaceSpecialCharacters(std::string& string) { } } -void CustomMessage::ReplaceColors(std::string& string) { +void CustomMessageManager::ReplaceColors(std::string& string) { for (auto colorPair : colors) { std::string textToReplace = "%"; textToReplace += colorPair.first; @@ -46,7 +46,7 @@ void CustomMessage::ReplaceColors(std::string& string) { } } -void CustomMessage::FormatCustomMessage(std::string& message, ItemID iid) { +void CustomMessageManager::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]); @@ -60,7 +60,7 @@ void CustomMessage::FormatCustomMessage(std::string& message, ItemID iid) { message += MESSAGE_END(); } -void CustomMessage::FormatCustomMessage(std::string& message) { +void CustomMessageManager::FormatCustomMessage(std::string& message) { size_t start_pos = 0; std::replace(message.begin(), message.end(), '&', NEWLINE()[0]); std::replace(message.begin(), message.end(), '^', WAIT_FOR_INPUT()[0]); @@ -70,7 +70,7 @@ void CustomMessage::FormatCustomMessage(std::string& message) { message += MESSAGE_END(); } -bool CustomMessage::InsertCustomMessage(std::string tableID, uint16_t textID, CustomMessageEntry messages) { +bool CustomMessageManager::InsertCustomMessage(std::string tableID, uint16_t textID, CustomMessageEntry messages) { auto result = messageTables.find(tableID); if (result == messageTables.end()) { return false; @@ -82,7 +82,7 @@ bool CustomMessage::InsertCustomMessage(std::string tableID, uint16_t textID, Cu -bool CustomMessage::CreateGetItemMessage(std::string tableID, GetItemID giid, ItemID iid, CustomMessageEntry messages) { +bool CustomMessageManager::CreateGetItemMessage(std::string tableID, GetItemID giid, ItemID iid, CustomMessageEntry messages) { FormatCustomMessage(messages.english, iid); FormatCustomMessage(messages.german, iid); FormatCustomMessage(messages.french, iid); @@ -90,14 +90,14 @@ bool CustomMessage::CreateGetItemMessage(std::string tableID, GetItemID giid, It return InsertCustomMessage(tableID, textID, messages); } -bool CustomMessage::CreateMessage(std::string tableID, uint16_t textID, CustomMessageEntry messages) { +bool CustomMessageManager::CreateMessage(std::string tableID, uint16_t textID, CustomMessageEntry messages) { FormatCustomMessage(messages.english); FormatCustomMessage(messages.german); FormatCustomMessage(messages.french); return InsertCustomMessage(tableID, textID, messages); } -CustomMessageEntry CustomMessage::RetrieveMessage(std::string tableID, uint16_t textID) { +CustomMessageEntry CustomMessageManager::RetrieveMessage(std::string tableID, uint16_t textID) { std::unordered_map::const_iterator result = messageTables.find(tableID); if (result == messageTables.end()) { return NULL_CUSTOM_MESSAGE; @@ -111,7 +111,7 @@ CustomMessageEntry CustomMessage::RetrieveMessage(std::string tableID, uint16_t return message; } -bool CustomMessage::ClearMessageTable(std::string tableID) { +bool CustomMessageManager::ClearMessageTable(std::string tableID) { auto result = messageTables.find(tableID); if (result == messageTables.end()) { return false; @@ -120,31 +120,31 @@ bool CustomMessage::ClearMessageTable(std::string tableID) { messageTable.clear(); } -bool CustomMessage::AddCustomMessageTable(std::string tableID) { +bool CustomMessageManager::AddCustomMessageTable(std::string tableID) { CustomMessageTable newMessageTable; return messageTables.emplace(tableID, newMessageTable).second; } -std::string CustomMessage::MESSAGE_END() { +std::string CustomMessageManager::MESSAGE_END() { return "\x02"s; } -std::string CustomMessage::ITEM_OBTAINED(uint8_t x) { +std::string CustomMessageManager::ITEM_OBTAINED(uint8_t x) { return "\x13"s + char(x); } -std::string CustomMessage::NEWLINE() { +std::string CustomMessageManager::NEWLINE() { return "\x01"s; } -std::string CustomMessage::COLOR(uint8_t x) { +std::string CustomMessageManager::COLOR(uint8_t x) { return "\x05"s + char(x); } -std::string CustomMessage::WAIT_FOR_INPUT() { +std::string CustomMessageManager::WAIT_FOR_INPUT() { return "\x04"s; } -std::string CustomMessage::PLAYER_NAME() { +std::string CustomMessageManager::PLAYER_NAME() { return "\x0F"s; } \ No newline at end of file diff --git a/soh/soh/Enhancements/custom_message/CustomMessage.h b/soh/soh/Enhancements/custom_message/CustomMessageManager.h similarity index 94% rename from soh/soh/Enhancements/custom_message/CustomMessage.h rename to soh/soh/Enhancements/custom_message/CustomMessageManager.h index 69ddcbe61..207d515e3 100644 --- a/soh/soh/Enhancements/custom_message/CustomMessage.h +++ b/soh/soh/Enhancements/custom_message/CustomMessageManager.h @@ -36,7 +36,7 @@ typedef struct { typedef std::unordered_map CustomMessageTable; -class CustomMessage { +class CustomMessageManager { private: std::unordered_map textBoxSpecialCharacters; std::unordered_map colors; @@ -56,10 +56,10 @@ class CustomMessage { std::string PLAYER_NAME(); public: - static CustomMessage* Instance; + static CustomMessageManager* Instance; - CustomMessage(); - ~CustomMessage(); + CustomMessageManager(); + ~CustomMessageManager(); bool CreateGetItemMessage(std::string tableID, GetItemID giid, ItemID iid, CustomMessageEntry messages); bool CreateMessage(std::string tableID, uint16_t textID, CustomMessageEntry messages); diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index 5159de0da..00bcadaf1 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -14,7 +14,7 @@ #include "3drando/rando_main.hpp" #include #include "Lib/ImGui/imgui_internal.h" -#include +#include using json = nlohmann::json; using namespace std::literals::string_literals; @@ -1483,22 +1483,22 @@ void Randomizer::LoadHintLocations(const char* spoilerFileName) { ParseHintLocationsFile(spoilerFileName); } - CustomMessage::Instance->ClearMessageTable(Randomizer::hintMessageTableID); - CustomMessage::Instance->AddCustomMessageTable(Randomizer::hintMessageTableID); + CustomMessageManager::Instance->ClearMessageTable(Randomizer::hintMessageTableID); + CustomMessageManager::Instance->AddCustomMessageTable(Randomizer::hintMessageTableID); - CustomMessage::Instance->CreateMessage( + CustomMessageManager::Instance->CreateMessage( Randomizer::hintMessageTableID, 0x7040, { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, gSaveContext.childAltarText, gSaveContext.childAltarText, gSaveContext.childAltarText }); - CustomMessage::Instance->CreateMessage( + CustomMessageManager::Instance->CreateMessage( Randomizer::hintMessageTableID, 0x7088, { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, gSaveContext.adultAltarText, gSaveContext.adultAltarText, gSaveContext.adultAltarText }); - CustomMessage::Instance->CreateMessage( + CustomMessageManager::Instance->CreateMessage( Randomizer::hintMessageTableID, 0x70CC, { TEXTBOX_TYPE_BLACK, TEXTBOX_POS_BOTTOM, gSaveContext.ganonHintText, gSaveContext.ganonHintText, gSaveContext.ganonHintText }); - CustomMessage::Instance->CreateMessage( + CustomMessageManager::Instance->CreateMessage( Randomizer::hintMessageTableID, 0x70CD, { TEXTBOX_TYPE_BLACK, TEXTBOX_POS_BOTTOM, gSaveContext.ganonText, gSaveContext.ganonText, gSaveContext.ganonText }); @@ -1511,7 +1511,7 @@ void Randomizer::LoadHintLocations(const char* spoilerFileName) { for (auto hintLocation : gSaveContext.hintLocations) { if(hintLocation.check == RC_LINKS_POCKET) break; this->hintLocations[hintLocation.check] = hintLocation.hintText; - CustomMessage::Instance->CreateMessage( + CustomMessageManager::Instance->CreateMessage( Randomizer::hintMessageTableID, hintLocation.check, { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, hintLocation.hintText, hintLocation.hintText, hintLocation.hintText }); } } @@ -4750,7 +4750,7 @@ typedef struct { } GetItemMessage; void CreateGetItemMessages(std::vector messageEntries) { - CustomMessage* customMessage = CustomMessage::Instance; + CustomMessageManager* customMessage = CustomMessageManager::Instance; customMessage->AddCustomMessageTable(Randomizer::getItemMessageTableID); for (GetItemMessage messageEntry : messageEntries) { customMessage->CreateGetItemMessage(Randomizer::getItemMessageTableID, messageEntry.giid, messageEntry.iid, @@ -4761,7 +4761,7 @@ void CreateGetItemMessages(std::vector messageEntries) { } void CreateScrubMessages() { - CustomMessage* customMessage = CustomMessage::Instance; + CustomMessageManager* customMessage = CustomMessageManager::Instance; customMessage->AddCustomMessageTable(Randomizer::scrubMessageTableID); const std::vector prices = { 10, 40 }; for (u8 price : prices) { diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 03a3eb7f5..c931edbd0 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -43,7 +43,7 @@ #include "variables.h" #include "macros.h" #include -#include +#include #ifdef __APPLE__ #include @@ -59,7 +59,7 @@ OTRGlobals* OTRGlobals::Instance; SaveManager* SaveManager::Instance; -CustomMessage* CustomMessage::Instance; +CustomMessageManager* CustomMessageManager::Instance; OTRGlobals::OTRGlobals() { context = Ship::GlobalCtx2::CreateInstance("Ship of Harkinian"); @@ -114,7 +114,7 @@ extern "C" void InitOTR() { #endif OTRGlobals::Instance = new OTRGlobals(); SaveManager::Instance = new SaveManager(); - CustomMessage::Instance = new CustomMessage(); + CustomMessageManager::Instance = new CustomMessageManager(); auto t = OTRGlobals::Instance->context->GetResourceManager()->LoadFile("version"); if (!t->bHasLoadError) @@ -1420,7 +1420,7 @@ extern "C" CustomMessageEntry Randomizer_CopyScrubMessage(u16 scrubTextId) { price = 40; break; } - return CustomMessage::Instance->RetrieveMessage(Randomizer::scrubMessageTableID, price); + return CustomMessageManager::Instance->RetrieveMessage(Randomizer::scrubMessageTableID, price); } extern "C" int CopyScrubMessage(u16 scrubTextId, char* buffer, const int maxBufferSize) { @@ -1496,22 +1496,22 @@ extern "C" int CopyScrubMessage(u16 scrubTextId, char* buffer, const int maxBuff } extern "C" CustomMessageEntry Randomizer_CopyAltarMessage() { - return (LINK_IS_ADULT) ? CustomMessage::Instance->RetrieveMessage(Randomizer::hintMessageTableID, 0x7088) - : CustomMessage::Instance->RetrieveMessage(Randomizer::hintMessageTableID, 0x7040); + return (LINK_IS_ADULT) ? CustomMessageManager::Instance->RetrieveMessage(Randomizer::hintMessageTableID, 0x7088) + : CustomMessageManager::Instance->RetrieveMessage(Randomizer::hintMessageTableID, 0x7040); } extern "C" CustomMessageEntry Randomizer_CopyGanonText() { - return CustomMessage::Instance->RetrieveMessage(Randomizer::hintMessageTableID, 0x70CD); + return CustomMessageManager::Instance->RetrieveMessage(Randomizer::hintMessageTableID, 0x70CD); } extern "C" CustomMessageEntry Randomizer_CopyGanonHintText() { - return CustomMessage::Instance->RetrieveMessage(Randomizer::hintMessageTableID, 0x70CC); + return CustomMessageManager::Instance->RetrieveMessage(Randomizer::hintMessageTableID, 0x70CC); } extern "C" CustomMessageEntry Randomizer_CopyHintFromCheck(RandomizerCheck check) { // we don't want to make a copy of the std::string returned from GetHintFromCheck // so we're just going to let RVO take care of it - const CustomMessageEntry hintText = CustomMessage::Instance->RetrieveMessage(Randomizer::hintMessageTableID, check); + const CustomMessageEntry hintText = CustomMessageManager::Instance->RetrieveMessage(Randomizer::hintMessageTableID, check); return hintText; } @@ -1524,7 +1524,7 @@ extern "C" s32 Randomizer_GetItemIdFromKnownCheck(RandomizerCheck randomizerChec } extern "C" CustomMessageEntry Randomizer_GetCustomGetItemMessage(GetItemID giid, char* buffer, const int maxBufferSize) { - const CustomMessageEntry getItemText = CustomMessage::Instance->RetrieveMessage(Randomizer::getItemMessageTableID, giid); + const CustomMessageEntry getItemText = CustomMessageManager::Instance->RetrieveMessage(Randomizer::getItemMessageTableID, giid); return getItemText; } @@ -1588,7 +1588,7 @@ extern "C" int CustomMessage_RetrieveIfExists(GlobalContext* globalCtx) { } else { textId = 0x00B5; } - messageEntry = CustomMessage::Instance->RetrieveMessage("BaseGameOverrides", textId); + messageEntry = CustomMessageManager::Instance->RetrieveMessage("BaseGameOverrides", textId); } } if (messageEntry.textBoxType != -1) { diff --git a/soh/soh/z_message_OTR.cpp b/soh/soh/z_message_OTR.cpp index c09286fad..64652189a 100644 --- a/soh/soh/z_message_OTR.cpp +++ b/soh/soh/z_message_OTR.cpp @@ -5,7 +5,7 @@ #include "global.h" #include "vt.h" #include -#include +#include extern "C" MessageTableEntry* sNesMessageEntryTablePtr; extern "C" MessageTableEntry* sGerMessageEntryTablePtr; @@ -95,21 +95,21 @@ extern "C" void OTRMessage_Init() sStaffMessageEntryTablePtr[i].msgSize = file2->messages[i].msg.size(); } - CustomMessage::Instance->AddCustomMessageTable(customMessageTableID); - CustomMessage::Instance->CreateGetItemMessage( + CustomMessageManager::Instance->AddCustomMessageTable(customMessageTableID); + CustomMessageManager::Instance->CreateGetItemMessage( customMessageTableID, (GetItemID)0x00B4, ITEM_SKULL_TOKEN, { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, "You got a %rGold Skulltula Token%w!&You've collected %r\x19%w tokens&in total!\x0E\x3C", - "Du erhlst 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" + "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( + CustomMessageManager::Instance->CreateGetItemMessage( customMessageTableID, (GetItemID)0x00B5, ITEM_SKULL_TOKEN, { TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, "You got a %rGold Skulltula Token%w!&You've collected %r\x19%w tokens&in total!", - "Du erhlst 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!" }); + "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!" }); } \ No newline at end of file