Skip to content

Commit dff44ce

Browse files
committed
Add separate folder settings for saves, states, and cheats
1 parent 7a323b8 commit dff44ce

14 files changed

+316
-236
lines changed

src/android/cpp/interface.cpp

+61-49
Original file line numberDiff line numberDiff line change
@@ -112,22 +112,10 @@ extern "C" JNIEXPORT jboolean JNICALL Java_com_hydra_noods_FileBrowser_loadSetti
112112
Setting("keyScreenSwap", &keyBinds[14], false)
113113
};
114114

115-
// Add the platform settings
115+
// Add the platform settings and load
116116
ScreenLayout::addSettings();
117117
Settings::add(platformSettings);
118-
119-
// Load the settings
120-
if (Settings::load(path + "/noods.ini"))
121-
return true;
122-
123-
// If this is the first time, set the path settings based on the root storage path
124-
Settings::bios7Path = path + "/bios7.bin";
125-
Settings::bios9Path = path + "/bios9.bin";
126-
Settings::firmwarePath = path + "/firmware.bin";
127-
Settings::gbaBiosPath = path + "/gba_bios.bin";
128-
Settings::sdImagePath = path + "/sd.img";
129-
Settings::save();
130-
return false;
118+
return Settings::load(path);
131119
}
132120

133121
extern "C" JNIEXPORT void JNICALL Java_com_hydra_noods_FileBrowser_getNdsIcon(JNIEnv *env, jobject obj, jint fd, jobject bitmap)
@@ -167,33 +155,27 @@ extern "C" JNIEXPORT jboolean JNICALL Java_com_hydra_noods_FileBrowser_isGbaLoad
167155
return gbaPath != "" || gbaRomFd != -1;
168156
}
169157

170-
extern "C" JNIEXPORT void JNICALL Java_com_hydra_noods_FileBrowser_setNdsPath(JNIEnv* env, jobject obj, jstring value)
158+
extern "C" JNIEXPORT void JNICALL Java_com_hydra_noods_FileBrowser_setNdsRom(JNIEnv* env, jobject obj, jstring romPath, jint romFd, jint saveFd, jint stateFd, jint cheatFd)
171159
{
172160
// Set the NDS ROM file path
173-
const char *str = env->GetStringUTFChars(value, nullptr);
161+
const char *str = env->GetStringUTFChars(romPath, nullptr);
174162
ndsPath = str;
175-
env->ReleaseStringUTFChars(value, str);
176-
}
177-
178-
extern "C" JNIEXPORT void JNICALL Java_com_hydra_noods_FileBrowser_setGbaPath(JNIEnv* env, jobject obj, jstring value)
179-
{
180-
// Set the GBA ROM file path
181-
const char *str = env->GetStringUTFChars(value, nullptr);
182-
gbaPath = str;
183-
env->ReleaseStringUTFChars(value, str);
184-
}
163+
env->ReleaseStringUTFChars(romPath, str);
185164

186-
extern "C" JNIEXPORT void JNICALL Java_com_hydra_noods_FileBrowser_setNdsFds(JNIEnv* env, jobject obj, jint romFd, jint saveFd, jint stateFd, jint cheatFd)
187-
{
188165
// Set the NDS ROM file descriptors
189166
ndsRomFd = romFd;
190167
ndsSaveFd = saveFd;
191168
ndsStateFd = stateFd;
192169
ndsCheatFd = cheatFd;
193170
}
194171

195-
extern "C" JNIEXPORT void JNICALL Java_com_hydra_noods_FileBrowser_setGbaFds(JNIEnv* env, jobject obj, jint romFd, jint saveFd, jint stateFd)
172+
extern "C" JNIEXPORT void JNICALL Java_com_hydra_noods_FileBrowser_setGbaRom(JNIEnv* env, jobject obj, jstring romPath, jint romFd, jint saveFd, jint stateFd)
196173
{
174+
// Set the GBA ROM file path
175+
const char *str = env->GetStringUTFChars(romPath, nullptr);
176+
gbaPath = str;
177+
env->ReleaseStringUTFChars(romPath, str);
178+
197179
// Set the GBA ROM file descriptors
198180
gbaRomFd = romFd;
199181
gbaSaveFd = saveFd;
@@ -352,6 +334,31 @@ extern "C" JNIEXPORT jint JNICALL Java_com_hydra_noods_SettingsMenu_getHighRes3D
352334
return Settings::highRes3D;
353335
}
354336

337+
extern "C" JNIEXPORT jint JNICALL Java_com_hydra_noods_SettingsMenu_getMicEnable(JNIEnv* env, jobject obj)
338+
{
339+
return micEnable;
340+
}
341+
342+
extern "C" JNIEXPORT jint JNICALL Java_com_hydra_noods_SettingsMenu_getShowFpsCounter(JNIEnv* env, jobject obj)
343+
{
344+
return showFpsCounter;
345+
}
346+
347+
extern "C" JNIEXPORT jint JNICALL Java_com_hydra_noods_SettingsMenu_getSavesFolder(JNIEnv* env, jobject obj)
348+
{
349+
return Settings::savesFolder;
350+
}
351+
352+
extern "C" JNIEXPORT jint JNICALL Java_com_hydra_noods_SettingsMenu_getStatesFolder(JNIEnv* env, jobject obj)
353+
{
354+
return Settings::statesFolder;
355+
}
356+
357+
extern "C" JNIEXPORT jint JNICALL Java_com_hydra_noods_SettingsMenu_getCheatsFolder(JNIEnv* env, jobject obj)
358+
{
359+
return Settings::cheatsFolder;
360+
}
361+
355362
extern "C" JNIEXPORT jint JNICALL Java_com_hydra_noods_SettingsMenu_getScreenPosition(JNIEnv* env, jobject obj)
356363
{
357364
return ScreenLayout::screenPosition;
@@ -397,16 +404,6 @@ extern "C" JNIEXPORT jint JNICALL Java_com_hydra_noods_SettingsMenu_getScreenGho
397404
return Settings::screenGhost;
398405
}
399406

400-
extern "C" JNIEXPORT jint JNICALL Java_com_hydra_noods_SettingsMenu_getMicEnable(JNIEnv* env, jobject obj)
401-
{
402-
return micEnable;
403-
}
404-
405-
extern "C" JNIEXPORT jint JNICALL Java_com_hydra_noods_SettingsMenu_getShowFpsCounter(JNIEnv* env, jobject obj)
406-
{
407-
return showFpsCounter;
408-
}
409-
410407
extern "C" JNIEXPORT jint JNICALL Java_com_hydra_noods_SettingsMenu_getButtonScale(JNIEnv* env, jobject obj)
411408
{
412409
return buttonScale;
@@ -447,6 +444,31 @@ extern "C" JNIEXPORT void JNICALL Java_com_hydra_noods_SettingsMenu_setHighRes3D
447444
Settings::highRes3D = value;
448445
}
449446

447+
extern "C" JNIEXPORT void JNICALL Java_com_hydra_noods_SettingsMenu_setMicEnable(JNIEnv* env, jobject obj, jint value)
448+
{
449+
micEnable = value;
450+
}
451+
452+
extern "C" JNIEXPORT void JNICALL Java_com_hydra_noods_SettingsMenu_setShowFpsCounter(JNIEnv* env, jobject obj, jint value)
453+
{
454+
showFpsCounter = value;
455+
}
456+
457+
extern "C" JNIEXPORT void JNICALL Java_com_hydra_noods_SettingsMenu_setSavesFolder(JNIEnv* env, jobject obj, jint value)
458+
{
459+
Settings::savesFolder = value;
460+
}
461+
462+
extern "C" JNIEXPORT void JNICALL Java_com_hydra_noods_SettingsMenu_setStatesFolder(JNIEnv* env, jobject obj, jint value)
463+
{
464+
Settings::statesFolder = value;
465+
}
466+
467+
extern "C" JNIEXPORT void JNICALL Java_com_hydra_noods_SettingsMenu_setCheatsFolder(JNIEnv* env, jobject obj, jint value)
468+
{
469+
Settings::cheatsFolder = value;
470+
}
471+
450472
extern "C" JNIEXPORT void JNICALL Java_com_hydra_noods_SettingsMenu_setScreenPosition(JNIEnv* env, jobject obj, jint value)
451473
{
452474
ScreenLayout::screenPosition = value;
@@ -492,16 +514,6 @@ extern "C" JNIEXPORT void JNICALL Java_com_hydra_noods_SettingsMenu_setScreenGho
492514
Settings::screenGhost = value;
493515
}
494516

