From 24115948ce4577c3acaab0b54b23ca8d6431f985 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Sun, 30 May 2021 18:56:33 -0400 Subject: [PATCH] Split Amount/Capacity sliders in Items window --- Runtime/ImGuiConsole.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/Runtime/ImGuiConsole.cpp b/Runtime/ImGuiConsole.cpp index 469b7b8c5..4c1329a78 100644 --- a/Runtime/ImGuiConsole.cpp +++ b/Runtime/ImGuiConsole.cpp @@ -965,17 +965,23 @@ static void RenderItemType(CPlayerState& pState, CPlayerState::EItemType itemTyp } } } else if (maxValue > 1) { - std::array item{}; - item[0] = int(pState.GetItemAmount(itemType)); - item[1] = int(pState.GetItemCapacity(itemType)); - if (ImGui::SliderInt2((name + " (Amount/Capacity)").c_str(), item.data(), 0, int(maxValue), "%d", - ImGuiSliderFlags_AlwaysClamp)) { + int capacity = pState.GetItemCapacity(itemType); + int amount = pState.GetItemAmount(itemType); + if (ImGui::SliderInt((name + " (Capacity)").c_str(), &capacity, 0, int(maxValue), "%d", + ImGuiSliderFlags_AlwaysClamp)) { if (itemType == CPlayerState::EItemType::Missiles) { - pState.ReInitializePowerUp(itemType, roundMultiple(item[1], 5)); + pState.ReInitializePowerUp(itemType, roundMultiple(capacity, 5)); } else { - pState.ReInitializePowerUp(itemType, u32(item[1])); + pState.ReInitializePowerUp(itemType, u32(capacity)); } - pState.ResetAndIncrPickUp(itemType, u32(item[0])); + pState.ResetAndIncrPickUp(itemType, u32(capacity)); + } + if (capacity > 0) { + if (ImGui::SliderInt((name + " (Amount)").c_str(), &amount, 0, capacity, "%d", ImGuiSliderFlags_AlwaysClamp)) { + pState.ResetAndIncrPickUp(itemType, u32(amount)); + } + } else { + ImGui::Dummy(ImGui::GetItemRectSize()); } } }