1
0
mirror of https://github.com/k4zmu2a/SpaceCadetPinball.git synced 2024-11-25 20:22:33 +01:00

high_score: fixed new score not shifting older scores.

Issue #33.
This commit is contained in:
Muzychenko Andrey 2021-10-15 13:26:39 +03:00
parent fd973f049c
commit f302687c7f

View File

@ -162,32 +162,31 @@ void high_score::RenderHighScoreDialog()
ImGui::TableSetupColumn("Score"); ImGui::TableSetupColumn("Score");
ImGui::TableHeadersRow(); ImGui::TableHeadersRow();
high_score_struct* tablePtr = dlg_hst; for (int offset = 0, row = 0; row < 5; row++)
for (int row = 0; row < 5; row++)
{ {
ImGui::TableNextRow(); ImGui::TableNextRow();
ImGui::TableNextColumn(); ImGui::TableNextColumn();
snprintf(buf, sizeof buf, "%d", row); snprintf(buf, sizeof buf, "%d", row);
ImGui::TextUnformatted(buf); ImGui::TextUnformatted(buf);
auto score = tablePtr->Score; auto currentRow = &dlg_hst[row + offset];
auto score = currentRow->Score;
ImGui::TableNextColumn(); ImGui::TableNextColumn();
if (dlg_enter_name == 1 && dlg_position == row) if (dlg_enter_name == 1 && dlg_position == row)
{ {
offset = -1;
score = dlg_score; score = dlg_score;
ImGui::PushItemWidth(200); ImGui::PushItemWidth(200);
ImGui::InputText("", default_name, IM_ARRAYSIZE(default_name)); ImGui::InputText("", default_name, IM_ARRAYSIZE(default_name));
} }
else else
{ {
ImGui::TextUnformatted(tablePtr->Name); ImGui::TextUnformatted(currentRow->Name);
} }
ImGui::TableNextColumn(); ImGui::TableNextColumn();
score::string_format(score, buf); score::string_format(score, buf);
ImGui::TextUnformatted(buf); ImGui::TextUnformatted(buf);
tablePtr++;
} }
ImGui::EndTable(); ImGui::EndTable();
} }