[gnome-nibbles/arnaudb/command-line] Skip setup screens depending on cli.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-nibbles/arnaudb/command-line] Skip setup screens depending on cli.
- Date: Thu, 9 Jul 2020 14:33:11 +0000 (UTC)
commit 03ad72ab39b2c3ace3e715c30938849aacdd0656
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Thu Jul 9 15:47:37 2020 +0200
Skip setup screens depending on cli.
src/gnome-nibbles.vala | 15 ++++++++++++++-
src/nibbles-window.vala | 39 +++++++++++++++++++++++++++++++++------
2 files changed, 47 insertions(+), 7 deletions(-)
---
diff --git a/src/gnome-nibbles.vala b/src/gnome-nibbles.vala
index 670580e..ee5d926 100644
--- a/src/gnome-nibbles.vala
+++ b/src/gnome-nibbles.vala
@@ -225,7 +225,20 @@ private class Nibbles : Gtk.Application
settings.set_boolean ("sound", (!) sound);
}
- window = new NibblesWindow (level == int.MIN ? 0 : level, start);
+ SetupScreen setup;
+ if (start)
+ setup = SetupScreen.GAME;
+ else if (nibbles_changed && players_changed)
+ {
+ if (speed != int.MIN && (disable_fakes || enable_fakes))
+ setup = SetupScreen.CONTROLS;
+ else
+ setup = SetupScreen.SPEED;
+ }
+ else
+ setup = SetupScreen.USUAL; // first-run or nibbles-number
+
+ window = new NibblesWindow (level == int.MIN ? 0 : level, setup);
add_window (window);
}
internal bool on_f1_pressed (Gdk.ModifierType state)
diff --git a/src/nibbles-window.vala b/src/nibbles-window.vala
index 4676075..1369750 100644
--- a/src/nibbles-window.vala
+++ b/src/nibbles-window.vala
@@ -18,6 +18,14 @@
using Gtk;
+private enum SetupScreen
+{
+ USUAL,
+ SPEED,
+ CONTROLS,
+ GAME
+}
+
[GtkTemplate (ui = "/org/gnome/Nibbles/ui/nibbles.ui")]
private class NibblesWindow : ApplicationWindow
{
@@ -62,7 +70,7 @@ private class NibblesWindow : ApplicationWindow
private NibblesGame? game = null;
public int cli_start_level { private get; internal construct; }
private int start_level { private get { return cli_start_level == 0 ? settings.get_int ("start-level") :
cli_start_level; }}
- public bool start_playing { private get; internal construct; }
+ public SetupScreen start_screen { private get; internal construct; }
/* Used for handling the game's scores */
private Games.Scores.Context scores_context;
@@ -92,9 +100,9 @@ private class NibblesWindow : ApplicationWindow
{ "back", back_cb } // called on Escape pressed; disabled only during countdown
(TODO pause?)
};
- internal NibblesWindow (int cli_start_level, bool start_playing)
+ internal NibblesWindow (int cli_start_level, SetupScreen start_screen)
{
- Object (cli_start_level: cli_start_level, start_playing: start_playing);
+ Object (cli_start_level: cli_start_level, start_screen: start_screen);
}
construct
@@ -177,7 +185,7 @@ private class NibblesWindow : ApplicationWindow
controls.load_pixmaps (view.tile_size);
/* Check whether to display the first run screen */
- if (start_playing)
+ if (start_screen == SetupScreen.GAME)
{
game.numhumans = settings.get_int ("players");
game.numai = settings.get_int ("ai");
@@ -188,6 +196,22 @@ private class NibblesWindow : ApplicationWindow
start_game ();
}
+ else if (start_screen == SetupScreen.CONTROLS)
+ {
+ game.numhumans = settings.get_int ("players");
+ game.numai = settings.get_int ("ai");
+ game.speed = settings.get_int ("speed");
+ game.fakes = settings.get_boolean ("fakes");
+
+ show_controls_screen ();
+ }
+ else if (start_screen == SetupScreen.SPEED)
+ {
+ game.numhumans = settings.get_int ("players");
+ game.numai = settings.get_int ("ai");
+
+ main_stack.set_visible_child_name ("speed");
+ }
else if (settings.get_boolean ("first-run"))
{
FirstRun first_run_panel = new FirstRun ();
@@ -519,6 +543,7 @@ private class NibblesWindow : ApplicationWindow
show_speed_screen ();
break;
case "speed":
+ leave_speed_screen ();
show_controls_screen ();
break;
case "controls":
@@ -568,7 +593,7 @@ private class NibblesWindow : ApplicationWindow
main_stack.set_visible_child_name ("speed");
}
- private void show_controls_screen ()
+ private void leave_speed_screen ()
{
int game_speed;
bool fakes;
@@ -577,8 +602,10 @@ private class NibblesWindow : ApplicationWindow
game.fakes = fakes;
settings.set_int ("speed", game_speed);
settings.set_boolean ("fakes", fakes);
+ }
- /* Create worms and load properties */
+ private void show_controls_screen ()
+ {
controls.clean ();
game.create_worms ();
game.load_worm_properties (worm_settings);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]