fix(hd): sync web Client Options 317HD state with Plugin Hub 317 HD config
Keeps the webclient's Client Options modal (2006scape_web_options.hd), startup URL/option state, and Plugin Hub's plugin.317_HD.enabled property synchronized in both directions and at runtime. ### Web HD State Synchronization - src/main/java/org/scape2006/web/WebLauncher.java: - Added syncHdStorageState(boolean) on startup when ?hd= or saved web options specify HD so plugin.317_HD.enabled in 2006scape_plugin_settings matches ClientSettings.HD_317 before PluginManager boots. - Registered window.scapeSetHd317 callback forwarding live HD toggles to game.setHD317Enabled(boolean). - src/main/java/org/scape2006/web/DesktopHooks.java: - Added jsSyncWebOptionHdFromPluginConfig(String) in savePluginConfig(String) so toggling 317 HD in Plugin Hub or via ::hd updates 2006scape_web_options.hd in localStorage. - src/main/webapp/index.html: - Updated saveOpts(applyLive) to mirror o.hd into plugin.317_HD.enabled in 2006scape_plugin_settings and invoke window.scapeSetHd317(o.hd) when saving live.
This commit is contained in:
1 parent
6737a936df
commit
558243a3b7
3 files changed
+71
-1
No files matched your search
@@ -573,6 +573,7 @@ public final class DesktopHooks {
|
||||
public static boolean savePluginConfig(String content) {
|
||||
if (content == null) return false;
|
||||
jsSavePluginConfig(content);
|
||||
jsSyncWebOptionHdFromPluginConfig(content);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -583,6 +584,22 @@ public final class DesktopHooks {
|
||||
"if (window.localStorage) window.localStorage.setItem('2006scape_plugin_settings', content);")
|
||||
private static native void jsSavePluginConfig(String content);
|
||||
|
||||
@JSBody(params = {"content"}, script =
|
||||
"try {\n" +
|
||||
" if (!window.localStorage || !content) return;\n" +
|
||||
" var m = content.match(/(?:^|\\r?\\n)plugin\\.317_HD\\.enabled\\s*=\\s*(true|false)/i);\n" +
|
||||
" if (!m) return;\n" +
|
||||
" var hdEnabled = m[1].toLowerCase() === 'true';\n" +
|
||||
" var raw = window.localStorage.getItem('2006scape_web_options');\n" +
|
||||
" var opts = raw ? JSON.parse(raw) : {};\n" +
|
||||
" if (!opts || typeof opts !== 'object') opts = {};\n" +
|
||||
" if (opts.hd !== hdEnabled) {\n" +
|
||||
" opts.hd = hdEnabled;\n" +
|
||||
" window.localStorage.setItem('2006scape_web_options', JSON.stringify(opts));\n" +
|
||||
" }\n" +
|
||||
"} catch (_) {}")
|
||||
private static native void jsSyncWebOptionHdFromPluginConfig(String content);
|
||||
|
||||
public static void yieldUi() {
|
||||
try {
|
||||
Thread.sleep(1L);
|
||||
|
||||
Reference in new issue
Block a user