Fixed a bug where the folder from a previously edited profile would stay in the editor even though the profile has no folders assigned
Added a JVM arguments editor
This commit is contained in:
artdeell 2022-04-17 08:52:34 +03:00
parent 6e4340f025
commit e733d1d53b
2 changed files with 37 additions and 7 deletions

View File

@ -45,6 +45,7 @@ public class ProfileEditor implements ExtraListener<ArrayList<String>> {
private final Spinner mJavaRuntimeSpinner;
private final Spinner mRendererSpinner;
private final EditText mPathSelectionEditText;
private final EditText mArgChangerEditText;
private final List<String> mRenderNames;
private final AlertDialog mDialog;
private String mSelectedVersionId;
@ -80,6 +81,7 @@ public class ProfileEditor implements ExtraListener<ArrayList<String>> {
mProfileIconImageView = mMainView.findViewById(R.id.vprof_editor_icon);
((TextView)mMainView.findViewById(R.id.vprof_editor_beginPathView)).setText(Tools.DIR_GAME_HOME+"/");
mPathSelectionEditText = mMainView.findViewById(R.id.vprof_editor_path);
mArgChangerEditText = mMainView.findViewById(R.id.vprof_editor_jre_args);
builder.setPositiveButton(R.string.global_save,this::save);
builder.setNegativeButton(android.R.string.cancel,(dialog,which)->destroy(dialog));
@ -152,9 +154,12 @@ public class ProfileEditor implements ExtraListener<ArrayList<String>> {
ArrayList<String> versions = (ArrayList<String>) ExtraCore.getValue(ExtraConstants.VERSION_LIST);
BaseLauncherActivity.updateVersionSpinner(context,versions,mVersionSpinner, mSelectedVersionId);
if(minecraftProfile.gameDir != null && minecraftProfile.gameDir.startsWith(Tools.LAUNCHERPROFILES_RTPREFIX)) {
if(minecraftProfile.gameDir != null && minecraftProfile.gameDir.startsWith(Tools.LAUNCHERPROFILES_RTPREFIX))
mPathSelectionEditText.setText(minecraftProfile.gameDir.substring(Tools.LAUNCHERPROFILES_RTPREFIX.length()));
}
else mPathSelectionEditText.setText("");
if(minecraftProfile.javaArgs != null) mArgChangerEditText.setText(minecraftProfile.javaArgs);
else mArgChangerEditText.setText("");
mDialog.show();
return true;
}
@ -189,9 +194,11 @@ public class ProfileEditor implements ExtraListener<ArrayList<String>> {
if(mRendererSpinner.getSelectedItemPosition() == mRenderNames.size()) profile.pojavRendererName = null;
else profile.pojavRendererName = mRenderNames.get(mRendererSpinner.getSelectedItemPosition());
String selectedPath = mPathSelectionEditText.getText().toString();
if(!selectedPath.isEmpty()) {
profile.gameDir = Tools.LAUNCHERPROFILES_RTPREFIX+selectedPath;
}
String arguments = mArgChangerEditText.getText().toString();
if(!selectedPath.isEmpty()) profile.gameDir = Tools.LAUNCHERPROFILES_RTPREFIX+selectedPath;
else profile.gameDir = null;
if(!arguments.isEmpty()) profile.javaArgs = arguments;
else profile.javaArgs = null;
LauncherProfiles.mainProfileJson.profiles.put(mEditingProfile,profile);
mEditSaveCallback.onSave(mEditingProfile,isNew, false);
destroy(dialog);

View File

@ -64,7 +64,7 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/vprof_editor_path" />
app:layout_constraintTop_toBottomOf="@+id/vprof_editor_jre_args" />
<TextView
android:id="@+id/textView4"
@ -119,8 +119,9 @@
android:layout_marginEnd="16dp"
android:ems="10"
android:hint=".minecraft"
android:inputType="textPersonName"
android:inputType="text"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/vprof_editior_profile_name" />
@ -131,5 +132,27 @@
app:layout_constraintBottom_toTopOf="@+id/vprof_editor_path"
app:layout_constraintStart_toStartOf="@+id/vprof_editor_path" />
<EditText
android:id="@+id/vprof_editor_jre_args"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="32dp"
android:layout_marginEnd="16dp"
android:ems="10"
android:inputType="text"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/vprof_editor_path" />
<TextView
android:id="@+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/pvc_jvmArgs"
app:layout_constraintBottom_toTopOf="@+id/vprof_editor_jre_args"
app:layout_constraintStart_toStartOf="@+id/vprof_editor_jre_args" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>