495-
extern "C" JNIEXPORT void JNICALL Java_com_hydra_noods_SettingsMenu_setMicEnable(JNIEnv* env, jobject obj, jint value)
496-
{
497-
micEnable = value;
498-
}
499-
500-
extern "C" JNIEXPORT void JNICALL Java_com_hydra_noods_SettingsMenu_setShowFpsCounter(JNIEnv* env, jobject obj, jint value)
501-
{
502-
showFpsCounter = value;
503-
}
504-
505517
extern "C" JNIEXPORT void JNICALL Java_com_hydra_noods_SettingsMenu_setButtonScale(JNIEnv* env, jobject obj, jint value)
506518
{
507519
buttonScale = value;

src/android/java/com/hydra/noods/FileBrowser.java

+14-20
Original file line numberDiff line numberDiff line change
@@ -415,10 +415,8 @@ private void update()
415415
// If a ROM of the other type is already loaded, ask if it should be loaded alongside the new ROM
416416
if (ext.equals(".nds"))
417417
{
418-
if (scoped)
419-
setNdsFds(getRomFd(file.getUri()), getSaveFd(file), getStateFd(file), getCheatFd(file));
420-
else
421-
setNdsPath(file.getUri().getPath());
418+
Uri uri = file.getUri();
419+
setNdsRom(uri.getPath(), getRomFd(uri), getSaveFd(file), getStateFd(file), getCheatFd(file));
422420

423421
if (isGbaLoaded())
424422
{
@@ -440,8 +438,7 @@ public void onClick(DialogInterface dialog, int id)
440438
@Override
441439
public void onClick(DialogInterface dialog, int id)
442440
{
443-
setGbaPath("");
444-
setGbaFds(-1, -1, -1);
441+
setGbaRom("", -1, -1, -1);
445442
tryStartCore();
446443
}
447444
});
@@ -451,8 +448,7 @@ public void onClick(DialogInterface dialog, int id)
451448
@Override
452449
public void onCancel(DialogInterface dialog)
453450
{
454-
setGbaPath("");
455-
setGbaFds(-1, -1, -1);
451+
setGbaRom("", -1, -1, -1);
456452
tryStartCore();
457453
}
458454
});
@@ -463,10 +459,8 @@ public void onCancel(DialogInterface dialog)
463459
}
464460
else
465461
{
466-
if (scoped)
467-
setGbaFds(getRomFd(file.getUri()), getSaveFd(file), getStateFd(file));
468-
else
469-
setGbaPath(file.getUri().getPath());
462+
Uri uri = file.getUri();
463+
setGbaRom(uri.getPath(), getRomFd(uri), getSaveFd(file), getStateFd(file));
470464

471465
if (isNdsLoaded())
472466
{
@@ -488,8 +482,7 @@ public void onClick(DialogInterface dialog, int id)
488482
@Override
489483
public void onClick(DialogInterface dialog, int id)
490484
{
491-
setNdsPath("");
492-
setNdsFds(-1, -1, -1, -1);
485+
setNdsRom("", -1, -1, -1, -1);
493486
tryStartCore();
494487
}
495488
});
@@ -499,8 +492,7 @@ public void onClick(DialogInterface dialog, int id)
499492
@Override
500493
public void onCancel(DialogInterface dialog)
501494
{
502-
setNdsPath("");
503-
setNdsFds(-1, -1, -1, -1);
495+
setNdsRom("", -1, -1, -1, -1);
504496
tryStartCore();
505497
}
506498
});
@@ -593,6 +585,7 @@ private int getRomFd(Uri romUri)
593585
try
594586
{
595587
// Get a descriptor for the file in scoped mode
588+
if (!scoped) return -1;
596589
return getContentResolver().openFileDescriptor(romUri, "r").detachFd();
597590
}
598591
catch (Exception e)
@@ -611,6 +604,7 @@ private int getSaveFd(DocumentFile rom)
611604
try
612605
{
613606
// Get a descriptor for the file in scoped mode
607+
if (!scoped || SettingsMenu.getSavesFolder() == 1) return -1;
614608
return getContentResolver().openFileDescriptor(uri, "rw").detachFd();
615609
}
616610
catch (Exception e)
@@ -645,6 +639,7 @@ private int getStateFd(DocumentFile rom)
645639
try
646640
{
647641
// Get a descriptor for the file in scoped mode
642+
if (!scoped || SettingsMenu.getStatesFolder() == 1) return -1;
648643
return getContentResolver().openFileDescriptor(uri, "rw").detachFd();
649644
}
650645
catch (Exception e)
@@ -666,6 +661,7 @@ private int getCheatFd(DocumentFile rom)
666661
try
667662
{
668663
// Get a descriptor for the file in scoped mode
664+
if (!scoped || SettingsMenu.getCheatsFolder() == 1) return -1;
669665
return getContentResolver().openFileDescriptor(uri, "rw").detachFd();
670666
}
671667
catch (Exception e)
@@ -683,8 +679,6 @@ private int getCheatFd(DocumentFile rom)
683679
public static native int startCore();
684680
public static native boolean isNdsLoaded();
685681
public static native boolean isGbaLoaded();
686-
public static native void setNdsPath(String value);
687-
public static native void setGbaPath(String value);
688-
public static native void setNdsFds(int romFd, int saveFd, int stateFd, int cheatFd);
689-
public static native void setGbaFds(int romFd, int saveFd, int stateFd);
682+
public static native void setNdsRom(String romPath, int romFd, int saveFd, int stateFd, int cheatFd);
683+
public static native void setGbaRom(String romPath, int romFd, int saveFd, int stateFd);
690684
}

