Renames CustomMessage to CustomMessageManager

This commit is contained in:
Christopher Leggett 2022-07-25 22:33:38 -04:00
parent 4c9e4b2d84
commit 822476373b
No known key found for this signature in database
GPG Key ID: 7093AE5FF7037D79
7 changed files with 56 additions and 56 deletions

View File

@ -179,7 +179,7 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="soh\Enhancements\custom_message\CustomMessage.cpp" />
<ClCompile Include="soh\Enhancements\custom_message\CustomMessageManager.cpp" />
<ClCompile Include="soh\Enhancements\cosmetics\CosmeticsEditor.cpp" />
<ClCompile Include="soh\Enhancements\debugger\actorViewer.cpp" />
<ClCompile Include="soh\Enhancements\gfx.c" />
@ -944,7 +944,7 @@
<ClCompile Include="src\overlays\misc\ovl_map_mark_data\z_map_mark_data.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="soh\Enhancements\custom_message\CustomMessage.h" />
<ClInclude Include="soh\Enhancements\custom_message\CustomMessageManager.h" />
<ClInclude Include="soh\Enhancements\cosmetics\CosmeticsEditor.h" />
<ClInclude Include="soh\Enhancements\debugger\actorViewer.h" />
<ClCompile Include="soh\Enhancements\randomizer\randomizer.h" />

View File

@ -2379,7 +2379,7 @@
<ClCompile Include="soh\Enhancements\randomizer\randomizer_item_tracker.cpp">
<Filter>Source Files\src</Filter>
</ClCompile>
<ClCompile Include="soh\Enhancements\custom_message\CustomMessage.cpp">
<ClCompile Include="soh\Enhancements\custom_message\CustomMessageManager.cpp">
<Filter>Source Files\soh\Enhancements\custom-message</Filter>
</ClCompile>
</ItemGroup>
@ -4070,7 +4070,7 @@
<ClInclude Include="soh\Enhancements\randomizer\randomizer_item_tracker.h">
<Filter>Source Files\src</Filter>
</ClInclude>
<ClInclude Include="soh\Enhancements\custom_message\CustomMessage.h">
<ClInclude Include="soh\Enhancements\custom_message\CustomMessageManager.h">
<Filter>Header Files\soh\Enhancements\custom-message</Filter>
</ClInclude>
</ItemGroup>

View File

@ -1,9 +1,9 @@
#include "CustomMessage.h"
#include "CustomMessageManager.h"
#include <algorithm>
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<std::string, CustomMessageTable>::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;
}

View File

@ -36,7 +36,7 @@ typedef struct {
typedef std::unordered_map<uint16_t, CustomMessageEntry> CustomMessageTable;
class CustomMessage {
class CustomMessageManager {
private:
std::unordered_map<std::string, char> textBoxSpecialCharacters;
std::unordered_map<std::string, char> 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);

View File

@ -14,7 +14,7 @@
#include "3drando/rando_main.hpp"
#include <soh/Enhancements/debugger/ImGuiHelpers.h>
#include "Lib/ImGui/imgui_internal.h"
#include <soh/Enhancements/custom_message/CustomMessage.h>
#include <soh/Enhancements/custom_message/CustomMessageManager.h>
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<GetItemMessage> 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<GetItemMessage> messageEntries) {
}
void CreateScrubMessages() {
CustomMessage* customMessage = CustomMessage::Instance;
CustomMessageManager* customMessage = CustomMessageManager::Instance;
customMessage->AddCustomMessageTable(Randomizer::scrubMessageTableID);
const std::vector<u8> prices = { 10, 40 };
for (u8 price : prices) {

View File

@ -43,7 +43,7 @@
#include "variables.h"
#include "macros.h"
#include <Utils/StringHelper.h>
#include <soh/Enhancements/custom_message/CustomMessage.h>
#include <soh/Enhancements/custom_message/CustomMessageManager.h>
#ifdef __APPLE__
#include <SDL_scancode.h>
@ -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) {

View File

@ -5,7 +5,7 @@
#include "global.h"
#include "vt.h"
#include <Text.h>
#include <soh/Enhancements/custom_message/CustomMessage.h>
#include <soh/Enhancements/custom_message/CustomMessageManager.h>
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 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"
"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 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!" });
"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!" });
}