From f302687c7f12d964e61386049e6965f52523ba24 Mon Sep 17 00:00:00 2001 From: Muzychenko Andrey <33288308+k4zmu2a@users.noreply.github.com> Date: Fri, 15 Oct 2021 13:26:39 +0300 Subject: [PATCH] high_score: fixed new score not shifting older scores. Issue #33. --- SpaceCadetPinball/high_score.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/SpaceCadetPinball/high_score.cpp b/SpaceCadetPinball/high_score.cpp index 1254c8c..443c97e 100644 --- a/SpaceCadetPinball/high_score.cpp +++ b/SpaceCadetPinball/high_score.cpp @@ -162,32 +162,31 @@ void high_score::RenderHighScoreDialog() ImGui::TableSetupColumn("Score"); ImGui::TableHeadersRow(); - high_score_struct* tablePtr = dlg_hst; - for (int row = 0; row < 5; row++) + for (int offset = 0, row = 0; row < 5; row++) { ImGui::TableNextRow(); ImGui::TableNextColumn(); snprintf(buf, sizeof buf, "%d", row); ImGui::TextUnformatted(buf); - auto score = tablePtr->Score; + auto currentRow = &dlg_hst[row + offset]; + auto score = currentRow->Score; ImGui::TableNextColumn(); if (dlg_enter_name == 1 && dlg_position == row) { + offset = -1; score = dlg_score; ImGui::PushItemWidth(200); ImGui::InputText("", default_name, IM_ARRAYSIZE(default_name)); } else { - ImGui::TextUnformatted(tablePtr->Name); + ImGui::TextUnformatted(currentRow->Name); } ImGui::TableNextColumn(); score::string_format(score, buf); ImGui::TextUnformatted(buf); - - tablePtr++; } ImGui::EndTable(); }