src/android/java/com/hydra/noods/SettingsMenu.java

+21-9
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ protected void onCreate(Bundle savedInstanceState)
8787
editor.putBoolean("threaded_2d", (getThreaded2D() == 0) ? false : true);
8888
editor.putString("threaded_3d", Integer.toString(getThreaded3D()));
8989
editor.putBoolean("high_res_3d", (getHighRes3D() == 0) ? false : true);
90+
editor.putBoolean("mic_enable", (getMicEnable() == 0) ? false : true);
91+
editor.putBoolean("show_fps_counter", (getShowFpsCounter() == 0) ? false : true);
92+
editor.putBoolean("saves_folder", (getSavesFolder() == 0) ? false : true);
93+
editor.putBoolean("states_folder", (getStatesFolder() == 0) ? false : true);
94+
editor.putBoolean("cheats_folder", (getCheatsFolder() == 0) ? false : true);
9095
editor.putString("screen_position", Integer.toString(getScreenPosition()));
9196
editor.putString("screen_rotation", Integer.toString(getScreenRotation()));
9297
editor.putString("screen_arrangement", Integer.toString(getScreenArrangement()));
@@ -96,8 +101,6 @@ protected void onCreate(Bundle savedInstanceState)
96101
editor.putBoolean("integer_scale", (getIntegerScale() == 0) ? false : true);
97102
editor.putBoolean("gba_crop", (getGbaCrop() == 0) ? false : true);
98103
editor.putBoolean("screen_ghost", (getScreenGhost() == 0) ? false : true);
99-
editor.putBoolean("mic_enable", (getMicEnable() == 0) ? false : true);
100-
editor.putBoolean("show_fps_counter", (getShowFpsCounter() == 0) ? false : true);
101104
editor.putInt("button_scale", getButtonScale());
102105
editor.putInt("button_spacing", getButtonSpacing());
103106
editor.putInt("vibrate_strength", getVibrateStrength());
@@ -138,7 +141,12 @@ public void onBackPressed()
138141
setFpsLimiter(Integer.parseInt(prefs.getString("fps_limiter", "1")));
139142
setThreaded2D(prefs.getBoolean("threaded_2d", true) ? 1 : 0);
140143
setThreaded3D(Integer.parseInt(prefs.getString("threaded_3d", "1")));
141-
setHighRes3D(prefs.getBoolean("high_res_3d", true) ? 1 : 0);
144+
setHighRes3D(prefs.getBoolean("high_res_3d", false) ? 1 : 0);
145+
setMicEnable(prefs.getBoolean("mic_enable", false) ? 1 : 0);
146+
setShowFpsCounter(prefs.getBoolean("show_fps_counter", false) ? 1 : 0);
147+
setSavesFolder(prefs.getBoolean("saves_folder", false) ? 1 : 0);
148+
setStatesFolder(prefs.getBoolean("states_folder", true) ? 1 : 0);
149+
setCheatsFolder(prefs.getBoolean("cheats_folder", true) ? 1 : 0);
142150
setScreenPosition(Integer.parseInt(prefs.getString("screen_position", "0")));
143151
setScreenRotation(Integer.parseInt(prefs.getString("screen_rotation", "0")));
144152
setScreenArrangement(Integer.parseInt(prefs.getString("screen_arrangement", "0")));
@@ -148,8 +156,6 @@ public void onBackPressed()
148156
setIntegerScale(prefs.getBoolean("integer_scale", false) ? 1 : 0);
149157
setGbaCrop(prefs.getBoolean("gba_crop", true) ? 1 : 0);
150158
setScreenGhost(prefs.getBoolean("screen_ghost", false) ? 1 : 0);
151-
setMicEnable(prefs.getBoolean("mic_enable", false) ? 1 : 0);
152-
setShowFpsCounter(prefs.getBoolean("show_fps_counter", false) ? 1 : 0);
153159
setButtonScale(prefs.getInt("button_scale", 5));
154160
setButtonSpacing(prefs.getInt("button_spacing", 10));
155161
setVibrateStrength(prefs.getInt("vibrate_strength", 1));
@@ -164,6 +170,11 @@ public void onBackPressed()
164170
public static native int getThreaded2D();
165171
public static native int getThreaded3D();
166172
public static native int getHighRes3D();
173+
public static native int getMicEnable();
174+
public static native int getShowFpsCounter();
175+
public static native int getSavesFolder();
176+
public static native int getStatesFolder();
177+
public static native int getCheatsFolder();
167178
public static native int getScreenPosition();
168179
public static native int getScreenRotation();
169180
public static native int getScreenArrangement();
@@ -173,8 +184,6 @@ public void onBackPressed()
173184
public static native int getIntegerScale();
174185
public static native int getGbaCrop();
175186
public static native int getScreenGhost();
176-
public static native int getMicEnable();
177-
public static native int getShowFpsCounter();
178187
public static native int getButtonScale();
179188
public static native int getButtonSpacing();
180189
public static native int getVibrateStrength();
@@ -183,6 +192,11 @@ public void onBackPressed()
183192
public static native void setThreaded2D(int value);
184193
public static native void setThreaded3D(int value);
185194
public static native void setHighRes3D(int value);
195+
public static native void setMicEnable(int value);
196+
public static native void setShowFpsCounter(int value);
197+
public static native void setSavesFolder(int value);
198+
public static native void setStatesFolder(int value);
199+
public static native void setCheatsFolder(int value);
186200
public static native void setScreenPosition(int value);
187201
public static native void setScreenRotation(int value);
188202
public static native void setScreenArrangement(int value);
@@ -192,8 +206,6 @@ public void onBackPressed()
192206
public static native void setIntegerScale(int value);
193207
public static native void setGbaCrop(int value);
194208
public static native void setScreenGhost(int value);
195-
public static native void setMicEnable(int value);
196-
public static native void setShowFpsCounter(int value);
197209
public static native void setButtonScale(int value);
198210
public static native void setButtonSpacing(int value);
199211
public static native void setVibrateStrength(int value);

0 commit comments

Comments
 (0)