diff --git a/index.css b/index.css
index 9d2bab2b..41b8aedb 100644
--- a/index.css
+++ b/index.css
@@ -1454,14 +1454,19 @@ div.states > .icon {
vertical-align: middle;
}
-div.states > .model {
- width: 7em;
-}
-
div.states > .icon > * {
pointer-events: none;
}
+div.states > .resourceCategory,
+div.states > .resourceModel {
+ cursor: pointer;
+ width: 7em;
+ overflow: hidden;
+ vertical-align: middle;
+ white-space: nowrap;
+}
+
#diplomacyBodySection > div {
cursor: pointer;
}
diff --git a/index.html b/index.html
index b9fa1e9a..5d4bdc06 100644
--- a/index.html
+++ b/index.html
@@ -3006,10 +3006,10 @@
@@ -42,8 +53,8 @@ function editResources() {
-
-
+
${r.category}
+
${model}
@@ -68,6 +79,106 @@ function editResources() {
$("#resourcesEditor").dialog({width: fitContent()});
}
+ function changeName(resource, name, line) {
+ resource.name = line.dataset.name = name;
+ }
+
+ function changeCategory(resource, line, el) {
+ const categories = [...new Set(pack.resources.map(r => r.category))].sort();
+ const categoryOptions = category => categories.map(c => `
`).join("");
+
+ alertMessage.innerHTML = `
+
+
Select category:
+
+
+
+
+ `;
+
+ $("#alert").dialog({resizable: false, title: "Change category",
+ buttons: {
+ Cancel: function() {$(this).dialog("close");},
+ Apply: function() {applyChanges(); $(this).dialog("close");}
+ }
+ });
+
+ function applyChanges() {
+ const custom = document.getElementById("resouceCategoryAdd").value;
+ const select = document.getElementById("resouceCategorySelect").value;
+ const category = custom ? capitalize(custom) : select;
+ resource.category = line.dataset.category = el.innerHTML = category;
+ }
+ }
+
+ function changeModel(resource, line, el) {
+ const defaultModels = Resources.defaultModels;
+ const model = line.dataset.model;
+ const modelOptions = Object.keys(defaultModels).map(m => `
`).join("");
+ const wikiURL = "https://github.com/Azgaar/Fantasy-Map-Generator/wiki/Resources:-spread-functions";
+
+ alertMessage.innerHTML = `
+
+
+
+
+
+ `;
+
+ $("#alert").dialog({resizable: false, title: "Change spread model",
+ buttons: {
+ Help: () => openURL(wikiURL),
+ Cancel: function() {$(this).dialog("close");},
+ Apply: function() {applyChanges(this);}
+ }
+ });
+
+ function applyChanges(dialog) {
+ const customName = document.getElementById("resouceModelCustomName").value;
+ const customFn = document.getElementById("resouceModelCustomFunction").value;
+
+ const message = document.getElementById("resourceModelMessage");
+ if (customName && !customFn) return message.innerHTML = "Error. Custom model function is required";
+ if (!customName && customFn) return message.innerHTML = "Error. Custom model name is required";
+ message.innerHTML = "";
+
+ if (customName && customFn) {
+ resource.model = line.dataset.model = el.innerHTML = customName;
+ resource.custom = customFn;
+ return;
+ }
+
+ const model = document.getElementById("resouceModelSelect").value;
+ resource.model = line.dataset.model = el.innerHTML = model;
+ $(dialog).dialog("close");
+ }
+ }
+
function resourceChangeColor() {
const circle = this.querySelector("circle");
const resource = Resources.get(+this.parentNode.dataset.id);