diff --git a/index.html b/index.html index 3c5aa05d..730f69e4 100644 --- a/index.html +++ b/index.html @@ -2739,13 +2739,13 @@
-
Click on state name to see relations.
Click on relations name to change it
+ diff --git a/modules/ui/diplomacy-editor.js b/modules/ui/diplomacy-editor.js index 9418f176..e28fe2d3 100644 --- a/modules/ui/diplomacy-editor.js +++ b/modules/ui/diplomacy-editor.js @@ -43,6 +43,7 @@ function editDiplomacy() { document.getElementById("diplomacyEditorRefresh").addEventListener("click", refreshDiplomacyEditor); document.getElementById("diplomacyEditStyle").addEventListener("click", () => editStyle("regions")); document.getElementById("diplomacyRegenerate").addEventListener("click", regenerateRelations); + document.getElementById("diplomacyReset").addEventListener("click", resetRelations); document.getElementById("diplomacyShowMatrix").addEventListener("click", showRelationsMatrix); document.getElementById("diplomacyHistory").addEventListener("click", showRelationsHistory); document.getElementById("diplomacyExport").addEventListener("click", downloadDiplomacyData); @@ -93,11 +94,13 @@ function editDiplomacy() { const tip = `${state.name} ${inText} ${selectedName}`; const tipSelect = `${tip}. Click to see relations to ${state.name}`; const tipChange = `Click to change relations. ${tip}`; + + const name = state.fullName.length < 23 ? state.fullName : state.name; COArenderer.trigger("stateCOA" + state.i, state.coa); - lines += `
+ lines += `
-
${state.fullName}
+
${name}
@@ -272,12 +275,26 @@ function editDiplomacy() { refreshDiplomacyEditor(); } + function resetRelations() { + pack.states[0].diplomacy = []; + + for (const state of pack.states) { + if (!state.i || state.removed) continue; + + const newRelations = state.diplomacy.map(relations => { + if (relations === "x") return "x"; + return "Neutral"; + }); + + state.diplomacy = newRelations; + } + + refreshDiplomacyEditor(); + } + function showRelationsHistory() { const chronicle = pack.states[0].diplomacy; - if (!chronicle.length) { - tip("Relations history is blank", false, "error"); - return; - } + if (!chronicle.length) return tip("Relations history is blank", false, "error"); let message = `
`; chronicle.forEach((entry, d) => {