Clean restart. No longer double-visits starting point!

This commit is contained in:
Kistaro Windrider 2024-07-05 13:37:09 -07:00
parent 1122b122f0
commit 1c2c6438bf
Signed by: kistaro
SSH Key Fingerprint: SHA256:TBE2ynfmJqsAf0CP6gsflA0q5X5wD5fVKWPsZ7eVUg8

View File

@ -24,6 +24,22 @@
} }
} }
}); });
$(document).on(':passageinit', function(ev) {
"use strict";
if (!Config.debug || variables().ADDON_TEST_CONFIG_MGR_STATE != 'ready') {
return;
}
const configs_chosen = recall('ADDON_TEST_CONFIG_MGR_chosen_configs', null);
if (!configs_chosen) {
return;
}
forget('ADDON_TEST_CONFIG_MGR_chosen_configs');
variables().ADDON_TEST_CONFIG_MGR_STATE="loading";
for (const target of configs_chosen) {
$.wiki("<<include \"" + target + "\">>");
}
variables().ADDON_TEST_CONFIG_MGR_STATE = 'done';
});
$(document).on(':passagestart', function(ev) { $(document).on(':passagestart', function(ev) {
"use strict"; "use strict";
if (!Config.debug) { if (!Config.debug) {
@ -56,21 +72,16 @@
let load_button = document.createElement("button"); let load_button = document.createElement("button");
load_button.innerText = "Load"; load_button.innerText = "Load";
load_button.onclick = function() { load_button.onclick = function() {
if (!Config.debug) { if (!Config.debug || Engine.state != 'idle') {
// debugging got disabled, ignore it
return; return;
} }
const orig_passage = passage();
variables().ADDON_TEST_CONFIG_MGR_STATE="loading";
const target = document.getElementById("addon_test_config_mgr_config_picker")?.value; const target = document.getElementById("addon_test_config_mgr_config_picker")?.value;
if (!target) { if (!target) {
return; return;
} }
$.wiki("<<include \"" + target + "\">>"); memorize('ADDON_TEST_CONFIG_MGR_chosen_configs', [target]);
variables().ADDON_TEST_CONFIG_MGR_STATE = 'done'; Engine.restart();
Engine.play(orig_passage, passage() == orig_passage);
}; };
$(ev.content).wiki("^^Test Config Manager^^\n" $(ev.content).wiki("^^Test Config Manager^^\n"
+ "!!!Would you like to load a test config?\n"); + "!!!Would you like to load a test config?\n");
$(ev.content).append(dropdown).append(load_button); $(ev.content).append(dropdown).append(load_button);