aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/love
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-05-13 13:15:42 +1000
committerDavid Walter Seikel2014-05-13 13:15:42 +1000
commitafd126e1d207c8fe7933562227f16684b00bfc7c (patch)
tree0f34168d20e485738fcfd1b5d67cf5e0d1bb8113 /src/love
parentDedicating my lifes work to my girl Boots. (diff)
downloadSledjHamr-afd126e1d207c8fe7933562227f16684b00bfc7c.zip
SledjHamr-afd126e1d207c8fe7933562227f16684b00bfc7c.tar.gz
SledjHamr-afd126e1d207c8fe7933562227f16684b00bfc7c.tar.bz2
SledjHamr-afd126e1d207c8fe7933562227f16684b00bfc7c.tar.xz
Finish separating out love.
Diffstat (limited to 'src/love')
-rw-r--r--src/love/love.c110
1 files changed, 87 insertions, 23 deletions
diff --git a/src/love/love.c b/src/love/love.c
index f3137b5..b0d1c05 100644
--- a/src/love/love.c
+++ b/src/love/love.c
@@ -4,8 +4,47 @@ Dedicated to my girl Boots, coz she means the world to me.
4 4
5*/ 5*/
6 6
7#include <Eet.h>
8#include <Ecore.h>
9#include <Ecore_Con.h>
10#include <Ecore_Evas.h>
11#include <Ecore_File.h>
12#include <Edje.h>
7 13
8#include "../LuaSL/LuaSL.h" 14#include "LumbrJack.h"
15#include "Runnr.h"
16
17
18#define WIDTH (512)
19#define HEIGHT (384)
20
21
22#define TABLE_WIDTH 7
23#define TABLE_HEIGHT 42
24
25
26typedef struct _gameGlobals
27{
28 Ecore_Evas *ee; // Our window.
29 Evas *canvas; // The canvas for drawing directly onto.
30 Evas_Object *bg; // Our background edje, also the game specific stuff.
31 Evas_Object *edje; // The edje of the background.
32 Ecore_Con_Server *server;
33 Eina_Hash *scripts;
34 const char *address;
35 int port;
36 boolean ui; // Wether we actually start up the UI.
37} gameGlobals;
38
39typedef struct _script
40{
41 char SID[PATH_MAX];
42 char fileName[PATH_MAX];
43 struct timeval startTime;
44 float compileTime;
45 int bugs, warnings;
46 boolean running;
47} script;
9 48
10 49
11int logDom; // Our logging domain. 50int logDom; // Our logging domain.
@@ -26,8 +65,33 @@ static const char *names[] =
26}; 65};
27 66
28 67
68static float timeDiff(struct timeval *now, struct timeval *then)
69{
70 if (0 == gettimeofday(now, 0))
71 {
72 struct timeval thisTime = { 0, 0 };
73 double result = 0.0;
74
75 thisTime.tv_sec = now->tv_sec;
76 thisTime.tv_usec = now->tv_usec;
77 if (thisTime.tv_usec < then->tv_usec)
78 {
79 thisTime.tv_sec--;
80 thisTime.tv_usec += 1000000;
81 }
82 thisTime.tv_usec -= then->tv_usec;
83 thisTime.tv_sec -= then->tv_sec;
84 result = ((double) thisTime.tv_usec) / ((double) 1000000.0);
85 result += thisTime.tv_sec;
86 return result;
87 }
88 else
89 return 0.0;
90}
91
92
29static void 93static void
30_edje_signal_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission, const char *source) 94_edje_signal_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
31{ 95{
32// gameGlobals *ourGlobals = data; 96// gameGlobals *ourGlobals = data;
33} 97}
@@ -78,7 +142,7 @@ Eina_Bool anim(void *data)
78} 142}
79 143
80static void 144static void
81_on_delete(Ecore_Evas *ee __UNUSED__) 145_on_delete(Ecore_Evas *ee)
82{ 146{
83 ecore_main_loop_quit(); 147 ecore_main_loop_quit();
84} 148}
@@ -100,7 +164,7 @@ static void dirList_compile(const char *name, const char *path, void *data)
100 snprintf(me->SID, sizeof(me->SID), "%08lx-%04lx-%04lx-%04lx-%012lx", random(), random() % 0xFFFF, random() % 0xFFFF, random() % 0xFFFF, random()); 164 snprintf(me->SID, sizeof(me->SID), "%08lx-%04lx-%04lx-%04lx-%012lx", random(), random() % 0xFFFF, random() % 0xFFFF, random() % 0xFFFF, random());
101 snprintf(me->fileName, sizeof(me->fileName), "%s/%s", path, name); 165 snprintf(me->fileName, sizeof(me->fileName), "%s/%s", path, name);
102 eina_hash_add(ourGlobals->scripts, me->SID, me); 166 eina_hash_add(ourGlobals->scripts, me->SID, me);
103 sendForth(ourGlobals, me->SID, "compile(%s)", me->fileName); 167 sendForth(ourGlobals->server, me->SID, "compile(%s)", me->fileName);
104 } 168 }
105 } 169 }
106} 170}
@@ -119,14 +183,14 @@ static Eina_Bool _timer_cb(void *data)
119 { 183 {
120 case 5 : 184 case 5 :
121 { 185 {
122 sendForth(ourGlobals, me->SID, "events.detectedKeys({\"%s\"})", ownerKey); 186 sendForth(ourGlobals->server, me->SID, "events.detectedKeys({\"%s\"})", ownerKey);
123 sendForth(ourGlobals, me->SID, "events.detectedNames({\"%s\"})", ownerName); 187 sendForth(ourGlobals->server, me->SID, "events.detectedNames({\"%s\"})", ownerName);
124 sendForth(ourGlobals, me->SID, "events.touch_start(1)"); 188 sendForth(ourGlobals->server, me->SID, "events.touch_start(1)");
125 break; 189 break;
126 } 190 }
127 case 9 : 191 case 9 :
128 { 192 {
129 sendForth(ourGlobals, me->SID, "quit()"); 193 sendForth(ourGlobals->server, me->SID, "quit()");
130 break; 194 break;
131 } 195 }
132 case 11 : 196 case 11 :
@@ -140,14 +204,14 @@ static Eina_Bool _timer_cb(void *data)
140 204
141 if (exit) 205 if (exit)
142 { 206 {
143 sendForth(ourGlobals, ownerKey, "exit()"); 207 sendForth(ourGlobals->server, ownerKey, "exit()");
144 ecore_main_loop_quit(); 208 ecore_main_loop_quit();
145 return ECORE_CALLBACK_CANCEL; 209 return ECORE_CALLBACK_CANCEL;
146 } 210 }
147 return ECORE_CALLBACK_RENEW; 211 return ECORE_CALLBACK_RENEW;
148} 212}
149 213
150static Eina_Bool _add(void *data, int type __UNUSED__, Ecore_Con_Event_Server_Add *ev) 214static Eina_Bool _add(void *data, int type, Ecore_Con_Event_Server_Add *ev)
151{ 215{
152 gameGlobals *ourGlobals = data; 216 gameGlobals *ourGlobals = data;
153 char buf[PATH_MAX]; 217 char buf[PATH_MAX];
@@ -161,7 +225,7 @@ static Eina_Bool _add(void *data, int type __UNUSED__, Ecore_Con_Event_Server_Ad
161 return ECORE_CALLBACK_RENEW; 225 return ECORE_CALLBACK_RENEW;
162} 226}
163 227
164static Eina_Bool _data(void *data, int type __UNUSED__, Ecore_Con_Event_Server_Data *ev) 228static Eina_Bool _data(void *data, int type, Ecore_Con_Event_Server_Data *ev)
165{ 229{
166 gameGlobals *ourGlobals = data; 230 gameGlobals *ourGlobals = data;
167 231
@@ -254,31 +318,31 @@ static Eina_Bool _data(void *data, int type __UNUSED__, Ecore_Con_Event_Server_D
254 PD("TOTAL compile speed is %f scripts per second", compiledCount / timeDiff(&now, &startTime)); 318 PD("TOTAL compile speed is %f scripts per second", compiledCount / timeDiff(&now, &startTime));
255 } 319 }
256// PD("The compile of %s worked, running it now.", SID); 320// PD("The compile of %s worked, running it now.", SID);
257 sendForth(ourGlobals, SID, "run()"); 321 sendForth(ourGlobals->server, SID, "run()");
258 } 322 }
259 else 323 else
260 { 324 {
261 // Send back some random or fixed values for testing. 325 // Send back some random or fixed values for testing.
262 if (0 == strcmp(command, "llGetKey()")) 326 if (0 == strcmp(command, "llGetKey()"))
263 sendForth(ourGlobals, SID, "return \"%08lx-%04lx-%04lx-%04lx-%012lx\"", random(), random() % 0xFFFF, random() % 0xFFFF, random() % 0xFFFF, random()); 327 sendForth(ourGlobals->server, SID, "return \"%08lx-%04lx-%04lx-%04lx-%012lx\"", random(), random() % 0xFFFF, random() % 0xFFFF, random() % 0xFFFF, random());
264 else if (0 == strcmp(command, "llGetOwner()")) 328 else if (0 == strcmp(command, "llGetOwner()"))
265 sendForth(ourGlobals, SID, "return \"%s\"", ownerKey); 329 sendForth(ourGlobals->server, SID, "return \"%s\"", ownerKey);
266 else if (0 == strcmp(command, "llGetPos()")) 330 else if (0 == strcmp(command, "llGetPos()"))
267 sendForth(ourGlobals, SID, "return {x=128.0, y=128.0, z=128.0}"); 331 sendForth(ourGlobals->server, SID, "return {x=128.0, y=128.0, z=128.0}");
268 else if (0 == strcmp(command, "llGetRot()")) 332 else if (0 == strcmp(command, "llGetRot()"))
269 sendForth(ourGlobals, SID, "return {x=0.0, y=0.0, z=0.0, s=1.0}"); 333 sendForth(ourGlobals->server, SID, "return {x=0.0, y=0.0, z=0.0, s=1.0}");
270 else if (0 == strcmp(command, "llGetObjectDesc()")) 334 else if (0 == strcmp(command, "llGetObjectDesc()"))
271 sendForth(ourGlobals, SID, "return \"\""); 335 sendForth(ourGlobals->server, SID, "return \"\"");
272 else if (0 == strncmp(command, "llGetAlpha(", 11)) 336 else if (0 == strncmp(command, "llGetAlpha(", 11))
273 sendForth(ourGlobals, SID, "return 1.0"); 337 sendForth(ourGlobals->server, SID, "return 1.0");
274 else if (0 == strcmp(command, "llGetInventoryNumber(7)")) 338 else if (0 == strcmp(command, "llGetInventoryNumber(7)"))
275 sendForth(ourGlobals, SID, "return 3"); 339 sendForth(ourGlobals->server, SID, "return 3");
276 else if (0 == strcmp(command, "llGetInventoryName(7, 2)")) 340 else if (0 == strcmp(command, "llGetInventoryName(7, 2)"))
277 sendForth(ourGlobals, SID, "return \".readme\""); 341 sendForth(ourGlobals->server, SID, "return \".readme\"");
278 else if (0 == strcmp(command, "llGetInventoryName(7, 1)")) 342 else if (0 == strcmp(command, "llGetInventoryName(7, 1)"))
279 sendForth(ourGlobals, SID, "return \".POSITIONS\""); 343 sendForth(ourGlobals->server, SID, "return \".POSITIONS\"");
280 else if (0 == strcmp(command, "llGetInventoryName(7, 0)")) 344 else if (0 == strcmp(command, "llGetInventoryName(7, 0)"))
281 sendForth(ourGlobals, SID, "return \".MENUITEMS\""); 345 sendForth(ourGlobals->server, SID, "return \".MENUITEMS\"");
282 else 346 else
283 PI("Script %s sent command %s", SID, command); 347 PI("Script %s sent command %s", SID, command);
284 } 348 }
@@ -291,7 +355,7 @@ static Eina_Bool _data(void *data, int type __UNUSED__, Ecore_Con_Event_Server_D
291 return ECORE_CALLBACK_RENEW; 355 return ECORE_CALLBACK_RENEW;
292} 356}
293 357
294static Eina_Bool _del(void *data, int type __UNUSED__, Ecore_Con_Event_Server_Del *ev) 358static Eina_Bool _del(void *data, int type, Ecore_Con_Event_Server_Del *ev)
295{ 359{
296 gameGlobals *ourGlobals = data; 360 gameGlobals *ourGlobals = data;
297 361