mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-22 20:11:24 +01:00
markers - generate tool + lock tooltip
This commit is contained in:
parent
fae03b599f
commit
b3e0d5e7b1
6 changed files with 914 additions and 0 deletions
|
|
@ -4,6 +4,7 @@ window.Markers = (function () {
|
|||
let config = [];
|
||||
let occupied = [];
|
||||
|
||||
<<<<<<< HEAD
|
||||
function getDefaultConfig() {
|
||||
const culturesSet = document.getElementById("culturesSet").value;
|
||||
const isFantasy = culturesSet.includes("Fantasy");
|
||||
|
|
@ -62,10 +63,14 @@ window.Markers = (function () {
|
|||
|
||||
const generate = function () {
|
||||
setConfig(getDefaultConfig());
|
||||
=======
|
||||
const generate = function () {
|
||||
>>>>>>> 01fbfca0 (markers - generate tool + lock tooltip)
|
||||
pack.markers = [];
|
||||
generateTypes();
|
||||
};
|
||||
|
||||
<<<<<<< HEAD
|
||||
const regenerate = () => {
|
||||
pack.markers = pack.markers.filter(({i, lock, cell}) => {
|
||||
if (lock) {
|
||||
|
|
@ -98,6 +103,15 @@ window.Markers = (function () {
|
|||
};
|
||||
|
||||
function generateTypes() {
|
||||
=======
|
||||
const regenerate = requestedMultiplier => {
|
||||
if (requestedMultiplier === 0) return;
|
||||
if (requestedMultiplier) multiplier = requestedMultiplier;
|
||||
generateTypes();
|
||||
};
|
||||
|
||||
const generateTypes = () => {
|
||||
>>>>>>> 01fbfca0 (markers - generate tool + lock tooltip)
|
||||
TIME && console.time("addMarkers");
|
||||
|
||||
config.forEach(({type, icon, dx, dy, px, min, each, multiplier, list, add}) => {
|
||||
|
|
@ -120,11 +134,19 @@ window.Markers = (function () {
|
|||
TIME && console.timeEnd("addMarkers");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
function getQuantity(array, min, each, multiplier) {
|
||||
if (!array.length || array.length < min / multiplier) return 0;
|
||||
const requestQty = Math.ceil((array.length / each) * multiplier);
|
||||
return array.length < requestQty ? array.length : requestQty;
|
||||
}
|
||||
=======
|
||||
const getQuantity = (array, min, each) => {
|
||||
if (!array.length || array.length < min / multiplier) return 0;
|
||||
const requestQty = Math.ceil((array.length / each) * multiplier);
|
||||
return array.length < requestQty ? array.length : requestQty;
|
||||
};
|
||||
>>>>>>> 01fbfca0 (markers - generate tool + lock tooltip)
|
||||
|
||||
function extractAnyElement(array) {
|
||||
const index = Math.floor(Math.random() * array.length);
|
||||
|
|
@ -1140,6 +1162,7 @@ window.Markers = (function () {
|
|||
notes.push({id, name, legend});
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
function listRifts({cells}) {
|
||||
return cells.i.filter(i => !occupied[i] && pack.cells.pop[i] <= 3 && biomesData.habitability[pack.cells.biome[i]]);
|
||||
}
|
||||
|
|
@ -1162,4 +1185,7 @@ window.Markers = (function () {
|
|||
}
|
||||
|
||||
return {add, generate, regenerate, getConfig, setConfig, deleteMarker};
|
||||
=======
|
||||
return {generate, regenerate};
|
||||
>>>>>>> 01fbfca0 (markers - generate tool + lock tooltip)
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -82,6 +82,7 @@ function overviewBurgs() {
|
|||
const province = prov ? pack.provinces[prov].name : '';
|
||||
const culture = pack.cultures[b.culture].name;
|
||||
|
||||
<<<<<<< HEAD
|
||||
lines += /* html */ `<div
|
||||
class="states"
|
||||
data-id=${b.i}
|
||||
|
|
@ -99,13 +100,31 @@ function overviewBurgs() {
|
|||
<select data-tip="Dominant culture. Click to change burg culture (to change cell culture use Cultures Editor)" class="stateCulture">
|
||||
${getCultureOptions(b.culture)}
|
||||
</select>
|
||||
=======
|
||||
lines += `<div class="states" data-id=${b.i} data-name="${
|
||||
b.name
|
||||
}" data-state="${state}" data-province="${province}" data-culture="${culture}" data-population=${population} data-type="${type}">
|
||||
<span data-tip="Click to zoom into view" class="icon-dot-circled pointer"></span>
|
||||
<input data-tip="Burg name. Click and type to change" class="burgName" value="${b.name}" autocorrect="off" spellcheck="false">
|
||||
<input data-tip="Burg province" class="burgState" value="${province}" disabled>
|
||||
<input data-tip="Burg state" class="burgState" value="${state}" disabled>
|
||||
<select data-tip="Dominant culture. Click to change burg culture (to change cell cultrure use Cultures Editor)" class="stateCulture">${getCultureOptions(
|
||||
b.culture
|
||||
)}</select>
|
||||
>>>>>>> 01fbfca0 (markers - generate tool + lock tooltip)
|
||||
<span data-tip="Burg population" class="icon-male"></span>
|
||||
<input data-tip="Burg population. Type to change" class="burgPopulation" value=${si(population)} />
|
||||
<div class="burgType">
|
||||
<<<<<<< HEAD
|
||||
<span
|
||||
data-tip="${b.capital ? " This burg is a state capital" : "Click to assign a capital status"}"
|
||||
class="icon-star-empty${b.capital ? "" : " inactive pointer"}"
|
||||
></span>
|
||||
=======
|
||||
<span data-tip="${b.capital ? " This burg is a state capital" : "Click to assign a capital status"}" class="icon-star-empty${
|
||||
b.capital ? "" : " inactive pointer"
|
||||
}"></span>
|
||||
>>>>>>> 01fbfca0 (markers - generate tool + lock tooltip)
|
||||
<span data-tip="Click to toggle port status" class="icon-anchor pointer${b.port ? "" : " inactive"}" style="font-size:.9em"></span>
|
||||
</div>
|
||||
<span data-tip="Edit burg" class="icon-pencil"></span>
|
||||
|
|
@ -207,6 +226,7 @@ function overviewBurgs() {
|
|||
function toggleBurgLockStatus() {
|
||||
const burgId = +this.parentNode.dataset.id;
|
||||
|
||||
<<<<<<< HEAD
|
||||
const burg = pack.burgs[burgId];
|
||||
burg.lock = !burg.lock;
|
||||
|
||||
|
|
@ -221,6 +241,8 @@ function overviewBurgs() {
|
|||
}
|
||||
}
|
||||
|
||||
=======
|
||||
>>>>>>> 01fbfca0 (markers - generate tool + lock tooltip)
|
||||
function openBurgEditor() {
|
||||
const burg = +this.parentNode.dataset.id;
|
||||
editBurg(burg);
|
||||
|
|
@ -413,6 +435,7 @@ function overviewBurgs() {
|
|||
if (this.value === "provinces") return d.province;
|
||||
};
|
||||
|
||||
<<<<<<< HEAD
|
||||
const mapping = {
|
||||
states: getStatesData,
|
||||
cultures: getCulturesData,
|
||||
|
|
@ -421,6 +444,16 @@ function overviewBurgs() {
|
|||
};
|
||||
|
||||
const base = mapping[this.value]();
|
||||
=======
|
||||
const base =
|
||||
this.value === "states"
|
||||
? getStatesData()
|
||||
: this.value === "cultures"
|
||||
? getCulturesData()
|
||||
: this.value === "parent"
|
||||
? getParentData()
|
||||
: getProvincesData();
|
||||
>>>>>>> 01fbfca0 (markers - generate tool + lock tooltip)
|
||||
burgs.forEach(b => (b.id = b.i + base.length - 1));
|
||||
|
||||
const data = base.concat(burgs);
|
||||
|
|
@ -452,10 +485,17 @@ function overviewBurgs() {
|
|||
}
|
||||
|
||||
function downloadBurgsData() {
|
||||
<<<<<<< HEAD
|
||||
let data = `Id,Burg,Province,Province Full Name,State,State Full Name,Culture,Religion,Population,Latitude,Longitude,Elevation (${heightUnit.value}),Capital,Port,Citadel,Walls,Plaza,Temple,Shanty Town`; // headers
|
||||
if (options.showMFCGMap) data += `,City Generator Link`;
|
||||
data += "\n";
|
||||
|
||||
=======
|
||||
let data =
|
||||
"Id,Burg,Province,Province Full Name,State,State Full Name,Culture,Religion,Population,Longitude,Latitude,Elevation (" +
|
||||
heightUnit.value +
|
||||
"),Capital,Port,Citadel,Walls,Plaza,Temple,Shanty Town\n"; // headers
|
||||
>>>>>>> 01fbfca0 (markers - generate tool + lock tooltip)
|
||||
const valid = pack.burgs.filter(b => b.i && !b.removed); // all valid burgs
|
||||
|
||||
valid.forEach((b) => {
|
||||
|
|
|
|||
|
|
@ -295,6 +295,7 @@ function getBurgSeed(burg) {
|
|||
return burg.MFCG || Number(`${seed}${String(burg.i).padStart(4, 0)}`);
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
function getMFCGlink(burg) {
|
||||
if (burg.link) return burg.link;
|
||||
|
||||
|
|
@ -356,6 +357,8 @@ function getMFCGlink(burg) {
|
|||
return url.toString();
|
||||
}
|
||||
|
||||
=======
|
||||
>>>>>>> 01fbfca0 (markers - generate tool + lock tooltip)
|
||||
// draw legend box
|
||||
function drawLegend(name, data) {
|
||||
legend.selectAll('*').remove(); // fully redraw every time
|
||||
|
|
|
|||
|
|
@ -74,8 +74,13 @@ function showElementLockTip(event) {
|
|||
}
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
const onMouseMove = debounce(handleMouseMove, 100);
|
||||
function handleMouseMove() {
|
||||
=======
|
||||
const moved = debounce(mouseMove, 100);
|
||||
function mouseMove() {
|
||||
>>>>>>> 01fbfca0 (markers - generate tool + lock tooltip)
|
||||
const point = d3.mouse(this);
|
||||
const i = findCell(point[0], point[1]); // pack cell id
|
||||
if (i === undefined) return;
|
||||
|
|
@ -121,11 +126,15 @@ function showMapTooltip(point, e, i, g) {
|
|||
if (group === "emblems" && e.target.tagName === "use") {
|
||||
const parent = e.target.parentNode;
|
||||
const [g, type] =
|
||||
<<<<<<< HEAD
|
||||
parent.id === "burgEmblems"
|
||||
? [pack.burgs, "burg"]
|
||||
: parent.id === "provinceEmblems"
|
||||
? [pack.provinces, "province"]
|
||||
: [pack.states, "state"];
|
||||
=======
|
||||
parent.id === "burgEmblems" ? [pack.burgs, "burg"] : parent.id === "provinceEmblems" ? [pack.provinces, "province"] : [pack.states, "state"];
|
||||
>>>>>>> 01fbfca0 (markers - generate tool + lock tooltip)
|
||||
const i = +e.target.dataset.i;
|
||||
if (event.shiftKey) highlightEmblemElement(type, g[i]);
|
||||
|
||||
|
|
|
|||
|
|
@ -443,11 +443,31 @@ function regenerateIce() {
|
|||
drawIce();
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
function regenerateMarkers() {
|
||||
Markers.regenerate();
|
||||
turnButtonOn("toggleMarkers");
|
||||
drawMarkers();
|
||||
if (document.getElementById("markersOverviewRefresh").offsetParent) markersOverviewRefresh.click();
|
||||
=======
|
||||
function regenerateMarkers(event) {
|
||||
if (isCtrlClick(event)) prompt("Please provide markers number multiplier", {default: 1, step: 0.01, min: 0, max: 100}, v => addNumberOfMarkers(v));
|
||||
else addNumberOfMarkers();
|
||||
|
||||
function addNumberOfMarkers(multiplier) {
|
||||
pack.markers = pack.markers.filter(marker => {
|
||||
if (marker.lock) return true;
|
||||
document.getElementById(`marker${marker.i}`)?.remove();
|
||||
const index = notes.findIndex(note => note.id === marker.id);
|
||||
if (index != -1) notes.splice(index, 1);
|
||||
return false;
|
||||
});
|
||||
|
||||
Markers.regenerate(multiplier);
|
||||
turnButtonOn("toggleMarkers");
|
||||
drawMarkers();
|
||||
}
|
||||
>>>>>>> 01fbfca0 (markers - generate tool + lock tooltip)
|
||||
}
|
||||
|
||||
function regenerateZones(event) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue