Rev 4989 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4989 | Rev 5000 | ||
---|---|---|---|
Line 95... | Line 95... | ||
95 | extern JNIEnv *env_; |
95 | extern JNIEnv *env_; |
96 | JavaVM *jvm_; |
96 | JavaVM *jvm_; |
97 | 97 | ||
98 | touchcontrols::Button *inv_buttons[GET_MAX]; |
98 | touchcontrols::Button *inv_buttons[GET_MAX]; |
99 | 99 | ||
- | 100 | std::string obbPath; |
|
- | 101 | std::string gamePath; |
|
- | 102 | ||
100 | void openGLStart() |
103 | void openGLStart() |
101 | {
|
104 | {
|
102 | if (curRenderer == REND_GL) |
105 | if (curRenderer == REND_GL) |
103 | {
|
106 | {
|
104 | glPushMatrix(); |
107 | glPushMatrix(); |
Line 383... | Line 386... | ||
383 | PortableKeyEvent(2, SDL_SCANCODE_PAUSE, 0);
|
386 | PortableKeyEvent(2, SDL_SCANCODE_PAUSE, 0);
|
384 | }
|
387 | }
|
385 | */
|
388 | */
|
386 | }
|
389 | }
|
387 | 390 | ||
388 | void initControls(int width, int height, const char *graphics_path, const char *settings_file) |
391 | void initControls(int width, int height, const char *graphics_path) |
389 | {
|
392 | {
|
390 | touchcontrols::GLScaleWidth = (float)width; |
393 | touchcontrols::GLScaleWidth = (float)width; |
391 | touchcontrols::GLScaleHeight = (float)height; |
394 | touchcontrols::GLScaleHeight = (float)-height; |
392 | 395 | ||
393 | LOGI("initControls %d x %d,x path = %s, settings = %s", width, height, graphics_path, settings_file); |
396 | LOGI("initControls %d x %d,x path = %s", width, height, graphics_path); |
394 | 397 | ||
395 | if (!controlsCreated) |
398 | if (!controlsCreated) |
396 | {
|
399 | {
|
397 | LOGI("creating controls"); |
400 | LOGI("creating controls"); |
398 | 401 | ||
Line 419... | Line 422... | ||
419 | 422 | ||
420 | 423 | ||
421 | ///////////////////////// YES NO SCREEN /////////////////////
|
424 | ///////////////////////// YES NO SCREEN /////////////////////
|
422 | 425 | ||
423 | tcYesNo->addControl( |
426 | tcYesNo->addControl( |
424 | new touchcontrols::Button("enter", touchcontrols::RectF(16, 8, 19, 11), "yes", SDL_SCANCODE_RETURN)); |
427 | new touchcontrols::Button("enter", touchcontrols::RectF(16, 9, 18, 11), "yes", SDL_SCANCODE_RETURN)); |
425 | tcYesNo->addControl( |
428 | tcYesNo->addControl( |
426 | new touchcontrols::Button("esc", touchcontrols::RectF(7, 8, 10, 11), "no", SDL_SCANCODE_ESCAPE)); |
429 | new touchcontrols::Button("esc", touchcontrols::RectF(8, 9, 10, 11), "no", SDL_SCANCODE_ESCAPE)); |
427 | tcYesNo->signal_button.connect(sigc::ptr_fun(&menuButton)); // Just reuse the menuButton function |
430 | tcYesNo->signal_button.connect(sigc::ptr_fun(&menuButton)); // Just reuse the menuButton function |
428 | 431 | ||
429 | 432 | ||
430 | ///////////////////////// MAIN MENU SCREEN /////////////////////
|
433 | ///////////////////////// MAIN MENU SCREEN /////////////////////
|
431 | 434 | ||
Line 438... | Line 441... | ||
438 | "arrow_left", SDL_SCANCODE_LEFT, true));
|
441 | "arrow_left", SDL_SCANCODE_LEFT, true));
|
439 | tcMenuMain->addControl(new touchcontrols::Button("right_arrow", touchcontrols::RectF(24,14,26,16),
|
442 | tcMenuMain->addControl(new touchcontrols::Button("right_arrow", touchcontrols::RectF(24,14,26,16),
|
440 | "arrow_right", SDL_SCANCODE_RIGHT, true));
|
443 | "arrow_right", SDL_SCANCODE_RIGHT, true));
|
441 | tcMenuMain->addControl(new touchcontrols::Button("enter", touchcontrols::RectF(0,14,2,16), "enter",
|
444 | tcMenuMain->addControl(new touchcontrols::Button("enter", touchcontrols::RectF(0,14,2,16), "enter",
|
442 | SDL_SCANCODE_RETURN));
|
445 | SDL_SCANCODE_RETURN));
|
443 | tcMenuMain->addControl(new touchcontrols::Button("esc", touchcontrols::RectF(0,12,2,14), "esc",
|
- | |
444 | SDL_SCANCODE_ESCAPE));
|
- | |
445 | tcMenuMain->signal_button.connect( sigc::ptr_fun(&menuButton) );
|
- | |
446 | tcMenuMain->setAlpha(1);
|
446 | tcMenuMain->setAlpha(1);
|
447 | */
|
447 | */
|
448 | 448 | ||
- | 449 | tcMenuMain->addControl(new touchcontrols::Button("arrow_left", touchcontrols::RectF(0, 2, 2, 4), "arrow_left", |
|
- | 450 | SDL_SCANCODE_ESCAPE)); |
|
- | 451 | tcMenuMain->signal_button.connect(sigc::ptr_fun(&menuButton)); |
|
- | 452 | ||
449 | touchcontrols::MultitouchMouse *mouseMenu = |
453 | touchcontrols::MultitouchMouse *mouseMenu = |
450 | new touchcontrols::MultitouchMouse("mouse", touchcontrols::RectF(0, 0, 26, 16), ""); |
454 | new touchcontrols::MultitouchMouse("mouse", touchcontrols::RectF(0, 0, 26, 16), ""); |
451 | mouseMenu->setHideGraphics(true); |
455 | mouseMenu->setHideGraphics(true); |
452 | tcMenuMain->addControl(mouseMenu); |
456 | tcMenuMain->addControl(mouseMenu); |
453 | mouseMenu->signal_action.connect(sigc::ptr_fun(&menuMouse)); |
457 | mouseMenu->signal_action.connect(sigc::ptr_fun(&menuMouse)); |
Line 458... | Line 462... | ||
458 | tcMenuMain->addControl(console_button); |
462 | tcMenuMain->addControl(console_button); |
459 | 463 | ||
460 | //////////////////////////// GAME SCREEN /////////////////////
|
464 | //////////////////////////// GAME SCREEN /////////////////////
|
461 | tcGameMain->setAlpha(droidinput.gameControlsAlpha); |
465 | tcGameMain->setAlpha(droidinput.gameControlsAlpha); |
462 | controlsContainer.editButtonAlpha = droidinput.gameControlsAlpha; |
466 | controlsContainer.editButtonAlpha = droidinput.gameControlsAlpha; |
- | 467 | ||
- | 468 | tcGameMain->addControl( |
|
- | 469 | new touchcontrols::Button("game_menu", touchcontrols::RectF(0, 0, 2, 2), "settings_bars", MENU_BACK)); |
|
- | 470 | ||
463 | tcGameMain->addControl( |
471 | tcGameMain->addControl( |
464 | new touchcontrols::Button("use", touchcontrols::RectF(20, 4, 23, 7), "use", gamefunc_Open)); |
472 | new touchcontrols::Button("use", touchcontrols::RectF(20, 4, 23, 7), "use", gamefunc_Open)); |
465 | tcGameMain->addControl( |
473 | tcGameMain->addControl( |
466 | new touchcontrols::Button("attack", touchcontrols::RectF(20, 7, 23, 10), "fire2", gamefunc_Fire)); |
474 | new touchcontrols::Button("attack", touchcontrols::RectF(20, 7, 23, 10), "fire2", gamefunc_Fire)); |
467 | tcGameMain->addControl( |
475 | tcGameMain->addControl( |
Line 580... | Line 588... | ||
580 | tcGameMain->setAlpha(droidinput.gameControlsAlpha); |
588 | tcGameMain->setAlpha(droidinput.gameControlsAlpha); |
581 | controlsContainer.editButtonAlpha = droidinput.gameControlsAlpha; |
589 | controlsContainer.editButtonAlpha = droidinput.gameControlsAlpha; |
582 | tcGameWeapons->setAlpha(droidinput.gameControlsAlpha); |
590 | tcGameWeapons->setAlpha(droidinput.gameControlsAlpha); |
583 | tcMenuMain->setAlpha(droidinput.gameControlsAlpha); |
591 | tcMenuMain->setAlpha(droidinput.gameControlsAlpha); |
584 | 592 | ||
585 | - | ||
586 | tcGameMain->setXMLFile((std::string)graphics_path + "/game.xml"); |
593 | tcGameMain->setXMLFile(gamePath + "/control_layout_main.xml"); |
587 | tcGameWeapons->setXMLFile((std::string)graphics_path + "/weapons.xml"); |
594 | tcGameWeapons->setXMLFile(gamePath + "/control_layout_weapons.xml"); |
588 | tcAutomap->setXMLFile((std::string)graphics_path + "/automap.xml"); |
595 | tcAutomap->setXMLFile(gamePath + "/control_layout_automap.xml"); |
589 | // tcInventory->setXMLFile((std::string)graphics_path + "/inventory.xml");
|
596 | // tcInventory->setXMLFile((std::string)graphics_path + "/inventory.xml");
|
590 | 597 | ||
591 | setControlsContainer(&controlsContainer); |
598 | setControlsContainer(&controlsContainer); |
592 | }
|
599 | }
|
593 | else
|
600 | else
|
Line 746... | Line 753... | ||
746 | 753 | ||
747 | JNIEnv *env_; |
754 | JNIEnv *env_; |
748 | 755 | ||
749 | int argc = 1; |
756 | int argc = 1; |
750 | const char *argv[32]; |
757 | const char *argv[32]; |
751 | std::string graphicpath; |
- | |
752 | std::string duke3d_path; |
- | |
753 | 758 | ||
754 | static inline const char *getGamePath() { return duke3d_path.c_str(); } |
759 | static inline const char *getGamePath() { return gamePath.c_str(); } |
755 | 760 | ||
756 | jint EXPORT_ME Java_com_voidpoint_duke3d_engine_NativeLib_init(JNIEnv *env, jobject thiz, jstring graphics_dir, |
761 | jint EXPORT_ME Java_com_voidpoint_duke3d_engine_NativeLib_init(JNIEnv *env, jobject thiz, jstring graphics_dir, |
757 | jint audio_rate, jint audio_buffer_size, |
762 | jint audio_rate, jint audio_buffer_size, |
758 | jobjectArray argsArray, jint renderer, |
763 | jobjectArray argsArray, jint renderer, |
759 | jstring jduke3d_path)
|
764 | jstring jduke3d_path)
|
Line 779... | Line 784... | ||
779 | argv[argc] = (char *)(env)->GetStringUTFChars(string, 0); |
784 | argv[argc] = (char *)(env)->GetStringUTFChars(string, 0); |
780 | LOGI("arg = %s", argv[argc]); |
785 | LOGI("arg = %s", argv[argc]); |
781 | argc++; |
786 | argc++; |
782 | }
|
787 | }
|
783 | 788 | ||
784 | duke3d_path = (char *)(env)->GetStringUTFChars(jduke3d_path, 0); |
789 | gamePath = std::string(env->GetStringUTFChars(jduke3d_path, NULL)); |
785 | 790 | ||
786 | // Change working dir, save games etc
|
791 | // Change working dir, save games etc
|
787 | // FIXME: potentially conflicts with chdirs in -game_dir support
|
792 | // FIXME: potentially conflicts with chdirs in -game_dir support
|
788 | chdir(getGamePath()); |
793 | chdir(getGamePath()); |
789 | char timidity_env[512]; |
794 | char timidity_env[512]; |
Line 792... | Line 797... | ||
792 | putenv(timidity_env); |
797 | putenv(timidity_env); |
793 | 798 | ||
794 | LOGI("duke3d_path = %s", getGamePath()); |
799 | LOGI("duke3d_path = %s", getGamePath()); |
795 | 800 | ||
796 | const char *p = env->GetStringUTFChars(graphics_dir, NULL); |
801 | const char *p = env->GetStringUTFChars(graphics_dir, NULL); |
797 | graphicpath = std::string(p); |
802 | obbPath = std::string(p); |
- | 803 | ||
- | 804 | LOGI("obbPath = %s", obbPath.c_str()); |
|
798 | 805 | ||
799 | initControls(droidinfo.screen_width, -droidinfo.screen_height, graphicpath.c_str(), |
806 | initControls(droidinfo.screen_width, droidinfo.screen_height, (obbPath + "/assets/").c_str()); |
800 | (graphicpath + "/touch_controls.xml").c_str()); |
- | |
801 | 807 | ||
802 | PortableInit(argc, argv); |
808 | PortableInit(argc, argv); |
803 | 809 | ||
804 | return 0; |
810 | return 0; |
805 | }
|
811 | }
|