Allow editing amount/capacity separately

This commit is contained in:
Phillip Stephens 2021-05-29 01:39:50 -07:00 committed by Luke Street
parent a066e9aa79
commit 53aabceae2
2 changed files with 25 additions and 11 deletions

View File

@ -11,7 +11,7 @@
namespace ImGui { namespace ImGui {
// Internal functions // Internal functions
void ClearIniSettings(); void ClearIniSettings();
} } // namespace ImGui
#include "TCastTo.hpp" // Generated file, do not modify include path #include "TCastTo.hpp" // Generated file, do not modify include path
@ -266,9 +266,10 @@ void ImGuiConsole::ShowInspectWindow(bool* isOpen) {
ImGui::TableHeadersRow(); ImGui::TableHeadersRow();
ImGuiTableSortSpecs* sortSpecs = ImGui::TableGetSortSpecs(); ImGuiTableSortSpecs* sortSpecs = ImGui::TableGetSortSpecs();
bool hasSortSpec = sortSpecs != nullptr && sortSpecs->SpecsCount == 1 && // no multi-sort bool hasSortSpec = sortSpecs != nullptr &&
// We can skip sorting if we just want uid ascending, sortSpecs->SpecsCount == 1 && // no multi-sort
// since that's how we iterate over CObjectList // We can skip sorting if we just want uid ascending,
// since that's how we iterate over CObjectList
(sortSpecs->Specs[0].ColumnUserID != 'id' || (sortSpecs->Specs[0].ColumnUserID != 'id' ||
sortSpecs->Specs[0].SortDirection != ImGuiSortDirection_Ascending); sortSpecs->Specs[0].SortDirection != ImGuiSortDirection_Ascending);
std::string_view search{m_inspectFilterText.data(), strlen(m_inspectFilterText.data())}; std::string_view search{m_inspectFilterText.data(), strlen(m_inspectFilterText.data())};
@ -730,6 +731,14 @@ static constexpr std::array ArtifactItems{
CPlayerState::EItemType::World, CPlayerState::EItemType::Spirit, CPlayerState::EItemType::Newborn, CPlayerState::EItemType::World, CPlayerState::EItemType::Spirit, CPlayerState::EItemType::Newborn,
}; };
int roundMultiple(int value, int multiple) {
if (multiple == 0) {
return value;
}
return static_cast<int>(std::round(static_cast<double>(value) / static_cast<double>(multiple)) *
static_cast<double>(multiple));
}
static void RenderItemType(CPlayerState& pState, CPlayerState::EItemType itemType) { static void RenderItemType(CPlayerState& pState, CPlayerState::EItemType itemType) {
u32 maxValue = CPlayerState::GetPowerUpMaxValue(itemType); u32 maxValue = CPlayerState::GetPowerUpMaxValue(itemType);
std::string name{CPlayerState::ItemTypeToName(itemType)}; std::string name{CPlayerState::ItemTypeToName(itemType)};
@ -748,10 +757,17 @@ static void RenderItemType(CPlayerState& pState, CPlayerState::EItemType itemTyp
} }
} }
} else if (maxValue > 1) { } else if (maxValue > 1) {
int capacity = int(pState.GetItemCapacity(itemType)); std::array<int, 2> item{};
if (ImGui::SliderInt(name.c_str(), &capacity, 0, int(maxValue), "%d", ImGuiSliderFlags_AlwaysClamp)) { item[0] = int(pState.GetItemAmount(itemType));
pState.ReInitializePowerUp(itemType, u32(capacity)); item[1] = int(pState.GetItemCapacity(itemType));
pState.ResetAndIncrPickUp(itemType, u32(capacity)); if (ImGui::SliderInt2((name + " (Amount/Capacity)").c_str(), item.data(), 0, int(maxValue), "%d",
ImGuiSliderFlags_AlwaysClamp)) {
if (itemType == CPlayerState::EItemType::Missiles) {
pState.ReInitializePowerUp(itemType, roundMultiple(item[1], 5));
} else {
pState.ReInitializePowerUp(itemType, u32(item[1]));
}
pState.ResetAndIncrPickUp(itemType, u32(item[0]));
} }
} }
} }

View File

@ -152,8 +152,6 @@
#include "Runtime/MP1/World/CThardusRockProjectile.hpp" #include "Runtime/MP1/World/CThardusRockProjectile.hpp"
#include "Runtime/MP1/World/CTryclops.hpp" #include "Runtime/MP1/World/CTryclops.hpp"
#include "Runtime/MP1/World/CWarWasp.hpp" #include "Runtime/MP1/World/CWarWasp.hpp"
#include "Runtime/CStateManager.hpp"
#include "Runtime/GameGlobalObjects.hpp" #include "Runtime/GameGlobalObjects.hpp"
#include "ImGuiConsole.hpp" #include "ImGuiConsole.hpp"
@ -265,7 +263,7 @@ void CEntity::ImGuiInspect() {
ImGui::TableSetupColumn("State", ImGuiTableColumnFlags_WidthFixed, 0, 'stat'); ImGui::TableSetupColumn("State", ImGuiTableColumnFlags_WidthFixed, 0, 'stat');
ImGui::TableSetupColumn("Message", ImGuiTableColumnFlags_WidthFixed, 0, 'msg'); ImGui::TableSetupColumn("Message", ImGuiTableColumnFlags_WidthFixed, 0, 'msg');
ImGui::TableSetupColumn("", ImGuiTableColumnFlags_NoSort | ImGuiTableColumnFlags_WidthFixed | ImGui::TableSetupColumn("", ImGuiTableColumnFlags_NoSort | ImGuiTableColumnFlags_WidthFixed |
ImGuiTableColumnFlags_NoResize); ImGuiTableColumnFlags_NoResize);
ImGui::TableSetupScrollFreeze(0, 1); ImGui::TableSetupScrollFreeze(0, 1);
ImGui::TableHeadersRow(); ImGui::TableHeadersRow();
for (const auto& item : *m_incomingConnections) { for (const auto& item : *m_incomingConnections) {