gbrainy r485 - trunk/src
- From: jmas svn gnome org
- To: svn-commits-list gnome org
- Subject: gbrainy r485 - trunk/src
- Date: Sun, 28 Dec 2008 09:59:54 +0000 (UTC)
Author: jmas
Date: Sun Dec 28 09:59:54 2008
New Revision: 485
URL: http://svn.gnome.org/viewvc/gbrainy?rev=485&view=rev
Log:
2008-12-28 Jordi Mas <jmas softcatala org>
* gbrainy.cs: Make UI elements sensitive to playing. Activate resume
* gbrainy.glade: Name elements to be able to reference them
* GameDrawingArea.cs: New memory tip
Modified:
trunk/src/ChangeLog
trunk/src/GameDrawingArea.cs
trunk/src/gbrainy.cs
trunk/src/gbrainy.glade
Modified: trunk/src/GameDrawingArea.cs
==============================================================================
--- trunk/src/GameDrawingArea.cs (original)
+++ trunk/src/GameDrawingArea.cs Sun Dec 28 09:59:54 2008
@@ -39,7 +39,6 @@
public Modes mode;
private GameSession session;
private ArrayListIndicesRandom random_indices;
- private const int tips_count = 10;
private const int tips_shown = 4;
private CountDown countdown;
private bool rtl;
@@ -56,7 +55,7 @@
public GameSession GameSession {
set {
session = value;
- random_indices = new ArrayListIndicesRandom (tips_count);
+ random_indices = new ArrayListIndicesRandom (GameTips.Count);
random_indices.Initialize ();
}
}
@@ -375,6 +374,10 @@
class GameTips
{
+ static public int Count {
+ get { return 11; }
+ }
+
static public String GetTip (int tip)
{
switch (tip) {
@@ -398,6 +401,8 @@
return Catalog.GetString ("Use the Settings to adjust the difficulty level of the game.");
case 9:
return Catalog.GetString ("Association of elements is a common technique for remembering things.");
+ case 10:
+ return Catalog.GetString ("Grouping elements into categories is a common technique for remembering things.");
}
return string.Empty;
Modified: trunk/src/gbrainy.cs
==============================================================================
--- trunk/src/gbrainy.cs (original)
+++ trunk/src/gbrainy.cs Sun Dec 28 09:59:54 2008
@@ -51,9 +51,12 @@
[Glade.Widget] Gtk.Label label_answer;
[Glade.Widget] Gtk.Menu settings_menu;
[Glade.Widget] Gtk.Menu help_menu;
+ [Glade.Widget] Gtk.MenuItem pause_menuitem;
+ [Glade.Widget] Gtk.MenuItem finish_menuitem;
+ [Glade.Widget] Gtk.MenuItem newgame_menuitem;
GameDrawingArea drawing_area;
GameSession session;
- ToolButton pause_tbbutton;
+ ToolButton all_tbbutton, logic_tbbutton, calculation_tbbutton, memory_tbbutton, pause_tbbutton, finish_tbbutton;
Gtk.TextBuffer question_buffer;
Gtk.TextBuffer solution_buffer;
TextTag tag_green;
@@ -96,43 +99,44 @@
tag_green.Foreground = "#00A000";
solution_buffer.TagTable.Add (tag_green);
- ToolButton button = new ToolButton ("allgames");
- button.SetTooltip (tooltips, Catalog.GetString ("Play all the games"), null);
- button.Label = Catalog.GetString ("All");
- button.Clicked += OnAllGames;
- toolbar.Insert (button, -1);
-
- button = new ToolButton ("logic-games");
- button.SetTooltip (tooltips, Catalog.GetString ("Play games that challenge your reasoning and thinking"), null);
- button.Label = Catalog.GetString ("Logic");
- button.Clicked += OnLogicOnly;
- toolbar.Insert (button, -1);
-
- button = new ToolButton ("math-games");
- button.Label = Catalog.GetString ("Calculation");
- button.SetTooltip (tooltips, Catalog.GetString ("Play games that challenge your mental calculation skills"), null);
- button.Clicked += OnMathOnly;
- toolbar.Insert (button, -1);
-
- button = new ToolButton ("memory-games");
- button.Label = Catalog.GetString ("Memory");
- button.SetTooltip (tooltips, Catalog.GetString ("Play games that challenge your short term memory"), null);
- button.Clicked += OnMemoryOnly;
- toolbar.Insert (button, -1);
+ all_tbbutton = new ToolButton ("allgames");
+ all_tbbutton.SetTooltip (tooltips, Catalog.GetString ("Play all the games"), null);
+ all_tbbutton.Label = Catalog.GetString ("All");
+ all_tbbutton.Clicked += OnAllGames;
+ toolbar.Insert (all_tbbutton, -1);
+
+ logic_tbbutton = new ToolButton ("logic-games");
+ logic_tbbutton.SetTooltip (tooltips, Catalog.GetString ("Play games that challenge your reasoning and thinking"), null);
+ logic_tbbutton.Label = Catalog.GetString ("Logic");
+ logic_tbbutton.Clicked += OnLogicOnly;
+ toolbar.Insert (logic_tbbutton, -1);
+
+ calculation_tbbutton = new ToolButton ("math-games");
+ calculation_tbbutton.Label = Catalog.GetString ("Calculation");
+ calculation_tbbutton.SetTooltip (tooltips, Catalog.GetString ("Play games that challenge your mental calculation skills"), null);
+ calculation_tbbutton.Clicked += OnMathOnly;
+ toolbar.Insert (calculation_tbbutton, -1);
+
+ memory_tbbutton = new ToolButton ("memory-games");
+ memory_tbbutton.Label = Catalog.GetString ("Memory");
+ memory_tbbutton.SetTooltip (tooltips, Catalog.GetString ("Play games that challenge your short term memory"), null);
+ memory_tbbutton.Clicked += OnMemoryOnly;
+ toolbar.Insert (memory_tbbutton, -1);
pause_tbbutton = new ToolButton ("pause");
pause_tbbutton.Label = Catalog.GetString ("Pause");
- pause_tbbutton.SetTooltip (tooltips, Catalog.GetString ("Pause the game"), null);
+ pause_tbbutton.SetTooltip (tooltips, Catalog.GetString ("Pause or resume the game"), null);
pause_tbbutton.Clicked += OnPauseGame;
toolbar.Insert (pause_tbbutton, -1);
- button = new ToolButton ("endgame");
- button.SetTooltip (tooltips, Catalog.GetString ("End the game and show score"), null);
- button.Label = Catalog.GetString ("Finish");
- button.Clicked += OnEndGame;
- toolbar.Insert (button, -1);
+ finish_tbbutton = new ToolButton ("endgame");
+ finish_tbbutton.SetTooltip (tooltips, Catalog.GetString ("End the game and show score"), null);
+ finish_tbbutton.Label = Catalog.GetString ("Finish");
+ finish_tbbutton.Clicked += OnEndGame;
+ toolbar.Insert (finish_tbbutton, -1);
- session = new GameSession (this);
+ session = new GameSession (this);
+ GameSensitiveUI ();
if (history == null)
history = new PlayerHistory ();
@@ -151,7 +155,6 @@
}
}
-
#if MONO_ADDINS
Gtk.MenuItem item = new Gtk.MenuItem (Catalog.GetString ("Extensions"));
settings_menu.Append (item);
@@ -298,6 +301,17 @@
drawing_area.QueueDraw ();
}
+ void GameSensitiveUI ()
+ {
+ //Toolbar buttons and menu items sensitive when there is or not a game
+ bool playing = session.Status != GameSession.SessionStatus.NotPlaying;
+
+ finish_tbbutton.Sensitive = pause_tbbutton.Sensitive = playing;
+ all_tbbutton.Sensitive = calculation_tbbutton.Sensitive = memory_tbbutton.Sensitive = logic_tbbutton.Sensitive = !playing;
+ pause_menuitem.Sensitive = finish_menuitem.Sensitive = playing;
+ newgame_menuitem.Sensitive = !playing;
+ }
+
void OnNextGameAfterCountDown (object source, EventArgs e)
{
drawing_area.mode = GameDrawingArea.Modes.Puzzle;
@@ -405,6 +419,7 @@
{
session.NewSession ();
GetNextGame ();
+ GameSensitiveUI ();
UpdateSolution (Catalog.GetString ("Once you have an answer type it in the \"Answer:\" entry box and press the \"OK\" button."));
UpdateStatusBar ();
}
@@ -497,22 +512,33 @@
UpdateSolution (String.Empty);
UpdateQuestion (String.Empty);
UpdateStatusBar ();
+ GameSensitiveUI ();
drawing_area.QueueDraw ();
ActiveInputControls (false);
+ SetPauseResumeButton (true);
}
- void OnPauseGame (object sender, EventArgs args)
+ void SetPauseResumeButton (bool pause)
{
- if (session.Paused) {
+ if (pause) {
+ pause_tbbutton.StockId = "pause";
+ pause_tbbutton.Label = Catalog.GetString ("Pause");
session.Resume ();
ActiveInputControls (true);
} else {
+ pause_tbbutton.StockId = "resume";
+ pause_tbbutton.Label = Catalog.GetString ("Resume");
session.Pause ();
ActiveInputControls (false);
}
UpdateStatusBar ();
}
+ void OnPauseGame (object sender, EventArgs args)
+ {
+ SetPauseResumeButton (session.Paused);
+ }
+
private void OnToolbarActivate (object sender, System.EventArgs args)
{
int width, height;
Modified: trunk/src/gbrainy.glade
==============================================================================
--- trunk/src/gbrainy.glade (original)
+++ trunk/src/gbrainy.glade Sun Dec 28 09:59:54 2008
@@ -42,7 +42,7 @@
<widget class="GtkMenu" id="item1_menu">
<child>
- <widget class="GtkMenuItem" id="menuitem2">
+ <widget class="GtkMenuItem" id="newgame_menuitem">
<property name="visible">True</property>
<property name="stock_item">GNOMEUIINFO_MENU_NEW_GAME_ITEM</property>
@@ -108,7 +108,7 @@
</child>
<child>
- <widget class="GtkImageMenuItem" id="imagemenuitem1">
+ <widget class="GtkImageMenuItem" id="pause_menuitem">
<property name="visible">True</property>
<property name="stock_item">GNOMEUIINFO_MENU_PAUSE_GAME_ITEM</property>
<signal name="activate" handler="OnPauseGame" last_modification_time="Tue, 07 Aug 2007 11:50:41 GMT"/>
@@ -116,7 +116,7 @@
</child>
<child>
- <widget class="GtkMenuItem" id="menuitem8">
+ <widget class="GtkMenuItem" id="finish_menuitem">
<property name="visible">True</property>
<property name="stock_item">GNOMEUIINFO_MENU_END_GAME_ITEM</property>
<signal name="activate" handler="OnEndGame" last_modification_time="Tue, 07 Aug 2007 11:50:41 GMT"/>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]