Commit 02dec862 authored by Arnaud Bonatti's avatar Arnaud Bonatti

Some cleanings.

parent a2c20560
......@@ -116,7 +116,7 @@ private class GameWindow : BaseWindow, AdaptativeWidget
return false;
}
public void shutdown (GLib.Settings settings)
internal void shutdown (GLib.Settings settings)
{
settings.set_int ("window-width", window_width);
settings.set_int ("window-height", window_height);
......@@ -128,30 +128,30 @@ private class GameWindow : BaseWindow, AdaptativeWidget
* * Some public calls
\*/
public void cannot_undo_more ()
internal void cannot_move ()
{
restart_action.set_enabled (false);
undo_action.set_enabled (false);
game_view.show_game_content (/* grab focus */ true);
/* Translators: notification, as a subtitle of the headerbar; on the 15-Puzzle game, if the user clicks a tile that cannot move */
show_notification (_("You can’t move this tile!"));
}
public void set_moves_count (uint moves_count)
internal void move (uint moves_count)
{
headerbar.set_moves_count (ref moves_count);
hide_notification ();
bool undo_possible = moves_count != 0;
restart_action.set_enabled (undo_possible);
undo_action.set_enabled (undo_possible);
if (!undo_possible)
game_view.show_game_content (/* grab focus */ true);
}
public void set_subtitle (string? subtitle)
{
if (subtitle != null)
show_notification ((!) subtitle);
}
public void finish_game ()
internal void finish_game ()
{
game_finished = true;
headerbar.new_game_button_grab_focus ();
headerbar.save_best_score ();
/* Translators: notification, as a subtitle of the headerbar; on both games, if the user solves the puzzle */
show_notification (_("Bravo! You finished the game!"));
}
protected override bool escape_pressed ()
......@@ -201,9 +201,9 @@ private class GameWindow : BaseWindow, AdaptativeWidget
public signal void redo ();
public signal void hint ();
public SimpleAction restart_action;
public SimpleAction undo_action;
public SimpleAction redo_action;
private SimpleAction restart_action;
private SimpleAction undo_action;
private SimpleAction redo_action;
private bool back_action_disabled = true;
......
......@@ -58,7 +58,6 @@ public class Game : Object
public signal void move (bool x_axis, int number, int x_gap, int y_gap, uint moves_count, bool disable_animation);
public signal void empty_tile ();
public signal void cannot_move (int x, int y);
public signal void cannot_undo_more ();
/*\
* * Creation / exporting
......@@ -303,9 +302,6 @@ public class Game : Object
state = previous_state;
previous_state = state == null ? null : ((!) state).previous;
if (state == null)
cannot_undo_more ();
}
public void restart ()
......@@ -320,8 +316,6 @@ public class Game : Object
state = previous_state;
previous_state = state == null ? null : ((!) state).previous;
}
cannot_undo_more ();
}
private void add_move (int x_gap, int y_gap)
......
......@@ -239,13 +239,16 @@ private class Taquin : Gtk.Application, BaseApplication
private void start_game ()
{
if (game != null)
{
SignalHandler.disconnect_by_func ((!) game, null, this);
SignalHandler.disconnect_by_func ((!) game, null, window);
}
GameType type = (GameType) settings.get_enum ("type");
int size = settings.get_int ("size");
game = new Game (type, size);
view.game = (!) game;
window.set_moves_count (0);
window.move (0);
string filename = "";
var dirlist = theme_dirlist.copy ();
......@@ -260,8 +263,7 @@ private class Taquin : Gtk.Application, BaseApplication
view.realize (); // TODO does that help?
((!) game).complete.connect (game_complete_cb);
((!) game).cannot_move.connect (cannot_move_cb);
((!) game).cannot_undo_more.connect (window.cannot_undo_more);
((!) game).cannot_move.connect (window.cannot_move);
((!) game).move.connect (move_cb);
}
......@@ -289,24 +291,13 @@ private class Taquin : Gtk.Application, BaseApplication
private void move_cb (bool x_axis, int number, int x_gap, int y_gap, uint moves_count, bool disable_animation)
{
window.set_moves_count (moves_count);
window.set_subtitle (null);
window.restart_action.set_enabled (true);
window.undo_action.set_enabled (true);
window.move (moves_count);
play_sound ("sliding-1"); // TODO sliding-n??
}
private void cannot_move_cb ()
{
/* Translators: notification, as a subtitle of the headerbar; on the 15-Puzzle game, if the user clicks a tile that cannot move */
window.set_subtitle (_("You can’t move this tile!"));
}
private void game_complete_cb ()
{
window.finish_game ();
/* Translators: notification, as a subtitle of the headerbar; on both games, if the user solves the puzzle */
window.set_subtitle (_("Bravo! You finished the game!"));
play_sound ("gameover");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment