From 868514ac621b3ca5c0a9f924461e37164dc712ff Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 18 Nov 2012 04:24:33 +0300 Subject: Add support for persistent directory under Android. This directory used for updates, configs, logs. --- src/client.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'src/client.cpp') diff --git a/src/client.cpp b/src/client.cpp index 38e30b22f..208858555 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -547,6 +547,7 @@ void Client::gameInit() SDLImageHelper::SDLSetEnableAlphaCache(config.getBoolValue("alphaCache")); ImageHelper::setEnableAlpha(config.getFloatValue("guialpha") != 1.0f); #endif + logVars(); graphicsManager.initGraphics(mOptions.noOpenGL); runCounters = config.getBoolValue("packetcounters"); applyVSync(); @@ -1804,7 +1805,8 @@ void Client::initLocalDataDir() mLocalDataDir = std::string(PHYSFS_getUserDir()); mLocalDataDir += "/Mana"; #elif defined __ANDROID__ - mLocalDataDir = "local"; + mLocalDataDir = getenv("DATADIR2") + branding.getValue( + "appShort", "ManaPlus") + "/local"; #else mLocalDataDir = std::string(PHYSFS_getUserDir()) + ".local/share/mana"; @@ -1852,7 +1854,8 @@ void Client::initConfigDir() else mConfigDir += "/mana/" + branding.getValue("appShort", "mana"); #elif defined __ANDROID__ - mConfigDir = "config"; + mConfigDir = getenv("DATADIR2") + branding.getValue( + "appShort", "ManaPlus") + "/config"; #else mConfigDir = std::string(PHYSFS_getUserDir()) + "/.config/mana/" + branding.getValue("appShort", "mana"); @@ -2098,12 +2101,17 @@ void Client::initScreenshotDir() } else if (mScreenshotDir.empty()) { +#ifdef __ANDROID__ + mLocalDataDir = getenv("DATADIR2") + std::string("/images"); +#else std::string configScreenshotDir = config.getStringValue("screenshotDirectory"); if (!configScreenshotDir.empty()) mScreenshotDir = configScreenshotDir; else mScreenshotDir = getDesktopDir(); +#endif + //config.setValue("screenshotDirectory", mScreenshotDir); logger->log("screenshotDirectory: " + mScreenshotDir); @@ -2730,3 +2738,12 @@ void Client::newChatMessage() client->mNewMessageFlag = true; } } + +void Client::logVars() +{ +#ifdef ANDROID + logger->log("APPDIR: %s", getenv("APPDIR")); + logger->log("DATADIR: %s", getenv("DATADIR")); + logger->log("DATADIR2: %s", getenv("DATADIR2")); +#endif +} -- cgit v1.2.3-70-g09d2