summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsongwon0.lee <songwon0.lee@samsung.com>2013-10-07 10:41:05 +0900
committersongwon0.lee <songwon0.lee@samsung.com>2013-10-07 10:41:05 +0900
commit7c6842aba1c637026929b8d2e6bdd81d647647e5 (patch)
treecfc8672f92c871d15ea652e1c04c4026134b3c72
parent3f01e2d064d90a4436f7e24a3f36ae5b58e881b7 (diff)
added timeattack mode
-rw-r--r--data/edc/layout.edc4
-rw-r--r--src/cell_manager.c2
-rw-r--r--src/main.c93
3 files changed, 90 insertions, 9 deletions
diff --git a/data/edc/layout.edc b/data/edc/layout.edc
index f8bfe05..8804894 100644
--- a/data/edc/layout.edc
+++ b/data/edc/layout.edc
@@ -37,8 +37,8 @@ group { name: "layout";
37 } 37 }
38 part { name: "ready_menu"; type: SWALLOW; 38 part { name: "ready_menu"; type: SWALLOW;
39 description { state: "default" 0.0; 39 description { state: "default" 0.0;
40 rel1.relative: 0 0; 40 rel1.relative: 0 0;
41 rel2.relative: 1 1; 41 rel2.relative: 1 1;
42 visible: 1; 42 visible: 1;
43 } 43 }
44 description { state: "ingame" 0.0; 44 description { state: "ingame" 0.0;
diff --git a/src/cell_manager.c b/src/cell_manager.c
index 0c2696a..111fddb 100644
--- a/src/cell_manager.c
+++ b/src/cell_manager.c
@@ -334,7 +334,7 @@ _cell_mouse_move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
334} 334}
335 335
336void 336void
337cell_table_shake(void) 337cell_table_shuffle(void)
338{ 338{
339 Cell_Info *cell_info; 339 Cell_Info *cell_info;
340 int i = 0, j = 0; 340 int i = 0, j = 0;
diff --git a/src/main.c b/src/main.c
index 2fb7232..6adc145 100644
--- a/src/main.c
+++ b/src/main.c
@@ -2,12 +2,61 @@
2 2
3#include "cell.h" 3#include "cell.h"
4 4
5//static Timer *game_timer; 5static Ecore_Timer *game_timer;
6static Evas_Object *win;
7static Evas_Object *progress_bar;
6 8
9static void _retry_game();
7static void 10static void
8_on_shake(void *data, Evas_Object *obj, void *ev) 11_on_retry_ok(void *data, Evas_Object *obj, void *ev)
9{ 12{
10 cell_table_shake(); 13 _retry_game();
14 evas_object_del(data);
15}
16
17static void
18_on_retry_cancel(void *data, Evas_Object *obj, void *ev)
19{
20 evas_object_del(data);
21 elm_exit();
22}
23
24static Eina_Bool
25_time_set(void* data)
26{
27 double progress = elm_progressbar_value_get(progress_bar);
28 if (progress > 0.0)
29 {
30 progress -= 1.0/60.0 * 0.1;
31 elm_progressbar_value_set(progress_bar, progress);
32 }
33 else
34 {
35 Evas_Object *popup = elm_popup_add(win);
36 elm_object_text_set(popup, "retry??");
37 elm_object_part_text_set(popup, "title,text", "Time Over");
38
39 Evas_Object *btn1 = elm_button_add(popup);
40 elm_object_text_set(btn1, "OK");
41 elm_object_part_content_set(popup, "button1", btn1);
42 evas_object_smart_callback_add(btn1, "clicked", _on_retry_ok, popup);
43
44 Evas_Object *btn2 = elm_button_add(popup);
45 elm_object_text_set(btn2, "Cancel");
46 elm_object_part_content_set(popup, "button2", btn2);
47 evas_object_smart_callback_add(btn2, "clicked", _on_retry_cancel, popup);
48
49 evas_object_show(popup);
50 return ECORE_CALLBACK_CANCEL;
51 }
52
53 return ECORE_CALLBACK_RENEW;
54}
55
56static void
57_on_shuffle(void *data, Evas_Object *obj, void *ev)
58{
59 cell_table_shuffle();
11} 60}
12 61
13static void 62static void
@@ -15,6 +64,7 @@ _on_start(void *layout, Evas_Object *obj, void *ev)
15{ 64{
16 elm_object_signal_emit(layout, "set ingame", ""); 65 elm_object_signal_emit(layout, "set ingame", "");
17 cell_table_init(layout); 66 cell_table_init(layout);
67 game_timer = ecore_timer_add(0.1, _time_set, NULL);
18} 68}
19 69
20static void 70static void
@@ -25,13 +75,36 @@ _on_style_selected(void *data, Evas_Object *obj, void *ev)
25 cell_style_set(name); 75 cell_style_set(name);
26} 76}
27 77
78static void
79_retry_game()
80{
81 elm_progressbar_value_set(progress_bar, 1);
82 game_timer = ecore_timer_add(0.1, _time_set, NULL);
83 cell_table_shuffle();
84}
85
86static char*
87_progress_format_cb(double val)
88{
89 char buf[3];
90 if (sprintf(buf, "%.f", 60.0 * val) > 0)
91 return strdup(buf);
92 return NULL;
93}
94
95static void
96_progress_format_free(char *str)
97{
98 free(str);
99}
100
28EAPI_MAIN int 101EAPI_MAIN int
29elm_main(int argc, char **argv) 102elm_main(int argc, char **argv)
30{ 103{
31 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED); 104 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
32 elm_theme_extension_add(NULL, "./data/edc/cell_button.edj"); 105 elm_theme_extension_add(NULL, "./data/edc/cell_button.edj");
33 106
34 Evas_Object *win = elm_win_util_standard_add("e-jeweled", "e-jeweled"); 107 win = elm_win_util_standard_add("e-jeweled", "e-jeweled");
35 elm_win_autodel_set(win, EINA_TRUE); 108 elm_win_autodel_set(win, EINA_TRUE);
36 evas_object_resize(win, 400, 600); 109 evas_object_resize(win, 400, 600);
37 evas_object_show(win); 110 evas_object_show(win);
@@ -74,8 +147,8 @@ elm_main(int argc, char **argv)
74 elm_box_pack_end(box, btn); 147 elm_box_pack_end(box, btn);
75 148
76 btn = elm_button_add(win); 149 btn = elm_button_add(win);
77 elm_object_text_set(btn, "SHAKE"); 150 elm_object_text_set(btn, "Shuffle");
78 evas_object_smart_callback_add(btn, "clicked", _on_shake, NULL); 151 evas_object_smart_callback_add(btn, "clicked", _on_shuffle, NULL);
79 evas_object_show(btn); 152 evas_object_show(btn);
80 elm_box_pack_end(box, btn); 153 elm_box_pack_end(box, btn);
81 154
@@ -84,8 +157,16 @@ elm_main(int argc, char **argv)
84 evas_object_show(box); 157 evas_object_show(box);
85 158
86 Evas_Object *pb = elm_progressbar_add(win); 159 Evas_Object *pb = elm_progressbar_add(win);
160 elm_object_text_set(pb, "Left Time : ");
161 elm_progressbar_value_set(pb, 1.0);
162 elm_progressbar_unit_format_function_set(pb,
163 _progress_format_cb,
164 _progress_format_free);
165 evas_object_size_hint_weight_set(pb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
166 evas_object_size_hint_align_set(pb, EVAS_HINT_FILL, EVAS_HINT_FILL);
87 elm_box_pack_end(box, pb); 167 elm_box_pack_end(box, pb);
88 evas_object_show(pb); 168 evas_object_show(pb);
169 progress_bar = pb;
89 170
90 elm_run(); 171 elm_run();
91 elm_shutdown(); 172 elm_shutdown();