mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-19 10:31:24 +01:00
reinstate economics logic
This commit is contained in:
parent
cea9b1a48a
commit
cb486fa0e8
17 changed files with 2179 additions and 42 deletions
|
|
@ -52,6 +52,7 @@ function getDefaultPresets() {
|
|||
"toggleScaleBar",
|
||||
"toggleVignette"
|
||||
],
|
||||
economical: ['toggleResources', 'toggleBiomes', 'toggleBorders', 'toggleIcons', 'toggleIce', 'toggleLabels', 'toggleRivers', 'toggleRoutes', 'toggleScaleBar'],
|
||||
military: [
|
||||
"toggleBorders",
|
||||
"toggleIcons",
|
||||
|
|
@ -2020,6 +2021,49 @@ function drawEmblems() {
|
|||
TIME && console.timeEnd("drawEmblems");
|
||||
}
|
||||
|
||||
function toggleResources(event) {
|
||||
if (!layerIsOn('toggleResources')) {
|
||||
turnButtonOn('toggleResources');
|
||||
drawResources();
|
||||
if (event && isCtrlClick(event)) editStyle('goods');
|
||||
} else {
|
||||
if (event && isCtrlClick(event)) {
|
||||
editStyle('goods');
|
||||
return;
|
||||
}
|
||||
goods.selectAll('*').remove();
|
||||
turnButtonOff('toggleResources');
|
||||
}
|
||||
}
|
||||
|
||||
function drawResources() {
|
||||
console.time('drawResources');
|
||||
const someArePinned = pack.resources.some((resource) => resource.pinned);
|
||||
const drawCircle = +goods.attr('data-circle');
|
||||
|
||||
let resourcesHTML = '';
|
||||
for (const i of pack.cells.i) {
|
||||
if (!pack.cells.resource[i]) continue;
|
||||
const resource = Resources.get(pack.cells.resource[i]);
|
||||
if (someArePinned && !resource.pinned) continue;
|
||||
const [x, y] = pack.cells.p[i];
|
||||
const stroke = Resources.getStroke(resource.color);
|
||||
|
||||
if (!drawCircle) {
|
||||
resourcesHTML += `<use data-i="${resource.i}" href="#${resource.icon}" x="${x - 3}" y="${y - 3}" width="6" height="6"/>`;
|
||||
continue;
|
||||
}
|
||||
|
||||
resourcesHTML += `<g>
|
||||
<circle data-i="${resource.i}" cx=${x} cy=${y} r="3" fill="${resource.color}" stroke="${stroke}" />
|
||||
<use href="#${resource.icon}" x="${x - 3}" y="${y - 3}" width="6" height="6"/>
|
||||
</g>`;
|
||||
}
|
||||
|
||||
goods.html(resourcesHTML);
|
||||
console.timeEnd('drawResources');
|
||||
}
|
||||
|
||||
function toggleVignette(event) {
|
||||
if (!layerIsOn("toggleVignette")) {
|
||||
turnButtonOn("toggleVignette");
|
||||
|
|
@ -2079,6 +2123,7 @@ function getLayer(id) {
|
|||
if (id === "togglePopulation") return $("#population");
|
||||
if (id === "toggleIce") return $("#ice");
|
||||
if (id === "toggleTexture") return $("#texture");
|
||||
if (id === "toggleResources") return $("#goods")
|
||||
if (id === "toggleEmblems") return $("#emblems");
|
||||
if (id === "toggleLabels") return $("#labels");
|
||||
if (id === "toggleIcons") return $("#icons");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue