From d94be0620822ac68b875bf9986736e445e96a42a Mon Sep 17 00:00:00 2001 From: Garrett Cox Date: Wed, 7 Sep 2022 12:08:29 -0500 Subject: [PATCH] Fix localized item names for shopsanity --- .../Enhancements/randomizer/randomizer.cpp | 25 ++++++------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index c1f0c49ba..73ec9a41f 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -111,8 +111,8 @@ Randomizer::Randomizer() { SpoilerfileGetNameToEnum[item.GetName().french] = item.GetRandomizerGet(); EnumToSpoilerfileGetName[item.GetRandomizerGet()] = { item.GetName().english, - item.GetName().french, item.GetName().english, + item.GetName().french, }; } } @@ -459,31 +459,22 @@ void Randomizer::LoadMerchantMessages(const char* spoilerFileName) { "%gobjet mystérieux%w pour 60 Rubis?\x1B&%gOui&Non%w", }); - // Make an inverse of std::unordered_map SpoilerfileGetNameToEnum - // so that we can get the name of the item from the RandomizerCheck - // TODO: We should probably just make the GetItemName in util.cpp more robust and use that instead. Currently - // it's not localized, doesn't have rando items, and quest items are separate, so we're doing this for now - std::unordered_map GetEnumToSpoilerfileName; - for (auto& [name, get] : SpoilerfileGetNameToEnum) { - GetEnumToSpoilerfileName[get] = name; - } - for (int index = 0; index < shopItemRandomizerChecks.size(); ++index) { RandomizerCheck shopItemCheck = shopItemRandomizerChecks[index]; - std::string shopItemName = GetEnumToSpoilerfileName[this->itemLocations[shopItemCheck]]; + std::vector shopItemName = EnumToSpoilerfileGetName[this->itemLocations[shopItemCheck]]; u16 shopItemPrice = merchantPrices[shopItemCheck]; // TODO: Magic number 100, we don't to overwrite deku scrub messages CustomMessageManager::Instance->CreateMessage( Randomizer::merchantMessageTableID, index + 100, { TEXTBOX_TYPE_BLACK, TEXTBOX_POS_VARIABLE, - "\x08%r" + shopItemName + ": " + std::to_string(shopItemPrice) + " Rupees&%wSpecial deal! ONE LEFT!&Get it while it lasts!\x0A\x02", - "\x08%r" + shopItemName + ": " + std::to_string(shopItemPrice) + " Rupees&%wSpecial deal! ONE LEFT!&Get it while it lasts!\x0A\x02", - "\x08%r" + shopItemName + ": " + std::to_string(shopItemPrice) + " Rubis&%wOffre spéciale! DERNIER EN STOCK!&Faites vite!\x0A\x02", + "\x08%r" + shopItemName[0] + ": " + std::to_string(shopItemPrice) + " Rupees&%wSpecial deal! ONE LEFT!&Get it while it lasts!\x0A\x02", + "\x08%r" + shopItemName[1] + ": " + std::to_string(shopItemPrice) + " Rupees&%wSpecial deal! ONE LEFT!&Get it while it lasts!\x0A\x02", + "\x08%r" + shopItemName[2] + ": " + std::to_string(shopItemPrice) + " Rubis&%wOffre spéciale! DERNIER EN STOCK!&Faites vite!\x0A\x02", }); CustomMessageManager::Instance->CreateMessage( Randomizer::merchantMessageTableID, index + shopItemRandomizerChecks.size() + 100, { TEXTBOX_TYPE_BLACK, TEXTBOX_POS_VARIABLE, - "\x08" + shopItemName + ": " + std::to_string(shopItemPrice) + " Rupees\x09&&\x1B%gBuy&Don't buy%w\x09\x02", - "\x08" + shopItemName + ": " + std::to_string(shopItemPrice) + " Rupees\x09&&\x1B%gBuy&Don't buy%w\x09\x02", - "\x08" + shopItemName + ": " + std::to_string(shopItemPrice) + " Rubis\x09&&\x1B%gAcheter&Ne pas acheter%w\x09\x02", + "\x08" + shopItemName[0] + ": " + std::to_string(shopItemPrice) + " Rupees\x09&&\x1B%gBuy&Don't buy%w\x09\x02", + "\x08" + shopItemName[1] + ": " + std::to_string(shopItemPrice) + " Rupees\x09&&\x1B%gBuy&Don't buy%w\x09\x02", + "\x08" + shopItemName[2] + ": " + std::to_string(shopItemPrice) + " Rubis\x09&&\x1B%gAcheter&Ne pas acheter%w\x09\x02", }); } }