Ticket #2474: alert-buttons.patch
File alert-buttons.patch, 6.0 KB (added by , 9 years ago) |
---|
-
binaries/data/mods/public/gui/session/input.js
1846 1846 var state = GetEntityState(e); 1847 1847 return (state && state.unitAI && state.unitAI.hasWorkOrders); 1848 1848 }); 1849 1849 1850 1850 Engine.PostNetworkCommand({"type": "back-to-work", "entities": workers}); 1851 1852 1851 } 1853 1852 1854 1853 function removeGuard() … … 1858 1857 var state = GetEntityState(e); 1859 1858 return (state && state.unitAI && state.unitAI.isGuarding); 1860 1859 }); 1861 1860 1862 1861 Engine.PostNetworkCommand({"type": "remove-guard", "entities": entities}); 1863 1862 } 1864 1863 … … 1868 1867 var state = GetEntityState(e); 1869 1868 return (state && state.alertRaiser && state.alertRaiser.canIncreaseLevel); 1870 1869 }); 1871 1872 Engine.PostNetworkCommand({"type": "increase-alert-level", "entities": entities}); 1870 1871 Engine.PostNetworkCommand({"type": "increase-alert-level", "entities": entities}); 1873 1872 } 1874 1873 1875 1874 function endOfAlert() … … 1878 1877 var state = GetEntityState(e); 1879 1878 return (state && state.alertRaiser && state.alertRaiser.hasRaisedAlert); 1880 1879 }); 1881 1880 1882 1881 Engine.PostNetworkCommand({"type": "alert-end", "entities": entities}); 1883 1882 } 1884 1883 -
binaries/data/mods/public/gui/session/selection_panels.js
43 43 44 44 var g_SelectionPanels = {}; 45 45 46 // ALERT 47 g_SelectionPanels.Alert = { 48 "getMaxNumberOfItems": function() 49 { 50 return 2; 51 }, 52 "getItems": function(unitEntState) 53 { 54 if (!unitEntState.alertRaiser) 55 return []; 56 return ["increase", "end"]; 57 }, 58 "setAction": function(data) 59 { 60 data.button.onPress = function() { 61 if (data.item == "increase") 62 increaseAlertLevel(); 63 else if (data.item == "end") 64 endOfAlert(); 65 }; 66 }, 67 "setTooltip": function(data) 68 { 69 if (data.item == "increase") 70 { 71 if (data.unitEntState.alertRaiser.hasRaisedAlert) 72 data.button.tooltip = translate("Increase the alert level to protect more units"); 73 else 74 data.button.tooltip = translate("Raise an alert!"); 75 } 76 else if (data.item == "end") 77 data.button.tooltip = translate("End of alert."); 78 }, 79 "setGraphics": function(data) 80 { 81 data.button.enabled = !data.stanceSelected; 82 if (data.item == "increase") 83 { 84 data.button.enabled = data.unitEntState.alertRaiser.canIncreaseLevel; 85 data.icon.sprite = "stretched:session/icons/bell_level1.png"; 86 } 87 else if (data.item == "end") 88 { 89 data.button.enabled = data.unitEntState.alertRaiser.hasRaisedAlert; 90 data.icon.sprite = "stretched:session/icons/bell_level0.png"; 91 } 92 }, 93 }; 94 46 95 // BARTER 47 96 g_SelectionPanels.Barter = { 48 97 "getMaxNumberOfItems": function() … … 1080 1129 // LEFT PANE 1081 1130 "Barter", // must always be visible on markets 1082 1131 "Garrison", // more important than Formation, as you want to see the garrisoned units in ships 1132 "Alert", 1083 1133 "Formation", 1084 1134 "Stance", // normal together with formation 1085 1135 -
binaries/data/mods/public/gui/session/selection_panels_left/alert_panel.xml
1 <?xml version="1.0" encoding="utf-8"?> 2 <object name="unitAlertPanel" 3 style="TranslucentPanel" 4 size="4 100%-43 100%-4 100%-4" 5 type="text" 6 > 7 <object size="100%-72 2 100% 100%"> 8 <repeat count="2"> 9 <object name="unitAlertButton[n]" hidden="true" style="iconButton" type="button" size="0 0 36 36" tooltip_style="sessionToolTipBottomBold" z="100"> 10 <object name="unitAlertIcon[n]" type="image" ghost="true" size="3 3 33 33"/> 11 </object> 12 </repeat> 13 </object> 14 </object> -
binaries/data/mods/public/gui/session/unit_actions.js
877 877 toggleTrade(); 878 878 }, 879 879 }, 880 // Raise alert881 "increase-alert-level": {882 "getInfo": function(entState)883 {884 if (!entState.alertRaiser || !entState.alertRaiser.canIncreaseLevel)885 return false;886 887 if (entState.alertRaiser.hasRaisedAlert)888 var tooltip = translate("Increase the alert level to protect more units");889 else890 var tooltip = translate("Raise an alert!");891 return {892 "tooltip": tooltip,893 "icon": "bell_level1.png"894 };895 },896 "execute": function(entState)897 {898 increaseAlertLevel();899 },900 },901 // End alert902 "alert-end": {903 "getInfo": function(entState)904 {905 if (!entState.alertRaiser || !entState.alertRaiser.hasRaisedAlert)906 return false907 return {908 "tooltip": translate("End of alert."),909 "icon": "bell_level0.png"910 };911 },912 "execute": function(entState)913 {914 endOfAlert();915 },916 },917 880 }; 918 881 919 882 var g_AllyEntityCommands = -
binaries/data/mods/public/gui/session/unit_commands.js
1 1 // The number of currently visible buttons (used to optimise showing/hiding) 2 var g_unitPanelButtons = {"Selection": 0, "Queue": 0, "Formation": 0, "Garrison": 0, "Training": 0, "Research": 0, " Barter": 0, "Construction": 0, "Command": 0, "AllyCommand": 0, "Stance": 0, "Gate": 0, "Pack": 0};2 var g_unitPanelButtons = {"Selection": 0, "Queue": 0, "Formation": 0, "Garrison": 0, "Training": 0, "Research": 0, "Alert": 0, "Barter": 0, "Construction": 0, "Command": 0, "AllyCommand": 0, "Stance": 0, "Gate": 0, "Pack": 0}; 3 3 4 4 /** 5 5 * Set the position of a panel object according to the index,