burgs placement change + resource style

This commit is contained in:
Azgaar 2021-07-07 21:17:39 +03:00
parent dc6528665a
commit b7545d2805
6 changed files with 687 additions and 479 deletions

View file

@ -1655,6 +1655,7 @@ function toggleResources(event) {
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) {
@ -1664,11 +1665,17 @@ function drawResources() {
const [x, y] = pack.cells.p[i];
const stroke = Resources.getStroke(resource.color);
if (!drawCircle) {
resourcesHTML += `<use 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');
}

View file

@ -251,6 +251,13 @@ function selectStyleElement() {
styleStrokeWidthInput.value = styleStrokeWidthOutput.value = el.attr('stroke-width') || 1;
}
if (sel === 'goods') {
styleStrokeWidth.style.display = 'block';
styleStrokeWidthInput.value = styleStrokeWidthOutput.value = el.attr('stroke-width') || '';
styleResources.style.display = 'block';
styleResourcesCircle.checked = +el.attr('data-circle');
}
// update group options
styleGroupSelect.options.length = 0; // remove all options
if (['routes', 'labels', 'coastline', 'lakes', 'anchors', 'burgIcons', 'borders'].includes(sel)) {
@ -677,6 +684,12 @@ styleEmblemsStateSizeInput.addEventListener('input', drawEmblems);
styleEmblemsProvinceSizeInput.addEventListener('input', drawEmblems);
styleEmblemsBurgSizeInput.addEventListener('input', drawEmblems);
styleResourcesCircle.addEventListener('change', function () {
goods.attr('data-circle', +this.checked);
goods.selectAll('*').remove();
drawResources();
});
// request a URL to image to be used as a texture
function textureProvideURL() {
alertMessage.innerHTML = `Provide an image URL to be used as a texture:
@ -913,7 +926,7 @@ function applyDefaultStyle() {
fogging.attr('opacity', 0.98).attr('fill', '#30426f');
emblems.attr('opacity', 0.9).attr('stroke-width', 1).attr('filter', null);
goods.attr('opacity', 1).attr('fill', '#000').attr('stroke', '#000').attr('stroke-width', 0.32).attr('filter', 'url(#dropShadow01)');
goods.attr('opacity', 1).attr('data-circle', 1).attr('fill', '#000').attr('stroke', '#000').attr('stroke-width', 0.32).attr('filter', 'url(#dropShadow01)');
}
// apply style settings in JSON