aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/extantz/extantz.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/extantz/extantz.c199
1 files changed, 82 insertions, 117 deletions
diff --git a/src/extantz/extantz.c b/src/extantz/extantz.c
index f4f602e..bf721e2 100644
--- a/src/extantz/extantz.c
+++ b/src/extantz/extantz.c
@@ -17,6 +17,7 @@ globals ourGlobals;
17 17
18 18
19 19
20#if USE_LOVE
20static Eina_Bool _add(void *data, int type, Ecore_Con_Event_Server_Add *ev) 21static Eina_Bool _add(void *data, int type, Ecore_Con_Event_Server_Add *ev)
21{ 22{
22 globals *ourGlobals = data; 23 globals *ourGlobals = data;
@@ -126,6 +127,7 @@ static Eina_Bool _del(void *data, int type, Ecore_Con_Event_Server_Del *ev)
126 127
127 return ECORE_CALLBACK_CANCEL; 128 return ECORE_CALLBACK_CANCEL;
128} 129}
130#endif
129 131
130#if USE_EVAS_3D 132#if USE_EVAS_3D
131static void _onWorldClick(void *data, Evas *e EINA_UNUSED, Evas_Object *o, void *einfo) 133static void _onWorldClick(void *data, Evas *e EINA_UNUSED, Evas_Object *o, void *einfo)
@@ -234,8 +236,10 @@ static void _on_resize(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA
234 ); 236 );
235 // Stop internal windows going under the toolbar. 237 // Stop internal windows going under the toolbar.
236 evas_object_resize(ourGlobals->mainWindow->layout, ourGlobals->win_w, h); 238 evas_object_resize(ourGlobals->mainWindow->layout, ourGlobals->win_w, h);
239#if USE_EPHYSICS
237 if (ourGlobals->world) 240 if (ourGlobals->world)
238 ephysics_world_render_geometry_set(ourGlobals->world, 0, 0, -50, ourGlobals->win_w, ourGlobals->win_h, 100); 241 ephysics_world_render_geometry_set(ourGlobals->world, 0, 0, -50, ourGlobals->win_w, ourGlobals->win_h, 100);
242#endif
239 _resize(gld); 243 _resize(gld);
240} 244}
241 245
@@ -424,27 +428,24 @@ static winFang *_makeMainMenu(globals *ourGlobals)
424 428
425 // GL focus gets lost when any menu is used. sigh 429 // GL focus gets lost when any menu is used. sigh
426 430
427 // Try to work around the borkedness of EFL menus by creating our own window.
428 // I can't figure it out, but the main menu wont appear otherwise. It worked before.
429 // TODO - rip out ELMs menu and create my own. It sucks. 431 // TODO - rip out ELMs menu and create my own. It sucks.
430 me = winFangAdd(ourGlobals->mainWindow, 0, -4, ourGlobals->win_w, 0, "main menu hack", "mainMenu", ourGlobals->world); 432 me = ourGlobals->mainWindow;
431
432 tb = makeMainMenu(me); 433 tb = makeMainMenu(me);
433 ourGlobals->tb = tb; 434 ourGlobals->tb = tb;
434 435
435 menu = menuAdd(ourGlobals->mainWindow, tb, "file"); 436 menu = menuAdd(me, tb, "file");
436 // Evas_Object *obj, Elm_Object_Item *parent, const char *icon, const char *label, Evas_Smart_Cb func, const void *data 437 // Evas_Object *obj, Elm_Object_Item *parent, const char *icon, const char *label, Evas_Smart_Cb func, const void *data
437 elm_menu_item_add(menu, NULL, NULL, "open", _on_open, ourGlobals); 438 elm_menu_item_add(menu, NULL, NULL, "open", _on_open, ourGlobals);
438 elm_menu_item_add(menu, NULL, NULL, "quit", _on_done, gld); 439 elm_menu_item_add(menu, NULL, NULL, "quit", _on_done, gld);
439 440
440 menu = menuAdd(ourGlobals->mainWindow, tb, "edit"); 441 menu = menuAdd(me, tb, "edit");
441 elm_menu_item_add(menu, NULL, NULL, "preferences", NULL, NULL); 442 elm_menu_item_add(menu, NULL, NULL, "preferences", NULL, NULL);
442 443
443 menu = menuAdd(ourGlobals->mainWindow, tb, "view"); 444 menu = menuAdd(me, tb, "view");
444 menu = menuAdd(ourGlobals->mainWindow, tb, "world"); 445 menu = menuAdd(me, tb, "world");
445 menu = menuAdd(ourGlobals->mainWindow, tb, "tools"); 446 menu = menuAdd(me, tb, "tools");
446 447
447 menu = menuAdd(ourGlobals->mainWindow, tb, "help"); 448 menu = menuAdd(me, tb, "help");
448 elm_menu_item_add(menu, NULL, NULL, "grid help", NULL, NULL); 449 elm_menu_item_add(menu, NULL, NULL, "grid help", NULL, NULL);
449 elm_menu_item_separator_add(menu, NULL); 450 elm_menu_item_separator_add(menu, NULL);
450 elm_menu_item_add(menu, NULL, NULL, "extantz blogs", NULL, NULL); 451 elm_menu_item_add(menu, NULL, NULL, "extantz blogs", NULL, NULL);
@@ -452,10 +453,10 @@ static winFang *_makeMainMenu(globals *ourGlobals)
452 elm_menu_item_separator_add(menu, NULL); 453 elm_menu_item_separator_add(menu, NULL);
453 elm_menu_item_add(menu, NULL, NULL, "about extantz", NULL, NULL); 454 elm_menu_item_add(menu, NULL, NULL, "about extantz", NULL, NULL);
454 455
455 menu = menuAdd(ourGlobals->mainWindow, tb, "advanced"); 456 menu = menuAdd(me, tb, "advanced");
456 elm_menu_item_add(menu, NULL, NULL, "debug settings", NULL, NULL); 457 elm_menu_item_add(menu, NULL, NULL, "debug settings", NULL, NULL);
457 458
458 menu = menuAdd(ourGlobals->mainWindow, tb, "god"); 459 menu = menuAdd(me, tb, "god");
459 460
460 makeMainMenuFinish(me, tb); 461 makeMainMenuFinish(me, tb);
461 462
@@ -466,7 +467,7 @@ static winFang *_makeMainMenu(globals *ourGlobals)
466 it = elm_toolbar_item_append(tb, NULL, NULL, NULL, NULL); elm_toolbar_item_separator_set(it, EINA_TRUE); 467 it = elm_toolbar_item_append(tb, NULL, NULL, NULL, NULL); elm_toolbar_item_separator_set(it, EINA_TRUE);
467 it = elm_toolbar_item_append(tb, NULL, "date time:o'clock", NULL, NULL); 468 it = elm_toolbar_item_append(tb, NULL, "date time:o'clock", NULL, NULL);
468 469
469 winFangCalcMinSize(me); 470 elm_layout_box_prepend(me->layout, WF_BOX, tb);
470 471
471 return me; 472 return me;
472} 473}
@@ -524,106 +525,62 @@ void overlay_add(globals *ourGlobals)
524} 525}
525 526
526 527
527// Use jobs to split the init load. So that the window pops up quickly, with it's background clouds. 528// Use jobs or timers to split the init load. So that the window pops up quickly, with it's background clouds.
528// Then the rest appears a bit at a time. 529// Then the rest appears a bit at a time.
529static Eina_Bool _makePhysics(void *data) 530int skangStep = 0;
530{ 531static Eina_Bool _makeSkang(void *data)
531 globals *ourGlobals = data;
532
533 if (ephysics_init())
534 ourGlobals->world = ephysicsAdd(ourGlobals);
535
536 return ECORE_CALLBACK_CANCEL;
537}
538
539static Eina_Bool _makeFiles(void *data)
540{
541 globals *ourGlobals = data;
542
543 ecore_job_add((Ecore_Cb) _makePhysics, ourGlobals);
544// ecore_timer_add(0.1, _makePhysics, ourGlobals);
545
546 ourGlobals->files = filesAdd(ourGlobals, (char *) prefix_data_get(), EINA_TRUE, EINA_FALSE);
547
548 return ECORE_CALLBACK_CANCEL;
549}
550
551static Eina_Bool _makeLove(void *data)
552{
553 globals *ourGlobals = data;
554
555 ecore_job_add((Ecore_Cb) _makeFiles, ourGlobals);
556// ecore_timer_add(0.1, _makeFiles, ourGlobals);
557
558// PD("About to try connecting to a love server.");
559 reachOut("love", "./love", "127.0.0.1", 8211 + 1, ourGlobals, (Ecore_Event_Handler_Cb) _add, /*(Ecore_Event_Handler_Cb) _data*/ NULL, (Ecore_Event_Handler_Cb) _del, clientParser);
560
561 return ECORE_CALLBACK_CANCEL;
562}
563
564static Eina_Bool _makeMess(void *data)
565{ 532{
566 globals *ourGlobals = data; 533 globals *ourGlobals = data;
567 534
568 ecore_job_add((Ecore_Cb) _makeLove, ourGlobals); 535 switch (skangStep++)
569// ecore_timer_add(0.1, _makeLove, ourGlobals); 536 {
570 537#if USE_SKANG
571// ourGlobals->LSLGuiMess = GuiLuaLoad("LSLGuiMess", ourGlobals->mainWindow, ourGlobals->world); 538 case 0 : ourGlobals->purkle = GuiLuaLoad("purkle", ourGlobals->mainWindow, ourGlobals->world); break;
572 539 case 1 : ourGlobals->LSLGuiMess = GuiLuaLoad("LSLGuiMess", ourGlobals->mainWindow, ourGlobals->world); break;
573 return ECORE_CALLBACK_CANCEL; 540 case 2 : ourGlobals->files = filesAdd(ourGlobals, (char *) prefix_data_get(), EINA_TRUE, EINA_FALSE); break;
574} 541#endif
575 542
576static Eina_Bool _makeScenery(void *data)
577{
578#if USE_EVAS_3D 543#if USE_EVAS_3D
579 globals *ourGlobals = data; 544 case 3 :
580 545 // Setup our Evas_3D stuff.
581 ecore_job_add((Ecore_Cb) _makeMess, ourGlobals); 546 ourGlobals->scene = scenriAdd(ourGlobals->win);
582// ecore_timer_add(0.1, _makeMess, ourGlobals); 547 // TODO - Just a temporary hack so Irrlicht and Evas_3D can share the camera move.
583 548// ourGlobals->gld->move = ourGlobals->scene->move;
584 // Setup our Evas_3D stuff. 549 evas_object_data_set(elm_image_object_get(ourGlobals->scene->image), "glob", ourGlobals);
585 ourGlobals->scene = scenriAdd(ourGlobals->win); 550 evas_object_image_pixels_get_callback_set(elm_image_object_get(ourGlobals->scene->image), on_pixels, ourGlobals);
586 // TODO - Just a temporary hack so Irrlicht and Evas_3D can share the camera move. 551 ourGlobals->scene->clickCb = _onWorldClick;
587// ourGlobals->gld->move = ourGlobals->scene->move; 552 break;
588 evas_object_data_set(elm_image_object_get(ourGlobals->scene->image), "glob", ourGlobals);
589 evas_object_image_pixels_get_callback_set(elm_image_object_get(ourGlobals->scene->image), on_pixels, ourGlobals);
590 ourGlobals->scene->clickCb = _onWorldClick;
591#endif 553#endif
592 554
593 return ECORE_CALLBACK_CANCEL; 555 // TODO - When the menus get fixed, we can bunch these all up with the rest of skang above.
594} 556#if USE_SKANG
595 557 case 4 : woMan_add(ourGlobals); break;
596static Eina_Bool _makeMenus(void *data) 558#endif
597{
598 globals *ourGlobals = data;
599
600// ecore_job_add((Ecore_Cb) _makeScenery, ourGlobals);
601 ecore_timer_add(0.5, _makeScenery, ourGlobals);
602
603 // Gotta do this after adding the windows, otherwise the menu renders under the window.
604 // This sucks, gotta redefine this menu each time we create a new window?
605 _makeMainMenu(ourGlobals);
606
607 return ECORE_CALLBACK_CANCEL;
608}
609
610static Eina_Bool _makePurkle(void *data)
611{
612 globals *ourGlobals = data;
613
614// ecore_job_add((Ecore_Cb) _makeMenus, ourGlobals);
615 ecore_timer_add(1.0, _makeMenus, ourGlobals);
616 559
617 woMan_add(ourGlobals); 560#if USE_LOVE
618 ourGlobals->purkle = GuiLuaLoad("purkle", ourGlobals->mainWindow, ourGlobals->world); 561 case 5 :
619 ourGlobals->LSLGuiMess = GuiLuaLoad("LSLGuiMess", ourGlobals->mainWindow, ourGlobals->world); 562// PD("About to try connecting to a love server.");
620// ourGlobals->files = filesAdd(ourGlobals, (char *) prefix_data_get(), EINA_TRUE, EINA_FALSE); 563 reachOut("love", "./love", "127.0.0.1", 8211 + 1, ourGlobals, (Ecore_Event_Handler_Cb) _add, /*(Ecore_Event_Handler_Cb) _data*/ NULL, (Ecore_Event_Handler_Cb) _del, clientParser);
564 break;
565#endif
621 566
622 // Gotta do this after adding the windows, otherwise the menu renders under the window. 567 case 6 :
623 // This sucks, gotta redefine this menu each time we create a new window? 568 // Gotta do this after adding the windows, otherwise the menu renders under the window.
624// _makeMainMenu(ourGlobals); 569 // This sucks, gotta redefine this menu each time we create a new window?
570 _makeMainMenu(ourGlobals);
571 break;
572
573 default :
574 // Menus and toolbars suck, so gotta kick it again here. Which is still not reliable.
575 elm_layout_sizing_eval(ourGlobals->mainWindow->layout);
576 _on_resize(ourGlobals, NULL, NULL, NULL);
577// ecore_job_add((Ecore_Cb) _makeScenery, ourGlobals);
578// ecore_timer_add(0.5, _makeScenery, ourGlobals);
579 return ECORE_CALLBACK_CANCEL;
580 break;
581 }
625 582
626 return ECORE_CALLBACK_CANCEL; 583 return ECORE_CALLBACK_RENEW;
627} 584}
628 585
629EAPI_MAIN int elm_main(int argc, char **argv) 586EAPI_MAIN int elm_main(int argc, char **argv)
@@ -664,8 +621,19 @@ EAPI_MAIN int elm_main(int argc, char **argv)
664 elm_config_preferred_engine_set("opengl_x11"); 621 elm_config_preferred_engine_set("opengl_x11");
665 elm_config_accel_preference_set("3d"); 622 elm_config_accel_preference_set("3d");
666 623
667 ourGlobals.mainWindow = winFangAdd(NULL, 0, 0, 50, 20, "extantz virtual world viewer", "extantz", NULL); 624 // Get the screen size.
625 // Found a use for a splash screen, though it's never visible, and even if it was, you would never see it. lol
626 ourGlobals.win = elm_win_add(NULL, "extantz", ELM_WIN_SPLASH);
627 elm_win_screen_size_get(ourGlobals.win, &ourGlobals.win_x, &ourGlobals.win_y, &ourGlobals.scr_w, &ourGlobals.scr_h);
628 ourGlobals.win_x = ourGlobals.win_x + (ourGlobals.scr_w / 3);
629 // TODO - Now we have to take the frame height into consideration, didn't have to do that before. Faked for now.
630 ourGlobals.win_y += 25;
631 ourGlobals.win_w = ourGlobals.scr_w / 2;
632 ourGlobals.win_h = ourGlobals.scr_h - 25;
633 evas_object_del(ourGlobals.win);
668 634
635 // Create the main window.
636 ourGlobals.mainWindow = winFangAdd(NULL, ourGlobals.win_x, ourGlobals.win_y, ourGlobals.win_w, ourGlobals.win_h, "extantz virtual world viewer", "extantz", NULL);
669 ourGlobals.win = ourGlobals.mainWindow->win; 637 ourGlobals.win = ourGlobals.mainWindow->win;
670 // TODO, or not TODO - I keep getting rid of these, but keep bringing them back. 638 // TODO, or not TODO - I keep getting rid of these, but keep bringing them back.
671 // Get the Evas / canvas from the elm window (that the Evas_Object "lives on"), which is itself an Evas_Object created by Elm, so not sure if it was created internally with Ecore_Evas. 639 // Get the Evas / canvas from the elm window (that the Evas_Object "lives on"), which is itself an Evas_Object created by Elm, so not sure if it was created internally with Ecore_Evas.
@@ -676,16 +644,6 @@ EAPI_MAIN int elm_main(int argc, char **argv)
676 ourGlobals.ee = ecore_evas_ecore_evas_get(ourGlobals.evas); // Only use this on Evas that was created with Ecore_Evas. 644 ourGlobals.ee = ecore_evas_ecore_evas_get(ourGlobals.evas); // Only use this on Evas that was created with Ecore_Evas.
677#endif 645#endif
678 646
679 // Get the screen size.
680 elm_win_screen_size_get(ourGlobals.win, &ourGlobals.win_x, &ourGlobals.win_y, &ourGlobals.scr_w, &ourGlobals.scr_h);
681 ourGlobals.win_x = ourGlobals.win_x + (ourGlobals.scr_w / 3);
682 // TODO - Now we have to take the frame height into consideration, didn't have to do that before. Faked for now.
683 ourGlobals.win_y += 28;
684 ourGlobals.win_w = ourGlobals.scr_w / 2;
685 ourGlobals.win_h = ourGlobals.scr_h - 30;
686 evas_object_move(ourGlobals.win, ourGlobals.win_x, ourGlobals.win_y);
687 evas_object_resize(ourGlobals.win, ourGlobals.win_w, ourGlobals.win_h);
688
689 evas_object_event_callback_add(ourGlobals.win, EVAS_CALLBACK_RESIZE, _on_resize, &ourGlobals); 647 evas_object_event_callback_add(ourGlobals.win, EVAS_CALLBACK_RESIZE, _on_resize, &ourGlobals);
690 648
691 649
@@ -714,10 +672,10 @@ EAPI_MAIN int elm_main(int argc, char **argv)
714 Ephysics objects 672 Ephysics objects
715 */ 673 */
716 674
717 // Override the background image 675 // Create the background image
718#if 1 676#if 1
719 snprintf(buf, sizeof(buf), "%s/sky_03.jpg", prefix_data_get()); 677 snprintf(buf, sizeof(buf), "%s/sky_03.jpg", prefix_data_get());
720 ourGlobals.mainWindow->bg = eo_add(ELM_IMAGE_CLASS, ourGlobals.mainWindow->win, 678 ourGlobals.mainWindow->bg = eo_add(ELM_BG_CLASS, ourGlobals.mainWindow->win,
721 evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND), 679 evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND),
722 elm_obj_image_fill_outside_set(EINA_TRUE), 680 elm_obj_image_fill_outside_set(EINA_TRUE),
723 efl_file_set(buf, NULL), 681 efl_file_set(buf, NULL),
@@ -734,17 +692,24 @@ EAPI_MAIN int elm_main(int argc, char **argv)
734 692
735 init_evas_gl(&ourGlobals); 693 init_evas_gl(&ourGlobals);
736 694
695#if USE_EPHYSICS
696 if (ephysics_init())
697 ourGlobals.world = ephysicsAdd(&ourGlobals);
698#endif
737 699
738 _on_resize(&ourGlobals, NULL, NULL, NULL); 700 _on_resize(&ourGlobals, NULL, NULL, NULL);
739 701
740 // TODO - It's still very random if we got clouds straight away or not. B-( 702 // Leave the rest of the init for later.
741 ecore_timer_add(0.5, _makePurkle, &ourGlobals); 703 ecore_timer_add(0.1, _makeSkang, &ourGlobals);
742 704
743 elm_run(); 705 elm_run();
706
744 ourGlobals.running = 0; 707 ourGlobals.running = 0;
745 708
709#if USE_EPHYSICS
746 ephysics_world_del(ourGlobals.world); 710 ephysics_world_del(ourGlobals.world);
747 ephysics_shutdown(); 711 ephysics_shutdown();
712#endif
748 713
749 if (ourGlobals.win) 714 if (ourGlobals.win)
750 { 715 {