[gnome-nibbles/arnaudb/modernize-code: 34/58] Fix pause bug.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-nibbles/arnaudb/modernize-code: 34/58] Fix pause bug.
- Date: Wed, 10 Jun 2020 17:15:47 +0000 (UTC)
commit 788a45b9bca4846c88aa6755eb574c2ef7274481
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Wed May 27 19:55:50 2020 +0200
Fix pause bug.
Else pausing is saved after a game restart.
src/nibbles-game.vala | 1 +
src/nibbles-window.vala | 22 ++++++++++++++++++----
2 files changed, 19 insertions(+), 4 deletions(-)
---
diff --git a/src/nibbles-game.vala b/src/nibbles-game.vala
index 8b07866..a196b75 100644
--- a/src/nibbles-game.vala
+++ b/src/nibbles-game.vala
@@ -140,6 +140,7 @@ private class NibblesGame : Object
internal inline void reset ()
{
current_level = start_level;
+ is_paused = false;
}
private void end ()
diff --git a/src/nibbles-window.vala b/src/nibbles-window.vala
index 18e3a9d..337c6ee 100644
--- a/src/nibbles-window.vala
+++ b/src/nibbles-window.vala
@@ -276,6 +276,8 @@ private class NibblesWindow : ApplicationWindow
{
settings.set_boolean ("first-run", false);
+ if (game.is_paused)
+ set_pause_button_label (/* paused */ false);
game.reset ();
view.new_level (game.current_level);
@@ -371,19 +373,31 @@ private class NibblesWindow : ApplicationWindow
if (game.is_running)
{
game.pause ();
- /* Translators: label of the Pause button, when the game is paused */
- pause_button.set_label (_("_Resume"));
+ set_pause_button_label (/* paused */ true);
}
else
{
game.unpause ();
- /* Translators: label of the Pause button, when the game is running */
- pause_button.set_label (_("_Pause"));
+ set_pause_button_label (/* paused */ false);
view.grab_focus ();
}
}
}
+ private void set_pause_button_label (bool paused)
+ {
+ if (paused)
+ {
+ /* Translators: label of the Pause button, when the game is paused */
+ pause_button.set_label (_("_Resume"));
+ }
+ else
+ {
+ /* Translators: label of the Pause button, when the game is running */
+ pause_button.set_label (_("_Pause"));
+ }
+ }
+
/*\
* * Settings changed events
\*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]