filter on one side, trees on both

This commit is contained in:
briaguya 2022-08-18 15:50:25 -04:00
parent fb3320c3ed
commit 11a8dc85ee

View File

@ -3735,9 +3735,6 @@ void DrawRandoEditor(bool& open) {
RandomizerCheckObjects::UpdateImGuiVisibility(); RandomizerCheckObjects::UpdateImGuiVisibility();
} }
static ImGuiTextFilter locationSearch;
locationSearch.Draw();
if (ImGui::BeginTable("tableRandoLocations", 2, if (ImGui::BeginTable("tableRandoLocations", 2,
ImGuiTableFlags_BordersH | ImGuiTableFlags_BordersV)) { ImGuiTableFlags_BordersH | ImGuiTableFlags_BordersV)) {
ImGui::TableSetupColumn("Randomized", ImGuiTableColumnFlags_WidthStretch, 200.0f); ImGui::TableSetupColumn("Randomized", ImGuiTableColumnFlags_WidthStretch, 200.0f);
@ -3751,6 +3748,9 @@ void DrawRandoEditor(bool& open) {
ImGui::TableNextColumn(); ImGui::TableNextColumn();
window->DC.CurrLineTextBaseOffset = 0.0f; window->DC.CurrLineTextBaseOffset = 0.0f;
static ImGuiTextFilter locationSearch;
locationSearch.Draw();
ImGui::BeginChild("ChildRandomizedLocations"); ImGui::BeginChild("ChildRandomizedLocations");
for (auto areaIt : RandomizerCheckObjects::GetAllRCAreas()) { for (auto areaIt : RandomizerCheckObjects::GetAllRCAreas()) {
// todo fix this, it's hacky and copypasta // todo fix this, it's hacky and copypasta
@ -3770,8 +3770,8 @@ void DrawRandoEditor(bool& open) {
ImGui::SetNextItemOpen(true, ImGuiCond_Once); ImGui::SetNextItemOpen(true, ImGuiCond_Once);
if (ImGui::TreeNode(areaIt.second.c_str())) { if (ImGui::TreeNode(areaIt.second.c_str())) {
for (auto locationIt : RandomizerCheckObjects::GetAllRCObjects()) { for (auto locationIt : RandomizerCheckObjects::GetAllRCObjects()) {
if (!excludedLocations.count(locationIt.second.rc) && if (locationIt.second.visibleInImgui &&
locationIt.second.visibleInImgui && !excludedLocations.count(locationIt.second.rc) &&
locationIt.second.rcArea == areaIt.first && locationIt.second.rcArea == areaIt.first &&
locationSearch.PassFilter(locationIt.second.rcSpoilerName.c_str())) { locationSearch.PassFilter(locationIt.second.rcSpoilerName.c_str())) {
@ -3793,14 +3793,37 @@ void DrawRandoEditor(bool& open) {
window->DC.CurrLineTextBaseOffset = 0.0f; window->DC.CurrLineTextBaseOffset = 0.0f;
ImGui::BeginChild("ChildVanillaLocations"); ImGui::BeginChild("ChildVanillaLocations");
for (auto it : SpoilerfileCheckNameToEnum) { for (auto areaIt : RandomizerCheckObjects::GetAllRCAreas()) {
auto elfound = excludedLocations.find(it.second); // todo fix this, it's hacky and copypasta
if (elfound != excludedLocations.end() && locationSearch.PassFilter(it.first.c_str())) { bool hasItems = false;
if (ImGui::ArrowButton(std::to_string(it.second).c_str(), ImGuiDir_Left)) { for (auto locationIt : RandomizerCheckObjects::GetAllRCObjects()) {
if (locationIt.second.visibleInImgui &&
excludedLocations.count(locationIt.second.rc) &&
locationIt.second.rcArea == areaIt.first) {
hasItems = true;
break;
}
}
if (hasItems) {
ImGui::SetNextItemOpen(true, ImGuiCond_Once);
if (ImGui::TreeNode(areaIt.second.c_str())) {
for (auto locationIt : RandomizerCheckObjects::GetAllRCObjects()) {
auto elfound = excludedLocations.find(locationIt.first);
if (locationIt.second.visibleInImgui &&
elfound != excludedLocations.end() &&
locationIt.second.rcArea == areaIt.first) {
if (ImGui::ArrowButton(std::to_string(locationIt.first).c_str(), ImGuiDir_Left)) {
excludedLocations.erase(elfound); excludedLocations.erase(elfound);
} }
ImGui::SameLine(); ImGui::SameLine();
ImGui::Text("%s", it.first.c_str()); ImGui::Text(locationIt.second.rcShortName.c_str());
}
}
ImGui::TreePop();
}
} }
} }
ImGui::EndChild(); ImGui::EndChild();
@ -3808,7 +3831,6 @@ void DrawRandoEditor(bool& open) {
ImGui::EndTable(); ImGui::EndTable();
} }
ImGui::PopStyleVar(1); ImGui::PopStyleVar(1);
PaddedSeparator();
ImGui::EndTabItem(); ImGui::EndTabItem();
} else { } else {
locationsTabOpen = false; locationsTabOpen = false;