Enhance the alert buttons by moving them to the garrisoning panel. Also add a new icon for the maximum level of alert.

Suggestion and testing by rogue-spectre, fixes #2474.

This was SVN commit r16670.
This commit is contained in:
Itms 2015-05-24 13:51:02 +00:00
parent b2e2e47205
commit bbf3422f01
6 changed files with 76 additions and 44 deletions

View file

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:171ca01dd502c0e3b6a946bae0ced992b9b71b9874901ab4d8b6d35227dcd639
size 1813

View file

@ -1846,9 +1846,8 @@ function backToWork()
var state = GetEntityState(e);
return (state && state.unitAI && state.unitAI.hasWorkOrders);
});
Engine.PostNetworkCommand({"type": "back-to-work", "entities": workers});
}
function removeGuard()
@ -1858,7 +1857,7 @@ function removeGuard()
var state = GetEntityState(e);
return (state && state.unitAI && state.unitAI.isGuarding);
});
Engine.PostNetworkCommand({"type": "remove-guard", "entities": entities});
}
@ -1868,8 +1867,8 @@ function increaseAlertLevel()
var state = GetEntityState(e);
return (state && state.alertRaiser && state.alertRaiser.canIncreaseLevel);
});
Engine.PostNetworkCommand({"type": "increase-alert-level", "entities": entities});
Engine.PostNetworkCommand({"type": "increase-alert-level", "entities": entities});
}
function endOfAlert()
@ -1878,7 +1877,7 @@ function endOfAlert()
var state = GetEntityState(e);
return (state && state.alertRaiser && state.alertRaiser.hasRaisedAlert);
});
Engine.PostNetworkCommand({"type": "alert-end", "entities": entities});
}

View file

@ -43,6 +43,58 @@ var g_formationsInfo = new Map();
var g_SelectionPanels = {};
// ALERT
g_SelectionPanels.Alert = {
"getMaxNumberOfItems": function()
{
return 2;
},
"getItems": function(unitEntState)
{
if (!unitEntState.alertRaiser)
return [];
return ["increase", "end"];
},
"setAction": function(data)
{
data.button.onPress = function() {
if (data.item == "increase")
increaseAlertLevel();
else if (data.item == "end")
endOfAlert();
};
},
"setTooltip": function(data)
{
if (data.item == "increase")
{
if (data.unitEntState.alertRaiser.hasRaisedAlert)
data.button.tooltip = translate("Increase the alert level to protect more units");
else
data.button.tooltip = translate("Raise an alert!");
}
else if (data.item == "end")
data.button.tooltip = translate("End of alert.");
},
"setGraphics": function(data)
{
if (data.item == "increase")
{
data.button.hidden = !data.unitEntState.alertRaiser.canIncreaseLevel;
if (data.unitEntState.alertRaiser.hasRaisedAlert)
data.icon.sprite = "stretched:session/icons/bell_level2.png";
else
data.icon.sprite = "stretched:session/icons/bell_level1.png";
}
else if (data.item == "end")
{
data.button.hidden = !data.unitEntState.alertRaiser.hasRaisedAlert;
data.icon.sprite = "stretched:session/icons/bell_level0.png";
}
data.button.enabled = !data.button.hidden;
},
};
// BARTER
g_SelectionPanels.Barter = {
"getMaxNumberOfItems": function()
@ -1080,6 +1132,7 @@ var g_PanelsOrder = [
// LEFT PANE
"Barter", // must always be visible on markets
"Garrison", // more important than Formation, as you want to see the garrisoned units in ships
"Alert",
"Formation",
"Stance", // normal together with formation

View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<object name="unitAlertPanel"
style="TranslucentPanel"
size="4 100%-43 100%-4 100%-4"
type="text"
>
<object size="100%-72 2 100% 100%">
<repeat count="2">
<object name="unitAlertButton[n]" hidden="true" style="iconButton" type="button" size="0 0 36 36" tooltip_style="sessionToolTipBottomBold" z="100">
<object name="unitAlertIcon[n]" type="image" ghost="true" size="3 3 33 33"/>
</object>
</repeat>
</object>
</object>

View file

@ -877,43 +877,6 @@ var g_EntityCommands =
toggleTrade();
},
},
// Raise alert
"increase-alert-level": {
"getInfo": function(entState)
{
if (!entState.alertRaiser || !entState.alertRaiser.canIncreaseLevel)
return false;
if (entState.alertRaiser.hasRaisedAlert)
var tooltip = translate("Increase the alert level to protect more units");
else
var tooltip = translate("Raise an alert!");
return {
"tooltip": tooltip,
"icon": "bell_level1.png"
};
},
"execute": function(entState)
{
increaseAlertLevel();
},
},
// End alert
"alert-end": {
"getInfo": function(entState)
{
if (!entState.alertRaiser || !entState.alertRaiser.hasRaisedAlert)
return false
return {
"tooltip": translate("End of alert."),
"icon": "bell_level0.png"
};
},
"execute": function(entState)
{
endOfAlert();
},
},
};
var g_AllyEntityCommands =

View file

@ -1,5 +1,5 @@
// The number of currently visible buttons (used to optimise showing/hiding)
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};
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};
/**
* Set the position of a panel object according to the index,