diff --git a/modules/ui/diplomacy-editor.js b/modules/ui/diplomacy-editor.js
index c5f5e986..eee4bb80 100644
--- a/modules/ui/diplomacy-editor.js
+++ b/modules/ui/diplomacy-editor.js
@@ -1,10 +1,9 @@
"use strict";
function editDiplomacy() {
if (customization) return;
- if (pack.states.filter(s => s.i && !s.removed).length < 2) {
- tip("There should be at least 2 states to edit the diplomacy", false, "error");
- return;
- }
+ if (pack.states.filter(s => s.i && !s.removed).length < 2) return tip("There should be at least 2 states to edit the diplomacy", false, "error");
+
+ const body = document.getElementById("diplomacyBodySection");
closeDialogs("#diplomacyEditor, .stable");
if (!layerIsOn("toggleStates")) toggleStates();
@@ -14,11 +13,22 @@ function editDiplomacy() {
if (layerIsOn("toggleBiomes")) toggleBiomes();
if (layerIsOn("toggleReligions")) toggleReligions();
- const body = document.getElementById("diplomacyBodySection");
- const statuses = ["Ally", "Friendly", "Neutral", "Suspicion", "Enemy", "Unknown", "Rival", "Vassal", "Suzerain"];
- const description = [" is an ally of ", " is friendly to ", " is neutral to ", " is suspicious of ",
- " is at war with ", " does not know about ", " is a rival of ", " is a vassal of ", " is suzerain to "];
- const colors = ["#00b300", "#d4f8aa", "#edeee8", "#eeafaa", "#e64b40", "#a9a9a9", "#ad5a1f", "#87CEFA", "#00008B"];
+ const relations = {
+ Ally: {
+ inText: "is an ally of",
+ color: "#00b300",
+ tip: "Ally means states formed a defensive pact and will protect each other in case of third party aggression"
+ },
+ Friendly: {inText: "is friendly to", color: "#d4f8aa", tip: "State is friendly to anouther state when they share some common interests"},
+ Neutral: {inText: "is neutral to", color: "#edeee8", tip: "Neutral means states relations are neither positive nor negative"},
+ Suspicion: {inText: "is suspicious of", color: "#eeafaa", tip: "Suspicion means state has a cautious distrust of another state"},
+ Enemy: {inText: "is at war with", color: "#e64b40", tip: "Enemies are states at war with each other"},
+ Unknown: {inText: "does not know about", color: "#a9a9a9", tip: "Relations are unknown if states do not have enough information about each other"},
+ Rival: {inText: "is a rival of", color: "#ad5a1f", tip: "Rivalry is a state of competing for dominance in the region"},
+ Vassal: {inText: "is a vassal of", color: "#87CEFA", tip: "Vassal is a state having obligation to its suzerain"},
+ Suzerain: {inText: "is suzerain to", color: "#00008B", tip: "Suzerain is a state having some control over its vassals"}
+ };
+
refreshDiplomacyEditor();
tip("Click on a state to see its diplomatic relations", false, "warning");
@@ -28,7 +38,10 @@ function editDiplomacy() {
modules.editDiplomacy = true;
$("#diplomacyEditor").dialog({
- title: "Diplomacy Editor", resizable: false, width: fitContent(), close: closeDiplomacyEditor,
+ title: "Diplomacy Editor",
+ resizable: false,
+ width: fitContent(),
+ close: closeDiplomacyEditor,
position: {my: "right top", at: "right-10 top+10", of: "svg", collision: "fit"}
});
@@ -36,10 +49,29 @@ function editDiplomacy() {
document.getElementById("diplomacyEditorRefresh").addEventListener("click", refreshDiplomacyEditor);
document.getElementById("diplomacyEditStyle").addEventListener("click", () => editStyle("regions"));
document.getElementById("diplomacyRegenerate").addEventListener("click", regenerateRelations);
- document.getElementById("diplomacyMatrix").addEventListener("click", showRelationsMatrix);
+ document.getElementById("diplomacyShowMatrix").addEventListener("click", showRelationsMatrix);
document.getElementById("diplomacyHistory").addEventListener("click", showRelationsHistory);
document.getElementById("diplomacyExport").addEventListener("click", downloadDiplomacyData);
- document.getElementById("diplomacySelect").addEventListener("mouseup", diplomacyChangeRelations);
+
+ body.addEventListener("click", function (ev) {
+ const el = ev.target;
+ if (el.parentElement.classList.contains("Self")) return;
+
+ if (el.classList.contains("changeRelations")) {
+ const line = el.parentElement;
+ const subjectId = +line.dataset.id;
+ const objectId = +body.querySelector("div.Self").dataset.id;
+ const currentRelation = line.dataset.relations;
+
+ selectRelation(subjectId, objectId, currentRelation);
+ return;
+ }
+
+ // select state of clicked line
+ body.querySelector("div.Self").classList.remove("Self");
+ el.parentElement.classList.add("Self");
+ refreshDiplomacyEditor();
+ });
function refreshDiplomacyEditor() {
diplomacyEditorAddLines();
@@ -50,33 +82,32 @@ function editDiplomacy() {
function diplomacyEditorAddLines() {
const states = pack.states;
const selectedLine = body.querySelector("div.Self");
- const sel = selectedLine ? +selectedLine.dataset.id : states.find(s => s.i && !s.removed).i;
- const selName = states[sel].fullName;
- diplomacySelect.style.display = "none";
+ const selectedId = selectedLine ? +selectedLine.dataset.id : states.find(s => s.i && !s.removed).i;
+ const selectedName = states[selectedId].fullName;
- COArenderer.trigger("stateCOA"+sel, states[sel].coa);
- let lines = `