From 40956094d5472280e2091b36f8488c87c3805a20 Mon Sep 17 00:00:00 2001 From: terminx Date: Wed, 11 Feb 2015 05:22:59 +0000 Subject: [PATCH] More Android work. DONT_BUILD. git-svn-id: https://svn.eduke32.com/eduke32@5000 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/Android.mk | 9 ++-- polymer/eduke32/build/src/sdlayer.c | 5 ++- .../eduke32/source/android/android-jni.cpp | 44 +++++++++++-------- polymer/eduke32/source/android/in_android.c | 4 +- polymer/eduke32/source/gameexec.c | 3 +- polymer/eduke32/source/menus.c | 21 ++++++--- 6 files changed, 51 insertions(+), 35 deletions(-) diff --git a/polymer/eduke32/Android.mk b/polymer/eduke32/Android.mk index 8428ba232..2fefee7b8 100644 --- a/polymer/eduke32/Android.mk +++ b/polymer/eduke32/Android.mk @@ -26,7 +26,7 @@ LOCAL_CPPFLAGS := -std=gnu++03 #-DUSE_LIBPNG -LOCAL_CFLAGS += -DHAVE_SDL -DHAVE_VORBIS -DHAVE_JWZGLES -DHAVE_ANDROID -DRENDERTYPESDL=1 -DUSE_OPENGL -DNETCODE_DISABLE +LOCAL_CFLAGS += -DHAVE_SDL -DHAVE_VORBIS -DHAVE_JWZGLES -DHAVE_ANDROID -DRENDERTYPESDL=1 -DUSE_OPENGL -DNETCODE_DISABLE -DUSE_LIBVPX #LOCAL_CFLAGS += -mhard-float -D_NDK_MATH_NO_SOFTFP=1 @@ -34,7 +34,7 @@ LOCAL_LDFLAGS := -fuse-ld=bfd LOCAL_ARM_NEON = true LOCAL_C_INCLUDES := $(LOCAL_PATH)/source $(LOCAL_PATH)/source/jmact $(LOCAL_PATH)/source/jaudiolib/include $(LOCAL_PATH)/source/enet/include $(LOCAL_PATH)/build/include -LOCAL_C_INCLUDES += $(TOP_DIR)/ $(TOP_DIR)/Libraries/liboggvorbis/include $(TOP_DIR)/Libraries/ $(TOP_DIR)/Libraries/SDL2/include $(TOP_DIR)/Libraries/SDL2_mixer/include $(TOP_DIR)/Libraries/libpng/include $(TOP_DIR)/Libraries/TinyXML/include $(TOP_DIR)/TouchControls +LOCAL_C_INCLUDES += $(TOP_DIR)/ $(TOP_DIR)/Libraries/liboggvorbis/include $(TOP_DIR)/Libraries/ $(TOP_DIR)/Libraries/SDL2/include $(TOP_DIR)/Libraries/SDL2_mixer/include $(TOP_DIR)/Libraries/libpng/include $(TOP_DIR)/Libraries/TinyXML/include $(TOP_DIR)/TouchControls $(TOP_DIR)/Libraries/libvpx/include ANDROID_SRC = \ source/android/android-jni.cpp \ @@ -83,6 +83,7 @@ GAME_SRC=source/game.c \ source/actors.c \ source/anim.c \ source/animsounds.c \ + source/animvpx.c \ source/common.c \ source/config.c \ source/demo.c \ @@ -133,8 +134,8 @@ GAME_SRC=source/game.c \ LOCAL_SRC_FILES = $(ANDROID_SRC) $(JAUDIO_SRC) $(JMACT_SRC) $(GAME_SRC) $(BUILD_SRC) LOCAL_LDLIBS := -lGLESv1_CM -lEGL -ldl -llog -lOpenSLES -lz -L$(TOP_DIR)/openssl/libs/ -LOCAL_STATIC_LIBRARIES := libpng crypto -LOCAL_SHARED_LIBRARIES := touchcontrols ogg vorbis SDL2 SDL2_mixer +LOCAL_STATIC_LIBRARIES := libpng crypto +LOCAL_SHARED_LIBRARIES := touchcontrols ogg vorbis SDL2 SDL2_mixer libvpx # SDL2_image ifeq ($(GP_LIC),1) diff --git a/polymer/eduke32/build/src/sdlayer.c b/polymer/eduke32/build/src/sdlayer.c index e54b0823a..99db8836c 100644 --- a/polymer/eduke32/build/src/sdlayer.c +++ b/polymer/eduke32/build/src/sdlayer.c @@ -344,7 +344,10 @@ int sdlayer_mobilefilter(void *userdata, SDL_Event *event) { case SDL_APP_TERMINATING: // yes, this calls into the game, ugh - G_Shutdown(); + if (mobile_halted == 1) + G_Shutdown(); + + mobile_halted = 1; return 0; case SDL_APP_LOWMEMORY: gltexinvalidatetype(INVALIDATE_ALL); diff --git a/polymer/eduke32/source/android/android-jni.cpp b/polymer/eduke32/source/android/android-jni.cpp index dee661098..04b8c7c15 100644 --- a/polymer/eduke32/source/android/android-jni.cpp +++ b/polymer/eduke32/source/android/android-jni.cpp @@ -97,6 +97,9 @@ JavaVM *jvm_; touchcontrols::Button *inv_buttons[GET_MAX]; +std::string obbPath; +std::string gamePath; + void openGLStart() { if (curRenderer == REND_GL) @@ -385,12 +388,12 @@ void touchSettingsButton(int state) */ } -void initControls(int width, int height, const char *graphics_path, const char *settings_file) +void initControls(int width, int height, const char *graphics_path) { touchcontrols::GLScaleWidth = (float)width; - touchcontrols::GLScaleHeight = (float)height; + touchcontrols::GLScaleHeight = (float)-height; - LOGI("initControls %d x %d,x path = %s, settings = %s", width, height, graphics_path, settings_file); + LOGI("initControls %d x %d,x path = %s", width, height, graphics_path); if (!controlsCreated) { @@ -421,9 +424,9 @@ void initControls(int width, int height, const char *graphics_path, const char * ///////////////////////// YES NO SCREEN ///////////////////// tcYesNo->addControl( - new touchcontrols::Button("enter", touchcontrols::RectF(16, 8, 19, 11), "yes", SDL_SCANCODE_RETURN)); + new touchcontrols::Button("enter", touchcontrols::RectF(16, 9, 18, 11), "yes", SDL_SCANCODE_RETURN)); tcYesNo->addControl( - new touchcontrols::Button("esc", touchcontrols::RectF(7, 8, 10, 11), "no", SDL_SCANCODE_ESCAPE)); + new touchcontrols::Button("esc", touchcontrols::RectF(8, 9, 10, 11), "no", SDL_SCANCODE_ESCAPE)); tcYesNo->signal_button.connect(sigc::ptr_fun(&menuButton)); // Just reuse the menuButton function @@ -440,12 +443,13 @@ void initControls(int width, int height, const char *graphics_path, const char * "arrow_right", SDL_SCANCODE_RIGHT, true)); tcMenuMain->addControl(new touchcontrols::Button("enter", touchcontrols::RectF(0,14,2,16), "enter", SDL_SCANCODE_RETURN)); - tcMenuMain->addControl(new touchcontrols::Button("esc", touchcontrols::RectF(0,12,2,14), "esc", - SDL_SCANCODE_ESCAPE)); - tcMenuMain->signal_button.connect( sigc::ptr_fun(&menuButton) ); tcMenuMain->setAlpha(1); */ + tcMenuMain->addControl(new touchcontrols::Button("arrow_left", touchcontrols::RectF(0, 2, 2, 4), "arrow_left", + SDL_SCANCODE_ESCAPE)); + tcMenuMain->signal_button.connect(sigc::ptr_fun(&menuButton)); + touchcontrols::MultitouchMouse *mouseMenu = new touchcontrols::MultitouchMouse("mouse", touchcontrols::RectF(0, 0, 26, 16), ""); mouseMenu->setHideGraphics(true); @@ -460,6 +464,10 @@ void initControls(int width, int height, const char *graphics_path, const char * //////////////////////////// GAME SCREEN ///////////////////// tcGameMain->setAlpha(droidinput.gameControlsAlpha); controlsContainer.editButtonAlpha = droidinput.gameControlsAlpha; + + tcGameMain->addControl( + new touchcontrols::Button("game_menu", touchcontrols::RectF(0, 0, 2, 2), "settings_bars", MENU_BACK)); + tcGameMain->addControl( new touchcontrols::Button("use", touchcontrols::RectF(20, 4, 23, 7), "use", gamefunc_Open)); tcGameMain->addControl( @@ -582,10 +590,9 @@ void initControls(int width, int height, const char *graphics_path, const char * tcGameWeapons->setAlpha(droidinput.gameControlsAlpha); tcMenuMain->setAlpha(droidinput.gameControlsAlpha); - - tcGameMain->setXMLFile((std::string)graphics_path + "/game.xml"); - tcGameWeapons->setXMLFile((std::string)graphics_path + "/weapons.xml"); - tcAutomap->setXMLFile((std::string)graphics_path + "/automap.xml"); + tcGameMain->setXMLFile(gamePath + "/control_layout_main.xml"); + tcGameWeapons->setXMLFile(gamePath + "/control_layout_weapons.xml"); + tcAutomap->setXMLFile(gamePath + "/control_layout_automap.xml"); // tcInventory->setXMLFile((std::string)graphics_path + "/inventory.xml"); setControlsContainer(&controlsContainer); @@ -748,10 +755,8 @@ JNIEnv *env_; int argc = 1; const char *argv[32]; -std::string graphicpath; -std::string duke3d_path; -static inline const char *getGamePath() { return duke3d_path.c_str(); } +static inline const char *getGamePath() { return gamePath.c_str(); } jint EXPORT_ME Java_com_voidpoint_duke3d_engine_NativeLib_init(JNIEnv *env, jobject thiz, jstring graphics_dir, jint audio_rate, jint audio_buffer_size, @@ -781,7 +786,7 @@ jint EXPORT_ME Java_com_voidpoint_duke3d_engine_NativeLib_init(JNIEnv *env, jobj argc++; } - duke3d_path = (char *)(env)->GetStringUTFChars(jduke3d_path, 0); + gamePath = std::string(env->GetStringUTFChars(jduke3d_path, NULL)); // Change working dir, save games etc // FIXME: potentially conflicts with chdirs in -game_dir support @@ -794,10 +799,11 @@ jint EXPORT_ME Java_com_voidpoint_duke3d_engine_NativeLib_init(JNIEnv *env, jobj LOGI("duke3d_path = %s", getGamePath()); const char *p = env->GetStringUTFChars(graphics_dir, NULL); - graphicpath = std::string(p); + obbPath = std::string(p); - initControls(droidinfo.screen_width, -droidinfo.screen_height, graphicpath.c_str(), - (graphicpath + "/touch_controls.xml").c_str()); + LOGI("obbPath = %s", obbPath.c_str()); + + initControls(droidinfo.screen_width, droidinfo.screen_height, (obbPath + "/assets/").c_str()); PortableInit(argc, argv); diff --git a/polymer/eduke32/source/android/in_android.c b/polymer/eduke32/source/android/in_android.c index 25444f83e..5a040c923 100644 --- a/polymer/eduke32/source/android/in_android.c +++ b/polymer/eduke32/source/android/in_android.c @@ -105,9 +105,9 @@ void PortableAction(int state, int action) if (action >= MENU_UP && action <= MENU_BACK) { - if (PortableRead(READ_SCREEN_MODE) == TOUCH_SCREEN_MENU) +// if (PortableRead(READ_SCREEN_MODE) == TOUCH_SCREEN_MENU) { - int sdl_code [] = { SDL_SCANCODE_UP, SDL_SCANCODE_DOWN, SDL_SCANCODE_LEFT, + int const sdl_code [] = { SDL_SCANCODE_UP, SDL_SCANCODE_DOWN, SDL_SCANCODE_LEFT, SDL_SCANCODE_RIGHT, SDL_SCANCODE_RETURN, SDL_SCANCODE_ESCAPE }; PortableKeyEvent(state, sdl_code[action-MENU_UP], 0); return; diff --git a/polymer/eduke32/source/gameexec.c b/polymer/eduke32/source/gameexec.c index 51f2d06e6..b38d289f9 100644 --- a/polymer/eduke32/source/gameexec.c +++ b/polymer/eduke32/source/gameexec.c @@ -19,13 +19,12 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ //------------------------------------------------------------------------- +#include "compat.h" #include #include #include // sqrt -#include "compat.h" - #include "build.h" #include "duke3d.h" diff --git a/polymer/eduke32/source/menus.c b/polymer/eduke32/source/menus.c index b809fff29..6e4f6e016 100644 --- a/polymer/eduke32/source/menus.c +++ b/polymer/eduke32/source/menus.c @@ -20,6 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ //------------------------------------------------------------------------- +#include "compat.h" #include "duke3d.h" #include "renderlayer.h" #include "net.h" @@ -259,6 +260,9 @@ static MenuEntry_t ME_ ## EntryName = MAKE_MENUENTRY( Title, &MF_Redfont, &Forma MAKE_MENU_TOP_ENTRYLINK( "New Game", MEF_MainMenu, MAIN_NEWGAME, MENU_EPISODE ); +#ifdef DROIDMENU +MAKE_MENU_TOP_ENTRYLINK( "Resume Game", MEF_MainMenu, MAIN_RESUMEGAME, MENU_CLOSE ); +#endif MAKE_MENU_TOP_ENTRYLINK( "New Game", MEF_MainMenu, MAIN_NEWGAME_INGAME, MENU_NEWVERIFY ); static MenuLink_t MEO_MAIN_NEWGAME_NETWORK = { MENU_NETWORK, MA_Advance, }; MAKE_MENU_TOP_ENTRYLINK( "Save Game", MEF_MainMenu, MAIN_SAVEGAME, MENU_SAVE ); @@ -284,15 +288,21 @@ static MenuEntry_t *MEL_MAIN[] = { }; static MenuEntry_t *MEL_MAIN_INGAME[] = { +#ifdef DROIDMENU + &ME_MAIN_RESUMEGAME, +#else &ME_MAIN_NEWGAME_INGAME, +#endif &ME_MAIN_SAVEGAME, &ME_MAIN_LOADGAME, &ME_MAIN_OPTIONS, #ifndef DROIDMENU &ME_MAIN_HELP, -#endif &ME_MAIN_QUITTOTITLE, &ME_MAIN_QUITGAME, +#else + &ME_MAIN_QUITTOTITLE, +#endif }; // Episode and Skill will be dynamically generated after CONs are parsed @@ -4254,15 +4264,13 @@ static int32_t M_RunMenuInput_MouseAdvance(void) return MOUSEACTIVECONDITIONAL(!m_mousecaught && mousepressstate == Mouse_Released); } -#if !defined __ANDROID__ +#if !defined EDUKE32_TOUCH_DEVICES static int32_t M_RunMenuInput_MouseReturn_status; static void M_RunMenu_MouseReturn(Menu_t *cm, const vec2_t origin) { -#if !defined EDUKE32_TOUCH_DEVICES if (!MOUSEACTIVECONDITION) return; -#endif if (cm->menuID == MENU_MAIN) return; @@ -4276,14 +4284,12 @@ static void M_RunMenu_MouseReturn(Menu_t *cm, const vec2_t origin) static int32_t M_RunMenuInput_MouseReturn(void) { -#if !defined __ANDROID__ #if !defined EDUKE32_TOUCH_DEVICES if (!MOUSEACTIVECONDITION) { M_RunMenuInput_MouseReturn_status = 0; return 0; } -#endif if (g_currentMenu == MENU_MAIN) return 0; @@ -4298,6 +4304,7 @@ static int32_t M_RunMenuInput_MouseReturn(void) M_RunMenuInput_MouseReturn_status = 0; #endif + return 0; } @@ -4559,7 +4566,7 @@ static void M_RunMenu(Menu_t *cm, const vec2_t origin) } } -#if !defined __ANDROID__ +#if !defined EDUKE32_TOUCH_DEVICES M_RunMenu_MouseReturn(cm, origin); #endif }