[iagno] Add the highlight-turnable-tiles settings.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [iagno] Add the highlight-turnable-tiles settings.
- Date: Mon, 15 Jul 2019 21:45:07 +0000 (UTC)
commit 196c58409cdba0375cdda27e390d11a7c7861ddb
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Sun Jul 14 18:31:50 2019 +0200
Add the highlight-turnable-tiles settings.
This function is mostly
for newbies, so disable
it by default and add a
switch for toggling it.
data/org.gnome.Reversi.gschema.xml | 7 +++++++
data/ui/iagno.ui | 5 +++++
src/game-view.vala | 6 +++++-
src/iagno.vala | 2 ++
4 files changed, 19 insertions(+), 1 deletion(-)
---
diff --git a/data/org.gnome.Reversi.gschema.xml b/data/org.gnome.Reversi.gschema.xml
index 729cb52..a2c4d36 100644
--- a/data/org.gnome.Reversi.gschema.xml
+++ b/data/org.gnome.Reversi.gschema.xml
@@ -27,6 +27,13 @@
<!-- Translators: description of a settings key, see 'dconf-editor /org/gnome/iagno/color' -->
<description>Whether to play as Dark or Light. Ignored for two-player games.</description>
</key>
+ <key name="highlight-turnable-tiles" type="b">
+ <default>false</default>
+ <!-- Translators: summary of a settings key, see 'dconf-editor
/org/gnome/iagno/highlight-turnable-tiles' -->
+ <summary>A flag to highlight turnable tiles</summary>
+ <!-- Translators: description of a settings key, see 'dconf-editor
/org/gnome/iagno/highlight-turnable-tiles' -->
+ <description>If “true”, the tiles that will be captured to the opponent by a ply are
highlighted.</description>
+ </key>
<key name="theme" type="s">
<default>'default'</default>
<!-- Translators: summary of a settings key, see 'dconf-editor /org/gnome/iagno/theme' -->
diff --git a/data/ui/iagno.ui b/data/ui/iagno.ui
index fe99945..3477d74 100644
--- a/data/ui/iagno.ui
+++ b/data/ui/iagno.ui
@@ -28,6 +28,11 @@
<attribute name="label" translatable="yes">A_ppearance</attribute>
<attribute name="action">app.theme</attribute>
</item>
+ <item>
+ <!-- Translators: hamburger menu entry; highlight-turnable-tiles togglebutton (with a mnemonic that
appears pressing Alt) -->
+ <attribute name="label" translatable="yes">Highlight _turnable tiles</attribute>
+ <attribute name="action">app.highlight-turnable-tiles</attribute>
+ </item>
<item>
<!-- Translators: hamburger menu entry; sound togglebutton (with a mnemonic that appears pressing
Alt) -->
<attribute name="label" translatable="yes">_Sound</attribute>
diff --git a/src/game-view.vala b/src/game-view.vala
index 59fda65..a82b07d 100644
--- a/src/game-view.vala
+++ b/src/game-view.vala
@@ -22,6 +22,8 @@
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; }
@@ -494,7 +496,9 @@ private class GameView : Gtk.DrawingArea
return;
}
highlight_tile (cr, x, y, highlight_state, /* soft highlight */ false);
- if (test_placing_tile && !(iagno_instance.computer != null && iagno_instance.player_one !=
game.current_color))
+ if (test_placing_tile
+ && show_turnable_tiles
+ && !(iagno_instance.computer != null && iagno_instance.player_one != game.current_color))
{
highlight_turnable_tiles (cr, move.x, move.y, 0, -1, move.n_tiles_n );
highlight_turnable_tiles (cr, move.x, move.y, 1, -1, move.n_tiles_ne);
diff --git a/src/iagno.vala b/src/iagno.vala
index fa62579..f2c1a29 100644
--- a/src/iagno.vala
+++ b/src/iagno.vala
@@ -254,6 +254,8 @@ private class Iagno : Gtk.Application
add_action (settings.create_action ("color"));
add_action (settings.create_action ("num-players"));
add_action (settings.create_action ("computer-level"));
+ add_action (settings.create_action ("highlight-turnable-tiles"));
+ settings.bind ("highlight-turnable-tiles", view, "show-turnable-tiles", SettingsBindFlags.GET);
Box level_box = (Box) builder.get_object ("difficulty-box");
Box color_box = (Box) builder.get_object ("color-box");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]