gnome-games r8313 - trunk/gnometris
- From: jclinton svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-games r8313 - trunk/gnometris
- Date: Sat, 15 Nov 2008 04:13:52 +0000 (UTC)
Author: jclinton
Date: Sat Nov 15 04:13:52 2008
New Revision: 8313
URL: http://svn.gnome.org/viewvc/gnome-games?rev=8313&view=rev
Log:
Fix the whitespace nightmare in Gnometris; ignore this.
All vim modelines set to C++ mode with tab whitespace.
Modified:
trunk/gnometris/blockops.cpp
trunk/gnometris/blockops.h
trunk/gnometris/blocks.cpp
trunk/gnometris/blocks.h
trunk/gnometris/field-noclutter.cpp
trunk/gnometris/field-noclutter.h
trunk/gnometris/field.cpp
trunk/gnometris/field.h
trunk/gnometris/highscores.cpp
trunk/gnometris/highscores.h
trunk/gnometris/main.cpp
trunk/gnometris/preview.h
trunk/gnometris/renderer.cpp
trunk/gnometris/renderer.h
trunk/gnometris/scoreframe.cpp
trunk/gnometris/scoreframe.h
trunk/gnometris/tetris.cpp
trunk/gnometris/tetris.h
Modified: trunk/gnometris/blockops.cpp
==============================================================================
--- trunk/gnometris/blockops.cpp (original)
+++ trunk/gnometris/blockops.cpp Sat Nov 15 04:13:52 2008
@@ -1,4 +1,4 @@
-/* -*- mode:C; indent-tabs-mode:nill; tab-width:8; c-basic-offset:8 -*- */
+/* -*- mode:C++; tab-width:8; c-basic-offset:8; indent-tabs-mode:true -*- */
/*
* written by J. Marcin Gorycki <marcin gorycki intel com>
*
@@ -27,10 +27,10 @@
BlockOps::BlockOps() :
- useTarget (false),
- blocknr (0),
- rot (0),
- color (0)
+ useTarget (false),
+ blocknr (0),
+ rot (0),
+ color (0)
{
field = new Block*[COLUMNS];
@@ -220,12 +220,12 @@
int
BlockOps::dropBlock()
{
- int count = 0;
-
+ int count = 0;
+
while (!moveBlockDown())
count++;
- return count;
+ return count;
}
void
@@ -320,7 +320,7 @@
for (int y = 0; y < LINES; ++y)
{
- // Allow for at least one blank per line
+ // Allow for at least one blank per line
blank = g_random_int_range(0, COLUMNS);
for (int x = 0; x < COLUMNS; ++x)
@@ -386,10 +386,10 @@
bool
BlockOps::isFieldEmpty (void)
{
- for (int x = 0; x < COLUMNS; x++) {
- if (field[x][LINES-1].what != EMPTY)
- return false;
- }
+ for (int x = 0; x < COLUMNS; x++) {
+ if (field[x][LINES-1].what != EMPTY)
+ return false;
+ }
- return true;
+ return true;
}
Modified: trunk/gnometris/blockops.h
==============================================================================
--- trunk/gnometris/blockops.h (original)
+++ trunk/gnometris/blockops.h Sat Nov 15 04:13:52 2008
@@ -1,5 +1,4 @@
-/* -*- mode:C; indent-tabs-mode:nill; tab-width:8; c-basic-offset:8 -*- */
-
+/* -*- mode:C++; tab-width:8; c-basic-offset:8; indent-tabs-mode:true -*- */
#ifndef __blockops_h__
#define __blockops_h__
@@ -26,60 +25,60 @@
#include "tetris.h"
enum SlotType {
- EMPTY,
- TARGET,
- FALLING,
- LAYING
+ EMPTY,
+ TARGET,
+ FALLING,
+ LAYING
};
struct Block {
- SlotType what;
- int color;
+ SlotType what;
+ int color;
};
class BlockOps {
public:
- BlockOps ();
- ~BlockOps ();
+ BlockOps ();
+ ~BlockOps ();
- bool moveBlockLeft ();
- bool moveBlockRight ();
- bool moveBlockDown ();
- bool rotateBlock (bool);
- int dropBlock ();
- void fallingToLaying ();
- int checkFullLines ();
- bool generateFallingBlock ();
- void emptyField (void);
- void emptyField (int filled_lines, int fill_prob);
- void putBlockInField (bool erase);
- int getLinesToBottom ();
- bool isFieldEmpty (void);
- void setUseTarget (bool);
- bool getUseTarget () {
- return useTarget;
- };
+ bool moveBlockLeft ();
+ bool moveBlockRight ();
+ bool moveBlockDown ();
+ bool rotateBlock (bool);
+ int dropBlock ();
+ void fallingToLaying ();
+ int checkFullLines ();
+ bool generateFallingBlock ();
+ void emptyField (void);
+ void emptyField (int filled_lines, int fill_prob);
+ void putBlockInField (bool erase);
+ int getLinesToBottom ();
+ bool isFieldEmpty (void);
+ void setUseTarget (bool);
+ bool getUseTarget () {
+ return useTarget;
+ };
private:
- void putBlockInField (int bx, int by, int blocknr, int rotation,
- SlotType fill);
- bool blockOkHere (int x, int y, int b, int r);
- void eliminateLine (int l);
+ void putBlockInField (int bx, int by, int blocknr, int rotation,
+ SlotType fill);
+ bool blockOkHere (int x, int y, int b, int r);
+ void eliminateLine (int l);
- bool useTarget;
+ bool useTarget;
protected:
- void clearTarget ();
- void generateTarget ();
+ void clearTarget ();
+ void generateTarget ();
- Block **field;
+ Block **field;
- int blocknr;
- int rot;
- int color;
+ int blocknr;
+ int rot;
+ int color;
- int posx;
- int posy;
+ int posx;
+ int posy;
};
#endif //__blockops_h__
Modified: trunk/gnometris/blocks.cpp
==============================================================================
--- trunk/gnometris/blocks.cpp (original)
+++ trunk/gnometris/blocks.cpp Sat Nov 15 04:13:52 2008
@@ -1,3 +1,4 @@
+/* -*- mode:C++; tab-width:8; c-basic-offset:8; indent-tabs-mode:true -*- */
/*
* written by J. Marcin Gorycki <marcin gorycki intel com>
*
Modified: trunk/gnometris/blocks.h
==============================================================================
--- trunk/gnometris/blocks.h (original)
+++ trunk/gnometris/blocks.h Sat Nov 15 04:13:52 2008
@@ -1,3 +1,4 @@
+/* -*- mode:C++; tab-width:8; c-basic-offset:8; indent-tabs-mode:true -*- */
#ifndef __blocks_h__
#define __blocks_h__
Modified: trunk/gnometris/field-noclutter.cpp
==============================================================================
--- trunk/gnometris/field-noclutter.cpp (original)
+++ trunk/gnometris/field-noclutter.cpp Sat Nov 15 04:13:52 2008
@@ -1,4 +1,4 @@
-/* -*- mode:C; indent-tabs-mode:nil; tab-width:8; c-basic-offset:8 -*- */
+/* -*- mode:C++; tab-width:8; c-basic-offset:8; indent-tabs-mode:true -*- */
/*
* written by J. Marcin Gorycki <marcin gorycki intel com>
*
@@ -33,19 +33,19 @@
showGameOver(false),
backgroundImage(NULL),
backgroundImageTiled(false),
- useBGImage(false),
+ useBGImage(false),
backgroundColor(NULL)
{
- themeID = 0;
- renderer = NULL;
- rendererTheme = -1;
+ themeID = 0;
+ renderer = NULL;
+ rendererTheme = -1;
w = gtk_drawing_area_new();
g_signal_connect (w, "expose_event", G_CALLBACK (expose), this);
g_signal_connect (w, "configure_event", G_CALLBACK (configure), this);
- /* We do our own double-buffering. */
- gtk_widget_set_double_buffered(w, FALSE);
+ /* We do our own double-buffering. */
+ gtk_widget_set_double_buffered(w, FALSE);
gtk_widget_set_size_request (w, COLUMNS*190/LINES, 190);
@@ -59,35 +59,35 @@
if (background)
cairo_surface_destroy(background);
- if (renderer)
- delete renderer;
+ if (renderer)
+ delete renderer;
}
void
Field::rescaleBackground ()
{
- cairo_t *bg_cr;
- cairo_t *tmp_cr;
+ cairo_t *bg_cr;
+ cairo_t *tmp_cr;
- if (!buffer)
- return;
+ if (!buffer)
+ return;
- tmp_cr = cairo_create (buffer);
+ tmp_cr = cairo_create (buffer);
- if (background)
- cairo_surface_destroy(background);
+ if (background)
+ cairo_surface_destroy(background);
background = cairo_surface_create_similar (cairo_get_target (tmp_cr),
- CAIRO_CONTENT_COLOR,
- w->allocation.width,
- w->allocation.height);
+ CAIRO_CONTENT_COLOR,
+ w->allocation.width,
+ w->allocation.height);
- cairo_destroy (tmp_cr);
+ cairo_destroy (tmp_cr);
bg_cr = cairo_create (background);
if (useBGImage && backgroundImage) {
- gdouble xscale, yscale;
+ gdouble xscale, yscale;
cairo_matrix_t m;
/* FIXME: This doesn't handle tiled backgrounds in the obvious way. */
@@ -105,7 +105,7 @@
cairo_destroy(bg_cr);
- redraw ();
+ redraw ();
}
gboolean
@@ -130,7 +130,7 @@
cairo_destroy (cr);
- field->rescaleBackground ();
+ field->rescaleBackground ();
return TRUE;
}
@@ -138,7 +138,7 @@
void
Field::draw (gint x, gint y, gint wd, gint ht)
{
- cairo_t *cr;
+ cairo_t *cr;
cr = gdk_cairo_create (w->window);
@@ -152,7 +152,7 @@
void
Field::draw (void)
{
- draw (0, 0, width, height);
+ draw (0, 0, width, height);
}
gboolean
@@ -211,30 +211,30 @@
Field::redraw()
{
cairo_t *cr;
-
+
g_return_if_fail(buffer);
- generateTarget ();
+ generateTarget ();
- if (rendererTheme != themeID) {
+ if (rendererTheme != themeID) {
- if (renderer)
- delete renderer;
+ if (renderer)
+ delete renderer;
- renderer = rendererFactory (themeID, buffer, background, field,
- COLUMNS, LINES, width, height);
- rendererTheme = themeID;
- } else {
- renderer->setTarget (buffer);
- renderer->setBackground (background);
- renderer->data = field;
- renderer->width = COLUMNS;
- renderer->height = LINES;
- renderer->pxwidth = width;
- renderer->pxheight = height;
- }
+ renderer = rendererFactory (themeID, buffer, background, field,
+ COLUMNS, LINES, width, height);
+ rendererTheme = themeID;
+ } else {
+ renderer->setTarget (buffer);
+ renderer->setBackground (background);
+ renderer->data = field;
+ renderer->width = COLUMNS;
+ renderer->height = LINES;
+ renderer->pxwidth = width;
+ renderer->pxheight = height;
+ }
- renderer->render ();
+ renderer->render ();
cr = cairo_create(buffer);
@@ -252,23 +252,23 @@
Field::setBackground(GdkPixbuf *bgImage)//, bool tiled)
{
backgroundImage = (GdkPixbuf *) g_object_ref(bgImage);
- useBGImage = true;
-// backgroundImageTiled = tiled;
+ useBGImage = true;
+ // backgroundImageTiled = tiled;
- rescaleBackground ();
+ rescaleBackground ();
}
void
Field::setBackground(GdkColor *bgColor)
{
backgroundColor = gdk_color_copy(bgColor);
- if (backgroundImage) {
- g_object_unref (backgroundImage);
- backgroundImage = NULL;
- }
- useBGImage = false;
+ if (backgroundImage) {
+ g_object_unref (backgroundImage);
+ backgroundImage = NULL;
+ }
+ useBGImage = false;
- rescaleBackground ();
+ rescaleBackground ();
}
void
@@ -306,5 +306,5 @@
void
Field::setTheme (gint id)
{
- themeID = id;
+ themeID = id;
}
Modified: trunk/gnometris/field-noclutter.h
==============================================================================
--- trunk/gnometris/field-noclutter.h (original)
+++ trunk/gnometris/field-noclutter.h Sat Nov 15 04:13:52 2008
@@ -1,4 +1,4 @@
-/* -*- mode:C; indent-tabs-mode:nil; tab-width:8; c-basic-offset:8 -*- */
+/* -*- mode:C++; tab-width:8; c-basic-offset:8; indent-tabs-mode:true -*- */
#ifndef __field_h__
#define __field_h__
@@ -28,52 +28,53 @@
class Field:public BlockOps {
public:
- Field ();
- ~Field ();
+ Field ();
+ ~Field ();
- void setBackground (GdkPixbuf * bgImage); //, bool tiled); fixme: move tiling here.
- void setBackground (GdkColor * bgColor);
- void placeBlock (int x, int y, int bcolor, bool remove);
- void showPauseMessage ();
- void hidePauseMessage ();
- void showGameOverMessage ();
- void hideGameOverMessage ();
- void redraw ();
- void setTheme (gint id);
-
- GtkWidget *getWidget () {
- return w;
-} private:
- GtkWidget * w;
-
- int width;
- int height;
-
- cairo_surface_t *buffer;
- cairo_surface_t *background;
- cairo_surface_t **blocks;
-
- bool showPause;
- bool showGameOver;
- Renderer *renderer;
- gint rendererTheme;
-
- GdkPixbuf *backgroundImage;
- bool backgroundImageTiled;
- bool useBGImage;
- GdkColor *backgroundColor;
- gint themeID;
-
- void drawMessage (cairo_t * cr, const char *msg);
- void redrawAll ();
- void draw (gint x, gint y, gint w, gint h);
- void draw ();
- void rescaleBackground ();
-
- static gboolean configure (GtkWidget * widget, GdkEventConfigure * event,
- Field * field);
- static gboolean expose (GtkWidget * widget, GdkEventExpose * event,
- Field * field);
+ void setBackground (GdkPixbuf * bgImage); //, bool tiled); fixme: move tiling here.
+ void setBackground (GdkColor * bgColor);
+ void placeBlock (int x, int y, int bcolor, bool remove);
+ void showPauseMessage ();
+ void hidePauseMessage ();
+ void showGameOverMessage ();
+ void hideGameOverMessage ();
+ void redraw ();
+ void setTheme (gint id);
+
+ GtkWidget *getWidget () {
+ return w;
+ }
+private:
+ GtkWidget * w;
+
+ int width;
+ int height;
+
+ cairo_surface_t *buffer;
+ cairo_surface_t *background;
+ cairo_surface_t **blocks;
+
+ bool showPause;
+ bool showGameOver;
+ Renderer *renderer;
+ gint rendererTheme;
+
+ GdkPixbuf *backgroundImage;
+ bool backgroundImageTiled;
+ bool useBGImage;
+ GdkColor *backgroundColor;
+ gint themeID;
+
+ void drawMessage (cairo_t * cr, const char *msg);
+ void redrawAll ();
+ void draw (gint x, gint y, gint w, gint h);
+ void draw ();
+ void rescaleBackground ();
+
+ static gboolean configure (GtkWidget * widget, GdkEventConfigure * event,
+ Field * field);
+ static gboolean expose (GtkWidget * widget, GdkEventExpose * event,
+ Field * field);
};
Modified: trunk/gnometris/field.cpp
==============================================================================
--- trunk/gnometris/field.cpp (original)
+++ trunk/gnometris/field.cpp Sat Nov 15 04:13:52 2008
@@ -1,4 +1,4 @@
-/* -*- mode:C; indent-tabs-mode:nil; tab-width:8; c-basic-offset:8 -*- */
+/* -*- mode:C++; tab-width:8; c-basic-offset:8; indent-tabs-mode:true -*- */
/*
* written by J. Marcin Gorycki <marcin gorycki intel com>
*
@@ -33,19 +33,19 @@
showGameOver(false),
backgroundImage(NULL),
backgroundImageTiled(false),
- useBGImage(false),
+useBGImage(false),
backgroundColor(NULL)
{
- themeID = 0;
- renderer = NULL;
- rendererTheme = -1;
+ themeID = 0;
+ renderer = NULL;
+ rendererTheme = -1;
w = gtk_drawing_area_new();
g_signal_connect (w, "expose_event", G_CALLBACK (expose), this);
g_signal_connect (w, "configure_event", G_CALLBACK (configure), this);
- /* We do our own double-buffering. */
- gtk_widget_set_double_buffered(w, FALSE);
+ /* We do our own double-buffering. */
+ gtk_widget_set_double_buffered(w, FALSE);
gtk_widget_set_size_request (w, COLUMNS*190/LINES, 190);
@@ -59,35 +59,35 @@
if (background)
cairo_surface_destroy(background);
- if (renderer)
- delete renderer;
+ if (renderer)
+ delete renderer;
}
void
Field::rescaleBackground ()
{
- cairo_t *bg_cr;
- cairo_t *tmp_cr;
+ cairo_t *bg_cr;
+ cairo_t *tmp_cr;
- if (!buffer)
- return;
+ if (!buffer)
+ return;
- tmp_cr = cairo_create (buffer);
+ tmp_cr = cairo_create (buffer);
- if (background)
- cairo_surface_destroy(background);
+ if (background)
+ cairo_surface_destroy(background);
background = cairo_surface_create_similar (cairo_get_target (tmp_cr),
- CAIRO_CONTENT_COLOR,
- w->allocation.width,
- w->allocation.height);
+ CAIRO_CONTENT_COLOR,
+ w->allocation.width,
+ w->allocation.height);
- cairo_destroy (tmp_cr);
+ cairo_destroy (tmp_cr);
bg_cr = cairo_create (background);
if (useBGImage && backgroundImage) {
- gdouble xscale, yscale;
+ gdouble xscale, yscale;
cairo_matrix_t m;
/* FIXME: This doesn't handle tiled backgrounds in the obvious way. */
@@ -105,7 +105,7 @@
cairo_destroy(bg_cr);
- redraw ();
+ redraw ();
}
gboolean
@@ -130,7 +130,7 @@
cairo_destroy (cr);
- field->rescaleBackground ();
+ field->rescaleBackground ();
return TRUE;
}
@@ -138,7 +138,7 @@
void
Field::draw (gint x, gint y, gint wd, gint ht)
{
- cairo_t *cr;
+ cairo_t *cr;
cr = gdk_cairo_create (w->window);
@@ -211,30 +211,30 @@
Field::redraw()
{
cairo_t *cr;
-
+
g_return_if_fail(buffer);
- generateTarget ();
+ generateTarget ();
- if (rendererTheme != themeID) {
+ if (rendererTheme != themeID) {
- if (renderer)
- delete renderer;
+ if (renderer)
+ delete renderer;
- renderer = rendererFactory (themeID, buffer, background, field,
- COLUMNS, LINES, width, height);
- rendererTheme = themeID;
- } else {
- renderer->setTarget (buffer);
- renderer->setBackground (background);
- renderer->data = field;
- renderer->width = COLUMNS;
- renderer->height = LINES;
- renderer->pxwidth = width;
- renderer->pxheight = height;
- }
+ renderer = rendererFactory (themeID, buffer, background, field,
+ COLUMNS, LINES, width, height);
+ rendererTheme = themeID;
+ } else {
+ renderer->setTarget (buffer);
+ renderer->setBackground (background);
+ renderer->data = field;
+ renderer->width = COLUMNS;
+ renderer->height = LINES;
+ renderer->pxwidth = width;
+ renderer->pxheight = height;
+ }
- renderer->render ();
+ renderer->render ();
cr = cairo_create(buffer);
@@ -252,23 +252,23 @@
Field::setBackground(GdkPixbuf *bgImage)//, bool tiled)
{
backgroundImage = (GdkPixbuf *) g_object_ref(bgImage);
- useBGImage = true;
+ useBGImage = true;
// backgroundImageTiled = tiled;
- rescaleBackground ();
+ rescaleBackground ();
}
void
Field::setBackground(GdkColor *bgColor)
{
backgroundColor = gdk_color_copy(bgColor);
- if (backgroundImage) {
- g_object_unref (backgroundImage);
- backgroundImage = NULL;
- }
- useBGImage = false;
+ if (backgroundImage) {
+ g_object_unref (backgroundImage);
+ backgroundImage = NULL;
+ }
+ useBGImage = false;
- rescaleBackground ();
+ rescaleBackground ();
}
void
@@ -306,5 +306,5 @@
void
Field::setTheme (gint id)
{
- themeID = id;
+ themeID = id;
}
Modified: trunk/gnometris/field.h
==============================================================================
--- trunk/gnometris/field.h (original)
+++ trunk/gnometris/field.h Sat Nov 15 04:13:52 2008
@@ -1,4 +1,4 @@
-/* -*- mode:C; indent-tabs-mode:nil; tab-width:8; c-basic-offset:8 -*- */
+/* -*- mode:C++; tab-width:8; c-basic-offset:8; indent-tabs-mode:true -*- */
#ifndef __field_h__
#define __field_h__
@@ -28,52 +28,53 @@
class Field:public BlockOps {
public:
- Field ();
- ~Field ();
+ Field ();
+ ~Field ();
- void setBackground (GdkPixbuf * bgImage); //, bool tiled); fixme: move tiling here.
- void setBackground (GdkColor * bgColor);
- void placeBlock (int x, int y, int bcolor, bool remove);
- void showPauseMessage ();
- void hidePauseMessage ();
- void showGameOverMessage ();
- void hideGameOverMessage ();
- void redraw ();
- void setTheme (gint id);
-
- GtkWidget *getWidget () {
- return w;
-} private:
- GtkWidget * w;
-
- int width;
- int height;
-
- cairo_surface_t *buffer;
- cairo_surface_t *background;
- cairo_surface_t **blocks;
-
- bool showPause;
- bool showGameOver;
- Renderer *renderer;
- gint rendererTheme;
-
- GdkPixbuf *backgroundImage;
- bool backgroundImageTiled;
- bool useBGImage;
- GdkColor *backgroundColor;
- gint themeID;
-
- void drawMessage (cairo_t * cr, const char *msg);
- void redrawAll ();
- void draw (gint x, gint y, gint w, gint h);
- void draw ();
- void rescaleBackground ();
-
- static gboolean configure (GtkWidget * widget, GdkEventConfigure * event,
- Field * field);
- static gboolean expose (GtkWidget * widget, GdkEventExpose * event,
- Field * field);
+ void setBackground (GdkPixbuf * bgImage); //, bool tiled); fixme: move tiling here.
+ void setBackground (GdkColor * bgColor);
+ void placeBlock (int x, int y, int bcolor, bool remove);
+ void showPauseMessage ();
+ void hidePauseMessage ();
+ void showGameOverMessage ();
+ void hideGameOverMessage ();
+ void redraw ();
+ void setTheme (gint id);
+
+ GtkWidget *getWidget () {
+ return w;
+ }
+private:
+ GtkWidget * w;
+
+ int width;
+ int height;
+
+ cairo_surface_t *buffer;
+ cairo_surface_t *background;
+ cairo_surface_t **blocks;
+
+ bool showPause;
+ bool showGameOver;
+ Renderer *renderer;
+ gint rendererTheme;
+
+ GdkPixbuf *backgroundImage;
+ bool backgroundImageTiled;
+ bool useBGImage;
+ GdkColor *backgroundColor;
+ gint themeID;
+
+ void drawMessage (cairo_t * cr, const char *msg);
+ void redrawAll ();
+ void draw (gint x, gint y, gint w, gint h);
+ void draw ();
+ void rescaleBackground ();
+
+ static gboolean configure (GtkWidget * widget, GdkEventConfigure * event,
+ Field * field);
+ static gboolean expose (GtkWidget * widget, GdkEventExpose * event,
+ Field * field);
};
Modified: trunk/gnometris/highscores.cpp
==============================================================================
--- trunk/gnometris/highscores.cpp (original)
+++ trunk/gnometris/highscores.cpp Sat Nov 15 04:13:52 2008
@@ -1,3 +1,4 @@
+/* -*- mode:C++; tab-width:8; c-basic-offset:8; indent-tabs-mode:true -*- */
/* highscores.cpp - wrap the high score dialog.
*
* Copyright 2005 (c) Callum McKenzie
@@ -25,32 +26,32 @@
#include "highscores.h"
static const GamesScoresDescription scoredesc = {NULL, NULL,
- "gnometris",
- GAMES_SCORES_STYLE_PLAIN_DESCENDING};
+ "gnometris",
+ GAMES_SCORES_STYLE_PLAIN_DESCENDING};
HighScores::HighScores ()
{
- highscores = games_scores_new (&scoredesc);
+ highscores = games_scores_new (&scoredesc);
- dialog = NULL;
+ dialog = NULL;
}
gint HighScores::add (gint score)
{
- GamesScoreValue value;
+ GamesScoreValue value;
- value.plain = score;
+ value.plain = score;
- return games_scores_add_score (highscores, value);
+ return games_scores_add_score (highscores, value);
}
void HighScores::show (GtkWindow *parent_window, gint highlight)
{
- if (!dialog)
- dialog = games_scores_dialog_new (parent_window, highscores, _("Gnometris Scores"));
+ if (!dialog)
+ dialog = games_scores_dialog_new (parent_window, highscores, _("Gnometris Scores"));
- games_scores_dialog_set_hilight (GAMES_SCORES_DIALOG (dialog), highlight);
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_hide (dialog);
+ games_scores_dialog_set_hilight (GAMES_SCORES_DIALOG (dialog), highlight);
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_hide (dialog);
}
Modified: trunk/gnometris/highscores.h
==============================================================================
--- trunk/gnometris/highscores.h (original)
+++ trunk/gnometris/highscores.h Sat Nov 15 04:13:52 2008
@@ -1,3 +1,4 @@
+/* -*- mode:C++; tab-width:8; c-basic-offset:8; indent-tabs-mode:true -*- */
/* highscores.cpp - wrap the high score dialog.
*
* Copyright 2005 (c) Callum McKenzie
@@ -27,14 +28,14 @@
class HighScores {
protected:
- GtkWidget * dialog;
- GamesScores *highscores;
+ GtkWidget * dialog;
+ GamesScores *highscores;
public:
- HighScores ();
+ HighScores ();
- gint add (gint score);
- void show (GtkWindow *parent_window, gint highlight = 0);
+ gint add (gint score);
+ void show (GtkWindow *parent_window, gint highlight = 0);
};
#endif
Modified: trunk/gnometris/main.cpp
==============================================================================
--- trunk/gnometris/main.cpp (original)
+++ trunk/gnometris/main.cpp Sat Nov 15 04:13:52 2008
@@ -1,3 +1,4 @@
+/* -*- mode:C++; tab-width:8; c-basic-offset:8; indent-tabs-mode:true -*- */
/*
* written by J. Marcin Gorycki <marcin gorycki intel com>
*
@@ -25,6 +26,10 @@
#include <libgames-support/games-conf.h>
#include <libgames-support/games-runtime.h>
+#ifdef HAVE_CLUTTER
+#include <clutter-gtk/gtk-clutter-embed.h>
+#endif
+
#include "tetris.h"
int
@@ -55,6 +60,9 @@
GOptionContext *context = g_option_context_new (NULL);
g_option_context_add_group (context, gtk_get_option_group (TRUE));
+#ifdef HAVE_CLUTTER
+ g_option_context_add_group (context, clutter_get_option_group_without_init ());
+#endif
g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE);
games_sound_add_option_group (context);
@@ -74,6 +82,14 @@
Tetris *t = new Tetris(cmdlineLevel);
+#ifdef HAVE_CLUTTER
+ if (gtk_clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS ) {
+ g_printerr ("Failed to initialise clutter: %s\n", error->message);
+ g_error_free (error);
+ return 1;
+ }
+#endif
+
gtk_main();
delete t;
Modified: trunk/gnometris/preview.h
==============================================================================
--- trunk/gnometris/preview.h (original)
+++ trunk/gnometris/preview.h Sat Nov 15 04:13:52 2008
@@ -1,3 +1,4 @@
+/* -*- mode:C++; tab-width:8; c-basic-offset:8; indent-tabs-mode:true -*- */
#ifndef __preview_h__
#define __preview_h__
@@ -27,35 +28,37 @@
class Preview {
public:
- Preview ();
- ~Preview ();
+ Preview ();
+ ~Preview ();
- GtkWidget *getWidget () {
- return w;
- } void enable (bool enable);
- void previewBlock (int bnr, int brot, int bcolor);
- void setTheme (int id);
+ GtkWidget *getWidget () {
+ return w;
+ }
+
+ void enable (bool enable);
+ void previewBlock (int bnr, int brot, int bcolor);
+ void setTheme (int id);
private:
- GtkWidget * w;
- gint width;
- gint height;
+ GtkWidget * w;
+ gint width;
+ gint height;
- int blocknr;
- int blockrot;
- int blockcolor;
+ int blocknr;
+ int blockrot;
+ int blockcolor;
- bool enabled;
+ bool enabled;
- int themeID;
- cairo_surface_t *background;
+ int themeID;
+ cairo_surface_t *background;
- static gint configure (GtkWidget * widget, GdkEventConfigure * event,
- Preview * preview);
- static gint expose (GtkWidget * widget, GdkEventExpose * event,
- Preview * preview);
+ static gint configure (GtkWidget * widget, GdkEventConfigure * event,
+ Preview * preview);
+ static gint expose (GtkWidget * widget, GdkEventExpose * event,
+ Preview * preview);
- Block **blocks;
+Block **blocks;
};
#endif //__preview_h__
Modified: trunk/gnometris/renderer.cpp
==============================================================================
--- trunk/gnometris/renderer.cpp (original)
+++ trunk/gnometris/renderer.cpp Sat Nov 15 04:13:52 2008
@@ -1,4 +1,4 @@
-/* -*- mode:C; indent-tabs-mode:nil; tab-width:8; c-basic-offset:8 -*- */
+/* -*- mode:C++; tab-width:8; c-basic-offset:8; indent-tabs-mode:true -*- */
/*
* written by Callum McKenzie <callum spooky-possum org>
*
@@ -25,47 +25,47 @@
#include "renderer.h"
const ThemeTableEntry ThemeTable[] = {{N_("Plain"), "plain"},
- {N_("Joined"), "joined"},
- {N_("Tango Flat"), "tangoflat"},
- {N_("Tango Shaded"), "tangoshaded"},
- {NULL, NULL}};
+ {N_("Joined"), "joined"},
+ {N_("Tango Flat"), "tangoflat"},
+ {N_("Tango Shaded"), "tangoshaded"},
+ {NULL, NULL}};
gint themeNameToNumber (const gchar *id)
{
- int i;
- const ThemeTableEntry *t;
+ int i;
+ const ThemeTableEntry *t;
- if (id == NULL)
- return 0;
+ if (id == NULL)
+ return 0;
- t = ThemeTable;
- i = 0;
- while (t->id) {
- if (strcmp (t->id, id) == 0)
- return i;
- t++;
- i++;
- }
+ t = ThemeTable;
+ i = 0;
+ while (t->id) {
+ if (strcmp (t->id, id) == 0)
+ return i;
+ t++;
+ i++;
+ }
- return 0;
+ return 0;
}
Renderer * rendererFactory (gint id, cairo_surface_t *dst,
- cairo_surface_t *bg, Block **src, int w,
- int h, int pxw, int pxh)
+ cairo_surface_t *bg, Block **src, int w,
+ int h, int pxw, int pxh)
{
- switch (id) {
- case 3:
- return new TangoBlock (dst, bg, src, w, h, pxw, pxh, TRUE);
- case 2:
- return new TangoBlock (dst, bg, src, w, h, pxw, pxh, FALSE);
- case 1:
- return new JoinedUp (dst, bg, src, w, h, pxw, pxh);
- case 0:
- default:
- return new Renderer (dst, bg, src, w, h, pxw, pxh);
- }
+ switch (id) {
+ case 3:
+ return new TangoBlock (dst, bg, src, w, h, pxw, pxh, TRUE);
+ case 2:
+ return new TangoBlock (dst, bg, src, w, h, pxw, pxh, FALSE);
+ case 1:
+ return new JoinedUp (dst, bg, src, w, h, pxw, pxh);
+ case 0:
+ default:
+ return new Renderer (dst, bg, src, w, h, pxw, pxh);
+ }
}
/* The Renderer class is a basic drawing class that is structured to
@@ -83,39 +83,39 @@
assumptions. */
Renderer::Renderer (cairo_surface_t *dst, cairo_surface_t *bg, Block **src,
- int w, int h, int pxw, int pxh)
+ int w, int h, int pxw, int pxh)
{
- target = cairo_surface_reference (dst);
- background = cairo_surface_reference (bg);
- data = src;
- width = w;
- height = h;
- pxwidth = pxw;
- pxheight = pxh;
+ target = cairo_surface_reference (dst);
+ background = cairo_surface_reference (bg);
+ data = src;
+ width = w;
+ height = h;
+ pxwidth = pxw;
+ pxheight = pxh;
}
Renderer::~Renderer ()
{
- cairo_surface_destroy (target);
- cairo_surface_destroy (background);
+ cairo_surface_destroy (target);
+ cairo_surface_destroy (background);
}
void Renderer::setTarget (cairo_surface_t * dst)
{
- cairo_surface_destroy (target);
- target = cairo_surface_reference (dst);
+ cairo_surface_destroy (target);
+ target = cairo_surface_reference (dst);
}
void Renderer::setBackground (cairo_surface_t *bg)
{
- cairo_surface_destroy (background);
- background = cairo_surface_reference (bg);
+ cairo_surface_destroy (background);
+ background = cairo_surface_reference (bg);
}
void Renderer::drawCell (cairo_t *cr, gint x, gint y)
{
- int i;
- const gdouble colours[7][3] = {{1.0, 0.0, 0.0},
+ int i;
+ const gdouble colours[7][3] = {{1.0, 0.0, 0.0},
{0.0, 1.0, 0.0},
{0.0, 0.0, 1.0},
{1.0, 1.0, 1.0},
@@ -124,18 +124,18 @@
{0.0, 1.0, 1.0}};
if (data[x][y].what == EMPTY)
- return;
+ return;
- if (data[x][y].what == TARGET) {
- cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.3);
- } else {
- i = data[x][y].color;
- i = CLAMP (i, 0, 6);
-
- cairo_set_source_rgb(cr, colours[i][0],
- colours[i][1],
- colours[i][2]);
- }
+ if (data[x][y].what == TARGET) {
+ cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.3);
+ } else {
+ i = data[x][y].color;
+ i = CLAMP (i, 0, 6);
+
+ cairo_set_source_rgb(cr, colours[i][0],
+ colours[i][1],
+ colours[i][2]);
+ }
cairo_rectangle(cr, x+0.05, y+0.05,
0.9, 0.9);
@@ -144,33 +144,33 @@
void Renderer::drawBackground (cairo_t *cr)
{
- cairo_set_source_surface (cr, background, 0, 0);
- cairo_paint (cr);
+ cairo_set_source_surface (cr, background, 0, 0);
+ cairo_paint (cr);
}
void Renderer::drawForeground (cairo_t *cr)
{
- int x, y;
+ int x, y;
- cairo_scale(cr, 1.0 * pxwidth / width, 1.0 * pxheight / height);
-
- for (y = 0; y<height; y++) {
- for (x = 0; x<width; x++) {
- drawCell (cr, x, y);
- }
- }
+ cairo_scale(cr, 1.0 * pxwidth / width, 1.0 * pxheight / height);
+
+ for (y = 0; y<height; y++) {
+ for (x = 0; x<width; x++) {
+ drawCell (cr, x, y);
+ }
+ }
}
void Renderer::render ()
{
- cairo_t *cr;
+ cairo_t *cr;
- cr = cairo_create (target);
+ cr = cairo_create (target);
- drawBackground (cr);
- drawForeground (cr);
+ drawBackground (cr);
+ drawForeground (cr);
- cairo_destroy (cr);
+ cairo_destroy (cr);
}
/*--------------------------------------------------------*/
@@ -178,188 +178,188 @@
void JoinedUp::drawInnerCorner (cairo_t *cr)
{
border = 0.2;
- cairo_move_to (cr, 0, 0);
- cairo_line_to (cr, border, border);
- cairo_line_to (cr, border, 0);
- cairo_move_to (cr, border, border);
- cairo_line_to (cr, 0, border);
- cairo_stroke (cr);
+ cairo_move_to (cr, 0, 0);
+ cairo_line_to (cr, border, border);
+ cairo_line_to (cr, border, 0);
+ cairo_move_to (cr, border, border);
+ cairo_line_to (cr, 0, border);
+ cairo_stroke (cr);
}
void JoinedUp::drawOuterCorner (cairo_t *cr)
{
border = 0.2;
- cairo_move_to (cr, 0, 0.5);
- cairo_line_to (cr, 0, 0);
- cairo_line_to (cr, 0.5, 0);
- cairo_move_to (cr, 0, 0);
- cairo_line_to (cr, border, border);
- cairo_line_to (cr, 0.5, border);
- cairo_move_to (cr, border, border);
- cairo_line_to (cr, border, 0.5);
- cairo_stroke (cr);
+ cairo_move_to (cr, 0, 0.5);
+ cairo_line_to (cr, 0, 0);
+ cairo_line_to (cr, 0.5, 0);
+ cairo_move_to (cr, 0, 0);
+ cairo_line_to (cr, border, border);
+ cairo_line_to (cr, 0.5, border);
+ cairo_move_to (cr, border, border);
+ cairo_line_to (cr, border, 0.5);
+ cairo_stroke (cr);
}
void JoinedUp::drawHEdge (cairo_t *cr)
{
border = 0.2;
- cairo_move_to (cr, 0, 0);
- cairo_line_to (cr, 0.5, 0);
- cairo_move_to (cr, 0, border);
- cairo_line_to (cr, 0.5, border);
- cairo_stroke (cr);
+ cairo_move_to (cr, 0, 0);
+ cairo_line_to (cr, 0.5, 0);
+ cairo_move_to (cr, 0, border);
+ cairo_line_to (cr, 0.5, border);
+ cairo_stroke (cr);
}
void JoinedUp::drawVEdge (cairo_t *cr)
{
border = 0.2;
- cairo_move_to (cr, 0, 0);
- cairo_line_to (cr, 0, 0.5);
- cairo_move_to (cr, border, 0);
- cairo_line_to (cr, border, 0.5);
- cairo_stroke (cr);
+ cairo_move_to (cr, 0, 0);
+ cairo_line_to (cr, 0, 0.5);
+ cairo_move_to (cr, border, 0);
+ cairo_line_to (cr, border, 0.5);
+ cairo_stroke (cr);
}
void JoinedUp::drawCell (cairo_t *cr, gint x, gint y)
{
- int i, m, n;
- int segments[4];
- double xofs;
- double yofs;
- int c;
- int neighbours[8];
- static const int formtable[4][8] = {{0, 7, 0, 7, 4, 9, 4, 8},
- {1, 4, 1, 4, 5, 10, 5, 8},
- {2, 6, 2, 6, 7, 11, 7, 8},
- {3, 5, 3, 5, 6, 12, 6, 8}};
- static const gdouble colours[7][3] = {{1.0, 0.0, 0.0},
- {0.1, 0.8, 0.1},
- {0.1, 0.1, 0.8},
- {1.0, 1.0, 1.0},
- {1.0, 1.0, 0.0},
- {0.8, 0.1, 0.8},
- {0.0, 1.0, 1.0}};
- static const int neighbourmap[8][2] = {{-1, -1}, {0, -1}, {+1, -1},
- {-1, 0}, {+1, 0},
- {-1, +1}, {0, +1}, {+1, +1}};
+ int i, m, n;
+ int segments[4];
+ double xofs;
+ double yofs;
+ int c;
+ int neighbours[8];
+ static const int formtable[4][8] = {{0, 7, 0, 7, 4, 9, 4, 8},
+ {1, 4, 1, 4, 5, 10, 5, 8},
+ {2, 6, 2, 6, 7, 11, 7, 8},
+ {3, 5, 3, 5, 6, 12, 6, 8}};
+ static const gdouble colours[7][3] = {{1.0, 0.0, 0.0},
+ {0.1, 0.8, 0.1},
+ {0.1, 0.1, 0.8},
+ {1.0, 1.0, 1.0},
+ {1.0, 1.0, 0.0},
+ {0.8, 0.1, 0.8},
+ {0.0, 1.0, 1.0}};
+ static const int neighbourmap[8][2] = {{-1, -1}, {0, -1}, {+1, -1},
+ {-1, 0}, {+1, 0},
+ {-1, +1}, {0, +1}, {+1, +1}};
if (data[x][y].what == EMPTY)
- return;
-
- i = data[x][y].color;
+ return;
+
+ i = data[x][y].color;
i = CLAMP (i, 0, 6);
-
- cairo_save (cr);
- cairo_translate (cr, x, y);
-
- cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
- cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
- cairo_set_line_width (cr, 0.05);
-
- if (data[x][y].what == TARGET) {
- cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0);
- } else {
- cairo_set_source_rgb (cr, colours[i][0],
- colours[i][1],
- colours[i][2]);
- }
- cairo_rectangle (cr, -0.025, -0.025, 1.025, 1.025);
- cairo_fill (cr);
- cairo_set_source_rgb (cr, 0.5, 0.5, 0.5);
-
- // Enumerate the neighbours.
- c = data[x][y].color;
- for (i=0; i<8; i++) {
- m = x + neighbourmap[i][0];
- n = y + neighbourmap[i][1];
- if ((m < 0) || (n < 0) || (m >= width) || (n >= height))
- neighbours[i] = 0;
- else
- neighbours[i] = ((data[m][n].what != EMPTY) &&
- (data[m][n].color == c)) ? 1 : 0;
- }
-
- // Sort out which quadrant of the square is drawn in what way.
- segments[0] = formtable [0][neighbours[3]*4 +
- neighbours[0]*2 +
- neighbours[1]];
- segments[1] = formtable [1][neighbours[1]*4 +
- neighbours[2]*2 +
- neighbours[4]];
- segments[2] = formtable [2][neighbours[6]*4 +
- neighbours[5]*2 +
- neighbours[3]];
- segments[3] = formtable [3][neighbours[4]*4 +
- neighbours[7]*2 +
- neighbours[6]];
-
- // Finally: do the actual drawing.
- for (i=0; i<4; i++) {
- cairo_save (cr);
- xofs = 0.5*(i % 2);
- yofs = 0.5*(i / 2);
- cairo_translate (cr, xofs, yofs);
- switch (segments[i]) {
- case 0:
- drawOuterCorner (cr);
- break;
- case 1:
- cairo_scale (cr, -1.0, 1.0);
- cairo_translate (cr, -0.5, 0);
- drawOuterCorner (cr);
- break;
- case 2:
- cairo_scale (cr, 1.0, -1.0);
- cairo_translate (cr, 0, -0.5);
- drawOuterCorner (cr);
- break;
- case 3:
- cairo_scale (cr, -1.0, -1.0);
- cairo_translate (cr, -0.5, -0.5);
- drawOuterCorner (cr);
- break;
- case 4:
- drawHEdge (cr);
- break;
- case 5:
- cairo_scale (cr, -1.0, 1.0);
- cairo_translate (cr, -0.5, 0);
- drawVEdge (cr);
- break;
- case 6:
- cairo_scale (cr, 1.0, -1.0);
- cairo_translate (cr, 0, -0.5);
- drawHEdge (cr);
- break;
- case 7:
- drawVEdge (cr);
- break;
-
- case 8:
- break;
- case 9:
- drawInnerCorner (cr);
- break;
- case 10:
- cairo_scale (cr, -1.0, 1.0);
- cairo_translate (cr, -0.5, 0);
- drawInnerCorner (cr);
- break;
- case 11:
- cairo_scale (cr, 1.0, -1.0);
- cairo_translate (cr, 0, -0.5);
- drawInnerCorner (cr);
- break;
- case 12:
- cairo_scale (cr, -1.0, -1.0);
- cairo_translate (cr, -0.5, -0.5);
- drawInnerCorner (cr);
- break;
- }
- cairo_restore (cr);
- }
- cairo_restore (cr);
+ cairo_save (cr);
+ cairo_translate (cr, x, y);
+
+ cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
+ cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
+ cairo_set_line_width (cr, 0.05);
+
+ if (data[x][y].what == TARGET) {
+ cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0);
+ } else {
+ cairo_set_source_rgb (cr, colours[i][0],
+ colours[i][1],
+ colours[i][2]);
+ }
+ cairo_rectangle (cr, -0.025, -0.025, 1.025, 1.025);
+ cairo_fill (cr);
+ cairo_set_source_rgb (cr, 0.5, 0.5, 0.5);
+
+ // Enumerate the neighbours.
+ c = data[x][y].color;
+ for (i=0; i<8; i++) {
+ m = x + neighbourmap[i][0];
+ n = y + neighbourmap[i][1];
+ if ((m < 0) || (n < 0) || (m >= width) || (n >= height))
+ neighbours[i] = 0;
+ else
+ neighbours[i] = ((data[m][n].what != EMPTY) &&
+ (data[m][n].color == c)) ? 1 : 0;
+ }
+
+ // Sort out which quadrant of the square is drawn in what way.
+ segments[0] = formtable [0][neighbours[3]*4 +
+ neighbours[0]*2 +
+ neighbours[1]];
+ segments[1] = formtable [1][neighbours[1]*4 +
+ neighbours[2]*2 +
+ neighbours[4]];
+ segments[2] = formtable [2][neighbours[6]*4 +
+ neighbours[5]*2 +
+ neighbours[3]];
+ segments[3] = formtable [3][neighbours[4]*4 +
+ neighbours[7]*2 +
+ neighbours[6]];
+
+ // Finally: do the actual drawing.
+ for (i=0; i<4; i++) {
+ cairo_save (cr);
+ xofs = 0.5*(i % 2);
+ yofs = 0.5*(i / 2);
+ cairo_translate (cr, xofs, yofs);
+ switch (segments[i]) {
+ case 0:
+ drawOuterCorner (cr);
+ break;
+ case 1:
+ cairo_scale (cr, -1.0, 1.0);
+ cairo_translate (cr, -0.5, 0);
+ drawOuterCorner (cr);
+ break;
+ case 2:
+ cairo_scale (cr, 1.0, -1.0);
+ cairo_translate (cr, 0, -0.5);
+ drawOuterCorner (cr);
+ break;
+ case 3:
+ cairo_scale (cr, -1.0, -1.0);
+ cairo_translate (cr, -0.5, -0.5);
+ drawOuterCorner (cr);
+ break;
+ case 4:
+ drawHEdge (cr);
+ break;
+ case 5:
+ cairo_scale (cr, -1.0, 1.0);
+ cairo_translate (cr, -0.5, 0);
+ drawVEdge (cr);
+ break;
+ case 6:
+ cairo_scale (cr, 1.0, -1.0);
+ cairo_translate (cr, 0, -0.5);
+ drawHEdge (cr);
+ break;
+ case 7:
+ drawVEdge (cr);
+ break;
+
+ case 8:
+ break;
+ case 9:
+ drawInnerCorner (cr);
+ break;
+ case 10:
+ cairo_scale (cr, -1.0, 1.0);
+ cairo_translate (cr, -0.5, 0);
+ drawInnerCorner (cr);
+ break;
+ case 11:
+ cairo_scale (cr, 1.0, -1.0);
+ cairo_translate (cr, 0, -0.5);
+ drawInnerCorner (cr);
+ break;
+ case 12:
+ cairo_scale (cr, -1.0, -1.0);
+ cairo_translate (cr, -0.5, -0.5);
+ drawInnerCorner (cr);
+ break;
+ }
+ cairo_restore (cr);
+ }
+
+ cairo_restore (cr);
}
/*--------------------------------------------------------*/
@@ -367,143 +367,143 @@
TangoBlock::TangoBlock (cairo_surface_t * dst, cairo_surface_t * bg, Block ** src,
int w, int h, int pxw, int pxh, gboolean grad) : Renderer (dst, bg, src, w, h, pxw, pxh)
{
- usegrads = grad;
+ usegrads = grad;
}
void TangoBlock::drawCell (cairo_t *cr, gint x, gint y)
{
- int i;
- cairo_pattern_t *pat = NULL;
- /* the following garbage is derived from the official tango style guide */
- const gdouble colours[8][3][3] = {
- {{0.93725490196078431, 0.16078431372549021, 0.16078431372549021},
- {0.8, 0.0, 0.0},
- {0.64313725490196083, 0.0, 0.0}}, /* red */
-
- {{0.54117647058823526, 0.88627450980392153, 0.20392156862745098},
- {0.45098039215686275, 0.82352941176470584, 0.086274509803921567},
- {0.30588235294117649, 0.60392156862745094, 0.023529411764705882}}, /* green */
-
- {{0.44705882352941179, 0.62352941176470589, 0.81176470588235294},
- {0.20392156862745098, 0.396078431372549, 0.64313725490196083},
- {0.12549019607843137, 0.29019607843137257, 0.52941176470588236}}, /* blue */
-
- {{0.93333333333333335, 0.93333333333333335, 0.92549019607843142},
- {0.82745098039215681, 0.84313725490196079, 0.81176470588235294},
- {0.72941176470588232, 0.74117647058823533, 0.71372549019607845}}, /* white */
-
- {{0.9882352941176471, 0.9137254901960784, 0.30980392156862746},
- {0.92941176470588238, 0.83137254901960789, 0.0},
- {0.7686274509803922, 0.62745098039215685, 0.0}}, /* yellow */
-
- {{0.67843137254901964, 0.49803921568627452, 0.6588235294117647},
- {0.45882352941176469, 0.31372549019607843, 0.4823529411764706},
- {0.36078431372549019, 0.20784313725490197, 0.4}}, /* purple */
-
- {{0.9882352941176471, 0.68627450980392157, 0.24313725490196078},
- {0.96078431372549022, 0.47450980392156861, 0.0},
- {0.80784313725490198, 0.36078431372549019, 0.0}}, /* orange (replacing cyan) */
-
- {{0.33, 0.34, 0.32},
- {0.18, 0.2, 0.21},
- {0.10, 0.12, 0.13}} /* grey */
- };
-
- if (data[x][y].what == EMPTY)
- return;
-
- if (data[x][y].what == TARGET) {
- i = 7;
- } else {
- i = data[x][y].color;
- i = CLAMP (i, 0, 6);
- }
-
- if (usegrads) {
- pat = cairo_pattern_create_linear (x+0.35, y, x+0.55, y+0.9);
- cairo_pattern_add_color_stop_rgb (pat, 0.0, colours[i][0][0],
- colours[i][0][1],
- colours[i][0][2]);
- cairo_pattern_add_color_stop_rgb (pat, 1.0, colours[i][1][0],
- colours[i][1][1],
- colours[i][1][2]);
- cairo_set_source (cr, pat);
- } else {
- cairo_set_source_rgb (cr, colours[i][0][0],
- colours[i][0][1],
- colours[i][0][2]);
- }
-
- drawRoundedRectangle (cr, x+0.05, y+0.05, 0.9, 0.9, 0.2);
- cairo_fill_preserve (cr); /* fill with shaded gradient */
-
-
- if (usegrads)
- cairo_pattern_destroy(pat);
- cairo_set_source_rgb(cr, colours[i][2][0],
- colours[i][2][1],
- colours[i][2][2]);
-
- cairo_set_line_width (cr, 0.1);
- cairo_stroke (cr); /* add darker outline */
-
- drawRoundedRectangle (cr, x+0.15, y+0.15, 0.7, 0.7, 0.08);
- if (data[x][y].what != TARGET) {
- if (usegrads) {
- pat = cairo_pattern_create_linear (x-0.3, y-0.3, x+0.8, y+0.8);
- switch (i) { /* yellow and white blocks need a brighter highlight */
- case 3:
- case 4:
- cairo_pattern_add_color_stop_rgba (pat, 0.0, 1.0,
- 1.0,
- 1.0,
- 1.0);
- cairo_pattern_add_color_stop_rgba (pat, 1.0, 1.0,
- 1.0,
- 1.0,
- 0.0);
- break;
- default:
- cairo_pattern_add_color_stop_rgba (pat, 0.0, 0.9295,
- 0.9295,
- 0.9295,
- 1.0);
- cairo_pattern_add_color_stop_rgba (pat, 1.0, 0.9295,
- 0.9295,
- 0.9295,
- 0.0);
- break;
- }
- cairo_set_source (cr, pat);
- } else {
- cairo_set_source_rgba (cr, 1.0,
- 1.0,
- 1.0,
- 0.35);
- }
- } else { /* black preview block, use a much weaker highlight */
- cairo_set_source_rgba (cr, 1.0,
- 1.0,
- 1.0,
- 0.15);
- }
- cairo_stroke (cr); /* add inner edge highlight */
-
- if (usegrads && (data[x][y].what != TARGET))
- cairo_pattern_destroy (pat);
+ int i;
+ cairo_pattern_t *pat = NULL;
+ /* the following garbage is derived from the official tango style guide */
+ const gdouble colours[8][3][3] = {
+ {{0.93725490196078431, 0.16078431372549021, 0.16078431372549021},
+ {0.8, 0.0, 0.0},
+ {0.64313725490196083, 0.0, 0.0}}, /* red */
+
+ {{0.54117647058823526, 0.88627450980392153, 0.20392156862745098},
+ {0.45098039215686275, 0.82352941176470584, 0.086274509803921567},
+ {0.30588235294117649, 0.60392156862745094, 0.023529411764705882}}, /* green */
+
+ {{0.44705882352941179, 0.62352941176470589, 0.81176470588235294},
+ {0.20392156862745098, 0.396078431372549, 0.64313725490196083},
+ {0.12549019607843137, 0.29019607843137257, 0.52941176470588236}}, /* blue */
+
+ {{0.93333333333333335, 0.93333333333333335, 0.92549019607843142},
+ {0.82745098039215681, 0.84313725490196079, 0.81176470588235294},
+ {0.72941176470588232, 0.74117647058823533, 0.71372549019607845}}, /* white */
+
+ {{0.9882352941176471, 0.9137254901960784, 0.30980392156862746},
+ {0.92941176470588238, 0.83137254901960789, 0.0},
+ {0.7686274509803922, 0.62745098039215685, 0.0}}, /* yellow */
+
+ {{0.67843137254901964, 0.49803921568627452, 0.6588235294117647},
+ {0.45882352941176469, 0.31372549019607843, 0.4823529411764706},
+ {0.36078431372549019, 0.20784313725490197, 0.4}}, /* purple */
+
+ {{0.9882352941176471, 0.68627450980392157, 0.24313725490196078},
+ {0.96078431372549022, 0.47450980392156861, 0.0},
+ {0.80784313725490198, 0.36078431372549019, 0.0}}, /* orange (replacing cyan) */
+
+ {{0.33, 0.34, 0.32},
+ {0.18, 0.2, 0.21},
+ {0.10, 0.12, 0.13}} /* grey */
+ };
+
+ if (data[x][y].what == EMPTY)
+ return;
+
+ if (data[x][y].what == TARGET) {
+ i = 7;
+ } else {
+ i = data[x][y].color;
+ i = CLAMP (i, 0, 6);
+ }
+
+ if (usegrads) {
+ pat = cairo_pattern_create_linear (x+0.35, y, x+0.55, y+0.9);
+ cairo_pattern_add_color_stop_rgb (pat, 0.0, colours[i][0][0],
+ colours[i][0][1],
+ colours[i][0][2]);
+ cairo_pattern_add_color_stop_rgb (pat, 1.0, colours[i][1][0],
+ colours[i][1][1],
+ colours[i][1][2]);
+ cairo_set_source (cr, pat);
+ } else {
+ cairo_set_source_rgb (cr, colours[i][0][0],
+ colours[i][0][1],
+ colours[i][0][2]);
+ }
+
+ drawRoundedRectangle (cr, x+0.05, y+0.05, 0.9, 0.9, 0.2);
+ cairo_fill_preserve (cr); /* fill with shaded gradient */
+
+
+ if (usegrads)
+ cairo_pattern_destroy(pat);
+ cairo_set_source_rgb(cr, colours[i][2][0],
+ colours[i][2][1],
+ colours[i][2][2]);
+
+ cairo_set_line_width (cr, 0.1);
+ cairo_stroke (cr); /* add darker outline */
+
+ drawRoundedRectangle (cr, x+0.15, y+0.15, 0.7, 0.7, 0.08);
+ if (data[x][y].what != TARGET) {
+ if (usegrads) {
+ pat = cairo_pattern_create_linear (x-0.3, y-0.3, x+0.8, y+0.8);
+ switch (i) { /* yellow and white blocks need a brighter highlight */
+ case 3:
+ case 4:
+ cairo_pattern_add_color_stop_rgba (pat, 0.0, 1.0,
+ 1.0,
+ 1.0,
+ 1.0);
+ cairo_pattern_add_color_stop_rgba (pat, 1.0, 1.0,
+ 1.0,
+ 1.0,
+ 0.0);
+ break;
+ default:
+ cairo_pattern_add_color_stop_rgba (pat, 0.0, 0.9295,
+ 0.9295,
+ 0.9295,
+ 1.0);
+ cairo_pattern_add_color_stop_rgba (pat, 1.0, 0.9295,
+ 0.9295,
+ 0.9295,
+ 0.0);
+ break;
+ }
+ cairo_set_source (cr, pat);
+ } else {
+ cairo_set_source_rgba (cr, 1.0,
+ 1.0,
+ 1.0,
+ 0.35);
+ }
+ } else { /* black preview block, use a much weaker highlight */
+ cairo_set_source_rgba (cr, 1.0,
+ 1.0,
+ 1.0,
+ 0.15);
+ }
+ cairo_stroke (cr); /* add inner edge highlight */
+
+ if (usegrads && (data[x][y].what != TARGET))
+ cairo_pattern_destroy (pat);
}
void TangoBlock::drawRoundedRectangle (cairo_t * cr, gdouble x, gdouble y, gdouble w, gdouble h, gdouble r)
{
- cairo_move_to(cr, x+r, y);
- cairo_line_to(cr, x+w-r, y);
- cairo_curve_to(cr, x+w-(r/2), y, x+w, y+(r/2), x+w, y+r);
- cairo_line_to(cr, x+w, y+h-r);
- cairo_curve_to(cr, x+w, y+h-(r/2), x+w-(r/2), y+h, x+w-r, y+h);
- cairo_line_to(cr, x+r, y+h);
- cairo_curve_to(cr, x+(r/2), y+h, x, y+h-(r/2), x, y+h-r);
- cairo_line_to(cr, x, y+r);
- cairo_curve_to(cr, x, y+(r/2), x+(r/2), y, x+r, y);
+ cairo_move_to(cr, x+r, y);
+ cairo_line_to(cr, x+w-r, y);
+ cairo_curve_to(cr, x+w-(r/2), y, x+w, y+(r/2), x+w, y+r);
+ cairo_line_to(cr, x+w, y+h-r);
+ cairo_curve_to(cr, x+w, y+h-(r/2), x+w-(r/2), y+h, x+w-r, y+h);
+ cairo_line_to(cr, x+r, y+h);
+ cairo_curve_to(cr, x+(r/2), y+h, x, y+h-(r/2), x, y+h-r);
+ cairo_line_to(cr, x, y+r);
+ cairo_curve_to(cr, x, y+(r/2), x+(r/2), y, x+r, y);
}
Modified: trunk/gnometris/renderer.h
==============================================================================
--- trunk/gnometris/renderer.h (original)
+++ trunk/gnometris/renderer.h Sat Nov 15 04:13:52 2008
@@ -1,4 +1,4 @@
-/* -*- mode:C; indent-tabs-mode:nil; tab-width:8; c-basic-offset:8 -*- */
+/* -*- mode:C++; tab-width:8; c-basic-offset:8; indent-tabs-mode:true -*- */
/*
* written by Callum McKenzie <callum spooky-possum org>
*
@@ -30,35 +30,35 @@
#include "blockops.h"
struct ThemeTableEntry {
- const gchar *name;
- const gchar *id;
+ const gchar *name;
+ const gchar *id;
};
extern const ThemeTableEntry ThemeTable[];
class Renderer {
public:
- Renderer (cairo_surface_t * dst, cairo_surface_t * bg, Block ** src,
- int w, int h, int pxw, int pxh);
- virtual ~ Renderer ();
- virtual void render ();
-
- void setTarget (cairo_surface_t *target);
- void setBackground (cairo_surface_t *background);
-
- Block **data;
- int width;
- int height;
- int pxwidth;
- int pxheight;
+ Renderer (cairo_surface_t * dst, cairo_surface_t * bg, Block ** src,
+ int w, int h, int pxw, int pxh);
+ virtual ~ Renderer ();
+ virtual void render ();
+
+ void setTarget (cairo_surface_t *target);
+ void setBackground (cairo_surface_t *background);
+
+ Block **data;
+ int width;
+ int height;
+ int pxwidth;
+ int pxheight;
protected:
- cairo_surface_t * target;
- cairo_surface_t *background;
+ cairo_surface_t * target;
+ cairo_surface_t *background;
- virtual void drawCell (cairo_t * cr, gint x, gint y);
- virtual void drawBackground (cairo_t * cr);
- virtual void drawForeground (cairo_t * cr);
+ virtual void drawCell (cairo_t * cr, gint x, gint y);
+ virtual void drawBackground (cairo_t * cr);
+ virtual void drawForeground (cairo_t * cr);
};
Renderer *rendererFactory (gint id, cairo_surface_t * dst,
@@ -68,31 +68,31 @@
class JoinedUp:public Renderer {
public:
- JoinedUp (cairo_surface_t * dst, cairo_surface_t * bg, Block ** src,
- int w, int h, int pxw, int pxh):Renderer (dst, bg, src, w, h, pxw,
- pxh) {
-} protected:
- virtual void drawCell (cairo_t * cr, gint x, gint y);
+ JoinedUp (cairo_surface_t * dst, cairo_surface_t * bg, Block ** src,
+ int w, int h, int pxw, int pxh):Renderer (dst, bg, src, w, h, pxw,
+ pxh) {}
+protected:
+ virtual void drawCell (cairo_t * cr, gint x, gint y);
private:
- double border;
- void drawInnerCorner (cairo_t * cr);
- void drawOuterCorner (cairo_t * cr);
- void drawHEdge (cairo_t * cr);
- void drawVEdge (cairo_t * cr);
+ double border;
+ void drawInnerCorner (cairo_t * cr);
+ void drawOuterCorner (cairo_t * cr);
+ void drawHEdge (cairo_t * cr);
+ void drawVEdge (cairo_t * cr);
};
class TangoBlock:public Renderer {
public:
- TangoBlock (cairo_surface_t * dst, cairo_surface_t * bg, Block ** src,
- int w, int h, int pxw, int pxh, gboolean grad);
+ TangoBlock (cairo_surface_t * dst, cairo_surface_t * bg, Block ** src,
+ int w, int h, int pxw, int pxh, gboolean grad);
protected:
- virtual void drawCell (cairo_t * cr, gint x, gint y);
- gboolean usegrads;
+ virtual void drawCell (cairo_t * cr, gint x, gint y);
+ gboolean usegrads;
private:
- void drawRoundedRectangle (cairo_t * cr, gdouble x, gdouble y, gdouble w, gdouble h, gdouble r);
+ void drawRoundedRectangle (cairo_t * cr, gdouble x, gdouble y, gdouble w, gdouble h, gdouble r);
};
#endif // __renderer_h__
Modified: trunk/gnometris/scoreframe.cpp
==============================================================================
--- trunk/gnometris/scoreframe.cpp (original)
+++ trunk/gnometris/scoreframe.cpp Sat Nov 15 04:13:52 2008
@@ -1,5 +1,4 @@
/* -*- mode:C++; tab-width:8; c-basic-offset:8; indent-tabs-mode:true -*- */
-
/*
* written by J. Marcin Gorycki <marcin gorycki intel com>
*
@@ -36,8 +35,8 @@
startingLevel = cmdlLevel;
else {
startingLevel = games_conf_get_integer (KEY_OPTIONS_GROUP,
- KEY_STARTING_LEVEL,
- NULL);
+ KEY_STARTING_LEVEL,
+ NULL);
}
startingLevel = CLAMP (startingLevel, 1, 20);
@@ -115,8 +114,8 @@
switch(newlines)
{
- case 0:
- return level;
+ case 0:
+ return level;
case 1:
linescore = 40;
games_sound_play ("lines1");
Modified: trunk/gnometris/scoreframe.h
==============================================================================
--- trunk/gnometris/scoreframe.h (original)
+++ trunk/gnometris/scoreframe.h Sat Nov 15 04:13:52 2008
@@ -1,3 +1,4 @@
+/* -*- mode:C++; tab-width:8; c-basic-offset:8; indent-tabs-mode:true -*- */
#ifndef __scoreframe_h__
#define __scoreframe_h__
@@ -23,51 +24,52 @@
class ScoreFrame {
public:
- ScoreFrame (int cmdlLevel);
+ ScoreFrame (int cmdlLevel);
- void show ();
- void resetScore ();
- void setLevel (int l);
- void setStartingLevel (int l);
-
- int getScore () {
- return score;
- } int getLines () {
- return lines;
- }
- int getLevel () {
- return level;
- }
-
- GtkWidget *getWidget () {
- return w;
- }
+ void show ();
+ void resetScore ();
+ void setLevel (int l);
+ void setStartingLevel (int l);
+
+ int getScore () {
+ return score;
+ }
+ int getLines () {
+ return lines;
+ }
+ int getLevel () {
+ return level;
+ }
+
+ GtkWidget *getWidget () {
+ return w;
+ }
- int scoreLines (int nlines);
- void scoreLastLineBonus ();
+ int scoreLines (int nlines);
+ void scoreLastLineBonus ();
private:
- GtkWidget * w;
- GtkWidget *scorew;
- GtkWidget *linesw;
- GtkWidget *levelw;
- GtkWidget *scoreLabel;
- GtkWidget *linesLabel;
- GtkWidget *levelLabel;
- GtkWidget *hbScore;
- GtkWidget *hbLines;
- GtkWidget *hbLevel;
- GtkWidget *vb;
- char b[20];
-
- int level;
- int score;
- int lines;
- int startingLevel;
-
- void setScore (int score);
- void setLines (int lines);
- void incScore (int score);
+ GtkWidget * w;
+ GtkWidget *scorew;
+ GtkWidget *linesw;
+ GtkWidget *levelw;
+ GtkWidget *scoreLabel;
+ GtkWidget *linesLabel;
+ GtkWidget *levelLabel;
+ GtkWidget *hbScore;
+ GtkWidget *hbLines;
+ GtkWidget *hbLevel;
+ GtkWidget *vb;
+ char b[20];
+
+ int level;
+ int score;
+ int lines;
+ int startingLevel;
+
+ void setScore (int score);
+ void setLines (int lines);
+ void incScore (int score);
};
#endif //__scoreframe_h__
Modified: trunk/gnometris/tetris.cpp
==============================================================================
--- trunk/gnometris/tetris.cpp (original)
+++ trunk/gnometris/tetris.cpp Sat Nov 15 04:13:52 2008
@@ -1,5 +1,4 @@
/* -*- mode:C++; tab-width:8; c-basic-offset:8; indent-tabs-mode:true -*- */
-
/*
* written by J. Marcin Gorycki <marcin gorycki intel com>
*
@@ -89,7 +88,7 @@
setupdialog(0),
cmdlineLevel(cmdlLevel),
fastFall(false),
- dropBlock(false)
+ dropBlock(false)
{
GtkUIManager *ui_manager;
GtkAccelGroup *accel_group;
@@ -157,9 +156,9 @@
/* Use default background image, if none found in user's home dir.*/
if (!g_file_test (bgPixmap, G_FILE_TEST_EXISTS)) {
- dname = games_runtime_get_directory (GAMES_RUNTIME_GAME_PIXMAP_DIRECTORY);
- defaultPixmap = g_build_filename (dname, "gnometris.svg", NULL);
- default_bgimage = true;
+ dname = games_runtime_get_directory (GAMES_RUNTIME_GAME_PIXMAP_DIRECTORY);
+ defaultPixmap = g_build_filename (dname, "gnometris.svg", NULL);
+ default_bgimage = true;
}
w = gtk_window_new (GTK_WINDOW_TOPLEVEL);
@@ -178,7 +177,7 @@
line_fill_prob = 5;
gtk_window_set_default_size (GTK_WINDOW (w), DEFAULT_WIDTH, DEFAULT_HEIGHT);
- games_conf_add_window (GTK_WINDOW (w), KEY_SAVED_GROUP);
+ games_conf_add_window (GTK_WINDOW (w), KEY_SAVED_GROUP);
preview = new Preview ();
field = new Field();
@@ -231,7 +230,7 @@
g_signal_connect (w, "key_press_event", G_CALLBACK (keyPressHandler), this);
g_signal_connect (w, "key_release_event", G_CALLBACK (keyReleaseHandler), this);
-
+
GtkWidget *vb2 = gtk_vbox_new(FALSE, 0);
gtk_container_set_border_width(GTK_CONTAINER(vb2), 10);
gtk_box_pack_end(GTK_BOX(hb), vb2, 0, 0, 0);
@@ -260,10 +259,10 @@
gtk_action_set_sensitive(end_game_action, FALSE);
gtk_action_set_sensitive(preferences_action, TRUE);
- confNotifyID = g_signal_connect (games_conf_get_default (),
- "value-changed",
- G_CALLBACK (confNotify),
- this);
+ confNotifyID = g_signal_connect (games_conf_get_default (),
+ "value-changed",
+ G_CALLBACK (confNotify),
+ this);
}
Tetris::~Tetris()
@@ -273,15 +272,15 @@
delete scoreFrame;
if (bgimage)
- g_object_unref (G_OBJECT (bgimage));
+ g_object_unref (G_OBJECT (bgimage));
if (bgPixmap)
g_free(bgPixmap);
if (defaultPixmap)
g_free(defaultPixmap);
- if (confNotifyID != 0)
- g_signal_handler_disconnect (games_conf_get_default (), confNotifyID);
+ if (confNotifyID != 0)
+ g_signal_handler_disconnect (games_conf_get_default (), confNotifyID);
}
void
@@ -341,7 +340,7 @@
int i, j;
temp = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8,
- bgwidth, bgheight);
+ bgwidth, bgheight);
for (i=0; i<=bgwidth/width; i++) {
for (j=0; j<=bgheight/height; j++) {
@@ -380,8 +379,8 @@
void
Tetris::confNotify (GamesConf *conf, const char *group, const char *key, gpointer data)
{
- if (!group)
- return;
+ if (!group)
+ return;
Tetris *t = (Tetris *) data;
@@ -392,13 +391,13 @@
char *
Tetris::confGetString (const char *group, const char *key, const char *default_val)
{
- return games_conf_get_string_with_default (group, key, default_val);
+ return games_conf_get_string_with_default (group, key, default_val);
}
int
Tetris::confGetInt (const char *group, const char *key, int default_val)
{
- return games_conf_get_integer_with_default (group, key, default_val);
+ return games_conf_get_integer_with_default (group, key, default_val);
}
gboolean
@@ -497,40 +496,40 @@
void
Tetris::setSound (GtkWidget *widget, gpointer data)
{
- games_conf_set_boolean (KEY_OPTIONS_GROUP, KEY_SOUND,
- GTK_TOGGLE_BUTTON (widget)->active);
+ games_conf_set_boolean (KEY_OPTIONS_GROUP, KEY_SOUND,
+ GTK_TOGGLE_BUTTON (widget)->active);
}
void
Tetris::setSelectionPreview(GtkWidget *widget, void *d)
{
- games_conf_set_boolean (KEY_OPTIONS_GROUP, KEY_DO_PREVIEW,
- GTK_TOGGLE_BUTTON (widget)->active);
+ games_conf_set_boolean (KEY_OPTIONS_GROUP, KEY_DO_PREVIEW,
+ GTK_TOGGLE_BUTTON (widget)->active);
}
void
Tetris::setSelectionBlocks(GtkWidget *widget, void *d)
{
- games_conf_set_boolean (KEY_OPTIONS_GROUP, KEY_RANDOM_BLOCK_COLORS,
- GTK_TOGGLE_BUTTON (widget)->active);
+ games_conf_set_boolean (KEY_OPTIONS_GROUP, KEY_RANDOM_BLOCK_COLORS,
+ GTK_TOGGLE_BUTTON (widget)->active);
}
void
Tetris::setRotateCounterClockWise(GtkWidget *widget, void *d)
{
- games_conf_set_boolean (KEY_OPTIONS_GROUP, KEY_ROTATE_COUNTER_CLOCKWISE,
- GTK_TOGGLE_BUTTON (widget)->active);
+ games_conf_set_boolean (KEY_OPTIONS_GROUP, KEY_ROTATE_COUNTER_CLOCKWISE,
+ GTK_TOGGLE_BUTTON (widget)->active);
}
void
Tetris::setSelection(GtkWidget *widget, void *data)
{
Tetris *t;
- t = (Tetris *)data;
+ t = (Tetris *)data;
t->themeno = gtk_combo_box_get_active (GTK_COMBO_BOX (widget));
t->field->setTheme (t->themeno);
- games_conf_set_string (KEY_OPTIONS_GROUP, KEY_THEME,
+ games_conf_set_string (KEY_OPTIONS_GROUP, KEY_THEME,
ThemeTable[t->themeno].id);
}
@@ -543,29 +542,29 @@
t->useTarget = GTK_TOGGLE_BUTTON (widget)->active;
- games_conf_set_boolean (KEY_OPTIONS_GROUP, KEY_USE_TARGET,
- t->useTarget);
+ games_conf_set_boolean (KEY_OPTIONS_GROUP, KEY_USE_TARGET,
+ t->useTarget);
}
void
Tetris::lineFillHeightChanged (GtkWidget *spin, gpointer data)
{
gint value = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (spin));
- games_conf_set_integer (KEY_OPTIONS_GROUP, KEY_LINE_FILL_HEIGHT, value);
+ games_conf_set_integer (KEY_OPTIONS_GROUP, KEY_LINE_FILL_HEIGHT, value);
}
void
Tetris::lineFillProbChanged (GtkWidget *spin, gpointer data)
{
gint value = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (spin));
- games_conf_set_integer (KEY_OPTIONS_GROUP, KEY_LINE_FILL_PROBABILITY, value);
+ games_conf_set_integer (KEY_OPTIONS_GROUP, KEY_LINE_FILL_PROBABILITY, value);
}
void
Tetris::startingLevelChanged (GtkWidget *spin, gpointer data)
{
gint value = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (spin));
- games_conf_set_integer (KEY_OPTIONS_GROUP, KEY_STARTING_LEVEL, value);
+ games_conf_set_integer (KEY_OPTIONS_GROUP, KEY_STARTING_LEVEL, value);
}
int
@@ -622,7 +621,7 @@
label = gtk_label_new_with_mnemonic (_("_Number of pre-filled rows:"));
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
- (GtkAttachOptions) GTK_FILL,
+ (GtkAttachOptions) GTK_FILL,
(GtkAttachOptions) 0,
0, 0);
@@ -641,7 +640,7 @@
label = gtk_label_new_with_mnemonic (_("_Density of blocks in a pre-filled row:"));
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
- (GtkAttachOptions) GTK_FILL,
+ (GtkAttachOptions) GTK_FILL,
(GtkAttachOptions) 0,
0, 0);
@@ -660,7 +659,7 @@
label = gtk_label_new_with_mnemonic (_("_Starting level:"));
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3,
- (GtkAttachOptions) GTK_FILL,
+ (GtkAttachOptions) GTK_FILL,
(GtkAttachOptions) 0,
0, 0);
@@ -885,12 +884,12 @@
if (t->paused)
return TRUE;
- if (t->onePause)
- {
+ if (t->onePause)
+ {
t->onePause = false;
t->field->redraw();
}
- else
+ else
{
bool res = t->field->moveBlockDown();
@@ -956,7 +955,7 @@
t->field->dropBlock();
t->manageFallen();
res = TRUE;
- }
+ }
}
t->field->redraw();
@@ -995,11 +994,11 @@
{
gchar cbuffer[64];
- games_conf_set_boolean (KEY_OPTIONS_GROUP, KEY_USE_BG_IMAGE, usebg);
+ games_conf_set_boolean (KEY_OPTIONS_GROUP, KEY_USE_BG_IMAGE, usebg);
g_snprintf (cbuffer, sizeof (cbuffer), "#%04x%04x%04x",
- bgcolour.red, bgcolour.green, bgcolour.blue);
- games_conf_set_string (KEY_OPTIONS_GROUP, KEY_BG_COLOUR, cbuffer);
+ bgcolour.red, bgcolour.green, bgcolour.blue);
+ games_conf_set_string (KEY_OPTIONS_GROUP, KEY_BG_COLOUR, cbuffer);
}
void
@@ -1324,7 +1323,7 @@
gtk_show_about_dialog (GTK_WINDOW (t->getWidget()),
#if GTK_CHECK_VERSION (2, 11, 0)
- "program-name", _("Gnometris"),
+ "program-name", _("Gnometris"),
#else
"name", _("Gnometris"),
#endif
@@ -1332,7 +1331,7 @@
"comments", _("A classic game of fitting falling blocks together.\n\nGnometris is a part of GNOME Games."),
"copyright", "Copyright \xc2\xa9 1999 J. Marcin Gorycki, 2000-2008 Others",
"license", license,
- "website-label", _("GNOME Games web site"),
+ "website-label", _("GNOME Games web site"),
"authors", authors,
"documenters", documenters,
"translator-credits", _("translator-credits"),
Modified: trunk/gnometris/tetris.h
==============================================================================
--- trunk/gnometris/tetris.h (original)
+++ trunk/gnometris/tetris.h Sat Nov 15 04:13:52 2008
@@ -1,3 +1,4 @@
+/* -*- mode:C++; tab-width:8; c-basic-offset:8; indent-tabs-mode:true -*- */
#ifndef __tetris_h__
#define __tetris_h__
@@ -72,132 +73,133 @@
class Tetris {
public:
- Tetris (int cmdlLevel);
- ~Tetris ();
+ Tetris (int cmdlLevel);
+ ~Tetris ();
- GtkWidget *getWidget () {
- return w;
- } void togglePause ();
- void generate ();
- void endOfGame ();
- void setupPixmap ();
+ GtkWidget *getWidget () {
+ return w;
+ }
+ void togglePause ();
+ void generate ();
+ void endOfGame ();
+ void setupPixmap ();
private:
- GtkWidget * w;
+ GtkWidget * w;
- GList *themeList;
+ GList *themeList;
- char *bgPixmap;
- char *defaultPixmap;
- gint themeno;
+ char *bgPixmap;
+ char *defaultPixmap;
+ gint themeno;
- Field *field;
- Preview *preview;
- BlockOps *ops;
- ScoreFrame *scoreFrame;
- HighScores *high_scores;
+ Field *field;
+ Preview *preview;
+ BlockOps *ops;
+ ScoreFrame *scoreFrame;
+ HighScores *high_scores;
- gulong confNotifyID;
+ gulong confNotifyID;
- bool paused;
- int timeoutId;
- bool onePause;
+ bool paused;
+ int timeoutId;
+ bool onePause;
- bool inPlay;
- bool useTarget;
+ bool inPlay;
+ bool useTarget;
- void generateTimer (int level);
+ void generateTimer (int level);
- static gint keyPressHandler (GtkWidget * widget, GdkEvent * event,
+ static gint keyPressHandler (GtkWidget * widget, GdkEvent * event,
Tetris * t);
- static gint keyReleaseHandler (GtkWidget * widget, GdkEvent * event,
+ static gint keyReleaseHandler (GtkWidget * widget, GdkEvent * event,
Tetris * t);
- static gchar *decodeDropData (gchar * data, gint type);
- void saveBgOptions ();
- static void decodeColour (guint16 * data, Tetris * t);
- static void resetColour (Tetris * t);
- static void dragDrop (GtkWidget * widget, GdkDragContext * context,
+ static gchar *decodeDropData (gchar * data, gint type);
+ void saveBgOptions ();
+ static void decodeColour (guint16 * data, Tetris * t);
+ static void resetColour (Tetris * t);
+ static void dragDrop (GtkWidget * widget, GdkDragContext * context,
gint x, gint y, GtkSelectionData * data,
guint info, guint time, Tetris * t);
- static gboolean configure (GtkWidget * widget, GdkEventConfigure * event,
+ static gboolean configure (GtkWidget * widget, GdkEventConfigure * event,
Tetris * t);
- static int timeoutHandler (void *d);
- static int gameQuit (GtkAction * action, void *d);
- static int gameNew (GtkAction * action, void *d);
- static int focusOut (GtkWidget * widget, GdkEvent * e, Tetris * t);
- static int gamePause (GtkAction * action, void *d);
- static int gameEnd (GtkAction * action, void *d);
- static int gameHelp (GtkAction * action, void *d);
- static int gameAbout (GtkAction * action, void *d);
- static int gameTopTen (GtkAction * action, void *d);
- static int gameProperties (GtkAction * action, void *d);
- static void setupdialogDestroy (GtkWidget * widget, void *d);
- static void setupdialogResponse (GtkWidget * dialog, gint response_id,
+ static int timeoutHandler (void *d);
+ static int gameQuit (GtkAction * action, void *d);
+ static int gameNew (GtkAction * action, void *d);
+ static int focusOut (GtkWidget * widget, GdkEvent * e, Tetris * t);
+ static int gamePause (GtkAction * action, void *d);
+ static int gameEnd (GtkAction * action, void *d);
+ static int gameHelp (GtkAction * action, void *d);
+ static int gameAbout (GtkAction * action, void *d);
+ static int gameTopTen (GtkAction * action, void *d);
+ static int gameProperties (GtkAction * action, void *d);
+ static void setupdialogDestroy (GtkWidget * widget, void *d);
+ static void setupdialogResponse (GtkWidget * dialog, gint response_id,
void *d);
- static void setSound (GtkWidget * widget, gpointer data);
- static void setSelectionPreview (GtkWidget * widget, void *d);
- static void setSelectionBlocks (GtkWidget * widget, void *d);
- static void setRotateCounterClockWise (GtkWidget * widget, void *d);
- static void setTarget (GtkWidget * widget, void *d);
- static void setSelection (GtkWidget * widget, void *data);
- static void setBGSelection (GtkWidget * widget, void *data);
-
- static void lineFillHeightChanged (GtkWidget * spin, gpointer data);
- static void lineFillProbChanged (GtkWidget * spin, gpointer data);
- static void startingLevelChanged (GtkWidget * spin, gpointer data);
-
- static void confNotify (GamesConf *conf, const char *group,
- const char *key, gpointer data);
- static gchar *confGetString (const char *group, const char *key,
- const char *default_val);
- static int confGetInt (const char *group, const char *key,
- int default_val);
- static gboolean confGetBoolean (const char *group, const char *key,
- gboolean default_val);
- void initOptions ();
- void setOptions ();
- void writeOptions ();
- void manageFallen ();
-
- GdkPixbuf *bgimage;
- gboolean usebg;
-
- GdkColor bgcolour;
-
- GtkWidget *setupdialog;
- GtkWidget *sentry;
- int startingLevel;
- int cmdlineLevel;
-
- int line_fill_height;
- int line_fill_prob;
-
- GtkWidget *fill_height_spinner;
- GtkWidget *fill_prob_spinner;
- GtkWidget *do_preview_toggle;
- GtkWidget *random_block_colors_toggle;
- GtkWidget *rotate_counter_clock_wise_toggle;
- GtkWidget *useTargetToggle;
- GtkWidget *sound_toggle;
-
- Preview *theme_preview;
-
- int moveLeft;
- int moveRight;
- int moveDown;
- int moveDrop;
- int moveRotate;
- int movePause;
-
- GtkAction *new_game_action;
- GtkAction *pause_action;
- GtkAction *resume_action;
- GtkAction *scores_action;
- GtkAction *end_game_action;
- GtkAction *preferences_action;
+ static void setSound (GtkWidget * widget, gpointer data);
+ static void setSelectionPreview (GtkWidget * widget, void *d);
+ static void setSelectionBlocks (GtkWidget * widget, void *d);
+ static void setRotateCounterClockWise (GtkWidget * widget, void *d);
+ static void setTarget (GtkWidget * widget, void *d);
+ static void setSelection (GtkWidget * widget, void *data);
+ static void setBGSelection (GtkWidget * widget, void *data);
+
+ static void lineFillHeightChanged (GtkWidget * spin, gpointer data);
+ static void lineFillProbChanged (GtkWidget * spin, gpointer data);
+ static void startingLevelChanged (GtkWidget * spin, gpointer data);
+
+ static void confNotify (GamesConf *conf, const char *group,
+ const char *key, gpointer data);
+ static gchar *confGetString (const char *group, const char *key,
+ const char *default_val);
+ static int confGetInt (const char *group, const char *key,
+ int default_val);
+ static gboolean confGetBoolean (const char *group, const char *key,
+ gboolean default_val);
+ void initOptions ();
+ void setOptions ();
+ void writeOptions ();
+ void manageFallen ();
+
+ GdkPixbuf *bgimage;
+ gboolean usebg;
+
+ GdkColor bgcolour;
+
+ GtkWidget *setupdialog;
+ GtkWidget *sentry;
+ int startingLevel;
+ int cmdlineLevel;
+
+ int line_fill_height;
+ int line_fill_prob;
+
+ GtkWidget *fill_height_spinner;
+ GtkWidget *fill_prob_spinner;
+ GtkWidget *do_preview_toggle;
+ GtkWidget *random_block_colors_toggle;
+ GtkWidget *rotate_counter_clock_wise_toggle;
+ GtkWidget *useTargetToggle;
+ GtkWidget *sound_toggle;
+
+ Preview *theme_preview;
+
+ int moveLeft;
+ int moveRight;
+ int moveDown;
+ int moveDrop;
+ int moveRotate;
+ int movePause;
+
+ GtkAction *new_game_action;
+ GtkAction *pause_action;
+ GtkAction *resume_action;
+ GtkAction *scores_action;
+ GtkAction *end_game_action;
+ GtkAction *preferences_action;
- bool fastFall;
- bool dropBlock;
+ bool fastFall;
+ bool dropBlock;
};
#endif // __tetris_h__
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]