finalize block tooltips, begin work on menubar
This commit is contained in:
parent
53b5386465
commit
ea6813b415
27
index.html
27
index.html
|
|
@ -7,11 +7,28 @@
|
||||||
<script type="module" src="scripts/main.js"></script>
|
<script type="module" src="scripts/main.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<nav id="top-menu">
|
<nav id="top-menu" class="menu-bar">
|
||||||
<button>File</button>
|
<div data-section="File" data-alt="f">
|
||||||
<button>Edit</button>
|
<button data-alt="n" data-button="new-file">New</button>
|
||||||
<button>Select</button>
|
<button data-alt="o" data-button="open-file">Open</button>
|
||||||
<button>View</button>
|
<div data-section="Recent Files" data-alt="r">
|
||||||
|
<button disabled>-</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div data-section="Edit" data-alt="e">
|
||||||
|
<button data-alt="u" data-button="undo">Undo</button>
|
||||||
|
<button data-alt="r" data-button="redo" disabled>Redo</button>
|
||||||
|
</div>
|
||||||
|
<div data-section="Select" data-alt="s">
|
||||||
|
<button data-alt="i">Invert</button>
|
||||||
|
</div>
|
||||||
|
<div data-section="View" data-alt="v">
|
||||||
|
<div data-section="Test" data-alt="e">
|
||||||
|
<div data-section="Test" data-alt="e">
|
||||||
|
<button disabled>-</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
<nav id="left-menu" data-state="planning">
|
<nav id="left-menu" data-state="planning">
|
||||||
<span data-resize="left-menu"></span>
|
<span data-resize="left-menu"></span>
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,8 @@ function putTextureOnCanvas(ctx, atlasSize, index, data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function buildAtlas(data) {
|
export async function buildAtlas(data) {
|
||||||
|
// TODO: atlas caching
|
||||||
|
|
||||||
emitEvent("config:process:atlas:start");
|
emitEvent("config:process:atlas:start");
|
||||||
const textures = [
|
const textures = [
|
||||||
...Object.entries(data.configuration),
|
...Object.entries(data.configuration),
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import { initializePlanner } from "./planner.js";
|
||||||
import { initializeMenuResizing } from "./resize-menus.js";
|
import { initializeMenuResizing } from "./resize-menus.js";
|
||||||
import { getState, setState, STATE } from "./state.js";
|
import { getState, setState, STATE } from "./state.js";
|
||||||
import { initializeTooltips } from "./tooltip.js";
|
import { initializeTooltips } from "./tooltip.js";
|
||||||
|
import { initializeMenuBar } from "./menu-bar.js";
|
||||||
|
|
||||||
window.addEventListener("load", () => {
|
window.addEventListener("load", () => {
|
||||||
emitEvent("setup-start");
|
emitEvent("setup-start");
|
||||||
|
|
@ -37,6 +38,7 @@ window.addEventListener("load", () => {
|
||||||
initializePlanner();
|
initializePlanner();
|
||||||
initializeMenuResizing();
|
initializeMenuResizing();
|
||||||
initializeTooltips();
|
initializeTooltips();
|
||||||
|
initializeMenuBar();
|
||||||
|
|
||||||
emitEvent("setup-end");
|
emitEvent("setup-end");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
export function initializeMenuBar() {}
|
||||||
|
|
@ -4,7 +4,8 @@ function findInPossible(entryList, entry) {
|
||||||
switch (entry.type) {
|
switch (entry.type) {
|
||||||
case "legacy_block":
|
case "legacy_block":
|
||||||
return entryList.find(v => v.name === entry.name
|
return entryList.find(v => v.name === entry.name
|
||||||
&& v.metadata === entry.metadata);
|
&& v.metadata === entry.metadata
|
||||||
|
&& (!entry.blockstate || JSON.stringify(v.blockstate) === JSON.stringify(entry.blockstate)));
|
||||||
|
|
||||||
case "oredict":
|
case "oredict":
|
||||||
return entryList.find(v => v.oredict === entry.oredict);
|
return entryList.find(v => v.oredict === entry.oredict);
|
||||||
|
|
|
||||||
|
|
@ -180,7 +180,10 @@ function* getBlockTooltip(metadata) {
|
||||||
|
|
||||||
yield data.modules["plannerator:display_name"].display_name;
|
yield data.modules["plannerator:display_name"].display_name;
|
||||||
|
|
||||||
|
let hasAdditionalData = false;
|
||||||
|
|
||||||
if ("nuclearcraft:overhaul_sfr:heat_sink" in data.modules) {
|
if ("nuclearcraft:overhaul_sfr:heat_sink" in data.modules) {
|
||||||
|
hasAdditionalData = true;
|
||||||
const heatSink = data.modules["nuclearcraft:overhaul_sfr:heat_sink"];
|
const heatSink = data.modules["nuclearcraft:overhaul_sfr:heat_sink"];
|
||||||
yield "Heatsink";
|
yield "Heatsink";
|
||||||
if (heatSink.cooling) {
|
if (heatSink.cooling) {
|
||||||
|
|
@ -192,60 +195,71 @@ function* getBlockTooltip(metadata) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ("nuclearcraft:overhaul_sfr:casing" in data.modules) {
|
||||||
|
hasAdditionalData = true;
|
||||||
|
yield "Casing";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ("nuclearcraft:overhaul_sfr:controller" in data.modules) {
|
||||||
|
hasAdditionalData = true;
|
||||||
|
yield "Controller";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ("nuclearcraft:overhaul_sfr:fuel_cell" in data.modules) {
|
||||||
|
hasAdditionalData = true;
|
||||||
|
yield "Fuel Cell";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ("nuclearcraft:overhaul_sfr:port" in data.modules) {
|
||||||
|
hasAdditionalData = true;
|
||||||
|
if (data.modules["nuclearcraft:overhaul_sfr:port"].output) {
|
||||||
|
yield "Output Port";
|
||||||
|
} else {
|
||||||
|
yield "Input Port";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ("nuclearcraft:overhaul_sfr:irradiator" in data.modules) {
|
||||||
|
hasAdditionalData = true;
|
||||||
|
yield "Irradiator";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ("nuclearcraft:overhaul_sfr:conductor" in data.modules) {
|
||||||
|
hasAdditionalData = true;
|
||||||
|
yield "Conductor";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ("nuclearcraft:overhaul_sfr:moderator" in data.modules) {
|
||||||
|
hasAdditionalData = true;
|
||||||
|
const moderator = data.modules["nuclearcraft:overhaul_sfr:moderator"];
|
||||||
|
yield "Moderator";
|
||||||
|
yield `Flux: ${moderator.flux}`;
|
||||||
|
yield `Efficiency: ${moderator.efficiency}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ("nuclearcraft:overhaul_sfr:reflector" in data.modules) {
|
||||||
|
hasAdditionalData = true;
|
||||||
|
const reflector = data.modules["nuclearcraft:overhaul_sfr:reflector"];
|
||||||
|
yield "Reflector";
|
||||||
|
yield `Efficiency: ${reflector.efficiency}`;
|
||||||
|
yield `Reflectivity: ${reflector.reflectivity}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ("nuclearcraft:overhaul_sfr:neutron_shield" in data.modules) {
|
||||||
|
hasAdditionalData = true;
|
||||||
|
const shield = data.modules["nuclearcraft:overhaul_sfr:neutron_shield"];
|
||||||
|
yield "Neutron Shield";
|
||||||
|
yield `Efficiency: ${shield.efficiency}`;
|
||||||
|
yield `Heat per Flux: ${shield.heat_per_flux}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hasAdditionalData) {
|
||||||
|
console.log("unknown block", data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseRuleAsTooltip(rule, props) {
|
function parseRuleAsTooltip(rule, props) {
|
||||||
void {
|
|
||||||
"cooling": 130,
|
|
||||||
"rules": [
|
|
||||||
{
|
|
||||||
"rules": [
|
|
||||||
{
|
|
||||||
"rules": [
|
|
||||||
{
|
|
||||||
"min": 2,
|
|
||||||
"max": 2,
|
|
||||||
"block": {
|
|
||||||
"metadata": 1,
|
|
||||||
"name": "nuclearcraft:solid_fission_sink2",
|
|
||||||
"type": "legacy_block",
|
|
||||||
"blockstate": {
|
|
||||||
"type": "lead"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"type": "between"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"min": 1,
|
|
||||||
"max": 1,
|
|
||||||
"block": {
|
|
||||||
"metadata": 1,
|
|
||||||
"name": "nuclearcraft:solid_fission_sink2",
|
|
||||||
"type": "legacy_block",
|
|
||||||
"blockstate": {
|
|
||||||
"type": "lead"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"type": "axial"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"type": "and"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"min": 1,
|
|
||||||
"max": 6,
|
|
||||||
"block": {
|
|
||||||
"name": "nuclearcraft:overhaul_sfr:casing",
|
|
||||||
"type": "module"
|
|
||||||
},
|
|
||||||
"type": "between"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"type": "and"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
// Requires exactly 2 lead heat sink AND exactly 1 pairs of axial lead heat sink AND at least 1 casing
|
|
||||||
switch (rule.type) {
|
switch (rule.type) {
|
||||||
case "and":
|
case "and":
|
||||||
return rule.rules.map(r => parseRuleAsTooltip(r, props)).join(" AND ");
|
return rule.rules.map(r => parseRuleAsTooltip(r, props)).join(" AND ");
|
||||||
|
|
@ -285,7 +299,6 @@ function parseRuleAsTooltip(rule, props) {
|
||||||
} else {
|
} else {
|
||||||
return `between ${rule.min} and ${rule.max} axial ${block}`;
|
return `between ${rule.min} and ${rule.max} axial ${block}`;
|
||||||
}
|
}
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue