Index: binaries/data/mods/public/gamesettings/attributes/PlayerColor.js =================================================================== --- binaries/data/mods/public/gamesettings/attributes/PlayerColor.js +++ binaries/data/mods/public/gamesettings/attributes/PlayerColor.js @@ -189,21 +189,37 @@ } }; -GameSettings.prototype.Attributes.PlayerColor.prototype.DefaultColors = [ - { "r": 10, "g": 10, "b": 190 }, - { "r": 230, "g": 10, "b": 10 }, - { "r": 125 , "g": 235, "b": 15 }, - { "r": 255, "g": 255, "b": 55 }, - { "r": 130, "g": 0, "b": 230 }, - { "r": 255, "g": 130, "b": 0 }, - { "r": 10, "g": 230, "b": 230 }, - { "r": 20, "g": 80, "b": 60 }, - { "r": 220, "g": 160, "b": 220 }, - { "r": 80, "g": 255, "b": 190 }, - { "r": 50, "g": 150, "b": 255 }, - { "r": 100, "g": 150, "b": 30 }, - { "r": 100, "g": 60, "b": 30 }, - { "r": 128, "g": 0, "b": 64 }, - { "r": 255, "g": 200, "b": 140 }, - { "r": 80, "g": 80, "b": 80 } -]; +GameSettings.prototype.Attributes.PlayerColor.MAX_COLORS = 16; // the current PlayerColor GUI can only show 16 colors + +function loadPlayerColors() +{ + const colorsToUse = g_Settings.PlayerDefaults.slice(1).map(pData => pData.Color); + + const json = Engine.ReadJSONFile(g_SettingsDirectory + "player_color_defaults.json"); + if (!json || !json.Data) + warn("Could not load " + g_SettingsDirectory + "player_color_defaults.json" + "!"); + else + { + if (json.TranslatedKeys) + { + let keyContext = json.TranslatedKeys; + + if (json.TranslationContext) + { + keyContext = {}; + for (const key of json.TranslatedKeys) + keyContext[key] = json.TranslationContext; + } + + translateObjectKeys(json.Data, keyContext); + } + + // append the new colors at the end + colorsToUse.splice(colorsToUse.length, 0, ...json.Data.map(d => d.color)); + } + + colorsToUse.slice(0, GameSettings.prototype.Attributes.PlayerColor.MAX_COLORS); + return colorsToUse; +} + +GameSettings.prototype.Attributes.PlayerColor.prototype.DefaultColors = loadPlayerColors(); Index: binaries/data/mods/public/simulation/data/settings/player_color_defaults.json =================================================================== --- binaries/data/mods/public/simulation/data/settings/player_color_defaults.json +++ binaries/data/mods/public/simulation/data/settings/player_color_defaults.json @@ -0,0 +1,29 @@ +{ + "TranslatedKeys": [], + "Data": [ + { + "color": { "r": 220, "g": 160, "b": 220 } + }, + { + "color": { "r": 80, "g": 255, "b": 190 } + }, + { + "color": { "r": 50, "g": 150, "b": 255 } + }, + { + "color": { "r": 100, "g": 150, "b": 30 } + }, + { + "color": { "r": 100, "g": 60, "b": 30 } + }, + { + "color": { "r": 128, "g": 0, "b": 64 } + }, + { + "color": { "r": 255, "g": 200, "b": 140 } + }, + { + "color": { "r": 80, "g": 80, "b": 80 } + } + ] +}