mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
Android support (#299)
* AI libs registering shenanigans on android; * Fixed resolution aspect + mouse event scaling; * Proper server init/deinit (through android IPC); Enabled threaded init in CMT; * Prevented a deadlock in logger on some devices; * Fixed frozen intro frame after interrupting the video; Added android progressbar displaying during initial data loading; * Hacky fix for choppy animations during heroes movement (should look better now, but it's definitely not a good solution); * Changes/fixes for new android launcher building process; * Fixed app hang after getting SDL_QUIT when activity was destroyed; * Functioanal, configurable advmap swiping support; * VCMI changes cleanup; Added few missing VCMI_ANDROID guards on swipe mechanics; * Removed unneeded sleep in server startup code for android; * Removed android ioapi hack (fixed in newest ndk); * Removed unused android's library loading logic; * Added android's swipe option to settings schema; * Moved NO_STD_TOSTRING to be defined in global.h instead of build files;
This commit is contained in:
@@ -15,6 +15,11 @@ namespace bfs = boost::filesystem;
|
||||
|
||||
bfs::path IVCMIDirs::userSavePath() const { return userDataPath() / "Saves"; }
|
||||
|
||||
bfs::path IVCMIDirs::fullLibraryPath(const std::string &desiredFolder, const std::string &baseLibName) const
|
||||
{
|
||||
return libraryPath() / desiredFolder / libraryName(baseLibName);
|
||||
}
|
||||
|
||||
void IVCMIDirs::init()
|
||||
{
|
||||
// TODO: Log errors
|
||||
@@ -24,6 +29,11 @@ void IVCMIDirs::init()
|
||||
bfs::create_directories(userSavePath());
|
||||
}
|
||||
|
||||
#ifdef VCMI_ANDROID
|
||||
#include "CAndroidVMHelper.h"
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef VCMI_WINDOWS
|
||||
|
||||
#ifdef __MINGW32__
|
||||
@@ -532,26 +542,55 @@ bfs::path VCMIDirsXDG::libraryPath() const { return M_LIB_DIR; }
|
||||
bfs::path VCMIDirsXDG::binaryPath() const { return M_BIN_DIR; }
|
||||
|
||||
std::string VCMIDirsXDG::libraryName(const std::string& basename) const { return "lib" + basename + ".so"; }
|
||||
|
||||
#ifdef VCMI_ANDROID
|
||||
|
||||
class VCMIDirsAndroid : public VCMIDirsXDG
|
||||
{
|
||||
std::string basePath;
|
||||
std::string internalPath;
|
||||
std::string nativePath;
|
||||
public:
|
||||
boost::filesystem::path userDataPath() const override;
|
||||
boost::filesystem::path userCachePath() const override;
|
||||
boost::filesystem::path userConfigPath() const override;
|
||||
bfs::path fullLibraryPath(const std::string & desiredFolder, const std::string & baseLibName) const override;
|
||||
bfs::path libraryPath() const override;
|
||||
bfs::path userDataPath() const override;
|
||||
bfs::path userCachePath() const override;
|
||||
bfs::path userConfigPath() const override;
|
||||
|
||||
std::vector<boost::filesystem::path> dataPaths() const override;
|
||||
std::vector<bfs::path> dataPaths() const override;
|
||||
|
||||
void init() override;
|
||||
};
|
||||
|
||||
// on Android HOME will be set to something like /sdcard/data/Android/is.xyz.vcmi/files/
|
||||
bfs::path VCMIDirsAndroid::userDataPath() const { return getenv("HOME"); }
|
||||
bfs::path VCMIDirsAndroid::libraryPath() const { return nativePath; }
|
||||
bfs::path VCMIDirsAndroid::userDataPath() const { return basePath; }
|
||||
bfs::path VCMIDirsAndroid::userCachePath() const { return userDataPath() / "cache"; }
|
||||
bfs::path VCMIDirsAndroid::userConfigPath() const { return userDataPath() / "config"; }
|
||||
|
||||
bfs::path VCMIDirsAndroid::fullLibraryPath(const std::string & desiredFolder, const std::string & baseLibName) const
|
||||
{
|
||||
// ignore passed folder (all libraries in android are dumped into a single folder)
|
||||
return libraryPath() / libraryName(baseLibName);
|
||||
}
|
||||
|
||||
std::vector<bfs::path> VCMIDirsAndroid::dataPaths() const
|
||||
{
|
||||
return std::vector<bfs::path>(1, userDataPath());
|
||||
std::vector<bfs::path> paths(2);
|
||||
paths.push_back(internalPath);
|
||||
paths.push_back(userDataPath());
|
||||
return paths;
|
||||
}
|
||||
|
||||
void VCMIDirsAndroid::init()
|
||||
{
|
||||
// asks java code to retrieve needed paths from environment
|
||||
CAndroidVMHelper envHelper;
|
||||
basePath = envHelper.callStaticStringMethod(CAndroidVMHelper::NATIVE_METHODS_DEFAULT_CLASS, "dataRoot");
|
||||
internalPath = envHelper.callStaticStringMethod(CAndroidVMHelper::NATIVE_METHODS_DEFAULT_CLASS, "internalDataRoot");
|
||||
nativePath = envHelper.callStaticStringMethod(CAndroidVMHelper::NATIVE_METHODS_DEFAULT_CLASS, "nativePath");
|
||||
IVCMIDirs::init();
|
||||
}
|
||||
|
||||
#endif // VCMI_ANDROID
|
||||
#endif // VCMI_APPLE, VCMI_XDG
|
||||
#endif // VCMI_WINDOWS, VCMI_UNIX
|
||||
@@ -569,7 +608,8 @@ namespace VCMIDirs
|
||||
static VCMIDirsXDG singleton;
|
||||
#elif defined(VCMI_APPLE)
|
||||
static VCMIDirsOSX singleton;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static bool initialized = false;
|
||||
if (!initialized)
|
||||
{
|
||||
@@ -584,3 +624,4 @@ namespace VCMIDirs
|
||||
return singleton;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user