Shorten the procedure to edit config, Handle config issues
This commit is contained in:
parent
04addad42d
commit
436fd57609
|
@ -92,7 +92,7 @@
|
|||
<string name="textOff">OFF</string>
|
||||
|
||||
<string name="platform">Copying logcat content to clipboard\nPlease paste in the issue report</string>
|
||||
|
||||
<string name="bios_config">Please generate a config\n(Run BIOS at least once)</string>
|
||||
<string name="menu_debug">Submit Error Logs</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -169,10 +169,8 @@ public class ConfigureFragment extends Fragment {
|
|||
boolean isChecked) {
|
||||
mPrefs.edit().putBoolean("dynarec_opt", isChecked).commit();
|
||||
dynarecopt = isChecked;
|
||||
if (!executeAppendConfig("Dynarec.Enabled",
|
||||
String.valueOf(isChecked ? 1 : 0))) {
|
||||
executeWriteConfig();
|
||||
}
|
||||
executeAppendConfig("Dynarec.Enabled",
|
||||
String.valueOf(isChecked ? 1 : 0));
|
||||
}
|
||||
};
|
||||
Switch dynarec_opt = (Switch) getView().findViewById(
|
||||
|
@ -191,10 +189,8 @@ public class ConfigureFragment extends Fragment {
|
|||
boolean isChecked) {
|
||||
mPrefs.edit().putBoolean("unstable_opt", isChecked).commit();
|
||||
unstableopt = isChecked;
|
||||
if (!executeAppendConfig("Dynarec.unstable-opt",
|
||||
String.valueOf(isChecked ? 1 : 0))) {
|
||||
executeWriteConfig();
|
||||
}
|
||||
executeAppendConfig("Dynarec.unstable-opt",
|
||||
String.valueOf(isChecked ? 1 : 0));
|
||||
}
|
||||
};
|
||||
Switch unstable_opt = (Switch) getView().findViewById(
|
||||
|
@ -227,10 +223,8 @@ public class ConfigureFragment extends Fragment {
|
|||
int pos, long id) {
|
||||
mPrefs.edit().putInt("dc_region", pos).commit();
|
||||
dcregion = pos;
|
||||
if (!executeAppendConfig("Dreamcast.Region",
|
||||
String.valueOf(pos))) {
|
||||
executeWriteConfig();
|
||||
}
|
||||
executeAppendConfig("Dreamcast.Region",
|
||||
String.valueOf(pos));
|
||||
|
||||
}
|
||||
|
||||
|
@ -246,10 +240,8 @@ public class ConfigureFragment extends Fragment {
|
|||
boolean isChecked) {
|
||||
mPrefs.edit().putBoolean("limit_fps", isChecked).commit();
|
||||
limitfps = isChecked;
|
||||
if (!executeAppendConfig("aica.LimitFPS",
|
||||
String.valueOf(isChecked ? 1 : 0))) {
|
||||
executeWriteConfig();
|
||||
}
|
||||
executeAppendConfig("aica.LimitFPS",
|
||||
String.valueOf(isChecked ? 1 : 0));
|
||||
}
|
||||
};
|
||||
Switch limit_fps = (Switch) getView()
|
||||
|
@ -268,10 +260,8 @@ public class ConfigureFragment extends Fragment {
|
|||
boolean isChecked) {
|
||||
mPrefs.edit().putBoolean("use_mipmaps", isChecked).commit();
|
||||
mipmaps = isChecked;
|
||||
if (!executeAppendConfig("rend.UseMipmaps",
|
||||
String.valueOf(isChecked ? 1 : 0))) {
|
||||
executeWriteConfig();
|
||||
}
|
||||
executeAppendConfig("rend.UseMipmaps",
|
||||
String.valueOf(isChecked ? 1 : 0));
|
||||
}
|
||||
};
|
||||
Switch mipmap_opt = (Switch) getView()
|
||||
|
@ -290,10 +280,8 @@ public class ConfigureFragment extends Fragment {
|
|||
boolean isChecked) {
|
||||
mPrefs.edit().putBoolean("stretch_view", isChecked).commit();
|
||||
widescreen = isChecked;
|
||||
if (!executeAppendConfig("rend.WideScreen",
|
||||
String.valueOf(isChecked ? 1 : 0))) {
|
||||
executeWriteConfig();
|
||||
}
|
||||
executeAppendConfig("rend.WideScreen",
|
||||
String.valueOf(isChecked ? 1 : 0));
|
||||
}
|
||||
};
|
||||
Switch stretch_view = (Switch) getView().findViewById(
|
||||
|
@ -331,10 +319,8 @@ public class ConfigureFragment extends Fragment {
|
|||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
mPrefs.edit().putInt("frame_skip", progressChanged).commit();
|
||||
frameskip = progressChanged;
|
||||
if (!executeAppendConfig("ta.skip",
|
||||
String.valueOf(progressChanged))) {
|
||||
executeWriteConfig();
|
||||
}
|
||||
executeAppendConfig("ta.skip",
|
||||
String.valueOf(progressChanged));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -344,10 +330,8 @@ public class ConfigureFragment extends Fragment {
|
|||
boolean isChecked) {
|
||||
mPrefs.edit().putBoolean("pvr_render", isChecked).commit();
|
||||
pvrrender = isChecked;
|
||||
if (!executeAppendConfig("pvr.rend",
|
||||
String.valueOf(isChecked ? 1 : 0))) {
|
||||
executeWriteConfig();
|
||||
}
|
||||
executeAppendConfig("pvr.rend",
|
||||
String.valueOf(isChecked ? 1 : 0));
|
||||
}
|
||||
};
|
||||
Switch pvr_render = (Switch) getView().findViewById(R.id.render_option);
|
||||
|
@ -368,9 +352,7 @@ public class ConfigureFragment extends Fragment {
|
|||
if (cheatEdit.getText() != null) {
|
||||
cheatdisk = cheatEdit.getText().toString();
|
||||
mPrefs.edit().putString("cheat_disk", cheatdisk).commit();
|
||||
if (!executeAppendConfig("image", cheatdisk)) {
|
||||
executeWriteConfig();
|
||||
}
|
||||
executeAppendConfig("image", cheatdisk);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -405,10 +387,10 @@ public class ConfigureFragment extends Fragment {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean executeAppendConfig(String identifier, String value) {
|
||||
public void executeAppendConfig(String identifier, String value) {
|
||||
File config = new File(home_directory, "emu.cfg");
|
||||
if (config.exists()) {
|
||||
try {
|
||||
try {
|
||||
if (config.exists()) {
|
||||
// Read existing emu.cfg and substitute new setting value
|
||||
StringBuilder rebuildFile = new StringBuilder();
|
||||
Scanner scanner = new Scanner(config);
|
||||
|
@ -426,53 +408,43 @@ public class ConfigureFragment extends Fragment {
|
|||
FileOutputStream fos = new FileOutputStream(config);
|
||||
fos.write(rebuildFile.toString().getBytes());
|
||||
fos.close();
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
Log.d("reicast", "Exception: " + e);
|
||||
} else if (config.createNewFile()) {
|
||||
StringBuilder rebuildFile = new StringBuilder();
|
||||
rebuildFile.append("[config]" + "\n");
|
||||
rebuildFile.append("Dynarec.Enabled="
|
||||
+ String.valueOf(dynarecopt ? 1 : 0) + "\n");
|
||||
rebuildFile.append("Dynarec.idleskip=1" + "\n");
|
||||
rebuildFile.append("Dynarec.unstable-opt="
|
||||
+ String.valueOf(unstableopt ? 1 : 0) + "\n");
|
||||
rebuildFile.append("Dreamcast.Cable=3" + "\n");
|
||||
long dreamTime = (System.currentTimeMillis() / 1000)
|
||||
+ MainActivity.dreamRTC;
|
||||
rebuildFile.append("Dreamcast.RTC=" + String.valueOf(dreamTime)
|
||||
+ "\n");
|
||||
rebuildFile.append("Dreamcast.Region="
|
||||
+ String.valueOf(dcregion) + "\n");
|
||||
rebuildFile.append("Dreamcast.Broadcast=4" + "\n");
|
||||
rebuildFile.append("aica.LimitFPS="
|
||||
+ String.valueOf(limitfps ? 1 : 0) + "\n");
|
||||
rebuildFile.append("aica.NoBatch=0" + "\n");
|
||||
rebuildFile.append("rend.UseMipmaps="
|
||||
+ String.valueOf(mipmaps ? 1 : 0) + "\n");
|
||||
rebuildFile.append("rend.WideScreen="
|
||||
+ String.valueOf(widescreen ? 1 : 0) + "\n");
|
||||
rebuildFile.append("pvr.Subdivide=0" + "\n");
|
||||
rebuildFile.append("ta.skip=" + String.valueOf(frameskip)
|
||||
+ "\n");
|
||||
rebuildFile.append("pvr.rend="
|
||||
+ String.valueOf(pvrrender ? 1 : 0) + "\n");
|
||||
rebuildFile.append("image=" + cheatdisk + "\n");
|
||||
FileOutputStream fos = new FileOutputStream(config);
|
||||
fos.write(rebuildFile.toString().getBytes());
|
||||
fos.close();
|
||||
} else {
|
||||
Toast.makeText(parentActivity,
|
||||
parentActivity.getString(R.string.bios_config),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void executeWriteConfig() {
|
||||
try {
|
||||
File config = new File(home_directory, "emu.cfg");
|
||||
if (config.exists()) {
|
||||
config.delete();
|
||||
}
|
||||
|
||||
// Write new emu.cfg using current display values
|
||||
|
||||
StringBuilder rebuildFile = new StringBuilder();
|
||||
rebuildFile.append("[config]" + "\n");
|
||||
rebuildFile.append("Dynarec.Enabled="
|
||||
+ String.valueOf(dynarecopt ? 1 : 0) + "\n");
|
||||
rebuildFile.append("Dynarec.idleskip=1" + "\n");
|
||||
rebuildFile.append("Dynarec.unstable-opt="
|
||||
+ String.valueOf(unstableopt ? 1 : 0) + "\n");
|
||||
rebuildFile.append("Dreamcast.Cable=3" + "\n");
|
||||
long dreamTime = (System.currentTimeMillis() / 1000)
|
||||
+ MainActivity.dreamRTC;
|
||||
rebuildFile.append("Dreamcast.RTC=" + String.valueOf(dreamTime)
|
||||
+ "\n");
|
||||
rebuildFile.append("Dreamcast.Region=" + String.valueOf(dcregion)
|
||||
+ "\n");
|
||||
rebuildFile.append("Dreamcast.Broadcast=4" + "\n");
|
||||
rebuildFile.append("aica.LimitFPS="
|
||||
+ String.valueOf(limitfps ? 1 : 0) + "\n");
|
||||
rebuildFile.append("aica.NoBatch=0" + "\n");
|
||||
rebuildFile.append("rend.UseMipmaps="
|
||||
+ String.valueOf(mipmaps ? 1 : 0) + "\n");
|
||||
rebuildFile.append("rend.WideScreen="
|
||||
+ String.valueOf(widescreen ? 1 : 0) + "\n");
|
||||
rebuildFile.append("pvr.Subdivide=0" + "\n");
|
||||
rebuildFile.append("ta.skip=" + String.valueOf(frameskip) + "\n");
|
||||
rebuildFile.append("pvr.rend=" + String.valueOf(pvrrender ? 1 : 0)
|
||||
+ "\n");
|
||||
rebuildFile.append("image=" + cheatdisk + "\n");
|
||||
FileOutputStream fos = new FileOutputStream(config);
|
||||
fos.write(rebuildFile.toString().getBytes());
|
||||
fos.close();
|
||||
} catch (Exception e) {
|
||||
Log.d("reicast", "Exception: " + e);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue