Index: binaries/data/config/default.cfg
===================================================================
--- binaries/data/config/default.cfg
+++ binaries/data/config/default.cfg
@@ -382,6 +382,12 @@
enable = true ; Enable/disable the splashscreen
version = 0 ; Splashscreen version (date of last modification). By default, 0 to force splashscreen to appear at first launch
+[gui.session.diplomacycolors]
+self = "21 55 149" ; Color of your units when diplomacy colors are enabled
+ally = "86 180 31" ; Color of allies when diplomacy colors are enabled
+neutral = "231 200 5" ; Color of neutral players when diplomacy colors are enabled
+enemy = "150 20 20" ; Color of enemies when diplomacy colors are enabled
+
[joystick] ; EXPERIMENTAL: joystick/gamepad settings
enable = false
deadzone = 8192
Index: binaries/data/mods/public/gui/common/color.js
===================================================================
--- binaries/data/mods/public/gui/common/color.js
+++ binaries/data/mods/public/gui/common/color.js
@@ -23,6 +23,19 @@
return ret;
}
+function guiToRgbColor(string)
+{
+ let color = string.split(" ");
+ if (color.length != 3 || color.some(num => !Number.isInteger(+num) || num < 0 || num > 255))
+ return undefined;
+
+ return {
+ "r": +color[0],
+ "g": +color[1],
+ "b": +color[2]
+ };
+}
+
/**
* True if the colors are identical.
*
Index: binaries/data/mods/public/gui/options/options.js
===================================================================
--- binaries/data/mods/public/gui/options/options.js
+++ binaries/data/mods/public/gui/options/options.js
@@ -68,6 +68,20 @@
"guiToValue": control => control.caption,
"guiSetter": "onTextEdit"
},
+ "color":
+ {
+ "configToValue": value => value,
+ "valueToGui": (value, control) => {
+ control.caption = value;
+ },
+ "guiToValue": control => control.caption,
+ "guiSetter": "onTextEdit",
+ "sanitizeValue": (value, control, option) => {
+ let sanitized = rgbToGuiColor(guiToRgbColor(value));
+ control.sprite = sanitized == value ? "color:" + value : "ModernDarkBoxWhiteInvalid";
+ return sanitized;
+ }
+ },
"number":
{
"configToValue": value => value,
Index: binaries/data/mods/public/gui/options/options.json
===================================================================
--- binaries/data/mods/public/gui/options/options.json
+++ binaries/data/mods/public/gui/options/options.json
@@ -426,6 +426,30 @@
{ "value": "buddies", "label": "Buddies" },
{ "value": "disabled", "label": "Disabled" }
]
+ },
+ {
+ "type": "color",
+ "label": "Diplomacy Colors: Self",
+ "tooltip": "Color of your units when diplomacy colors are enabled. Default: \"21 55 149\"",
+ "config": "gui.session.diplomacycolors.self"
+ },
+ {
+ "type": "color",
+ "label": "Diplomacy Colors: Ally",
+ "tooltip": "Color of allies when diplomacy colors are enabled. Default: \"86 180 31\"",
+ "config": "gui.session.diplomacycolors.ally"
+ },
+ {
+ "type": "color",
+ "label": "Diplomacy Colors: Neutral",
+ "tooltip": "Color of neutral players when diplomacy colors are enabled. Default: \"231 200 5\"",
+ "config": "gui.session.diplomacycolors.neutral"
+ },
+ {
+ "type": "color",
+ "label": "Diplomacy Colors: Enemy",
+ "tooltip": "Color of enemies when diplomacy colors are enabled. Default: \"150 20 20\"",
+ "config": "gui.session.diplomacycolors.enemy"
}
]
},
Index: binaries/data/mods/public/gui/options/options.xml
===================================================================
--- binaries/data/mods/public/gui/options/options.xml
+++ binaries/data/mods/public/gui/options/options.xml
@@ -27,6 +27,7 @@
+
Index: binaries/data/mods/public/gui/session/menu.js
===================================================================
--- binaries/data/mods/public/gui/session/menu.js
+++ binaries/data/mods/public/gui/session/menu.js
@@ -244,10 +244,19 @@
pauseGame();
Engine.PushGuiPage("page_options.xml", {
- "callback": "resumeGame"
+ "callback": "optionsPageClosed"
});
}
+function optionsPageClosed()
+{
+ updateEnabledRangeOverlayTypes();
+ if (g_DiplomacyColorsToggle)
+ updateDisplayedPlayerColors();
+
+ resumeGame();
+}
+
function openChat(command = "")
{
if (g_Disconnected)
Index: binaries/data/mods/public/gui/session/session.js
===================================================================
--- binaries/data/mods/public/gui/session/session.js
+++ binaries/data/mods/public/gui/session/session.js
@@ -23,11 +23,6 @@
var g_DisplayedPlayerColors;
/**
- * The self/ally/neutral/enemy color codes.
- */
-var g_DiplomacyColorPalette;
-
-/**
* Colors to flash when pop limit reached.
*/
var g_DefaultPopulationColor = "white";
@@ -294,7 +289,6 @@
for (let slot in Engine.GetGUIObjectByName("panelEntityPanel").children)
initPanelEntities(slot);
- g_DiplomacyColorPalette = Engine.ReadJSONFile(g_SettingsDirectory + "diplomacy_colors.json");
g_DisplayedPlayerColors = g_Players.map(player => player.color);
updateViewedPlayerDropdown();
@@ -310,7 +304,7 @@
g_Selection.selected = hotloadData.selection;
Engine.SetBoundingBoxDebugOverlay(false);
-
+ updateEnabledRangeOverlayTypes();
initChatWindow();
sendLobbyPlayerlistUpdate();
@@ -396,6 +390,10 @@
{
if (g_DiplomacyColorsToggle)
{
+ let getDiplomacyColor = stance =>
+ guiToRgbColor(Engine.ConfigDB_GetValue("user", "gui.session.diplomacycolors." + stance)) ||
+ guiToRgbColor(Engine.ConfigDB_GetValue("default", "gui.session.diplomacycolors." + stance));
+
let teamRepresentatives = {};
for (let i = 1; i < g_Players.length; ++i)
if (g_ViewedPlayer <= 0)
@@ -409,10 +407,10 @@
else
// Players see colors depending on diplomacy
g_DisplayedPlayerColors[i] =
- g_ViewedPlayer == i ? g_DiplomacyColorPalette.Self :
- g_Players[g_ViewedPlayer].isAlly[i] ? g_DiplomacyColorPalette.Ally :
- g_Players[g_ViewedPlayer].isNeutral[i] ? g_DiplomacyColorPalette.Neutral :
- g_DiplomacyColorPalette.Enemy;
+ g_ViewedPlayer == i ? getDiplomacyColor("self") :
+ g_Players[g_ViewedPlayer].isAlly[i] ? getDiplomacyColor("ally") :
+ g_Players[g_ViewedPlayer].isNeutral[i] ? getDiplomacyColor("neutral") :
+ getDiplomacyColor("enemy");
g_DisplayedPlayerColors[0] = g_Players[0].color;
}
@@ -879,12 +877,6 @@
handleNotifications();
updateGUIObjects();
- for (let type of ["Attack", "Auras", "Heal"])
- Engine.GuiInterfaceCall("EnableVisualRangeOverlayType", {
- "type": type,
- "enabled": Engine.ConfigDB_GetValue("user", "gui.session." + type.toLowerCase() + "range") == "true"
- });
-
if (g_ConfirmExit)
confirmExit();
}
@@ -1407,6 +1399,15 @@
});
}
+function updateEnabledRangeOverlayTypes()
+{
+ for (let type of ["Attack", "Auras", "Heal"])
+ Engine.GuiInterfaceCall("EnableVisualRangeOverlayType", {
+ "type": type,
+ "enabled": Engine.ConfigDB_GetValue("user", "gui.session." + type.toLowerCase() + "range") == "true"
+ });
+}
+
// Update the additional list of entities to be highlighted.
function updateAdditionalHighlight()
{
Index: binaries/data/mods/public/simulation/data/settings/diplomacy_colors.json
===================================================================
--- binaries/data/mods/public/simulation/data/settings/diplomacy_colors.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "Self": { "r": 0, "g": 68, "b": 255 },
- "Ally": { "r": 94, "g": 255, "b": 0 },
- "Neutral": { "r": 255, "g": 220, "b": 0 },
- "Enemy": { "r": 255, "g": 0, "b": 0 }
-}