mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 01:41:22 +01:00
states-editor - dynamic module
This commit is contained in:
parent
c87c12295b
commit
4fcd62bb99
7 changed files with 1360 additions and 1345 deletions
113
index.html
113
index.html
|
|
@ -3083,110 +3083,6 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="statesEditor" class="dialog stable" style="display: none">
|
|
||||||
<div id="statesHeader" class="header">
|
|
||||||
<div style="left: 1.8em" data-tip="Click to sort by state name" class="sortable alphabetically" data-sortby="name">State </div>
|
|
||||||
<div style="left: 9.7em" data-tip="Click to sort by state form name" class="sortable alphabetically" data-sortby="form">Form </div>
|
|
||||||
<div style="left: 16.3em" data-tip="Click to sort by capital name" class="sortable alphabetically hide" data-sortby="capital">Capital </div>
|
|
||||||
<div style="left: 23em" data-tip="Click to sort by state dominant culture" class="sortable alphabetically hide" data-sortby="culture">
|
|
||||||
Culture
|
|
||||||
</div>
|
|
||||||
<div style="left: 27.8em" data-tip="Click to sort by state burgs count" class="sortable hide" data-sortby="burgs">Burgs </div>
|
|
||||||
<div style="left: 32.5em" data-tip="Click to sort by state area" class="sortable hide icon-sort-number-down" data-sortby="area">Area </div>
|
|
||||||
<div style="left: 37em" data-tip="Click to sort by state population" class="sortable hide" data-sortby="population">Population </div>
|
|
||||||
<div style="left: 43.5em" data-tip="Click to sort by state type" class="sortable alphabetically hidden show hide" data-sortby="type">Type </div>
|
|
||||||
<div style="left: 47em" data-tip="Click to sort by state expansion value" class="sortable hidden show hide" data-sortby="expansionism">
|
|
||||||
Expansion
|
|
||||||
</div>
|
|
||||||
<div style="left: 53.5em" data-tip="Click to sort by state cells count" class="sortable hidden show hide" data-sortby="cells">Cells </div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="statesBodySection" class="table" data-type="absolute"></div>
|
|
||||||
|
|
||||||
<div id="statesFooter" class="totalLine">
|
|
||||||
<div data-tip="States number" style="margin-left: 5px">States: <span id="statesFooterStates">0</span></div>
|
|
||||||
<div data-tip="Total land cells number" style="margin-left: 12px">Cells: <span id="statesFooterCells">0</span></div>
|
|
||||||
<div data-tip="Total burgs number" style="margin-left: 12px">Burgs: <span id="statesFooterBurgs">0</span></div>
|
|
||||||
<div data-tip="Total land area" style="margin-left: 12px">Land Area: <span id="statesFooterArea">0</span></div>
|
|
||||||
<div data-tip="Total population" style="margin-left: 12px">Population: <span id="statesFooterPopulation">0</span></div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="statesBottom">
|
|
||||||
<button id="statesEditorRefresh" data-tip="Refresh the Editor" class="icon-cw"></button>
|
|
||||||
<button id="statesEditStyle" data-tip="Edit states style in Style Editor" class="icon-adjust"></button>
|
|
||||||
<button id="statesLegend" data-tip="Toggle Legend box" class="icon-list-bullet"></button>
|
|
||||||
<button id="statesPercentage" data-tip="Toggle percentage / absolute values views" class="icon-percent"></button>
|
|
||||||
<button id="statesChart" data-tip="Show states bubble chart" class="icon-chart-area"></button>
|
|
||||||
|
|
||||||
<button id="statesRegenerate" data-tip="Show the regeneration menu and more data" class="icon-cog-alt"></button>
|
|
||||||
<div id="statesRegenerateButtons" style="display: none">
|
|
||||||
<button id="statesRegenerateBack" data-tip="Hide the regeneration menu" class="icon-cog-alt"></button>
|
|
||||||
<button id="statesRandomize" data-tip="Randomize states Expansion value and re-calculate states and provinces" class="icon-shuffle"></button>
|
|
||||||
<span data-tip="Additional growth rate. Defines how many lands will stay neutral">
|
|
||||||
<label class="italic">Growth rate:</label>
|
|
||||||
<input
|
|
||||||
id="statesNeutral"
|
|
||||||
oninput="tip('Growth rate: '+this.value); statesNeutralNumber.value = this.value"
|
|
||||||
type="range"
|
|
||||||
min=".1"
|
|
||||||
max="3"
|
|
||||||
step=".05"
|
|
||||||
value="1"
|
|
||||||
style="width: 90px"
|
|
||||||
/>
|
|
||||||
<input
|
|
||||||
id="statesNeutralNumber"
|
|
||||||
oninput="tip('Growth rate: '+this.value); statesNeutral.value = this.value"
|
|
||||||
type="number"
|
|
||||||
min=".1"
|
|
||||||
max="3"
|
|
||||||
step=".05"
|
|
||||||
value="1"
|
|
||||||
style="width: 42px"
|
|
||||||
/>
|
|
||||||
</span>
|
|
||||||
<button id="statesRecalculate" data-tip="Recalculate states based on current values of growth-related attributes" class="icon-retweet"></button>
|
|
||||||
<span data-tip="Allow states neutral distance, expansion and type changes to take an immediate effect">
|
|
||||||
<input id="statesAutoChange" class="checkbox" type="checkbox" />
|
|
||||||
<label for="statesAutoChange" class="checkbox-label"><i>auto-apply changes</i></label>
|
|
||||||
</span>
|
|
||||||
<span data-tip="Allow system to change state labels when states data is change">
|
|
||||||
<input id="adjustLabels" class="checkbox" type="checkbox" />
|
|
||||||
<label for="adjustLabels" class="checkbox-label"><i>auto-change labels</i></label>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<button id="statesManually" data-tip="Manually re-assign states" class="icon-brush"></button>
|
|
||||||
<div id="statesManuallyButtons" style="display: none">
|
|
||||||
<label data-tip="Change brush size. Shortcut: + (increase), – (decrease)" class="italic"
|
|
||||||
>Brush size:
|
|
||||||
<input
|
|
||||||
id="statesManuallyBrush"
|
|
||||||
oninput="tip('Brush size: '+this.value); statesManuallyBrushNumber.value = this.value"
|
|
||||||
type="range"
|
|
||||||
min="5"
|
|
||||||
max="99"
|
|
||||||
value="15"
|
|
||||||
style="width: 5em"
|
|
||||||
/>
|
|
||||||
<input
|
|
||||||
id="statesManuallyBrushNumber"
|
|
||||||
oninput="tip('Brush size: '+this.value); statesManuallyBrush.value = this.value"
|
|
||||||
type="number"
|
|
||||||
min="5"
|
|
||||||
max="99"
|
|
||||||
value="15"
|
|
||||||
/> </label
|
|
||||||
><br />
|
|
||||||
<button id="statesManuallyApply" data-tip="Apply assignment" class="icon-check"></button>
|
|
||||||
<button id="statesManuallyCancel" data-tip="Cancel assignment" class="icon-cancel"></button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<button id="statesAdd" data-tip="Add a new state. Hold Shift to add multiple" class="icon-plus"></button>
|
|
||||||
<button id="statesExport" data-tip="Save state-related data as a text file (.csv)" class="icon-download"></button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="stateNameEditor" class="dialog" data-state="0" style="display: none">
|
<div id="stateNameEditor" class="dialog" data-state="0" style="display: none">
|
||||||
<div>
|
<div>
|
||||||
<div data-tip="State short name" class="label">Short name:</div>
|
<div data-tip="State short name" class="label">Short name:</div>
|
||||||
|
|
@ -6278,7 +6174,7 @@
|
||||||
<script src="modules/lakes.js"></script>
|
<script src="modules/lakes.js"></script>
|
||||||
<script src="modules/names-generator.js"></script>
|
<script src="modules/names-generator.js"></script>
|
||||||
<script src="modules/cultures-generator.js"></script>
|
<script src="modules/cultures-generator.js"></script>
|
||||||
<script src="modules/burgs-and-states.js?v=14052022"></script>
|
<script src="modules/burgs-and-states.js?v=15052022"></script>
|
||||||
<script src="modules/routes-generator.js"></script>
|
<script src="modules/routes-generator.js"></script>
|
||||||
<script src="modules/religions-generator.js"></script>
|
<script src="modules/religions-generator.js"></script>
|
||||||
<script src="modules/military-generator.js"></script>
|
<script src="modules/military-generator.js"></script>
|
||||||
|
|
@ -6293,17 +6189,16 @@
|
||||||
<script src="modules/ui/measurers.js"></script>
|
<script src="modules/ui/measurers.js"></script>
|
||||||
<script src="modules/ui/stylePresets.js"></script>
|
<script src="modules/ui/stylePresets.js"></script>
|
||||||
|
|
||||||
<script src="modules/ui/general.js"></script>
|
<script src="modules/ui/general.js?v=15052022"></script>
|
||||||
<script src="modules/ui/options.js?v=14052022"></script>
|
<script src="modules/ui/options.js?v=14052022"></script>
|
||||||
<script src="main.js?v=14052022"></script>
|
<script src="main.js?v=15052022"></script>
|
||||||
|
|
||||||
<script defer src="modules/relief-icons.js"></script>
|
<script defer src="modules/relief-icons.js"></script>
|
||||||
<script defer src="modules/ui/style.js"></script>
|
<script defer src="modules/ui/style.js"></script>
|
||||||
|
<script defer src="modules/ui/editors.js?v=15052022"></script>
|
||||||
<script defer src="modules/ui/tools.js"></script>
|
<script defer src="modules/ui/tools.js"></script>
|
||||||
<script defer src="modules/ui/world-configurator.js"></script>
|
<script defer src="modules/ui/world-configurator.js"></script>
|
||||||
<script defer src="modules/ui/editors.js"></script>
|
|
||||||
<script defer src="modules/ui/heightmap-editor.js"></script>
|
<script defer src="modules/ui/heightmap-editor.js"></script>
|
||||||
<script defer src="modules/ui/states-editor.js"></script>
|
|
||||||
<script defer src="modules/ui/provinces-editor.js"></script>
|
<script defer src="modules/ui/provinces-editor.js"></script>
|
||||||
<script defer src="modules/ui/biomes-editor.js"></script>
|
<script defer src="modules/ui/biomes-editor.js"></script>
|
||||||
<script defer src="modules/ui/cultures-editor.js"></script>
|
<script defer src="modules/ui/cultures-editor.js"></script>
|
||||||
|
|
|
||||||
1
main.js
1
main.js
|
|
@ -168,6 +168,7 @@ let populationRate = +document.getElementById("populationRateInput").value;
|
||||||
let distanceScale = +document.getElementById("distanceScaleInput").value;
|
let distanceScale = +document.getElementById("distanceScaleInput").value;
|
||||||
let urbanization = +document.getElementById("urbanizationInput").value;
|
let urbanization = +document.getElementById("urbanizationInput").value;
|
||||||
let urbanDensity = +document.getElementById("urbanDensityInput").value;
|
let urbanDensity = +document.getElementById("urbanDensityInput").value;
|
||||||
|
let statesNeutral = 1; // statesEditor growth parameter
|
||||||
|
|
||||||
applyStoredOptions();
|
applyStoredOptions();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -352,7 +352,7 @@ window.BurgsAndStates = (function () {
|
||||||
cells.state = new Uint16Array(cells.i.length);
|
cells.state = new Uint16Array(cells.i.length);
|
||||||
const queue = new PriorityQueue({comparator: (a, b) => a.p - b.p});
|
const queue = new PriorityQueue({comparator: (a, b) => a.p - b.p});
|
||||||
const cost = [];
|
const cost = [];
|
||||||
const neutral = (cells.i.length / 5000) * 2500 * neutralInput.value * statesNeutral.value; // limit cost for state growth
|
const neutral = (cells.i.length / 5000) * 2500 * neutralInput.value * statesNeutral; // limit cost for state growth
|
||||||
|
|
||||||
states
|
states
|
||||||
.filter(s => s.i && !s.removed)
|
.filter(s => s.i && !s.removed)
|
||||||
|
|
|
||||||
1334
modules/dynamic/editors/states-editor.js
Normal file
1334
modules/dynamic/editors/states-editor.js
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -1093,3 +1093,10 @@ function refreshAllEditors() {
|
||||||
if (document.getElementById("zonesEditorRefresh").offsetParent) zonesEditorRefresh.click();
|
if (document.getElementById("zonesEditorRefresh").offsetParent) zonesEditorRefresh.click();
|
||||||
TIME && console.timeEnd("refreshAllEditors");
|
TIME && console.timeEnd("refreshAllEditors");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// dynamically loaded editors
|
||||||
|
async function editStates() {
|
||||||
|
if (customization) return;
|
||||||
|
const StateEditor = await import("../dynamic/editors/states-editor.js");
|
||||||
|
StateEditor.open();
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -75,12 +75,12 @@ function handleMouseMove() {
|
||||||
const g = findGridCell(point[0], point[1]); // grid cell id
|
const g = findGridCell(point[0], point[1]); // grid cell id
|
||||||
if (tooltip.dataset.main) showMainTip();
|
if (tooltip.dataset.main) showMainTip();
|
||||||
else showMapTooltip(point, d3.event, i, g);
|
else showMapTooltip(point, d3.event, i, g);
|
||||||
if (cellInfo.offsetParent) updateCellInfo(point, i, g);
|
if (cellInfo?.offsetParent) updateCellInfo(point, i, g);
|
||||||
}
|
}
|
||||||
|
|
||||||
// show note box on hover (if any)
|
// show note box on hover (if any)
|
||||||
function showNotes(e) {
|
function showNotes(e) {
|
||||||
if (notesEditor.offsetParent) return;
|
if (notesEditor?.offsetParent) return;
|
||||||
let id = e.target.id || e.target.parentNode.id || e.target.parentNode.parentNode.id;
|
let id = e.target.id || e.target.parentNode.id || e.target.parentNode.parentNode.id;
|
||||||
if (e.target.parentNode.parentNode.id === "burgLabels") id = "burg" + e.target.dataset.id;
|
if (e.target.parentNode.parentNode.id === "burgLabels") id = "burg" + e.target.dataset.id;
|
||||||
else if (e.target.parentNode.parentNode.id === "burgIcons") id = "burg" + e.target.dataset.id;
|
else if (e.target.parentNode.parentNode.id === "burgIcons") id = "burg" + e.target.dataset.id;
|
||||||
|
|
@ -90,7 +90,7 @@ function showNotes(e) {
|
||||||
document.getElementById("notes").style.display = "block";
|
document.getElementById("notes").style.display = "block";
|
||||||
document.getElementById("notesHeader").innerHTML = note.name;
|
document.getElementById("notesHeader").innerHTML = note.name;
|
||||||
document.getElementById("notesBody").innerHTML = note.legend;
|
document.getElementById("notesBody").innerHTML = note.legend;
|
||||||
} else if (!options.pinNotes && !markerEditor.offsetParent) {
|
} else if (!options.pinNotes && !markerEditor?.offsetParent) {
|
||||||
document.getElementById("notes").style.display = "none";
|
document.getElementById("notes").style.display = "none";
|
||||||
document.getElementById("notesHeader").innerHTML = "";
|
document.getElementById("notesHeader").innerHTML = "";
|
||||||
document.getElementById("notesBody").innerHTML = "";
|
document.getElementById("notesBody").innerHTML = "";
|
||||||
|
|
@ -129,7 +129,7 @@ function showMapTooltip(point, e, i, g) {
|
||||||
const r = pack.rivers.find(r => r.i === river);
|
const r = pack.rivers.find(r => r.i === river);
|
||||||
const name = r ? r.name + " " + r.type : "";
|
const name = r ? r.name + " " + r.type : "";
|
||||||
tip(name + ". Click to edit");
|
tip(name + ". Click to edit");
|
||||||
if (riversOverview.offsetParent) highlightEditorLine(riversOverview, river, 5000);
|
if (riversOverview?.offsetParent) highlightEditorLine(riversOverview, river, 5000);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -142,7 +142,7 @@ function showMapTooltip(point, e, i, g) {
|
||||||
const b = pack.burgs[burg];
|
const b = pack.burgs[burg];
|
||||||
const population = si(b.population * populationRate * urbanization);
|
const population = si(b.population * populationRate * urbanization);
|
||||||
tip(`${b.name}. Population: ${population}. Click to edit`);
|
tip(`${b.name}. Population: ${population}. Click to edit`);
|
||||||
if (burgsOverview.offsetParent) highlightEditorLine(burgsOverview, burg, 5000);
|
if (burgsOverview?.offsetParent) highlightEditorLine(burgsOverview, burg, 5000);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (group === "labels") return tip("Click to edit the Label");
|
if (group === "labels") return tip("Click to edit the Label");
|
||||||
|
|
@ -176,7 +176,7 @@ function showMapTooltip(point, e, i, g) {
|
||||||
if (group === "zones") {
|
if (group === "zones") {
|
||||||
const zone = path[path.length - 8];
|
const zone = path[path.length - 8];
|
||||||
tip(zone.dataset.description);
|
tip(zone.dataset.description);
|
||||||
if (zonesEditor.offsetParent) highlightEditorLine(zonesEditor, zone.id, 5000);
|
if (zonesEditor?.offsetParent) highlightEditorLine(zonesEditor, zone.id, 5000);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -189,27 +189,27 @@ function showMapTooltip(point, e, i, g) {
|
||||||
else if (layerIsOn("toggleBiomes") && pack.cells.biome[i]) {
|
else if (layerIsOn("toggleBiomes") && pack.cells.biome[i]) {
|
||||||
const biome = pack.cells.biome[i];
|
const biome = pack.cells.biome[i];
|
||||||
tip("Biome: " + biomesData.name[biome]);
|
tip("Biome: " + biomesData.name[biome]);
|
||||||
if (biomesEditor.offsetParent) highlightEditorLine(biomesEditor, biome);
|
if (biomesEditor?.offsetParent) highlightEditorLine(biomesEditor, biome);
|
||||||
} else if (layerIsOn("toggleReligions") && pack.cells.religion[i]) {
|
} else if (layerIsOn("toggleReligions") && pack.cells.religion[i]) {
|
||||||
const religion = pack.cells.religion[i];
|
const religion = pack.cells.religion[i];
|
||||||
const r = pack.religions[religion];
|
const r = pack.religions[religion];
|
||||||
const type = r.type === "Cult" || r.type == "Heresy" ? r.type : r.type + " religion";
|
const type = r.type === "Cult" || r.type == "Heresy" ? r.type : r.type + " religion";
|
||||||
tip(type + ": " + r.name);
|
tip(type + ": " + r.name);
|
||||||
if (religionsEditor.offsetParent) highlightEditorLine(religionsEditor, religion);
|
if (religionsEditor?.offsetParent) highlightEditorLine(religionsEditor, religion);
|
||||||
} else if (pack.cells.state[i] && (layerIsOn("toggleProvinces") || layerIsOn("toggleStates"))) {
|
} else if (pack.cells.state[i] && (layerIsOn("toggleProvinces") || layerIsOn("toggleStates"))) {
|
||||||
const state = pack.cells.state[i];
|
const state = pack.cells.state[i];
|
||||||
const stateName = pack.states[state].fullName;
|
const stateName = pack.states[state].fullName;
|
||||||
const province = pack.cells.province[i];
|
const province = pack.cells.province[i];
|
||||||
const prov = province ? pack.provinces[province].fullName + ", " : "";
|
const prov = province ? pack.provinces[province].fullName + ", " : "";
|
||||||
tip(prov + stateName);
|
tip(prov + stateName);
|
||||||
if (statesEditor.offsetParent) highlightEditorLine(statesEditor, state);
|
if (statesEditor?.offsetParent) highlightEditorLine(statesEditor, state);
|
||||||
if (diplomacyEditor.offsetParent) highlightEditorLine(diplomacyEditor, state);
|
if (diplomacyEditor?.offsetParent) highlightEditorLine(diplomacyEditor, state);
|
||||||
if (militaryOverview.offsetParent) highlightEditorLine(militaryOverview, state);
|
if (militaryOverview?.offsetParent) highlightEditorLine(militaryOverview, state);
|
||||||
if (provincesEditor.offsetParent) highlightEditorLine(provincesEditor, province);
|
if (provincesEditor?.offsetParent) highlightEditorLine(provincesEditor, province);
|
||||||
} else if (layerIsOn("toggleCultures") && pack.cells.culture[i]) {
|
} else if (layerIsOn("toggleCultures") && pack.cells.culture[i]) {
|
||||||
const culture = pack.cells.culture[i];
|
const culture = pack.cells.culture[i];
|
||||||
tip("Culture: " + pack.cultures[culture].name);
|
tip("Culture: " + pack.cultures[culture].name);
|
||||||
if (culturesEditor.offsetParent) highlightEditorLine(culturesEditor, culture);
|
if (culturesEditor?.offsetParent) highlightEditorLine(culturesEditor, culture);
|
||||||
} else if (layerIsOn("toggleHeight")) tip("Height: " + getFriendlyHeight(point));
|
} else if (layerIsOn("toggleHeight")) tip("Height: " + getFriendlyHeight(point));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue