aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/extantz/extantz.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/extantz/extantz.c')
-rw-r--r--src/extantz/extantz.c92
1 files changed, 52 insertions, 40 deletions
diff --git a/src/extantz/extantz.c b/src/extantz/extantz.c
index 3da9643..07fe817 100644
--- a/src/extantz/extantz.c
+++ b/src/extantz/extantz.c
@@ -5,6 +5,10 @@
5#include "LumbrJack.h" 5#include "LumbrJack.h"
6 6
7 7
8static void _onWorldClick(void *data, Evas *e EINA_UNUSED, Evas_Object *o, void *einfo);
9static void on_pixels(void *data, Evas_Object *obj);
10
11
8static int logDom; // Our logging domain. 12static int logDom; // Our logging domain.
9globals ourGlobals; 13globals ourGlobals;
10static Eina_Strbuf *serverStream; 14static Eina_Strbuf *serverStream;
@@ -15,7 +19,19 @@ static Eina_Bool _add(void *data, int type, Ecore_Con_Event_Server_Add *ev)
15{ 19{
16 globals *ourGlobals = data; 20 globals *ourGlobals = data;
17 21
22 PI("Server connected.");
18 ourGlobals->server = ev->server; 23 ourGlobals->server = ev->server;
24 if (ourGlobals->LSLGuiMess) ourGlobals->LSLGuiMess->server = ourGlobals->server;
25 if (ourGlobals->purkle) ourGlobals->purkle->server = ourGlobals->server;
26
27 Evas_3D_Demo_add(ourGlobals);
28 // TODO - Just a temporary hack so Irrlicht and Evas_3D can share the camera move.
29 ourGlobals->gld.move = ourGlobals->scene->move;
30 evas_object_data_set(elm_image_object_get(ourGlobals->scene->image), "glob", ourGlobals);
31 evas_object_image_pixels_get_callback_set(elm_image_object_get(ourGlobals->scene->image), on_pixels, ourGlobals);
32 // Setup our callback for clicking in world.
33 ourGlobals->scene->clickCb = _onWorldClick;
34
19 return ECORE_CALLBACK_RENEW; 35 return ECORE_CALLBACK_RENEW;
20} 36}
21 37
@@ -46,25 +62,33 @@ static Eina_Bool _data(void *data, int type, Ecore_Con_Event_Server_Data *ev)
46 || (0 == strncmp(command, "llSay(", 6)) 62 || (0 == strncmp(command, "llSay(", 6))
47 || (0 == strncmp(command, "llShout(", 8))) 63 || (0 == strncmp(command, "llShout(", 8)))
48 { 64 {
49 int _P;
50// char *name = "that's me";
51
52 lua_getfield(ourGlobals->purkle->L, LUA_REGISTRYINDEX, ourGlobals->purkle->name);
53 _P = lua_gettop(ourGlobals->purkle->L);
54 65
55 sprintf(buf, "%s: %s", SID, command); 66 sprintf(buf, "%s: %s", SID, command);
56 push_lua(ourGlobals->purkle->L, "@ ( $ )", _P, "append", buf, 0); 67 if (ourGlobals->purkle)
57// push_lua(ourGlobals->purkle->L, "@ ( $ % $ $ $ )", _P, "say", _P, name, SID, buf, 0); 68 {
69 int _P;
70
71 lua_getfield(ourGlobals->purkle->L, LUA_REGISTRYINDEX, ourGlobals->purkle->name);
72 _P = lua_gettop(ourGlobals->purkle->L);
73 push_lua(ourGlobals->purkle->L, "@ ( $ )", _P, "append", buf, 0);
74 }
75 else
76 PW("No purkle to put - %s", buf);
58 } 77 }
59 else if (0 == strncmp(command, "llDialog(", 9)) 78 else if (0 == strncmp(command, "llDialog(", 9))
60 { 79 {
61 int _M; 80 if (ourGlobals->LSLGuiMess)
81 {
82 int _M;
62 83
63 lua_getfield(ourGlobals->LSLGuiMess->L, LUA_REGISTRYINDEX, ourGlobals->LSLGuiMess->name); 84 lua_getfield(ourGlobals->LSLGuiMess->L, LUA_REGISTRYINDEX, ourGlobals->LSLGuiMess->name);
64 _M = lua_gettop(ourGlobals->LSLGuiMess->L); 85 _M = lua_gettop(ourGlobals->LSLGuiMess->L);
65 86
66 // TODO - Somewhere in the chain the new lines that MLP likes to put into llDialog's message munge things. Fix that. 87 // TODO - Somewhere in the chain the new lines that MLP likes to put into llDialog's message munge things. Fix that.
67 push_lua(ourGlobals->LSLGuiMess->L, "@ ( $ )", _M, "doLua", command, 0); 88 push_lua(ourGlobals->LSLGuiMess->L, "@ ( $ )", _M, "doLua", command, 0);
89 }
90 else
91 PE("No LSLGuiMess to send - %s", command);
68 92
69 } 93 }
70 else 94 else
@@ -86,11 +110,16 @@ static Eina_Bool _del(void *data, int type, Ecore_Con_Event_Server_Del *ev)
86 110
87 if (ev->server) 111 if (ev->server)
88 { 112 {
89 ecore_con_server_del(ourGlobals->server); 113 ecore_con_server_del(ev->server);
90 ourGlobals->server = NULL; 114 ourGlobals->server = NULL;
115 if (ourGlobals->running)
116 {
117 PW("Server dropped out, trying to reconnect.");
118 ourGlobals->server = reachOut("127.0.0.1", 8211 + 1, ourGlobals, (Ecore_Event_Handler_Cb) _add, (Ecore_Event_Handler_Cb) _data, (Ecore_Event_Handler_Cb) _del);
119 }
91 } 120 }
92 121
93 return ECORE_CALLBACK_RENEW; 122 return ECORE_CALLBACK_CANCEL;
94} 123}
95 124
96static void _onWorldClick(void *data, Evas *e EINA_UNUSED, Evas_Object *o, void *einfo) 125static void _onWorldClick(void *data, Evas *e EINA_UNUSED, Evas_Object *o, void *einfo)
@@ -317,7 +346,7 @@ static Eina_Bool doFrame(void *data)
317 // Either way, _draw_gl gets called eventully. 346 // Either way, _draw_gl gets called eventully.
318 if (gld->elmGl) 347 if (gld->elmGl)
319 elm_glview_changed_set(gld->elmGl); 348 elm_glview_changed_set(gld->elmGl);
320 else if (ourGlobals->scene->image) 349 else if ((ourGlobals->scene) && (ourGlobals->scene->image))
321 { 350 {
322// evas_object_image_pixels_dirty_set(elm_image_object_get(ourGlobals->scene->image), EINA_TRUE); 351// evas_object_image_pixels_dirty_set(elm_image_object_get(ourGlobals->scene->image), EINA_TRUE);
323 _draw_gl(elm_image_object_get(ourGlobals->scene->image)); 352 _draw_gl(elm_image_object_get(ourGlobals->scene->image));
@@ -534,6 +563,7 @@ EAPI_MAIN int elm_main(int argc, char **argv)
534 fprintf(stdout, "locale directory is: %s\n", elm_app_locale_dir_get()); 563 fprintf(stdout, "locale directory is: %s\n", elm_app_locale_dir_get());
535 564
536 logDom = loggingStartup("extantz", logDom); 565 logDom = loggingStartup("extantz", logDom);
566 ourGlobals.running = 1;
537 567
538 // Add extras, so we can run test.lua later. 568 // Add extras, so we can run test.lua later.
539 env = getenv("LUA_CPATH"); 569 env = getenv("LUA_CPATH");
@@ -638,12 +668,6 @@ EAPI_MAIN int elm_main(int argc, char **argv)
638 668
639 init_evas_gl(&ourGlobals); 669 init_evas_gl(&ourGlobals);
640 670
641 Evas_3D_Demo_add(&ourGlobals);
642 // TODO - Just a temporary hack so Irrlicht and Evas_3D can share the camera move.
643 ourGlobals.gld.move = ourGlobals.scene->move;
644 evas_object_data_set(elm_image_object_get(ourGlobals.scene->image), "glob", &ourGlobals);
645 evas_object_image_pixels_get_callback_set(elm_image_object_get(ourGlobals.scene->image), on_pixels, &ourGlobals);
646
647 // Gotta do this after adding the windows, otherwise the menu renders under the window. 671 // Gotta do this after adding the windows, otherwise the menu renders under the window.
648 // This sucks, gotta redefine this menu each time we create a new window? 672 // This sucks, gotta redefine this menu each time we create a new window?
649 // Also, GL focus gets lost when any menu is used. sigh 673 // Also, GL focus gets lost when any menu is used. sigh
@@ -651,36 +675,24 @@ EAPI_MAIN int elm_main(int argc, char **argv)
651 675
652 ourGlobals.world = ephysicsAdd(&ourGlobals); 676 ourGlobals.world = ephysicsAdd(&ourGlobals);
653 677
654 // Try to connect to the love server we started before.
655 ourGlobals.address = "127.0.0.1";
656 ourGlobals.port = 8211;
657 sleep(2);
658 if ((ourGlobals.server = ecore_con_server_connect(ECORE_CON_REMOTE_TCP, ourGlobals.address, ourGlobals.port + 1, &ourGlobals)))
659 {
660 ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD, (Ecore_Event_Handler_Cb) _add, &ourGlobals);
661 ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA, (Ecore_Event_Handler_Cb) _data, &ourGlobals);
662 ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DEL, (Ecore_Event_Handler_Cb) _del, &ourGlobals);
663 serverStream = eina_strbuf_new();
664 }
665 else
666 PC("Failed to connect to server!");
667
668// overlay_add(&ourGlobals); 678// overlay_add(&ourGlobals);
669// GuiLuaLoad("test", ourGlobals.mainWindow, ourGlobals.world); 679// GuiLuaLoad("test", ourGlobals.mainWindow, ourGlobals.world);
670 woMan_add(&ourGlobals); 680 woMan_add(&ourGlobals);
671 ourGlobals.LSLGuiMess = GuiLuaLoad("LSLGuiMess", ourGlobals.mainWindow, ourGlobals.server, ourGlobals.world); 681 ourGlobals.purkle = GuiLuaLoad("purkle", ourGlobals.mainWindow, ourGlobals.world);
672 ourGlobals.purkle = GuiLuaLoad("purkle", ourGlobals.mainWindow, ourGlobals.server, ourGlobals.world); 682 ourGlobals.LSLGuiMess = GuiLuaLoad("LSLGuiMess", ourGlobals.mainWindow, ourGlobals.world);
673 ourGlobals.files = filesAdd(&ourGlobals, (char *) elm_app_data_dir_get(), EINA_TRUE, EINA_FALSE); 683 ourGlobals.files = filesAdd(&ourGlobals, (char *) elm_app_data_dir_get(), EINA_TRUE, EINA_FALSE);
674 684
685 // Try to connect to the love server we started before.
686 serverStream = eina_strbuf_new();
687 reachOut("127.0.0.1", 8211 + 1, &ourGlobals, (Ecore_Event_Handler_Cb) _add, (Ecore_Event_Handler_Cb) _data, (Ecore_Event_Handler_Cb) _del);
688
675 // Bump the top toolbar above the windows. 689 // Bump the top toolbar above the windows.
676 evas_object_raise(ourGlobals.tb); 690 evas_object_raise(ourGlobals.tb);
677 691
678 _on_resize(&ourGlobals, NULL, NULL, NULL); 692 _on_resize(&ourGlobals, NULL, NULL, NULL);
679 693
680 // Setup our callback for clicking in world.
681 ourGlobals.scene->clickCb = _onWorldClick;
682
683 elm_run(); 694 elm_run();
695 ourGlobals.running = 0;
684 696
685 ephysics_world_del(ourGlobals.world); 697 ephysics_world_del(ourGlobals.world);
686 ephysics_shutdown(); 698 ephysics_shutdown();