mirror of
https://github.com/2009scape/2009Scape-mobile.git
synced 2025-12-21 09:01:56 -07:00
Make the profile settings from the previous commit user-editable
This commit is contained in:
parent
ac40da2c4e
commit
015e27daa0
4 changed files with 91 additions and 3 deletions
|
|
@ -103,6 +103,7 @@ public class BaseMainActivity extends BaseActivity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(prof.__P_renderer_name != null) {
|
if(prof.__P_renderer_name != null) {
|
||||||
|
Log.i("RdrDebug","__P_renderer="+prof.__P_renderer_name);
|
||||||
Tools.LOCAL_RENDERER = prof.__P_renderer_name;
|
Tools.LOCAL_RENDERER = prof.__P_renderer_name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import android.content.DialogInterface;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
@ -17,12 +18,18 @@ import androidx.annotation.Nullable;
|
||||||
import net.kdt.pojavlaunch.BaseLauncherActivity;
|
import net.kdt.pojavlaunch.BaseLauncherActivity;
|
||||||
import net.kdt.pojavlaunch.PojavLauncherActivity;
|
import net.kdt.pojavlaunch.PojavLauncherActivity;
|
||||||
import net.kdt.pojavlaunch.R;
|
import net.kdt.pojavlaunch.R;
|
||||||
|
import net.kdt.pojavlaunch.Tools;
|
||||||
import net.kdt.pojavlaunch.extra.ExtraCore;
|
import net.kdt.pojavlaunch.extra.ExtraCore;
|
||||||
import net.kdt.pojavlaunch.extra.ExtraListener;
|
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.LauncherProfiles;
|
||||||
import net.kdt.pojavlaunch.value.launcherprofiles.MinecraftProfile;
|
import net.kdt.pojavlaunch.value.launcherprofiles.MinecraftProfile;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
|
@ -31,6 +38,10 @@ public class ProfileEditor implements ExtraListener<ArrayList<String>> {
|
||||||
TextView profileNameView;
|
TextView profileNameView;
|
||||||
ImageView profileIconView;
|
ImageView profileIconView;
|
||||||
Spinner versionSpinner;
|
Spinner versionSpinner;
|
||||||
|
Spinner javaRuntimeSpinner;
|
||||||
|
Spinner rendererSpinner;
|
||||||
|
List<MultiRTUtils.Runtime> runtimes;
|
||||||
|
List<String> renderNames;
|
||||||
AlertDialog dialog;
|
AlertDialog dialog;
|
||||||
Context context;
|
Context context;
|
||||||
String selectedVersionId;
|
String selectedVersionId;
|
||||||
|
|
@ -51,6 +62,15 @@ public class ProfileEditor implements ExtraListener<ArrayList<String>> {
|
||||||
bldr.setView(mainView);
|
bldr.setView(mainView);
|
||||||
profileNameView = mainView.findViewById(R.id.vprof_editior_profile_name);
|
profileNameView = mainView.findViewById(R.id.vprof_editior_profile_name);
|
||||||
versionSpinner = mainView.findViewById(R.id.vprof_editor_version_spinner);
|
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);
|
profileIconView = mainView.findViewById(R.id.vprof_editor_icon);
|
||||||
bldr.setPositiveButton(R.string.global_save,this::save);
|
bldr.setPositiveButton(R.string.global_save,this::save);
|
||||||
bldr.setNegativeButton(android.R.string.cancel,(dialog,which)->destroy(dialog));
|
bldr.setNegativeButton(android.R.string.cancel,(dialog,which)->destroy(dialog));
|
||||||
|
|
@ -75,7 +95,21 @@ public class ProfileEditor implements ExtraListener<ArrayList<String>> {
|
||||||
}
|
}
|
||||||
editingProfile = uuid;
|
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);
|
ExtraCore.addExtraListener("lac_version_list",this);
|
||||||
profileNameView.setText(prof.name);
|
profileNameView.setText(prof.name);
|
||||||
if(ProfileAdapter.iconCache.containsKey(profile)) {
|
if(ProfileAdapter.iconCache.containsKey(profile)) {
|
||||||
|
|
@ -126,6 +160,16 @@ public class ProfileEditor implements ExtraListener<ArrayList<String>> {
|
||||||
}
|
}
|
||||||
prof.name = profileNameView.getText().toString();
|
prof.name = profileNameView.getText().toString();
|
||||||
prof.lastVersionId = (String)versionSpinner.getSelectedItem();
|
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);
|
LauncherProfiles.mainProfileJson.profiles.put(editingProfile,prof);
|
||||||
cb.onSave(editingProfile,isNew, false);
|
cb.onSave(editingProfile,isNew, false);
|
||||||
destroy(dialog);
|
destroy(dialog);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?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"
|
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"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
@ -57,6 +60,7 @@
|
||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="16dp"
|
||||||
android:layout_marginTop="32dp"
|
android:layout_marginTop="32dp"
|
||||||
android:layout_marginEnd="16dp"
|
android:layout_marginEnd="16dp"
|
||||||
|
android:minHeight="48dp"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/vprof_editior_profile_name" />
|
app:layout_constraintTop_toBottomOf="@+id/vprof_editior_profile_name" />
|
||||||
|
|
@ -69,4 +73,41 @@
|
||||||
app:layout_constraintBottom_toTopOf="@+id/vprof_editor_version_spinner"
|
app:layout_constraintBottom_toTopOf="@+id/vprof_editor_version_spinner"
|
||||||
app:layout_constraintStart_toStartOf="@+id/vprof_editor_version_spinner" />
|
app:layout_constraintStart_toStartOf="@+id/vprof_editor_version_spinner" />
|
||||||
|
|
||||||
|
<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>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
</ScrollView>
|
||||||
|
|
@ -294,4 +294,6 @@
|
||||||
<string name="vbo_hack_title">Disable VBOs</string>
|
<string name="vbo_hack_title">Disable VBOs</string>
|
||||||
<string name="vbo_hack_description">Help with compatibility on some old versions</string>
|
<string name="vbo_hack_description">Help with compatibility on some old versions</string>
|
||||||
<string name="global_delete">Delete</string>
|
<string name="global_delete">Delete</string>
|
||||||
|
<string name="pedit_java_runtime">Java Runtime</string>
|
||||||
|
<string name="pedit_renderer">Renderer</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue