diff --git a/mm/2s2h/Rando/CheckTracker/CheckTracker.cpp b/mm/2s2h/Rando/CheckTracker/CheckTracker.cpp index 48dfddb947..271a99bd86 100644 --- a/mm/2s2h/Rando/CheckTracker/CheckTracker.cpp +++ b/mm/2s2h/Rando/CheckTracker/CheckTracker.cpp @@ -15,6 +15,7 @@ #include "assets/archives/schedule_dma_static/schedule_dma_static_yar.h" #include "assets/interface/icon_item_field_static/icon_item_field_static.h" #include "assets/objects/gameplay_keep/gameplay_keep.h" +#include "assets/overlays/ovl_En_Syateki_Okuta/ovl_En_Syateki_Okuta.h" extern "C" { s16 Play_GetOriginalSceneId(s16 sceneId); @@ -40,6 +41,7 @@ static std::unordered_map betterSceneIndex = { #define CVAR_NAME_TRACKER_OPACITY "gRando.CheckTracker.Opacity" #define CVAR_NAME_TRACKER_SCALE "gRando.CheckTracker.Scale" #define CVAR_NAME_SHOW_CURRENT_SCENE "gRando.CheckTracker.ShowCurrentScene" +#define CVAR_NAME_SHOW_FILTER_OPTIONS "gRando.CheckTracker.ShowFilters" #define CVAR_SHOW_CHECK_TRACKER CVarGetInteger(CVAR_NAME_SHOW_CHECK_TRACKER, 0) #define CVAR_SHOW_LOGIC CVarGetInteger(CVAR_NAME_SHOW_LOGIC, 0) #define CVAR_HIDE_COLLECTED CVarGetInteger(CVAR_NAME_HIDE_COLLECTED, 0) @@ -48,6 +50,7 @@ static std::unordered_map betterSceneIndex = { #define CVAR_TRACKER_OPACITY CVarGetFloat(CVAR_NAME_TRACKER_OPACITY, 0.5f) #define CVAR_TRACKER_SCALE CVarGetFloat(CVAR_NAME_TRACKER_SCALE, 1.0f) #define CVAR_SHOW_CURRENT_SCENE CVarGetInteger(CVAR_NAME_SHOW_CURRENT_SCENE, 0) +#define CVAR_SHOW_FILTER_OPTIONS CVarGetInteger(CVAR_NAME_SHOW_FILTER_OPTIONS, 1) static bool sExpandedHeadersToggle = true; static bool sExpandedHeadersState = true; @@ -61,6 +64,7 @@ ImVec4 trackerBG = ImVec4{ 0, 0, 0, 0.5f }; std::map> sceneChecks; std::vector sortedSceneIds; std::unordered_map accessLogicFuncs; +std::vector checkTypeFilter; std::vector checkTypeIconList = { /*RCTYPE_UNKNOWN*/ gItemIconBombersNotebookTex, @@ -145,6 +149,18 @@ bool checkTrackerShouldShowRow(bool obtained, bool skipped) { return showCheck; } +bool checkTrackerIsFiltered(RandoCheckId randoCheckId) { + bool filterCheck = false; + if (checkTypeFilter.empty()) { + return false; + } + if (std::find(checkTypeFilter.begin(), checkTypeFilter.end(), + Rando::StaticData::Checks[randoCheckId].randoCheckType) == checkTypeFilter.end()) { + filterCheck = true; + } + return filterCheck; +} + void CheckTrackerDrawLogicalList() { std::set reachableRegions = {}; // Get connected entrances from starting & warp points @@ -358,6 +374,10 @@ void CheckTrackerDrawNonLogicalList() { continue; } + if (checkTrackerIsFiltered(checkId)) { + continue; + } + checks.push_back(checkId); } @@ -406,7 +426,8 @@ void CheckTrackerDrawNonLogicalList() { textColor = UIWidgets::ColorValues.at(UIWidgets::Colors::Gray); } - if (checkTrackerShouldShowRow(randoSaveCheck.obtained, randoSaveCheck.skipped)) { + if (checkTrackerShouldShowRow(randoSaveCheck.obtained, randoSaveCheck.skipped) && + !checkTrackerIsFiltered(randoCheckId)) { ImGui::PushStyleColor(ImGuiCol_Text, textColor); ImGui::BeginGroup(); float cursorPosY = ImGui::GetCursorPosY(); @@ -485,24 +506,70 @@ void CheckTrackerWindow::Draw() { return; } - bool sameLine = !(ImGui::GetContentRegionAvail().x <= 300.0f * trackerScale); - - UIWidgets::PushStyleCombobox(); - sCheckTrackerFilter.Draw("##filter", (ImGui::GetContentRegionAvail().x - - (sameLine ? (ImGui::CalcTextSize("Total: ").x + - ImGui::CalcTextSize(totalChecksFound().c_str()).x + 15.0f) - : 0))); - UIWidgets::PopStyleCombobox(); - if (!sCheckTrackerFilter.IsActive()) { - ImGui::SameLine(18.0f); - ImGui::Text("Search"); - } + if (CVAR_SHOW_FILTER_OPTIONS) { + bool sameLine = !(ImGui::GetContentRegionAvail().x <= 300.0f * trackerScale); + + UIWidgets::PushStyleCombobox(); + sCheckTrackerFilter.Draw("##filter", (ImGui::GetContentRegionAvail().x - + (sameLine ? (ImGui::CalcTextSize("Total: ").x + + ImGui::CalcTextSize(totalChecksFound().c_str()).x + 15.0f) + : 0))); + UIWidgets::PopStyleCombobox(); + if (!sCheckTrackerFilter.IsActive()) { + ImGui::SameLine(18.0f); + ImGui::Text("Search"); + } + + if (sameLine) { + ImGui::SameLine(ImGui::GetContentRegionAvail().x - + (ImGui::CalcTextSize("Total: ").x + ImGui::CalcTextSize(totalChecksFound().c_str()).x)); + } + ImGui::Text("Total: %s", totalChecksFound().c_str()); - if (sameLine) { - ImGui::SameLine(ImGui::GetContentRegionAvail().x - - (ImGui::CalcTextSize("Total: ").x + ImGui::CalcTextSize(totalChecksFound().c_str()).x)); + if (ImGui::BeginTable("Type Filter", (RCTYPE_MAX - 1) / 2, ImGuiTableFlags_SizingFixedSame)) { + for (int i = RCTYPE_UNKNOWN; i < RCTYPE_MAX; i++) { + ImGui::TableNextColumn(); + ImVec4 buttonCol = std::find(checkTypeFilter.begin(), checkTypeFilter.end(), (RandoCheckType)i) != + checkTypeFilter.end() + ? UIWidgets::ColorValues.at(UIWidgets::Colors::Gray) + : UIWidgets::ColorValues.at(UIWidgets::Colors::NoColor); + ImGui::PushStyleColor(ImGuiCol_Button, buttonCol); + ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(1.0f, 1.0f, 1.0f, 0.2f)); + ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(1.0f, 1.0f, 1.0f, 0.1f)); + TexturePtr textureId = Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName( + i == RCTYPE_UNKNOWN ? (const char*)gShootingGalleryOctorokCrossTex : checkTypeIconList[i]); + if (i == RCTYPE_OWL) { + ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 4.0f); + } else if (i == RCTYPE_SONG) { + ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 4.0f); + } + if (ImGui::ImageButton(std::to_string(i).c_str(), textureId, + ImVec2(i == RCTYPE_SONG ? 18.0f : 24.0f, i == RCTYPE_OWL ? 12.0f : 24.0f), + ImVec2(0, 0), ImVec2(1, 1), ImVec4(0, 0, 0, 0), + i == RCTYPE_UNKNOWN ? ImVec4(1, 0, 0, 1) + : i == RCTYPE_FREESTANDING ? ImVec4(0.78f, 1, 0.39f, 1) + : ImVec4(1, 1, 1, 1))) { + if (i == RCTYPE_UNKNOWN) { + checkTypeFilter.clear(); + } else { + bool typeExists = false; + for (int j = 0; j < checkTypeFilter.size(); j++) { + if (checkTypeFilter[j] == (RandoCheckType)i) { + typeExists = true; + checkTypeFilter.erase(checkTypeFilter.begin() + j); + break; + } + } + if (!typeExists) { + checkTypeFilter.push_back((RandoCheckType)i); + } + } + } + ImGui::PopStyleColor(3); + } + ImGui::EndTable(); + } } - ImGui::Text("Total: %s", totalChecksFound().c_str()); ImGui::BeginChild("Checks"); // if (CVAR_SHOW_LOGIC) { @@ -523,6 +590,7 @@ void SettingsWindow::DrawElement() { ImGui::SeparatorText("Check Tracker Settings"); if (ImGui::BeginTable("Settings Table", 2)) { ImGui::TableNextColumn(); + UIWidgets::CVarCheckbox("Show Filter Options", CVAR_NAME_SHOW_FILTER_OPTIONS); UIWidgets::CVarCheckbox("Dim Out of Logic Checks", CVAR_NAME_SHOW_LOGIC); UIWidgets::CVarCheckbox("Hide Collected Checks", CVAR_NAME_HIDE_COLLECTED); UIWidgets::CVarCheckbox("Hide Skipped Checks", CVAR_NAME_HIDE_SKIPPED); diff --git a/mm/2s2h/ShipUtils.cpp b/mm/2s2h/ShipUtils.cpp index 3ef51387f9..bb28eaaff6 100644 --- a/mm/2s2h/ShipUtils.cpp +++ b/mm/2s2h/ShipUtils.cpp @@ -15,6 +15,7 @@ #include "assets/interface/icon_item_dungeon_static/icon_item_dungeon_static.h" #include "assets/interface/icon_item_field_static/icon_item_field_static.h" #include "assets/objects/gameplay_keep/gameplay_keep.h" +#include "assets/overlays/ovl_En_Syateki_Okuta/ovl_En_Syateki_Okuta.h" extern "C" { #include "z64.h" @@ -44,7 +45,7 @@ std::unordered_map sceneNames = { #undef DEFINE_SCENE_UNSET // These textures are not in existing lists that we iterate over. -std::array miscellaneousTextures = { +std::array miscellaneousTextures = { gArcheryScoreIconTex, gBarrelTrackerIcon, gChestTrackerIcon, @@ -69,6 +70,7 @@ std::array miscellaneousTextures = { gPauseUnusedCursorTex, gWorldMapOwlFaceTex, gItemIconTingleMapTex, + gShootingGalleryOctorokCrossTex, }; std::array digitList = { gCounterDigit0Tex, gCounterDigit1Tex, gCounterDigit2Tex, gCounterDigit3Tex,