implement new file
This commit is contained in:
parent
d91b77015f
commit
8515e21ea9
19
index.html
19
index.html
|
|
@ -9,9 +9,9 @@
|
||||||
<body>
|
<body>
|
||||||
<nav id="top-menu" class="menu-bar">
|
<nav id="top-menu" class="menu-bar">
|
||||||
<div data-section="File" data-alt="f">
|
<div data-section="File" data-alt="f">
|
||||||
<button data-alt="n" data-button="file:new">New</button>
|
<button data-alt="n" data-button="file:new" disabled data-enable-on="config:end">New</button>
|
||||||
<button data-alt="o" data-button="file:load">Open</button>
|
<button data-alt="o" data-button="file:load" disabled data-enable-on="config:end">Open</button>
|
||||||
<button data-alt="s" data-button="file:save">Save</button>
|
<button data-alt="s" data-button="file:save" disabled data-enable-on="config:end">Save</button>
|
||||||
<div data-section="Configuiration" data-alt="c">
|
<div data-section="Configuiration" data-alt="c">
|
||||||
<button data-alt="d" data-button="load-configuration" data-configuration="default">Default</button>
|
<button data-alt="d" data-button="load-configuration" data-configuration="default">Default</button>
|
||||||
<button data-alt="e" data-button="load-configuration" data-configuration="e2ee">E2EE</button>
|
<button data-alt="e" data-button="load-configuration" data-configuration="e2ee">E2EE</button>
|
||||||
|
|
@ -57,10 +57,17 @@
|
||||||
<span data-resize="bottom-menu"></span>
|
<span data-resize="bottom-menu"></span>
|
||||||
</aside>
|
</aside>
|
||||||
<main>
|
<main>
|
||||||
<div data-state="initialization">
|
<div data-state="initialization" class="m2">
|
||||||
Select configuration file:
|
Select configuration file:
|
||||||
<button data-button="load-configuration" data-configuration="default">Default (2026-07-06)</button>
|
<div class="m1">
|
||||||
<input type="file" data-input="configuration" accept=".ncpf.json" />
|
<button data-button="load-configuration" data-configuration="default">Default</button>
|
||||||
|
</div>
|
||||||
|
<div class="m1">
|
||||||
|
<button data-button="load-configuration" data-configuration="e2ee">E2EE</button>
|
||||||
|
</div>
|
||||||
|
<div class="m1">
|
||||||
|
<button data-button="load-configuration">Select file...</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div data-state="planning">
|
<div data-state="planning">
|
||||||
<header class="status-bar">
|
<header class="status-bar">
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import { awaitEvent, emitEvent, listenTo } from "./events.js";
|
import { awaitEvent, emitEvent, listenTo } from "./events.js";
|
||||||
import { checkEquivalence, findFullEntry, stripEntryToMinimums } from "./ncpf-utils.js";
|
import { checkEquivalence, findFullEntry, stripEntryToMinimums } from "./ncpf-utils.js";
|
||||||
import {
|
import {
|
||||||
|
clearPlanner,
|
||||||
getPlannerDom,
|
getPlannerDom,
|
||||||
getPlannerMultiblockSize,
|
getPlannerMultiblockSize,
|
||||||
getPlannerMultiblockType,
|
getPlannerMultiblockType,
|
||||||
|
|
@ -14,7 +15,10 @@ import { DevError, UserError } from "./errors.js";
|
||||||
|
|
||||||
registerLoadCallback(() => {
|
registerLoadCallback(() => {
|
||||||
listenTo("file:load", () => showOpenFileDialog(({ data, filename }) => loadFile(data, filename)));
|
listenTo("file:load", () => showOpenFileDialog(({ data, filename }) => loadFile(data, filename)));
|
||||||
listenTo("file:new", () => {});
|
listenTo("file:new", () => {
|
||||||
|
clearPlanner();
|
||||||
|
resetSolver();
|
||||||
|
});
|
||||||
listenTo("file:save", () => saveFile());
|
listenTo("file:save", () => saveFile());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,12 @@ window.addEventListener("load", () => {
|
||||||
emitEvent(elem.dataset.form + ":submit", e);
|
emitEvent(elem.dataset.form + ":submit", e);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
getElements("enable-on", "*").forEach(elem => {
|
||||||
|
elem.disabled = true;
|
||||||
|
awaitEvent(elem.dataset.enableOn).then(() => {
|
||||||
|
elem.disabled = false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
listenTo("config:end", () => setState(STATE.planning));
|
listenTo("config:end", () => setState(STATE.planning));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,9 +12,15 @@ const zoomOptions = [ 0.5, 1, 2, 3, 4, 5 ];
|
||||||
const zoomDefault = 2;
|
const zoomDefault = 2;
|
||||||
const zoomStorageKey = "zoom-size";
|
const zoomStorageKey = "zoom-size";
|
||||||
|
|
||||||
|
const defaultMultiblockSize = [9, 7, 9]; // width (screen x), height (xy grids), depth (screen y)
|
||||||
|
const defaultMultiblockType = "nuclearcraft:overhaul_sfr";
|
||||||
|
const maxMultiblockSize = {
|
||||||
|
["nuclearcraft:overhaul_sfr"]: [26, 26, 26],
|
||||||
|
}
|
||||||
|
|
||||||
let suppressHover = false;
|
let suppressHover = false;
|
||||||
let multiblockSize = [9, 7, 9]; // width (screen x), height (xy grids), depth (screen y)
|
let multiblockSize = [...defaultMultiblockSize];
|
||||||
let multiblockType = "nuclearcraft:overhaul_sfr";
|
let multiblockType = defaultMultiblockType;
|
||||||
|
|
||||||
registerLoadCallback(() => {
|
registerLoadCallback(() => {
|
||||||
listenTo("config:end", buildPlanner);
|
listenTo("config:end", buildPlanner);
|
||||||
|
|
@ -257,9 +263,9 @@ export function getSelectedCells() {
|
||||||
return [...document.querySelectorAll("#planner [data-selected]")];
|
return [...document.querySelectorAll("#planner [data-selected]")];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function clearPlanner(size, type) {
|
export function clearPlanner(size = null, type = null) {
|
||||||
multiblockSize = size;
|
multiblockSize = size ?? [...defaultMultiblockSize];
|
||||||
multiblockType = type;
|
multiblockType = type ?? defaultMultiblockType;
|
||||||
buildPlanner();
|
buildPlanner();
|
||||||
}
|
}
|
||||||
export function loadPlanner(size, type, textures) {
|
export function loadPlanner(size, type, textures) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue