From 8a8b91dfe1b2ec8513f9a49207a76328d532e9a0 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 4 Sep 2014 22:47:03 +0400 Subject: [PATCH] fixed all code for building on all platforms inlcudng ANDROID --- CMakeLists.txt | 9 +++++++ apps/openmw/CMakeLists.txt | 8 ++++++ components/files/linuxpath.cpp | 40 ++++++++++++++++++++--------- components/ogreinit/ogreinit.cpp | 8 +++--- extern/sdl4ogre/sdlwindowhelper.cpp | 17 +++++++----- libs/openengine/gui/manager.cpp | 4 ++- 6 files changed, 62 insertions(+), 24 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ba5e77af5..c0d3c8f03c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,6 +58,15 @@ if (ANDROID) set(CMAKE_FIND_ROOT_PATH ${OPENMW_DEPENDENCIES_DIR} "${CMAKE_FIND_ROOT_PATH}") endif (ANDROID) +if (NOT ANDROID) +ADD_DEFINITIONS(-DNOT_ANDROID) +endif() + +if (ANDROID) +ADD_DEFINITIONS(-DBUILD_ANDROID) +endif() + + # doxygen main page configure_file ("${OpenMW_SOURCE_DIR}/docs/mainpage.hpp.cmake" "${OpenMW_SOURCE_DIR}/docs/mainpage.hpp") diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 6aa8ae464c..2fb4f793fe 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -19,6 +19,14 @@ endif () if(NOT WIN32 AND NOT ANDROID) set(GAME ${GAME} crashcatcher.cpp) endif() +if (NOT ANDROID) +ADD_DEFINITIONS(-DNOT_ANDROID) +endif() + +if (ANDROID) +ADD_DEFINITIONS(-DBUILD_ANDROID) +endif() + set(GAME_HEADER engine.hpp diff --git a/components/files/linuxpath.cpp b/components/files/linuxpath.cpp index aa0f20a68d..c59f4065de 100644 --- a/components/files/linuxpath.cpp +++ b/components/files/linuxpath.cpp @@ -58,39 +58,51 @@ LinuxPath::LinuxPath(const std::string& application_name) boost::filesystem::path LinuxPath::getUserConfigPath() const { -//if (flag==false) - // return getEnv("XDG_CONFIG_HOME", getUserHome() / ".config") / mName; +#ifdef NOT_ANDROID + return getEnv("XDG_CONFIG_HOME", getUserHome() / ".config") / mName; +#endif //else - return getEnv("XDG_CONFIG_HOME", "/sdcard/morrowind/config") / mName; - +#ifdef BUILD_ANDROID + return getEnv("XDG_CONFIG_HOME", "/sdcard/morrowind/config") / mName; +#endif } boost::filesystem::path LinuxPath::getUserDataPath() const { //if (flag==false) - // return getEnv("XDG_DATA_HOME", getUserHome() / ".local/share") / mName; +#ifdef NOT_ANDROID + + return getEnv("XDG_DATA_HOME", getUserHome() / ".local/share") / mName; +#endif //else +#ifdef BUILD_ANDROID return getEnv("XDG_DATA_HOME", "/sdcard/morrowind/share") / mName; - +#endif } boost::filesystem::path LinuxPath::getCachePath() const { //if (flag==false) - // return getEnv("XDG_CACHE_HOME", getUserHome() / ".cache") / mName; +#ifdef NOT_ANDROID + return getEnv("XDG_CACHE_HOME", getUserHome() / ".cache") / mName; +#endif //else +#ifdef BUILD_ANDROID return getEnv("XDG_CACHE_HOME", "/sdcard/morrowind/cache") / mName; - +#endif } boost::filesystem::path LinuxPath::getGlobalConfigPath() const { //if (flag==false) - // boost::filesystem::path globalPath("/etc/"); +#ifdef NOT_ANDROID + boost::filesystem::path globalPath("/etc/"); +#endif //else +#ifdef BUILD_ANDROID boost::filesystem::path globalPath("/sdcard/morrowind/"); - +#endif return globalPath / mName; } @@ -102,10 +114,14 @@ boost::filesystem::path LinuxPath::getLocalPath() const boost::filesystem::path LinuxPath::getGlobalDataPath() const { //if (flag==false) - // boost::filesystem::path globalDataPath("/usr/share/games/"); +#ifdef NOT_ANDROID + + boost::filesystem::path globalDataPath("/usr/share/games/"); +#endif //else +#ifdef BUILD_ANDROID boost::filesystem::path globalDataPath("/sdcard/morrowind/data"); - +#endif return globalDataPath / mName; } diff --git a/components/ogreinit/ogreinit.cpp b/components/ogreinit/ogreinit.cpp index 3a69020846..8d316468e2 100644 --- a/components/ogreinit/ogreinit.cpp +++ b/components/ogreinit/ogreinit.cpp @@ -94,9 +94,9 @@ namespace OgreInit Ogre::Root* OgreInit::init(const std::string &logPath) { -/* - if (flag1==false) - { + + #ifdef NOT_ANDROID + // Set up logging first new Ogre::LogManager; Ogre::Log *log = Ogre::LogManager::getSingleton().createLog(logPath); @@ -108,7 +108,7 @@ namespace OgreInit // Disable logging to cout/cerr log->setDebugOutputEnabled(false); - }*/ + #endif mRoot = new Ogre::Root("", "", ""); #if defined(ENABLE_PLUGIN_GL) || (ENABLE_PLUGIN_GLES2) || defined(ENABLE_PLUGIN_Direct3D9) || defined(ENABLE_PLUGIN_CgProgramManager) || defined(ENABLE_PLUGIN_OctreeSceneManager) || defined(ENABLE_PLUGIN_ParticleFX) diff --git a/extern/sdl4ogre/sdlwindowhelper.cpp b/extern/sdl4ogre/sdlwindowhelper.cpp index eaf6e8d226..dd05a296e2 100644 --- a/extern/sdl4ogre/sdlwindowhelper.cpp +++ b/extern/sdl4ogre/sdlwindowhelper.cpp @@ -44,18 +44,21 @@ SDLWindowHelper::SDLWindowHelper (SDL_Window* window, int w, int h, winHandle = Ogre::StringConverter::toString(WindowContentViewHandle(wmInfo)); break; -#else + +#elif BUILD_ANDROID case SDL_SYSWM_ANDROID: winHandle = Ogre::StringConverter::toString((unsigned long)wmInfo.info.android.window); winHandleSurface = Ogre::StringConverter::toString((unsigned long)wmInfo.info.android.surface); flag1=true; break; - if (flag1==false) -{ - //case SDL_SYSWM_X11: - // winHandle = Ogre::StringConverter::toString((unsigned long)wmInfo.info.x11.window); - // break; -} + + #elif NOT_ANDROID + + case SDL_SYSWM_X11: + winHandle = Ogre::StringConverter::toString((unsigned long)wmInfo.info.x11.window); + break; + + #endif diff --git a/libs/openengine/gui/manager.cpp b/libs/openengine/gui/manager.cpp index 4c48ffbc72..41b0fcff8a 100644 --- a/libs/openengine/gui/manager.cpp +++ b/libs/openengine/gui/manager.cpp @@ -653,7 +653,9 @@ void MyGUIManager::updateWindow (Ogre::RenderWindow *wnd) void MyGUIManager::windowResized() { - // mRenderManager->setActiveViewport(0); +#ifdef NOT_ANDROID + mRenderManager->setActiveViewport(0); +#endif } void MyGUIManager::shutdown()