summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorTimothy Flynn <trflynn89@pm.me>2021-05-18 11:24:07 -0400
committerAndreas Kling <kling@serenityos.org>2021-05-18 17:57:23 +0200
commit547c7ba57feb1d933e2c549664497688281e1033 (patch)
treea45160ea31918993dac3c86fa70d8b38be9eac5d /Userland
parent3d3a75f1b99185b0f4439b7b5fd3c927d71571ca (diff)
downloadserenity-547c7ba57feb1d933e2c549664497688281e1033.zip
Solitaire: Display high score in status bar
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Games/Solitaire/Solitaire.gml2
-rw-r--r--Userland/Games/Solitaire/main.cpp9
2 files changed, 7 insertions, 4 deletions
diff --git a/Userland/Games/Solitaire/Solitaire.gml b/Userland/Games/Solitaire/Solitaire.gml
index 18361997c8..89eab06248 100644
--- a/Userland/Games/Solitaire/Solitaire.gml
+++ b/Userland/Games/Solitaire/Solitaire.gml
@@ -12,6 +12,6 @@
@GUI::Statusbar {
name: "statusbar"
- label_count: 2
+ label_count: 3
}
}
diff --git a/Userland/Games/Solitaire/main.cpp b/Userland/Games/Solitaire/main.cpp
index c53630cd35..fb13ac7cdd 100644
--- a/Userland/Games/Solitaire/main.cpp
+++ b/Userland/Games/Solitaire/main.cpp
@@ -77,7 +77,8 @@ int main(int argc, char** argv)
auto& statusbar = *widget.find_descendant_of_type_named<GUI::Statusbar>("statusbar");
statusbar.set_text(0, "Score: 0");
- statusbar.set_text(1, "Time: 00:00:00");
+ statusbar.set_text(1, String::formatted("High Score: {}", high_score));
+ statusbar.set_text(2, "Time: 00:00:00");
app->on_action_enter = [&](GUI::Action& action) {
auto text = action.status_tip();
@@ -93,8 +94,10 @@ int main(int argc, char** argv)
game.on_score_update = [&](uint32_t score) {
statusbar.set_text(0, String::formatted("Score: {}", score));
- if (score > high_score)
+ if (score > high_score) {
update_high_score(score);
+ statusbar.set_text(1, String::formatted("High Score: {}", high_score));
+ }
};
uint64_t seconds_elapsed = 0;
@@ -106,7 +109,7 @@ int main(int argc, char** argv)
uint64_t minutes = (seconds_elapsed / 60) % 60;
uint64_t seconds = seconds_elapsed % 60;
- statusbar.set_text(1, String::formatted("Time: {:02}:{:02}:{:02}", hours, minutes, seconds));
+ statusbar.set_text(2, String::formatted("Time: {:02}:{:02}:{:02}", hours, minutes, seconds));
});
game.on_game_start = [&]() {