mirror of
https://github.com/2009scape/2009Scape-mobile.git
synced 2025-12-20 13:30:15 -07:00
Start moving Pojav modules outside of the game directory
This commit is contained in:
parent
7b99b423e5
commit
9e14381b32
8 changed files with 35 additions and 33 deletions
|
|
@ -120,7 +120,7 @@ public class BaseMainActivity extends LoggableActivity {
|
|||
// FIXME: is it safe fot multi thread?
|
||||
GLOBAL_CLIPBOARD = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
||||
|
||||
logFile = new File(Tools.DIR_GAME_NEW, "latestlog.txt");
|
||||
logFile = new File(Tools.DIR_GAME_HOME, "latestlog.txt");
|
||||
logFile.delete();
|
||||
logFile.createNewFile();
|
||||
logStream = new PrintStream(logFile.getAbsolutePath());
|
||||
|
|
@ -931,7 +931,7 @@ public class BaseMainActivity extends LoggableActivity {
|
|||
}
|
||||
|
||||
private void checkLWJGL3Installed() {
|
||||
File lwjgl3dir = new File(Tools.DIR_GAME_NEW, "lwjgl3");
|
||||
File lwjgl3dir = new File(Tools.DIR_GAME_HOME, "lwjgl3");
|
||||
if (!lwjgl3dir.exists() || lwjgl3dir.isFile() || lwjgl3dir.list().length == 0) {
|
||||
appendlnToLog("Error: LWJGL3 was not installed!");
|
||||
throw new RuntimeException(getString(R.string.mcn_check_fail_lwjgl));
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ public class JavaGUILauncherActivity extends LoggableActivity implements View.On
|
|||
|
||||
placeMouseAt(CallbackBridge.physicalWidth / 2, CallbackBridge.physicalHeight / 2);
|
||||
|
||||
logFile = new File(Tools.DIR_GAME_NEW, "latestlog.txt");
|
||||
logFile = new File(Tools.DIR_GAME_HOME, "latestlog.txt");
|
||||
logFile.delete();
|
||||
logFile.createNewFile();
|
||||
logStream = new PrintStream(logFile.getAbsolutePath());
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ public class PojavApplication extends Application
|
|||
@Override
|
||||
public void uncaughtException(Thread thread, Throwable th) {
|
||||
boolean storagePermAllowed = Build.VERSION.SDK_INT < 23 || ActivityCompat.checkSelfPermission(PojavApplication.this, android.Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED;
|
||||
File crashFile = new File(storagePermAllowed ? Tools.DIR_GAME_NEW : Tools.DIR_DATA, "latestcrash.txt");
|
||||
File crashFile = new File(storagePermAllowed ? Tools.DIR_GAME_HOME : Tools.DIR_DATA, "latestcrash.txt");
|
||||
try {
|
||||
// Write to file, since some devices may not able to show error
|
||||
crashFile.getParentFile().mkdirs();
|
||||
|
|
|
|||
|
|
@ -326,7 +326,7 @@ public class PojavLoginActivity extends BaseActivity
|
|||
}
|
||||
|
||||
private void unpackComponent(AssetManager am, String component) throws IOException {
|
||||
File versionFile = new File(Tools.DIR_GAME_NEW + "/" + component + "/version");
|
||||
File versionFile = new File(Tools.DIR_GAME_HOME + "/" + component + "/version");
|
||||
InputStream is = am.open("components/" + component + "/version");
|
||||
if(!versionFile.exists()) {
|
||||
if (versionFile.getParentFile().exists() && versionFile.getParentFile().isDirectory()) {
|
||||
|
|
@ -337,7 +337,7 @@ public class PojavLoginActivity extends BaseActivity
|
|||
Log.i("UnpackPrep", component + ": Pack was installed manually, or does not exist, unpacking new...");
|
||||
String[] fileList = am.list("components/" + component);
|
||||
for(String s : fileList) {
|
||||
Tools.copyAssetFile(this, "components/" + component + "/" + s, Tools.DIR_GAME_NEW + "/" + component, true);
|
||||
Tools.copyAssetFile(this, "components/" + component + "/" + s, Tools.DIR_GAME_HOME + "/" + component, true);
|
||||
}
|
||||
} else {
|
||||
FileInputStream fis = new FileInputStream(versionFile);
|
||||
|
|
@ -351,28 +351,15 @@ public class PojavLoginActivity extends BaseActivity
|
|||
|
||||
String[] fileList = am.list("components/" + component);
|
||||
for (String s : fileList) {
|
||||
Tools.copyAssetFile(this, "components/" + component + "/" + s, Tools.DIR_GAME_NEW + "/" + component, true);
|
||||
Tools.copyAssetFile(this, "components/" + component + "/" + s, Tools.DIR_GAME_HOME + "/" + component, true);
|
||||
}
|
||||
} else {
|
||||
Log.i("UnpackPrep", component + ": Pack is up-to-date with the launcher, continuing...");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void initMain() throws Throwable {
|
||||
mkdirs(Tools.DIR_ACCOUNT_NEW);
|
||||
PojavMigrator.migrateAccountData(this);
|
||||
|
||||
mkdirs(Tools.DIR_GAME_HOME);
|
||||
if (!PojavMigrator.migrateGameDir()) {
|
||||
mkdirs(Tools.DIR_GAME_NEW);
|
||||
mkdirs(Tools.DIR_GAME_NEW + "/config");
|
||||
mkdirs(Tools.DIR_GAME_NEW + "/lwjgl3");
|
||||
mkdirs(Tools.DIR_GAME_NEW + "/mods");
|
||||
mkdirs(Tools.DIR_HOME_VERSION);
|
||||
mkdirs(Tools.DIR_HOME_LIBRARY);
|
||||
}
|
||||
|
||||
public static void disableSplash() {
|
||||
mkdirs(Tools.DIR_GAME_NEW + "/config");
|
||||
File forgeSplashFile = new File(Tools.DIR_GAME_NEW, "config/splash.properties");
|
||||
String forgeSplashContent = "enabled=true";
|
||||
try {
|
||||
|
|
@ -381,11 +368,25 @@ public class PojavLoginActivity extends BaseActivity
|
|||
}
|
||||
if (forgeSplashContent.contains("enabled=true")) {
|
||||
Tools.write(forgeSplashFile.getAbsolutePath(),
|
||||
forgeSplashContent.replace("enabled=true", "enabled=false"));
|
||||
forgeSplashContent.replace("enabled=true", "enabled=false"));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Log.w(Tools.APP_NAME, "Could not disable Forge 1.12.2 and below splash screen!", e);
|
||||
}
|
||||
}
|
||||
private void initMain() throws Throwable {
|
||||
mkdirs(Tools.DIR_ACCOUNT_NEW);
|
||||
PojavMigrator.migrateAccountData(this);
|
||||
|
||||
mkdirs(Tools.DIR_GAME_HOME);
|
||||
mkdirs(Tools.DIR_GAME_HOME + "/lwjgl3");
|
||||
mkdirs(Tools.DIR_GAME_HOME + "/config");
|
||||
if (!PojavMigrator.migrateGameDir()) {
|
||||
mkdirs(Tools.DIR_GAME_NEW);
|
||||
mkdirs(Tools.DIR_GAME_NEW + "/mods");
|
||||
mkdirs(Tools.DIR_HOME_VERSION);
|
||||
mkdirs(Tools.DIR_HOME_LIBRARY);
|
||||
}
|
||||
|
||||
mkdirs(Tools.CTRLMAP_PATH);
|
||||
|
||||
|
|
@ -601,7 +602,7 @@ public class PojavLoginActivity extends BaseActivity
|
|||
tarIn.close();
|
||||
}
|
||||
|
||||
private boolean mkdirs(String path)
|
||||
private static boolean mkdirs(String path)
|
||||
{
|
||||
File file = new File(path);
|
||||
// check necessary???
|
||||
|
|
|
|||
|
|
@ -49,16 +49,16 @@ public class PojavMigrator
|
|||
}
|
||||
return moved;
|
||||
}
|
||||
|
||||
/*
|
||||
public static boolean migrateBugFix20201217() throws IOException, InterruptedException {
|
||||
File bugGameDir = new File(Tools.DIR_GAME_NEW + "/.minecraft");
|
||||
File oldGameDir = new File(Tools.DIR_GAME_OLD);
|
||||
boolean moved = bugGameDir.exists() && bugGameDir.isDirectory();
|
||||
/*
|
||||
|
||||
if (oldGameDir.exists() && oldGameDir.isDirectory() && moved) {
|
||||
command("rm -rf " + oldGameDir.getAbsolutePath());
|
||||
}
|
||||
*/
|
||||
|
||||
if (moved) {
|
||||
command("mv " + bugGameDir.getAbsolutePath() + " " + Tools.DIR_GAME_OLD);
|
||||
command("rm -rf " + Tools.DIR_GAME_HOME + "/*");
|
||||
|
|
@ -67,7 +67,7 @@ public class PojavMigrator
|
|||
|
||||
return moved;
|
||||
}
|
||||
|
||||
*/
|
||||
private static void command(String cmd) throws IOException, InterruptedException {
|
||||
Process p = Runtime.getRuntime().exec(cmd);
|
||||
int exitCode = p.waitFor();
|
||||
|
|
|
|||
|
|
@ -59,8 +59,8 @@ public final class Tools
|
|||
|
||||
public static final String ASSETS_PATH = DIR_GAME_NEW + "/assets";
|
||||
public static final String OBSOLETE_RESOURCES_PATH= DIR_GAME_NEW + "/resources";
|
||||
public static final String CTRLMAP_PATH = DIR_GAME_NEW + "/controlmap";
|
||||
public static final String CTRLDEF_FILE = DIR_GAME_NEW + "/controlmap/default.json";
|
||||
public static final String CTRLMAP_PATH = DIR_GAME_HOME + "/controlmap";
|
||||
public static final String CTRLDEF_FILE = DIR_GAME_HOME + "/controlmap/default.json";
|
||||
|
||||
public static final String LIBNAME_OPTIFINE = "optifine:OptiFine";
|
||||
|
||||
|
|
@ -113,7 +113,7 @@ public final class Tools
|
|||
|
||||
StringBuilder cacioClasspath = new StringBuilder();
|
||||
cacioClasspath.append("-Xbootclasspath/p");
|
||||
File cacioDir = new File(DIR_GAME_NEW + "/caciocavallo");
|
||||
File cacioDir = new File(DIR_GAME_HOME + "/caciocavallo");
|
||||
if (cacioDir.exists() && cacioDir.isDirectory()) {
|
||||
for (File file : cacioDir.listFiles()) {
|
||||
if (file.getName().endsWith(".jar")) {
|
||||
|
|
@ -270,7 +270,7 @@ public final class Tools
|
|||
|
||||
private static String getLWJGL3ClassPath() {
|
||||
StringBuilder libStr = new StringBuilder();
|
||||
File lwjgl3Folder = new File(Tools.DIR_GAME_NEW, "lwjgl3");
|
||||
File lwjgl3Folder = new File(Tools.DIR_GAME_HOME, "lwjgl3");
|
||||
if (/* info.arguments != null && */ lwjgl3Folder.exists()) {
|
||||
for (File file: lwjgl3Folder.listFiles()) {
|
||||
if (file.getName().endsWith(".jar")) {
|
||||
|
|
|
|||
|
|
@ -259,6 +259,7 @@ public class MinecraftDownloaderTask extends AsyncTask<String, String, Throwable
|
|||
jvmArgs.add("-Xms128M");
|
||||
jvmArgs.add("-Xmx1G");
|
||||
*/
|
||||
PojavLoginActivity.disableSplash();
|
||||
Intent mainIntent = new Intent(mActivity, MainActivity.class /* MainActivity.class */);
|
||||
// mainIntent.addFlags(Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT);
|
||||
mainIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
|
||||
|
|
|
|||
|
|
@ -227,7 +227,7 @@ public class JREUtils
|
|||
envMap.put("AWTSTUB_WIDTH", Integer.toString(CallbackBridge.windowWidth > 0 ? CallbackBridge.windowWidth : CallbackBridge.physicalWidth));
|
||||
envMap.put("AWTSTUB_HEIGHT", Integer.toString(CallbackBridge.windowHeight > 0 ? CallbackBridge.windowHeight : CallbackBridge.physicalHeight));
|
||||
|
||||
File customEnvFile = new File(Tools.DIR_GAME_NEW, "custom_env.txt");
|
||||
File customEnvFile = new File(Tools.DIR_GAME_HOME, "custom_env.txt");
|
||||
if (customEnvFile.exists() && customEnvFile.isFile()) {
|
||||
BufferedReader reader = new BufferedReader(new FileReader(customEnvFile));
|
||||
String line;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue