use external files for save

This commit is contained in:
qimiko committed 2024-01-06 20:17:05 -07:00
1 parent 10bdd06aa7
commit 0335be9908
4 files changed
+23 -2

No files matched your search

@@ -68,9 +68,12 @@ class GeometryDashActivity : AppCompatActivity(), Cocos2dxHelper.Cocos2dxHelperL
try {
// fixes bugs specific to the new app directory, such as package name
val saveDir = LaunchUtils.getSaveDirectory(this)
saveDir.mkdir()
LauncherFix.loadLibrary()
LauncherFix.setOriginalDataPath(Constants.GJ_DATA_DIR)
LauncherFix.setDataPath(filesDir.path)
LauncherFix.setDataPath(saveDir.path)
} catch (e: UnsatisfiedLinkError) {
e.printStackTrace()
}
@@ -222,6 +222,12 @@ object GeodeUtils {
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
// i am actually very lazy to move this to a separate class
@@ -55,6 +55,17 @@ object LaunchUtils {
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")
fun addAssetsFromPackage(assetManager: AssetManager, packageInfo: PackageInfo) {
// 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.os.Process
import com.customRobTop.BaseRobTopActivity
import com.geode.launcher.utils.LaunchUtils
@Suppress("unused", "KotlinJniMissingFunction")
@@ -50,7 +51,7 @@ object Cocos2dxHelper {
// sContext = pContext
this.cocos2dxHelperListener = cocos2dxHelperListener
packageName = applicationInfo.packageName
fileDirectory = context.filesDir.absolutePath
fileDirectory = LaunchUtils.getSaveDirectory(context).absolutePath
// Cocos2dxHelper.sCocos2dxAccelerometer = Cocos2dxAccelerometer(pContext)
// Cocos2dxHelper.sCocos2dMusic = Cocos2dxMusic(pContext)
// var simultaneousStreams: Int = Cocos2dxSound.MAX_SIMULTANEOUS_STREAMS_DEFAULT