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,7 +50,8 @@ public class InstallModActivity extends LoggableActivity
|
|||||||
JREUtils.redirectAndPrintJRELog(this);
|
JREUtils.redirectAndPrintJRELog(this);
|
||||||
|
|
||||||
final File modFile = (File) getIntent().getExtras().getSerializable("modFile");
|
final File modFile = (File) getIntent().getExtras().getSerializable("modFile");
|
||||||
|
final String javaArgs = getIntent().getExtras().getString("javaArgs");
|
||||||
|
|
||||||
mTextureView = findViewById(R.id.installmod_surfaceview);
|
mTextureView = findViewById(R.id.installmod_surfaceview);
|
||||||
mTextureView.setSurfaceTextureListener(new TextureView.SurfaceTextureListener(){
|
mTextureView.setSurfaceTextureListener(new TextureView.SurfaceTextureListener(){
|
||||||
|
|
||||||
@ -68,7 +69,7 @@ public class InstallModActivity extends LoggableActivity
|
|||||||
new Thread(new Runnable(){
|
new Thread(new Runnable(){
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
launchJavaRuntime(modFile);
|
launchJavaRuntime(modFile, javaArgs);
|
||||||
// finish();
|
// finish();
|
||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
@ -107,7 +108,7 @@ public class InstallModActivity extends LoggableActivity
|
|||||||
// mIsResuming = true;
|
// mIsResuming = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void launchJavaRuntime(File modFile) {
|
private void launchJavaRuntime(File modFile, String javaArgs) {
|
||||||
try {
|
try {
|
||||||
List<String> javaArgList = new ArrayList<String>();
|
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.addAll(Arrays.asList(Tools.read(cacioArgOverrideFile.getAbsolutePath()).split(" ")));
|
||||||
}
|
}
|
||||||
|
|
||||||
javaArgList.add("-jar");
|
if (javaArgs != null) {
|
||||||
javaArgList.add(modFile.getAbsolutePath());
|
javaArgList.addAll(Arrays.asList(javaArgs.split(" ")));
|
||||||
|
} else {
|
||||||
|
javaArgList.add("-jar");
|
||||||
|
javaArgList.add(modFile.getAbsolutePath());
|
||||||
|
}
|
||||||
|
|
||||||
System.out.println(Arrays.toString(javaArgList.toArray(new String[0])));
|
System.out.println(Arrays.toString(javaArgList.toArray(new String[0])));
|
||||||
|
|
||||||
|
@ -765,17 +765,20 @@ public class MCLauncherActivity extends AppCompatActivity
|
|||||||
{
|
{
|
||||||
switch (p2) {
|
switch (p2) {
|
||||||
case 0: // Mod installer
|
case 0: // Mod installer
|
||||||
installMod();
|
installMod(false);
|
||||||
break;
|
break;
|
||||||
case 1: // Custom controls
|
case 1: // Mod installer with java args
|
||||||
|
installMod(true);
|
||||||
|
break;
|
||||||
|
case 2: // Custom controls
|
||||||
if (Tools.enableDevFeatures) {
|
if (Tools.enableDevFeatures) {
|
||||||
startActivity(new Intent(MCLauncherActivity.this, CustomControlsActivity.class));
|
startActivity(new Intent(MCLauncherActivity.this, CustomControlsActivity.class));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2: // Settings
|
case 3: // Settings
|
||||||
startActivity(new Intent(MCLauncherActivity.this, LauncherPreferenceActivity.class));
|
startActivity(new Intent(MCLauncherActivity.this, LauncherPreferenceActivity.class));
|
||||||
break;
|
break;
|
||||||
case 3:{ // About
|
case 4: { // About
|
||||||
final AlertDialog.Builder aboutB = new AlertDialog.Builder(MCLauncherActivity.this);
|
final AlertDialog.Builder aboutB = new AlertDialog.Builder(MCLauncherActivity.this);
|
||||||
aboutB.setTitle(R.string.mcl_option_about);
|
aboutB.setTitle(R.string.mcl_option_about);
|
||||||
try
|
try
|
||||||
@ -797,26 +800,43 @@ public class MCLauncherActivity extends AppCompatActivity
|
|||||||
builder.show();
|
builder.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void installMod() {
|
private void installMod(boolean customJavaArgs) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
builder.setTitle(R.string.alerttitle_installmod);
|
builder.setTitle(R.string.alerttitle_installmod);
|
||||||
builder.setPositiveButton(android.R.string.cancel, null);
|
builder.setNegativeButton(android.R.string.cancel, null);
|
||||||
|
|
||||||
|
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(){
|
||||||
|
|
||||||
final AlertDialog dialog = builder.create();
|
@Override
|
||||||
FileListView flv = new FileListView(this);
|
public void onFileSelected(File file, String path, String name) {
|
||||||
flv.setFileSelectedListener(new FileSelectedListener(){
|
if (name.endsWith(".jar")) {
|
||||||
|
Intent intent = new Intent(MCLauncherActivity.this, InstallModActivity.class);
|
||||||
@Override
|
intent.putExtra("modFile", file);
|
||||||
public void onFileSelected(File file, String path, String name) {
|
startActivity(intent);
|
||||||
if (name.endsWith(".jar")) {
|
dialog.dismiss();
|
||||||
Intent intent = new Intent(MCLauncherActivity.this, InstallModActivity.class);
|
}
|
||||||
intent.putExtra("modFile", file);
|
}
|
||||||
startActivity(intent);
|
});
|
||||||
dialog.dismiss();
|
dialog.setView(flv);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
dialog.setView(flv);
|
|
||||||
dialog.show();
|
dialog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<string-array name="mcl_options">
|
<string-array name="mcl_options">
|
||||||
<item>@string/mcl_option_modinstall</item>
|
<item>@string/mcl_option_modinstall</item>
|
||||||
|
<item>@string/mcl_option_modinstallwitharg</item>
|
||||||
<item>@string/mcl_option_customcontrol</item>
|
<item>@string/mcl_option_customcontrol</item>
|
||||||
<item>@string/mcl_option_settings</item>
|
<item>@string/mcl_option_settings</item>
|
||||||
<item>@string/mcl_option_about</item>
|
<item>@string/mcl_option_about</item>
|
||||||
|
@ -86,6 +86,7 @@
|
|||||||
<string name="mcl_options">Options</string>
|
<string name="mcl_options">Options</string>
|
||||||
<string name="mcl_option_modmgr">Mod manager (no function)</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_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_checkupdate">Check for update</string>
|
||||||
<string name="mcl_option_customcontrol">Custom controls</string>
|
<string name="mcl_option_customcontrol">Custom controls</string>
|
||||||
<string name="mcl_option_settings">Settings</string>
|
<string name="mcl_option_settings">Settings</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user