gbrainy r526 - in trunk/src: . CalculationGames Dialogs MemoryGames PuzzleGames
- From: jmas svn gnome org
- To: svn-commits-list gnome org
- Subject: gbrainy r526 - in trunk/src: . CalculationGames Dialogs MemoryGames PuzzleGames
- Date: Sun, 5 Apr 2009 11:58:47 +0000 (UTC)
Author: jmas
Date: Sun Apr 5 11:58:47 2009
New Revision: 526
URL: http://svn.gnome.org/viewvc/gbrainy?rev=526&view=rev
Log:
2009-04-05 Jordi Mas <jmas softcatala org>
* GameSession.cs: Use const and style fixes
* GameDrawingArea.cs: Use const and style fixes
* Dialogs/PlayerHistoryDialog.cs: Use const and style fixes
* Dialogs/CustomGameDialog.cs: Use const and style fixes
* MemoryGames/MemoryCountDots.cs: Use const and style fixes
* MemoryGames/MemoryIndications.cs: Use const and style fixes
* gbrainy.cs: Use const and style fixes
* CairoContextEx.cs: Use const and style fixes
* PuzzleGames/PuzzleFigures.cs: Use const and style fixes
* PuzzleGames/PuzzleCoverPercentage.cs: Use const and style fixes
* PuzzleGames/PuzzleClocks.cs: Use const and style fixes
* PuzzleGames/PuzzleMostInCommon.cs: Use const and style fixes
* PuzzleGames/PuzzleDivideCircle.cs: Use const and style fixes
* PuzzleGames/PuzzleCounting.cs: Use const and style fixes
* PuzzleGames/PuzzleTriangles.cs: Use const and style fixes
* PuzzleGames/PuzzleCirclesRectangle.cs: Use const and style fixes
* PuzzleGames/PuzzleCube.cs: Use const and style fixes
* PuzzleGames/PuzzleFigurePattern.cs: Use const and style fixes
* PuzzleGames/PuzzleBalance.cs: Use const and style fixes
* PuzzleGames/PuzzlePeopleTable.cs: Use const and style fixes
* PuzzleGames/PuzzleLargerShape.cs: Use const and style fixes
* CalculationGames/CalculationArithmetical.cs: Use const and style fixes
* CalculationGames/CalculationFractions.cs: Use const and style fixes
* CalculationGames/CalculationOperator.cs: Use const and style fixes
* Memory.cs: Use const and style fixes
Modified:
trunk/src/CairoContextEx.cs
trunk/src/CalculationGames/CalculationArithmetical.cs
trunk/src/CalculationGames/CalculationFractions.cs
trunk/src/CalculationGames/CalculationOperator.cs
trunk/src/ChangeLog
trunk/src/Dialogs/CustomGameDialog.cs
trunk/src/Dialogs/PlayerHistoryDialog.cs
trunk/src/GameDrawingArea.cs
trunk/src/GameSession.cs
trunk/src/Memory.cs
trunk/src/MemoryGames/MemoryCountDots.cs
trunk/src/MemoryGames/MemoryIndications.cs
trunk/src/PuzzleGames/PuzzleBalance.cs
trunk/src/PuzzleGames/PuzzleCirclesRectangle.cs
trunk/src/PuzzleGames/PuzzleClocks.cs
trunk/src/PuzzleGames/PuzzleCounting.cs
trunk/src/PuzzleGames/PuzzleCoverPercentage.cs
trunk/src/PuzzleGames/PuzzleCube.cs
trunk/src/PuzzleGames/PuzzleDivideCircle.cs
trunk/src/PuzzleGames/PuzzleFigurePattern.cs
trunk/src/PuzzleGames/PuzzleFigures.cs
trunk/src/PuzzleGames/PuzzleLargerShape.cs
trunk/src/PuzzleGames/PuzzleMostInCommon.cs
trunk/src/PuzzleGames/PuzzlePeopleTable.cs
trunk/src/PuzzleGames/PuzzleTriangles.cs
trunk/src/gbrainy.cs
Modified: trunk/src/CairoContextEx.cs
==============================================================================
--- trunk/src/CairoContextEx.cs (original)
+++ trunk/src/CairoContextEx.cs Sun Apr 5 11:58:47 2009
@@ -135,7 +135,7 @@
the device unit space and then translate to our user space.
* Cairo Show.Text paints on the bottom-left of the coordinates
- and Pango paints on the top-left of the coordinate
+ and Pango paints on the top-left of the coordinates
*/
Modified: trunk/src/CalculationGames/CalculationArithmetical.cs
==============================================================================
--- trunk/src/CalculationGames/CalculationArithmetical.cs (original)
+++ trunk/src/CalculationGames/CalculationArithmetical.cs Sun Apr 5 11:58:47 2009
@@ -101,8 +101,9 @@
public override void Draw (CairoContextEx gr, int area_width, int area_height)
{
- double operand_y = DrawAreaY + 0.2, operand_space = 0.1;
- double aligned_pos = 0.58;
+ double operand_y = DrawAreaY + 0.2;
+ const double operand_space = 0.1;
+ const double aligned_pos = 0.58;
base.Draw (gr, area_width, area_height);
Modified: trunk/src/CalculationGames/CalculationFractions.cs
==============================================================================
--- trunk/src/CalculationGames/CalculationFractions.cs (original)
+++ trunk/src/CalculationGames/CalculationFractions.cs Sun Apr 5 11:58:47 2009
@@ -131,9 +131,9 @@
public override void Draw (CairoContextEx gr, int area_width, int area_height)
{
- double fraction_size = 0.17;
+ const double fraction_size = 0.17;
double x = 0.5 - (fractions_num * fraction_size / 2), y = DrawAreaY + 0.3;
- double offset_x = 0.12;
+ const double offset_x = 0.12;
base.Draw (gr, area_width, area_height);
Modified: trunk/src/CalculationGames/CalculationOperator.cs
==============================================================================
--- trunk/src/CalculationGames/CalculationOperator.cs (original)
+++ trunk/src/CalculationGames/CalculationOperator.cs Sun Apr 5 11:58:47 2009
@@ -82,7 +82,7 @@
public override void Draw (CairoContextEx gr, int area_width, int area_height)
{
- double aligned_pos = 0.58;
+ const double aligned_pos = 0.58;
base.Draw (gr, area_width, area_height);
Modified: trunk/src/Dialogs/CustomGameDialog.cs
==============================================================================
--- trunk/src/Dialogs/CustomGameDialog.cs (original)
+++ trunk/src/Dialogs/CustomGameDialog.cs Sun Apr 5 11:58:47 2009
@@ -33,18 +33,19 @@
int ngames, npos;
Type [] custom_games;
+ const int COL_ENABLED = 2;
+ const int COL_OBJECT = 3;
+
public CustomGameDialog (GameManager manager) : base ("customgame")
{
Game game;
Type[] games;
GameManager gm;
- ngames = 0;
this.manager = manager;
gm = new GameManager ();
gm.GameType = GameSession.Types.AllGames;
games = gm.CustomGames;
- dialog = null;
drawing_area = new CairoPreview ();
preview_vbox.Add (drawing_area);
@@ -65,7 +66,7 @@
CellRendererToggle toggle_cell = new CellRendererToggle();
TreeViewColumn toggle_column = new TreeViewColumn(Catalog.GetString("Enabled"),
- toggle_cell, "active", 2);
+ toggle_cell, "active", COL_ENABLED);
toggle_cell.Activatable = true;
toggle_cell.Toggled += OnActiveToggled;
toggle_column.Expand = false;
@@ -119,7 +120,7 @@
return;
}
- Game game = games_store.GetValue (iter, 3) as Game;
+ Game game = games_store.GetValue (iter, COL_OBJECT) as Game;
game.Initialize ();
preview_question.Markup = game.Question;
drawing_area.puzzle = game;
@@ -133,14 +134,14 @@
if (!games_store.GetIter (out iter, new TreePath (args.Path)))
return;
- bool enabled = !(bool) games_store.GetValue (iter, 2);
- games_store.SetValue (iter, 2, enabled);
+ bool enabled = !(bool) games_store.GetValue (iter, COL_ENABLED);
+ games_store.SetValue (iter, COL_ENABLED, enabled);
}
void OnSelectAll (object sender, EventArgs args)
{
games_store.Foreach (delegate (TreeModel model, TreePath path, TreeIter iter) {
- games_store.SetValue (iter, 2, true);
+ games_store.SetValue (iter, COL_ENABLED, true);
return false;
});
}
@@ -148,7 +149,7 @@
void OnUnSelectAll (object sender, EventArgs args)
{
games_store.Foreach (delegate (TreeModel model, TreePath path, TreeIter iter) {
- games_store.SetValue (iter, 2, false);
+ games_store.SetValue (iter, COL_ENABLED, false);
return false;
});
}
@@ -159,7 +160,7 @@
npos = 0;
games_store.Foreach (delegate (TreeModel model, TreePath path, TreeIter iter) {
- if ((bool) games_store.GetValue (iter, 2) == true)
+ if ((bool) games_store.GetValue (iter, COL_ENABLED) == true)
ngames++;
return false;
@@ -170,8 +171,8 @@
custom_games = new Type [ngames];
games_store.Foreach (delegate (TreeModel model, TreePath path, TreeIter iter) {
- Game game = games_store.GetValue (iter, 3) as Game;
- bool enabled = (bool) games_store.GetValue (iter, 2);
+ Game game = games_store.GetValue (iter, COL_OBJECT) as Game;
+ bool enabled = (bool) games_store.GetValue (iter, COL_ENABLED);
if (enabled == true) {
custom_games[npos] = game.GetType ();
@@ -186,7 +187,7 @@
public class CairoPreview : DrawingArea
{
- public Game puzzle = null;
+ public Game puzzle;
protected override bool OnExposeEvent (Gdk.EventExpose args)
{
Modified: trunk/src/Dialogs/PlayerHistoryDialog.cs
==============================================================================
--- trunk/src/Dialogs/PlayerHistoryDialog.cs (original)
+++ trunk/src/Dialogs/PlayerHistoryDialog.cs Sun Apr 5 11:58:47 2009
@@ -81,7 +81,7 @@
private void DrawLegend (CairoContextEx cr, double x, double y)
{
- double line_size = 0.05, offset_x = 0.01, second_row = 0.05;
+ const double line_size = 0.05, offset_x = 0.01, second_row = 0.05;
cr.Color = total_color;
cr.MoveTo (x, y);
@@ -125,10 +125,12 @@
{
double px, py;
PlayerHistory history = gbrainy.history;
- double ratio = (area_w / (history.Games.Count - 1));
+ double ratio;
if (history.Games.Count == 0)
return;
+
+ ratio = area_w / (history.Games.Count - 1);
if (dlg.checkbutton_logic.Active) { // Logic
cr.Color = logic_color;
Modified: trunk/src/GameDrawingArea.cs
==============================================================================
--- trunk/src/GameDrawingArea.cs (original)
+++ trunk/src/GameDrawingArea.cs Sun Apr 5 11:58:47 2009
@@ -48,9 +48,6 @@
public GameDrawingArea (gbrainy application)
{
mode = Modes.Welcome;
- puzzle = null;
- session = null;
- countdown = null;
rtl = Direction == Gtk.TextDirection.Rtl;
this.application = application;
}
@@ -105,7 +102,7 @@
private void DrawWelcome (CairoContextEx gr, int area_width, int area_height)
{
double y = 0.05;
- double space = 0.20;
+ const double space = 0.20;
gr.Scale (area_width, area_height);
gr.DrawBackground ();
@@ -142,7 +139,7 @@
}
- static public void DrawBar (CairoContextEx gr, double x, double y, double w, double h, double percentage)
+ static void DrawBar (CairoContextEx gr, double x, double y, double w, double h, double percentage)
{
double per = percentage / 100;
@@ -165,8 +162,8 @@
private void DrawGraphicBar (CairoContextEx gr, double x, double y)
{
- double area_w = 0.8, area_h = 0.28;
- double bar_w = 0.05, bar_h = area_h - 0.02;
+ const double area_w = 0.8, area_h = 0.28;
+ const double bar_w = 0.05, bar_h = area_h - 0.02;
gr.LineWidth = 0.005;
@@ -196,7 +193,7 @@
private void DrawScores (CairoContextEx gr, int area_width, int area_height)
{
double y = 0.04, x = 0.05;
- double space_small = 0.02;
+ const double space_small = 0.02;
string s;
gr.Scale (area_width, area_height);
Modified: trunk/src/GameSession.cs
==============================================================================
--- trunk/src/GameSession.cs (original)
+++ trunk/src/GameSession.cs Sun Apr 5 11:58:47 2009
@@ -72,11 +72,6 @@
{
game_manager = new GameManager ();
game_time = TimeSpan.Zero;
- games_played = 0;
- games_won = 0;
- current_game = null;
- timer = null;
- paused = false;
app = brainy;
timer = new System.Timers.Timer ();
@@ -85,8 +80,6 @@
scores = new int [(int) ScoresType.Last];
games = new int [(int) ScoresType.Last];
- total_score = 0;
- scored_game = false;
status = SessionStatus.NotPlaying;
}
Modified: trunk/src/Memory.cs
==============================================================================
--- trunk/src/Memory.cs (original)
+++ trunk/src/Memory.cs Sun Apr 5 11:58:47 2009
@@ -167,7 +167,7 @@
public void DrawTimeBar (CairoContextEx gr, double x, double y, double percentage)
{
double width = 0.04, height = 0.6;
- double w = 0.003, h = 0.003;
+ const double w = 0.003, h = 0.003;
gr.Save ();
gr.Color = new Color (0, 0, 0);
Modified: trunk/src/MemoryGames/MemoryCountDots.cs
==============================================================================
--- trunk/src/MemoryGames/MemoryCountDots.cs (original)
+++ trunk/src/MemoryGames/MemoryCountDots.cs Sun Apr 5 11:58:47 2009
@@ -84,13 +84,13 @@
private void DrawObject (CairoContextEx gr, int area_width, int area_height)
{
palette.Alpha = alpha;
- double x = DrawAreaX + 0.15, y = DrawAreaY + 0.1 ;
+ double x = DrawAreaX + 0.15, y = DrawAreaY + 0.1;
gr.Color = palette.Cairo(ColorPalette.Id.Black);
double pos_x = x, pos_y = y;
- double figure_size = 0.6 ;
- double square_size = figure_size / NUMCOLUMNS ;
- double center_square = square_size / 2;
+ const double figure_size = 0.6;
+ const double square_size = figure_size / NUMCOLUMNS ;
+ const double center_square = square_size / 2;
double radius_square = .8 * (square_size - (LineWidth *2)) / 2;
gr.Rectangle (pos_x, pos_y, figure_size, figure_size);
Modified: trunk/src/MemoryGames/MemoryIndications.cs
==============================================================================
--- trunk/src/MemoryGames/MemoryIndications.cs (original)
+++ trunk/src/MemoryGames/MemoryIndications.cs Sun Apr 5 11:58:47 2009
@@ -51,8 +51,8 @@
public void Draw (CairoContextEx gr, ref double x, ref double y, Indication next_prev)
{
- double line_length = 0.050;
- double points = 0.050;
+ const double line_length = 0.050;
+ const double points = 0.050;
if (type == Type.Start) {
gr.Rectangle (x, y, points, points);
Modified: trunk/src/PuzzleGames/PuzzleBalance.cs
==============================================================================
--- trunk/src/PuzzleGames/PuzzleBalance.cs (original)
+++ trunk/src/PuzzleGames/PuzzleBalance.cs Sun Apr 5 11:58:47 2009
@@ -75,7 +75,7 @@
public void DrawBalance (CairoContextEx gr, double x, double y, int index, bool full)
{
- double width = 0.5;
+ const double width = 0.5;
double fig_x = x + 0.1, fig_y = y - 0.11;
int total = (full == true) ? (elements * 2) : elements;
Modified: trunk/src/PuzzleGames/PuzzleCirclesRectangle.cs
==============================================================================
--- trunk/src/PuzzleGames/PuzzleCirclesRectangle.cs (original)
+++ trunk/src/PuzzleGames/PuzzleCirclesRectangle.cs Sun Apr 5 11:58:47 2009
@@ -58,9 +58,9 @@
{
double first_x = DrawAreaX + 0.05;
double first_y = DrawAreaY + 0.1;
- double space_fromrect = 0.02, space_fromcircle = 0.01;
+ const double space_fromrect = 0.02, space_fromcircle = 0.01;
int circles = 8;
- double unit = 0.0625;
+ const double unit = 0.0625;
base.Draw (gr, area_width, area_height);
Modified: trunk/src/PuzzleGames/PuzzleClocks.cs
==============================================================================
--- trunk/src/PuzzleGames/PuzzleClocks.cs (original)
+++ trunk/src/PuzzleGames/PuzzleClocks.cs Sun Apr 5 11:58:47 2009
@@ -106,7 +106,7 @@
static void DrawClock (CairoContextEx gr, double x, double y, int hand_short, int hand_large, bool draw_large)
{
- double radius = figure_size / 2;
+ const double radius = figure_size / 2;
double x0, y0;
int num, degrees;
Modified: trunk/src/PuzzleGames/PuzzleCounting.cs
==============================================================================
--- trunk/src/PuzzleGames/PuzzleCounting.cs (original)
+++ trunk/src/PuzzleGames/PuzzleCounting.cs Sun Apr 5 11:58:47 2009
@@ -108,8 +108,8 @@
if (gametype == GameType.Fence)
{
double x105, y105;
- double x = 0.35, y = 0.2;
- double figure_size = 0.4;
+ const double x = 0.35, y = 0.2;
+ const double figure_size = 0.4;
x105 = figure_size * Math.Cos (105 * Math.PI / 180);
y105 = figure_size * Math.Sin (105 * Math.PI / 180);
Modified: trunk/src/PuzzleGames/PuzzleCoverPercentage.cs
==============================================================================
--- trunk/src/PuzzleGames/PuzzleCoverPercentage.cs (original)
+++ trunk/src/PuzzleGames/PuzzleCoverPercentage.cs Sun Apr 5 11:58:47 2009
@@ -26,7 +26,7 @@
private bool cover_zone1, cover_zone2, cover_zone3, cover_zone4;
private int partial_zone, partial_zones;
private const double width = 0.5, height = 0.5;
- private double line_width = 0.001;
+ private const double line_width = 0.001;
public override string Name {
get {return Catalog.GetString ("Cover percentage");}
Modified: trunk/src/PuzzleGames/PuzzleCube.cs
==============================================================================
--- trunk/src/PuzzleGames/PuzzleCube.cs (original)
+++ trunk/src/PuzzleGames/PuzzleCube.cs Sun Apr 5 11:58:47 2009
@@ -53,8 +53,8 @@
{
double x = DrawAreaX + 0.1;
double y = DrawAreaY + 0.1;
- double txtoff_x = 0.04;
- double txtoff_y = 0.03;
+ const double txtoff_x = 0.04;
+ const double txtoff_y = 0.03;
base.Draw (gr, area_width, area_height);
Modified: trunk/src/PuzzleGames/PuzzleDivideCircle.cs
==============================================================================
--- trunk/src/PuzzleGames/PuzzleDivideCircle.cs (original)
+++ trunk/src/PuzzleGames/PuzzleDivideCircle.cs Sun Apr 5 11:58:47 2009
@@ -65,7 +65,7 @@
static private void DrawAndConnectPoints (CairoContextEx gr, double x, double y, Circle[] circles, bool connect)
{
- double point_size = 0.01;
+ const double point_size = 0.01;
for (int i = 0; i < circles.Length; i++) {
gr.Arc (x + point_size + circles[i].x, y + point_size + circles[i].y, point_size, 0, 2 * Math.PI);
gr.Fill ();
Modified: trunk/src/PuzzleGames/PuzzleFigurePattern.cs
==============================================================================
--- trunk/src/PuzzleGames/PuzzleFigurePattern.cs (original)
+++ trunk/src/PuzzleGames/PuzzleFigurePattern.cs Sun Apr 5 11:58:47 2009
@@ -100,7 +100,7 @@
{
double org_x = DrawAreaX + 0.1;
double x = org_x, y = 0.08;
- double figure_size = 0.13, space_x = 0.1, space_y = 0.2;
+ const double figure_size = 0.13, space_x = 0.1, space_y = 0.2;
double x45, y45, x135, y135, offset;
base.Draw (gr, area_width, area_height);
Modified: trunk/src/PuzzleGames/PuzzleFigures.cs
==============================================================================
--- trunk/src/PuzzleGames/PuzzleFigures.cs (original)
+++ trunk/src/PuzzleGames/PuzzleFigures.cs Sun Apr 5 11:58:47 2009
@@ -107,7 +107,7 @@
public override void Draw (CairoContextEx gr, int area_width, int area_height)
{
int element;
- double figure_width = 0.1, figure_height = 0.1, space_width = 0.05, space_height = 0.1;
+ const double figure_width = 0.1, figure_height = 0.1, space_width = 0.05, space_height = 0.1;
double x = DrawAreaX, y = DrawAreaY;
base.Draw (gr, area_width, area_height);
Modified: trunk/src/PuzzleGames/PuzzleLargerShape.cs
==============================================================================
--- trunk/src/PuzzleGames/PuzzleLargerShape.cs (original)
+++ trunk/src/PuzzleGames/PuzzleLargerShape.cs Sun Apr 5 11:58:47 2009
@@ -201,8 +201,8 @@
private void DrawPossibleAnswer (CairoContextEx gr, double x, double y, char [] portions, int figure, int seq)
{
- int columns = 3, rows = 3;
- double rect_w = 0.05, rect_h = 0.05;
+ const int columns = 3, rows = 3;
+ const double rect_w = 0.05, rect_h = 0.05;
int index = figure * columns * rows;
for (int row = 0; row < rows; row++) {
Modified: trunk/src/PuzzleGames/PuzzleMostInCommon.cs
==============================================================================
--- trunk/src/PuzzleGames/PuzzleMostInCommon.cs (original)
+++ trunk/src/PuzzleGames/PuzzleMostInCommon.cs Sun Apr 5 11:58:47 2009
@@ -256,7 +256,7 @@
private void DrawFigure (CairoContextEx gr, double x, double y, FigureElement[] figure)
{
- double cercle_size = 0.15;
+ const double cercle_size = 0.15;
gr.Stroke ();
gr.Arc (x + cercle_size / 2, y + cercle_size / 2, cercle_size / 2, 0, 2 * Math.PI);
gr.Stroke ();
Modified: trunk/src/PuzzleGames/PuzzlePeopleTable.cs
==============================================================================
--- trunk/src/PuzzleGames/PuzzlePeopleTable.cs (original)
+++ trunk/src/PuzzleGames/PuzzlePeopleTable.cs Sun Apr 5 11:58:47 2009
@@ -97,7 +97,7 @@
gr.Arc (pos_x + figure_size, pos_y + figure_size, figure_size, 0, 2 * Math.PI);
gr.Stroke ();
- double point_size = 0.01;
+ const double point_size = 0.01;
for (int i = 0; i < circles.Length; i++) {
gr.Arc (x + point_size + circles[i].x, y + point_size + circles[i].y, point_size, 0, 2 * Math.PI);
gr.Fill ();
Modified: trunk/src/PuzzleGames/PuzzleTriangles.cs
==============================================================================
--- trunk/src/PuzzleGames/PuzzleTriangles.cs (original)
+++ trunk/src/PuzzleGames/PuzzleTriangles.cs Sun Apr 5 11:58:47 2009
@@ -65,7 +65,7 @@
public override void Draw (CairoContextEx gr, int area_width, int area_height)
{
double x = DrawAreaX + 0.1, y = DrawAreaY + 0.2;
- double witdh = 0.6, height = 0.5;
+ const double witdh = 0.6, height = 0.5;
base.Draw (gr, area_width, area_height);
Modified: trunk/src/gbrainy.cs
==============================================================================
--- trunk/src/gbrainy.cs (original)
+++ trunk/src/gbrainy.cs Sun Apr 5 11:58:47 2009
@@ -311,7 +311,7 @@
void GameSensitiveUI ()
{
- //Toolbar buttons and menu items sensitive when there is or not a game
+ //Toolbar buttons and menu items that are sensitive when the user is playing
bool playing;
if (session.Status != GameSession.SessionStatus.NotPlaying || drawing_area.Mode == GameDrawingArea.Modes.CountDown)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]