Share the override default params with android

This commit is contained in:
Benau 2019-07-13 14:22:22 +08:00
parent b9d00dba6d
commit 8c00a1e857
5 changed files with 24 additions and 10 deletions

View File

@ -207,6 +207,7 @@ LOCAL_CFLAGS := -I../lib/angelscript/include \
-Iobj/openal/include \ -Iobj/openal/include \
-Iobj/openssl/include \ -Iobj/openssl/include \
-DUSE_GLES2 \ -DUSE_GLES2 \
-DMOBILE_STK \
-DENABLE_SOUND \ -DENABLE_SOUND \
-DENABLE_CRYPTO_OPENSSL \ -DENABLE_CRYPTO_OPENSSL \
-DNDEBUG \ -DNDEBUG \

View File

@ -90,8 +90,10 @@ namespace irr
} }
#define _IRR_COMPILE_WITH_IOS_BUILTIN_MAIN_
#ifdef _IRR_COMPILE_WITH_IOS_BUILTIN_MAIN_ #ifdef _IRR_COMPILE_WITH_IOS_BUILTIN_MAIN_
extern void irrlicht_main(); extern int ios_main(int argc, char *argv[]);
extern void override_default_params_for_mobile();
#endif #endif
#endif #endif

View File

@ -56,7 +56,7 @@ namespace irr
Active = true; Active = true;
Focus = false; Focus = false;
[self performSelectorOnMainThread:@selector(runIrrlicht) withObject:nil waitUntilDone:NO]; [self performSelectorOnMainThread:@selector(runSTK) withObject:nil waitUntilDone:NO];
return YES; return YES;
} }
@ -143,9 +143,10 @@ namespace irr
Focus = true; Focus = true;
} }
- (void)runIrrlicht - (void)runSTK
{ {
irrlicht_main(); override_default_params_for_mobile();
ios_main(0, {});
} }
- (void)setDevice:(irr::CIrrDeviceiOS*)device - (void)setDevice:(irr::CIrrDeviceiOS*)device

View File

@ -1858,7 +1858,11 @@ void main_abort()
#endif #endif
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
int main(int argc, char *argv[] ) #ifdef IOS_STK
int ios_main(int argc, char *argv[])
#else
int main(int argc, char *argv[])
#endif
{ {
CommandLine::init(argc, argv); CommandLine::init(argc, argv);

View File

@ -15,19 +15,21 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifdef ANDROID #ifdef MOBILE_STK
#include "config/user_config.hpp" #include "config/user_config.hpp"
#include "graphics/irr_driver.hpp" #include "graphics/irr_driver.hpp"
#include "utils/log.hpp" #include "utils/log.hpp"
#ifdef ANDROID
#include "../../../lib/irrlicht/source/Irrlicht/CIrrDeviceAndroid.h" #include "../../../lib/irrlicht/source/Irrlicht/CIrrDeviceAndroid.h"
#endif
extern int main(int argc, char *argv[]); extern int main(int argc, char *argv[]);
struct android_app* global_android_app; struct android_app* global_android_app;
void override_default_params() void override_default_params_for_mobile()
{ {
// It has an effect only on the first run, when config file is created. // It has an effect only on the first run, when config file is created.
// So that we can still modify these params in STK options and user's // So that we can still modify these params in STK options and user's
@ -42,7 +44,8 @@ void override_default_params()
// Enable multitouch race GUI // Enable multitouch race GUI
UserConfigParams::m_multitouch_draw_gui = true; UserConfigParams::m_multitouch_draw_gui = true;
#ifdef ANDROID
// Set multitouch device scale depending on actual screen size // Set multitouch device scale depending on actual screen size
int32_t screen_size = AConfiguration_getScreenSize(global_android_app->config); int32_t screen_size = AConfiguration_getScreenSize(global_android_app->config);
@ -67,7 +70,8 @@ void override_default_params()
default: default:
break; break;
} }
#endif
// Enable screen keyboard // Enable screen keyboard
UserConfigParams::m_screen_keyboard = 1; UserConfigParams::m_screen_keyboard = 1;
@ -82,6 +86,7 @@ void override_default_params()
UserConfigParams::m_enforce_current_player = true; UserConfigParams::m_enforce_current_player = true;
} }
#ifdef ANDROID
void android_main(struct android_app* app) void android_main(struct android_app* app)
{ {
Log::info("AndroidMain", "Loading application..."); Log::info("AndroidMain", "Loading application...");
@ -92,7 +97,7 @@ void android_main(struct android_app* app)
CIrrDeviceAndroid::onCreate(); CIrrDeviceAndroid::onCreate();
app_dummy(); app_dummy();
override_default_params(); override_default_params_for_mobile();
main(0, {}); main(0, {});
@ -106,5 +111,6 @@ void android_main(struct android_app* app)
fflush(NULL); fflush(NULL);
_exit(0); _exit(0);
} }
#endif
#endif #endif