@@ -35,6 +35,7 @@ import org.fmod.FMOD
3535import java.io.File
3636import java.io.FileInputStream
3737import java.io.FileOutputStream
38+ import java.io.IOException
3839
3940enum class DisplayMode {
4041 DEFAULT , LIMITED , FULLSCREEN ;
@@ -132,9 +133,7 @@ class GeometryDashActivity : AppCompatActivity(), Cocos2dxHelper.Cocos2dxHelperL
132133 tryLoadLibrary(gdPackageInfo, Constants .FMOD_LIB_NAME )
133134 tryLoadLibrary(gdPackageInfo, Constants .COCOS_LIB_NAME )
134135
135- if (getLoadTesting()) {
136- loadTestingLibraries()
137- }
136+ loadInternalMods()
138137
139138 setContentView(createView())
140139
@@ -513,48 +512,44 @@ class GeometryDashActivity : AppCompatActivity(), Cocos2dxHelper.Cocos2dxHelperL
513512 return isEmulator
514513 }
515514
516- private fun getLoadTesting (): Boolean {
517- val preferences = PreferenceUtils .get(this )
518- return preferences.getBoolean(PreferenceUtils .Key .LOAD_TESTING )
515+ override fun onCapabilityAdded (capability : String ): Boolean {
516+ if (capability == GeodeUtils .CAPABILITY_EXTENDED_INPUT ) {
517+ mGLSurfaceView?.useKeyboardEvents = true
518+ return true
519+ }
520+
521+ return false
519522 }
520523
521- @SuppressLint(" UnsafeDynamicallyLoadedCode" )
522- private fun loadTestingLibraries () {
523- // clear data dir
524- val testDirPath = File (filesDir.path + File .separator + " testlib" + File .separator)
525- if (testDirPath.exists()) {
526- testDirPath.deleteRecursively()
524+ /* *
525+ * Copies a mod from the launcher's assets to the Geode mods directory.
526+ * This method is not recommended for casual use, the new mod will not be automatically removed.
527+ */
528+ private fun loadInternalMods () {
529+ val internalModBase = " mods"
530+
531+ val modListing = try {
532+ assets.list(internalModBase)
533+ } catch (ioe: IOException ) {
534+ emptyArray<String >()
527535 }
528- testDirPath.mkdir()
529536
530- val dir = LaunchUtils .getBaseDirectory(this )
531- val testingPath = File (dir, " test" )
537+ val modDirectory = File (
538+ LaunchUtils .getBaseDirectory(this ),
539+ " game/geode/mods"
540+ )
532541
533- testingPath.walk().forEach {
534- if (it.isFile) {
535- // welcome to the world of Android classloader permissions
536- val outputFile = File (testDirPath, it.name)
537- DownloadUtils .copyFile(
538- FileInputStream (it),
539- FileOutputStream (outputFile)
540- )
542+ modDirectory.mkdirs()
541543
542- try {
543- println (" Loading test library ${outputFile.name} " )
544- System .load(outputFile.path)
545- } catch (e: UnsatisfiedLinkError ) {
546- e.printStackTrace()
547- }
548- }
549- }
550- }
544+ modListing?.forEach { fileName ->
545+ if (fileName.endsWith(" .geode" )) {
546+ val modOutput = File (modDirectory, fileName)
551547
552- override fun onCapabilityAdded (capability : String ): Boolean {
553- if (capability == GeodeUtils .CAPABILITY_EXTENDED_INPUT ) {
554- mGLSurfaceView?.useKeyboardEvents = true
555- return true
556- }
548+ val mod = assets.open(" $internalModBase /$fileName " )
549+ DownloadUtils .copyFile(mod, modOutput.outputStream())
557550
558- return false
551+ println (" Copied internal mod $fileName " )
552+ }
553+ }
559554 }
560555}
0 commit comments