Skip to content

Commit 8a70b8e

Browse files
committed
Combine input and dropdown for unit and object select
1 parent 978481f commit 8a70b8e

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

Menu.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -492,8 +492,11 @@ void Menu::Draw()
492492
#endif
493493

494494
// unit switch
495-
static char* unit = nullptr;
496-
if (ImGui::BeginCombo("##Unit", unit))
495+
static char unit[MAX_UNIT_LEN] = "";
496+
ImGui::InputText("##unit", unit, MAX_UNIT_LEN);
497+
ImGui::SameLine();
498+
499+
if (ImGui::BeginCombo("##Unit", nullptr, ImGuiComboFlags_NoPreview))
497500
{
498501
auto unitList = gUnitList;
499502

@@ -506,7 +509,7 @@ void Menu::Draw()
506509
bool selected = unit == x->name;
507510

508511
if (ImGui::Selectable(x->name, selected))
509-
unit = x->name;
512+
strcpy_s(unit, x->name);
510513

511514
if (selected)
512515
ImGui::SetItemDefaultFocus();
@@ -614,8 +617,11 @@ void Menu::Draw()
614617
#endif
615618

616619
// object select for birthing
617-
static char* name = nullptr;
618-
if (ImGui::BeginCombo("##Instance", name))
620+
static char name[100] = "";
621+
ImGui::InputText("##object", name, 100);
622+
ImGui::SameLine();
623+
624+
if (ImGui::BeginCombo("##Instance", nullptr, ImGuiComboFlags_NoPreview))
619625
{
620626
auto objectList = gObjectList;
621627

@@ -625,7 +631,7 @@ void Menu::Draw()
625631
auto selected = object->name == name;
626632

627633
if (ImGui::Selectable(object->name, selected))
628-
name = object->name;
634+
strcpy_s(name, object->name);
629635

630636
if (selected)
631637
ImGui::SetItemDefaultFocus();

0 commit comments

Comments
 (0)