summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHermet Park <hermet@hermet.pe.kr>2016-02-13 13:16:11 +0900
committerHermet Park <hermet@hermet.pe.kr>2016-02-13 13:16:11 +0900
commit218fbed02ffbc9ffe933373ec21c6519bf138d57 (patch)
treec8887ff0b67835977d973e6f254769dd6cfa3ac6
parentd35dba63e11c1205aa74d0b3142d217f088f8473 (diff)
support large text
-rw-r--r--src/bin/etypers.c52
1 files changed, 37 insertions, 15 deletions
diff --git a/src/bin/etypers.c b/src/bin/etypers.c
index 076a1af..8219f3c 100644
--- a/src/bin/etypers.c
+++ b/src/bin/etypers.c
@@ -9,6 +9,8 @@
9#define WALL_COLOR 100, 100, 100, 170 9#define WALL_COLOR 100, 100, 100, 170
10#define MINUS_SCORE 25 10#define MINUS_SCORE 25
11#define ITEM_TIME 55 11#define ITEM_TIME 55
12#define LARGE_TEXT_SCALE 1.15
13#define DEFAULT_TEXT_SCALE 1
12 14
13typedef enum _GameState 15typedef enum _GameState
14{ 16{
@@ -31,6 +33,7 @@ typedef struct _AppData
31 long score; 33 long score;
32 float hit_cnt; 34 float hit_cnt;
33 float hit_try_cnt; 35 float hit_try_cnt;
36 float text_scale;
34 unsigned long combo; 37 unsigned long combo;
35 Evas_Coord bound_w; 38 Evas_Coord bound_w;
36 Evas_Coord bound_h; 39 Evas_Coord bound_h;
@@ -41,7 +44,8 @@ typedef struct _AppData
41 Evas_Object *entry; 44 Evas_Object *entry;
42 Evas_Object *table; 45 Evas_Object *table;
43 Evas_Object *popup; 46 Evas_Object *popup;
44 Evas_Object *check; 47 Evas_Object *item_check;
48 Evas_Object *text_check;
45 GameState state; 49 GameState state;
46 Ecore_Timer *timer; 50 Ecore_Timer *timer;
47 Ecore_Animator *animator; 51 Ecore_Animator *animator;
@@ -116,12 +120,14 @@ remove_all_enemies(AppData *appdata)
116 120
117static Enemy * 121static Enemy *
118enemy_new(Evas_Object *parent, const char *str, Evas_Coord x, Evas_Coord y, 122enemy_new(Evas_Object *parent, const char *str, Evas_Coord x, Evas_Coord y,
119 Evas_Coord max_w, Evas_Coord max_h, Eina_Bool item) 123 Evas_Coord max_w, Evas_Coord max_h, float text_scale, Eina_Bool item)
120{ 124{
121 Enemy *enemy = calloc(1, sizeof(Enemy)); 125 Enemy *enemy = calloc(1, sizeof(Enemy));
122 if (!enemy) return NULL; 126 if (!enemy) return NULL;
123 127
124 Evas_Object *entry = elm_entry_add(parent); 128 Evas_Object *entry = elm_entry_add(parent);
129 elm_object_scale_set(entry, text_scale);
130
125 if (!entry) 131 if (!entry)
126 { 132 {
127 free(enemy); 133 free(enemy);
@@ -173,9 +179,12 @@ enemy_add(AppData *appdata)
173{ 179{
174 unsigned int words_cnt = eina_array_count(appdata->words_array); 180 unsigned int words_cnt = eina_array_count(appdata->words_array);
175 char *word = eina_array_data_get(appdata->words_array,(rand() % words_cnt)); 181 char *word = eina_array_data_get(appdata->words_array,(rand() % words_cnt));
182
176 Enemy *enemy = enemy_new(appdata->bx, word, 183 Enemy *enemy = enemy_new(appdata->bx, word,
177 (rand() % appdata->bound_w), 0, appdata->bound_w, 184 (rand() % appdata->bound_w), 0, appdata->bound_w,
178 appdata->bound_h, appdata->item_time); 185 appdata->bound_h, appdata->text_scale,
186 appdata->item_time);
187
179 appdata->item_time = EINA_FALSE; 188 appdata->item_time = EINA_FALSE;
180 appdata->enemies = eina_inlist_append(appdata->enemies, 189 appdata->enemies = eina_inlist_append(appdata->enemies,
181 (Eina_Inlist *) enemy); 190 (Eina_Inlist *) enemy);
@@ -680,7 +689,11 @@ game_level_cb(void *data, Evas_Object *obj, void *event_info)
680{ 689{
681 AppData *appdata = evas_object_data_get(obj, "appdata"); 690 AppData *appdata = evas_object_data_get(obj, "appdata");
682 691
683 appdata->item = elm_check_state_get(appdata->check); 692 appdata->item = elm_check_state_get(appdata->item_check);
693 if (elm_check_state_get(appdata->text_check))
694 appdata->text_scale = LARGE_TEXT_SCALE;
695 else
696 appdata->text_scale = DEFAULT_TEXT_SCALE;
684 697
685 evas_object_del(appdata->popup); 698 evas_object_del(appdata->popup);
686 appdata->popup = NULL; 699 appdata->popup = NULL;
@@ -754,17 +767,28 @@ game_start_cb(void *data, Evas_Object *obj, void *event_info)
754 elm_box_pack_end(box, list); 767 elm_box_pack_end(box, list);
755 768
756 //Item 769 //Item
757 Evas_Object *check = elm_check_add(box); 770 Evas_Object *item_check = elm_check_add(box);
758 elm_check_state_set(check, EINA_TRUE); 771 evas_object_size_hint_weight_set(item_check, EVAS_HINT_EXPAND, 0);
759 elm_object_text_set(check, "Random Item"); 772 evas_object_size_hint_align_set(item_check, 0, 0);
760 evas_object_show(check); 773 elm_check_state_set(item_check, EINA_TRUE);
761 elm_box_pack_end(box, check); 774 elm_object_text_set(item_check, "Random Item");
775 evas_object_show(item_check);
776 elm_box_pack_end(box, item_check);
777
778 //Size
779 Evas_Object *text_check = elm_check_add(box);
780 elm_object_text_set(text_check, "Large Text");
781 evas_object_size_hint_weight_set(text_check, EVAS_HINT_EXPAND, 0);
782 evas_object_size_hint_align_set(text_check, 0, 0);
783 evas_object_show(text_check);
784 elm_box_pack_end(box, text_check);
762 785
763 elm_object_content_set(notify, box); 786 elm_object_content_set(notify, box);
764 evas_object_show(notify); 787 evas_object_show(notify);
765 788
766 appdata->popup = notify; 789 appdata->popup = notify;
767 appdata->check = check; 790 appdata->item_check = item_check;
791 appdata->text_check = text_check;
768} 792}
769 793
770static void 794static void
@@ -1008,17 +1032,15 @@ int elm_main(int argc, char **argv)
1008{ 1032{
1009 srand((unsigned int) time(NULL)); 1033 srand((unsigned int) time(NULL));
1010 1034
1011 AppData *appdata = calloc(1, sizeof(AppData)); 1035 AppData appdata;
1012 if (!appdata) return 0; 1036 memset(&appdata, 0x0, sizeof(AppData));
1013 1037
1014 elm_steup(); 1038 elm_steup();
1015 1039
1016 app_init(appdata); 1040 app_init(&appdata);
1017 1041
1018 elm_run(); 1042 elm_run();
1019 1043
1020 free(appdata);
1021
1022 return 0; 1044 return 0;
1023} 1045}
1024ELM_MAIN() 1046ELM_MAIN()