diff options
Diffstat (limited to '')
-rwxr-xr-x | LuaSL/build.sh | 70 | ||||
-rw-r--r-- | LuaSL/src/LuaSL.edc | 205 | ||||
-rw-r--r-- | LuaSL/src/LuaSL.h | 64 | ||||
-rw-r--r-- | LuaSL/src/LuaSL_main.c | 173 | ||||
-rw-r--r-- | LuaSL/src/LuaSL_utilities.c | 101 | ||||
-rw-r--r-- | LuaSL/src/fonts/Vera.ttf | bin | 0 -> 65932 bytes | |||
-rw-r--r-- | LuaSL/src/images/bubble.png | bin | 0 -> 4737 bytes | |||
-rw-r--r-- | LuaSL/src/images/bubble_sh.png | bin | 0 -> 1600 bytes | |||
-rw-r--r-- | LuaSL/src/images/test.png | bin | 0 -> 22869 bytes |
9 files changed, 613 insertions, 0 deletions
diff --git a/LuaSL/build.sh b/LuaSL/build.sh new file mode 100755 index 0000000..206f3c0 --- /dev/null +++ b/LuaSL/build.sh | |||
@@ -0,0 +1,70 @@ | |||
1 | #! /bin/bash | ||
2 | |||
3 | cd src | ||
4 | |||
5 | export LOCALDIR=`pwd` | ||
6 | |||
7 | if [ -d "/opt/e17" ] | ||
8 | then | ||
9 | export E17DIR="/opt/e17" | ||
10 | else | ||
11 | export E17DIR="/usr" | ||
12 | fi | ||
13 | |||
14 | # No need for a make file, or dependencies, the entire thing takes only a few seconds to build. | ||
15 | |||
16 | CFLAGS="-g -Wall -I include -I $LOCALDIR" | ||
17 | CFLAGS="$CFLAGS -I $E17DIR/include/eina-1" | ||
18 | CFLAGS="$CFLAGS -I $E17DIR/include/eina-1/eina" | ||
19 | CFLAGS="$CFLAGS -I $E17DIR/include/eet-1" | ||
20 | CFLAGS="$CFLAGS -I $E17DIR/include/edje-1" | ||
21 | CFLAGS="$CFLAGS -I $E17DIR/include/evas-1" | ||
22 | CFLAGS="$CFLAGS -I $E17DIR/include/ecore-1" | ||
23 | CFLAGS="$CFLAGS -I $E17DIR/include" | ||
24 | CFLAGS="$CFLAGS -DPACKAGE_DATA_DIR=\"$LOCALDIR\" $CFLAGOPTS" | ||
25 | |||
26 | LDFLAGS="-L lib -L /usr/lib -L /lib -L $E17DIR/lib" | ||
27 | libs="-lecore -levas -ledje -leet -leina" | ||
28 | # These need to be added to libs if linking staticaly, though some part of EFL don't like that. | ||
29 | #-lecore_evas \ | ||
30 | #-lecore_fb \ | ||
31 | #-lecore_file \ | ||
32 | #-lecore \ | ||
33 | #-ledje \ | ||
34 | #-levas \ | ||
35 | #-lembryo \ | ||
36 | #-leet \ | ||
37 | #-leina \ | ||
38 | #-llua \ | ||
39 | #-lm \ | ||
40 | #-ldl \ | ||
41 | #-lglib-2.0 \ | ||
42 | #-lpthread \ | ||
43 | #-lfontconfig \ | ||
44 | #-lfreetype \ | ||
45 | #-lexpat \ | ||
46 | #-lrt \ | ||
47 | #-lz | ||
48 | |||
49 | names="LuaSL_main LuaSL_utilities" | ||
50 | |||
51 | EDJE_FLAGS="-id images -fd fonts" | ||
52 | |||
53 | rm -f LuaSL *.o *.edj | ||
54 | command="edje_cc $EDJE_FLAGS LuaSL.edc LuaSL.edj" | ||
55 | echo $command | ||
56 | $command | ||
57 | |||
58 | objects="" | ||
59 | for i in $names | ||
60 | do | ||
61 | command="gcc $CFLAGS -c -o $i.o $i.c" | ||
62 | echo $command | ||
63 | $command | ||
64 | objects="$objects $i.o" | ||
65 | done | ||
66 | |||
67 | command="gcc $CFLAGS -o LuaSL $objects $LDFLAGS $libs" | ||
68 | echo $command | ||
69 | $command | ||
70 | |||
diff --git a/LuaSL/src/LuaSL.edc b/LuaSL/src/LuaSL.edc new file mode 100644 index 0000000..f74395b --- /dev/null +++ b/LuaSL/src/LuaSL.edc | |||
@@ -0,0 +1,205 @@ | |||
1 | color_classes { | ||
2 | color_class { name: "test_colour"; color: 255 255 255 255; } | ||
3 | } | ||
4 | |||
5 | fonts { | ||
6 | font: "Vera.ttf" "default"; | ||
7 | } | ||
8 | |||
9 | images { | ||
10 | image: "bubble.png" COMP; | ||
11 | image: "test.png" COMP; | ||
12 | } | ||
13 | |||
14 | collections { | ||
15 | group { | ||
16 | name: "main"; | ||
17 | lua_script_only: 1; | ||
18 | lua_script { | ||
19 | --// stick object private/local vars here | ||
20 | local D; | ||
21 | local text_geom; | ||
22 | |||
23 | --// init object here | ||
24 | D = {}; --// data is empty table to start | ||
25 | |||
26 | --// send some random edje message | ||
27 | edje.messagesend(7, "none" ); | ||
28 | edje.messagesend(7, "sig", "signal", "source"); | ||
29 | edje.messagesend(7, "str", "hello world"); | ||
30 | edje.messagesend(7, "int", 987); | ||
31 | edje.messagesend(7, "float", 987.321); | ||
32 | edje.messagesend(7, "strset", {"hello", "there", "world"}); | ||
33 | edje.messagesend(7, "intset", {1, 2, 3}); | ||
34 | edje.messagesend(7, "floatset", {1.1, 2.2, 3.3}); | ||
35 | edje.messagesend(7, "strint", "hello world", 7); | ||
36 | edje.messagesend(7, "strfloat", "hello world", 7.654); | ||
37 | edje.messagesend(7, "strintset","hello world", {1, 2, 3}); | ||
38 | |||
39 | D.edje = edje.edje(); | ||
40 | D.edje:file("plain/edje/group"); | ||
41 | D.edje:show(); | ||
42 | |||
43 | D.text = edje.text(); | ||
44 | D.text:geom (50, 5, 150, 50); | ||
45 | D.text:color (255, 0, 0, 255); | ||
46 | D.text:font("Sans:style=Bold", 32); | ||
47 | D.text:text("Lua rocks!"); | ||
48 | text_geom = D.text:geom(); | ||
49 | print(D.text:text()); | ||
50 | D.text:show(); | ||
51 | |||
52 | |||
53 | --// shutdown func - generally empty or not there. everything garbage collected for you | ||
54 | function shutdown () | ||
55 | print("lua::shutdown"); | ||
56 | end | ||
57 | |||
58 | function show () | ||
59 | print("lua::show"); | ||
60 | end | ||
61 | |||
62 | function hide () | ||
63 | print("lua::hide"); | ||
64 | end | ||
65 | |||
66 | function move (x, y) | ||
67 | print("lua::move x=" .. x .. " x=" .. y); | ||
68 | D.edje:move(0, 0); | ||
69 | end | ||
70 | |||
71 | function resize (w, h) | ||
72 | print("lua::resize w=" .. w .. " h=" .. h); | ||
73 | D.text:move((w - text_geom.w) / 2, (h - text_geom.h) / 8); | ||
74 | D.edje:resize(w, h); | ||
75 | end | ||
76 | |||
77 | function message (id, type, ...) | ||
78 | print("lua::message id=" .. id .. " type=" .. type); | ||
79 | --// handle your message type here. check id + type then use the | ||
80 | --// vararg appropriately. they are the same as the params passed | ||
81 | --// to edje:messagesend() (if any are passed at all). Any array | ||
82 | --// arguments are passed as a single table. | ||
83 | |||
84 | if ("none" == type) then | ||
85 | print("lua::message no args"); | ||
86 | elseif ("strset" == type) then | ||
87 | strs = ... ; | ||
88 | print_table_start(strs, "", "lua::message strings"); | ||
89 | elseif ("intset" == type) then | ||
90 | ints = ... ; | ||
91 | print_table_start(ints, "", "lua::message ints"); | ||
92 | elseif ("floatset" == type) then | ||
93 | floats = ... ; | ||
94 | print_table_start(floats, "", "lua::message floats"); | ||
95 | elseif ("strintset" == type) then | ||
96 | str, ints = ... ; | ||
97 | print("lua::message " .. str); | ||
98 | print_table_start(ints, "", "lua::message ints"); | ||
99 | elseif ("strfloatset" == type) then | ||
100 | str, floats = ... ; | ||
101 | print("lua::message " .. str); | ||
102 | print_table_start(floats, "", "lua::message floats"); | ||
103 | else | ||
104 | print("lua::message " .. ... ); | ||
105 | end | ||
106 | end | ||
107 | |||
108 | function signal (sig, src) | ||
109 | print("lua::signal sig= " .. sig .. " src= " .. src); | ||
110 | end | ||
111 | } | ||
112 | } | ||
113 | |||
114 | // The group name NEEDS a / in it, | ||
115 | // or the part below that tries to swallow it won't work. | ||
116 | // Leaving just the lua part visible. | ||
117 | group { | ||
118 | name: "bubbles/lua"; | ||
119 | lua_script_only: 1; | ||
120 | lua_script { | ||
121 | local bubbles = { }; | ||
122 | local bubbleCols = 8; | ||
123 | local bubbleRows = 6; | ||
124 | |||
125 | for i = 1, bubbleRows do | ||
126 | row = { }; | ||
127 | for j = 1, bubbleCols do | ||
128 | image = edje.image(); | ||
129 | image:image("bubble.png"); | ||
130 | image:show(); | ||
131 | table.insert(row, image); | ||
132 | end | ||
133 | table.insert(bubbles, row); | ||
134 | end | ||
135 | |||
136 | function resize (w, h) | ||
137 | for i = 1, bubbleRows do | ||
138 | for j = 1, bubbleCols do | ||
139 | w1 = w / bubbleCols; | ||
140 | h1 = h / bubbleRows; | ||
141 | bubbles[i][j]:geom((j - 1) * w1, (i - 1) * h1, w1, h1); | ||
142 | if ((1 == i) or (1 == j) or (bubbleRows == i) or (bubbleCols == j)) then | ||
143 | bubbles[i][j]:color(0, 255, 0, 200); | ||
144 | else | ||
145 | bubbles[i][j]:color(math.random(200) + 55, 0, math.random(255) + 55, 200); | ||
146 | end | ||
147 | end | ||
148 | end | ||
149 | end | ||
150 | } | ||
151 | } | ||
152 | |||
153 | group { | ||
154 | name: "plain/edje/group"; | ||
155 | parts { | ||
156 | part { | ||
157 | name: "background"; | ||
158 | type: RECT; | ||
159 | mouse_events: 0; | ||
160 | description { | ||
161 | state: "default" 0.0; | ||
162 | color: 0 0 0 255; | ||
163 | } | ||
164 | } | ||
165 | |||
166 | // A lua group embedded in an edje group. | ||
167 | part { | ||
168 | name: "bubbles_lua"; | ||
169 | type: GROUP; | ||
170 | source: "bubbles/lua"; | ||
171 | mouse_events: 0; | ||
172 | description { state: "default" 0.0; } | ||
173 | } | ||
174 | |||
175 | part { | ||
176 | name: "background_image"; | ||
177 | type: IMAGE; | ||
178 | mouse_events: 0; | ||
179 | description { | ||
180 | state: "default" 0.0; | ||
181 | aspect_preference: HORIZONTAL; | ||
182 | color_class: "test_colour"; | ||
183 | image { normal: "test.png"; } | ||
184 | } | ||
185 | } | ||
186 | |||
187 | part { | ||
188 | name: "some_text"; | ||
189 | type: TEXT; | ||
190 | mouse_events: 0; | ||
191 | description { | ||
192 | state: "default" 0; | ||
193 | text | ||
194 | { | ||
195 | text: "This is test text."; | ||
196 | text_class: "test_text_class"; | ||
197 | } | ||
198 | } | ||
199 | } | ||
200 | |||
201 | } | ||
202 | } | ||
203 | |||
204 | } | ||
205 | |||
diff --git a/LuaSL/src/LuaSL.h b/LuaSL/src/LuaSL.h new file mode 100644 index 0000000..af87de5 --- /dev/null +++ b/LuaSL/src/LuaSL.h | |||
@@ -0,0 +1,64 @@ | |||
1 | //#include <Elementary.h> | ||
2 | #ifdef HAVE_CONFIG_H | ||
3 | #include "config.h" | ||
4 | #else | ||
5 | #define PACKAGE_EXAMPLES_DIR "." | ||
6 | #define __UNUSED__ | ||
7 | #endif | ||
8 | |||
9 | #include <Eet.h> | ||
10 | #include <Ecore.h> | ||
11 | #include <Ecore_Evas.h> | ||
12 | #include <Ecore_File.h> | ||
13 | #include <Edje.h> | ||
14 | #include <stdio.h> | ||
15 | #include <ctype.h> | ||
16 | |||
17 | #define WIDTH (1024) | ||
18 | #define HEIGHT (768) | ||
19 | |||
20 | #define PC(...) EINA_LOG_DOM_CRIT(game->logDom, __VA_ARGS__) | ||
21 | #define PE(...) EINA_LOG_DOM_ERR(game->logDom, __VA_ARGS__) | ||
22 | #define PW(...) EINA_LOG_DOM_WARN(game->logDom, __VA_ARGS__) | ||
23 | #define PD(...) EINA_LOG_DOM_DBG(game->logDom, __VA_ARGS__) | ||
24 | #define PI(...) EINA_LOG_DOM_INFO(game->logDom, __VA_ARGS__) | ||
25 | |||
26 | #define PCm(...) EINA_LOG_DOM_CRIT(game.logDom, __VA_ARGS__) | ||
27 | #define PEm(...) EINA_LOG_DOM_ERR(game.logDom, __VA_ARGS__) | ||
28 | #define PWm(...) EINA_LOG_DOM_WARN(game.logDom, __VA_ARGS__) | ||
29 | #define PDm(...) EINA_LOG_DOM_DBG(game.logDom, __VA_ARGS__) | ||
30 | #define PIm(...) EINA_LOG_DOM_INFO(game.logDom, __VA_ARGS__) | ||
31 | |||
32 | #define D() PD("DEBUG") | ||
33 | |||
34 | // "01:03:52 01-01-1973\n\0" | ||
35 | #define DATE_TIME_LEN 21 | ||
36 | |||
37 | #define TABLE_WIDTH 7 | ||
38 | #define TABLE_HEIGHT 42 | ||
39 | |||
40 | #ifndef FALSE | ||
41 | // NEVER change this | ||
42 | typedef enum | ||
43 | { | ||
44 | FALSE = 0, | ||
45 | TRUE = 1 | ||
46 | } boolean; | ||
47 | #endif | ||
48 | |||
49 | typedef struct | ||
50 | { | ||
51 | Ecore_Evas *ee; // Our window. | ||
52 | Evas *canvas; // The canvas for drawing directly onto. | ||
53 | Evas_Object *bg; // Our background edje, also the game specific stuff. | ||
54 | Evas_Object *edje; // The edje of the background. | ||
55 | int logDom; | ||
56 | } gameGlobals; | ||
57 | |||
58 | typedef void (*doSomething) (gameGlobals *game, unsigned char key); | ||
59 | |||
60 | void loggingStartup(gameGlobals *game); | ||
61 | char *getDateTime(struct tm **nowOut, char *dateOut, time_t *tiemOut); | ||
62 | float timeDiff(struct timeval *now, struct timeval *then); | ||
63 | |||
64 | |||
diff --git a/LuaSL/src/LuaSL_main.c b/LuaSL/src/LuaSL_main.c new file mode 100644 index 0000000..29b04d6 --- /dev/null +++ b/LuaSL/src/LuaSL_main.c | |||
@@ -0,0 +1,173 @@ | |||
1 | #include "LuaSL.h" | ||
2 | |||
3 | |||
4 | static const char *names[] = | ||
5 | { | ||
6 | "bub1", "sh1", | ||
7 | "bub2", "sh2", | ||
8 | "bub3", "sh3", | ||
9 | }; | ||
10 | |||
11 | |||
12 | static void | ||
13 | _edje_signal_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission, const char *source) | ||
14 | { | ||
15 | // gameGlobals *game = data; | ||
16 | } | ||
17 | |||
18 | static | ||
19 | Eina_Bool anim(void *data) | ||
20 | { | ||
21 | gameGlobals *game = data; | ||
22 | Evas_Object *bub, *sh; | ||
23 | Evas_Coord x, y, w, h, vw, vh; | ||
24 | double t, xx, yy, zz, r, fac; | ||
25 | double lx, ly; | ||
26 | unsigned int i; | ||
27 | |||
28 | evas_output_viewport_get(game->canvas, 0, 0, &vw, &vh); | ||
29 | r = 48; | ||
30 | t = ecore_loop_time_get(); | ||
31 | fac = 2.0 / (double)((sizeof(names) / sizeof(char *) / 2)); | ||
32 | evas_pointer_canvas_xy_get(game->canvas, &x, &y); | ||
33 | lx = x; | ||
34 | ly = y; | ||
35 | |||
36 | for (i = 0; i < (sizeof(names) / sizeof(char *) / 2); i++) | ||
37 | { | ||
38 | bub = evas_object_data_get(game->bg, names[i * 2]); | ||
39 | sh = evas_object_data_get(game->bg, names[(i * 2) + 1]); | ||
40 | zz = (((2 + sin(t * 6 + (M_PI * (i * fac)))) / 3) * 64) * 2; | ||
41 | xx = (cos(t * 4 + (M_PI * (i * fac))) * r) * 2; | ||
42 | yy = (sin(t * 6 + (M_PI * (i * fac))) * r) * 2; | ||
43 | |||
44 | w = zz; | ||
45 | h = zz; | ||
46 | x = (vw / 2) + xx - (w / 2); | ||
47 | y = (vh / 2) + yy - (h / 2); | ||
48 | |||
49 | evas_object_move(bub, x, y); | ||
50 | evas_object_resize(bub, w, h); | ||
51 | |||
52 | x = x - ((lx - (x + (w / 2))) / 4); | ||
53 | y = y - ((ly - (y + (h / 2))) / 4); | ||
54 | |||
55 | evas_object_move(sh, x, y); | ||
56 | evas_object_resize(sh, w, h); | ||
57 | evas_object_raise(sh); | ||
58 | evas_object_raise(bub); | ||
59 | } | ||
60 | return ECORE_CALLBACK_RENEW; | ||
61 | } | ||
62 | |||
63 | static void | ||
64 | _on_delete(Ecore_Evas *ee __UNUSED__) | ||
65 | { | ||
66 | ecore_main_loop_quit(); | ||
67 | } | ||
68 | |||
69 | int | ||
70 | main(int argc, char **argv) | ||
71 | { | ||
72 | /* put here any init specific to this app like parsing args etc. */ | ||
73 | gameGlobals game; | ||
74 | |||
75 | if (!ecore_evas_init()) | ||
76 | return EXIT_FAILURE; | ||
77 | |||
78 | if (!edje_init()) | ||
79 | { | ||
80 | ecore_evas_shutdown(); | ||
81 | return EXIT_FAILURE; | ||
82 | } | ||
83 | |||
84 | memset(&game, 0, sizeof(gameGlobals)); | ||
85 | // Since we increment at the begining, we need to pre decrement this so it starts at 0. | ||
86 | |||
87 | loggingStartup(&game); | ||
88 | |||
89 | // else if ((game.config) && (game.data)) | ||
90 | { | ||
91 | char buf[PATH_MAX]; | ||
92 | char *group = "main"; | ||
93 | Evas_Object *bub, *sh; | ||
94 | Ecore_Animator *ani; | ||
95 | unsigned int i; | ||
96 | |||
97 | /* this will give you a window with an Evas canvas under the first engine available */ | ||
98 | game.ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL); | ||
99 | if (!game.ee) | ||
100 | { | ||
101 | PEm("You got to have at least one evas engine built and linked up to ecore-evas for this example to run properly."); | ||
102 | edje_shutdown(); | ||
103 | ecore_evas_shutdown(); | ||
104 | return -1; | ||
105 | } | ||
106 | game.canvas = ecore_evas_get(game.ee); | ||
107 | ecore_evas_title_set(game.ee, "LuaoSL test harness"); | ||
108 | ecore_evas_show(game.ee); | ||
109 | |||
110 | game.bg = evas_object_rectangle_add(game.canvas); | ||
111 | evas_object_color_set(game.bg, 255, 255, 255, 255); /* white bg */ | ||
112 | evas_object_move(game.bg, 0, 0); /* at canvas' origin */ | ||
113 | evas_object_size_hint_weight_set(game.bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | ||
114 | evas_object_resize(game.bg, WIDTH, HEIGHT); /* covers full canvas */ | ||
115 | evas_object_show(game.bg); | ||
116 | ecore_evas_object_associate(game.ee, game.bg, ECORE_EVAS_OBJECT_ASSOCIATE_BASE); | ||
117 | evas_object_focus_set(game.bg, EINA_TRUE); | ||
118 | |||
119 | game.edje = edje_object_add(game.canvas); | ||
120 | snprintf(buf, sizeof(buf), "%s/%s.edj", PACKAGE_DATA_DIR, "LuaSL"); | ||
121 | if (!edje_object_file_set(game.edje, buf, group)) | ||
122 | { | ||
123 | int err = edje_object_load_error_get(game.edje); | ||
124 | const char *errmsg = edje_load_error_str(err); | ||
125 | PEm("Could not load '%s' from %s: %s\n", group, buf, errmsg); | ||
126 | |||
127 | evas_object_del(game.edje); | ||
128 | ecore_evas_free(game.ee); | ||
129 | edje_shutdown(); | ||
130 | ecore_evas_shutdown(); | ||
131 | return -2; | ||
132 | } | ||
133 | evas_object_move(game.edje, 0, 0); | ||
134 | evas_object_resize(game.edje, WIDTH, HEIGHT); | ||
135 | evas_object_show(game.edje); | ||
136 | |||
137 | snprintf(buf, sizeof(buf), "%s/images/bubble_sh.png", PACKAGE_DATA_DIR); | ||
138 | for (i = 0; i < (sizeof(names) / sizeof(char *) / 2); i++) | ||
139 | { | ||
140 | sh = evas_object_image_filled_add(game.canvas); | ||
141 | evas_object_image_file_set(sh, buf, NULL); | ||
142 | evas_object_resize(sh, 64, 64); | ||
143 | evas_object_show(sh); | ||
144 | evas_object_data_set(game.bg, names[(i * 2) + 1], sh); | ||
145 | } | ||
146 | |||
147 | snprintf(buf, sizeof(buf), "%s/images/bubble.png", PACKAGE_DATA_DIR); | ||
148 | for (i = 0; i < (sizeof(names) / sizeof(char *) / 2); i++) | ||
149 | { | ||
150 | bub = evas_object_image_filled_add(game.canvas); | ||
151 | evas_object_image_file_set(bub, buf, NULL); | ||
152 | evas_object_resize(bub, 64, 64); | ||
153 | evas_object_show(bub); | ||
154 | evas_object_data_set(game.bg, names[(i * 2)], bub); | ||
155 | } | ||
156 | ani = ecore_animator_add(anim, &game); | ||
157 | evas_object_data_set(game.bg, "animator", ani); | ||
158 | |||
159 | // Setup our callbacks. | ||
160 | ecore_evas_callback_delete_request_set(game.ee, _on_delete); | ||
161 | edje_object_signal_callback_add(game.edje, "*", "game_*", _edje_signal_cb, &game); | ||
162 | |||
163 | ecore_main_loop_begin(); | ||
164 | |||
165 | ecore_animator_del(ani); | ||
166 | ecore_evas_free(game.ee); | ||
167 | edje_shutdown(); | ||
168 | ecore_evas_shutdown(); | ||
169 | } | ||
170 | |||
171 | return 0; | ||
172 | } | ||
173 | |||
diff --git a/LuaSL/src/LuaSL_utilities.c b/LuaSL/src/LuaSL_utilities.c new file mode 100644 index 0000000..1675a92 --- /dev/null +++ b/LuaSL/src/LuaSL_utilities.c | |||
@@ -0,0 +1,101 @@ | |||
1 | #include "LuaSL.h" | ||
2 | |||
3 | |||
4 | // "01:03:52 01-01-1973\n\0" | ||
5 | # define DATE_TIME_LEN 21 | ||
6 | |||
7 | |||
8 | char dateTime[DATE_TIME_LEN]; | ||
9 | |||
10 | |||
11 | static | ||
12 | void _ggg_log_print_cb(const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc, int line, const char *fmt, void *data, va_list args) | ||
13 | { | ||
14 | FILE *f = data; | ||
15 | char dt[DATE_TIME_LEN + 1]; | ||
16 | char fileTab[256], funcTab[256]; | ||
17 | |||
18 | getDateTime(NULL, dt, NULL); | ||
19 | dt[19] = '\0'; | ||
20 | if (12 > strlen(file)) | ||
21 | snprintf(fileTab, sizeof(fileTab), "%s\t\t", file); | ||
22 | else | ||
23 | snprintf(fileTab, sizeof(fileTab), "%s\t", file); | ||
24 | snprintf(funcTab, sizeof(funcTab), "\t%s", fnc); | ||
25 | fprintf(f, "%s ", dt); | ||
26 | if (f == stderr) | ||
27 | eina_log_print_cb_stderr(d, level, fileTab, funcTab, line, fmt, data, args); | ||
28 | else if (f == stdout) | ||
29 | eina_log_print_cb_stdout(d, level, fileTab, funcTab, line, fmt, data, args); | ||
30 | fflush(f); | ||
31 | } | ||
32 | |||
33 | void loggingStartup(gameGlobals *game) | ||
34 | { | ||
35 | game->logDom = eina_log_domain_register("LuaSL", NULL); | ||
36 | if (game->logDom < 0) | ||
37 | { | ||
38 | EINA_LOG_CRIT("could not register log domain 'LuaSL'"); | ||
39 | } | ||
40 | // TODO - should unregister this later. | ||
41 | eina_log_level_set(EINA_LOG_LEVEL_DBG); | ||
42 | eina_log_domain_level_set("LuaSL", EINA_LOG_LEVEL_DBG); | ||
43 | // TODO - use a different domain for those things we need to log for legal reasons. | ||
44 | // Setup a callback that calls both the usual stderr callback AND the file one, | ||
45 | // but sending ggg domain messages to one file, and legal ones to another. | ||
46 | // Don't bother sending the ggg ones to the file if we are not embedded, we can see them on the terminal. | ||
47 | eina_log_print_cb_set(_ggg_log_print_cb, stderr); | ||
48 | } | ||
49 | |||
50 | char *getDateTime(struct tm **nowOut, char *dateOut, time_t *timeOut) | ||
51 | { | ||
52 | struct tm *newTime; | ||
53 | time_t szClock; | ||
54 | char *date = dateTime; | ||
55 | |||
56 | // Get time in seconds | ||
57 | time(&szClock); | ||
58 | // Convert time to struct tm form | ||
59 | newTime = localtime(&szClock); | ||
60 | |||
61 | if (nowOut) | ||
62 | *nowOut = newTime; | ||
63 | if (dateOut) | ||
64 | date = dateOut; | ||
65 | if (timeOut) | ||
66 | *timeOut = szClock; | ||
67 | |||
68 | // format | ||
69 | strftime(date, DATE_TIME_LEN, "%d/%m/%Y %H:%M:%S\r", newTime); | ||
70 | return (dateTime); | ||
71 | } | ||
72 | |||
73 | float timeDiff(struct timeval *now, struct timeval *then) | ||
74 | { | ||
75 | if (0 == gettimeofday(now, 0)) | ||
76 | { | ||
77 | struct timeval thisTime = { 0, 0 }; | ||
78 | double result = 0.0; | ||
79 | |||
80 | //fprintf(stderr, " %ld . %ld\n", now->tv_sec, now->tv_usec); | ||
81 | //fprintf(stderr, "minus %ld . %ld\n", then->tv_sec, then->tv_usec); | ||
82 | |||
83 | thisTime.tv_sec = now->tv_sec; | ||
84 | thisTime.tv_usec = now->tv_usec; | ||
85 | if (thisTime.tv_usec < then->tv_usec) | ||
86 | { | ||
87 | thisTime.tv_sec--; | ||
88 | thisTime.tv_usec += 1000000; | ||
89 | } | ||
90 | thisTime.tv_usec -= then->tv_usec; | ||
91 | thisTime.tv_sec -= then->tv_sec; | ||
92 | result = ((double) thisTime.tv_usec) / ((double) 1000000.0); | ||
93 | result += thisTime.tv_sec; | ||
94 | //fprintf(stderr, "equals %lf\n", result); | ||
95 | //fflush(stderr); | ||
96 | return result; | ||
97 | } | ||
98 | else | ||
99 | return 0.0; | ||
100 | } | ||
101 | |||
diff --git a/LuaSL/src/fonts/Vera.ttf b/LuaSL/src/fonts/Vera.ttf new file mode 100644 index 0000000..58cd6b5 --- /dev/null +++ b/LuaSL/src/fonts/Vera.ttf | |||
Binary files differ | |||
diff --git a/LuaSL/src/images/bubble.png b/LuaSL/src/images/bubble.png new file mode 100644 index 0000000..8fc50f9 --- /dev/null +++ b/LuaSL/src/images/bubble.png | |||
Binary files differ | |||
diff --git a/LuaSL/src/images/bubble_sh.png b/LuaSL/src/images/bubble_sh.png new file mode 100644 index 0000000..b66c1e6 --- /dev/null +++ b/LuaSL/src/images/bubble_sh.png | |||
Binary files differ | |||
diff --git a/LuaSL/src/images/test.png b/LuaSL/src/images/test.png new file mode 100644 index 0000000..fb620d7 --- /dev/null +++ b/LuaSL/src/images/test.png | |||
Binary files differ | |||