mirror of
https://github.com/rommapp/romm.git
synced 2026-11-29 10:01:00 +01:00
Merge pull request #3920 from rommapp/fix/ejs-default-settings-fallback
Keep config.yaml EmulatorJS core settings active after user changes settings
This commit is contained in:
@@ -389,6 +389,36 @@ window.EJS_onGameStart = async () => {
|
||||
// emulator's own start hook keeps the flag true for any entry point.
|
||||
playing.value = true;
|
||||
|
||||
// Patch the instance so unsaved keys still fall back to config defaults.
|
||||
const originalPreGetSetting = window.EJS_emulator?.preGetSetting.bind(
|
||||
window.EJS_emulator,
|
||||
);
|
||||
if (window.EJS_emulator) {
|
||||
window.EJS_emulator.preGetSetting = (setting: string) => {
|
||||
const value = originalPreGetSetting(setting);
|
||||
if (value !== undefined && value !== null) return value;
|
||||
const defaults = window.EJS_emulator.config?.defaultOptions ?? {};
|
||||
return defaults[setting] !== undefined ? defaults[setting] : null;
|
||||
};
|
||||
|
||||
window.EJS_emulator.rewindEnabled =
|
||||
window.EJS_emulator.preGetSetting("rewindEnabled") === "enabled";
|
||||
|
||||
if (![0, 1, 2, 3].includes(window.EJS_emulator.config?.videoRotation)) {
|
||||
window.EJS_emulator.videoRotation =
|
||||
window.EJS_emulator.preGetSetting("videoRotation") || 0;
|
||||
}
|
||||
|
||||
const webgl2Setting = window.EJS_emulator.preGetSetting("webgl2Enabled");
|
||||
if (webgl2Setting === "disabled" || !window.EJS_emulator.supportsWebgl2) {
|
||||
window.EJS_emulator.webgl2Enabled = false;
|
||||
} else if (webgl2Setting === "enabled") {
|
||||
window.EJS_emulator.webgl2Enabled = true;
|
||||
} else {
|
||||
window.EJS_emulator.webgl2Enabled = null;
|
||||
}
|
||||
}
|
||||
|
||||
// Install netplay overrides synchronously, before any await below, so they
|
||||
// are in place before room polling or a Create/Join action can start.
|
||||
const netplay = window.EJS_emulator?.netplay;
|
||||
|
||||
Reference in New Issue
Block a user