aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--LuaSL/src/LuaSL.h9
-rw-r--r--LuaSL/src/LuaSL_main.c187
2 files changed, 114 insertions, 82 deletions
diff --git a/LuaSL/src/LuaSL.h b/LuaSL/src/LuaSL.h
index 26547ee..e3b7065 100644
--- a/LuaSL/src/LuaSL.h
+++ b/LuaSL/src/LuaSL.h
@@ -48,11 +48,12 @@ typedef enum
48 48
49typedef struct 49typedef struct
50{ 50{
51 Ecore_Evas *ee; // Our window. 51 Ecore_Evas *ee; // Our window.
52 Evas *canvas; // The canvas for drawing directly onto. 52 Evas *canvas; // The canvas for drawing directly onto.
53 Evas_Object *bg; // Our background edje, also the game specific stuff. 53 Evas_Object *bg; // Our background edje, also the game specific stuff.
54 Evas_Object *edje; // The edje of the background. 54 Evas_Object *edje; // The edje of the background.
55 int logDom; 55 int logDom;
56 boolean ui; // Wether we actually start up the UI.
56} gameGlobals; 57} gameGlobals;
57 58
58 59
diff --git a/LuaSL/src/LuaSL_main.c b/LuaSL/src/LuaSL_main.c
index 2f5e770..efa3d43 100644
--- a/LuaSL/src/LuaSL_main.c
+++ b/LuaSL/src/LuaSL_main.c
@@ -1,11 +1,9 @@
1#include "LuaSL.h" 1#include "LuaSL.h"
2 2
3#define HARNESS 0
4#define LUA_TEST 0 3#define LUA_TEST 0
5 4
6static int scriptCount; 5static int scriptCount;
7 6
8#if HARNESS
9static const char *names[] = 7static const char *names[] =
10{ 8{
11 "bub1", "sh1", 9 "bub1", "sh1",
@@ -70,7 +68,6 @@ _on_delete(Ecore_Evas *ee __UNUSED__)
70{ 68{
71 ecore_main_loop_quit(); 69 ecore_main_loop_quit();
72} 70}
73#endif
74 71
75static void dirList_cb(const char *name, const char *path, void *data) 72static void dirList_cb(const char *name, const char *path, void *data)
76{ 73{
@@ -116,6 +113,8 @@ main(int argc, char **argv)
116{ 113{
117 /* put here any init specific to this app like parsing args etc. */ 114 /* put here any init specific to this app like parsing args etc. */
118 gameGlobals game; 115 gameGlobals game;
116 char *programName = argv[0];
117 boolean badArgs = FALSE;
119 118
120 if (!ecore_evas_init()) 119 if (!ecore_evas_init())
121 return EXIT_FAILURE; 120 return EXIT_FAILURE;
@@ -130,8 +129,43 @@ main(int argc, char **argv)
130 129
131 loggingStartup(&game); 130 loggingStartup(&game);
132 131
132 // get the arguments passed in
133 while (--argc > 0 && *++argv != '\0')
134 {
135 if (*argv[0] == '-')
136 {
137 // point to the characters after the '-' sign
138 char *s = argv[0] + 1;
139
140 switch (*s)
141 {
142 case 'u':
143 {
144 game.ui = TRUE;
145 break;
146 }
147 default:
148 badArgs = TRUE;
149 }
150 }
151 else
152 badArgs = TRUE;
153 }
154
155
156 if (badArgs)
157 {
158 // display the program usage to the user as they have it wrong
159 printf("Usage: %s [-u]\n", programName);
160 printf(" -u: Show the test UI.\n");
161 }
162 else
133// else if ((game.config) && (game.data)) 163// else if ((game.config) && (game.data))
134 { 164 {
165 unsigned int i;
166 Evas_Object *bub, *sh;
167 Ecore_Animator *ani;
168 char *group = "main";
135 char buf[PATH_MAX]; 169 char buf[PATH_MAX];
136 struct timeval lastTime2; 170 struct timeval lastTime2;
137 struct timeval thisTime2; 171 struct timeval thisTime2;
@@ -140,78 +174,75 @@ main(int argc, char **argv)
140 unsigned int lslCount; 174 unsigned int lslCount;
141 float diff0; 175 float diff0;
142#endif 176#endif
143#if HARNESS
144 unsigned int i;
145 char *group = "main";
146 Evas_Object *bub, *sh;
147 Ecore_Animator *ani;
148 177
149 /* this will give you a window with an Evas canvas under the first engine available */ 178 if (game.ui)
150 game.ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
151 if (!game.ee)
152 { 179 {
153 PEm("You got to have at least one evas engine built and linked up to ecore-evas for this example to run properly."); 180 /* this will give you a window with an Evas canvas under the first engine available */
154 edje_shutdown(); 181 game.ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
155 ecore_evas_shutdown(); 182 if (!game.ee)
156 return -1; 183 {
184 PEm("You got to have at least one evas engine built and linked up to ecore-evas for this example to run properly.");
185 edje_shutdown();
186 ecore_evas_shutdown();
187 return -1;
188 }
189 game.canvas = ecore_evas_get(game.ee);
190 ecore_evas_title_set(game.ee, "LuaSL test harness");
191 ecore_evas_show(game.ee);
192
193 game.bg = evas_object_rectangle_add(game.canvas);
194 evas_object_color_set(game.bg, 255, 255, 255, 255); /* white bg */
195 evas_object_move(game.bg, 0, 0); /* at canvas' origin */
196 evas_object_size_hint_weight_set(game.bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
197 evas_object_resize(game.bg, WIDTH, HEIGHT); /* covers full canvas */
198 evas_object_show(game.bg);
199 ecore_evas_object_associate(game.ee, game.bg, ECORE_EVAS_OBJECT_ASSOCIATE_BASE);
200 evas_object_focus_set(game.bg, EINA_TRUE);
201
202 game.edje = edje_object_add(game.canvas);
203 snprintf(buf, sizeof(buf), "%s/%s.edj", PACKAGE_DATA_DIR, "LuaSL");
204 if (!edje_object_file_set(game.edje, buf, group))
205 {
206 int err = edje_object_load_error_get(game.edje);
207 const char *errmsg = edje_load_error_str(err);
208 PEm("Could not load '%s' from %s: %s\n", group, buf, errmsg);
209
210 evas_object_del(game.edje);
211 ecore_evas_free(game.ee);
212 edje_shutdown();
213 ecore_evas_shutdown();
214 return -2;
215 }
216 evas_object_move(game.edje, 0, 0);
217 evas_object_resize(game.edje, WIDTH, HEIGHT);
218 evas_object_show(game.edje);
219
220 snprintf(buf, sizeof(buf), "%s/images/bubble_sh.png", PACKAGE_DATA_DIR);
221 for (i = 0; i < (sizeof(names) / sizeof(char *) / 2); i++)
222 {
223 sh = evas_object_image_filled_add(game.canvas);
224 evas_object_image_file_set(sh, buf, NULL);
225 evas_object_resize(sh, 64, 64);
226 evas_object_show(sh);
227 evas_object_data_set(game.bg, names[(i * 2) + 1], sh);
228 }
229
230 snprintf(buf, sizeof(buf), "%s/images/bubble.png", PACKAGE_DATA_DIR);
231 for (i = 0; i < (sizeof(names) / sizeof(char *) / 2); i++)
232 {
233 bub = evas_object_image_filled_add(game.canvas);
234 evas_object_image_file_set(bub, buf, NULL);
235 evas_object_resize(bub, 64, 64);
236 evas_object_show(bub);
237 evas_object_data_set(game.bg, names[(i * 2)], bub);
238 }
239 ani = ecore_animator_add(anim, &game);
240 evas_object_data_set(game.bg, "animator", ani);
241
242 // Setup our callbacks.
243 ecore_evas_callback_delete_request_set(game.ee, _on_delete);
244 edje_object_signal_callback_add(game.edje, "*", "game_*", _edje_signal_cb, &game);
157 } 245 }
158 game.canvas = ecore_evas_get(game.ee);
159 ecore_evas_title_set(game.ee, "LuaSL test harness");
160 ecore_evas_show(game.ee);
161
162 game.bg = evas_object_rectangle_add(game.canvas);
163 evas_object_color_set(game.bg, 255, 255, 255, 255); /* white bg */
164 evas_object_move(game.bg, 0, 0); /* at canvas' origin */
165 evas_object_size_hint_weight_set(game.bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
166 evas_object_resize(game.bg, WIDTH, HEIGHT); /* covers full canvas */
167 evas_object_show(game.bg);
168 ecore_evas_object_associate(game.ee, game.bg, ECORE_EVAS_OBJECT_ASSOCIATE_BASE);
169 evas_object_focus_set(game.bg, EINA_TRUE);
170
171 game.edje = edje_object_add(game.canvas);
172 snprintf(buf, sizeof(buf), "%s/%s.edj", PACKAGE_DATA_DIR, "LuaSL");
173 if (!edje_object_file_set(game.edje, buf, group))
174 {
175 int err = edje_object_load_error_get(game.edje);
176 const char *errmsg = edje_load_error_str(err);
177 PEm("Could not load '%s' from %s: %s\n", group, buf, errmsg);
178
179 evas_object_del(game.edje);
180 ecore_evas_free(game.ee);
181 edje_shutdown();
182 ecore_evas_shutdown();
183 return -2;
184 }
185 evas_object_move(game.edje, 0, 0);
186 evas_object_resize(game.edje, WIDTH, HEIGHT);
187 evas_object_show(game.edje);
188
189 snprintf(buf, sizeof(buf), "%s/images/bubble_sh.png", PACKAGE_DATA_DIR);
190 for (i = 0; i < (sizeof(names) / sizeof(char *) / 2); i++)
191 {
192 sh = evas_object_image_filled_add(game.canvas);
193 evas_object_image_file_set(sh, buf, NULL);
194 evas_object_resize(sh, 64, 64);
195 evas_object_show(sh);
196 evas_object_data_set(game.bg, names[(i * 2) + 1], sh);
197 }
198
199 snprintf(buf, sizeof(buf), "%s/images/bubble.png", PACKAGE_DATA_DIR);
200 for (i = 0; i < (sizeof(names) / sizeof(char *) / 2); i++)
201 {
202 bub = evas_object_image_filled_add(game.canvas);
203 evas_object_image_file_set(bub, buf, NULL);
204 evas_object_resize(bub, 64, 64);
205 evas_object_show(bub);
206 evas_object_data_set(game.bg, names[(i * 2)], bub);
207 }
208 ani = ecore_animator_add(anim, &game);
209 evas_object_data_set(game.bg, "animator", ani);
210
211 // Setup our callbacks.
212 ecore_evas_callback_delete_request_set(game.ee, _on_delete);
213 edje_object_signal_callback_add(game.edje, "*", "game_*", _edje_signal_cb, &game);
214#endif
215 246
216 // Do the compiles. 247 // Do the compiles.
217 scriptCount = 0; 248 scriptCount = 0;
@@ -235,12 +266,12 @@ main(int argc, char **argv)
235 printf("Combined estimate of compiling speed is %f scripts per second.\n", 1 / ((diff0 / lslCount) + (diff / scriptCount))); 266 printf("Combined estimate of compiling speed is %f scripts per second.\n", 1 / ((diff0 / lslCount) + (diff / scriptCount)));
236#endif 267#endif
237 268
238// ecore_main_loop_begin(); 269 if (game.ui)
239 270 {
240#if HARNESS 271 ecore_main_loop_begin();
241 ecore_animator_del(ani); 272 ecore_animator_del(ani);
242 ecore_evas_free(game.ee); 273 ecore_evas_free(game.ee);
243#endif 274 }
244 edje_shutdown(); 275 edje_shutdown();
245 ecore_evas_shutdown(); 276 ecore_evas_shutdown();
246 } 277 }