mirror of
https://github.com/2009scape/2009Scape-mobile.git
synced 2025-12-21 09:01:56 -07:00
Changes
- Auto scale fixes - Now launch Fabric installer easier
This commit is contained in:
parent
927f81d6e2
commit
091042c820
11 changed files with 97 additions and 20 deletions
|
|
@ -2,14 +2,16 @@ package net.kdt.pojavlaunch;
|
|||
|
||||
import android.graphics.*;
|
||||
import android.os.*;
|
||||
import android.support.v7.app.*;
|
||||
import android.util.*;
|
||||
import android.view.*;
|
||||
import android.widget.*;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import net.kdt.pojavlaunch.installers.*;
|
||||
import net.kdt.pojavlaunch.utils.*;
|
||||
import org.lwjgl.glfw.*;
|
||||
import net.kdt.pojavlaunch.installers.*;
|
||||
import android.util.*;
|
||||
import android.content.*;
|
||||
|
||||
public class JavaGUILauncherActivity extends LoggableActivity {
|
||||
private AWTCanvasView mTextureView;
|
||||
|
|
@ -20,6 +22,8 @@ public class JavaGUILauncherActivity extends LoggableActivity {
|
|||
|
||||
private File logFile;
|
||||
private PrintStream logStream;
|
||||
|
||||
private Object mDialogLock;
|
||||
|
||||
private boolean isLogAllow, mSkipDetectMod;
|
||||
|
||||
|
|
@ -56,7 +60,6 @@ public class JavaGUILauncherActivity extends LoggableActivity {
|
|||
|
||||
mSkipDetectMod = getIntent().getExtras().getBoolean("skipDetectMod", false);
|
||||
if (mSkipDetectMod) {
|
||||
JREUtils.redirectAndPrintJRELog(this, null);
|
||||
new Thread(new Runnable(){
|
||||
@Override
|
||||
public void run() {
|
||||
|
|
@ -78,7 +81,7 @@ public class JavaGUILauncherActivity extends LoggableActivity {
|
|||
Toast.makeText(JavaGUILauncherActivity.this, R.string.toast_optifine_success, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
} catch (IOException e) {
|
||||
} catch (Throwable e) {
|
||||
appendlnToLog("Install failed:");
|
||||
appendlnToLog(Log.getStackTraceString(e));
|
||||
Tools.showError(JavaGUILauncherActivity.this, e);
|
||||
|
|
@ -90,6 +93,42 @@ public class JavaGUILauncherActivity extends LoggableActivity {
|
|||
Tools.showError(this, th, true);
|
||||
}
|
||||
}
|
||||
|
||||
public String dialogInput(final String title, final int message) {
|
||||
final StringBuilder str = new StringBuilder();
|
||||
|
||||
runOnUiThread(new Runnable(){
|
||||
@Override
|
||||
public void run() {
|
||||
final EditText editText = new EditText(JavaGUILauncherActivity.this);
|
||||
editText.setHint(message);
|
||||
editText.setSingleLine();
|
||||
|
||||
AlertDialog.Builder d = new AlertDialog.Builder(JavaGUILauncherActivity.this);
|
||||
d.setCancelable(false);
|
||||
d.setTitle(title);
|
||||
d.setView(message);
|
||||
d.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener(){
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface i, int id) {
|
||||
str.append(editText.getText().toString());
|
||||
mDialogLock.notifyAll();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
synchronized (mDialogLock) {
|
||||
mDialogLock.wait();
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return str.toString();
|
||||
}
|
||||
|
||||
public void forceClose(View v) {
|
||||
BaseMainActivity.dialogForceClose(this);
|
||||
|
|
@ -120,16 +159,19 @@ public class JavaGUILauncherActivity extends LoggableActivity {
|
|||
} else if (InstallerDetector.isForgeNew(installer)) {
|
||||
appendlnToLog("Detected Forge Installer 1.12.2 or above!");
|
||||
new NewForgeInstaller(installer).install(this);
|
||||
} else {
|
||||
} else if (InstallerDetector.isFabric(installer)) {
|
||||
appendlnToLog("Detected Fabric Installer!");
|
||||
new FabricInstaller(installer).install(this);
|
||||
} else {
|
||||
appendlnToLog("No mod detected. Starting JVM");
|
||||
isLogAllow = false;
|
||||
mSkipDetectMod = true;
|
||||
JREUtils.redirectAndPrintJRELog(this, null);
|
||||
launchJavaRuntime(modFile, javaArgs);
|
||||
}
|
||||
}
|
||||
|
||||
private void launchJavaRuntime(File modFile, String javaArgs) {
|
||||
public void launchJavaRuntime(File modFile, String javaArgs) {
|
||||
JREUtils.redirectAndPrintJRELog(this, null);
|
||||
try {
|
||||
List<String> javaArgList = new ArrayList<String>();
|
||||
|
||||
|
|
|
|||
|
|
@ -344,7 +344,7 @@ public final class Tools
|
|||
public static float dpToPx(float dp) {
|
||||
// 921600 = 1280 * 720, default scale
|
||||
// TODO better way to scaling
|
||||
float scaledDp = dp / DisplayMetrics.DENSITY_XHIGH * currentDisplayMetrics.densityDpi;
|
||||
float scaledDp = dp; // / DisplayMetrics.DENSITY_XHIGH * currentDisplayMetrics.densityDpi;
|
||||
return (scaledDp * currentDisplayMetrics.density);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ public class BaseInstaller {
|
|||
mJarFile = new ZipFile(file);
|
||||
}
|
||||
|
||||
public void install(LoggableActivity ctx) throws IOException {}
|
||||
public void install(JavaGUILauncherActivity ctx) throws IOException {}
|
||||
|
||||
public void from(BaseInstaller base) {
|
||||
mFile = base.mFile;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
package net.kdt.pojavlaunch.installers;
|
||||
|
||||
import android.content.*;
|
||||
import java.io.*;
|
||||
import java.util.jar.*;
|
||||
import net.kdt.pojavlaunch.*;
|
||||
import java.nio.charset.*;
|
||||
import net.kdt.pojavlaunch.value.*;
|
||||
import org.apache.commons.io.*;
|
||||
import com.google.gson.*;
|
||||
import java.util.zip.*;
|
||||
|
||||
public class FabricInstaller extends BaseInstaller {
|
||||
public FabricInstaller(BaseInstaller i) {
|
||||
from(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void install(JavaGUILauncherActivity ctx) throws IOException {
|
||||
// Unused ZipFile
|
||||
mJarFile.close();
|
||||
|
||||
String mcversion = ctx.dialogInput("Fabric installer", R.string.main_version);
|
||||
|
||||
ctx.appendlnToLog("Launching JVM");
|
||||
ctx.launchJavaRuntime(null,
|
||||
"-jar " + mFile.getAbsolutePath() + " client -dir . -mcversion " + mcversion);
|
||||
}
|
||||
}
|
||||
|
|
@ -6,6 +6,10 @@ import net.kdt.pojavlaunch.value.*;
|
|||
|
||||
public class InstallerDetector
|
||||
{
|
||||
public static boolean isFabric(BaseInstaller installer) {
|
||||
return installer.mJarFile.getEntry("net/fabricmc/installer/Main.class") != null;
|
||||
}
|
||||
|
||||
// Forge Legacy: for 1.12.1 and below
|
||||
public static boolean isForgeLegacy(BaseInstaller installer) throws IOException, JsonSyntaxException {
|
||||
ForgeInstallProfile profile = LegacyForgeInstaller.readInstallProfile(installer);
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ public class LegacyForgeInstaller extends BaseInstaller {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void install(LoggableActivity ctx) throws IOException {
|
||||
public void install(JavaGUILauncherActivity ctx) throws IOException {
|
||||
String target;
|
||||
|
||||
ctx.appendlnToLog("Reading install_profile.json");
|
||||
|
|
@ -40,6 +40,8 @@ public class LegacyForgeInstaller extends BaseInstaller {
|
|||
FileOutputStream out = new FileOutputStream(target);
|
||||
IOUtils.copy(mJarFile.getInputStream(mJarFile.getEntry(profile.install.filePath)), out);
|
||||
out.close();
|
||||
|
||||
mJarFile.close();
|
||||
}
|
||||
|
||||
public static ForgeInstallProfile readInstallProfile(BaseInstaller base) throws IOException, JsonSyntaxException {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ public class NewForgeInstaller extends BaseInstaller {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void install(LoggableActivity ctx) throws IOException {
|
||||
public void install(JavaGUILauncherActivity ctx) throws IOException {
|
||||
String target;
|
||||
|
||||
ctx.appendlnToLog("Reading install_profile.json");
|
||||
|
|
@ -42,6 +42,8 @@ public class NewForgeInstaller extends BaseInstaller {
|
|||
String downloadPath = "https://files.minecraftforge.net/maven/" + profile.path.replace(":", "/").replace("net.minecraftforge","net/minecraftforge") + "/forge-" + libInfos[2] + "-universal.jar";
|
||||
ctx.appendlnToLog("Downloading " + target);
|
||||
Tools.downloadFile(downloadPath, target);
|
||||
|
||||
mJarFile.close();
|
||||
}
|
||||
|
||||
public static ForgeInstallProfile readInstallProfile(BaseInstaller base) throws IOException, JsonSyntaxException {
|
||||
|
|
|
|||
|
|
@ -20,6 +20,11 @@ public class LauncherPreferenceFragment extends PreferenceFragmentCompat
|
|||
seek2.setMin(100);
|
||||
seek2.setMax(1000);
|
||||
seek2.setValue(500);
|
||||
|
||||
SeekBarPreference seek3 = (SeekBarPreference) findPreference("buttonscale");
|
||||
seek3.setMin(20);
|
||||
seek3.setMax(500);
|
||||
seek3.setValue(100);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ public class LauncherPreferences
|
|||
public static String PREF_LANGUAGE = "default";
|
||||
|
||||
public static void loadPreferences() {
|
||||
PREF_BUTTONSIZE = DEFAULT_PREF.getFloat("controlSize", 1f);
|
||||
PREF_BUTTONSIZE = DEFAULT_PREF.getFloat("buttonscale", 100);
|
||||
PREF_FREEFORM = DEFAULT_PREF.getBoolean("freeform", false);
|
||||
PREF_VERTYPE_RELEASE = DEFAULT_PREF.getBoolean("vertype_release", true);
|
||||
PREF_VERTYPE_SNAPSHOT = DEFAULT_PREF.getBoolean("vertype_snapshot", false);
|
||||
|
|
|
|||
|
|
@ -190,12 +190,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GL_nativeRegalMakeCurrent(JNIEnv *e
|
|||
RegalMakeCurrent(potatoBridge.eglContext);
|
||||
}
|
||||
|
||||
bool isSizeSet;
|
||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_glfw_GLFW_nativeEglSwapBuffers(JNIEnv *env, jclass clazz) {
|
||||
if (!isSizeSet) {
|
||||
isSizeSet = true;
|
||||
Java_org_lwjgl_glfw_CallbackBridge_nativeSendScreenSize(NULL, NULL, savedWidth, savedHeight);
|
||||
}
|
||||
return eglSwapBuffers(potatoBridge.eglDisplay, potatoBridge.eglSurface);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -53,8 +53,6 @@
|
|||
<string name="error_checklog">Error! Please check the log below: %s</string>
|
||||
<string name="error_no_version">No version!</string>
|
||||
<string name="error_load_version">Unable to load version %s</string>
|
||||
<string name="error_convert_lib">Unable to convert library %s</string>
|
||||
<string name="error_convert_client">Unable to convert Minecraft %s</string>
|
||||
<string name="error_show_more">Show more</string>
|
||||
<string name="error_show_less">Show less</string>
|
||||
|
||||
|
|
@ -210,7 +208,7 @@
|
|||
<string name="main_welcome">Welcome,</string>
|
||||
<string name="main_infodev">Info (DEV)</string>
|
||||
<string name="main_switchuser">Switch user</string>
|
||||
<string name="main_version_">Version:</string>
|
||||
<string name="main_version">Version:</string>
|
||||
<string name="main_nocrash">No crash detected</string>
|
||||
<string name="main_nolog">No log.</string>
|
||||
</resources>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue