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