From dbb4e3eefcdca09978580bdf55f68ca3dd500da5 Mon Sep 17 00:00:00 2001 From: briaguya Date: Thu, 18 Aug 2022 08:20:52 -0400 Subject: [PATCH] start on tree view --- .../Enhancements/randomizer/randomizer.cpp | 48 +++++++++---------- .../randomizer/randomizer_check_objects.h | 2 + 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index 6f18e878e4..070909814d 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -3747,37 +3747,35 @@ void DrawRandoEditor(bool& open) { window->DC.CurrLineTextBaseOffset = 0.0f; ImGui::BeginChild("ChildRandomizedLocations"); - for (auto it : SpoilerfileCheckNameToEnum) { - if (!excludedLocations.count(it.second) && locationSearch.PassFilter(it.first.c_str())) { - if (ImGui::ArrowButton(std::to_string(it.second).c_str(), ImGuiDir_Right)) { - excludedLocations.insert(it.second); + for (auto areaIt : RandomizerCheckObjects::GetAllRCAreas()) { + // todo fix this, it's hacky and we shouldn't need to iterate through so many times + bool hasItems = false; + for (auto locationIt : RandomizerCheckObjects::GetAllRCObjects()) { + if (!excludedLocations.count(locationIt.second.rc) && + locationIt.second.rcArea == areaIt.first && + locationSearch.PassFilter(locationIt.second.rcSpoilerName.c_str())) { + hasItems = true; + break; } - ImGui::SameLine(); - ImGui::Text("%s", it.first.c_str()); } - /* Checkbox UI - - if (locationSearch.PassFilter(it.first.c_str())) { - // we need the part from ## on to make each button unique in imgui - std::string buttonKey = "->##" + std::to_string(it.second); - // if (ImGui::SmallButton(buttonKey.c_str())) { - // excludedLocations.insert(it.second); - // } - auto elfound = excludedLocations.find(it.second); - bool varTheImguiCheckboxNeeds = elfound == excludedLocations.end(); - if (ImGui::Checkbox(it.first.c_str(), &varTheImguiCheckboxNeeds)) { - if (elfound != excludedLocations.end()) { - excludedLocations.erase(elfound); - } else { - excludedLocations.insert(it.second); + if (hasItems) { + ImGui::SetNextItemOpen(true, ImGuiCond_Once); + if (ImGui::TreeNode(areaIt.second.c_str())) { + for (auto locationIt : RandomizerCheckObjects::GetAllRCObjects()) { + if (!excludedLocations.count(locationIt.second.rc) && + locationIt.second.rcArea == areaIt.first && + locationSearch.PassFilter(locationIt.second.rcSpoilerName.c_str())) { + if (ImGui::ArrowButton(std::to_string(locationIt.first).c_str(), ImGuiDir_Right)) { + excludedLocations.insert(locationIt.first); + } + ImGui::SameLine(); + ImGui::Text(locationIt.second.rcShortName.c_str()); + } } + ImGui::TreePop(); } - // ImGui::SameLine(); - // ImGui::Text("%s", it.first.c_str()); } - - */ } ImGui::EndChild(); diff --git a/soh/soh/Enhancements/randomizer/randomizer_check_objects.h b/soh/soh/Enhancements/randomizer/randomizer_check_objects.h index 2e175f43c4..44e8a149a2 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_check_objects.h +++ b/soh/soh/Enhancements/randomizer/randomizer_check_objects.h @@ -1,6 +1,7 @@ #pragma once #include "randomizerTypes.h" #include +#include #include // Check types based on main settings @@ -72,6 +73,7 @@ typedef struct { } RandomizerCheckObject; namespace RandomizerCheckObjects { + std::map GetAllRCAreas(); std::unordered_map GetAllRCObjects(); RandomizerCheckObject GetRCObject(RandomizerCheck check);