Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 85 additions & 17 deletions mm/2s2h/Rando/CheckTracker/CheckTracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -40,6 +41,7 @@ static std::unordered_map<s32, s32> 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)
Expand All @@ -48,6 +50,7 @@ static std::unordered_map<s32, s32> 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;
Expand All @@ -61,6 +64,7 @@ ImVec4 trackerBG = ImVec4{ 0, 0, 0, 0.5f };
std::map<SceneId, std::vector<RandoCheckId>> sceneChecks;
std::vector<SceneId> sortedSceneIds;
std::unordered_map<RandoCheckId, std::string> accessLogicFuncs;
std::vector<RandoCheckType> checkTypeFilter;

std::vector<const char*> checkTypeIconList = {
/*RCTYPE_UNKNOWN*/ gItemIconBombersNotebookTex,
Expand Down Expand Up @@ -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<RandoRegionId> reachableRegions = {};
// Get connected entrances from starting & warp points
Expand Down Expand Up @@ -358,6 +374,10 @@ void CheckTrackerDrawNonLogicalList() {
continue;
}

if (checkTrackerIsFiltered(checkId)) {
continue;
}

checks.push_back(checkId);
}

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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) {
Expand All @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion mm/2s2h/ShipUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -44,7 +45,7 @@ std::unordered_map<s16, const char*> sceneNames = {
#undef DEFINE_SCENE_UNSET

// These textures are not in existing lists that we iterate over.
std::array<const char*, 24> miscellaneousTextures = {
std::array<const char*, 25> miscellaneousTextures = {
gArcheryScoreIconTex,
gBarrelTrackerIcon,
gChestTrackerIcon,
Expand All @@ -69,6 +70,7 @@ std::array<const char*, 24> miscellaneousTextures = {
gPauseUnusedCursorTex,
gWorldMapOwlFaceTex,
gItemIconTingleMapTex,
gShootingGalleryOctorokCrossTex,
};

std::array<const char*, 11> digitList = { gCounterDigit0Tex, gCounterDigit1Tex, gCounterDigit2Tex, gCounterDigit3Tex,
Expand Down
Loading