Merge branch 'rando-next' of https://github.com/HarbourMasters/Shipwright into shopsanity

This commit is contained in:
Garrett Cox 2022-09-06 13:30:49 -05:00
commit b2f4d5e95a
9 changed files with 69 additions and 9 deletions

View File

@ -329,6 +329,7 @@ namespace SohImGui {
statsWindowOpen = CVar_GetS32("gStatsEnabled", 0);
CVar_RegisterS32("gRandomizeRupeeNames", 1);
CVar_RegisterS32("gRandoRelevantNavi", 1);
CVar_RegisterS32("gRandoMatchKeyColors", 1);
#ifdef __SWITCH__
Ship::Switch::SetupFont(io->Fonts);
#endif

View File

@ -262,5 +262,6 @@ extern GraphicsContext* __gfxCtx;
#define NUM_TRIALS 6
#define NUM_SHOP_ITEMS 64
#define NUM_SCRUBS 35
#endif

View File

@ -110,7 +110,7 @@ Sprite* Randomizer::GetSeedTexture(uint8_t index) {
Randomizer::~Randomizer() {
this->randoSettings.clear();
this->itemLocations.clear();
this->randomizerMerchantPrices.clear();
this->merchantPrices.clear();
}
std::unordered_map<std::string, RandomizerInf> spoilerFileTrialToEnum = {
@ -1095,6 +1095,7 @@ void Randomizer::ParseRandomizerSettingsFile(const char* spoilerFileName) {
} else if (it.value() == "Anywhere") {
gSaveContext.randoSettings[index].value = 3;
}
break;
case RSK_KEYSANITY:
if(it.value() == "Start With") {
gSaveContext.randoSettings[index].value = 0;
@ -1393,7 +1394,7 @@ void Randomizer::ParseItemLocationsFile(const char* spoilerFileName, bool silent
gSaveContext.itemLocations[index].check = SpoilerfileCheckNameToEnum[it.key()];
gSaveContext.itemLocations[index].get = SpoilerfileGetNameToEnum[itemit.value()];
} else if (itemit.key() == "price") {
randomizerMerchantPrices[gSaveContext.itemLocations[index].check] = itemit.value();
merchantPrices[gSaveContext.itemLocations[index].check] = itemit.value();
}
}
} else {
@ -2616,8 +2617,8 @@ ScrubIdentity Randomizer::IdentifyScrub(s32 sceneNum, s32 actorParams, s32 respa
break;
}
if (randomizerMerchantPrices.find(scrubIdentity.randomizerCheck) != randomizerMerchantPrices.end()) {
scrubIdentity.itemPrice = randomizerMerchantPrices[scrubIdentity.randomizerCheck];
if (merchantPrices.find(scrubIdentity.randomizerCheck) != merchantPrices.end()) {
scrubIdentity.itemPrice = merchantPrices[scrubIdentity.randomizerCheck];
}
return scrubIdentity;

View File

@ -14,13 +14,11 @@ class Randomizer {
private:
std::unordered_map<RandomizerCheck, RandomizerGet> itemLocations;
std::unordered_map<RandomizerCheck, std::string> hintLocations;
std::unordered_map<RandomizerInf, bool> trialsRequired;
std::string childAltarText;
std::string adultAltarText;
std::string ganonHintText;
std::string ganonText;
std::unordered_map<RandomizerSettingKey, u8> randoSettings;
std::unordered_map<RandomizerCheck, u16> randomizerMerchantPrices;
void ParseRandomizerSettingsFile(const char* spoilerFileName);
void ParseHintLocationsFile(const char* spoilerFileName);
void ParseRequiredTrialsFile(const char* spoilerFileName);
@ -38,6 +36,10 @@ class Randomizer {
static const std::string rupeeMessageTableID;
static const std::string NaviRandoMessageTableID;
// Public for now to be accessed by SaveManager, will be made private again soon :tm:
std::unordered_map<RandomizerInf, bool> trialsRequired;
std::unordered_map<RandomizerCheck, u16> merchantPrices;
static Sprite* GetSeedTexture(uint8_t index);
s16 GetItemModelFromId(s16 itemId);
s32 GetItemIDFromGetItemID(s32 getItemId);

View File

@ -1392,7 +1392,24 @@ namespace GameMenuBar {
UIWidgets::Tooltip(
"When obtaining rupees, randomize what the rupee is called in the textbox."
);
UIWidgets::PaddedEnhancementCheckbox("Key Colors Match Dungeon", "gRandoMatchKeyColors", true, false);
// Only disable the key colors checkbox when none of the keysanity settings are set to "Any Dungeon", "Overworld" or "Anywhere"
bool disableKeyColors = true;
if (OTRGlobals::Instance->gRandomizer->GetRandoSettingValue(RSK_KEYSANITY) > 2 ||
OTRGlobals::Instance->gRandomizer->GetRandoSettingValue(RSK_GERUDO_KEYS) > 0 ||
OTRGlobals::Instance->gRandomizer->GetRandoSettingValue(RSK_BOSS_KEYSANITY) > 2 ||
OTRGlobals::Instance->gRandomizer->GetRandoSettingValue(RSK_GANONS_BOSS_KEY) > 2 ||
!gSaveContext.n64ddFlag) {
disableKeyColors = false;
}
const char* disableKeyColorsText =
"This setting is disabled because a savefile is loaded without any key\n"
"shuffle settings set to \"Any Dungeon\", \"Overworld\" or \"Anywhere\"";
UIWidgets::PaddedEnhancementCheckbox("Key Colors Match Dungeon", "gRandoMatchKeyColors", true, false,
disableKeyColors, disableKeyColorsText);
UIWidgets::Tooltip(
"Matches the color of small keys and boss keys to the dungeon they belong to. "
"This helps identify keys from afar and adds a little bit of flair.\n\nThis only "

View File

@ -91,6 +91,24 @@ void SaveManager::LoadRandomizerVersion1() {
}
SaveManager::Instance->LoadData("adultTradeItems", gSaveContext.adultTradeItems);
std::shared_ptr<Randomizer> randomizer = OTRGlobals::Instance->gRandomizer;
size_t merchantPricesSize = 0;
if (randomizer->GetRandoSettingValue(RSK_SHUFFLE_SCRUBS) > 0) {
merchantPricesSize += NUM_SCRUBS;
}
// TODO: Add shop item count when shopsanity is enabled
SaveManager::Instance->LoadArray("merchantPrices", merchantPricesSize, [&](size_t i) {
SaveManager::Instance->LoadStruct("", [&]() {
RandomizerCheck rc;
SaveManager::Instance->LoadData("check", rc);
uint32_t price;
SaveManager::Instance->LoadData("price", price);
randomizer->merchantPrices[rc] = price;
});
});
}
void SaveManager::SaveRandomizer() {
@ -135,6 +153,20 @@ void SaveManager::SaveRandomizer() {
}
SaveManager::Instance->SaveData("adultTradeItems", gSaveContext.adultTradeItems);
std::shared_ptr<Randomizer> randomizer = OTRGlobals::Instance->gRandomizer;
std::vector<std::pair<RandomizerCheck, u16>> merchantPrices;
for (const auto & [ check, price ] : randomizer->merchantPrices) {
merchantPrices.push_back(std::make_pair(check, price));
}
SaveManager::Instance->SaveArray("merchantPrices", merchantPrices.size(), [&](size_t i) {
SaveManager::Instance->SaveStruct("", [&]() {
SaveManager::Instance->SaveData("check", merchantPrices[i].first);
SaveManager::Instance->SaveData("price", merchantPrices[i].second);
});
});
}
void SaveManager::Init() {

View File

@ -8,7 +8,6 @@
#define NUM_DUNGEONS 8
#define NUM_COWS 10
#define NUM_SCRUBS 35
/**
* Initialize new save.
@ -521,6 +520,7 @@ void Sram_InitSave(FileChooseContext* fileChooseCtx) {
// complete mask quest
if (Randomizer_GetSettingValue(RSK_COMPLETE_MASK_QUEST)) {
gSaveContext.infTable[7] |= 0x80; // Soldier Wears Keaton Mask
gSaveContext.itemGetInf[3] |= 0x100; // Sold Keaton Mask
gSaveContext.itemGetInf[3] |= 0x200; // Sold Skull Mask
gSaveContext.itemGetInf[3] |= 0x400; // Sold Spooky Mask

View File

@ -349,6 +349,7 @@ void EnSyatekiMan_EndGame(EnSyatekiMan* this, GlobalContext* globalCtx) {
this->getItemId = GI_BULLET_BAG_50;
}
} else {
this->getItemEntry = (GetItemEntry)GET_ITEM_NONE;
this->getItemId = GI_RUPEE_PURPLE;
}
} else {
@ -371,6 +372,7 @@ void EnSyatekiMan_EndGame(EnSyatekiMan* this, GlobalContext* globalCtx) {
break;
}
} else {
this->getItemEntry = (GetItemEntry)GET_ITEM_NONE;
this->getItemId = GI_RUPEE_PURPLE;
}
}

View File

@ -381,7 +381,11 @@ void KaleidoScope_DrawItemSelect(GlobalContext* globalCtx) {
--INV_CONTENT(ITEM_TRADE_CHILD);
} else if ((pauseCtx->stickRelX < -30 || pauseCtx->stickRelX > 30 || pauseCtx->stickRelY < -30 || pauseCtx->stickRelY > 30) ||
dpad && CHECK_BTN_ANY(input->press.button, BTN_DUP | BTN_DDOWN | BTN_DLEFT | BTN_DRIGHT)) {
INV_CONTENT(ITEM_TRADE_CHILD) ^= ITEM_MASK_KEATON ^ ITEM_MASK_TRUTH;
if (INV_CONTENT(ITEM_TRADE_CHILD) == ITEM_LETTER_ZELDA) {
INV_CONTENT(ITEM_TRADE_CHILD) = ITEM_MASK_KEATON;
} else {
INV_CONTENT(ITEM_TRADE_CHILD) ^= ITEM_MASK_KEATON ^ ITEM_MASK_TRUTH;
}
Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
}
for (uint16_t cSlotIndex = 0; cSlotIndex < ARRAY_COUNT(gSaveContext.equips.cButtonSlots); cSlotIndex++) {