mirror of
https://github.com/HarbourMasters/Shipwright
synced 2026-08-21 23:01:26 -04:00
Recalculate Available Checks from Current Region (#6165)
This commit is contained in:
@@ -270,6 +270,8 @@ std::vector<uint32_t> buttons = { BTN_A, BTN_B, BTN_CUP, BTN_CDOWN, BTN_CLEFT,
|
||||
BTN_Z, BTN_R, BTN_START, BTN_DUP, BTN_DDOWN, BTN_DLEFT, BTN_DRIGHT };
|
||||
static ImGuiTextFilter checkSearch;
|
||||
static bool recalculateAvailable = false;
|
||||
static RandomizerRegion availableChecksStartingRegion = RR_ROOT;
|
||||
static int16_t previousEntrance = 0;
|
||||
std::array<bool, RCAREA_INVALID> filterAreasHidden = { 0 };
|
||||
std::array<bool, RC_MAX> filterChecksHidden = { 0 };
|
||||
|
||||
@@ -610,9 +612,7 @@ void CheckTrackerLoadGame(int32_t fileNum) {
|
||||
|
||||
RegionTable_Init();
|
||||
|
||||
if (Rando::Context::GetInstance()->GetOption(RSK_SHUFFLE_ENTRANCES).Get()) {
|
||||
Rando::Context::GetInstance()->GetEntranceShuffler()->ApplyEntranceOverrides();
|
||||
}
|
||||
Rando::Context::GetInstance()->GetEntranceShuffler()->ApplyEntranceOverrides();
|
||||
|
||||
recalculateAvailable = true;
|
||||
}
|
||||
@@ -954,6 +954,8 @@ void SetAreaSpoiled(RandomizerCheckArea rcArea) {
|
||||
SaveManager::Instance->SaveSection(gSaveContext.fileNum, sectionId, true);
|
||||
}
|
||||
|
||||
void InternalRecalculateAvailableChecks(RandomizerRegion startingRegion);
|
||||
|
||||
void CheckTrackerWindow::DrawElement() {
|
||||
Color_Background = CVarGetColor(CVAR_TRACKER_CHECK("BgColor.Value"), Color_Bg_Default);
|
||||
Color_Area_Incomplete_Main = CVarGetColor(CVAR_TRACKER_CHECK("AreaIncomplete.MainColor.Value"), Color_Main_Default);
|
||||
@@ -1027,9 +1029,15 @@ void CheckTrackerWindow::DrawElement() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (gPlayState->nextEntranceIndex != previousEntrance) {
|
||||
previousEntrance = gPlayState->nextEntranceIndex;
|
||||
recalculateAvailable = true;
|
||||
}
|
||||
|
||||
if (recalculateAvailable) {
|
||||
recalculateAvailable = false;
|
||||
RecalculateAvailableChecks();
|
||||
InternalRecalculateAvailableChecks(availableChecksStartingRegion);
|
||||
availableChecksStartingRegion = RR_ROOT;
|
||||
}
|
||||
|
||||
// Quick Options
|
||||
@@ -2052,7 +2060,7 @@ void ImGuiDrawTwoColorPickerSection(const char* text, const char* cvarMainName,
|
||||
UIWidgets::PopStyleCombobox();
|
||||
}
|
||||
|
||||
void RecalculateAvailableChecks(RandomizerRegion startingRegion /* = RR_ROOT */) {
|
||||
void InternalRecalculateAvailableChecks(RandomizerRegion startingRegion) {
|
||||
if (!enableAvailableChecks || !GameInteractor::IsSaveLoaded()) {
|
||||
return;
|
||||
}
|
||||
@@ -2063,6 +2071,20 @@ void RecalculateAvailableChecks(RandomizerRegion startingRegion /* = RR_ROOT */)
|
||||
const auto& ctx = Rando::Context::GetInstance();
|
||||
logic = ctx->GetLogic();
|
||||
|
||||
int16_t entranceIndex = gPlayState->nextEntranceIndex;
|
||||
if (startingRegion == RR_ROOT && entranceIndex >= 0 && entranceIndex < ENTR_MAX) {
|
||||
// Try to find a mapped entrance
|
||||
// e.g. ENTR_DEKU_TREE_0_1 (index 1) is not mapped, but ENTR_DEKU_TREE_ENTRANCE (index 0) is mapped
|
||||
const int8_t scene = gEntranceTable[entranceIndex].scene;
|
||||
for (; entranceIndex >= 0 && gEntranceTable[entranceIndex].scene == scene; entranceIndex--) {
|
||||
const auto entrance = Rando::EntranceShuffler::GetEntranceByIndex(entranceIndex);
|
||||
if (entrance != nullptr) {
|
||||
startingRegion = entrance->GetOriginalConnectedRegionKey();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<RandomizerCheck> targetLocations;
|
||||
targetLocations.reserve(RC_MAX);
|
||||
for (auto& location : Rando::StaticData::GetLocationTable()) {
|
||||
@@ -2097,6 +2119,11 @@ void RecalculateAvailableChecks(RandomizerRegion startingRegion /* = RR_ROOT */)
|
||||
GetPerformanceTimer(PT_RECALCULATE_AVAILABLE_CHECKS).count());
|
||||
}
|
||||
|
||||
void RecalculateAvailableChecks(RandomizerRegion startingRegion /* = RR_ROOT */) {
|
||||
recalculateAvailable = true;
|
||||
availableChecksStartingRegion = startingRegion;
|
||||
}
|
||||
|
||||
void CheckTracker_LoadFromPreset(nlohmann::json info) {
|
||||
presetLoaded = true;
|
||||
presetPos = { info["pos"]["x"], info["pos"]["y"] };
|
||||
|
||||
Reference in New Issue
Block a user