mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-18 18:11:24 +01:00
fix: options menue now works as intended
This commit is contained in:
parent
2ad1e75cfd
commit
21abd9efd5
2 changed files with 21 additions and 21 deletions
|
|
@ -365,7 +365,6 @@
|
||||||
data-tip="Click to show the Menu"
|
data-tip="Click to show the Menu"
|
||||||
data-shortcut="Tab"
|
data-shortcut="Tab"
|
||||||
class="options glow"
|
class="options glow"
|
||||||
onclick="showOptions(event)"
|
|
||||||
>
|
>
|
||||||
►
|
►
|
||||||
</button>
|
</button>
|
||||||
|
|
@ -391,7 +390,6 @@
|
||||||
data-tip="Click to hide the Menu"
|
data-tip="Click to hide the Menu"
|
||||||
data-shortcut="Tab or Esc"
|
data-shortcut="Tab or Esc"
|
||||||
class="options"
|
class="options"
|
||||||
onclick="hideOptions(event)"
|
|
||||||
>
|
>
|
||||||
◄
|
◄
|
||||||
</button>
|
</button>
|
||||||
|
|
@ -7657,8 +7655,8 @@
|
||||||
<script type="module" src="/src/modules/submap.js"></script>
|
<script type="module" src="/src/modules/submap.js"></script>
|
||||||
<script type="module" src="/src/modules/fonts.js"></script>
|
<script type="module" src="/src/modules/fonts.js"></script>
|
||||||
<script type="module" src="/src/modules/ui/stylePresets.js"></script>
|
<script type="module" src="/src/modules/ui/stylePresets.js"></script>
|
||||||
<script type="module" src="/src/modules/ui/options.js"></script>
|
|
||||||
<script type="module" src="/src/modules/zoom.js"></script>
|
<script type="module" src="/src/modules/zoom.js"></script>
|
||||||
|
<script type="module" src="/src/modules/ui/options.ts"></script>
|
||||||
|
|
||||||
<script type="module" src="/src/main.ts"></script>
|
<script type="module" src="/src/main.ts"></script>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,8 @@ byId<'button'>("optionsTrigger").on("click", showOptions);
|
||||||
byId<'button'>("optionsHide").on("click", hideOptions);
|
byId<'button'>("optionsHide").on("click", hideOptions);
|
||||||
|
|
||||||
// Window Objects
|
// Window Objects
|
||||||
const {Zoom, COA, Cloud, ThreeD, Names} = window;
|
const {COA, Cloud, ThreeD, Names, Zoom} = window;
|
||||||
|
|
||||||
|
|
||||||
// DIV elements
|
// DIV elements
|
||||||
const tooltip = byId<'div'>("tooltip");
|
const tooltip = byId<'div'>("tooltip");
|
||||||
|
|
@ -40,7 +41,8 @@ const tooltip = byId<'div'>("tooltip");
|
||||||
// Options pane elements
|
// Options pane elements
|
||||||
const optionsTrigger = byId<'button'>("optionsTrigger");
|
const optionsTrigger = byId<'button'>("optionsTrigger");
|
||||||
const regenerate = byId<'button'>("regenerate");
|
const regenerate = byId<'button'>("regenerate");
|
||||||
const optionsDiv = byId<'div'>("optionsContainer");
|
const optionsContainer = byId<'div'>("optionsContainer");
|
||||||
|
const optionsDisplay = byId<'div'>("options");
|
||||||
const collapsible = byId<'div'>("collapsible");
|
const collapsible = byId<'div'>("collapsible");
|
||||||
const layersContent = byId<'div'>("layersContent");
|
const layersContent = byId<'div'>("layersContent");
|
||||||
const styleContent = byId<'div'>("styleContent");
|
const styleContent = byId<'div'>("styleContent");
|
||||||
|
|
@ -140,7 +142,7 @@ export function showOptions(event: Event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
regenerate.style.display = "none";
|
regenerate.style.display = "none";
|
||||||
optionsDiv.style.display = "block";
|
optionsDisplay.style.display = "block";
|
||||||
optionsTrigger.style.display = "none";
|
optionsTrigger.style.display = "none";
|
||||||
|
|
||||||
if (event) event.stopPropagation();
|
if (event) event.stopPropagation();
|
||||||
|
|
@ -148,21 +150,21 @@ export function showOptions(event: Event) {
|
||||||
|
|
||||||
// Hide options pane on trigger click
|
// Hide options pane on trigger click
|
||||||
export function hideOptions(event: Event) {
|
export function hideOptions(event: Event) {
|
||||||
optionsDiv.style.display = "none";
|
optionsDisplay.style.display = "none";
|
||||||
optionsTrigger.style.display = "block";
|
optionsTrigger.style.display = "block";
|
||||||
if (event) event.stopPropagation();
|
if (event) event.stopPropagation();
|
||||||
}
|
}
|
||||||
|
|
||||||
// To toggle options on hotkey press
|
// To toggle options on hotkey press
|
||||||
export function toggleOptions(event: MouseEvent) {
|
export function toggleOptions(event: MouseEvent) {
|
||||||
if (optionsDiv.style.display === "none") showOptions(event);
|
if (optionsContainer.style.display === "none") showOptions(event);
|
||||||
else hideOptions(event);
|
else hideOptions(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Toggle "New Map!" pane on hover
|
// Toggle "New Map!" pane on hover
|
||||||
optionsTrigger.on("mouseenter", function () {
|
optionsTrigger.on("mouseenter", function () {
|
||||||
if (optionsTrigger.classList.contains("glow")) return;
|
if (optionsTrigger.classList.contains("glow")) return;
|
||||||
if (optionsDiv.style.display === "none") regenerate.style.display = "block";
|
if (optionsContainer.style.display === "none") regenerate.style.display = "block";
|
||||||
});
|
});
|
||||||
|
|
||||||
collapsible.on("mouseleave", function () {
|
collapsible.on("mouseleave", function () {
|
||||||
|
|
@ -170,17 +172,17 @@ collapsible.on("mouseleave", function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Activate options tab on click
|
// Activate options tab on click
|
||||||
optionsDiv
|
optionsContainer
|
||||||
.querySelector("div.tab")!
|
.querySelector("div.tab")!
|
||||||
.on("click", function (event: any ) { // MARKER: any
|
.on("click", function (event: any ) { // MARKER: any
|
||||||
if (event.target.tagName !== "BUTTON") return;
|
if (event.target.tagName !== "BUTTON") return;
|
||||||
const id = event.target.id;
|
const id = event.target.id;
|
||||||
const active = optionsDiv.querySelector(".tab > button.active");
|
const active = optionsContainer.querySelector(".tab > button.active");
|
||||||
if (active && id === active.id) return; // already active tab is clicked
|
if (active && id === active.id) return; // already active tab is clicked
|
||||||
|
|
||||||
if (active) active.classList.remove("active");
|
if (active) active.classList.remove("active");
|
||||||
byId(id)!.classList.add("active");
|
byId(id).classList.add("active");
|
||||||
optionsDiv
|
optionsContainer
|
||||||
.querySelectorAll<HTMLElement>(".tabcontent")
|
.querySelectorAll<HTMLElement>(".tabcontent")
|
||||||
.forEach((e: HTMLElement) => {e.style.display = "none"});
|
.forEach((e: HTMLElement) => {e.style.display = "none"});
|
||||||
|
|
||||||
|
|
@ -207,9 +209,9 @@ async function showSupporters() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// on any option or dialog change
|
// on any option or dialog change
|
||||||
optionsDiv.on("change", storeValueIfRequired);
|
optionsContainer.on("change", storeValueIfRequired);
|
||||||
dialogDiv.on("change", storeValueIfRequired);
|
dialogDiv.on("change", storeValueIfRequired);
|
||||||
optionsDiv.on("input", updateOutputToFollowInput);
|
optionsContainer.on("input", updateOutputToFollowInput);
|
||||||
dialogDiv.on("input", updateOutputToFollowInput);
|
dialogDiv.on("input", updateOutputToFollowInput);
|
||||||
|
|
||||||
function storeValueIfRequired(ev: any) { // MARKER: any
|
function storeValueIfRequired(ev: any) { // MARKER: any
|
||||||
|
|
@ -320,10 +322,10 @@ function changeMapSize() {
|
||||||
|
|
||||||
// just apply canvas size that was already set
|
// just apply canvas size that was already set
|
||||||
export function applyMapSize() {
|
export function applyMapSize() {
|
||||||
const zoomMin = Number(zoomExtentMin.value);
|
const zoomMin = zoomExtentMin.valueAsNumber;
|
||||||
const zoomMax = Number(zoomExtentMax.value);
|
const zoomMax = zoomExtentMax.valueAsNumber;
|
||||||
graphWidth = Number(mapWidthInput.value);
|
graphWidth = mapWidthInput.valueAsNumber;
|
||||||
graphHeight = Number(mapHeightInput.value);
|
graphHeight = mapHeightInput.valueAsNumber;
|
||||||
svgWidth = Math.min(graphWidth, window.innerWidth);
|
svgWidth = Math.min(graphWidth, window.innerWidth);
|
||||||
svgHeight = Math.min(graphHeight, window.innerHeight);
|
svgHeight = Math.min(graphHeight, window.innerHeight);
|
||||||
svg.attr("width", svgWidth).attr("height", svgHeight);
|
svg.attr("width", svgWidth).attr("height", svgHeight);
|
||||||
|
|
@ -537,7 +539,7 @@ function changeUIsize(value: number) {
|
||||||
|
|
||||||
uiSizeInput.valueAsNumber = uiSizeOutput.valueAsNumber = value;
|
uiSizeInput.valueAsNumber = uiSizeOutput.valueAsNumber = value;
|
||||||
document.getElementsByTagName("body")[0].style.fontSize = rn(value * 10, 2) + "px";
|
document.getElementsByTagName("body")[0].style.fontSize = rn(value * 10, 2) + "px";
|
||||||
optionsDiv.style.width = value * 300 + "px";
|
optionsContainer.style.width = value * 300 + "px";
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUImaxSize() {
|
function getUImaxSize() {
|
||||||
|
|
@ -1126,7 +1128,7 @@ async function enter3dView(type) {
|
||||||
resizeStop: resize3d,
|
resizeStop: resize3d,
|
||||||
close: enterStandardView
|
close: enterStandardView
|
||||||
});
|
});
|
||||||
} else document.body.insertBefore(canvas, optionsDiv);
|
} else document.body.insertBefore(canvas, optionsContainer);
|
||||||
|
|
||||||
toggle3dOptions();
|
toggle3dOptions();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue