forked from geode-sdk/android-launcher
use external files for save
This commit is contained in:
4 files changed
+23
-2
No files matched your search
@@ -68,9 +68,12 @@ class GeometryDashActivity : AppCompatActivity(), Cocos2dxHelper.Cocos2dxHelperL
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// fixes bugs specific to the new app directory, such as package name
|
// fixes bugs specific to the new app directory, such as package name
|
||||||
|
val saveDir = LaunchUtils.getSaveDirectory(this)
|
||||||
|
saveDir.mkdir()
|
||||||
|
|
||||||
LauncherFix.loadLibrary()
|
LauncherFix.loadLibrary()
|
||||||
LauncherFix.setOriginalDataPath(Constants.GJ_DATA_DIR)
|
LauncherFix.setOriginalDataPath(Constants.GJ_DATA_DIR)
|
||||||
LauncherFix.setDataPath(filesDir.path)
|
LauncherFix.setDataPath(saveDir.path)
|
||||||
} catch (e: UnsatisfiedLinkError) {
|
} catch (e: UnsatisfiedLinkError) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -222,6 +222,12 @@ object GeodeUtils {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun getBaseDirectory(): String {
|
||||||
|
val activity = activity.get()!!
|
||||||
|
return LaunchUtils.getBaseDirectory(activity).path
|
||||||
|
}
|
||||||
|
|
||||||
// copied from https://stackoverflow.com/questions/17546101/get-real-path-for-uri-android
|
// copied from https://stackoverflow.com/questions/17546101/get-real-path-for-uri-android
|
||||||
// i am actually very lazy to move this to a separate class
|
// i am actually very lazy to move this to a separate class
|
||||||
|
|
||||||
|
|||||||
@@ -55,6 +55,17 @@ object LaunchUtils {
|
|||||||
return getInstalledGeodePath(context) != null
|
return getInstalledGeodePath(context) != null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the directory that Geode/the game should base itself off of.
|
||||||
|
*/
|
||||||
|
fun getBaseDirectory(context: Context): File {
|
||||||
|
return context.getExternalFilesDir("")!!
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getSaveDirectory(context: Context): File {
|
||||||
|
return File(getBaseDirectory(context), "save")
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressLint("DiscouragedPrivateApi")
|
@SuppressLint("DiscouragedPrivateApi")
|
||||||
fun addAssetsFromPackage(assetManager: AssetManager, packageInfo: PackageInfo) {
|
fun addAssetsFromPackage(assetManager: AssetManager, packageInfo: PackageInfo) {
|
||||||
// this method is officially marked as deprecated but it is the only method we are allowed to reflect
|
// this method is officially marked as deprecated but it is the only method we are allowed to reflect
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import android.content.Context
|
|||||||
import android.content.pm.ApplicationInfo
|
import android.content.pm.ApplicationInfo
|
||||||
import android.os.Process
|
import android.os.Process
|
||||||
import com.customRobTop.BaseRobTopActivity
|
import com.customRobTop.BaseRobTopActivity
|
||||||
|
import com.geode.launcher.utils.LaunchUtils
|
||||||
|
|
||||||
|
|
||||||
@Suppress("unused", "KotlinJniMissingFunction")
|
@Suppress("unused", "KotlinJniMissingFunction")
|
||||||
@@ -50,7 +51,7 @@ object Cocos2dxHelper {
|
|||||||
// sContext = pContext
|
// sContext = pContext
|
||||||
this.cocos2dxHelperListener = cocos2dxHelperListener
|
this.cocos2dxHelperListener = cocos2dxHelperListener
|
||||||
packageName = applicationInfo.packageName
|
packageName = applicationInfo.packageName
|
||||||
fileDirectory = context.filesDir.absolutePath
|
fileDirectory = LaunchUtils.getSaveDirectory(context).absolutePath
|
||||||
// Cocos2dxHelper.sCocos2dxAccelerometer = Cocos2dxAccelerometer(pContext)
|
// Cocos2dxHelper.sCocos2dxAccelerometer = Cocos2dxAccelerometer(pContext)
|
||||||
// Cocos2dxHelper.sCocos2dMusic = Cocos2dxMusic(pContext)
|
// Cocos2dxHelper.sCocos2dMusic = Cocos2dxMusic(pContext)
|
||||||
// var simultaneousStreams: Int = Cocos2dxSound.MAX_SIMULTANEOUS_STREAMS_DEFAULT
|
// var simultaneousStreams: Int = Cocos2dxSound.MAX_SIMULTANEOUS_STREAMS_DEFAULT
|
||||||
|
|||||||
Reference in new issue
Block a user