Fix some options not updating correctly when dropping jsons and applying Presets (#5240)

* Re-Run ship init funcs on json drop and preset apply

* Prevent registering rando locations from running more than once

* Moves registered=true right after early return

* Move ShipInit call into applyPreset
This commit is contained in:
Christopher Leggett 2025-03-29 00:02:38 -04:00 committed by GitHub
parent 4d18a36e1a
commit 554379fd70
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 23 additions and 0 deletions

View file

@ -34,6 +34,7 @@ void applyPreset(std::vector<PresetEntry> entries) {
}
Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame();
}
ShipInit::Init("*");
}
void DrawPresetSelector(PresetType presetTypeId) {

View file

@ -59,6 +59,9 @@ void RegisterShuffleCows() {
static RegisterShipInitFunc initFunc(RegisterShuffleCows, { "IS_RANDO" });
void Rando::StaticData::RegisterCowLocations() {
static bool registered = false;
if (registered) return;
registered = true;
// clang-format-off
locationTable[RC_KF_LINKS_HOUSE_COW] = Location::Base(RC_KF_LINKS_HOUSE_COW, RCQUEST_BOTH, RCTYPE_COW, ACTOR_EN_COW, SCENE_LINKS_HOUSE, 0x00, "Links House Cow", RHT_KF_LINKS_HOUSE_COW, RG_MILK, SpoilerCollectionCheck::RandomizerInf(RAND_INF_COWS_MILKED_KF_LINKS_HOUSE_COW));
locationTable[RC_HF_COW_GROTTO_COW] = Location::Base(RC_HF_COW_GROTTO_COW, RCQUEST_BOTH, RCTYPE_COW, RCAREA_HYRULE_FIELD, ACTOR_EN_COW, SCENE_GROTTOS, TWO_ACTOR_PARAMS(3485, -291), "Cow Grotto Cow", RHT_HF_COW_GROTTO_COW, RG_MILK, SpoilerCollectionCheck::RandomizerInf(RAND_INF_COWS_MILKED_HF_COW_GROTTO_COW));

View file

@ -278,6 +278,9 @@ void RegisterShuffleCrates() {
}
void Rando::StaticData::RegisterCrateLocations() {
static bool registered = false;
if (registered) return;
registered = true;
// clang-format off
// Overworld Crates
// Randomizer Check Randomizer Check Quest Area Scene ID Params Short Name Hint Text Key Vanilla Spoiler Collection Check

View file

@ -185,6 +185,9 @@ void ShuffleFairies_UnregisterHooks() {
}
void Rando::StaticData::RegisterFairyLocations() {
static bool registered = false;
if (registered) return;
registered = true;
// clang-format off
locationTable[RC_SFM_FAIRY_GROTTO_FAIRY_1] = Location::Fairy(RC_SFM_FAIRY_GROTTO_FAIRY_1, RCQUEST_BOTH, RCAREA_SACRED_FOREST_MEADOW, SCENE_FAIRYS_FOUNTAIN, 0x1800, "Grotto Fairy 1", RHT_SFM_FAIRY_GROTTO_FAIRY, SpoilerCollectionCheck::RandomizerInf(RAND_INF_SFM_FAIRY_GROTTO_FAIRY_1));
locationTable[RC_SFM_FAIRY_GROTTO_FAIRY_2] = Location::Fairy(RC_SFM_FAIRY_GROTTO_FAIRY_2, RCQUEST_BOTH, RCAREA_SACRED_FOREST_MEADOW, SCENE_FAIRYS_FOUNTAIN, 0x1801, "Grotto Fairy 2", RHT_SFM_FAIRY_GROTTO_FAIRY, SpoilerCollectionCheck::RandomizerInf(RAND_INF_SFM_FAIRY_GROTTO_FAIRY_2));

View file

@ -45,6 +45,9 @@ void ShuffleFreestanding_OnVanillaBehaviorHandler(GIVanillaBehavior id, bool* sh
}
void Rando::StaticData::RegisterFreestandingLocations() {
static bool registered = false;
if (registered) return;
registered = true;
// clang-format off
locationTable[RC_KF_BOULDER_RUPEE_2] = Location::Collectable(RC_KF_BOULDER_RUPEE_2, RCQUEST_BOTH, RCTYPE_FREESTANDING, ACTOR_EN_ITEM00, SCENE_KOKIRI_FOREST, TWO_ACTOR_PARAMS(-712, 1857), "Boulder Maze Second Rupee", RHT_KOKIRI_FOREST_RUPEE, RG_BLUE_RUPEE, SpoilerCollectionCheck::RandomizerInf(RAND_INF_KF_BOULDER_RUPEE_2));
locationTable[RC_KF_BOULDER_RUPEE_1] = Location::Collectable(RC_KF_BOULDER_RUPEE_1, RCQUEST_BOTH, RCTYPE_FREESTANDING, ACTOR_EN_ITEM00, SCENE_KOKIRI_FOREST, TWO_ACTOR_PARAMS(-1009, 1556), "Boulder Maze First Rupee", RHT_KOKIRI_FOREST_RUPEE, RG_BLUE_RUPEE, SpoilerCollectionCheck::RandomizerInf(RAND_INF_KF_BOULDER_RUPEE_1));

View file

@ -157,6 +157,9 @@ void RegisterShuffleGrass() {
void Rando::StaticData::RegisterGrassLocations() {
static bool registered = false;
if (registered) return;
registered = true;
// clang-format off
// Overworld Grass
// Randomizer Check Randomizer Check Quest Area Scene ID Params Short Name Spoiler Name Hint Text Key Vanilla Spoiler Collection Check

View file

@ -95,6 +95,9 @@ void ShufflePots_OnVanillaBehaviorHandler(GIVanillaBehavior id, bool* should, va
}
void Rando::StaticData::RegisterPotLocations() {
static bool registered = false;
if (registered) return;
registered = true;
// clang-format off
// Overworld Pots
// Randomizer Check Randomizer Check Quest Area Scene ID Params Short Name Hint Text Key Vanilla Spoiler Collection Check

View file

@ -580,6 +580,9 @@ extern "C" {
}
void Rando::StaticData::RegisterFishLocations() {
static bool registered = false;
if (registered) return;
registered = true;
// clang-format off
// Fishing Pond
locationTable[RC_LH_CHILD_FISH_1] = Location::Fish(RC_LH_CHILD_FISH_1, RCQUEST_BOTH, ACTOR_FISHING, SCENE_FISHING_POND, 100, RAND_INF_CHILD_FISH_1, "Child Pond Fish 1", RHT_LH_POND_FISH, RG_NONE);

View file

@ -2538,6 +2538,7 @@ void SoH_ProcessDroppedFiles(std::string filePath) {
std::dynamic_pointer_cast<Ship::ConsoleWindow>(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Console"))->ClearBindings();
gui->SaveConsoleVariablesNextFrame();
ShipInit::Init("*");
uint32_t finalHash = boost::hash_32<std::string>{}(configJson.dump());
gui->GetGameOverlay()->TextDrawNotification(30.0f, true, "Configuration Loaded. Hash: %d", finalHash);