gbrainy r493 - in trunk/src: . Dialogs



Author: jmas
Date: Tue Jan  6 13:28:48 2009
New Revision: 493
URL: http://svn.gnome.org/viewvc/gbrainy?rev=493&view=rev

Log:
2009-01-06 Jordi Mas <jmas softcatala org>

	* GameDrawingArea.cs:Allow next on memory games
	* gbrainy.cs: Allow next on memory games
	* GameSession.cs: Allow next on memory games
	* Dialogs/AboutDialog.cs: Update copyright year



Modified:
   trunk/src/ChangeLog
   trunk/src/Dialogs/AboutDialog.cs
   trunk/src/GameDrawingArea.cs
   trunk/src/GameSession.cs
   trunk/src/gbrainy.cs

Modified: trunk/src/Dialogs/AboutDialog.cs
==============================================================================
--- trunk/src/Dialogs/AboutDialog.cs	(original)
+++ trunk/src/Dialogs/AboutDialog.cs	Tue Jan  6 13:28:48 2009
@@ -51,7 +51,7 @@
 		Documenters = null;
 		Logo = LoadFromAssembly ("gbrainy.svg");
 
-		Copyright = "(c) 2007-2008 Jordi Mas i Hernandez\n";
+		Copyright = "(c) 2007-2009 Jordi Mas i Hernandez\n";
 		Copyright += Catalog.GetString ("Based on ideas by Terry Stickels, MENSA books and Jordi Mas.");
 
 		Comments = Catalog.GetString ("A brain teaser and trainer game to have fun and to keep your brain trained.");

Modified: trunk/src/GameDrawingArea.cs
==============================================================================
--- trunk/src/GameDrawingArea.cs	(original)
+++ trunk/src/GameDrawingArea.cs	Tue Jan  6 13:28:48 2009
@@ -35,13 +35,13 @@
 		CountDown,
 	}
 
+	GameSession session;
+	ArrayListIndicesRandom random_indices;
+	const int tips_shown = 4;
+	CountDown countdown;
+	bool rtl;
 	public Game puzzle;
-	public Modes mode;
-	private GameSession session;
-	private ArrayListIndicesRandom random_indices;
-	private const int tips_shown = 4;
-	private CountDown countdown;
-	private bool rtl;
+	Modes mode;
 
 	public GameDrawingArea ()
 	{
@@ -60,6 +60,16 @@
 		}
 	}
 
+	public Modes Mode {
+		get { return mode;}
+		set {
+			if (mode == Modes.CountDown && countdown != null)
+				countdown.EndDrawCountDown ();
+
+			mode = value;
+		}
+	}
+
 	private void DrawBand (CairoContextEx gr, double x, double y)
 	{
 		gr.Save ();
@@ -82,6 +92,7 @@
 			return;
 
 		countdown.EndDrawCountDown ();
+		countdown = null;
 	}
 
 	private void DrawImage (CairoContextEx gr, double x, double y, string img)

Modified: trunk/src/GameSession.cs
==============================================================================
--- trunk/src/GameSession.cs	(original)
+++ trunk/src/GameSession.cs	Tue Jan  6 13:28:48 2009
@@ -286,7 +286,7 @@
 
 	public void ScoreGame ()
 	{
-		if (scored_game == true)
+		if (current_game == null || scored_game == true)
 			return;
 
 		switch (current_game.Type) {

Modified: trunk/src/gbrainy.cs
==============================================================================
--- trunk/src/gbrainy.cs	(original)
+++ trunk/src/gbrainy.cs	Tue Jan  6 13:28:48 2009
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007-2008 Jordi Mas i HernÃndez <jmas softcatala org>
+ * Copyright (C) 2007-2009 Jordi Mas i HernÃndez <jmas softcatala org>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -136,7 +136,6 @@
 		toolbar.Insert (finish_tbbutton, -1);
 
 		session = new GameSession (this);
-		GameSensitiveUI ();
 
 		if (history == null)
 			history = new PlayerHistory ();
@@ -146,6 +145,7 @@
 
 		session.GameManager.Difficulty = (Game.Difficulty) preferences.GetIntValue (Preferences.DifficultyKey);
 		drawing_area = new GameDrawingArea ();
+		GameSensitiveUI ();
 
 		// For low resolutions, hide the toolbar and made the drawing area smaller
 		if (drawing_area.Screen.Width> 0 && drawing_area.Screen.Height > 0) {
@@ -178,7 +178,6 @@
 		solution_textview.ModifyBase (Gtk.StateType.Normal, color);
 
 		ActiveInputControls (false);
-		//OnMemoryOnly (this, EventArgs.Empty); // temp
 	}
 
 	/* Taken from locale.h  */
@@ -304,8 +303,13 @@
 	void GameSensitiveUI () 
 	{
 		//Toolbar buttons and menu items sensitive when there is or not a game
-		bool playing = session.Status != GameSession.SessionStatus.NotPlaying;
-		
+		bool playing;
+
+		if (session.Status != GameSession.SessionStatus.NotPlaying || drawing_area.Mode == GameDrawingArea.Modes.CountDown)
+			playing = true;
+		else
+			playing = false;
+	
 		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;
@@ -314,8 +318,9 @@
 
 	void OnNextGameAfterCountDown (object source, EventArgs e)
 	{
-		drawing_area.mode = GameDrawingArea.Modes.Puzzle;
+		drawing_area.Mode = GameDrawingArea.Modes.Puzzle;
 		ActiveInputControls (session.CurrentGame.ButtonsActive);
+		next_button.Sensitive = true;
 		drawing_area.puzzle = session.CurrentGame;		
 		UpdateQuestion (session.CurrentGame.Question);
 		answer_entry.Text = string.Empty;
@@ -334,7 +339,6 @@
 		session.NextGame ();
 		
 		if (preferences.GetBoolValue (Preferences.MemQuestionWarnKey) && session.Type != GameSession.Types.MemoryTrainers && ((session.CurrentGame as Memory)  != null)) {
-			ActiveInputControls (false);
 			drawing_area.OnDrawCountDown (OnNextGameAfterCountDown);
 		}
 		else
@@ -441,8 +445,11 @@
 		UpdateSolution (String.Empty);
  		UpdateQuestion (String.Empty);
 
-		if (preferences.GetBoolValue (Preferences.MemQuestionWarnKey))
+		if (preferences.GetBoolValue (Preferences.MemQuestionWarnKey)) {
 			drawing_area.OnDrawCountDown (OnMemoryOnlyAfterCountDown);
+			GameSensitiveUI ();
+			next_button.Sensitive = true;
+		}
 		else
 			OnNewGame ();
 	}
@@ -501,7 +508,7 @@
 
 	void OnEndGame (object sender, EventArgs args)
 	{
-		drawing_area.mode = GameDrawingArea.Modes.Scores;
+		drawing_area.Mode = GameDrawingArea.Modes.Scores;
 		drawing_area.GameSession = session.Copy ();
 	
 		history.SaveGameSession (session);



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