Skip to content
This repository was archived by the owner on Sep 23, 2025. It is now read-only.

Commit eb51e8d

Browse files
committed
[Renderer/MG](feat): Make settings UI functional
1 parent 403b2dc commit eb51e8d

File tree

3 files changed

+49
-19
lines changed

3 files changed

+49
-19
lines changed

app_pojavlauncher/src/main/java/com/kdt/ui/dialog/CustomDialog.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
import net.kdt.pojavlaunch.R;
2020

21+
import java.io.IOException;
22+
2123
public class CustomDialog implements DraggableDialog.DialogInitializationListener {
2224
private final AlertDialog dialog;
2325
private final String[] items;
@@ -133,7 +135,13 @@ private CustomDialog(Context context, String title, String message, String scrol
133135

134136
confirmButton.setOnClickListener(v -> {
135137
boolean shouldDismiss = true;
136-
if (confirmListener != null) shouldDismiss = confirmListener.onConfirm(customView);
138+
if (confirmListener != null) {
139+
try {
140+
shouldDismiss = confirmListener.onConfirm(customView);
141+
} catch (IOException e) {
142+
throw new RuntimeException(e);
143+
}
144+
}
137145
if (shouldDismiss) dialog.dismiss();
138146
});
139147

@@ -168,7 +176,7 @@ public interface OnButtonClickListener {
168176
}
169177

170178
public interface OnConfirmListener {
171-
boolean onConfirm(View view);
179+
boolean onConfirm(View view) throws IOException;
172180
}
173181

174182
public interface OnCancelListener {

app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/prefs/screens/LauncherPreferenceVideoFragment.java

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,37 @@
11
package net.kdt.pojavlaunch.prefs.screens;
22

3-
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_RENDERER;
43

4+
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_RENDERER;
55
import android.content.SharedPreferences;
66
import android.os.Build;
77
import android.os.Bundle;
8-
import android.net.Uri;
9-
10-
import androidx.annotation.NonNull;
11-
import androidx.annotation.Nullable;
12-
import androidx.appcompat.app.AlertDialog;
138

149
import androidx.preference.ListPreference;
1510
import androidx.preference.SwitchPreference;
1611
import androidx.preference.SwitchPreferenceCompat;
1712
import androidx.preference.Preference;
18-
import android.text.InputFilter;
13+
1914
import android.util.Log;
2015
import android.view.LayoutInflater;
2116
import android.view.View;
2217
import android.widget.ArrayAdapter;
23-
import android.widget.AdapterView;
2418
import android.widget.EditText;
2519
import android.widget.Spinner;
2620
import android.widget.Switch;
27-
import android.widget.Toast;
2821

29-
import net.kdt.pojavlaunch.PojavApplication;
3022
import net.kdt.pojavlaunch.R;
3123
import net.kdt.pojavlaunch.Tools;
3224
import net.kdt.pojavlaunch.prefs.CustomSeekBarPreference;
3325
import net.kdt.pojavlaunch.prefs.LauncherPreferences;
26+
import net.kdt.pojavlaunch.utils.FileUtils;
27+
3428
import com.kdt.ui.dialog.*;
3529

30+
import java.io.File;
31+
import java.io.IOException;
3632
import java.util.ArrayList;
37-
import java.util.List;
38-
import java.util.Set;
33+
import java.util.LinkedHashMap;
34+
import java.util.Map;
3935

4036
/**
4137
* Fragment for any settings video related
@@ -100,7 +96,7 @@ public void onSharedPreferenceChanged(SharedPreferences p, String s) {
10096
computeVisibility();
10197
}
10298

103-
private void computeVisibility(){
99+
private void computeVisibility() {
104100
requirePreference("force_vsync", SwitchPreferenceCompat.class)
105101
.setVisible(LauncherPreferences.PREF_USE_ALTERNATE_SURFACE);
106102
}
@@ -160,7 +156,7 @@ private void mgRendererSettings() {
160156
.setConfirmListener(R.string.alertdialog_done, customView -> {
161157
String cacheSize = maxGlslCacheSize.getText().toString();
162158

163-
if (cacheSize.isEmpty()) {
159+
if (cacheSize.isEmpty()) {
164160
maxGlslCacheSize.setError(getString(R.string.global_error_field_empty));
165161
return false;
166162

@@ -183,8 +179,8 @@ private void mgRendererSettings() {
183179
}
184180

185181
if (currentCacheSize <= 0 && currentCacheSize != -1) {
186-
maxGlslCacheSize.setError(getString(R.string.mg_option_glsl_cache_error_range));
187-
return false;
182+
maxGlslCacheSize.setError(getString(R.string.mg_option_glsl_cache_error_range));
183+
return false;
188184
}
189185
LauncherPreferences.MG_MULTIDRAWMODE_OPTION = Integer.toString(enableCompatibleMode.getSelectedItemPosition());
190186
LauncherPreferences.MG_GLSL_CACHE_SIZE = cacheSize;
@@ -200,11 +196,37 @@ private void mgRendererSettings() {
200196
.putString("mg_ext_gl43", LauncherPreferences.MG_EXT_GL43)
201197
.putString("mg_ext_compute_shader", LauncherPreferences.MG_EXT_CS)
202198
.apply();
199+
try {
200+
writeRendererSettings();
201+
} catch (Exception e) {
202+
throw new IOException(e);
203+
}
204+
203205
return true;
204206
})
205207
.setCancelListener(R.string.alertdialog_cancel, customView -> true)
206208
.setDraggable(true)
207209
.build()
208210
.show();
209211
}
212+
private void writeRendererSettings() throws IOException {
213+
Map<String, Integer> MGConfigMap = new LinkedHashMap<>();
214+
215+
MGConfigMap.put("enableAngle", Integer.parseInt(LauncherPreferences.MG_ANGLE_OPTION));
216+
MGConfigMap.put("enableNoError", Integer.parseInt(LauncherPreferences.MG_NOERROR_OPTION));
217+
MGConfigMap.put("enableExtGL43", Integer.parseInt(LauncherPreferences.MG_EXT_GL43));
218+
MGConfigMap.put("enableExtComputeShader", Integer.parseInt(LauncherPreferences.MG_EXT_CS));
219+
MGConfigMap.put("maxGlslCacheSize", Integer.parseInt(LauncherPreferences.MG_GLSL_CACHE_SIZE));
220+
MGConfigMap.put("multidrawMode", Integer.parseInt(LauncherPreferences.MG_MULTIDRAWMODE_OPTION));
221+
222+
File configFile = new File(Tools.DIR_DATA + "/MobileGlues", "config.json");
223+
FileUtils.ensureParentDirectory(configFile);
224+
try {
225+
Tools.write(configFile.getAbsolutePath(),Tools.GLOBAL_GSON.toJson(MGConfigMap));
226+
} catch (IOException e) {
227+
throw new RuntimeException(e);
228+
}
229+
230+
231+
}
210232
}

app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/utils/JREUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ public static void setJavaEnvironment(Activity activity, String jreHome) throws
221221
} else if(LOCAL_RENDERER.equals("opengles_mobileglues")) { // TODO: Needs refactoring
222222
envMap.put("LIBGL_ES", "3");
223223
envMap.put("POJAVEXEC_EGL","libmobileglues.so");
224-
envMap.put("MG_DIR_PATH", Tools.DIR_CACHE.getAbsolutePath());
224+
envMap.put("MG_DIR_PATH", Tools.DIR_DATA + "/MobileGlues");
225225
envMap.put("MG_maxGlslCacheSize", MG_GLSL_CACHE_SIZE);
226226
envMap.put("MG_enableANGLE", MG_ANGLE_OPTION);
227227
envMap.put("MG_enableNoError", MG_NOERROR_OPTION);

0 commit comments

Comments
 (0)