aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rwxr-xr-xLuaSL/build.sh13
-rw-r--r--LuaSL/src/LuaSL.h16
-rw-r--r--LuaSL/src/LuaSL_main.c329
-rw-r--r--LuaSL/src/LuaSL_test.c310
-rwxr-xr-xtest.sh8
5 files changed, 420 insertions, 256 deletions
diff --git a/LuaSL/build.sh b/LuaSL/build.sh
index edddb31..7242205 100755
--- a/LuaSL/build.sh
+++ b/LuaSL/build.sh
@@ -76,3 +76,16 @@ command="gcc $CFLAGS -o ../LuaSL $objects $LDFLAGS $libs"
76echo $command 76echo $command
77$command 77$command
78 78
79names="LuaSL_test LuaSL_utilities"
80objects=""
81for i in $names
82do
83 command="gcc $CFLAGS -c -o $i.o $i.c"
84 echo $command
85 $command
86 objects="$objects $i.o"
87done
88command="gcc $CFLAGS -o ../LuaSL_test $objects $LDFLAGS $libs"
89echo $command
90$command
91
diff --git a/LuaSL/src/LuaSL.h b/LuaSL/src/LuaSL.h
index 0b831c8..3b8c761 100644
--- a/LuaSL/src/LuaSL.h
+++ b/LuaSL/src/LuaSL.h
@@ -8,6 +8,7 @@
8 8
9#include <Eet.h> 9#include <Eet.h>
10#include <Ecore.h> 10#include <Ecore.h>
11#include <Ecore_Con.h>
11#include <Ecore_Evas.h> 12#include <Ecore_Evas.h>
12#include <Ecore_File.h> 13#include <Ecore_File.h>
13#include <Edje.h> 14#include <Edje.h>
@@ -48,12 +49,15 @@ typedef enum
48 49
49typedef struct 50typedef struct
50{ 51{
51 Ecore_Evas *ee; // Our window. 52 Ecore_Evas *ee; // Our window.
52 Evas *canvas; // The canvas for drawing directly onto. 53 Evas *canvas; // The canvas for drawing directly onto.
53 Evas_Object *bg; // Our background edje, also the game specific stuff. 54 Evas_Object *bg; // Our background edje, also the game specific stuff.
54 Evas_Object *edje; // The edje of the background. 55 Evas_Object *edje; // The edje of the background.
55 int logDom; 56 Ecore_Con_Server *server;
56 boolean ui; // Wether we actually start up the UI. 57 int logDom;
58 const char *address;
59 int port;
60 boolean ui; // Wether we actually start up the UI.
57} gameGlobals; 61} gameGlobals;
58 62
59 63
diff --git a/LuaSL/src/LuaSL_main.c b/LuaSL/src/LuaSL_main.c
index d6485df..621aad2 100644
--- a/LuaSL/src/LuaSL_main.c
+++ b/LuaSL/src/LuaSL_main.c
@@ -2,295 +2,128 @@
2#include "LuaSL.h" 2#include "LuaSL.h"
3 3
4 4
5static int scriptCount; 5Eina_Strbuf *clientStream;
6
7static const char *names[] =
8{
9 "bub1", "sh1",
10 "bub2", "sh2",
11 "bub3", "sh3",
12};
13 6
14 7
15static void 8Eina_Bool _add(void *data, int type __UNUSED__, Ecore_Con_Event_Client_Add *ev)
16_edje_signal_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission, const char *source)
17{ 9{
18// gameGlobals *game = data; 10 ecore_con_client_timeout_set(ev->client, 0);
11 return ECORE_CALLBACK_RENEW;
19} 12}
20 13
21static 14Eina_Bool _del(void *data, int type __UNUSED__, Ecore_Con_Event_Client_Del *ev)
22Eina_Bool anim(void *data)
23{ 15{
24 gameGlobals *game = data; 16 gameGlobals *game = data;
25 Evas_Object *bub, *sh;
26 Evas_Coord x, y, w, h, vw, vh;
27 double t, xx, yy, zz, r, fac;
28 double lx, ly;
29 unsigned int i;
30 17
31 evas_output_viewport_get(game->canvas, 0, 0, &vw, &vh); 18 if (ev->client)
32 r = 48;
33 t = ecore_loop_time_get();
34 fac = 2.0 / (double)((sizeof(names) / sizeof(char *) / 2));
35 evas_pointer_canvas_xy_get(game->canvas, &x, &y);
36 lx = x;
37 ly = y;
38
39 for (i = 0; i < (sizeof(names) / sizeof(char *) / 2); i++)
40 { 19 {
41 bub = evas_object_data_get(game->bg, names[i * 2]); 20 PD("No more clients, exiting.");
42 sh = evas_object_data_get(game->bg, names[(i * 2) + 1]); 21 ecore_con_client_del(ev->client);
43 zz = (((2 + sin(t * 6 + (M_PI * (i * fac)))) / 3) * 64) * 2; 22 ecore_main_loop_quit();
44 xx = (cos(t * 4 + (M_PI * (i * fac))) * r) * 2;
45 yy = (sin(t * 6 + (M_PI * (i * fac))) * r) * 2;
46
47 w = zz;
48 h = zz;
49 x = (vw / 2) + xx - (w / 2);
50 y = (vh / 2) + yy - (h / 2);
51
52 evas_object_move(bub, x, y);
53 evas_object_resize(bub, w, h);
54
55 x = x - ((lx - (x + (w / 2))) / 4);
56 y = y - ((ly - (y + (h / 2))) / 4);
57
58 evas_object_move(sh, x, y);
59 evas_object_resize(sh, w, h);
60 evas_object_raise(sh);
61 evas_object_raise(bub);
62 } 23 }
63 return ECORE_CALLBACK_RENEW; 24 return ECORE_CALLBACK_RENEW;
64} 25}
65 26
66static void 27Eina_Bool _data(void *data, int type __UNUSED__, Ecore_Con_Event_Client_Data *ev)
67_on_delete(Ecore_Evas *ee __UNUSED__)
68{
69 ecore_main_loop_quit();
70}
71
72static void dirList_compile(const char *name, const char *path, void *data)
73{ 28{
74 gameGlobals *game = data; 29 gameGlobals *game = data;
75 char buf[PATH_MAX]; 30 char SID[PATH_MAX];
76 char *ext = rindex(name, '.'); 31 const char *command;
32 char *ext;
77 33
78 if (ext) 34 eina_strbuf_append_length(clientStream, ev->data, ev->size);
35 command = eina_strbuf_string_get(clientStream);
36 while ((ext = index(command, '\n')))
79 { 37 {
80 if ((!LUASL_DEBUG) || (0 == scriptCount)) 38 int length = ext - command;
39
40 strncpy(SID, command, length + 1);
41 SID[length] = '\0';
42 eina_strbuf_remove(clientStream, 0, length + 1);
43 ext = rindex(SID, '.');
44 if (ext)
81 { 45 {
82 if (0 == strcmp(ext, ".lsl")) 46 ext[0] = '\0';
47 command = ext + 1;
48 if (0 == strcmp(command, "compile()"))
83 { 49 {
84 scriptCount++; 50 if (compileLSL(game, SID, FALSE))
85 snprintf(buf, sizeof(buf), "%s/%s", path, name); 51 PD("The compile of %s worked.", SID);
86 if (compileLSL(game, buf, FALSE))
87 PD("The compile of %s worked,", buf);
88 else 52 else
89 PE("The compile of %s failed!", buf); 53 PE("The compile of %s failed!", SID);
90 } 54 }
91 } 55 else if (0 == strcmp(command, "start()"))
92 } 56 {
93} 57 runLuaFile(game, SID);
94 58 }
95static void dirList_run(const char *name, const char *path, void *data) 59 else if (0 == strcmp(command, "exit()"))
96{ 60 {
97 gameGlobals *game = data; 61 PD("Told to exit.");
98 char buf[PATH_MAX]; 62 ecore_main_loop_quit();
99 char *ext = rindex(name, '.'); 63 }
64 else
65 {
66 char temp[PATH_MAX];
67 const char *status = NULL;
100 68
101 if (ext) 69 snprintf(temp, sizeof(temp), "%s.events", SID);
102 { 70 status = sendToChannel(temp, command, NULL, NULL);
103 if (0 == strcmp(ext, ".out")) 71 if (status)
104 { 72 PE("Error sending command %s to script %s : %s", command, temp, status);
105 snprintf(buf, sizeof(buf), "%s/%s", path, name); 73 }
106// PD("Running Lua script %s", buf);
107 runLuaFile(game, buf);
108 } 74 }
109 }
110}
111 75
112static void dirList_quit(const char *name, const char *path, void *data) 76 // Get the next blob to check it.
113{ 77 command = eina_strbuf_string_get(clientStream);
114 gameGlobals *game = data;
115 char buf[PATH_MAX];
116 char *ext = rindex(name, '.');
117
118 if (ext)
119 {
120 if (0 == strcmp(ext, ".out"))
121 {
122 const char *status = NULL;
123
124 snprintf(buf, sizeof(buf), "%s/%s.events", path, name);
125// PD("Quitting Lua script %s", buf);
126 status = sendToChannel(buf, "quit()", NULL, NULL);
127 if (status)
128 PE("Error trying to kill script %s : %s", buf, status);
129 }
130 } 78 }
79
80 return ECORE_CALLBACK_RENEW;
131} 81}
132 82
133int 83int main(int argc, char **argv)
134main(int argc, char **argv)
135{ 84{
136 /* put here any init specific to this app like parsing args etc. */
137 gameGlobals game; 85 gameGlobals game;
138 char *programName = argv[0]; 86 int result = EXIT_FAILURE;
139 boolean badArgs = FALSE;
140
141 if (!ecore_evas_init())
142 return EXIT_FAILURE;
143
144 if (!edje_init())
145 {
146 ecore_evas_shutdown();
147 return EXIT_FAILURE;
148 }
149 87
150 memset(&game, 0, sizeof(gameGlobals)); 88 memset(&game, 0, sizeof(gameGlobals));
89 game.address = "127.0.01";
90 game.port = 8211;
151 91
152 loggingStartup(&game); 92 if (eina_init())
153
154 // get the arguments passed in
155 while (--argc > 0 && *++argv != '\0')
156 { 93 {
157 if (*argv[0] == '-') 94 loggingStartup(&game);
95 if (ecore_con_init())
158 { 96 {
159 // point to the characters after the '-' sign 97 if ((game.server = ecore_con_server_add(ECORE_CON_REMOTE_TCP, game.address, game.port, &game)))
160 char *s = argv[0] + 1;
161
162 switch (*s)
163 { 98 {
164 case 'u': 99 ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_ADD, (Ecore_Event_Handler_Cb) _add, &game);
100 ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DEL, (Ecore_Event_Handler_Cb) _del, &game);
101 ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DATA, (Ecore_Event_Handler_Cb) _data, &game);
102 ecore_con_server_timeout_set(game.server, 0);
103 ecore_con_server_client_limit_set(game.server, -1, 0);
104 clientStream = eina_strbuf_new();
105
106 if (edje_init())
165 { 107 {
166 game.ui = TRUE; 108 result = 0;
167 break; 109 compilerSetup(&game);
110 runnerSetup(&game);
111 ecore_main_loop_begin();
112 runnerTearDown(&game);
113 edje_shutdown();
168 } 114 }
169 default: 115 else
170 badArgs = TRUE; 116 PCm("Failed to init edje!");
171 } 117 }
118 else
119 PCm("Failed to add server!");
120 ecore_con_shutdown();
172 } 121 }
173 else 122 else
174 badArgs = TRUE; 123 PCm("Failed to init ecore_con!");
175 }
176
177
178 if (badArgs)
179 {
180 // display the program usage to the user as they have it wrong
181 printf("Usage: %s [-u]\n", programName);
182 printf(" -u: Show the test UI.\n");
183 } 124 }
184 else 125 else
185// else if ((game.config) && (game.data)) 126 fprintf(stderr, "Failed to init eina!");
186 {
187 unsigned int i;
188 Evas_Object *bub, *sh;
189 Ecore_Animator *ani;
190 char *group = "main";
191 char buf[PATH_MAX];
192 struct timeval lastTime2;
193 struct timeval thisTime2;
194 float diff;
195
196 if (game.ui)
197 {
198 /* this will give you a window with an Evas canvas under the first engine available */
199 game.ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
200 if (!game.ee)
201 {
202 PEm("You got to have at least one evas engine built and linked up to ecore-evas for this example to run properly.");
203 edje_shutdown();
204 ecore_evas_shutdown();
205 return -1;
206 }
207 game.canvas = ecore_evas_get(game.ee);
208 ecore_evas_title_set(game.ee, "LuaSL test harness");
209 ecore_evas_show(game.ee);
210
211 game.bg = evas_object_rectangle_add(game.canvas);
212 evas_object_color_set(game.bg, 255, 255, 255, 255); /* white bg */
213 evas_object_move(game.bg, 0, 0); /* at canvas' origin */
214 evas_object_size_hint_weight_set(game.bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
215 evas_object_resize(game.bg, WIDTH, HEIGHT); /* covers full canvas */
216 evas_object_show(game.bg);
217 ecore_evas_object_associate(game.ee, game.bg, ECORE_EVAS_OBJECT_ASSOCIATE_BASE);
218 evas_object_focus_set(game.bg, EINA_TRUE);
219
220 game.edje = edje_object_add(game.canvas);
221 snprintf(buf, sizeof(buf), "%s/%s.edj", PACKAGE_DATA_DIR, "LuaSL");
222 if (!edje_object_file_set(game.edje, buf, group))
223 {
224 int err = edje_object_load_error_get(game.edje);
225 const char *errmsg = edje_load_error_str(err);
226 PEm("Could not load '%s' from %s: %s\n", group, buf, errmsg);
227
228 evas_object_del(game.edje);
229 ecore_evas_free(game.ee);
230 edje_shutdown();
231 ecore_evas_shutdown();
232 return -2;
233 }
234 evas_object_move(game.edje, 0, 0);
235 evas_object_resize(game.edje, WIDTH, HEIGHT);
236 evas_object_show(game.edje);
237
238 snprintf(buf, sizeof(buf), "%s/images/bubble_sh.png", PACKAGE_DATA_DIR);
239 for (i = 0; i < (sizeof(names) / sizeof(char *) / 2); i++)
240 {
241 sh = evas_object_image_filled_add(game.canvas);
242 evas_object_image_file_set(sh, buf, NULL);
243 evas_object_resize(sh, 64, 64);
244 evas_object_show(sh);
245 evas_object_data_set(game.bg, names[(i * 2) + 1], sh);
246 }
247
248 snprintf(buf, sizeof(buf), "%s/images/bubble.png", PACKAGE_DATA_DIR);
249 for (i = 0; i < (sizeof(names) / sizeof(char *) / 2); i++)
250 {
251 bub = evas_object_image_filled_add(game.canvas);
252 evas_object_image_file_set(bub, buf, NULL);
253 evas_object_resize(bub, 64, 64);
254 evas_object_show(bub);
255 evas_object_data_set(game.bg, names[(i * 2)], bub);
256 }
257 ani = ecore_animator_add(anim, &game);
258 evas_object_data_set(game.bg, "animator", ani);
259
260 // Setup our callbacks.
261 ecore_evas_callback_delete_request_set(game.ee, _on_delete);
262 edje_object_signal_callback_add(game.edje, "*", "game_*", _edje_signal_cb, &game);
263 }
264
265 // Do the compiles.
266 scriptCount = 0;
267 compilerSetup(&game);
268 runnerSetup(&game);
269 gettimeofday(&lastTime2, 0);
270 snprintf(buf, sizeof(buf), "%s/Test sim/objects", PACKAGE_DATA_DIR);
271 eina_file_dir_list(buf, EINA_TRUE, dirList_compile, &game);
272 diff = timeDiff(&thisTime2, &lastTime2);
273 printf("Compiling %d LSL scripts took %f seconds, that's %f scripts per second.\n", scriptCount, diff, scriptCount / diff);
274 eina_file_dir_list(buf, EINA_TRUE, dirList_run, &game);
275
276 if (game.ui)
277 {
278 ecore_main_loop_begin();
279 ecore_animator_del(ani);
280 ecore_evas_free(game.ee);
281 }
282 else
283 {
284 // Wait awhile, then quit all scripts we started, for testing.
285 sleep(2);
286 snprintf(buf, sizeof(buf), "%s/Test sim/objects", PACKAGE_DATA_DIR);
287 eina_file_dir_list(buf, EINA_TRUE, dirList_quit, &game);
288 }
289
290 runnerTearDown(&game);
291 edje_shutdown();
292 ecore_evas_shutdown();
293 }
294 127
295 return 0; 128 return result;
296} 129}
diff --git a/LuaSL/src/LuaSL_test.c b/LuaSL/src/LuaSL_test.c
new file mode 100644
index 0000000..91ad152
--- /dev/null
+++ b/LuaSL/src/LuaSL_test.c
@@ -0,0 +1,310 @@
1
2#include "LuaSL.h"
3
4
5static const char *names[] =
6{
7 "bub1", "sh1",
8 "bub2", "sh2",
9 "bub3", "sh3",
10};
11
12
13static void
14_edje_signal_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission, const char *source)
15{
16// gameGlobals *game = data;
17}
18
19static
20Eina_Bool anim(void *data)
21{
22 gameGlobals *game = data;
23 Evas_Object *bub, *sh;
24 Evas_Coord x, y, w, h, vw, vh;
25 double t, xx, yy, zz, r, fac;
26 double lx, ly;
27 unsigned int i;
28
29 evas_output_viewport_get(game->canvas, 0, 0, &vw, &vh);
30 r = 48;
31 t = ecore_loop_time_get();
32 fac = 2.0 / (double)((sizeof(names) / sizeof(char *) / 2));
33 evas_pointer_canvas_xy_get(game->canvas, &x, &y);
34 lx = x;
35 ly = y;
36
37 for (i = 0; i < (sizeof(names) / sizeof(char *) / 2); i++)
38 {
39 bub = evas_object_data_get(game->bg, names[i * 2]);
40 sh = evas_object_data_get(game->bg, names[(i * 2) + 1]);
41 zz = (((2 + sin(t * 6 + (M_PI * (i * fac)))) / 3) * 64) * 2;
42 xx = (cos(t * 4 + (M_PI * (i * fac))) * r) * 2;
43 yy = (sin(t * 6 + (M_PI * (i * fac))) * r) * 2;
44
45 w = zz;
46 h = zz;
47 x = (vw / 2) + xx - (w / 2);
48 y = (vh / 2) + yy - (h / 2);
49
50 evas_object_move(bub, x, y);
51 evas_object_resize(bub, w, h);
52
53 x = x - ((lx - (x + (w / 2))) / 4);
54 y = y - ((ly - (y + (h / 2))) / 4);
55
56 evas_object_move(sh, x, y);
57 evas_object_resize(sh, w, h);
58 evas_object_raise(sh);
59 evas_object_raise(bub);
60 }
61 return ECORE_CALLBACK_RENEW;
62}
63
64static void
65_on_delete(Ecore_Evas *ee __UNUSED__)
66{
67 ecore_main_loop_quit();
68}
69
70static void common_dirList(gameGlobals *game, const char *name, const char *path, const char *type, const char *command)
71{
72 char buf[PATH_MAX];
73 char *ext = rindex(name, '.');
74
75 if (ext)
76 {
77 if (0 == strcmp(ext, type))
78 {
79 snprintf(buf, sizeof(buf), "%s/%s.%s()\n", path, name, command);
80 ecore_con_server_send(game->server, buf, strlen(buf));
81 ecore_con_server_flush(game->server);
82 }
83 }
84}
85
86static void dirList_compile(const char *name, const char *path, void *data)
87{
88 gameGlobals *game = data;
89
90 common_dirList(game, name, path, ".lsl", "compile");
91}
92
93static void dirList_run(const char *name, const char *path, void *data)
94{
95 gameGlobals *game = data;
96
97 common_dirList(game, name, path, ".out", "start");
98}
99
100static void dirList_quit(const char *name, const char *path, void *data)
101{
102 gameGlobals *game = data;
103
104 common_dirList(game, name, path, ".out", "quit");
105}
106
107Eina_Bool _add(void *data, int type __UNUSED__, Ecore_Con_Event_Server_Add *ev)
108{
109 gameGlobals *game = data;
110 char buf[PATH_MAX];
111
112 game->server = ev->server;
113 snprintf(buf, sizeof(buf), "%s/Test sim/objects", PACKAGE_DATA_DIR);
114 eina_file_dir_list(buf, EINA_TRUE, dirList_compile, game);
115 eina_file_dir_list(buf, EINA_TRUE, dirList_run, game);
116 // Wait awhile, then quit all scripts we started, for testing.
117 sleep(2);
118 eina_file_dir_list(buf, EINA_TRUE, dirList_quit, game);
119
120 ecore_con_server_send(game->server, ".exit()\n", 8);
121 ecore_con_server_flush(game->server);
122 ecore_main_loop_quit();
123
124 return ECORE_CALLBACK_RENEW;
125}
126
127Eina_Bool _del(void *data, int type __UNUSED__, Ecore_Con_Event_Server_Del *ev)
128{
129 gameGlobals *game = data;
130
131 if (ev->server)
132 {
133 game->server = NULL;
134 ecore_con_server_del(ev->server);
135 ecore_main_loop_quit();
136 }
137
138 return ECORE_CALLBACK_RENEW;
139}
140
141Eina_Bool _data(void *data, int type __UNUSED__, Ecore_Con_Event_Server_Data *ev)
142{
143 gameGlobals *game = data;
144
145 return ECORE_CALLBACK_RENEW;
146}
147
148int main(int argc, char **argv)
149{
150 /* put here any init specific to this app like parsing args etc. */
151 gameGlobals game;
152 char *programName = argv[0];
153 boolean badArgs = FALSE;
154 int result = EXIT_FAILURE;
155
156 memset(&game, 0, sizeof(gameGlobals));
157 game.address = "127.0.01";
158 game.port = 8211;
159
160 if (eina_init())
161 {
162 loggingStartup(&game);
163 if (ecore_con_init())
164 {
165 if ((game.server = ecore_con_server_connect(ECORE_CON_REMOTE_TCP, game.address, game.port, &game)))
166 {
167 ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD, (Ecore_Event_Handler_Cb) _add, &game);
168 ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DEL, (Ecore_Event_Handler_Cb) _del, &game);
169 ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA, (Ecore_Event_Handler_Cb) _data, &game);
170
171 if (ecore_evas_init())
172 {
173 if (edje_init())
174 {
175 // get the arguments passed in
176 while (--argc > 0 && *++argv != '\0')
177 {
178 if (*argv[0] == '-')
179 {
180 // point to the characters after the '-' sign
181 char *s = argv[0] + 1;
182
183 switch (*s)
184 {
185 case 'u':
186 {
187 game.ui = TRUE;
188 break;
189 }
190 default:
191 badArgs = TRUE;
192 }
193 }
194 else
195 badArgs = TRUE;
196 }
197
198 if (badArgs)
199 {
200 // display the program usage to the user as they have it wrong
201 printf("Usage: %s [-u]\n", programName);
202 printf(" -u: Show the test UI.\n");
203 }
204 else
205 // else if ((game.config) && (game.data))
206 {
207 unsigned int i;
208 Evas_Object *bub, *sh;
209 Ecore_Animator *ani;
210 char *group = "main";
211 char buf[PATH_MAX];
212
213 if (game.ui)
214 {
215 /* this will give you a window with an Evas canvas under the first engine available */
216 game.ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
217 if (!game.ee)
218 {
219 PEm("You got to have at least one evas engine built and linked up to ecore-evas for this example to run properly.");
220 edje_shutdown();
221 ecore_evas_shutdown();
222 return -1;
223 }
224 game.canvas = ecore_evas_get(game.ee);
225 ecore_evas_title_set(game.ee, "LuaSL test harness");
226 ecore_evas_show(game.ee);
227
228 game.bg = evas_object_rectangle_add(game.canvas);
229 evas_object_color_set(game.bg, 255, 255, 255, 255); /* white bg */
230 evas_object_move(game.bg, 0, 0); /* at canvas' origin */
231 evas_object_size_hint_weight_set(game.bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
232 evas_object_resize(game.bg, WIDTH, HEIGHT); /* covers full canvas */
233 evas_object_show(game.bg);
234 ecore_evas_object_associate(game.ee, game.bg, ECORE_EVAS_OBJECT_ASSOCIATE_BASE);
235 evas_object_focus_set(game.bg, EINA_TRUE);
236
237 game.edje = edje_object_add(game.canvas);
238 snprintf(buf, sizeof(buf), "%s/%s.edj", PACKAGE_DATA_DIR, "LuaSL");
239 if (!edje_object_file_set(game.edje, buf, group))
240 {
241 int err = edje_object_load_error_get(game.edje);
242 const char *errmsg = edje_load_error_str(err);
243 PEm("Could not load '%s' from %s: %s\n", group, buf, errmsg);
244
245 evas_object_del(game.edje);
246 ecore_evas_free(game.ee);
247 edje_shutdown();
248 ecore_evas_shutdown();
249 return -2;
250 }
251 evas_object_move(game.edje, 0, 0);
252 evas_object_resize(game.edje, WIDTH, HEIGHT);
253 evas_object_show(game.edje);
254
255 snprintf(buf, sizeof(buf), "%s/images/bubble_sh.png", PACKAGE_DATA_DIR);
256 for (i = 0; i < (sizeof(names) / sizeof(char *) / 2); i++)
257 {
258 sh = evas_object_image_filled_add(game.canvas);
259 evas_object_image_file_set(sh, buf, NULL);
260 evas_object_resize(sh, 64, 64);
261 evas_object_show(sh);
262 evas_object_data_set(game.bg, names[(i * 2) + 1], sh);
263 }
264
265 snprintf(buf, sizeof(buf), "%s/images/bubble.png", PACKAGE_DATA_DIR);
266 for (i = 0; i < (sizeof(names) / sizeof(char *) / 2); i++)
267 {
268 bub = evas_object_image_filled_add(game.canvas);
269 evas_object_image_file_set(bub, buf, NULL);
270 evas_object_resize(bub, 64, 64);
271 evas_object_show(bub);
272 evas_object_data_set(game.bg, names[(i * 2)], bub);
273 }
274 ani = ecore_animator_add(anim, &game);
275 evas_object_data_set(game.bg, "animator", ani);
276
277 // Setup our callbacks.
278 ecore_evas_callback_delete_request_set(game.ee, _on_delete);
279 edje_object_signal_callback_add(game.edje, "*", "game_*", _edje_signal_cb, &game);
280 }
281
282 ecore_main_loop_begin();
283 if (game.ui)
284 {
285 ecore_animator_del(ani);
286 ecore_evas_free(game.ee);
287 }
288 }
289
290 edje_shutdown();
291 }
292 else
293 PCm("Failed to init edje!");
294 ecore_evas_shutdown();
295 }
296 else
297 PCm("Failed to init ecore_evas!");
298 }
299 else
300 PCm("Failed to connect to server!");
301 ecore_con_shutdown();
302 }
303 else
304 PCm("Failed to init ecore_con!");
305 }
306 else
307 fprintf(stderr, "Failed to init eina!");
308
309 return result;
310}
diff --git a/test.sh b/test.sh
index 52a9561..b9455c0 100755
--- a/test.sh
+++ b/test.sh
@@ -7,11 +7,13 @@ wd=$(pwd)
7./build.sh || exit 7./build.sh || exit
8 8
9echo "_______________ TESTING LuaSL _______________" 9echo "_______________ TESTING LuaSL _______________"
10# Kill any left overs.
11killall -KILL LuaSL
10cd $wd/LuaSL/testLua 12cd $wd/LuaSL/testLua
11export LUA_PATH="$wd/LuaSL/src/?.lua" 13export LUA_PATH="$wd/LuaSL/src/?.lua"
12export LUA_SOPATH='../../libraries/luaproc/' 14export LUA_SOPATH='../../libraries/luaproc/'
13export LD_LIBRARY_PATH="../../libraries/luajit-2.0/src:$LD_LIBRARY_PATH" 15export LD_LIBRARY_PATH="../../libraries/luajit-2.0/src:$LD_LIBRARY_PATH"
14 16export EINA_LOG_LEVELS="ecore:2,ecore_con:2"
15 17
16case $@ in 18case $@ in
17 19
@@ -24,7 +26,9 @@ case $@ in
24 ;; 26 ;;
25 27
26 *) 28 *)
27 ../LuaSL 29 ../LuaSL &
30 sleep 1
31 ../LuaSL_test
28 ;; 32 ;;
29 33
30esac 34esac