[five-or-more/vala-port] show score dialog on gameover



commit 9d6924deec731c90db5ba1bb4cf546ea00a08d50
Author: Thomas Hindoe Paaboel Andersen <phomes gmail com>
Date:   Sun Nov 11 22:40:14 2012 +0100

    show score dialog on gameover

 TODO                 |    5 ++++-
 src/application.vala |   30 ++++++++++++++++++------------
 2 files changed, 22 insertions(+), 13 deletions(-)
---
diff --git a/TODO b/TODO
index 10880cb..8ac8f37 100644
--- a/TODO
+++ b/TODO
@@ -13,7 +13,8 @@ Are the window sizes stored on shutdown?
 Should the translations files be cleaned up after the split?
 
 Implement the line-detection code
-Implement game over detection
+
+Use the current score when showing the gameover score-dialog
 
 2d-view:
   show the queue
@@ -25,3 +26,5 @@ cli: use the keys from gdk instead of hardcoding the numbers
 Remove all unused code files from the old games-lib
 
 Add a new-game screen
+
+use the clamp function from vala
diff --git a/src/application.vala b/src/application.vala
index 22a4a83..1d61700 100644
--- a/src/application.vala
+++ b/src/application.vala
@@ -68,32 +68,38 @@ namespace FiveOrMore
             section.append (_("_Quit"), "app.quit");
             set_app_menu (menu);
 
-            var size = get_current_size ();
-            board = new GlinesBoard(size.columns, size.rows, size.ncolors, size.npieces);
-
-            var box = (Gtk.Box) builder.get_object ("vbox");
-            var view2d = new View2D (board);
-            box.add (view2d);
-            view2d.show ();
-
             window = (Gtk.ApplicationWindow) builder.get_object ("glines_window");
             add_window (window);
 
             history = new History (Path.build_filename (Environment.get_user_data_dir (), "five-or-more", "history"));
             history.load ();
+
+            setup_new_game ();
         }
 
         public override void activate ()
         {
-            //var v = new ViewCli (board);
-            //v.run();
-
             window.present ();
         }
 
         private void new_game_cb ()
         {
-            stdout.printf ("new game\n");
+            setup_new_game ();
+        }
+
+        private void setup_new_game ()
+        {
+            var size = get_current_size ();
+            board = new GlinesBoard(size.columns, size.rows, size.ncolors, size.npieces);
+            board.gameover.connect ((o) => this.scores_cb());
+
+            var view2d = new View2D (board);
+
+            var box = (Gtk.Box) builder.get_object ("vbox");
+            box.foreach(c => box.remove (c));
+
+            box.add (view2d);
+            view2d.show ();
         }
 
         private void scores_cb ()



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]