mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-13 14:51:51 -04:00
Add an option to install mod with custom args
This commit is contained in:
parent
48af767506
commit
ff855b5a52
@ -50,6 +50,7 @@ public class InstallModActivity extends LoggableActivity
|
||||
JREUtils.redirectAndPrintJRELog(this);
|
||||
|
||||
final File modFile = (File) getIntent().getExtras().getSerializable("modFile");
|
||||
final String javaArgs = getIntent().getExtras().getString("javaArgs");
|
||||
|
||||
mTextureView = findViewById(R.id.installmod_surfaceview);
|
||||
mTextureView.setSurfaceTextureListener(new TextureView.SurfaceTextureListener(){
|
||||
@ -68,7 +69,7 @@ public class InstallModActivity extends LoggableActivity
|
||||
new Thread(new Runnable(){
|
||||
@Override
|
||||
public void run() {
|
||||
launchJavaRuntime(modFile);
|
||||
launchJavaRuntime(modFile, javaArgs);
|
||||
// finish();
|
||||
}
|
||||
}).start();
|
||||
@ -107,7 +108,7 @@ public class InstallModActivity extends LoggableActivity
|
||||
// mIsResuming = true;
|
||||
}
|
||||
|
||||
private void launchJavaRuntime(File modFile) {
|
||||
private void launchJavaRuntime(File modFile, String javaArgs) {
|
||||
try {
|
||||
List<String> javaArgList = new ArrayList<String>();
|
||||
|
||||
@ -131,8 +132,12 @@ public class InstallModActivity extends LoggableActivity
|
||||
javaArgList.addAll(Arrays.asList(Tools.read(cacioArgOverrideFile.getAbsolutePath()).split(" ")));
|
||||
}
|
||||
|
||||
javaArgList.add("-jar");
|
||||
javaArgList.add(modFile.getAbsolutePath());
|
||||
if (javaArgs != null) {
|
||||
javaArgList.addAll(Arrays.asList(javaArgs.split(" ")));
|
||||
} else {
|
||||
javaArgList.add("-jar");
|
||||
javaArgList.add(modFile.getAbsolutePath());
|
||||
}
|
||||
|
||||
System.out.println(Arrays.toString(javaArgList.toArray(new String[0])));
|
||||
|
||||
|
@ -765,17 +765,20 @@ public class MCLauncherActivity extends AppCompatActivity
|
||||
{
|
||||
switch (p2) {
|
||||
case 0: // Mod installer
|
||||
installMod();
|
||||
installMod(false);
|
||||
break;
|
||||
case 1: // Custom controls
|
||||
case 1: // Mod installer with java args
|
||||
installMod(true);
|
||||
break;
|
||||
case 2: // Custom controls
|
||||
if (Tools.enableDevFeatures) {
|
||||
startActivity(new Intent(MCLauncherActivity.this, CustomControlsActivity.class));
|
||||
}
|
||||
break;
|
||||
case 2: // Settings
|
||||
case 3: // Settings
|
||||
startActivity(new Intent(MCLauncherActivity.this, LauncherPreferenceActivity.class));
|
||||
break;
|
||||
case 3:{ // About
|
||||
case 4: { // About
|
||||
final AlertDialog.Builder aboutB = new AlertDialog.Builder(MCLauncherActivity.this);
|
||||
aboutB.setTitle(R.string.mcl_option_about);
|
||||
try
|
||||
@ -797,26 +800,43 @@ public class MCLauncherActivity extends AppCompatActivity
|
||||
builder.show();
|
||||
}
|
||||
|
||||
private void installMod() {
|
||||
private void installMod(boolean customJavaArgs) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle(R.string.alerttitle_installmod);
|
||||
builder.setPositiveButton(android.R.string.cancel, null);
|
||||
builder.setNegativeButton(android.R.string.cancel, null);
|
||||
|
||||
final AlertDialog dialog = builder.create();
|
||||
FileListView flv = new FileListView(this);
|
||||
flv.setFileSelectedListener(new FileSelectedListener(){
|
||||
final AlertDialog dialog;
|
||||
if (customJavaArgs) {
|
||||
final EditText edit = new EditText(this);
|
||||
edit.setSingleLine();
|
||||
edit.setHint("-jar/-cp /path/to/file.jar ...");
|
||||
builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener(){
|
||||
@Override
|
||||
public void onClick(DialogInterface di, int i) {
|
||||
Intent intent = new Intent(MCLauncherActivity.this, InstallModActivity.class);
|
||||
intent.putExtra("javaArgs", edit.getText().toString());
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
dialog = builder.create();
|
||||
dialog.setView(edit);
|
||||
} else {
|
||||
dialog = builder.create();
|
||||
FileListView flv = new FileListView(this);
|
||||
flv.setFileSelectedListener(new FileSelectedListener(){
|
||||
|
||||
@Override
|
||||
public void onFileSelected(File file, String path, String name) {
|
||||
if (name.endsWith(".jar")) {
|
||||
Intent intent = new Intent(MCLauncherActivity.this, InstallModActivity.class);
|
||||
intent.putExtra("modFile", file);
|
||||
startActivity(intent);
|
||||
dialog.dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
dialog.setView(flv);
|
||||
@Override
|
||||
public void onFileSelected(File file, String path, String name) {
|
||||
if (name.endsWith(".jar")) {
|
||||
Intent intent = new Intent(MCLauncherActivity.this, InstallModActivity.class);
|
||||
intent.putExtra("modFile", file);
|
||||
startActivity(intent);
|
||||
dialog.dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
dialog.setView(flv);
|
||||
}
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
<resources>
|
||||
<string-array name="mcl_options">
|
||||
<item>@string/mcl_option_modinstall</item>
|
||||
<item>@string/mcl_option_modinstallwitharg</item>
|
||||
<item>@string/mcl_option_customcontrol</item>
|
||||
<item>@string/mcl_option_settings</item>
|
||||
<item>@string/mcl_option_about</item>
|
||||
|
@ -86,6 +86,7 @@
|
||||
<string name="mcl_options">Options</string>
|
||||
<string name="mcl_option_modmgr">Mod manager (no function)</string>
|
||||
<string name="mcl_option_modinstall">Install mod (Forge, LabyMod, Fabric,...)</string>
|
||||
<string name="mcl_option_modinstallwitharg">Install mod (with custom arguments)</string>
|
||||
<string name="mcl_option_checkupdate">Check for update</string>
|
||||
<string name="mcl_option_customcontrol">Custom controls</string>
|
||||
<string name="mcl_option_settings">Settings</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user