[iagno] Remove scoreboard.



commit 370182a094ee2d2c431dd584a2fcb9ccbecb3221
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Fri Mar 1 12:28:47 2019 +0100

    Remove scoreboard.

 data/iagno.css           |  7 ++--
 data/ui/iagno-screens.ui | 47 -----------------------
 data/ui/iagno.ui         | 36 ++----------------
 src/game-view.vala       | 97 ++----------------------------------------------
 src/game-window.vala     | 43 +++++++++------------
 src/iagno.vala           | 17 ---------
 6 files changed, 29 insertions(+), 218 deletions(-)
---
diff --git a/data/iagno.css b/data/iagno.css
index 3ff18a9..c5209da 100644
--- a/data/iagno.css
+++ b/data/iagno.css
@@ -21,13 +21,14 @@ button.unfullscreen-button {
   margin:6px;
 }
 
+.main-box {
+  padding:1.5rem;
+}
+
 /* Labels' tweaks */
 label.bold-label {
   font-weight: bold;
 }
-grid#scoreboard label {
-  padding: 4px 7px 4px 0;
-}
 
 /* "Default" theme is in italic */
 popover > stack > box:nth-child(2) > box > box > box:first-child > modelbutton:first-child > box > label {
diff --git a/data/ui/iagno-screens.ui b/data/ui/iagno-screens.ui
index 07da0c1..f3629d8 100644
--- a/data/ui/iagno-screens.ui
+++ b/data/ui/iagno-screens.ui
@@ -197,51 +197,4 @@
       </object>
     </child>
   </object>
-  <object class="GtkGrid" id="scoregrid">
-    <property name="name">scoreboard</property>
-    <property name="visible">True</property>
-    <property name="halign">center</property>
-    <property name="column-spacing">12</property>
-    <property name="row-spacing">0</property>
-    <property name="column-homogeneous">True</property>
-    <property name="row-homogeneous">True</property>
-    <property name="margin-end">12</property>
-    <child>
-      <object class="GtkDrawingArea" id="scoredrawing">
-        <property name="visible">True</property>
-      </object>
-      <packing>
-        <property name="left-attach">0</property>
-        <property name="top-attach">0</property>
-        <property name="width">2</property><!-- yeah, this sounds stupid, but... -->
-        <property name="height">2</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkLabel" id="dark-score-label">
-        <property name="visible">True</property>
-        <property name="label">00</property>
-        <style>
-          <class name="bold-label"/>
-        </style>
-      </object>
-      <packing>
-        <property name="left-attach">2</property>
-        <property name="top-attach">0</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkLabel" id="light-score-label">
-        <property name="visible">True</property>
-        <property name="label">00</property>
-        <style>
-          <class name="bold-label"/>
-        </style>
-      </object>
-      <packing>
-        <property name="left-attach">2</property>
-        <property name="top-attach">1</property>
-      </packing>
-    </child>
-  </object>
 </interface>
diff --git a/data/ui/iagno.ui b/data/ui/iagno.ui
index c8de818..66de515 100644
--- a/data/ui/iagno.ui
+++ b/data/ui/iagno.ui
@@ -143,42 +143,14 @@
                 <property name="height-request">350</property>
                 <property name="spacing">6</property>
               </object>
-              <packing>
-                <property name="name">start-box</property>
-              </packing>
             </child>
             <child>
-              <object class="GtkAspectFrame">
+              <object class="GtkBox" id="view_box">
                 <property name="visible">True</property>
-                <property name="shadow-type">GTK_SHADOW_NONE</property>
-                <property name="obey-child">false</property>
-                <property name="ratio">1.4</property>
-                <property name="margin">25</property>
-                <child>
-                  <object class="GtkBox" id="game_box">
-                    <property name="visible">True</property>
-                    <property name="orientation">horizontal</property>
-                    <property name="spacing">25</property>
-                    <child>
-                      <object class="GtkBox" id="side_box">
-                        <property name="visible">True</property>
-                        <property name="orientation">vertical</property>
-                        <property name="spacing">6</property>
-                        <property name="width-request">111</property>
-                      </object>
-                      <packing>
-                        <property name="pack-type">end</property>
-                        <property name="expand">False</property>
-                        <property name="fill">True</property>
-                        <property name="padding">0</property>
-                      </packing>
-                    </child>
-                  </object>
-                </child>
+                <style>
+                  <class name="main-box"/>
+                </style>
               </object>
-              <packing>
-                <property name="name">frame</property>
-              </packing>
             </child>
           </object>
         </child>
diff --git a/src/game-view.vala b/src/game-view.vala
index da22afc..048f63d 100644
--- a/src/game-view.vala
+++ b/src/game-view.vala
@@ -24,16 +24,6 @@ private class GameView : Gtk.DrawingArea
 {
     internal bool show_turnable_tiles { private get; internal set; default = false; }
 
-    private Gtk.DrawingArea _scoreboard;
-    [CCode (notify = false)] internal Gtk.DrawingArea scoreboard {
-        private get { return _scoreboard; }
-        internal set
-        {
-            _scoreboard = value;
-            _scoreboard.draw.connect (draw_scoreboard);
-        }
-    }
-
     /* Theme */
     private string pieces_file;
 
@@ -103,7 +93,6 @@ private class GameView : Gtk.DrawingArea
     /* Pre-rendered image */
     private uint render_size = 0;
     private Cairo.Pattern? tiles_pattern = null;
-    private Cairo.Pattern? scoreboard_tiles_pattern = null;
     private Cairo.Pattern? board_pattern = null;
 
     private bool noise_pixbuf_loaded = false;
@@ -114,9 +103,6 @@ private class GameView : Gtk.DrawingArea
     /* Animation timer */
     private uint animate_timeout = 0;
 
-    // private double cursor = 0;
-    private int current_player_number = 0;
-
     internal signal void move (uint8 x, uint8 y);
     internal signal void clear_impossible_to_move_here_warning ();
 
@@ -165,6 +151,9 @@ private class GameView : Gtk.DrawingArea
 
     construct
     {
+        hexpand = true;
+        vexpand = true;
+
         set_events (Gdk.EventMask.EXPOSURE_MASK
                   | Gdk.EventMask.BUTTON_PRESS_MASK
                   | Gdk.EventMask.BUTTON_RELEASE_MASK
@@ -216,8 +205,6 @@ private class GameView : Gtk.DrawingArea
 
             /* redraw all */
             tiles_pattern = null;
-            // scoreboard_tiles_pattern = null;
-            scoreboard.queue_draw ();
             queue_draw ();
         }
     }
@@ -1275,82 +1262,4 @@ private class GameView : Gtk.DrawingArea
                 queue_draw_tile (x, y);
             });
     }
-
-    /*\
-    * * scoreboard
-    \*/
-
-    private bool draw_scoreboard (Cairo.Context cr)
-    {
-        int height = scoreboard.get_allocated_height ();
-        int width = scoreboard.get_allocated_width ();
-        double half_height = height / 2.0;
-
-        cr.set_line_cap (Cairo.LineCap.ROUND);
-        cr.set_line_join (Cairo.LineJoin.ROUND);
-
-        cr.save ();
-
-        cr.set_source_rgba (mark_red, mark_green, mark_blue, 1.0);
-        cr.set_line_width (mark_width);
-
-        cr.translate (0, current_player_number * half_height);
-        cr.move_to (height / 4.0, height / 8.0);
-        cr.line_to (width - 5.0 * height / 8.0, height / 4.0);
-        cr.line_to (height / 4.0, 3.0 * height / 8.0);
-        cr.stroke ();
-
-        cr.restore ();
-
-        // if (scoreboard_tiles_pattern == null)
-        // {
-            /* prepare drawing of pieces */
-            var surface = new Cairo.Surface.similar (cr.get_target (), Cairo.Content.COLOR_ALPHA, height * 
4, height * 2);
-            var c = new Cairo.Context (surface);
-            load_image (c, height * 4, height * 2);
-            scoreboard_tiles_pattern = new Cairo.Pattern.for_surface (surface);
-
-            cr.translate (width - half_height, 0);
-            var matrix = Cairo.Matrix.identity ();
-
-            /* draw dark piece */
-            matrix.translate (half_height, 0);
-            ((!) scoreboard_tiles_pattern).set_matrix (matrix);
-            cr.set_source ((!) scoreboard_tiles_pattern);
-            cr.rectangle (0, 0, /* width and height */ half_height, half_height);
-            cr.fill ();
-
-            /* draw white piece */
-            matrix.translate (3 * height, height);
-            ((!) scoreboard_tiles_pattern).set_matrix (matrix);
-            cr.set_source ((!) scoreboard_tiles_pattern);
-            cr.rectangle (0, half_height, /* width and height */ half_height, half_height);
-            cr.fill ();
-        // }
-
-        // TODO
-        /* if (cursor > current_player_number)
-        {
-            cursor -= 0.14;
-            if (cursor < 0)
-                cursor = 0;
-            scoreboard.queue_draw ();
-        }
-        else if (cursor < current_player_number)
-        {
-            cursor += 0.14;
-            if (cursor > 1)
-                cursor = 1;
-            scoreboard.queue_draw ();
-        } */
-
-        return true;
-    }
-
-    internal void update_scoreboard ()
-        requires (game_is_set)
-    {
-        current_player_number = (game.current_color == Player.DARK) ? 0 : 1;
-        scoreboard.queue_draw ();  // TODO queue_draw_area (…), or only refresh part of the DrawingArea, or 
both
-    }
 }
