[gnome-chess/chess-telepathy-networking-support-664946-rebase: 8/64] [glchess] Add new setting "opponent-type" & let "opponent" store remote IDs
- From: Chandni Verma <vchandni src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-chess/chess-telepathy-networking-support-664946-rebase: 8/64] [glchess] Add new setting "opponent-type" & let "opponent" store remote IDs
- Date: Sun, 23 Dec 2012 03:39:17 +0000 (UTC)
commit f7a127595e4299dd2298d2cda6724b4f7c3afb06
Author: Chandni Verma <chandniverma2112 gmail com>
Date: Tue May 1 12:26:58 2012 +0530
[glchess] Add new setting "opponent-type" & let "opponent" store remote IDs
data/org.gnome.gnome-chess.gschema.xml.in | 7 ++++-
src/gnome-chess.vala | 41 +++++++++++++++++++---------
2 files changed, 34 insertions(+), 14 deletions(-)
---
diff --git a/data/org.gnome.gnome-chess.gschema.xml.in b/data/org.gnome.gnome-chess.gschema.xml.in
index daf2599..668ac50 100644
--- a/data/org.gnome.gnome-chess.gschema.xml.in
+++ b/data/org.gnome.gnome-chess.gschema.xml.in
@@ -146,10 +146,15 @@
<_summary>true if the human player is playing white</_summary>
<_description>true if the human player is playing white</_description>
</key>
+ <key name="opponent-type" type="s">
+ <default>'robot'</default>
+ <_summary>The kind of opponent player</_summary>
+ <_description>Can be 'robot' to play against a chess engine, 'local-player' to play against a local player or 'remote-player' to play against a remote contact</_description>
+ </key>
<key name="opponent" type="s">
<default>''</default>
<_summary>The opponent player</_summary>
- <_description>Can be 'human' (play against another human player), '' (use the first available chess engine) or the name of a specific engine to play against</_description>
+ <_description>Can be 'human' (play against another human player), '' (use the first available chess engine), the name of a specific engine to play against or a string uniquely identifying a remote player</_description>
</key>
<key name="difficulty" enum="org.gnome.gnome-chess.Difficulty">
<default>'easy'</default>
diff --git a/src/gnome-chess.vala b/src/gnome-chess.vala
index 1aab737..170d19a 100644
--- a/src/gnome-chess.vala
+++ b/src/gnome-chess.vala
@@ -43,7 +43,7 @@ public class Application : Gtk.Application
private Gtk.TreeView treeview_robots;
private Gtk.ListStore robot_list_model;
- private Gtk.Widget done_button;
+ private Gtk.Button done_button;
private Gtk.Widget grid_installable_robots;
private Gtk.Label label_install_robots;
@@ -184,7 +184,7 @@ public class Application : Gtk.Application
treeview_robots = (Gtk.TreeView) builder.get_object ("treeview_robots");
robot_list_model = (Gtk.ListStore) treeview_robots.model;
- done_button = (Gtk.Widget) builder.get_object ("button_preferences_done");
+ done_button = (Gtk.Button) builder.get_object ("button_preferences_done");
grid_installable_robots = (Gtk.Widget) builder.get_object ("grid_installable_robots");
label_install_robots = (Gtk.Label) builder.get_object ("label_install_robots");
@@ -1256,6 +1256,17 @@ public class Application : Gtk.Application
}
break;
}
+
+ if (settings.get_string ("opponent-type") == "robot")
+ {
+ treeview_robots.sensitive = true;
+ done_button.label = _("_Done");
+ }
+ else
+ {
+ treeview_robots.sensitive = false;
+ done_button.label = _("_Back");
+ }
}
else
{
@@ -2114,19 +2125,23 @@ public class Application : Gtk.Application
var duration = settings.get_int ("duration");
if (duration > 0)
pgn_game.time_control = "%d".printf (duration);
- var engine_name = settings.get_string ("opponent");
- var engine_level = settings.get_string ("difficulty");
- if (engine_name != null && engine_name != "human")
+
+ if (settings.get_string ("opponent-type") == "robot")
{
- if (settings.get_boolean ("play-as-white"))
+ var engine_name = settings.get_string ("opponent");
+ var engine_level = settings.get_string ("difficulty");
+ if (engine_name != null)
{
- pgn_game.tags.insert ("BlackAI", engine_name);
- pgn_game.tags.insert ("BlackLevel", engine_level);
- }
- else
- {
- pgn_game.tags.insert ("WhiteAI", engine_name);
- pgn_game.tags.insert ("WhiteLevel", engine_level);
+ if (settings.get_boolean ("play-as-white"))
+ {
+ pgn_game.tags.insert ("BlackAI", engine_name);
+ pgn_game.tags.insert ("BlackLevel", engine_level);
+ }
+ else
+ {
+ pgn_game.tags.insert ("WhiteAI", engine_name);
+ pgn_game.tags.insert ("WhiteLevel", engine_level);
+ }
}
}
start_game ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]