From 069f7c98a60d35e52658f08fe62f3952f5c8edaf Mon Sep 17 00:00:00 2001 From: PurpleHato Date: Fri, 2 Sep 2022 22:07:05 +0200 Subject: [PATCH 01/11] Enum + combo box --- .../randomizer/randomizer_item_tracker.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp index 8cede9a66..e9ca06b5f 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp @@ -225,6 +225,14 @@ std::vector buttonMap = { BTN_DRIGHT }; +typedef enum { + ITEM_TRACKER_NUMBER_NONE, + ITEM_TRACKER_NUMBER_CURRENT_CAPACITY_ONLY, + ITEM_TRACKER_NUMBER_CURRENT_AMMO_ONLY, + ITEM_TRACKER_NUMBER_CAPACITY, + ITEM_TRACKER_NUMBER_AMMO, +} ItemTrackerNumberOption; + bool IsValidSaveFile() { bool validSave = gSaveContext.fileNum >= 0 && gSaveContext.fileNum <= 2; return validSave; @@ -325,7 +333,7 @@ void DrawItemCount(ItemTrackerItem item) { ImGui::Text("%d", (int)currentAndMax.x); ImGui::PopStyleColor(); } else { - if (CVar_GetS32("gItemTrackerDisplayCurrentMax", 0) == 1) { + if (CVar_GetS32("gItemTrackerCapacityTrack", 0) == ITEM_TRACKER_NUMBER_CAPACITY) { std::string currentAndMaxString = std::to_string((int)currentAndMax.x) + "/" + std::to_string((int)currentAndMax.y); ImGui::SetCursorScreenPos(ImVec2(p.x + (iconSize / 2) - (ImGui::CalcTextSize(currentAndMaxString.c_str()).x / 2), p.y - 14)); @@ -876,8 +884,9 @@ void DrawItemTrackerOptions(bool& open) { PaddedSeparator(); SohImGui::EnhancementSliderInt("Icon size : %dpx", "##ITEMTRACKERICONSIZE", "gItemTrackerIconSize", 25, 128, "", 36, true); SohImGui::EnhancementSliderInt("Icon margins : %dpx", "##ITEMTRACKERSPACING", "gItemTrackerIconSpacing", -5, 50, "", 12, true); - PaddedEnhancementCheckbox("Display \"Current/Max\" values", "gItemTrackerDisplayCurrentMax", 0); - if (CVar_GetS32("gItemTrackerDisplayCurrentMax", 0) == 0) { + + LabeledComboBoxRightAligned("Ammo/Capacity Tracking", "gItemTrackerCapacityTrack", { "No Numbers", "Current Capacity", "Current Ammo", "currentCapacity/maxCapacity", "currentAmmo/currentCapacity" }, 0); + if (CVar_GetS32("gItemTrackerCapacityTrack", 0) == ITEM_TRACKER_NUMBER_CURRENT_CAPACITY_ONLY || CVar_GetS32("gItemTrackerCapacityTrack", 0) == ITEM_TRACKER_NUMBER_CURRENT_AMMO_ONLY) { PaddedEnhancementCheckbox("Align count to left side", "gItemTrackerCurrentOnLeft", 0); } From 2ead2557f02597d03e5814bb339336fe385a68f7 Mon Sep 17 00:00:00 2001 From: PurpleHato Date: Fri, 2 Sep 2022 22:41:05 +0200 Subject: [PATCH 02/11] combobox title rename + no number tracking --- soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp index e9ca06b5f..93a042cbd 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp @@ -342,6 +342,8 @@ void DrawItemCount(ItemTrackerItem item) { ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(0, 255, 0, 255)); ImGui::Text("%d", (int)currentAndMax.y); ImGui::PopStyleColor(); + } else if (CVar_GetS32("gItemTrackerCapacityTrack", 0) == ITEM_TRACKER_NUMBER_NONE) { + return; } else { std::string currentString = std::to_string((int)currentAndMax.x); float x = CVar_GetS32("gItemTrackerCurrentOnLeft", 0) ? p.x : p.x + (iconSize / 2) - (ImGui::CalcTextSize(currentString.c_str()).x / 2); @@ -885,7 +887,7 @@ void DrawItemTrackerOptions(bool& open) { SohImGui::EnhancementSliderInt("Icon size : %dpx", "##ITEMTRACKERICONSIZE", "gItemTrackerIconSize", 25, 128, "", 36, true); SohImGui::EnhancementSliderInt("Icon margins : %dpx", "##ITEMTRACKERSPACING", "gItemTrackerIconSpacing", -5, 50, "", 12, true); - LabeledComboBoxRightAligned("Ammo/Capacity Tracking", "gItemTrackerCapacityTrack", { "No Numbers", "Current Capacity", "Current Ammo", "currentCapacity/maxCapacity", "currentAmmo/currentCapacity" }, 0); + LabeledComboBoxRightAligned("Ammo/Capacity Tracking", "gItemTrackerCapacityTrack", { "No Numbers", "Current Capacity", "Current Ammo", "Current Capacity / Max Capacity", "Current Ammo / Current Capacity" }, 0); if (CVar_GetS32("gItemTrackerCapacityTrack", 0) == ITEM_TRACKER_NUMBER_CURRENT_CAPACITY_ONLY || CVar_GetS32("gItemTrackerCapacityTrack", 0) == ITEM_TRACKER_NUMBER_CURRENT_AMMO_ONLY) { PaddedEnhancementCheckbox("Align count to left side", "gItemTrackerCurrentOnLeft", 0); } From f69d9697e9356bfcd785ba444d6062f5503387f2 Mon Sep 17 00:00:00 2001 From: PurpleHato Date: Sat, 3 Sep 2022 01:30:47 +0200 Subject: [PATCH 03/11] Struct instead of ImVec + basic comportment for all case --- .../randomizer/randomizer_item_tracker.cpp | 152 ++++++++++++------ 1 file changed, 103 insertions(+), 49 deletions(-) diff --git a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp index 93a042cbd..6ba5c7f7b 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp @@ -233,77 +233,102 @@ typedef enum { ITEM_TRACKER_NUMBER_AMMO, } ItemTrackerNumberOption; +struct ItemTrackerNumbers { + int currentCapacity; + int maxCapacity; + int currentAmmo; +}; + bool IsValidSaveFile() { bool validSave = gSaveContext.fileNum >= 0 && gSaveContext.fileNum <= 2; return validSave; } -ImVec2 GetItemCurrentAndMax(ItemTrackerItem item) { - ImVec2 result = { 0, 0 }; - +ItemTrackerNumbers GetItemCurrentAndMax(ItemTrackerItem item) { + ItemTrackerNumbers result; + result.currentCapacity = 0; + result.maxCapacity = 0; + result.currentAmmo = 0; + switch (item.id) { case ITEM_STICK: - result.x = CUR_CAPACITY(UPG_STICKS); - result.y = 30; + result.currentCapacity = CUR_CAPACITY(UPG_STICKS); + result.maxCapacity = 30; + result.currentAmmo = AMMO(ITEM_STICK); break; case ITEM_NUT: - result.x = CUR_CAPACITY(UPG_NUTS); - result.y = 40; + result.currentCapacity = CUR_CAPACITY(UPG_NUTS); + result.maxCapacity = 40; + result.currentAmmo = AMMO(ITEM_NUT); break; case ITEM_BOMB: - result.x = CUR_CAPACITY(UPG_BOMB_BAG); - result.y = 40; + result.currentCapacity = CUR_CAPACITY(UPG_BOMB_BAG); + result.maxCapacity = 40; + result.currentAmmo = AMMO(ITEM_BOMB); break; case ITEM_BOW: - result.x = CUR_CAPACITY(UPG_QUIVER); - result.y = 50; + result.currentCapacity = CUR_CAPACITY(UPG_QUIVER); + result.maxCapacity = 50; + result.currentAmmo = AMMO(ITEM_BOW); break; case ITEM_SLINGSHOT: - result.x = CUR_CAPACITY(UPG_BULLET_BAG); - result.y = 50; + result.currentCapacity = CUR_CAPACITY(UPG_BULLET_BAG); + result.maxCapacity = 50; + result.currentAmmo = AMMO(ITEM_SLINGSHOT); break; case ITEM_WALLET_ADULT: + result.currentCapacity = CUR_CAPACITY(UPG_WALLET); + result.maxCapacity = 200; + result.currentAmmo = gSaveContext.rupees; + break; case ITEM_WALLET_GIANT: - result.x = CUR_CAPACITY(UPG_WALLET); - result.y = 500; + result.currentCapacity = CUR_CAPACITY(UPG_WALLET); + result.maxCapacity = 500; + result.currentAmmo = gSaveContext.rupees; + break; + case ITEM_BOMBCHU: + result.currentCapacity = 50; + result.maxCapacity = 50; + result.currentAmmo = AMMO(ITEM_BOMBCHU); break; case ITEM_BEAN: - result.x = AMMO(ITEM_BEAN); - result.y = 10; + result.currentCapacity = 10; + result.maxCapacity = 10; + result.currentAmmo = AMMO(ITEM_BEAN); break; case QUEST_SKULL_TOKEN: - result.x = gSaveContext.inventory.gsTokens; - result.y = 100; + result.maxCapacity = 100; + result.currentAmmo = gSaveContext.inventory.gsTokens; break; case ITEM_KEY_SMALL: - result.x = gSaveContext.inventory.dungeonKeys[item.data]; + result.currentCapacity = gSaveContext.inventory.dungeonKeys[item.data]; switch (item.data) { case SCENE_BMORI1: - result.y = 5; + result.maxCapacity = 5; break; case SCENE_HIDAN: - result.y = 8; + result.maxCapacity = 8; break; case SCENE_MIZUSIN: - result.y = 6; + result.maxCapacity = 6; break; case SCENE_JYASINZOU: - result.y = 5; + result.maxCapacity = 5; break; case SCENE_HAKADAN: - result.y = 5; + result.maxCapacity = 5; break; case SCENE_HAKADANCH: - result.y = 3; + result.maxCapacity = 3; break; case SCENE_GANONTIKA: - result.y = 2; + result.maxCapacity = 2; break; case SCENE_MEN: - result.y = 9; + result.maxCapacity = 9; break; case SCENE_GERUDOWAY: - result.y = 4; + result.maxCapacity = 4; break; } break; @@ -314,7 +339,7 @@ ImVec2 GetItemCurrentAndMax(ItemTrackerItem item) { void DrawItemCount(ItemTrackerItem item) { int iconSize = CVar_GetS32("gItemTrackerIconSize", 36); - ImVec2 currentAndMax = GetItemCurrentAndMax(item); + ItemTrackerNumbers currentAndMax = GetItemCurrentAndMax(item); ImVec2 p = ImGui::GetCursorScreenPos(); if (!IsValidSaveFile()) { @@ -323,33 +348,62 @@ void DrawItemCount(ItemTrackerItem item) { return; } - if (currentAndMax.x > 0) { - if (currentAndMax.x >= currentAndMax.y) { - std::string currentString = std::to_string((int)currentAndMax.x); + if (currentAndMax.currentCapacity > 0) { + if (currentAndMax.currentCapacity >= currentAndMax.maxCapacity) { + std::string currentString = std::to_string((int)currentAndMax.currentCapacity); float x = CVar_GetS32("gItemTrackerCurrentOnLeft", 0) ? p.x : p.x + (iconSize / 2) - (ImGui::CalcTextSize(currentString.c_str()).x / 2); ImGui::SetCursorScreenPos(ImVec2(x, p.y - 14)); ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(0, 255, 0, 255)); - ImGui::Text("%d", (int)currentAndMax.x); + ImGui::Text("%d", (int)currentAndMax.currentCapacity); ImGui::PopStyleColor(); } else { - if (CVar_GetS32("gItemTrackerCapacityTrack", 0) == ITEM_TRACKER_NUMBER_CAPACITY) { - std::string currentAndMaxString = std::to_string((int)currentAndMax.x) + "/" + std::to_string((int)currentAndMax.y); + switch (CVar_GetS32("gItemTrackerCapacityTrack", 0)) { + case ITEM_TRACKER_NUMBER_NONE: + break; + case ITEM_TRACKER_NUMBER_CURRENT_CAPACITY_ONLY: + { + std::string currentString = std::to_string((int)currentAndMax.currentCapacity); + float x = CVar_GetS32("gItemTrackerCurrentOnLeft", 0) ? p.x : p.x + (iconSize / 2) - (ImGui::CalcTextSize(currentString.c_str()).x / 2); - ImGui::SetCursorScreenPos(ImVec2(p.x + (iconSize / 2) - (ImGui::CalcTextSize(currentAndMaxString.c_str()).x / 2), p.y - 14)); - ImGui::Text("%d/", (int)currentAndMax.x); - ImGui::SameLine(0, 0.0f); - ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(0, 255, 0, 255)); - ImGui::Text("%d", (int)currentAndMax.y); - ImGui::PopStyleColor(); - } else if (CVar_GetS32("gItemTrackerCapacityTrack", 0) == ITEM_TRACKER_NUMBER_NONE) { - return; - } else { - std::string currentString = std::to_string((int)currentAndMax.x); - float x = CVar_GetS32("gItemTrackerCurrentOnLeft", 0) ? p.x : p.x + (iconSize / 2) - (ImGui::CalcTextSize(currentString.c_str()).x / 2); + ImGui::SetCursorScreenPos(ImVec2(x, p.y - 14)); + ImGui::Text("%d", (int)currentAndMax.currentCapacity); + } + break; + case ITEM_TRACKER_NUMBER_CURRENT_AMMO_ONLY: + { + std::string currentString = std::to_string((int)currentAndMax.currentAmmo); + float x = CVar_GetS32("gItemTrackerCurrentOnLeft", 0) ? p.x : p.x + (iconSize / 2) - (ImGui::CalcTextSize(currentString.c_str()).x / 2); + + ImGui::SetCursorScreenPos(ImVec2(x, p.y - 14)); + ImGui::Text("%d", (int)currentAndMax.currentAmmo); + } + break; + case ITEM_TRACKER_NUMBER_CAPACITY: + { + std::string currentAndMaxString = std::to_string((int)currentAndMax.currentCapacity) + "/" + std::to_string((int)currentAndMax.maxCapacity); + + ImGui::SetCursorScreenPos(ImVec2(p.x + (iconSize / 2) - (ImGui::CalcTextSize(currentAndMaxString.c_str()).x / 2), p.y - 14)); + ImGui::Text("%d/", (int)currentAndMax.currentCapacity); + ImGui::SameLine(0, 0.0f); + ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(0, 255, 0, 255)); + ImGui::Text("%d", (int)currentAndMax.maxCapacity); + ImGui::PopStyleColor(); + } + break; + case ITEM_TRACKER_NUMBER_AMMO: + { + std::string currentAndMaxString = std::to_string((int)currentAndMax.currentAmmo) + "/" + std::to_string((int)currentAndMax.maxCapacity); + + ImGui::SetCursorScreenPos(ImVec2(p.x + (iconSize / 2) - (ImGui::CalcTextSize(currentAndMaxString.c_str()).x / 2), p.y - 14)); + ImGui::Text("%d/", (int)currentAndMax.currentAmmo); + ImGui::SameLine(0, 0.0f); + ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(0, 255, 0, 255)); + ImGui::Text("%d", (int)currentAndMax.maxCapacity); + ImGui::PopStyleColor(); + } + break; - ImGui::SetCursorScreenPos(ImVec2(x, p.y - 14)); - ImGui::Text("%d", (int)currentAndMax.x); } } } From 377c0304691447848f7ced331974bb1a3b439286 Mon Sep 17 00:00:00 2001 From: PurpleHato Date: Sat, 3 Sep 2022 21:57:58 +0200 Subject: [PATCH 04/11] Fixed capacity on ammmo tracking --- .../randomizer/randomizer_item_tracker.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp index 6ba5c7f7b..6fadd930c 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp @@ -249,7 +249,7 @@ ItemTrackerNumbers GetItemCurrentAndMax(ItemTrackerItem item) { result.currentCapacity = 0; result.maxCapacity = 0; result.currentAmmo = 0; - + switch (item.id) { case ITEM_STICK: result.currentCapacity = CUR_CAPACITY(UPG_STICKS); @@ -393,17 +393,24 @@ void DrawItemCount(ItemTrackerItem item) { break; case ITEM_TRACKER_NUMBER_AMMO: { - std::string currentAndMaxString = std::to_string((int)currentAndMax.currentAmmo) + "/" + std::to_string((int)currentAndMax.maxCapacity); + std::string currentAndMaxString = std::to_string((int)currentAndMax.currentAmmo) + "/" + std::to_string((int)currentAndMax.currentCapacity); ImGui::SetCursorScreenPos(ImVec2(p.x + (iconSize / 2) - (ImGui::CalcTextSize(currentAndMaxString.c_str()).x / 2), p.y - 14)); + if (currentAndMax.currentAmmo == 0) { + ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(150, 150, 150, 255)); + } else if (currentAndMax.currentAmmo == currentAndMax.currentCapacity) { + ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(0, 255, 0, 255)); + } else { + ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(255, 255, 255, 255)); + } ImGui::Text("%d/", (int)currentAndMax.currentAmmo); + ImGui::PopStyleColor(); ImGui::SameLine(0, 0.0f); ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(0, 255, 0, 255)); - ImGui::Text("%d", (int)currentAndMax.maxCapacity); + ImGui::Text("%d", (int)currentAndMax.currentCapacity); ImGui::PopStyleColor(); } break; - } } } From d4bc5875d73bdfd7e94724a3cdfae4426f67c87c Mon Sep 17 00:00:00 2001 From: PurpleHato Date: Sat, 3 Sep 2022 23:49:15 +0200 Subject: [PATCH 05/11] tweak on main logic --- .../randomizer/randomizer_item_tracker.cpp | 126 +++++++++++------- 1 file changed, 80 insertions(+), 46 deletions(-) diff --git a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp index 6fadd930c..f4bfdd377 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp @@ -287,16 +287,17 @@ ItemTrackerNumbers GetItemCurrentAndMax(ItemTrackerItem item) { result.currentAmmo = gSaveContext.rupees; break; case ITEM_BOMBCHU: - result.currentCapacity = 50; + result.currentCapacity = IsValidSaveFile() ? 50 : 0; result.maxCapacity = 50; result.currentAmmo = AMMO(ITEM_BOMBCHU); break; case ITEM_BEAN: - result.currentCapacity = 10; + result.currentCapacity = IsValidSaveFile() ? 10 : 0; result.maxCapacity = 10; result.currentAmmo = AMMO(ITEM_BEAN); break; case QUEST_SKULL_TOKEN: + result.currentCapacity = IsValidSaveFile() ? 100 : 0; result.maxCapacity = 100; result.currentAmmo = gSaveContext.inventory.gsTokens; break; @@ -349,7 +350,7 @@ void DrawItemCount(ItemTrackerItem item) { } if (currentAndMax.currentCapacity > 0) { - if (currentAndMax.currentCapacity >= currentAndMax.maxCapacity) { + /*if (currentAndMax.currentCapacity >= currentAndMax.maxCapacity) { std::string currentString = std::to_string((int)currentAndMax.currentCapacity); float x = CVar_GetS32("gItemTrackerCurrentOnLeft", 0) ? p.x : p.x + (iconSize / 2) - (ImGui::CalcTextSize(currentString.c_str()).x / 2); @@ -358,60 +359,93 @@ void DrawItemCount(ItemTrackerItem item) { ImGui::Text("%d", (int)currentAndMax.currentCapacity); ImGui::PopStyleColor(); } else { + if (item.id == QUEST_SKULL_TOKEN) { switch (CVar_GetS32("gItemTrackerCapacityTrack", 0)) { case ITEM_TRACKER_NUMBER_NONE: - break; case ITEM_TRACKER_NUMBER_CURRENT_CAPACITY_ONLY: - { - std::string currentString = std::to_string((int)currentAndMax.currentCapacity); - float x = CVar_GetS32("gItemTrackerCurrentOnLeft", 0) ? p.x : p.x + (iconSize / 2) - (ImGui::CalcTextSize(currentString.c_str()).x / 2); - - ImGui::SetCursorScreenPos(ImVec2(x, p.y - 14)); - ImGui::Text("%d", (int)currentAndMax.currentCapacity); - } - break; case ITEM_TRACKER_NUMBER_CURRENT_AMMO_ONLY: - { std::string currentString = std::to_string((int)currentAndMax.currentAmmo); float x = CVar_GetS32("gItemTrackerCurrentOnLeft", 0) ? p.x : p.x + (iconSize / 2) - (ImGui::CalcTextSize(currentString.c_str()).x / 2); ImGui::SetCursorScreenPos(ImVec2(x, p.y - 14)); ImGui::Text("%d", (int)currentAndMax.currentAmmo); - } - break; - case ITEM_TRACKER_NUMBER_CAPACITY: - { - std::string currentAndMaxString = std::to_string((int)currentAndMax.currentCapacity) + "/" + std::to_string((int)currentAndMax.maxCapacity); - - ImGui::SetCursorScreenPos(ImVec2(p.x + (iconSize / 2) - (ImGui::CalcTextSize(currentAndMaxString.c_str()).x / 2), p.y - 14)); - ImGui::Text("%d/", (int)currentAndMax.currentCapacity); - ImGui::SameLine(0, 0.0f); - ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(0, 255, 0, 255)); - ImGui::Text("%d", (int)currentAndMax.maxCapacity); - ImGui::PopStyleColor(); - } - break; - case ITEM_TRACKER_NUMBER_AMMO: - { - std::string currentAndMaxString = std::to_string((int)currentAndMax.currentAmmo) + "/" + std::to_string((int)currentAndMax.currentCapacity); - - ImGui::SetCursorScreenPos(ImVec2(p.x + (iconSize / 2) - (ImGui::CalcTextSize(currentAndMaxString.c_str()).x / 2), p.y - 14)); - if (currentAndMax.currentAmmo == 0) { - ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(150, 150, 150, 255)); - } else if (currentAndMax.currentAmmo == currentAndMax.currentCapacity) { - ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(0, 255, 0, 255)); - } else { - ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(255, 255, 255, 255)); - } - ImGui::Text("%d/", (int)currentAndMax.currentAmmo); - ImGui::PopStyleColor(); - ImGui::SameLine(0, 0.0f); - ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(0, 255, 0, 255)); - ImGui::Text("%d", (int)currentAndMax.currentCapacity); - ImGui::PopStyleColor(); - } break; } + }*/ + + switch (CVar_GetS32("gItemTrackerCapacityTrack", 0)) { + case ITEM_TRACKER_NUMBER_NONE: + break; + case ITEM_TRACKER_NUMBER_CURRENT_CAPACITY_ONLY: + { + std::string currentString = std::to_string((int)currentAndMax.currentCapacity); + float x = CVar_GetS32("gItemTrackerCurrentOnLeft", 0) ? p.x : p.x + (iconSize / 2) - (ImGui::CalcTextSize(currentString.c_str()).x / 2); + + ImGui::SetCursorScreenPos(ImVec2(x, p.y - 14)); + ImGui::Text("%d", (int)currentAndMax.currentCapacity); + } + break; + case ITEM_TRACKER_NUMBER_CURRENT_AMMO_ONLY: + { + std::string currentString = std::to_string((int)currentAndMax.currentAmmo); + float x = CVar_GetS32("gItemTrackerCurrentOnLeft", 0) ? p.x : p.x + (iconSize / 2) - (ImGui::CalcTextSize(currentString.c_str()).x / 2); + + ImGui::SetCursorScreenPos(ImVec2(x, p.y - 14)); + ImGui::Text("%d", (int)currentAndMax.currentAmmo); + } + break; + case ITEM_TRACKER_NUMBER_CAPACITY: + { + std::string currentAndMaxString="0"; + if (item.id == QUEST_SKULL_TOKEN) { + std::string currentAndMaxString = std::to_string((int)currentAndMax.currentAmmo) + "/" + std::to_string((int)currentAndMax.maxCapacity); + } else { + std::string currentAndMaxString = std::to_string((int)currentAndMax.currentCapacity) + "/" + std::to_string((int)currentAndMax.maxCapacity); + } + + ImGui::SetCursorScreenPos(ImVec2(p.x + (iconSize / 2) - (ImGui::CalcTextSize(currentAndMaxString.c_str()).x / 2), p.y - 14)); + + + if (item.id == QUEST_SKULL_TOKEN) { + ImGui::Text("%d/", (int)currentAndMax.currentAmmo); + } else { + ImGui::Text("%d/", (int)currentAndMax.currentCapacity); + } + + ImGui::SameLine(0, 0.0f); + if (item.id == QUEST_SKULL_TOKEN) { + ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(255, 0, 0, 255)); + } else { + ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(0, 255, 0, 255)); + } + ImGui::Text("%d", (int)currentAndMax.maxCapacity); + ImGui::PopStyleColor(); + } + break; + case ITEM_TRACKER_NUMBER_AMMO: + { + std::string currentAndMaxString = std::to_string((int)currentAndMax.currentAmmo) + "/" + std::to_string((int)currentAndMax.currentCapacity); + + ImGui::SetCursorScreenPos(ImVec2(p.x + (iconSize / 2) - (ImGui::CalcTextSize(currentAndMaxString.c_str()).x / 2), p.y - 14)); + if (currentAndMax.currentAmmo == 0) { + ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(150, 150, 150, 255)); + } else if (currentAndMax.currentAmmo == currentAndMax.currentCapacity) { + ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(0, 255, 0, 255)); + } else { + ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(255, 255, 255, 255)); + } + ImGui::Text("%d/", (int)currentAndMax.currentAmmo); + ImGui::PopStyleColor(); + ImGui::SameLine(0, 0.0f); + if (item.id == QUEST_SKULL_TOKEN) { + ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(255, 0, 0, 255)); + } else { + ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(0, 255, 0, 255)); + } + ImGui::Text("%d", (int)currentAndMax.currentCapacity); + ImGui::PopStyleColor(); + } + break; } } } From 27f613b3f8aec7a8a59d9fa3d3bda66f3ebaffe5 Mon Sep 17 00:00:00 2001 From: PurpleHato Date: Sun, 4 Sep 2022 01:03:28 +0200 Subject: [PATCH 06/11] All color logic for all types --- .../randomizer/randomizer_item_tracker.cpp | 88 +++++++++++-------- 1 file changed, 53 insertions(+), 35 deletions(-) diff --git a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp index f4bfdd377..407b81808 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp @@ -350,39 +350,36 @@ void DrawItemCount(ItemTrackerItem item) { } if (currentAndMax.currentCapacity > 0) { - /*if (currentAndMax.currentCapacity >= currentAndMax.maxCapacity) { - std::string currentString = std::to_string((int)currentAndMax.currentCapacity); - float x = CVar_GetS32("gItemTrackerCurrentOnLeft", 0) ? p.x : p.x + (iconSize / 2) - (ImGui::CalcTextSize(currentString.c_str()).x / 2); - - ImGui::SetCursorScreenPos(ImVec2(x, p.y - 14)); - ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(0, 255, 0, 255)); - ImGui::Text("%d", (int)currentAndMax.currentCapacity); - ImGui::PopStyleColor(); - } else { - if (item.id == QUEST_SKULL_TOKEN) { - switch (CVar_GetS32("gItemTrackerCapacityTrack", 0)) { - case ITEM_TRACKER_NUMBER_NONE: - case ITEM_TRACKER_NUMBER_CURRENT_CAPACITY_ONLY: - case ITEM_TRACKER_NUMBER_CURRENT_AMMO_ONLY: - std::string currentString = std::to_string((int)currentAndMax.currentAmmo); - float x = CVar_GetS32("gItemTrackerCurrentOnLeft", 0) ? p.x : p.x + (iconSize / 2) - (ImGui::CalcTextSize(currentString.c_str()).x / 2); - - ImGui::SetCursorScreenPos(ImVec2(x, p.y - 14)); - ImGui::Text("%d", (int)currentAndMax.currentAmmo); - break; - } - }*/ - switch (CVar_GetS32("gItemTrackerCapacityTrack", 0)) { case ITEM_TRACKER_NUMBER_NONE: break; case ITEM_TRACKER_NUMBER_CURRENT_CAPACITY_ONLY: { - std::string currentString = std::to_string((int)currentAndMax.currentCapacity); + std::string currentString = std::to_string((int)currentAndMax.currentCapacity); // Init like that else it would mess up with centering + + if (item.id == QUEST_SKULL_TOKEN) { + std::string currentString = std::to_string((int)currentAndMax.currentAmmo); + } else { + std::string currentString = std::to_string((int)currentAndMax.currentCapacity); + } float x = CVar_GetS32("gItemTrackerCurrentOnLeft", 0) ? p.x : p.x + (iconSize / 2) - (ImGui::CalcTextSize(currentString.c_str()).x / 2); ImGui::SetCursorScreenPos(ImVec2(x, p.y - 14)); - ImGui::Text("%d", (int)currentAndMax.currentCapacity); + if (item.id != QUEST_SKULL_TOKEN && currentAndMax.currentCapacity == currentAndMax.maxCapacity) { + ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(0, 255, 0, 255)); + } else if (item.id == QUEST_SKULL_TOKEN && currentAndMax.currentAmmo == currentAndMax.maxCapacity){ + ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(255, 0, 0, 255)); + } else { + ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(255, 255, 255, 255)); + } + + if (item.id == QUEST_SKULL_TOKEN) { + ImGui::Text("%d", (int)currentAndMax.currentAmmo); + } else { + ImGui::Text("%d", (int)currentAndMax.currentCapacity); + } + + ImGui::PopStyleColor(); } break; case ITEM_TRACKER_NUMBER_CURRENT_AMMO_ONLY: @@ -391,27 +388,48 @@ void DrawItemCount(ItemTrackerItem item) { float x = CVar_GetS32("gItemTrackerCurrentOnLeft", 0) ? p.x : p.x + (iconSize / 2) - (ImGui::CalcTextSize(currentString.c_str()).x / 2); ImGui::SetCursorScreenPos(ImVec2(x, p.y - 14)); + if (currentAndMax.currentAmmo == 0) { + ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(150, 150, 150, 255)); + } else if (item.id == QUEST_SKULL_TOKEN && currentAndMax.currentAmmo == currentAndMax.currentCapacity) { + ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(255, 0, 0, 255)); + } else if (currentAndMax.currentAmmo == currentAndMax.currentCapacity) { + ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(0, 255, 0, 255)); + } else { + ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(255, 255, 255, 255)); + } ImGui::Text("%d", (int)currentAndMax.currentAmmo); + ImGui::PopStyleColor(); } break; case ITEM_TRACKER_NUMBER_CAPACITY: { - std::string currentAndMaxString="0"; + std::string currentAndMaxString = std::to_string((int)currentAndMax.currentCapacity) + "/" + std::to_string((int)currentAndMax.maxCapacity); // This one is there for a correc tspacing initialisation, else it would mess it up + if (item.id == QUEST_SKULL_TOKEN) { std::string currentAndMaxString = std::to_string((int)currentAndMax.currentAmmo) + "/" + std::to_string((int)currentAndMax.maxCapacity); + ImGui::SetCursorScreenPos(ImVec2(p.x + (iconSize / 2) - (ImGui::CalcTextSize(currentAndMaxString.c_str()).x / 2), p.y - 18)); + + if (currentAndMax.currentAmmo == 0) { + ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(150, 150, 150, 255)); + } else if (currentAndMax.currentAmmo == currentAndMax.currentCapacity) { + ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(255, 0, 0, 255)); + } else { + ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(255, 255, 255, 255)); + } + ImGui::Text("%d/", (int)currentAndMax.currentAmmo); + ImGui::PopStyleColor(); } else { std::string currentAndMaxString = std::to_string((int)currentAndMax.currentCapacity) + "/" + std::to_string((int)currentAndMax.maxCapacity); - } - - ImGui::SetCursorScreenPos(ImVec2(p.x + (iconSize / 2) - (ImGui::CalcTextSize(currentAndMaxString.c_str()).x / 2), p.y - 14)); - - - if (item.id == QUEST_SKULL_TOKEN) { - ImGui::Text("%d/", (int)currentAndMax.currentAmmo); - } else { + ImGui::SetCursorScreenPos(ImVec2(p.x + (iconSize / 2) - (ImGui::CalcTextSize(currentAndMaxString.c_str()).x / 2), p.y - 14)); + if (currentAndMax.currentCapacity == currentAndMax.maxCapacity) { + ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(0, 255, 0, 255)); + } else { + ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(255, 255, 255, 255)); + } ImGui::Text("%d/", (int)currentAndMax.currentCapacity); + ImGui::PopStyleColor(); } - + ImGui::SameLine(0, 0.0f); if (item.id == QUEST_SKULL_TOKEN) { ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(255, 0, 0, 255)); From 6dbc292ff3d775136aaca2fd27f97bd9480a9526 Mon Sep 17 00:00:00 2001 From: PurpleHato Date: Sun, 4 Sep 2022 01:22:15 +0200 Subject: [PATCH 07/11] Fix: changes to please new LUS --- soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp index e555dea08..b06a39c9c 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp @@ -1000,9 +1000,9 @@ void DrawItemTrackerOptions(bool& open) { LabeledComboBoxRightAligned("Combo Button 2", "gItemTrackerComboButton2", { "A", "B", "C-Up", "C-Down", "C-Left", "C-Right", "L", "Z", "R", "Start", "D-Up", "D-Down", "D-Left", "D-Right" }, 8); } } - PaddedSeparator(); - SohImGui::EnhancementSliderInt("Icon size : %dpx", "##ITEMTRACKERICONSIZE", "gItemTrackerIconSize", 25, 128, "", 36, true); - SohImGui::EnhancementSliderInt("Icon margins : %dpx", "##ITEMTRACKERSPACING", "gItemTrackerIconSpacing", -5, 50, "", 12, true); + UIWidgets::PaddedSeparator(); + UIWidgets::EnhancementSliderInt("Icon size : %dpx", "##ITEMTRACKERICONSIZE", "gItemTrackerIconSize", 25, 128, "", 36, true); + UIWidgets::EnhancementSliderInt("Icon margins : %dpx", "##ITEMTRACKERSPACING", "gItemTrackerIconSpacing", -5, 50, "", 12, true); LabeledComboBoxRightAligned("Ammo/Capacity Tracking", "gItemTrackerCapacityTrack", { "No Numbers", "Current Capacity", "Current Ammo", "Current Capacity / Max Capacity", "Current Ammo / Current Capacity" }, 0); if (CVar_GetS32("gItemTrackerCapacityTrack", 0) == ITEM_TRACKER_NUMBER_CURRENT_CAPACITY_ONLY || CVar_GetS32("gItemTrackerCapacityTrack", 0) == ITEM_TRACKER_NUMBER_CURRENT_AMMO_ONLY) { From 6bf886ecae01a178af0ec4a2c9c805896e4e55cb Mon Sep 17 00:00:00 2001 From: Garrett Cox Date: Sun, 4 Sep 2022 11:55:40 -0500 Subject: [PATCH 08/11] Refactor DrawItemCount and Use EnhancementCombobox for tracker capacity options --- .../randomizer/randomizer_item_tracker.cpp | 218 +++++++----------- 1 file changed, 82 insertions(+), 136 deletions(-) diff --git a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp index b06a39c9c..cc3f1e577 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp @@ -286,49 +286,48 @@ ItemTrackerNumbers GetItemCurrentAndMax(ItemTrackerItem item) { result.currentAmmo = gSaveContext.rupees; break; case ITEM_BOMBCHU: - result.currentCapacity = IsValidSaveFile() ? 50 : 0; + result.currentCapacity = INV_CONTENT(ITEM_BOMBCHU) == ITEM_BOMBCHU ? 50 : 0; result.maxCapacity = 50; result.currentAmmo = AMMO(ITEM_BOMBCHU); break; case ITEM_BEAN: - result.currentCapacity = IsValidSaveFile() ? 10 : 0; + result.currentCapacity = INV_CONTENT(ITEM_BEAN) == ITEM_BEAN ? 10 : 0; result.maxCapacity = 10; result.currentAmmo = AMMO(ITEM_BEAN); break; case QUEST_SKULL_TOKEN: - result.currentCapacity = IsValidSaveFile() ? 100 : 0; - result.maxCapacity = 100; + result.maxCapacity = result.currentCapacity = 100; result.currentAmmo = gSaveContext.inventory.gsTokens; break; case ITEM_KEY_SMALL: - result.currentCapacity = gSaveContext.inventory.dungeonKeys[item.data]; + result.currentAmmo = MAX(gSaveContext.inventory.dungeonKeys[item.data], 0); switch (item.data) { case SCENE_BMORI1: - result.maxCapacity = 5; + result.maxCapacity = result.currentCapacity = 5; break; case SCENE_HIDAN: - result.maxCapacity = 8; + result.maxCapacity = result.currentCapacity = 8; break; case SCENE_MIZUSIN: - result.maxCapacity = 6; + result.maxCapacity = result.currentCapacity = 6; break; case SCENE_JYASINZOU: - result.maxCapacity = 5; + result.maxCapacity = result.currentCapacity = 5; break; case SCENE_HAKADAN: - result.maxCapacity = 5; + result.maxCapacity = result.currentCapacity = 5; break; case SCENE_HAKADANCH: - result.maxCapacity = 3; + result.maxCapacity = result.currentCapacity = 3; break; case SCENE_GANONTIKA: - result.maxCapacity = 2; + result.maxCapacity = result.currentCapacity = 2; break; case SCENE_MEN: - result.maxCapacity = 9; + result.maxCapacity = result.currentCapacity = 9; break; case SCENE_GERUDOWAY: - result.maxCapacity = 4; + result.maxCapacity = result.currentCapacity = 4; break; } break; @@ -337,133 +336,77 @@ ItemTrackerNumbers GetItemCurrentAndMax(ItemTrackerItem item) { return result; } +#define IM_COL_WHITE IM_COL32(255, 255, 255, 255) +#define IM_COL_RED IM_COL32(255, 0, 0, 255) +#define IM_COL_GREEN IM_COL32(0, 255, 0, 255) +#define IM_COL_GRAY IM_COL32(150, 150, 150, 255) + void DrawItemCount(ItemTrackerItem item) { int iconSize = CVar_GetS32("gItemTrackerIconSize", 36); ItemTrackerNumbers currentAndMax = GetItemCurrentAndMax(item); ImVec2 p = ImGui::GetCursorScreenPos(); + int32_t trackerMode = CVar_GetS32("gItemTrackerCapacityTrack", 1); - if (!IsValidSaveFile()) { + if (currentAndMax.currentCapacity > 0 && trackerMode != ITEM_TRACKER_NUMBER_NONE && IsValidSaveFile()) { + std::string currentString = ""; + std::string maxString = ""; + ImU32 currentColor = IM_COL_WHITE; + ImU32 maxColor = item.id == QUEST_SKULL_TOKEN ? IM_COL_RED : IM_COL_GREEN; + + bool shouldAlignToLeft = CVar_GetS32("gItemTrackerCurrentOnLeft", 0) && + trackerMode != ITEM_TRACKER_NUMBER_CAPACITY && + trackerMode != ITEM_TRACKER_NUMBER_AMMO; + + bool shouldDisplayAmmo = trackerMode == ITEM_TRACKER_NUMBER_AMMO || + trackerMode == ITEM_TRACKER_NUMBER_CURRENT_AMMO_ONLY || + // These items have a static capacity, so display ammo instead + item.id == ITEM_BOMBCHU || + item.id == ITEM_BEAN || + item.id == QUEST_SKULL_TOKEN || + item.id == ITEM_KEY_SMALL; + + bool shouldDisplayMax = trackerMode == ITEM_TRACKER_NUMBER_AMMO || trackerMode == ITEM_TRACKER_NUMBER_CAPACITY; + + if (shouldDisplayAmmo) { + currentString = std::to_string(currentAndMax.currentAmmo); + if (currentAndMax.currentAmmo >= currentAndMax.currentCapacity) { + if (item.id == QUEST_SKULL_TOKEN) { + currentColor = IM_COL_RED; + } else { + currentColor = IM_COL_GREEN; + } + } else { + if (shouldDisplayMax) { + currentString += "/"; + maxString = std::to_string(currentAndMax.currentCapacity); + } + if (currentAndMax.currentAmmo <= 0) { + currentColor = IM_COL_GRAY; + } + } + } else { + currentString = std::to_string(currentAndMax.currentCapacity); + if (currentAndMax.currentCapacity >= currentAndMax.maxCapacity) { + currentColor = IM_COL_GREEN; + } else if (shouldDisplayMax) { + currentString += "/"; + maxString = std::to_string(currentAndMax.maxCapacity); + } + } + + float x = shouldAlignToLeft ? p.x : p.x + (iconSize / 2) - (ImGui::CalcTextSize((currentString + maxString).c_str()).x / 2); + + ImGui::SetCursorScreenPos(ImVec2(x, p.y - 14)); + ImGui::PushStyleColor(ImGuiCol_Text, currentColor); + ImGui::Text(currentString.c_str()); + ImGui::PopStyleColor(); + ImGui::SameLine(0, 0.0f); + ImGui::PushStyleColor(ImGuiCol_Text, maxColor); + ImGui::Text(maxString.c_str()); + ImGui::PopStyleColor(); + } else { ImGui::SetCursorScreenPos(ImVec2(p.x, p.y - 14)); ImGui::Text(""); - return; - } - - if (currentAndMax.currentCapacity > 0) { - switch (CVar_GetS32("gItemTrackerCapacityTrack", 0)) { - case ITEM_TRACKER_NUMBER_NONE: - break; - case ITEM_TRACKER_NUMBER_CURRENT_CAPACITY_ONLY: - { - std::string currentString = std::to_string((int)currentAndMax.currentCapacity); // Init like that else it would mess up with centering - - if (item.id == QUEST_SKULL_TOKEN) { - std::string currentString = std::to_string((int)currentAndMax.currentAmmo); - } else { - std::string currentString = std::to_string((int)currentAndMax.currentCapacity); - } - float x = CVar_GetS32("gItemTrackerCurrentOnLeft", 0) ? p.x : p.x + (iconSize / 2) - (ImGui::CalcTextSize(currentString.c_str()).x / 2); - - ImGui::SetCursorScreenPos(ImVec2(x, p.y - 14)); - if (item.id != QUEST_SKULL_TOKEN && currentAndMax.currentCapacity == currentAndMax.maxCapacity) { - ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(0, 255, 0, 255)); - } else if (item.id == QUEST_SKULL_TOKEN && currentAndMax.currentAmmo == currentAndMax.maxCapacity){ - ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(255, 0, 0, 255)); - } else { - ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(255, 255, 255, 255)); - } - - if (item.id == QUEST_SKULL_TOKEN) { - ImGui::Text("%d", (int)currentAndMax.currentAmmo); - } else { - ImGui::Text("%d", (int)currentAndMax.currentCapacity); - } - - ImGui::PopStyleColor(); - } - break; - case ITEM_TRACKER_NUMBER_CURRENT_AMMO_ONLY: - { - std::string currentString = std::to_string((int)currentAndMax.currentAmmo); - float x = CVar_GetS32("gItemTrackerCurrentOnLeft", 0) ? p.x : p.x + (iconSize / 2) - (ImGui::CalcTextSize(currentString.c_str()).x / 2); - - ImGui::SetCursorScreenPos(ImVec2(x, p.y - 14)); - if (currentAndMax.currentAmmo == 0) { - ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(150, 150, 150, 255)); - } else if (item.id == QUEST_SKULL_TOKEN && currentAndMax.currentAmmo == currentAndMax.currentCapacity) { - ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(255, 0, 0, 255)); - } else if (currentAndMax.currentAmmo == currentAndMax.currentCapacity) { - ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(0, 255, 0, 255)); - } else { - ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(255, 255, 255, 255)); - } - ImGui::Text("%d", (int)currentAndMax.currentAmmo); - ImGui::PopStyleColor(); - } - break; - case ITEM_TRACKER_NUMBER_CAPACITY: - { - std::string currentAndMaxString = std::to_string((int)currentAndMax.currentCapacity) + "/" + std::to_string((int)currentAndMax.maxCapacity); // This one is there for a correc tspacing initialisation, else it would mess it up - - if (item.id == QUEST_SKULL_TOKEN) { - std::string currentAndMaxString = std::to_string((int)currentAndMax.currentAmmo) + "/" + std::to_string((int)currentAndMax.maxCapacity); - ImGui::SetCursorScreenPos(ImVec2(p.x + (iconSize / 2) - (ImGui::CalcTextSize(currentAndMaxString.c_str()).x / 2), p.y - 18)); - - if (currentAndMax.currentAmmo == 0) { - ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(150, 150, 150, 255)); - } else if (currentAndMax.currentAmmo == currentAndMax.currentCapacity) { - ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(255, 0, 0, 255)); - } else { - ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(255, 255, 255, 255)); - } - ImGui::Text("%d/", (int)currentAndMax.currentAmmo); - ImGui::PopStyleColor(); - } else { - std::string currentAndMaxString = std::to_string((int)currentAndMax.currentCapacity) + "/" + std::to_string((int)currentAndMax.maxCapacity); - ImGui::SetCursorScreenPos(ImVec2(p.x + (iconSize / 2) - (ImGui::CalcTextSize(currentAndMaxString.c_str()).x / 2), p.y - 14)); - if (currentAndMax.currentCapacity == currentAndMax.maxCapacity) { - ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(0, 255, 0, 255)); - } else { - ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(255, 255, 255, 255)); - } - ImGui::Text("%d/", (int)currentAndMax.currentCapacity); - ImGui::PopStyleColor(); - } - - ImGui::SameLine(0, 0.0f); - if (item.id == QUEST_SKULL_TOKEN) { - ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(255, 0, 0, 255)); - } else { - ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(0, 255, 0, 255)); - } - ImGui::Text("%d", (int)currentAndMax.maxCapacity); - ImGui::PopStyleColor(); - } - break; - case ITEM_TRACKER_NUMBER_AMMO: - { - std::string currentAndMaxString = std::to_string((int)currentAndMax.currentAmmo) + "/" + std::to_string((int)currentAndMax.currentCapacity); - - ImGui::SetCursorScreenPos(ImVec2(p.x + (iconSize / 2) - (ImGui::CalcTextSize(currentAndMaxString.c_str()).x / 2), p.y - 14)); - if (currentAndMax.currentAmmo == 0) { - ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(150, 150, 150, 255)); - } else if (currentAndMax.currentAmmo == currentAndMax.currentCapacity) { - ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(0, 255, 0, 255)); - } else { - ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(255, 255, 255, 255)); - } - ImGui::Text("%d/", (int)currentAndMax.currentAmmo); - ImGui::PopStyleColor(); - ImGui::SameLine(0, 0.0f); - if (item.id == QUEST_SKULL_TOKEN) { - ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(255, 0, 0, 255)); - } else { - ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(0, 255, 0, 255)); - } - ImGui::Text("%d", (int)currentAndMax.currentCapacity); - ImGui::PopStyleColor(); - } - break; - } } } @@ -957,6 +900,8 @@ void DrawItemTracker(bool& open) { } } +const char* itemTrackerCapacityTrackOptions[5] = { "No Numbers", "Current Capacity", "Current Ammo", "Current Capacity / Max Capacity", "Current Ammo / Current Capacity" }; + void DrawItemTrackerOptions(bool& open) { if (!open) { CVar_SetS32("gItemTrackerSettingsEnabled", 0); @@ -1004,8 +949,9 @@ void DrawItemTrackerOptions(bool& open) { UIWidgets::EnhancementSliderInt("Icon size : %dpx", "##ITEMTRACKERICONSIZE", "gItemTrackerIconSize", 25, 128, "", 36, true); UIWidgets::EnhancementSliderInt("Icon margins : %dpx", "##ITEMTRACKERSPACING", "gItemTrackerIconSpacing", -5, 50, "", 12, true); - LabeledComboBoxRightAligned("Ammo/Capacity Tracking", "gItemTrackerCapacityTrack", { "No Numbers", "Current Capacity", "Current Ammo", "Current Capacity / Max Capacity", "Current Ammo / Current Capacity" }, 0); - if (CVar_GetS32("gItemTrackerCapacityTrack", 0) == ITEM_TRACKER_NUMBER_CURRENT_CAPACITY_ONLY || CVar_GetS32("gItemTrackerCapacityTrack", 0) == ITEM_TRACKER_NUMBER_CURRENT_AMMO_ONLY) { + ImGui::Text("Ammo/Capacity Tracking"); + UIWidgets::EnhancementCombobox("gItemTrackerCapacityTrack", itemTrackerCapacityTrackOptions, 5, 1); + if (CVar_GetS32("gItemTrackerCapacityTrack", 1) == ITEM_TRACKER_NUMBER_CURRENT_CAPACITY_ONLY || CVar_GetS32("gItemTrackerCapacityTrack", 1) == ITEM_TRACKER_NUMBER_CURRENT_AMMO_ONLY) { PaddedEnhancementCheckbox("Align count to left side", "gItemTrackerCurrentOnLeft", 0); } From e11ca62ee13fa0cb1a829799c2c45a178c207049 Mon Sep 17 00:00:00 2001 From: PurpleHato Date: Sun, 4 Sep 2022 20:09:48 +0200 Subject: [PATCH 09/11] small tweaks and rename --- .../randomizer/randomizer_item_tracker.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp index 3c5d6dabf..3a1dc5962 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp @@ -339,33 +339,33 @@ ItemTrackerNumbers GetItemCurrentAndMax(ItemTrackerItem item) { #define IM_COL_WHITE IM_COL32(255, 255, 255, 255) #define IM_COL_RED IM_COL32(255, 0, 0, 255) #define IM_COL_GREEN IM_COL32(0, 255, 0, 255) -#define IM_COL_GRAY IM_COL32(150, 150, 150, 255) +#define IM_COL_GRAY IM_COL32(155, 155, 155, 255) void DrawItemCount(ItemTrackerItem item) { int iconSize = CVar_GetS32("gItemTrackerIconSize", 36); ItemTrackerNumbers currentAndMax = GetItemCurrentAndMax(item); ImVec2 p = ImGui::GetCursorScreenPos(); - int32_t trackerMode = CVar_GetS32("gItemTrackerCapacityTrack", 1); + int32_t trackerNumberDisplayMode = CVar_GetS32("gItemTrackerCapacityTrack", 1); - if (currentAndMax.currentCapacity > 0 && trackerMode != ITEM_TRACKER_NUMBER_NONE && IsValidSaveFile()) { + if (currentAndMax.currentCapacity > 0 && trackerNumberDisplayMode != ITEM_TRACKER_NUMBER_NONE && IsValidSaveFile()) { std::string currentString = ""; std::string maxString = ""; ImU32 currentColor = IM_COL_WHITE; ImU32 maxColor = item.id == QUEST_SKULL_TOKEN ? IM_COL_RED : IM_COL_GREEN; bool shouldAlignToLeft = CVar_GetS32("gItemTrackerCurrentOnLeft", 0) && - trackerMode != ITEM_TRACKER_NUMBER_CAPACITY && - trackerMode != ITEM_TRACKER_NUMBER_AMMO; + trackerNumberDisplayMode != ITEM_TRACKER_NUMBER_CAPACITY && + trackerNumberDisplayMode != ITEM_TRACKER_NUMBER_AMMO; - bool shouldDisplayAmmo = trackerMode == ITEM_TRACKER_NUMBER_AMMO || - trackerMode == ITEM_TRACKER_NUMBER_CURRENT_AMMO_ONLY || + bool shouldDisplayAmmo = trackerNumberDisplayMode == ITEM_TRACKER_NUMBER_AMMO || + trackerNumberDisplayMode == ITEM_TRACKER_NUMBER_CURRENT_AMMO_ONLY || // These items have a static capacity, so display ammo instead item.id == ITEM_BOMBCHU || item.id == ITEM_BEAN || item.id == QUEST_SKULL_TOKEN || item.id == ITEM_KEY_SMALL; - bool shouldDisplayMax = trackerMode == ITEM_TRACKER_NUMBER_AMMO || trackerMode == ITEM_TRACKER_NUMBER_CAPACITY; + bool shouldDisplayMax = !(trackerNumberDisplayMode == ITEM_TRACKER_NUMBER_CURRENT_CAPACITY_ONLY || trackerNumberDisplayMode == ITEM_TRACKER_NUMBER_CURRENT_AMMO_ONLY); if (shouldDisplayAmmo) { currentString = std::to_string(currentAndMax.currentAmmo); From 47c7d3f061ce08700fd3d4f2c72463473b695053 Mon Sep 17 00:00:00 2001 From: PurpleHato Date: Sun, 4 Sep 2022 20:39:56 +0200 Subject: [PATCH 10/11] always display XX/YY when in ammo/capacity mode --- .../randomizer/randomizer_item_tracker.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp index 3a1dc5962..d6cfc8a37 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp @@ -375,14 +375,13 @@ void DrawItemCount(ItemTrackerItem item) { } else { currentColor = IM_COL_GREEN; } - } else { - if (shouldDisplayMax) { - currentString += "/"; - maxString = std::to_string(currentAndMax.currentCapacity); - } - if (currentAndMax.currentAmmo <= 0) { - currentColor = IM_COL_GRAY; - } + } + if (shouldDisplayMax) { + currentString += "/"; + maxString = std::to_string(currentAndMax.currentCapacity); + } + if (currentAndMax.currentAmmo <= 0) { + currentColor = IM_COL_GRAY; } } else { currentString = std::to_string(currentAndMax.currentCapacity); From a6937e985034e57ce4a9c8f9a8849100ea1e0c8a Mon Sep 17 00:00:00 2001 From: PurpleHato Date: Sun, 4 Sep 2022 21:31:50 +0200 Subject: [PATCH 11/11] added hovertext for the number display --- soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp index d6cfc8a37..47acc746c 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp @@ -947,6 +947,8 @@ void DrawItemTrackerOptions(bool& open) { ImGui::Text("Ammo/Capacity Tracking"); UIWidgets::EnhancementCombobox("gItemTrackerCapacityTrack", itemTrackerCapacityTrackOptions, 5, 1); + UIWidgets::InsertHelpHoverText("Customize what the numbers under each item are tracking." + "\n\nNote: items without capacity upgrades will track ammo even in capacity mode"); if (CVar_GetS32("gItemTrackerCapacityTrack", 1) == ITEM_TRACKER_NUMBER_CURRENT_CAPACITY_ONLY || CVar_GetS32("gItemTrackerCapacityTrack", 1) == ITEM_TRACKER_NUMBER_CURRENT_AMMO_ONLY) { PaddedEnhancementCheckbox("Align count to left side", "gItemTrackerCurrentOnLeft", 0); }