diff --git a/src/game-window.vala b/src/game-window.vala
index 70ce7e0..000dad5 100644
--- a/src/game-window.vala
+++ b/src/game-window.vala
@@ -43,16 +43,14 @@ private class GameWindow : ApplicationWindow
     /* private widgets */
     [GtkChild] private HeaderBar headerbar;
     [GtkChild] private Stack stack;
+    [GtkChild] private Box new_game_box;
+    [GtkChild] private Box view_box;
 
     private Button? start_game_button = null;
     [GtkChild] private Button new_game_button;
     [GtkChild] private Button back_button;
     [GtkChild] private Button unfullscreen_button;
 
-    [GtkChild] private Box game_box;
-    [GtkChild] private Box new_game_box;
-    [GtkChild] private Box side_box;
-
     private Widget view;
 
     /* signals */
@@ -118,8 +116,8 @@ private class GameWindow : ApplicationWindow
 
         configure_history_button ();
 
-        game_box.pack_start (view, true, true, 0);
-        game_box.set_focus_child (view);            // TODO test if necessary; note: view could grab focus 
from application
+        view_box.add (view);
+        stack.set_visible_child (view_box);
         view.halign = Align.FILL;
         view.can_focus = true;
         view.show ();
@@ -219,11 +217,6 @@ private class GameWindow : ApplicationWindow
     * * Some internal calls
     \*/
 
-    internal void add_to_sidebox (Widget widget)
-    {
-        side_box.pack_start (widget, false, false, 0);
-    }
-
     internal void cannot_undo_more ()
     {
         undo_action.set_enabled (false);
@@ -269,7 +262,7 @@ private class GameWindow : ApplicationWindow
     {
         headerbar.set_subtitle (null);      // TODO save / restore?
 
-        stack.set_visible_child_name ("start-box");
+        stack.set_visible_child (new_game_box);
         new_game_button.hide ();
         history_button.hide ();
 
@@ -281,7 +274,7 @@ private class GameWindow : ApplicationWindow
 
     private void show_view ()
     {
-        stack.set_visible_child_name ("frame");
+        stack.set_visible_child (view_box);
         back_button.hide ();        // TODO transition?
         new_game_button.show ();
         history_button.show ();
@@ -298,8 +291,8 @@ private class GameWindow : ApplicationWindow
 
     private void new_game_cb ()
     {
-        string? stack_child = stack.get_visible_child_name ();
-        if (stack_child == null || (!) stack_child != "frame")
+        Widget? stack_child = stack.get_visible_child ();
+        if (stack_child == null || (!) stack_child != view_box)
             return;
 
         wait ();
@@ -315,8 +308,8 @@ private class GameWindow : ApplicationWindow
 
     private void start_game_cb ()
     {
-        string? stack_child = stack.get_visible_child_name ();
-        if (stack_child == null || (!) stack_child != "start-box")
+        Widget? stack_child = stack.get_visible_child ();
+        if (stack_child == null || (!) stack_child != new_game_box)
             return;
 
         game_finished = false;
@@ -335,8 +328,8 @@ private class GameWindow : ApplicationWindow
 
     private void back_cb ()
     {
-        string? stack_child = stack.get_visible_child_name ();
-        if (stack_child == null || (!) stack_child != "start-box")
+        Widget? stack_child = stack.get_visible_child ();
+        if (stack_child == null || (!) stack_child != new_game_box)
             return;
         // TODO change back headerbar subtitle?
         stack.set_transition_type (StackTransitionType.SLIDE_RIGHT);
@@ -352,10 +345,10 @@ private class GameWindow : ApplicationWindow
 
     private void undo_cb ()
     {
-        string? stack_child = stack.get_visible_child_name ();
+        Widget? stack_child = stack.get_visible_child ();
         if (stack_child == null)
             return;
-        if ((!) stack_child != "frame")
+        if ((!) stack_child != view_box)
         {
             if (back_action.get_enabled ())
                 back_cb ();
@@ -372,8 +365,8 @@ private class GameWindow : ApplicationWindow
 
 /*    private void redo_cb ()
     {
-        string? stack_child = stack.get_visible_child_name ();
-        if (stack_child == null || (!) stack_child != "frame")
+        Widget? stack_child = stack.get_visible_child ();
+        if (stack_child == null || (!) stack_child != view_box)
             return;
 
         if (!back_button.is_focus)
@@ -384,8 +377,8 @@ private class GameWindow : ApplicationWindow
 
 /*    private void hint_cb ()
     {
-        string? stack_child = stack.get_visible_child_name ();
-        if (stack_child == null || (!) stack_child != "frame")
+        Widget? stack_child = stack.get_visible_child ();
+        if (stack_child == null || (!) stack_child != view_box)
             return;
         hint ();
     } */
diff --git a/src/iagno.vala b/src/iagno.vala
index 96cdccf..0f69507 100644
--- a/src/iagno.vala
+++ b/src/iagno.vala
@@ -45,8 +45,6 @@ private class Iagno : Gtk.Application
     /* Widgets */
     private GameWindow window;
     private GameView view;
-    private Label dark_score_label;
-    private Label light_score_label;
 
     /* Computer player (if there is one) */
     internal ComputerPlayer? computer { internal get; private set; default = null; }
@@ -212,9 +210,6 @@ private class Iagno : Gtk.Application
         view.move.connect (player_move_cb);
         view.clear_impossible_to_move_here_warning.connect (clear_impossible_to_move_here_warning);
 
-        DrawingArea scoredrawing = (DrawingArea) builder.get_object ("scoredrawing");
-        view.scoreboard = scoredrawing;
-
         if (settings.get_boolean ("sound"))
             init_sound ();
 
@@ -294,9 +289,6 @@ private class Iagno : Gtk.Application
                                  view,
                                  appearance_menu);
 
-        Widget scoregrid = (Widget) builder.get_object ("scoregrid");
-        window.add_to_sidebox (scoregrid);
-
         window.play.connect (start_game);
         window.wait.connect (wait_cb);
         window.back.connect (back_cb);
@@ -335,10 +327,6 @@ private class Iagno : Gtk.Application
         level_box.sensitive = solo;
         color_box.sensitive = solo;
 
-        /* Information widgets */
-        light_score_label = (Label) builder.get_object ("light-score-label");
-        dark_score_label = (Label) builder.get_object ("dark-score-label");
-
         if (start_now)
             start_game ();
 
@@ -460,10 +448,6 @@ private class Iagno : Gtk.Application
         requires (game_is_set)
     {
         window.new_turn_start (/* can undo */ first_player_is_human ? (game.number_of_moves >= 1) : 
(game.number_of_moves >= 2));
-
-        /* Translators: this is a 2 digit representation of the current score. */
-        dark_score_label.set_text (_("%.2d").printf (game.n_dark_tiles));
-        light_score_label.set_text (_("%.2d").printf (game.n_light_tiles));
     }
 
     private void undo_cb ()
@@ -599,7 +583,6 @@ private class Iagno : Gtk.Application
     {
         /* for the move that just ended */
         play_sound (Sound.FLIP);
-        view.update_scoreboard ();
         window.set_history_button_label (game.current_color);
     }
 


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