ngc891 pushed a commit to branch master.
commit a31655520d98092e038a3c6d4f12f473652287a7
Author: Jerome Pinot <[email protected]>
Date: Sat Mar 23 15:15:42 2013 +0900
elemines: put the default mines count inside the edje theme
---
data/themes/default.edc | 1 +
src/elemines.h | 2 +-
src/game.c | 2 +-
src/gui.c | 23 +++++++++++++++++++++--
src/main.c | 10 ++--------
5 files changed, 26 insertions(+), 12 deletions(-)
diff --git a/data/themes/default.edc b/data/themes/default.edc
index 51cd831..ff00c22 100644
--- a/data/themes/default.edc
+++ b/data/themes/default.edc
@@ -69,6 +69,7 @@ fonts {
}
data {
+ item: "MINES" "12";
item: "width" "500";
item: "height" "600";
}
diff --git a/src/elemines.h b/src/elemines.h
index 71bb2e9..ee73836 100644
--- a/src/elemines.h
+++ b/src/elemines.h
@@ -55,7 +55,6 @@
#define SIZE_X 10
#define SIZE_Y 10
-#define MINES 12
#define STANDARD "Standard"
#define CUSTOM "Custom"
@@ -84,6 +83,7 @@ struct ui_struct {
struct datas_struct {
int mines_total;
+ int mines_theme;
int remain;
int counter;
};
diff --git a/src/game.c b/src/game.c
index 38de35d..08128ee 100644
--- a/src/game.c
+++ b/src/game.c
@@ -51,7 +51,7 @@ _scoring(void)
/* add the score */
game.trophy.escore = etrophy_score_new(user, score);
/* Level is Standard if using default board values */
- if (game.datas.mines_total == MINES)
+ if (game.datas.mines_total == game.datas.mines_theme)
{
game.trophy.game_type = STANDARD;
}
diff --git a/src/gui.c b/src/gui.c
index d0e5f6e..99495e2 100644
--- a/src/gui.c
+++ b/src/gui.c
@@ -79,7 +79,7 @@ _config(void *data __UNUSED__, Evas_Object *obj __UNUSED__,
/* we get back the mine number from user and init again the game */
number = elm_spinner_value_get(spin);
if ( (number < 2) || (number > (SIZE_X * SIZE_Y)) )
- number = MINES;
+ number = game.datas.mines_theme;
game.datas.mines_total = number;
evas_object_hide(game.ui.popup);
@@ -118,7 +118,7 @@ _show_config(void *data __UNUSED__, Evas_Object *obj
__UNUSED__,
snprintf(buffer, sizeof(buffer), _("<b>Note:</b> default mine number is "
"<b>%d</b> with scoring in <b>%s</b> category. If you change "
"the mine number to something else, your score will be put in the "
- "<b>%s</b> category."), MINES, STANDARD, CUSTOM);
+ "<b>%s</b> category."), game.datas.mines_theme, STANDARD, CUSTOM);
elm_object_text_set(label, buffer);
evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
@@ -227,6 +227,25 @@ gui(char *theme, Eina_Bool fullscreen)
elm_theme_extension_add(NULL, game.edje_file);
+ /* get default mines count from theme */
+ if (edje_file_data_get(game.edje_file, "MINES") != NULL)
+ {
+ game.datas.mines_theme = atoi(edje_file_data_get(game.edje_file,
"MINES"));
+ }
+ else
+ {
+ EINA_LOG_CRIT("Loading theme error: can not read the MINES value in
%s", game.edje_file);
+ return EINA_FALSE;
+ }
+
+ /* Validate input values */
+ if (game.datas.mines_total == 0)
+ game.datas.mines_total = game.datas.mines_theme;
+ if (game.datas.mines_total < 0)
+ game.datas.mines_total = 1;
+ if (game.datas.mines_total > (SIZE_X * SIZE_Y - 1))
+ game.datas.mines_total = SIZE_X * SIZE_Y - 1;
+
/* set general properties */
game.ui.window = elm_win_add(NULL, PACKAGE, ELM_WIN_BASIC);
elm_win_title_set(game.ui.window, PACKAGE);
diff --git a/src/main.c b/src/main.c
index 0e284e3..b9eb169 100644
--- a/src/main.c
+++ b/src/main.c
@@ -190,8 +190,8 @@ elm_main(int argc __UNUSED__, char **argv __UNUSED__)
textdomain(PACKAGE);
#endif
- /* Set default values */
- game.datas.mines_total = MINES;
+ /* will be used to check input */
+ game.datas.mines_total = 0;
/* Get user values */
args = ecore_getopt_parse(&optdesc, values, argc, argv);
@@ -205,12 +205,6 @@ elm_main(int argc __UNUSED__, char **argv __UNUSED__)
goto end;
}
- /* Validate user values */
- if (game.datas.mines_total < 1)
- game.datas.mines_total = 1;
- if (game.datas.mines_total > (SIZE_X * SIZE_Y - 1))
- game.datas.mines_total = SIZE_X * SIZE_Y - 1;
-
game.clock.started = EINA_FALSE;
if (gui(theme, fullscreen) != EINA_TRUE)
--
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar