1
0
mirror of https://github.com/k4zmu2a/SpaceCadetPinball.git synced 2024-11-22 02:32:39 +01:00

Improved player name entry in high score dialog.

Issue #165.
This commit is contained in:
Muzychenko Andrey 2022-12-09 13:01:33 +03:00
parent 2162cac977
commit 3109a8ea75
2 changed files with 16 additions and 4 deletions

View File

@ -145,7 +145,7 @@ void high_score::RenderHighScoreDialog()
} }
} }
bool unused_open = true; bool unused_open = true, textBoxSubmit = false;
if (ImGui::BeginPopupModal(pb::get_rc_string(Msg::HIGHSCORES_Caption), &unused_open, ImGuiWindowFlags_AlwaysAutoResize)) if (ImGui::BeginPopupModal(pb::get_rc_string(Msg::HIGHSCORES_Caption), &unused_open, ImGuiWindowFlags_AlwaysAutoResize))
{ {
if (ImGui::BeginTable("table1", 3, ImGuiTableFlags_Borders)) if (ImGui::BeginTable("table1", 3, ImGuiTableFlags_Borders))
@ -171,7 +171,19 @@ void high_score::RenderHighScoreDialog()
offset = -1; offset = -1;
score = DlgData.Entry.Score; score = DlgData.Entry.Score;
ImGui::PushItemWidth(200); ImGui::PushItemWidth(200);
ImGui::InputText("", DlgData.Entry.Name, IM_ARRAYSIZE(DlgData.Entry.Name));
static bool doubleFocus = false;
if (ImGui::IsWindowAppearing() || doubleFocus)
{
// Hack - set focus only works on the second time.
ImGui::SetKeyboardFocusHere(0);
doubleFocus ^= true;
}
if (ImGui::InputText("", DlgData.Entry.Name, IM_ARRAYSIZE(DlgData.Entry.Name),
ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_AutoSelectAll))
{
textBoxSubmit = true;
}
} }
else else
{ {
@ -185,7 +197,7 @@ void high_score::RenderHighScoreDialog()
ImGui::EndTable(); ImGui::EndTable();
} }
if (ImGui::Button(pb::get_rc_string(Msg::HIGHSCORES_Ok))) if (ImGui::Button(pb::get_rc_string(Msg::HIGHSCORES_Ok)) || textBoxSubmit)
{ {
if (dlg_enter_name) if (dlg_enter_name)
{ {

View File

@ -562,7 +562,7 @@ void pb::end_game()
if (position >= 0) if (position >= 0)
{ {
high_score_struct entry{ {0}, scores[i] }; high_score_struct entry{ {0}, scores[i] };
const char* playerName = "Player"; const char* playerName;
switch(scoreIndex[i]) switch(scoreIndex[i])
{ {