summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Dilly <bdilly@profusion.mobi>2012-10-10 21:50:04 +0000
committerBruno Dilly <bdilly@profusion.mobi>2012-10-10 21:50:04 +0000
commit5fc35bc286dccc95023c1915ec8259c019401f73 (patch)
tree34d8009fedfcdf24a4f68a2f8646f489ba117eee
parentdc91319dc2e2ddccc0e57066fae4659b27843019 (diff)
etrophy: set date field internally
Instead of leaving this task to the library user. SVN revision: 77823
-rw-r--r--configure.ac3
-rw-r--r--src/lib/Etrophy.h16
-rw-r--r--src/lib/etrophy.c51
-rw-r--r--src/lib/etrophy_layouts.c3
4 files changed, 31 insertions, 42 deletions
diff --git a/configure.ac b/configure.ac
index 9ed0f4a..5fdb236 100644
--- a/configure.ac
+++ b/configure.ac
@@ -124,6 +124,7 @@ PKG_CHECK_MODULES([ELEMENTARY],
124 elementary >= 1.7.0 124 elementary >= 1.7.0
125 evas >= 1.7.0 125 evas >= 1.7.0
126 ecore-file >= 1.7.0 126 ecore-file >= 1.7.0
127 ecore >= 1.7.0
127 eet >= 1.7.0 128 eet >= 1.7.0
128 eina >= 1.7.0 129 eina >= 1.7.0
129 ]) 130 ])
@@ -140,7 +141,7 @@ AC_ARG_WITH([edje-cc],
140 ],[edje_cc=$(pkg-config --variable=prefix edje)/bin/edje_cc]) 141 ],[edje_cc=$(pkg-config --variable=prefix edje)/bin/edje_cc])
141AC_SUBST(edje_cc) 142AC_SUBST(edje_cc)
142 143
143requirement_etrophy="elementary >= 1.7.0 evas >= 1.7.0 ecore-file >= 1.7.0 eet >= 1.7.0 eina >= 1.7.0 ${requirement_etrophy}" 144requirement_etrophy="elementary >= 1.7.0 evas >= 1.7.0 ecore-file >= 1.7.0 ecore >= 1.7.0 eet >= 1.7.0 eina >= 1.7.0 ${requirement_etrophy}"
144 145
145### Checks for header files 146### Checks for header files
146AC_CHECK_HEADERS([locale.h sys/resource.h]) 147AC_CHECK_HEADERS([locale.h sys/resource.h])
diff --git a/src/lib/Etrophy.h b/src/lib/Etrophy.h
index ee6117e..43d7c23 100644
--- a/src/lib/Etrophy.h
+++ b/src/lib/Etrophy.h
@@ -55,33 +55,31 @@ typedef struct _Etrophy_Level Etrophy_Level;
55typedef struct _Etrophy_Gamescore Etrophy_Gamescore; 55typedef struct _Etrophy_Gamescore Etrophy_Gamescore;
56 56
57/* Etrophy_Trophy */ 57/* Etrophy_Trophy */
58EAPI Etrophy_Trophy *etrophy_trophy_new(const char *name, const char *description, Etrophy_Trophy_State state, int date); 58EAPI Etrophy_Trophy *etrophy_trophy_new(const char *name, const char *description, Etrophy_Trophy_State state);
59EAPI void etrophy_trophy_free(Etrophy_Trophy *trophy); 59EAPI void etrophy_trophy_free(Etrophy_Trophy *trophy);
60 60
61EAPI const char *etrophy_trophy_name_get(const Etrophy_Trophy *trophy); 61EAPI const char *etrophy_trophy_name_get(const Etrophy_Trophy *trophy);
62EAPI const char *etrophy_trophy_description_get(const Etrophy_Trophy *trophy); 62EAPI const char *etrophy_trophy_description_get(const Etrophy_Trophy *trophy);
63EAPI void etrophy_trophy_state_set(Etrophy_Trophy *trophy, Etrophy_Trophy_State state); 63EAPI void etrophy_trophy_state_set(Etrophy_Trophy *trophy, Etrophy_Trophy_State state);
64EAPI Etrophy_Trophy_State etrophy_trophy_state_get(const Etrophy_Trophy *trophy); 64EAPI Etrophy_Trophy_State etrophy_trophy_state_get(const Etrophy_Trophy *trophy);
65EAPI void etrophy_trophy_date_set(Etrophy_Trophy *trophy, int date); 65EAPI unsigned int etrophy_trophy_date_get(const Etrophy_Trophy *trophy);
66EAPI int etrophy_trophy_date_get(const Etrophy_Trophy *trophy);
67 66
68/* Etrophy_Lock */ 67/* Etrophy_Lock */
69EAPI Etrophy_Lock *etrophy_lock_new(const char *name, Etrophy_Lock_State state, int date); 68EAPI Etrophy_Lock *etrophy_lock_new(const char *name, Etrophy_Lock_State state);
70EAPI void etrophy_lock_free(Etrophy_Lock *lock); 69EAPI void etrophy_lock_free(Etrophy_Lock *lock);
71 70
72EAPI const char *etrophy_lock_name_get(const Etrophy_Lock *lock); 71EAPI const char *etrophy_lock_name_get(const Etrophy_Lock *lock);
73EAPI void etrophy_lock_state_set(Etrophy_Lock *lock, Etrophy_Lock_State state); 72EAPI void etrophy_lock_state_set(Etrophy_Lock *lock, Etrophy_Lock_State state);
74EAPI Etrophy_Lock_State etrophy_lock_state_get(const Etrophy_Lock *lock); 73EAPI Etrophy_Lock_State etrophy_lock_state_get(const Etrophy_Lock *lock);
75EAPI void etrophy_lock_date_set(Etrophy_Lock *lock, int date); 74EAPI unsigned int etrophy_lock_date_get(const Etrophy_Lock *lock);
76EAPI int etrophy_lock_date_get(const Etrophy_Lock *lock);
77 75
78/* Etrophy_Score */ 76/* Etrophy_Score */
79EAPI Etrophy_Score *etrophy_score_new(const char *player_name, int score, int date); 77EAPI Etrophy_Score *etrophy_score_new(const char *player_name, int score);
80EAPI void etrophy_score_free(Etrophy_Score *escore); 78EAPI void etrophy_score_free(Etrophy_Score *escore);
81 79
82EAPI const char *etrophy_score_player_name_get(const Etrophy_Score *escore); 80EAPI const char *etrophy_score_player_name_get(const Etrophy_Score *escore);
83EAPI int etrophy_score_score_get(const Etrophy_Score *escore); 81EAPI int etrophy_score_score_get(const Etrophy_Score *escore);
84EAPI int etrophy_score_date_get(const Etrophy_Score *escore); 82EAPI unsigned int etrophy_score_date_get(const Etrophy_Score *escore);
85 83
86/* Etrophy_Level */ 84/* Etrophy_Level */
87EAPI Etrophy_Level *etrophy_level_new(const char *name); 85EAPI Etrophy_Level *etrophy_level_new(const char *name);
@@ -122,7 +120,7 @@ EAPI void etrophy_gamescore_clear(Etrophy_Gamescore *gamescore);
122 120
123EAPI int etrophy_gamescore_level_hi_score_get(const Etrophy_Gamescore *gamescore, const char *level_name); 121EAPI int etrophy_gamescore_level_hi_score_get(const Etrophy_Gamescore *gamescore, const char *level_name);
124EAPI int etrophy_gamescore_level_low_score_get(const Etrophy_Gamescore *gamescore, const char *level_name); 122EAPI int etrophy_gamescore_level_low_score_get(const Etrophy_Gamescore *gamescore, const char *level_name);
125EAPI Etrophy_Score *etrophy_gamescore_level_score_add(Etrophy_Gamescore *gamescore, const char *level_name, const char *player_name, int score, int date); 123EAPI Etrophy_Score *etrophy_gamescore_level_score_add(Etrophy_Gamescore *gamescore, const char *level_name, const char *player_name, int score);
126 124
127/* Layouts */ 125/* Layouts */
128EAPI Evas_Object *etrophy_score_layout_add(Evas_Object *parent, Etrophy_Gamescore *gamescore); 126EAPI Evas_Object *etrophy_score_layout_add(Evas_Object *parent, Etrophy_Gamescore *gamescore);
diff --git a/src/lib/etrophy.c b/src/lib/etrophy.c
index b2c6829..586aa86 100644
--- a/src/lib/etrophy.c
+++ b/src/lib/etrophy.c
@@ -8,6 +8,7 @@
8#include <sys/types.h> 8#include <sys/types.h>
9#include <unistd.h> 9#include <unistd.h>
10 10
11#include <Ecore.h>
11#include <Ecore_File.h> 12#include <Ecore_File.h>
12#include <Eet.h> 13#include <Eet.h>
13#include <Eina.h> 14#include <Eina.h>
@@ -51,21 +52,21 @@ struct _Etrophy_Trophy
51 const char *name; 52 const char *name;
52 const char *description; 53 const char *description;
53 Etrophy_Trophy_State state; 54 Etrophy_Trophy_State state;
54 int date; 55 unsigned int date;
55}; 56};
56 57
57struct _Etrophy_Lock 58struct _Etrophy_Lock
58{ 59{
59 const char *name; 60 const char *name;
60 Etrophy_Lock_State state; 61 Etrophy_Lock_State state;
61 int date; 62 unsigned int date;
62}; 63};
63 64
64struct _Etrophy_Score 65struct _Etrophy_Score
65{ 66{
66 const char *player_name; 67 const char *player_name;
67 int score; 68 int score;
68 int date; 69 unsigned int date;
69}; 70};
70 71
71struct _Etrophy_Level 72struct _Etrophy_Level
@@ -107,7 +108,7 @@ _trophy_init(void)
107 EET_DATA_DESCRIPTOR_ADD_BASIC(_trophy_descriptor, Etrophy_Trophy, 108 EET_DATA_DESCRIPTOR_ADD_BASIC(_trophy_descriptor, Etrophy_Trophy,
108 "state", state, EET_T_UINT); 109 "state", state, EET_T_UINT);
109 EET_DATA_DESCRIPTOR_ADD_BASIC(_trophy_descriptor, Etrophy_Trophy, 110 EET_DATA_DESCRIPTOR_ADD_BASIC(_trophy_descriptor, Etrophy_Trophy,
110 "date", date, EET_T_INT); 111 "date", date, EET_T_UINT);
111} 112}
112 113
113static inline void 114static inline void
@@ -119,7 +120,7 @@ _trophy_shutdown(void)
119} 120}
120 121
121EAPI Etrophy_Trophy * 122EAPI Etrophy_Trophy *
122etrophy_trophy_new(const char *name, const char *description, Etrophy_Trophy_State state, int date) 123etrophy_trophy_new(const char *name, const char *description, Etrophy_Trophy_State state)
123{ 124{
124 Etrophy_Trophy *trophy = calloc(1, sizeof(Etrophy_Trophy)); 125 Etrophy_Trophy *trophy = calloc(1, sizeof(Etrophy_Trophy));
125 126
@@ -132,7 +133,7 @@ etrophy_trophy_new(const char *name, const char *description, Etrophy_Trophy_Sta
132 trophy->name = eina_stringshare_add(name); 133 trophy->name = eina_stringshare_add(name);
133 trophy->description = eina_stringshare_add(description); 134 trophy->description = eina_stringshare_add(description);
134 trophy->state = state; 135 trophy->state = state;
135 trophy->date = date; 136 trophy->date = (unsigned int) ecore_time_get();
136 137
137 return trophy; 138 return trophy;
138} 139}
@@ -169,21 +170,15 @@ etrophy_trophy_state_set(Etrophy_Trophy *trophy, Etrophy_Trophy_State state)
169 EINA_SAFETY_ON_NULL_RETURN(trophy); 170 EINA_SAFETY_ON_NULL_RETURN(trophy);
170 if (state >= ETROPHY_TROPHY_STATE_LAST_VALUE) return; 171 if (state >= ETROPHY_TROPHY_STATE_LAST_VALUE) return;
171 trophy->state = state; 172 trophy->state = state;
173 trophy->date = (unsigned int) ecore_time_get();
172} 174}
173 175
174EAPI inline int 176EAPI inline unsigned int
175etrophy_trophy_date_get(const Etrophy_Trophy *trophy) 177etrophy_trophy_date_get(const Etrophy_Trophy *trophy)
176{ 178{
177 return trophy->date; 179 return trophy->date;
178} 180}
179 181
180EAPI inline void
181etrophy_trophy_date_set(Etrophy_Trophy *trophy, int date)
182{
183 EINA_SAFETY_ON_NULL_RETURN(trophy);
184 trophy->date = date;
185}
186
187static inline void 182static inline void
188_lock_init(void) 183_lock_init(void)
189{ 184{
@@ -199,7 +194,7 @@ _lock_init(void)
199 EET_DATA_DESCRIPTOR_ADD_BASIC(_lock_descriptor, Etrophy_Lock, "state", 194 EET_DATA_DESCRIPTOR_ADD_BASIC(_lock_descriptor, Etrophy_Lock, "state",
200 state, EET_T_UINT); 195 state, EET_T_UINT);
201 EET_DATA_DESCRIPTOR_ADD_BASIC(_lock_descriptor, Etrophy_Lock, "date", 196 EET_DATA_DESCRIPTOR_ADD_BASIC(_lock_descriptor, Etrophy_Lock, "date",
202 date, EET_T_INT); 197 date, EET_T_UINT);
203} 198}
204 199
205static inline void 200static inline void
@@ -211,7 +206,7 @@ _lock_shutdown(void)
211} 206}
212 207
213EAPI Etrophy_Lock * 208EAPI Etrophy_Lock *
214etrophy_lock_new(const char *name, Etrophy_Lock_State state, int date) 209etrophy_lock_new(const char *name, Etrophy_Lock_State state)
215{ 210{
216 Etrophy_Lock *lock = calloc(1, sizeof(Etrophy_Lock)); 211 Etrophy_Lock *lock = calloc(1, sizeof(Etrophy_Lock));
217 212
@@ -223,7 +218,7 @@ etrophy_lock_new(const char *name, Etrophy_Lock_State state, int date)
223 218
224 lock->name = eina_stringshare_add(name); 219 lock->name = eina_stringshare_add(name);
225 lock->state = state; 220 lock->state = state;
226 lock->date = date; 221 lock->date = (unsigned int) ecore_time_get();
227 222
228 return lock; 223 return lock;
229} 224}
@@ -253,21 +248,15 @@ etrophy_lock_state_set(Etrophy_Lock *lock, Etrophy_Lock_State state)
253 EINA_SAFETY_ON_NULL_RETURN(lock); 248 EINA_SAFETY_ON_NULL_RETURN(lock);
254 if (state >= ETROPHY_LOCK_STATE_LAST_VALUE) return; 249 if (state >= ETROPHY_LOCK_STATE_LAST_VALUE) return;
255 lock->state = state; 250 lock->state = state;
251 lock->date = (unsigned int) ecore_time_get();
256} 252}
257 253
258EAPI inline int 254EAPI inline unsigned int
259etrophy_lock_date_get(const Etrophy_Lock *lock) 255etrophy_lock_date_get(const Etrophy_Lock *lock)
260{ 256{
261 return lock->date; 257 return lock->date;
262} 258}
263 259
264EAPI inline void
265etrophy_lock_date_set(Etrophy_Lock *lock, int date)
266{
267 EINA_SAFETY_ON_NULL_RETURN(lock);
268 lock->date = date;
269}
270
271static inline void 260static inline void
272_score_init(void) 261_score_init(void)
273{ 262{
@@ -283,7 +272,7 @@ _score_init(void)
283 EET_DATA_DESCRIPTOR_ADD_BASIC(_score_descriptor, Etrophy_Score, 272 EET_DATA_DESCRIPTOR_ADD_BASIC(_score_descriptor, Etrophy_Score,
284 "score", score, EET_T_INT); 273 "score", score, EET_T_INT);
285 EET_DATA_DESCRIPTOR_ADD_BASIC(_score_descriptor, Etrophy_Score, 274 EET_DATA_DESCRIPTOR_ADD_BASIC(_score_descriptor, Etrophy_Score,
286 "date", date, EET_T_INT); 275 "date", date, EET_T_UINT);
287} 276}
288 277
289static inline void 278static inline void
@@ -295,7 +284,7 @@ _score_shutdown(void)
295} 284}
296 285
297EAPI Etrophy_Score * 286EAPI Etrophy_Score *
298etrophy_score_new(const char *player_name, int score, int date) 287etrophy_score_new(const char *player_name, int score)
299{ 288{
300 Etrophy_Score *escore = calloc(1, sizeof(Etrophy_Score)); 289 Etrophy_Score *escore = calloc(1, sizeof(Etrophy_Score));
301 290
@@ -307,7 +296,7 @@ etrophy_score_new(const char *player_name, int score, int date)
307 296
308 escore->player_name = eina_stringshare_add(player_name); 297 escore->player_name = eina_stringshare_add(player_name);
309 escore->score = score; 298 escore->score = score;
310 escore->date = date; 299 escore->date = (unsigned int) ecore_time_get();
311 300
312 DBG("Score created. Player: %s, score: %i", player_name, score); 301 DBG("Score created. Player: %s, score: %i", player_name, score);
313 302
@@ -333,7 +322,7 @@ etrophy_score_score_get(const Etrophy_Score *escore)
333 return escore->score; 322 return escore->score;
334} 323}
335 324
336EAPI inline int 325EAPI inline unsigned int
337etrophy_score_date_get(const Etrophy_Score *escore) 326etrophy_score_date_get(const Etrophy_Score *escore)
338{ 327{
339 return escore->date; 328 return escore->date;
@@ -731,13 +720,13 @@ etrophy_gamescore_level_low_score_get(const Etrophy_Gamescore *gamescore, const
731} 720}
732 721
733EAPI Etrophy_Score * 722EAPI Etrophy_Score *
734etrophy_gamescore_level_score_add(Etrophy_Gamescore *gamescore, const char *level_name, const char *player_name, int score, int date) 723etrophy_gamescore_level_score_add(Etrophy_Gamescore *gamescore, const char *level_name, const char *player_name, int score)
735{ 724{
736 Etrophy_Score *escore; 725 Etrophy_Score *escore;
737 Etrophy_Level *level; 726 Etrophy_Level *level;
738 Eina_List *l; 727 Eina_List *l;
739 728
740 escore = etrophy_score_new(player_name, score, date); 729 escore = etrophy_score_new(player_name, score);
741 if (!escore) return NULL; 730 if (!escore) return NULL;
742 731
743 EINA_LIST_FOREACH(gamescore->levels, l, level) 732 EINA_LIST_FOREACH(gamescore->levels, l, level)
diff --git a/src/lib/etrophy_layouts.c b/src/lib/etrophy_layouts.c
index 932e184..a5fe188 100644
--- a/src/lib/etrophy_layouts.c
+++ b/src/lib/etrophy_layouts.c
@@ -63,8 +63,9 @@ EAPI Evas_Object *
63etrophy_score_layout_add(Evas_Object *parent, Etrophy_Gamescore *gamescore) 63etrophy_score_layout_add(Evas_Object *parent, Etrophy_Gamescore *gamescore)
64{ 64{
65 Evas_Object *layout, *spinner, *genlist; 65 Evas_Object *layout, *spinner, *genlist;
66 Eina_List *levels, *l; 66 const Eina_List *levels;
67 Etrophy_Level *level; 67 Etrophy_Level *level;
68 Eina_List *l;
68 int i = 0; 69 int i = 0;
69 70
70 layout = elm_layout_add(parent); 71 layout = elm_layout_add(parent);