Ticket #3911: visible_ai_setting.patch
File visible_ai_setting.patch, 4.3 KB (added by , 8 years ago) |
---|
-
binaries/data/mods/public/gui/aiconfig/aiconfig.js
1 1 var g_PlayerSlot; 2 var g_IsController; 2 3 3 4 const g_AIDescriptions = [{ 4 5 "id": "", … … 10 11 11 12 function init(settings) 12 13 { 14 g_IsController = settings.callback != ""; 13 15 // Remember the player ID that we change the AI settings for 14 16 g_PlayerSlot = settings.playerSlot; 15 17 … … 20 22 var aiDiff = Engine.GetGUIObjectByName("aiDifficulty"); 21 23 aiDiff.list = prepareForDropdown(g_Settings.AIDifficulties).Title; 22 24 aiDiff.selected = settings.difficulty; 25 26 Engine.GetGUIObjectByName("aiSelectionText").caption = aiSelection.list[aiSelection.selected]; 27 Engine.GetGUIObjectByName("aiDifficultyText").caption = aiDiff.list[aiDiff.selected]; 28 29 aiSelection.hidden = !g_IsController; 30 aiDiff.hidden = !g_IsController; 31 32 Engine.GetGUIObjectByName("aiSelectionText").hidden = g_IsController; 33 Engine.GetGUIObjectByName("aiDifficultyText").hidden = g_IsController; 23 34 } 24 35 25 36 function selectAI(idx) … … 31 42 { 32 43 var idx = Engine.GetGUIObjectByName("aiSelection").selected; 33 44 34 // Pop the page before calling the callback, so the callback runs 35 // in the parent GUI page's context 36 Engine.PopGuiPageCB({ 37 "id": g_AIDescriptions[idx].id, 38 "name": g_AIDescriptions[idx].data.name, 39 "difficulty": Engine.GetGUIObjectByName("aiDifficulty").selected, 40 "playerSlot": g_PlayerSlot 41 }); 45 if(g_IsController) 46 // Pop the page before calling the callback, so the callback runs 47 // in the parent GUI page's context 48 Engine.PopGuiPageCB({ 49 "id": g_AIDescriptions[idx].id, 50 "name": g_AIDescriptions[idx].data.name, 51 "difficulty": Engine.GetGUIObjectByName("aiDifficulty").selected, 52 "playerSlot": g_PlayerSlot 53 }); 54 else 55 Engine.PopGuiPage(); 42 56 } -
binaries/data/mods/public/gui/aiconfig/aiconfig.xml
24 24 <object name="aiSelection" type="dropdown" style="ModernDropDown" size="50%-24 0 50%+136 28"> 25 25 <action on="SelectionChange">selectAI(this.selected);</action> 26 26 </object> 27 <object name="aiSelectionText" type="text" style="ModernLeftLabelText" size="50%-24 0 50%+136 28"/> 27 28 28 29 <object type="text" style="ModernRightLabelText" size="-10 35 90 50%+35"> 29 30 <translatableAttribute id="caption">AI Difficulty:</translatableAttribute> … … 31 32 32 33 <object name="aiDifficulty" type="dropdown" style="ModernDropDown" size="50%-24 35 50%+136 63"> 33 34 </object> 35 <object name="aiDifficultyText" type="text" style="ModernLeftLabelText" size="50%-24 35 50%+136 63"/> 34 36 </object> 35 37 36 38 <object name="aiDescription" type="text" style="ModernLabelText" size="8% 90 92% 100%-60"/> -
binaries/data/mods/public/gui/gamesetup/gamesetup.js
1499 1499 selection = noAssignment; 1500 1500 1501 1501 // Since no human is assigned, show the AI config button 1502 if (g_IsController) 1503 { 1504 configButton.hidden = false; 1505 configButton.onpress = function() { 1506 Engine.PushGuiPage("page_aiconfig.xml", { 1507 "id": g_GameAttributes.settings.PlayerData[playerSlot].AI, 1508 "difficulty": g_GameAttributes.settings.PlayerData[playerSlot].AIDiff, 1509 "callback": "AIConfigCallback", 1510 "playerSlot": playerSlot // required by the callback function 1511 }); 1512 }; 1513 } 1502 configButton.hidden = false; 1503 configButton.onpress = function() { 1504 Engine.PushGuiPage("page_aiconfig.xml", { 1505 "id": g_GameAttributes.settings.PlayerData[playerSlot].AI, 1506 "difficulty": g_GameAttributes.settings.PlayerData[playerSlot].AIDiff, 1507 "callback": g_IsController ? "AIConfigCallback" : "", 1508 "playerSlot": playerSlot // required by the callback function 1509 }); 1510 }; 1514 1511 } 1515 1512 // There was a human, so make sure we don't have any AI left 1516 1513 // over in their slot, if we're in charge of the attributes