Fixed capacity on ammmo tracking

This commit is contained in:
PurpleHato 2022-09-03 21:57:58 +02:00
parent f69d9697e9
commit 377c030469

View File

@ -393,17 +393,24 @@ void DrawItemCount(ItemTrackerItem item) {
break; break;
case ITEM_TRACKER_NUMBER_AMMO: 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)); 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::Text("%d/", (int)currentAndMax.currentAmmo);
ImGui::PopStyleColor();
ImGui::SameLine(0, 0.0f); ImGui::SameLine(0, 0.0f);
ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(0, 255, 0, 255)); ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(0, 255, 0, 255));
ImGui::Text("%d", (int)currentAndMax.maxCapacity); ImGui::Text("%d", (int)currentAndMax.currentCapacity);
ImGui::PopStyleColor(); ImGui::PopStyleColor();
} }
break; break;
} }
} }
} }