Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

Commit

Permalink
Make the profile settings from the previous commit user-editable
Browse files Browse the repository at this point in the history
  • Loading branch information
artdeell committed Jan 10, 2022
1 parent ac40da2 commit 015e27d
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ protected void initLayout(int resId) {
}
}
if(prof.__P_renderer_name != null) {
Log.i("RdrDebug","__P_renderer="+prof.__P_renderer_name);
Tools.LOCAL_RENDERER = prof.__P_renderer_name;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.Spinner;
import android.widget.TextView;
Expand All @@ -17,12 +18,18 @@
import net.kdt.pojavlaunch.BaseLauncherActivity;
import net.kdt.pojavlaunch.PojavLauncherActivity;
import net.kdt.pojavlaunch.R;
import net.kdt.pojavlaunch.Tools;
import net.kdt.pojavlaunch.extra.ExtraCore;
import net.kdt.pojavlaunch.extra.ExtraListener;
import net.kdt.pojavlaunch.multirt.MultiRTUtils;
import net.kdt.pojavlaunch.multirt.RTSpinnerAdapter;
import net.kdt.pojavlaunch.value.launcherprofiles.LauncherProfiles;
import net.kdt.pojavlaunch.value.launcherprofiles.MinecraftProfile;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.UUID;

Expand All @@ -31,6 +38,10 @@ public class ProfileEditor implements ExtraListener<ArrayList<String>> {
TextView profileNameView;
ImageView profileIconView;
Spinner versionSpinner;
Spinner javaRuntimeSpinner;
Spinner rendererSpinner;
List<MultiRTUtils.Runtime> runtimes;
List<String> renderNames;
AlertDialog dialog;
Context context;
String selectedVersionId;
Expand All @@ -51,6 +62,15 @@ public ProfileEditor(Context _ctx, EditSaveCallback cb) {
bldr.setView(mainView);
profileNameView = mainView.findViewById(R.id.vprof_editior_profile_name);
versionSpinner = mainView.findViewById(R.id.vprof_editor_version_spinner);
javaRuntimeSpinner = mainView.findViewById(R.id.vprof_editor_spinner_runtime);
rendererSpinner = mainView.findViewById(R.id.vprof_editor_profile_renderer);
{
List<String> renderList = new ArrayList<>();
Collections.addAll(renderList, context.getResources().getStringArray(R.array.renderer));
renderList.add("Default");
renderNames = Arrays.asList(context.getResources().getStringArray(R.array.renderer_values));
rendererSpinner.setAdapter(new ArrayAdapter<>(context, android.R.layout.simple_spinner_dropdown_item,renderList));
}
profileIconView = mainView.findViewById(R.id.vprof_editor_icon);
bldr.setPositiveButton(R.string.global_save,this::save);
bldr.setNegativeButton(android.R.string.cancel,(dialog,which)->destroy(dialog));
Expand All @@ -75,7 +95,21 @@ public boolean show(@NonNull String profile) {
}
editingProfile = uuid;
}

runtimes = MultiRTUtils.getRuntimes();
javaRuntimeSpinner.setAdapter(new RTSpinnerAdapter(context, runtimes));
int jvm_index = runtimes.indexOf(new MultiRTUtils.Runtime("<Default>"));
int rnd_index = rendererSpinner.getAdapter().getCount()-1;
if (prof.javaDir != null) {
String selectedRuntime = prof.javaDir.substring(Tools.LAUNCHERPROFILES_RTPREFIX.length());
int nindex = runtimes.indexOf(new MultiRTUtils.Runtime(selectedRuntime));
if (nindex != -1) jvm_index = nindex;
}
if(prof.__P_renderer_name != null) {
int nindex = renderNames.indexOf(prof.__P_renderer_name);
if(nindex != -1) rnd_index = nindex;
}
javaRuntimeSpinner.setSelection(jvm_index);
rendererSpinner.setSelection(rnd_index);
ExtraCore.addExtraListener("lac_version_list",this);
profileNameView.setText(prof.name);
if(ProfileAdapter.iconCache.containsKey(profile)) {
Expand Down Expand Up @@ -126,6 +160,16 @@ public void save(DialogInterface dialog, int which) {
}
prof.name = profileNameView.getText().toString();
prof.lastVersionId = (String)versionSpinner.getSelectedItem();
MultiRTUtils.Runtime selectedRuntime = (MultiRTUtils.Runtime) javaRuntimeSpinner.getSelectedItem();
if(selectedRuntime.name.equals("<Default>")) {
prof.javaDir = null;
}else if(selectedRuntime.versionString == null) {
prof.javaDir = null;
}else{
prof.javaDir = Tools.LAUNCHERPROFILES_RTPREFIX+selectedRuntime.name;
}
if(rendererSpinner.getSelectedItemPosition() == renderNames.size()) prof.__P_renderer_name = null;
else prof.__P_renderer_name = renderNames.get(rendererSpinner.getSelectedItemPosition());
LauncherProfiles.mainProfileJson.profiles.put(editingProfile,prof);
cb.onSave(editingProfile,isNew, false);
destroy(dialog);
Expand Down
45 changes: 43 additions & 2 deletions app_pojavlauncher/src/main/res/layout/version_profile_editor.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
Expand Down Expand Up @@ -57,6 +60,7 @@
android:layout_marginStart="16dp"
android:layout_marginTop="32dp"
android:layout_marginEnd="16dp"
android:minHeight="48dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/vprof_editior_profile_name" />
Expand All @@ -69,4 +73,41 @@
app:layout_constraintBottom_toTopOf="@+id/vprof_editor_version_spinner"
app:layout_constraintStart_toStartOf="@+id/vprof_editor_version_spinner" />

</androidx.constraintlayout.widget.ConstraintLayout>
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/pedit_java_runtime"
app:layout_constraintBottom_toTopOf="@+id/vprof_editor_spinner_runtime"
app:layout_constraintStart_toStartOf="@+id/vprof_editor_spinner_runtime" />

<Spinner
android:id="@+id/vprof_editor_spinner_runtime"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:minHeight="48dp"
app:layout_constraintEnd_toEndOf="@+id/vprof_editor_version_spinner"
app:layout_constraintStart_toStartOf="@+id/vprof_editor_version_spinner"
app:layout_constraintTop_toBottomOf="@+id/vprof_editor_version_spinner" />

<Spinner
android:id="@+id/vprof_editor_profile_renderer"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:minHeight="48dp"
app:layout_constraintEnd_toEndOf="@+id/vprof_editor_spinner_runtime"
app:layout_constraintStart_toStartOf="@+id/vprof_editor_spinner_runtime"
app:layout_constraintTop_toBottomOf="@+id/vprof_editor_spinner_runtime" />

<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
app:layout_constraintBottom_toTopOf="@+id/vprof_editor_profile_renderer"
app:layout_constraintStart_toStartOf="@+id/vprof_editor_profile_renderer" />

</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
2 changes: 2 additions & 0 deletions app_pojavlauncher/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -294,4 +294,6 @@
<string name="vbo_hack_title">Disable VBOs</string>
<string name="vbo_hack_description">Help with compatibility on some old versions</string>
<string name="global_delete">Delete</string>
<string name="pedit_java_runtime">Java Runtime</string>
<string name="pedit_renderer">Renderer</string>
</resources>

0 comments on commit 015e27d

Please sign in to comment.