mirror of
https://github.com/YimMenu/YimMenuV2.git
synced 2026-10-11 01:38:13 +08:00
Initial port
This commit is contained in:
1 parent
c2f19fe029
commit
aa3746462b
120 files changed
+11235
-7012
No files matched your search
@@ -0,0 +1,42 @@
|
||||
#include "Items.hpp"
|
||||
#include "core/commands/Command.hpp"
|
||||
#include "core/commands/Commands.hpp"
|
||||
#include "core/commands/IntCommand.hpp"
|
||||
#include "core/frontend/widgets/toggle/imgui_toggle.hpp"
|
||||
|
||||
namespace YimMenu
|
||||
{
|
||||
IntCommandItem::IntCommandItem(joaat_t id, std::optional<std::string> label_override) :
|
||||
m_Command(Commands::GetCommand<IntCommand>(id)),
|
||||
m_LabelOverride(label_override)
|
||||
{
|
||||
}
|
||||
|
||||
void IntCommandItem::Draw()
|
||||
{
|
||||
if (!m_Command)
|
||||
{
|
||||
ImGui::Text("Unknown!");
|
||||
return;
|
||||
}
|
||||
|
||||
int value = m_Command->GetState();
|
||||
auto label = m_LabelOverride.has_value() ? m_LabelOverride.value().c_str() : m_Command->GetLabel().c_str();
|
||||
if (!m_Command->GetMinimum().has_value() || !m_Command->GetMaximum().has_value())
|
||||
{
|
||||
ImGui::SetNextItemWidth(150);
|
||||
if (ImGui::InputInt(label, &value))
|
||||
{
|
||||
m_Command->SetState(value);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui::SetNextItemWidth(150);
|
||||
if (ImGui::SliderInt(label, &value, m_Command->GetMinimum().value(), m_Command->GetMaximum().value()))
|
||||
{
|
||||
m_Command->SetState(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user