From: Enlightenment S. <no-...@en...> - 2012-10-10 21:50:11
|
Log: etrophy: set date field internally Instead of leaving this task to the library user. Author: bdilly Date: 2012-10-10 14:50:04 -0700 (Wed, 10 Oct 2012) New Revision: 77823 Trac: http://trac.enlightenment.org/e/changeset/77823 Modified: trunk/PROTO/etrophy/configure.ac trunk/PROTO/etrophy/src/lib/Etrophy.h trunk/PROTO/etrophy/src/lib/etrophy.c trunk/PROTO/etrophy/src/lib/etrophy_layouts.c Modified: trunk/PROTO/etrophy/configure.ac =================================================================== --- trunk/PROTO/etrophy/configure.ac 2012-10-10 21:49:59 UTC (rev 77822) +++ trunk/PROTO/etrophy/configure.ac 2012-10-10 21:50:04 UTC (rev 77823) @@ -124,6 +124,7 @@ 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 ]) @@ -140,7 +141,7 @@ ],[edje_cc=$(pkg-config --variable=prefix edje)/bin/edje_cc]) AC_SUBST(edje_cc) -requirement_etrophy="elementary >= 1.7.0 evas >= 1.7.0 ecore-file >= 1.7.0 eet >= 1.7.0 eina >= 1.7.0 ${requirement_etrophy}" +requirement_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}" ### Checks for header files AC_CHECK_HEADERS([locale.h sys/resource.h]) Modified: trunk/PROTO/etrophy/src/lib/Etrophy.h =================================================================== --- trunk/PROTO/etrophy/src/lib/Etrophy.h 2012-10-10 21:49:59 UTC (rev 77822) +++ trunk/PROTO/etrophy/src/lib/Etrophy.h 2012-10-10 21:50:04 UTC (rev 77823) @@ -55,33 +55,31 @@ typedef struct _Etrophy_Gamescore Etrophy_Gamescore; /* Etrophy_Trophy */ -EAPI Etrophy_Trophy *etrophy_trophy_new(const char *name, const char *description, Etrophy_Trophy_State state, int date); +EAPI Etrophy_Trophy *etrophy_trophy_new(const char *name, const char *description, Etrophy_Trophy_State state); EAPI void etrophy_trophy_free(Etrophy_Trophy *trophy); EAPI const char *etrophy_trophy_name_get(const Etrophy_Trophy *trophy); EAPI const char *etrophy_trophy_description_get(const Etrophy_Trophy *trophy); EAPI void etrophy_trophy_state_set(Etrophy_Trophy *trophy, Etrophy_Trophy_State state); EAPI Etrophy_Trophy_State etrophy_trophy_state_get(const Etrophy_Trophy *trophy); -EAPI void etrophy_trophy_date_set(Etrophy_Trophy *trophy, int date); -EAPI int etrophy_trophy_date_get(const Etrophy_Trophy *trophy); +EAPI unsigned int etrophy_trophy_date_get(const Etrophy_Trophy *trophy); /* Etrophy_Lock */ -EAPI Etrophy_Lock *etrophy_lock_new(const char *name, Etrophy_Lock_State state, int date); +EAPI Etrophy_Lock *etrophy_lock_new(const char *name, Etrophy_Lock_State state); EAPI void etrophy_lock_free(Etrophy_Lock *lock); EAPI const char *etrophy_lock_name_get(const Etrophy_Lock *lock); EAPI void etrophy_lock_state_set(Etrophy_Lock *lock, Etrophy_Lock_State state); EAPI Etrophy_Lock_State etrophy_lock_state_get(const Etrophy_Lock *lock); -EAPI void etrophy_lock_date_set(Etrophy_Lock *lock, int date); -EAPI int etrophy_lock_date_get(const Etrophy_Lock *lock); +EAPI unsigned int etrophy_lock_date_get(const Etrophy_Lock *lock); /* Etrophy_Score */ -EAPI Etrophy_Score *etrophy_score_new(const char *player_name, int score, int date); +EAPI Etrophy_Score *etrophy_score_new(const char *player_name, int score); EAPI void etrophy_score_free(Etrophy_Score *escore); EAPI const char *etrophy_score_player_name_get(const Etrophy_Score *escore); EAPI int etrophy_score_score_get(const Etrophy_Score *escore); -EAPI int etrophy_score_date_get(const Etrophy_Score *escore); +EAPI unsigned int etrophy_score_date_get(const Etrophy_Score *escore); /* Etrophy_Level */ EAPI Etrophy_Level *etrophy_level_new(const char *name); @@ -122,7 +120,7 @@ EAPI int etrophy_gamescore_level_hi_score_get(const Etrophy_Gamescore *gamescore, const char *level_name); EAPI int etrophy_gamescore_level_low_score_get(const Etrophy_Gamescore *gamescore, const char *level_name); -EAPI Etrophy_Score *etrophy_gamescore_level_score_add(Etrophy_Gamescore *gamescore, const char *level_name, const char *player_name, int score, int date); +EAPI Etrophy_Score *etrophy_gamescore_level_score_add(Etrophy_Gamescore *gamescore, const char *level_name, const char *player_name, int score); /* Layouts */ EAPI Evas_Object *etrophy_score_layout_add(Evas_Object *parent, Etrophy_Gamescore *gamescore); Modified: trunk/PROTO/etrophy/src/lib/etrophy.c =================================================================== --- trunk/PROTO/etrophy/src/lib/etrophy.c 2012-10-10 21:49:59 UTC (rev 77822) +++ trunk/PROTO/etrophy/src/lib/etrophy.c 2012-10-10 21:50:04 UTC (rev 77823) @@ -8,6 +8,7 @@ #include <sys/types.h> #include <unistd.h> +#include <Ecore.h> #include <Ecore_File.h> #include <Eet.h> #include <Eina.h> @@ -51,21 +52,21 @@ const char *name; const char *description; Etrophy_Trophy_State state; - int date; + unsigned int date; }; struct _Etrophy_Lock { const char *name; Etrophy_Lock_State state; - int date; + unsigned int date; }; struct _Etrophy_Score { const char *player_name; int score; - int date; + unsigned int date; }; struct _Etrophy_Level @@ -107,7 +108,7 @@ EET_DATA_DESCRIPTOR_ADD_BASIC(_trophy_descriptor, Etrophy_Trophy, "state", state, EET_T_UINT); EET_DATA_DESCRIPTOR_ADD_BASIC(_trophy_descriptor, Etrophy_Trophy, - "date", date, EET_T_INT); + "date", date, EET_T_UINT); } static inline void @@ -119,7 +120,7 @@ } EAPI Etrophy_Trophy * -etrophy_trophy_new(const char *name, const char *description, Etrophy_Trophy_State state, int date) +etrophy_trophy_new(const char *name, const char *description, Etrophy_Trophy_State state) { Etrophy_Trophy *trophy = calloc(1, sizeof(Etrophy_Trophy)); @@ -132,7 +133,7 @@ trophy->name = eina_stringshare_add(name); trophy->description = eina_stringshare_add(description); trophy->state = state; - trophy->date = date; + trophy->date = (unsigned int) ecore_time_get(); return trophy; } @@ -169,21 +170,15 @@ EINA_SAFETY_ON_NULL_RETURN(trophy); if (state >= ETROPHY_TROPHY_STATE_LAST_VALUE) return; trophy->state = state; + trophy->date = (unsigned int) ecore_time_get(); } -EAPI inline int +EAPI inline unsigned int etrophy_trophy_date_get(const Etrophy_Trophy *trophy) { return trophy->date; } -EAPI inline void -etrophy_trophy_date_set(Etrophy_Trophy *trophy, int date) -{ - EINA_SAFETY_ON_NULL_RETURN(trophy); - trophy->date = date; -} - static inline void _lock_init(void) { @@ -199,7 +194,7 @@ EET_DATA_DESCRIPTOR_ADD_BASIC(_lock_descriptor, Etrophy_Lock, "state", state, EET_T_UINT); EET_DATA_DESCRIPTOR_ADD_BASIC(_lock_descriptor, Etrophy_Lock, "date", - date, EET_T_INT); + date, EET_T_UINT); } static inline void @@ -211,7 +206,7 @@ } EAPI Etrophy_Lock * -etrophy_lock_new(const char *name, Etrophy_Lock_State state, int date) +etrophy_lock_new(const char *name, Etrophy_Lock_State state) { Etrophy_Lock *lock = calloc(1, sizeof(Etrophy_Lock)); @@ -223,7 +218,7 @@ lock->name = eina_stringshare_add(name); lock->state = state; - lock->date = date; + lock->date = (unsigned int) ecore_time_get(); return lock; } @@ -253,21 +248,15 @@ EINA_SAFETY_ON_NULL_RETURN(lock); if (state >= ETROPHY_LOCK_STATE_LAST_VALUE) return; lock->state = state; + lock->date = (unsigned int) ecore_time_get(); } -EAPI inline int +EAPI inline unsigned int etrophy_lock_date_get(const Etrophy_Lock *lock) { return lock->date; } -EAPI inline void -etrophy_lock_date_set(Etrophy_Lock *lock, int date) -{ - EINA_SAFETY_ON_NULL_RETURN(lock); - lock->date = date; -} - static inline void _score_init(void) { @@ -283,7 +272,7 @@ EET_DATA_DESCRIPTOR_ADD_BASIC(_score_descriptor, Etrophy_Score, "score", score, EET_T_INT); EET_DATA_DESCRIPTOR_ADD_BASIC(_score_descriptor, Etrophy_Score, - "date", date, EET_T_INT); + "date", date, EET_T_UINT); } static inline void @@ -295,7 +284,7 @@ } EAPI Etrophy_Score * -etrophy_score_new(const char *player_name, int score, int date) +etrophy_score_new(const char *player_name, int score) { Etrophy_Score *escore = calloc(1, sizeof(Etrophy_Score)); @@ -307,7 +296,7 @@ escore->player_name = eina_stringshare_add(player_name); escore->score = score; - escore->date = date; + escore->date = (unsigned int) ecore_time_get(); DBG("Score created. Player: %s, score: %i", player_name, score); @@ -333,7 +322,7 @@ return escore->score; } -EAPI inline int +EAPI inline unsigned int etrophy_score_date_get(const Etrophy_Score *escore) { return escore->date; @@ -731,13 +720,13 @@ } EAPI Etrophy_Score * -etrophy_gamescore_level_score_add(Etrophy_Gamescore *gamescore, const char *level_name, const char *player_name, int score, int date) +etrophy_gamescore_level_score_add(Etrophy_Gamescore *gamescore, const char *level_name, const char *player_name, int score) { Etrophy_Score *escore; Etrophy_Level *level; Eina_List *l; - escore = etrophy_score_new(player_name, score, date); + escore = etrophy_score_new(player_name, score); if (!escore) return NULL; EINA_LIST_FOREACH(gamescore->levels, l, level) Modified: trunk/PROTO/etrophy/src/lib/etrophy_layouts.c =================================================================== --- trunk/PROTO/etrophy/src/lib/etrophy_layouts.c 2012-10-10 21:49:59 UTC (rev 77822) +++ trunk/PROTO/etrophy/src/lib/etrophy_layouts.c 2012-10-10 21:50:04 UTC (rev 77823) @@ -63,8 +63,9 @@ etrophy_score_layout_add(Evas_Object *parent, Etrophy_Gamescore *gamescore) { Evas_Object *layout, *spinner, *genlist; - Eina_List *levels, *l; + const Eina_List *levels; Etrophy_Level *level; + Eina_List *l; int i = 0; layout = elm_layout_add(parent); |