More fixes for global_android_app

This commit is contained in:
Deve 2018-08-16 21:36:41 +02:00
parent a2af7127e7
commit 80fd62c7d8
4 changed files with 90 additions and 62 deletions

View File

@ -59,18 +59,26 @@ CIrrDeviceAndroid::CIrrDeviceAndroid(const SIrrlichtCreationParameters& param)
setDebugName("CIrrDeviceAndroid");
#endif
Android = (android_app *)(param.PrivateData);
assert(Android != NULL);
createKeyMap();
CursorControl = new CCursorControl();
Android = (android_app*)(param.PrivateData);
if (Android == NULL && CreationParams.DriverType != video::EDT_NULL)
{
os::Printer::log("Irrlicht device can run only with NULL driver without android_app.", ELL_DEBUG);
return;
}
if (Android != NULL)
{
Android->userData = this;
Android->onAppCmd = handleAndroidCommand;
Android->onAppCmdDirect = handleAndroidCommandDirect;
Android->onInputEvent = handleInput;
printConfig();
createKeyMap();
CursorControl = new CCursorControl();
Close = Android->destroyRequested;
@ -107,20 +115,26 @@ CIrrDeviceAndroid::CIrrDeviceAndroid(const SIrrlichtCreationParameters& param)
ExposedVideoData.OGLESAndroid.Window = Android->window;
createVideoModeList();
}
createDriver();
if (VideoDriver)
{
createGUIAndScene();
}
}
CIrrDeviceAndroid::~CIrrDeviceAndroid()
{
if (Android)
{
Android->userData = NULL;
Android->onAppCmd = NULL;
Android->onInputEvent = NULL;
}
}
void CIrrDeviceAndroid::printConfig()
{
@ -211,6 +225,9 @@ bool CIrrDeviceAndroid::run()
{
os::Timer::tick();
if (Android == NULL)
return !Close;
while (!Close)
{
s32 Events = 0;

View File

@ -50,6 +50,9 @@ void AssetsAndroid::init()
if (m_file_manager == NULL)
return;
if (!global_android_app)
return;
bool needs_extract_data = false;
const std::string version = std::string("supertuxkart.") + STK_VERSION;
@ -339,6 +342,9 @@ void AssetsAndroid::extractData()
bool AssetsAndroid::extractDir(std::string dir_name)
{
#ifdef ANDROID
if (!global_android_app)
return false;
AAssetManager* amgr = global_android_app->activity->assetManager;
Log::info("AssetsAndroid", "Extracting %s directory",

View File

@ -756,11 +756,6 @@ int handleCmdLinePreliminary()
if(CommandLine::has("--kartdir", &s))
KartPropertiesManager::addKartSearchDir(s);
#ifndef SERVER_ONLY
if(CommandLine::has("--no-graphics") || CommandLine::has("-l"))
#endif
ProfileWorld::disableGraphics();
if (CommandLine::has("--sp-shader-debug"))
SP::SPShader::m_sp_shader_debug = true;
@ -1844,6 +1839,11 @@ int main(int argc, char *argv[] )
if (CommandLine::has("--stdout-dir", &s))
FileManager::setStdoutDir(s);
#ifndef SERVER_ONLY
if(CommandLine::has("--no-graphics") || CommandLine::has("-l"))
#endif
ProfileWorld::disableGraphics();
// Init the minimum managers so that user config exists, then
// handle all command line options that do not need (or must
// not have) other managers initialised:

View File

@ -312,15 +312,19 @@ Translations::Translations() //: m_dictionary_manager("UTF-16")
} // if c[0]
#elif defined(ANDROID)
if (global_android_app)
{
char p_language[3] = {};
AConfiguration_getLanguage(global_android_app->config, p_language);
AConfiguration_getLanguage(global_android_app->config,
p_language);
if (p_language != NULL)
{
language += p_language;
char p_country[3] = {};
AConfiguration_getCountry(global_android_app->config, p_country);
AConfiguration_getCountry(global_android_app->config,
p_country);
if (p_country)
{
@ -328,6 +332,7 @@ Translations::Translations() //: m_dictionary_manager("UTF-16")
language += p_country;
}
}
}
#endif
} // neither LANGUAGE nor LANG defined