mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-01-07 03:48:10 -05:00
Auto scroll Check Tracker windows to current area
This commit is contained in:
parent
dba5df9e2a
commit
b6c0775f1b
@ -894,6 +894,26 @@ std::map<RandomizerCheck, RandomizerCheckObject> RandomizerCheckObjects::GetAllR
|
||||
return rcObjects;
|
||||
}
|
||||
|
||||
std::map<SceneID, RandomizerCheckArea> rcAreaBySceneID = {};
|
||||
std::map<SceneID, RandomizerCheckArea> RandomizerCheckObjects::GetAllRCAreaBySceneID() {
|
||||
//memoize on first request
|
||||
if (rcAreaBySceneID.size() == 0) {
|
||||
for (auto& [randomizerCheck, rcObject] : rcObjects) {
|
||||
rcAreaBySceneID[rcObject.sceneId] = rcObject.rcArea;
|
||||
}
|
||||
}
|
||||
return rcAreaBySceneID;
|
||||
}
|
||||
|
||||
RandomizerCheckArea RandomizerCheckObjects::GetRCAreaBySceneID(SceneID sceneId) {
|
||||
std::map<SceneID, RandomizerCheckArea> areas = GetAllRCAreaBySceneID();
|
||||
auto areaIt = areas.find(sceneId);
|
||||
if (areaIt == areas.end())
|
||||
return RCAREA_INVALID;
|
||||
else
|
||||
return areaIt->second;
|
||||
}
|
||||
|
||||
void RandomizerCheckObjects::UpdateImGuiVisibility() {
|
||||
for (auto& [randomizerCheck, locationIt] : rcObjects) {
|
||||
locationIt.visibleInImgui = (
|
||||
|
@ -92,5 +92,7 @@ namespace RandomizerCheckObjects {
|
||||
std::string GetRCAreaName(RandomizerCheckArea area);
|
||||
std::map<RandomizerCheck, RandomizerCheckObject> GetAllRCObjects();
|
||||
std::map<RandomizerCheckArea, std::map<RandomizerCheck, RandomizerCheckObject>> GetAllRCObjectsByArea();
|
||||
std::map<SceneID, RandomizerCheckArea> GetAllRCAreaBySceneID();
|
||||
RandomizerCheckArea GetRCAreaBySceneID(SceneID sceneId);
|
||||
void UpdateImGuiVisibility();
|
||||
}
|
||||
|
@ -700,8 +700,8 @@ bool HasItemBeenCollected(RandomizerCheckObject obj) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RandomizerCheckArea lastArea = RCAREA_INVALID;
|
||||
void DrawLocations() {
|
||||
RandomizerCheckObjects::UpdateImGuiVisibility();
|
||||
|
||||
if (ImGui::BeginTable("tableRandoChecks", 2, ImGuiTableFlags_BordersH | ImGuiTableFlags_BordersV)) {
|
||||
ImGui::TableSetupColumn("To Check", ImGuiTableColumnFlags_WidthStretch, 200.0f);
|
||||
@ -716,6 +716,10 @@ void DrawLocations() {
|
||||
locationSearch.Draw();
|
||||
|
||||
bool lastItemFound = false;
|
||||
bool doAreaScroll = false;
|
||||
RandomizerCheckArea currentArea = RCAREA_INVALID;
|
||||
if (gGlobalCtx != nullptr)
|
||||
currentArea = RandomizerCheckObjects::GetRCAreaBySceneID((SceneID)gGlobalCtx->sceneNum);
|
||||
|
||||
ImGui::BeginChild("ChildToCheckLocations", ImVec2(0, -8));
|
||||
for (auto& [rcArea, rcObjects] : RandomizerCheckObjects::GetAllRCObjectsByArea()) {
|
||||
@ -725,6 +729,7 @@ void DrawLocations() {
|
||||
locationSearch.PassFilter(locationIt.second.rcSpoilerName.c_str())) {
|
||||
|
||||
hasItems = true;
|
||||
doAreaScroll = (currentArea != RCAREA_INVALID && currentArea != lastArea && currentArea == rcArea);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -732,6 +737,10 @@ void DrawLocations() {
|
||||
if (hasItems) {
|
||||
ImGui::SetNextItemOpen(true, ImGuiCond_Once);
|
||||
if (ImGui::TreeNode(RandomizerCheckObjects::GetRCAreaName(rcArea).c_str())) {
|
||||
if (doAreaScroll) {
|
||||
ImGui::SetScrollHereY(0.0f);
|
||||
doAreaScroll = false;
|
||||
}
|
||||
for (auto& locationIt : rcObjects) {
|
||||
// If the location has its scene flag set
|
||||
if (HasItemBeenCollected(locationIt.second)) { // && checkedLocations.find(locationIt.rc) != checkedLocations.end()) {
|
||||
@ -786,21 +795,27 @@ void DrawLocations() {
|
||||
ImGui::EndChild();
|
||||
|
||||
// COLUMN 2 - CHECKED LOCATIONS
|
||||
doAreaScroll = false;
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::BeginChild("ChildCheckedLocations", ImVec2(0, -8));
|
||||
for (auto& areaIt : RandomizerCheckObjects::GetAllRCObjectsByArea()) {
|
||||
for (auto& [rcArea, rcObjects] : RandomizerCheckObjects::GetAllRCObjectsByArea()) {
|
||||
bool hasItems = false;
|
||||
for (auto& locationIt : areaIt.second) {
|
||||
for (auto& locationIt : rcObjects) {
|
||||
if (locationIt.second.visibleInImgui && checkedLocations.count(locationIt.second.rc)) {
|
||||
hasItems = true;
|
||||
doAreaScroll = (currentArea != RCAREA_INVALID && currentArea != lastArea && currentArea == rcArea);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasItems) {
|
||||
ImGui::SetNextItemOpen(true, ImGuiCond_Once);
|
||||
if (ImGui::TreeNode(RandomizerCheckObjects::GetRCAreaName(areaIt.first).c_str())) {
|
||||
for (auto& locationIt : areaIt.second) {
|
||||
if (ImGui::TreeNode(RandomizerCheckObjects::GetRCAreaName(rcArea).c_str())) {
|
||||
if (doAreaScroll) {
|
||||
ImGui::SetScrollHereY(0.0f);
|
||||
doAreaScroll = false;
|
||||
}
|
||||
for (auto& locationIt : rcObjects) {
|
||||
auto elfound = checkedLocations.find(locationIt.second.rc);
|
||||
if (locationIt.second.visibleInImgui && elfound != checkedLocations.end()) {
|
||||
// If the location has its scene flag set
|
||||
@ -832,6 +847,8 @@ void DrawLocations() {
|
||||
}
|
||||
ImGui::EndChild();
|
||||
ImGui::EndTable();
|
||||
|
||||
lastArea = currentArea;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user