Skip to content

Commit e75e5f1

Browse files
committed
[Settings/MG]: Small fixes for the settings UI
Refactors to long and adds a limit to maxGlslCacheSize so java is happy with people putting absurdly large numbers on it.
1 parent eb51e8d commit e75e5f1

File tree

5 files changed

+29
-35
lines changed

5 files changed

+29
-35
lines changed

app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/PojavApplication.java

+1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ public void onCreate() {
7676
.concat("/x86");
7777
}
7878
AsyncAssetManager.unpackRuntime(getAssets());
79+
LauncherPreferences.writeMGRendererSettings();
7980
} catch (Throwable throwable) {
8081
Intent ferrorIntent = new Intent(this, FatalErrorActivity.class);
8182
ferrorIntent.putExtra("throwable", throwable);

app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/prefs/LauncherPreferences.java

+20
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,13 @@
1515

1616
import net.kdt.pojavlaunch.*;
1717
import net.kdt.pojavlaunch.multirt.MultiRTUtils;
18+
import net.kdt.pojavlaunch.utils.FileUtils;
1819
import net.kdt.pojavlaunch.utils.JREUtils;
1920

21+
import java.io.File;
2022
import java.io.IOException;
23+
import java.util.LinkedHashMap;
24+
import java.util.Map;
2125

2226
public class LauncherPreferences {
2327
public static final String PREF_KEY_CURRENT_PROFILE = "currentProfile";
@@ -232,4 +236,20 @@ public static void computeNotchSize(Activity activity) {
232236
}
233237
Tools.updateWindowSize(activity);
234238
}
239+
public static void writeMGRendererSettings() throws IOException {
240+
Map<String, Object> MGConfigMap = new LinkedHashMap<>();
241+
MGConfigMap.put("enableAngle", Integer.parseInt(MG_ANGLE_OPTION));
242+
MGConfigMap.put("enableNoError", Integer.parseInt(MG_NOERROR_OPTION));
243+
MGConfigMap.put("enableExtGL43", Integer.parseInt(MG_EXT_GL43));
244+
MGConfigMap.put("enableExtComputeShader", Integer.parseInt(MG_EXT_CS));
245+
MGConfigMap.put("maxGlslCacheSize", Long.parseLong(MG_GLSL_CACHE_SIZE));
246+
MGConfigMap.put("multidrawMode", Integer.parseInt(MG_MULTIDRAWMODE_OPTION));
247+
File configFile = new File(Tools.DIR_DATA + "/MobileGlues", "config.json");
248+
FileUtils.ensureParentDirectory(configFile);
249+
try {
250+
Tools.write(configFile.getAbsolutePath(),Tools.GLOBAL_GSON.toJson(MGConfigMap));
251+
} catch (IOException e) {
252+
throw new RuntimeException(e);
253+
}
254+
}
235255
}

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

+6-35
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,17 @@
1818
import android.widget.EditText;
1919
import android.widget.Spinner;
2020
import android.widget.Switch;
21+
import android.widget.Toast;
2122

2223
import net.kdt.pojavlaunch.R;
2324
import net.kdt.pojavlaunch.Tools;
2425
import net.kdt.pojavlaunch.prefs.CustomSeekBarPreference;
2526
import net.kdt.pojavlaunch.prefs.LauncherPreferences;
26-
import net.kdt.pojavlaunch.utils.FileUtils;
2727

2828
import com.kdt.ui.dialog.*;
2929

30-
import java.io.File;
3130
import java.io.IOException;
3231
import java.util.ArrayList;
33-
import java.util.LinkedHashMap;
34-
import java.util.Map;
3532

3633
/**
3734
* Fragment for any settings video related
@@ -162,19 +159,13 @@ private void mgRendererSettings() {
162159

163160
}
164161

165-
int currentCacheSize;
162+
long currentCacheSize;
166163
try {
167-
currentCacheSize = Integer.parseInt(cacheSize);
164+
currentCacheSize = Long.parseLong(cacheSize);
168165
} catch (NumberFormatException e) {
169166
Log.e("MG maxGlslCacheSize", e.toString());
170-
171-
// maxGlslCacheSize.setError(e.toString());
172-
maxGlslCacheSize.setError(getString(R.string.mg_option_glsl_cache_error_unexpected));
173-
return false;
174-
}
175-
176-
if (currentCacheSize > 99999) {
177-
maxGlslCacheSize.setError(getString(R.string.mg_option_glsl_cache_error_invalid));
167+
Toast.makeText(getContext(),getString(R.string.mg_option_glsl_cache_error_too_big),Toast.LENGTH_SHORT).show();
168+
maxGlslCacheSize.setText(Long.toString(Long.MAX_VALUE));
178169
return false;
179170
}
180171

@@ -197,7 +188,7 @@ private void mgRendererSettings() {
197188
.putString("mg_ext_compute_shader", LauncherPreferences.MG_EXT_CS)
198189
.apply();
199190
try {
200-
writeRendererSettings();
191+
LauncherPreferences.writeMGRendererSettings();
201192
} catch (Exception e) {
202193
throw new IOException(e);
203194
}
@@ -209,24 +200,4 @@ private void mgRendererSettings() {
209200
.build()
210201
.show();
211202
}
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-
}
232203
}

app_pojavlauncher/src/main/res/layout/dialog_mgrenderer_settings.xml

+1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
android:id="@+id/mg_switch_ext_cs"
9292
android:layout_width="match_parent"
9393
android:layout_height="wrap_content"
94+
android:layout_marginBottom="32dp"
9495
android:text="@string/mg_option_ext_cs"
9596
app:layout_constraintBottom_toBottomOf="parent" />
9697

app_pojavlauncher/src/main/res/values/strings.xml

+1
Original file line numberDiff line numberDiff line change
@@ -465,4 +465,5 @@
465465
<string name="mg_option_multidraw_mode_drawelements">Forcing DrawElements</string>
466466
<string name="mg_option_ext_gl43">Enable incomplete OpenGL43 extension</string>
467467
<string name="mg_option_ext_cs">Enable incomplete ARB_compute_shader extension</string>
468+
<string name="mg_option_glsl_cache_error_too_big">Error: Value too big. Setting to maximum possible value.</string>
468469
</resources>

0 commit comments

Comments
 (0)