mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-18 10:01:23 +01:00
feat: assistant - ability to toggle assistant
This commit is contained in:
parent
cb34491a17
commit
f45c8040e1
2 changed files with 12 additions and 3 deletions
14
main.js
14
main.js
|
|
@ -317,7 +317,7 @@ async function generateMapOnLoad() {
|
|||
applyPreset(); // apply saved layers preset
|
||||
fitMapToScreen();
|
||||
focusOn(); // based on searchParams focus on point, cell or burg from MFCG
|
||||
loadAssistant();
|
||||
toggleAssistant();
|
||||
}
|
||||
|
||||
// focus on coordinates, cell or burg provided in searchParams
|
||||
|
|
@ -367,9 +367,17 @@ function focusOn() {
|
|||
}
|
||||
}
|
||||
|
||||
function loadAssistant() {
|
||||
let isAssistantLoaded = false;
|
||||
function toggleAssistant() {
|
||||
const assistantContainer = byId("chat-widget-container");
|
||||
const showAssistant = byId("azgaarAssistant").value === "show";
|
||||
if (showAssistant) import("./libs/openwidget.min.js");
|
||||
|
||||
if (showAssistant) {
|
||||
if (isAssistantLoaded) assistantContainer.style.display = "block";
|
||||
else import("./libs/openwidget.min.js").then(() => (isAssistantLoaded = true));
|
||||
} else if (isAssistantLoaded) {
|
||||
assistantContainer.style.display = "none";
|
||||
}
|
||||
}
|
||||
|
||||
// find burg for MFCG and focus on it
|
||||
|
|
|
|||
|
|
@ -148,6 +148,7 @@ optionsContent.addEventListener("change", event => {
|
|||
else if (id === "yearInput") changeYear();
|
||||
else if (id === "eraInput") changeEra();
|
||||
else if (id === "stateLabelsModeInput") options.stateLabelsMode = value;
|
||||
else if (id === "azgaarAssistant") toggleAssistant();
|
||||
});
|
||||
|
||||
optionsContent.addEventListener("click", event => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue