mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-22 20:11:24 +01:00
regenerate resources
This commit is contained in:
parent
1c500479a5
commit
65d48da566
3 changed files with 17 additions and 5 deletions
|
|
@ -1927,12 +1927,11 @@ function drawResources() {
|
||||||
function toggleResources(event) {
|
function toggleResources(event) {
|
||||||
if (!layerIsOn("toggleResources")) {
|
if (!layerIsOn("toggleResources")) {
|
||||||
turnButtonOn("toggleResources");
|
turnButtonOn("toggleResources");
|
||||||
$('#goods').fadeIn();
|
drawResources();
|
||||||
if (!goods.selectAll("*").size()) drawResources();
|
|
||||||
if (event && isCtrlClick(event)) editStyle("goods");
|
if (event && isCtrlClick(event)) editStyle("goods");
|
||||||
} else {
|
} else {
|
||||||
if (event && isCtrlClick(event)) {editStyle("goods"); return;}
|
if (event && isCtrlClick(event)) {editStyle("goods"); return;}
|
||||||
$('#goods').fadeOut();
|
goods.selectAll("*").remove();
|
||||||
turnButtonOff("toggleResources");
|
turnButtonOff("toggleResources");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ function editResources() {
|
||||||
|
|
||||||
// add listeners
|
// add listeners
|
||||||
document.getElementById("resourcesEditorRefresh").addEventListener("click", resourcesEditorAddLines);
|
document.getElementById("resourcesEditorRefresh").addEventListener("click", resourcesEditorAddLines);
|
||||||
|
document.getElementById("resourcesRegenerate").addEventListener("click", regenerateResources);
|
||||||
document.getElementById("resourcesLegend").addEventListener("click", toggleLegend);
|
document.getElementById("resourcesLegend").addEventListener("click", toggleLegend);
|
||||||
document.getElementById("resourcesPercentage").addEventListener("click", togglePercentageMode);
|
document.getElementById("resourcesPercentage").addEventListener("click", togglePercentageMode);
|
||||||
document.getElementById("resourcesExport").addEventListener("click", downloadResourcesData);
|
document.getElementById("resourcesExport").addEventListener("click", downloadResourcesData);
|
||||||
|
|
@ -24,6 +25,11 @@ function editResources() {
|
||||||
// add line for each resource
|
// add line for each resource
|
||||||
function resourcesEditorAddLines() {
|
function resourcesEditorAddLines() {
|
||||||
let lines = "";
|
let lines = "";
|
||||||
|
const categories = [...new Set(pack.resources.map(r => r.category))].sort();
|
||||||
|
const categoryOptions = category => categories.map(c => `<option ${c === category ? "selected" : ""} value="${c}">${c}</option>`).join("");
|
||||||
|
|
||||||
|
const models = [...new Set(pack.resources.map(r => r.model))].sort();
|
||||||
|
const modelOptions = model => models.map(m => `<option ${m === model ? "selected" : ""} value="${m}">${m}</option>`).join("");
|
||||||
|
|
||||||
// // {i: 33, name: "Saltpeter", icon: "resource-saltpeter", color: "#e6e3e3", value: 8, chance: 2, model: "habitability", bonus: {artillery: 3}}
|
// // {i: 33, name: "Saltpeter", icon: "resource-saltpeter", color: "#e6e3e3", value: 8, chance: 2, model: "habitability", bonus: {artillery: 3}}
|
||||||
for (const r of pack.resources) {
|
for (const r of pack.resources) {
|
||||||
|
|
@ -36,8 +42,8 @@ function editResources() {
|
||||||
<use href="#${r.icon}" x="10%" y="10%" width="80%" height="80%"/>
|
<use href="#${r.icon}" x="10%" y="10%" width="80%" height="80%"/>
|
||||||
</svg>
|
</svg>
|
||||||
<input data-tip="Resource name. Click and category to change" class="resourceName" value="${r.name}" autocorrect="off" spellcheck="false">
|
<input data-tip="Resource name. Click and category to change" class="resourceName" value="${r.name}" autocorrect="off" spellcheck="false">
|
||||||
<select data-tip="Resource category. Select to change"><option selected>No data</option></select>
|
<select data-tip="Resource category. Select to change">${categoryOptions(r.category)}</select>
|
||||||
<input data-tip="Resource spread model. Select to change" value="${r.model}" class="model"/>
|
<select data-tip="Resource spread model. Select to change" class="model">${modelOptions(r.model)}</select>
|
||||||
|
|
||||||
<input data-tip="Resource basic value. Click and type to change" value="${r.value}" type="number" min=0 max=100 step=1 />
|
<input data-tip="Resource basic value. Click and type to change" value="${r.value}" type="number" min=0 max=100 step=1 />
|
||||||
<input data-tip="Resource generation chance in eligible cell. Click and type to change" value="${r.chance}" type="number" min=0 max=100 step=.1 />
|
<input data-tip="Resource generation chance in eligible cell. Click and type to change" value="${r.chance}" type="number" min=0 max=100 step=.1 />
|
||||||
|
|
|
||||||
|
|
@ -356,6 +356,13 @@ function regenerateResources() {
|
||||||
refreshAllEditors();
|
refreshAllEditors();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function regenerateResources() {
|
||||||
|
Resources.generate();
|
||||||
|
goods.selectAll("*").remove();
|
||||||
|
if (layerIsOn("toggleResources")) drawResources();
|
||||||
|
refreshAllEditors();
|
||||||
|
}
|
||||||
|
|
||||||
function regenerateEmblems() {
|
function regenerateEmblems() {
|
||||||
// remove old emblems
|
// remove old emblems
|
||||||
document.querySelectorAll("[id^=stateCOA]").forEach(el => el.remove());
|
document.querySelectorAll("[id^=stateCOA]").forEach(el => el.remove());
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue