Index: binaries/data/config/default.cfg =================================================================== --- binaries/data/config/default.cfg +++ binaries/data/config/default.cfg @@ -381,6 +381,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 +[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 @@ -24,6 +24,22 @@ } /** + * Extract RGB colors from a string + * + * @param {string} color string + * @returns {Object} + */ +function guiToRgbColor(string) +{ + let color = string.split(" "); + return { + "r": Number(color[0] || 0), + "g": Number(color[1] || 0), + "b": Number(color[2] || 0) + }; +} + +/** * True if the colors are identical. * * @param {Object} color1 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": "string", + "label": "Diplomacy Colors: Self", + "tooltip": "Color of your units when diplomacy colors are enabled. (Default RGB string = 21 55 149)", + "config": "diplomacycolors.self" + }, + { + "type": "string", + "label": "Diplomacy Colors: Ally", + "tooltip": "Color of allies when diplomacy colors are enabled. (Default RGB string = 86 180 31)", + "config": "diplomacycolors.ally" + }, + { + "type": "string", + "label": "Diplomacy Colors: Neutral", + "tooltip": "Color of neutral players when diplomacy colors are enabled. (Default RGB string = 231 200 5)", + "config": "diplomacycolors.neutral" + }, + { + "type": "string", + "label": "Diplomacy Colors: Enemy", + "tooltip": "Color of enemies when diplomacy colors are enabled. (Default RGB string = 150 20 20)", + "config": "diplomacycolors.enemy" } ] }, 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 @@ -1143,6 +1143,9 @@ function resumeGame(explicit = false) { + if (g_DiplomacyColorsToggle) + updateDisplayedPlayerColors(); + pauseGame(false, explicit); } 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,7 +23,7 @@ var g_DisplayedPlayerColors; /** - * The self/ally/neutral/enemy color codes. + * The default self/ally/neutral/enemy color codes. */ var g_DiplomacyColorPalette; @@ -389,6 +389,14 @@ updateDisplayedPlayerColors(); } +function sanitizeDiplomacyColor(stance) +{ + let validColor = num => Number.isInteger(num) && num >= 0 && num <= 255; + let color = guiToRgbColor(Engine.ConfigDB_GetValue("user", "diplomacycolors." + stance)); + return validColor(color.r) && validColor(color.g) && validColor(color.b) ? + color : g_DiplomacyColorPalette[stance]; +} + /** * Updates the displayed colors of players in the simulation and GUI. */ @@ -409,10 +417,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 ? sanitizeDiplomacyColor("self") : + g_Players[g_ViewedPlayer].isAlly[i] ? sanitizeDiplomacyColor("ally") : + g_Players[g_ViewedPlayer].isNeutral[i] ? sanitizeDiplomacyColor("neutral") : + sanitizeDiplomacyColor("enemy"); g_DisplayedPlayerColors[0] = g_Players[0].color; } Index: binaries/data/mods/public/simulation/data/settings/diplomacy_colors.json =================================================================== --- binaries/data/mods/public/simulation/data/settings/diplomacy_colors.json +++ binaries/data/mods/public/simulation/data/settings/diplomacy_colors.json @@ -1,6 +1,6 @@ { - "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 } + "self": { "r": 21, "g": 55, "b": 149 }, + "ally": { "r": 86, "g": 180, "b": 31 }, + "neutral": { "r": 231, "g": 200, "b": 5 }, + "enemy": { "r": 150, "g": 20, "b": 20 } }