Ticket #1580: 1580.7.diff
File 1580.7.diff, 7.0 KB (added by , 9 years ago) |
---|
-
binaries/data/mods/public/gui/common/functions_utility.js
146 146 return ret; 147 147 } 148 148 149 149 // ==================================================================== 150 150 151 function sameColor(color1, color2) 152 { 153 return color1.r === color2.r && color1.g === color2.g && color1.b === color2.b; 154 } 155 156 // ==================================================================== 157 151 158 /** 152 159 * Convert time in milliseconds to [hh:]mm:ss string representation. 153 160 * @param time Time period in milliseconds (integer) 154 161 * @return String representing time period 155 162 */ -
binaries/data/mods/public/gui/gamesetup/gamesetup.js
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 10 const g_PopulationCapacities = prepareForDropdown(g_Settings ? g_Settings.PopulationCapacities : undefined); 11 11 const g_StartingResources = prepareForDropdown(g_Settings ? g_Settings.StartingResources : undefined); 12 12 13 const g_PlayerColors = initPlayerDefaults().slice(1).map(playerData => playerData.Color); 14 13 15 //////////////////////////////////////////////////////////////////////////////////////////////// 14 16 15 17 // Is this is a networked game, or offline 16 18 var g_IsNetworked; 17 19 … … 378 380 g_GameAttributes.settings.PlayerData[playerSlot].Team = this.selected - 1; 379 381 380 382 updateGameAttributes(); 381 383 }; 382 384 385 // Populate color drop-down lists. 386 var colorPicker = Engine.GetGUIObjectByName("playerColorPicker["+i+"]"); 387 colorPicker.list = g_PlayerColors.map(color => '[color="' + color.r + ' ' + color.g + ' ' + color.b + '"]■[/color]' ); 388 colorPicker.list_data = g_PlayerColors.map((color, index) => index); 389 colorPicker.selected = -1; 390 391 // Update color 392 colorPicker.onSelectionChange = function() 393 { 394 if (this.selected == -1) 395 return; 396 397 // Add missing properties 398 g_GameAttributes.settings.PlayerData.forEach((pData, index) => { 399 if (!pData.Color) 400 pData.Color = g_PlayerColors[index]; 401 }); 402 403 // Apply color if noone else has it 404 if (g_GameAttributes.settings.PlayerData.every(pData => !sameColor(g_PlayerColors[this.selected], pData.Color))) 405 g_GameAttributes.settings.PlayerData[playerSlot].Color = g_PlayerColors[this.selected]; 406 407 if (!g_IsInGuiUpdate) 408 updateGameAttributes(); 409 } 410 383 411 // Set events 384 412 var civ = Engine.GetGUIObjectByName("playerCiv["+i+"]"); 385 413 civ.onSelectionChange = function() { 386 414 if ((this.selected != -1)&&(g_GameAttributes.mapType !== "scenario")) 387 415 g_GameAttributes.settings.PlayerData[playerSlot].Civ = this.list_data[this.selected]; … … 1420 1448 var pCiv = Engine.GetGUIObjectByName("playerCiv["+i+"]"); 1421 1449 var pCivText = Engine.GetGUIObjectByName("playerCivText["+i+"]"); 1422 1450 var pTeam = Engine.GetGUIObjectByName("playerTeam["+i+"]"); 1423 1451 var pTeamText = Engine.GetGUIObjectByName("playerTeamText["+i+"]"); 1424 1452 var pColor = Engine.GetGUIObjectByName("playerColor["+i+"]"); 1453 var pColorPicker = Engine.GetGUIObjectByName("playerColorPicker["+i+"]") 1425 1454 1426 1455 // Player data / defaults 1427 1456 var pData = mapSettings.PlayerData ? mapSettings.PlayerData[i] : {}; 1428 1457 var pDefs = g_DefaultPlayerData ? g_DefaultPlayerData[i] : {}; 1429 1458 … … 1447 1476 // TODO: Allow clients to choose their own civ and team 1448 1477 if (!g_IsController || g_GameAttributes.mapType == "scenario") 1449 1478 { 1450 1479 pCivText.hidden = false; 1451 1480 pCiv.hidden = true; 1481 pColorPicker.hidden = true; 1452 1482 pTeamText.hidden = false; 1453 1483 pTeam.hidden = true; 1454 1484 // Set text values 1455 1485 if (civ == "random") 1456 1486 pCivText.caption = "[color=\"orange\"]" + translateWithContext("civilization", "Random"); … … 1462 1492 { 1463 1493 pCivText.hidden = true; 1464 1494 pCiv.hidden = false; 1465 1495 pTeamText.hidden = true; 1466 1496 pTeam.hidden = false; 1497 pColorPicker.hidden = false; 1467 1498 // Set dropdown values 1468 1499 pCiv.selected = (civ ? pCiv.list_data.indexOf(civ) : 0); 1469 1500 pTeam.selected = (team !== undefined && team >= 0) ? team+1 : 0; 1501 pColorPicker.selected = g_PlayerColors.findIndex(col => sameColor(col, color)); 1470 1502 } 1471 1503 } 1472 1504 1473 1505 Engine.GetGUIObjectByName("mapInfoDescription").caption = playerString; 1474 1506 -
binaries/data/mods/public/gui/gamesetup/gamesetup.xml
40 40 </action> 41 41 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="-3% 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> 51 54 <object name="playerCivHeading" type="text" style="ModernLabelText" size="50%+65 0 85%-26 100%"> 52 55 <translatableAttribute id="caption">Civilization</translatableAttribute> … … 69 72 </object> 70 73 <object size="1 36 100%-1 100%"> 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="15%+5 2 20%+5 30" tooltip_style="onscreenToolTip"> 79 <translatableAttribute id="tooltip">Pick a 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> 78 84 <object name="playerAssignmentText[n]" type="text" style="ModernLabelText" size="22%+5 0 50%+35 30"/> 79 85 <object name="playerConfig[n]" type="button" style="StoneButton" size="50%+40 4 50%+64 28"