Merged in Bobbyjones/love/new-conf-flag-for-android-2 (pull request #53)

New conf flag for android 2
This commit is contained in:
Alex Szpakowski
2016-01-10 20:11:34 -04:00
6 changed files with 56 additions and 5 deletions
+10
View File
@@ -50,6 +50,16 @@ Filesystem::~Filesystem()
{
}
void Filesystem::setAndroidSaveExternal(bool useExternal)
{
this->useExternal = useExternal;
}
bool Filesystem::isAndroidSaveExternal() const
{
return useExternal;
}
bool Filesystem::isRealDirectory(const std::string &path) const
{
#ifdef LOVE_WINDOWS
+18
View File
@@ -79,6 +79,20 @@ public:
**/
virtual bool setupWriteDirectory() = 0;
/**
* This sets the save location on Android.
* False for internal, true for external
* @param external Bool for whether
* Android should use external file storage.
**/
virtual void setAndroidSaveExternal(bool useExternal = false);
/**
* Gets whether the Android save is external.
* Returns a bool.
**/
virtual bool isAndroidSaveExternal() const;
/**
* Sets the name of the save folder.
* @param ident The name of the game. Will be used to
@@ -263,6 +277,10 @@ public:
**/
virtual std::string getExecutablePath() const;
private:
//should we save external or internal for Android
bool useExternal;
}; // Filesystem
} // filesystem
+10 -5
View File
@@ -144,7 +144,7 @@ bool Filesystem::isFused() const
return fused;
}
bool Filesystem::setIdentity(const char *ident, bool appendToPath)
bool Filesystem::setIdentity(const char *ident, bool appendToPath)
{
if (!PHYSFS_isInit())
return false;
@@ -169,11 +169,16 @@ bool Filesystem::setIdentity(const char *ident, bool appendToPath)
#ifdef LOVE_ANDROID
if (save_identity == "")
save_identity = "unnamed";
std::string internal_storage_path = SDL_AndroidGetInternalStoragePath();
std::string save_directory = internal_storage_path + "/save";
save_path_full = std::string(SDL_AndroidGetInternalStoragePath()) + std::string("/save/") + save_identity;
std::string storage_path;
if (isAndroidSaveExternal())
storage_path = SDL_AndroidGetExternalStoragePath();
else
storage_path = SDL_AndroidGetInternalStoragePath();
std::string save_directory = storage_path + "/save";
save_path_full = storage_path + std::string("/save/") + save_identity;
if (!love::android::directoryExists(save_path_full.c_str()) &&
!love::android::mkdir(save_path_full.c_str()))
@@ -69,6 +69,13 @@ int w_isFused(lua_State *L)
return 1;
}
int w_setAndroidSaveExternal(lua_State *L)
{
bool useExternal = luax_optboolean(L, 1, false);
instance()->setAndroidSaveExternal(useExternal);
return 0;
}
int w_setIdentity(lua_State *L)
{
const char *arg = luaL_checkstring(L, 1);
@@ -708,6 +715,7 @@ static const luaL_Reg functions[] =
{ "init", w_init },
{ "setFused", w_setFused },
{ "isFused", w_isFused },
{ "_setAndroidSaveExternal", w_setAndroidSaveExternal },
{ "setIdentity", w_setIdentity },
{ "getIdentity", w_getIdentity },
{ "setSource", w_setSource },