This commit is contained in:
Azgaar 2019-12-23 20:06:43 +03:00
parent f684996f82
commit bc6b8cdafe
18 changed files with 111 additions and 111 deletions

View file

@ -5,11 +5,11 @@
}(this, (function () {'use strict';
// set default options
const options = {scale: 50, lightness: .7, shadow: .5, sun: {x: 100, y: 600, z: 1000}, rotateMesh: 0, rotateGlobe: .5,
const options = {scale: 50, lightness: .7, shadow: .5, sun: {x: 100, y: 600, z: 1000}, rotateMesh: 0, rotateGlobe: .5,
skyColor: "#9ecef5", waterColor: "#53679f", extendedWater: 0, resolution: 2};
// set variables
let Renderer, scene, camera, controls, animationFrame, material, texture,
let Renderer, scene, camera, controls, animationFrame, material, texture,
geometry, mesh, ambientLight, spotLight, waterPlane, waterMaterial, waterMesh;
// initiate 3d scene
@ -157,7 +157,7 @@ async function newMesh(canvas) {
// controls
controls = await OrbitControls(camera, canvas);
controls.enableKeys = false;
controls.minDistance = 10;
controls.minDistance = 10;
controls.maxDistance = 1000;
controls.maxPolarAngle = Math.PI/2;
controls.autoRotate = Boolean(options.rotateMesh);

View file

@ -132,7 +132,7 @@ function editBiomes() {
const color = biomesData.color[biome];
biomes.select("#biome"+biome).transition().attr("stroke-width", .7).attr("stroke", color);
}
function biomeChangeColor(el) {
const currentFill = el.getAttribute("fill");
const biome = +el.parentNode.parentNode.dataset.id;
@ -145,7 +145,7 @@ function editBiomes() {
openPicker(currentFill, callback);
}
function biomeChangeName(el) {
const biome = +el.parentNode.dataset.id;
el.parentNode.dataset.name = el.value;
@ -200,12 +200,12 @@ function editBiomes() {
body.dataset.type = "percentage";
const totalCells = +biomesFooterCells.innerHTML;
const totalArea = +biomesFooterArea.dataset.area;
const totalPopulation = +biomesFooterPopulation.dataset.population;
const totalPopulation = +biomesFooterPopulation.dataset.population;
body.querySelectorAll(":scope> div").forEach(function(el) {
el.querySelector(".biomeCells").innerHTML = rn(+el.dataset.cells / totalCells * 100) + "%";
el.querySelector(".biomeArea").innerHTML = rn(+el.dataset.area / totalArea * 100) + "%";
el.querySelector(".biomePopulation").innerHTML = rn(+el.dataset.population / totalPopulation * 100) + "%";
el.querySelector(".biomePopulation").innerHTML = rn(+el.dataset.population / totalPopulation * 100) + "%";
});
} else {
body.dataset.type = "absolute";
@ -314,7 +314,7 @@ function editBiomes() {
const biome = assigned.size() ? +assigned.attr("data-biome") : pack.cells.biome[i];
body.querySelector("div.selected").classList.remove("selected");
body.querySelector("div[data-id='"+biome+"']").classList.add("selected");
body.querySelector("div[data-id='"+biome+"']").classList.add("selected");
}
function dragBiomeBrush() {
@ -324,7 +324,7 @@ function editBiomes() {
if (!d3.event.dx && !d3.event.dy) return;
const p = d3.mouse(this);
moveCircle(p[0], p[1], r);
const found = r > 5 ? findAll(p[0], p[1], r) : [findCell(p[0], p[1], r)];
const selection = found.filter(isLand);
if (selection) changeBiomeForSelection(selection);
@ -356,7 +356,7 @@ function editBiomes() {
const radius = +biomesManuallyBrush.value;
moveCircle(point[0], point[1], radius);
}
function applyBiomesChange() {
const changed = biomes.select("#temp").selectAll("polygon");
changed.each(function() {
@ -364,7 +364,7 @@ function editBiomes() {
const b = +this.dataset.biome;
pack.cells.biome[i] = b;
});
if (changed.size()) {
drawBiomes();
refreshBiomesEditor();
@ -390,7 +390,7 @@ function editBiomes() {
const selected = document.querySelector("#biomesBody > div.selected");
if (selected) selected.classList.remove("selected");
}
function restoreInitialBiomes() {
biomesData = applyDefaultBiomesSystem();
defineBiomes();

View file

@ -15,7 +15,7 @@ function editBurg(id) {
const of = id ? "svg" : d3.event.target;
$("#burgEditor").dialog({
title: "Edit Burg", resizable: false, close: closeBurgEditor,
title: "Edit Burg", resizable: false, close: closeBurgEditor,
position: {my, at, of, collision: "fit"}
});
@ -56,19 +56,19 @@ function editBurg(id) {
document.getElementById("burgEditAnchorStyle").style.display = +b.port ? "inline-block" : "none";
// toggle features
if (b.capital) document.getElementById("burgCapital").classList.remove("inactive");
if (b.capital) document.getElementById("burgCapital").classList.remove("inactive");
else document.getElementById("burgCapital").classList.add("inactive");
if (b.port) document.getElementById("burgPort").classList.remove("inactive");
if (b.port) document.getElementById("burgPort").classList.remove("inactive");
else document.getElementById("burgPort").classList.add("inactive");
if (b.citadel) document.getElementById("burgCitadel").classList.remove("inactive");
if (b.citadel) document.getElementById("burgCitadel").classList.remove("inactive");
else document.getElementById("burgCitadel").classList.add("inactive");
if (b.walls) document.getElementById("burgWalls").classList.remove("inactive");
if (b.walls) document.getElementById("burgWalls").classList.remove("inactive");
else document.getElementById("burgWalls").classList.add("inactive");
if (b.plaza) document.getElementById("burgPlaza").classList.remove("inactive");
if (b.plaza) document.getElementById("burgPlaza").classList.remove("inactive");
else document.getElementById("burgPlaza").classList.add("inactive");
if (b.temple) document.getElementById("burgTemple").classList.remove("inactive");
if (b.temple) document.getElementById("burgTemple").classList.remove("inactive");
else document.getElementById("burgTemple").classList.add("inactive");
if (b.shanty) document.getElementById("burgShanty").classList.remove("inactive");
if (b.shanty) document.getElementById("burgShanty").classList.remove("inactive");
else document.getElementById("burgShanty").classList.add("inactive");
// select group
@ -102,7 +102,7 @@ function editBurg(id) {
document.getElementById("burgGroupSection").style.display = "none";
document.getElementById("burgInputGroup").style.display = "none";
document.getElementById("burgInputGroup").value = "";
document.getElementById("burgSelectGroup").style.display = "inline-block";
document.getElementById("burgSelectGroup").style.display = "inline-block";
}
function changeGroup() {
@ -187,7 +187,7 @@ function editBurg(id) {
const burgsToRemove = burgsInGroup.filter(b => !pack.burgs[b].capital);
const capital = burgsToRemove.length < burgsInGroup.length;
alertMessage.innerHTML = `Are you sure you want to remove
alertMessage.innerHTML = `Are you sure you want to remove
${basic || capital ? "all elements in the group" : "the entire burg group"}?
<br>Please note that capital burgs will not be deleted.
<br><br>Burgs to be removed: ${burgsToRemove.length}`;
@ -243,7 +243,7 @@ function editBurg(id) {
const b = pack.burgs[id];
const feature = this.dataset.feature;
const turnOn = this.classList.contains("inactive");
if (feature === "port") togglePort(id);
if (feature === "port") togglePort(id);
else if(feature === "capital") toggleCapital(id);
else b[feature] = +turnOn;
if (b[feature]) this.classList.remove("inactive");
@ -284,7 +284,7 @@ function editBurg(id) {
const defSeed = seed + id.padStart(4, 0);
if (event.ctrlKey) {
const newSeed = prompt(`Please provide a Medieval Fantasy City Generator seed. `+
const newSeed = prompt(`Please provide a Medieval Fantasy City Generator seed. `+
`Seed should be a number. Default seed is FMG map seed + burg id padded to 4 chars with zeros (${defSeed}). `+
`Please note that if seed is custom, "Overworld" button from MFCG will open a different map`, burg.MFCG || defSeed);
if (newSeed) burg.MFCG = newSeed; else return;
@ -315,7 +315,7 @@ function editBurg(id) {
const defSeed = `${seed}-b${id}`;
if (event.ctrlKey) {
const newSeed = prompt(`Please provide an Iron Arachne Heraldry Generator seed. `+
const newSeed = prompt(`Please provide an Iron Arachne Heraldry Generator seed. `+
`Default seed is a combination of FMG map seed and burg id (${defSeed})`, burg.IAHG || defSeed);
if (newSeed) burg.IAHG = newSeed; else return;
}

View file

@ -344,8 +344,8 @@ function overviewBurgs() {
if (this.value === "provinces") return d.province;
}
const base = this.value === "states" ? getStatesData()
: this.value === "cultures" ? getCulturesData()
const base = this.value === "states" ? getStatesData()
: this.value === "cultures" ? getCulturesData()
: this.value === "parent" ? getParentData() : getProvincesData();
burgs.forEach(b => b.id = b.i+base.length-1);
@ -401,7 +401,7 @@ function overviewBurgs() {
}
function renameBurgsInBulk() {
const message = `Download burgs list as a text file, make changes and re-upload the file.
const message = `Download burgs list as a text file, make changes and re-upload the file.
If you do not want to change the name, just leave it as is`;
alertMessage.innerHTML = message;

View file

@ -82,7 +82,7 @@ function editCoastline(node = d3.event.target) {
document.getElementById("coastlineGroupsSelection").style.display = "none";
document.getElementById("coastlineGroupName").style.display = "none";
document.getElementById("coastlineGroupName").value = "";
document.getElementById("coastlineGroup").style.display = "inline-block";
document.getElementById("coastlineGroup").style.display = "inline-block";
}
function selectCoastlineGroup(node) {
@ -107,7 +107,7 @@ function editCoastline(node = d3.event.target) {
} else {
coastlineGroupName.style.display = "none";
coastlineGroup.style.display = "inline-block";
}
}
}
function createNewGroup() {
@ -146,7 +146,7 @@ function editCoastline(node = d3.event.target) {
toggleNewGroupInput();
document.getElementById("coastlineGroupName").value = "";
}
function removeCoastlineGroup() {
const group = elSelected.node().parentNode.id;
if (["sea_island", "lake_island"].includes(group)) {
@ -155,7 +155,7 @@ function editCoastline(node = d3.event.target) {
}
const count = elSelected.node().parentNode.childElementCount;
alertMessage.innerHTML = `Are you sure you want to remove the group?
alertMessage.innerHTML = `Are you sure you want to remove the group?
All coastline elements of the group (${count}) will be moved under <i>sea_island</i> group`;
$("#alert").dialog({resizable: false, title: "Remove coastline group", width:"26em",
buttons: {

View file

@ -142,13 +142,13 @@ function editCultures() {
types.forEach(t => options += `<option ${type === t ? "selected" : ""} value="${t}">${t}</option>`);
return options;
}
function getBaseOptions(base) {
let options = "";
nameBases.forEach((n, i) => options += `<option ${base === i ? "selected" : ""} value="${i}">${n.name}</option>`);
return options;
}
function cultureHighlightOn(event) {
const culture = +event.target.dataset.id;
const info = document.getElementById("cultureInfo");
@ -420,7 +420,7 @@ function editCultures() {
}
$("#alert").dialog({
title: "Cultures tree", width: fitContent(), resizable: false,
title: "Cultures tree", width: fitContent(), resizable: false,
position: {my: "left center", at: "left+10 center", of: "svg"}, buttons: {},
close: () => {alertMessage.innerHTML = "";}
});
@ -471,7 +471,7 @@ function editCultures() {
pack.burgs.forEach(b => b.culture = pack.cells.culture[b.cell]);
refreshCulturesEditor();
}
function enterCultureManualAssignent() {
if (!layerIsOn("toggleCultures")) toggleCultures();
customization = 4;
@ -521,7 +521,7 @@ function editCultures() {
if (!d3.event.dx && !d3.event.dy) return;
const p = d3.mouse(this);
moveCircle(p[0], p[1], r);
const found = r > 5 ? findAll(p[0], p[1], r) : [findCell(p[0], p[1], r)];
const selection = found.filter(isLand);
if (selection) changeCultureForSelection(selection);
@ -589,7 +589,7 @@ function editCultures() {
const selected = body.querySelector("div.selected");
if (selected) selected.classList.remove("selected");
}
function enterAddCulturesMode() {
if (this.classList.contains("pressed")) {exitAddCultureMode(); return;};
customization = 9;
@ -624,7 +624,7 @@ function editCultures() {
function downloadCulturesData() {
const unit = areaUnit.value === "square" ? distanceUnitInput.value + "2" : areaUnit.value;
let data = "Id,Culture,Color,Cells,Expansionism,Type,Area "+unit+",Population,Namesbase\n"; // headers
body.querySelectorAll(":scope > div").forEach(function(el) {
data += el.dataset.id + ",";
data += el.dataset.name + ",";