From d4bc5875d73bdfd7e94724a3cdfae4426f67c87c Mon Sep 17 00:00:00 2001 From: PurpleHato Date: Sat, 3 Sep 2022 23:49:15 +0200 Subject: [PATCH] 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; } } }