Ticket #1580: 1580.3.diff
File 1580.3.diff, 6.2 KB (added by , 9 years ago) |
---|
-
binaries/data/mods/public/gui/common/settings.js
32 32 var settings = { 33 33 "Ceasefire": loadCeasefire(), 34 34 "GameSpeeds": loadSettingValuesFile("game_speeds.json"), 35 "PlayerColors": loadPlayerColors(), 35 36 "PopulationCapacities": loadPopulationCapacities(), 36 37 "StartingResources": loadSettingValuesFile("starting_resources.json") 37 38 }; … … 89 90 } 90 91 91 92 /** 93 * Loads available colors settings. 94 * 95 * @returns {Array|undefined} 96 */ 97 function loadPlayerColors() 98 { 99 var json = Engine.ReadJSONFile("simulation/data/player_defaults.json"); 100 101 if (!json || !json.PlayerData || !Array.isArray(json.PlayerData)) 102 { 103 error("Could not load player_defaults.json"); 104 return undefined; 105 } 106 107 return json.PlayerData.map(player => player.Color); 108 } 109 110 /** 92 111 * Loads available population capacities. 93 112 * 94 113 * @returns {Array|undefined} -
binaries/data/mods/public/gui/gamesetup/gamesetup.js
7 7 8 8 const g_Ceasefire = prepareForDropdown(g_Settings ? g_Settings.Ceasefire : undefined); 9 9 const g_GameSpeeds = prepareForDropdown(g_Settings ? g_Settings.GameSpeeds.filter(speed => !speed.ReplayOnly) : undefined); 10 const g_PlayerColors = prepareForDropdown(g_Settings ? g_Settings.PlayerColors : undefined); 10 11 const g_PopulationCapacities = prepareForDropdown(g_Settings ? g_Settings.PopulationCapacities : undefined); 11 12 const g_StartingResources = prepareForDropdown(g_Settings ? g_Settings.StartingResources : undefined); 12 13 … … 50 51 51 52 var g_AIs = []; 52 53 54 var g_PlayerColorIds = []; 55 var g_PlayerColorNames = []; 56 var g_PlayerColorValues = []; 57 53 58 var g_ChatMessages = []; 54 59 55 60 // Data caches … … 380 385 updateGameAttributes(); 381 386 }; 382 387 388 // Populate color drop-down lists. 389 var colorPicker = Engine.GetGUIObjectByName("playerColorPicker["+i+"]"); 390 colorPicker.list = getPlayerColorNames(); 391 colorPicker.list_data = getPlayerColorIds(); 392 colorPicker.selected = -1; 393 // Update color 394 colorPicker.onSelectionChange = function() 395 { 396 if (this.selected !== -1) 397 { 398 var numPlayers = g_GameAttributes.settings.PlayerData.length; 399 400 } 401 } 402 383 403 // Set events 384 404 var civ = Engine.GetGUIObjectByName("playerCiv["+i+"]"); 385 405 civ.onSelectionChange = function() { … … 413 433 } 414 434 } 415 435 436 function getPlayerColorIds() 437 { 438 for(let i = 0; i < g_PlayerColors.r.length;++i) 439 g_PlayerColorIds[i] = i; 440 441 return g_PlayerColorIds; 442 } 443 function getPlayerColorNames() 444 { 445 for(let i = 0; i < g_PlayerColors.r.length;++i) 446 g_PlayerColorNames[i] = "[color=\"" + g_PlayerColors.r[i] + " " + g_PlayerColors.g[i] + " " + g_PlayerColors.b[i] + " 255\"]" + "■"; 447 448 return g_PlayerColorNames; 449 } 450 function getPlayerColorValues() 451 { 452 for(let i = 0; i < g_PlayerColors.r.length;++i) 453 { 454 g_PlayerColorValues[i].r = g_PlayerColors.r[i]; 455 g_PlayerColorValues[i].g = g_PlayerColors.g[i]; 456 g_PlayerColorValues[i].b = g_PlayerColors.b[i]; 457 } 458 459 return g_PlayerColorValues; 460 } 461 416 462 function handleNetMessage(message) 417 463 { 418 464 log("Net message: " + uneval(message)); -
binaries/data/mods/public/gui/gamesetup/gamesetup.xml
42 42 <!-- Player assignments --> 43 43 <object size="24 49 100%-440 345" type="image" sprite="ModernDarkBoxGold" name="playerAssignmentsPanel"> 44 44 <object size="0 6 100% 30"> 45 <object name="playerNameHeading" type="text" style="ModernLabelText" size="0 0 22% 100%">45 <object name="playerNameHeading" type="text" style="ModernLabelText" size="0 0 16% 100%"> 46 46 <translatableAttribute id="caption">Player Name</translatableAttribute> 47 47 </object> 48 <object name="playerColorHeading" type="text" style="ModernLabelText" size="-2% 0 40% 100%"> 49 <translatableAttribute id="caption">Color</translatableAttribute> 50 </object> 48 51 <object name="playerPlacementHeading" type="text" style="ModernLabelText" size="22%+5 0 50%+35 100%"> 49 52 <translatableAttribute id="caption">Player Placement</translatableAttribute> 50 53 </object> … … 71 74 <repeat count="8"> 72 75 <object name="playerBox[n]" size="0 0 100% 32" hidden="true"> 73 76 <object name="playerColor[n]" type="image" size="0 0 100% 100%"/> 74 <object name="playerName[n]" type="text" style="ModernLabelText" size="0 2 22% 30"/> 77 <object name="playerName[n]" type="text" style="ModernLabelText" size="0 0 16% 100%"/> 78 <object name="playerColorPicker[n]" type="dropdown" style="ModernDropDown" size="16%+5 2 20%+5 30" tooltip_style="onscreenToolTip"> 79 <translatableAttribute id="tooltip">Pick Color.</translatableAttribute> 80 </object> 75 81 <object name="playerAssignment[n]" type="dropdown" style="ModernDropDown" size="22%+5 2 50%+35 30" tooltip_style="onscreenToolTip"> 76 82 <translatableAttribute id="tooltip">Select player.</translatableAttribute> 77 83 </object> … … 152 158 tooltip_style="onscreenToolTip"> 153 159 <translatableAttribute id="tooltip">Select a map to play on.</translatableAttribute> 154 160 <action on="SelectionChange"> 155 if (this.list_data[this.selected]) 161 if (this.list_data[this.selected]) 156 162 selectMap(this.list_data[this.selected]); 157 163 </action> 158 164 </object> … … 179 185 180 186 <!-- Map Description --> 181 187 <object size="100%-425 529 100%-25 100%-60"> 182 <object name="mapInfoName" type="text" style="ModernLeftLabelText" size="0 0 100%-120 30"/> 188 <object name="mapInfoName" type="text" style="ModernLeftLabelText" size="0 0 100%-120 30"/> 183 189 <object type="image" sprite="ModernDarkBoxGold" size="0 30 100% 100%"> 184 190 <object name="mapInfoDescription" type="text" style="MapDescription" size="0 0 100% 100%"/> 185 191 </object>