forked from 0ad/0ad
Allow observers to follow the commands and attacks of the currently viewed player, fixes #3743.
If enabled, the camera focuses on the affected units (source and target) and selects them. This was SVN commit r17893.
This commit is contained in:
parent
f1d99a9450
commit
d7fe1b6002
@ -37,6 +37,12 @@ var g_IsObserver = false;
|
||||
*/
|
||||
var g_ViewedPlayer = Engine.GetPlayerID();
|
||||
|
||||
/**
|
||||
* True if the camera should focus on attacks and player commands
|
||||
* and select the affected units.
|
||||
*/
|
||||
var g_FollowPlayer = false;
|
||||
|
||||
/**
|
||||
* Unique ID for lobby reports.
|
||||
*/
|
||||
@ -328,6 +334,8 @@ function selectViewPlayer(playerID)
|
||||
alphaLabel.hidden = g_ViewedPlayer > 0 && !viewPlayer.hidden;
|
||||
alphaLabel.size = g_ViewedPlayer > 0 ? "50%+20 0 100%-226 100%" : "200 0 100%-475 100%";
|
||||
|
||||
Engine.GetGUIObjectByName("optionFollowPlayer").hidden = !g_IsObserver || g_ViewedPlayer < 1;
|
||||
|
||||
if (g_IsDiplomacyOpen)
|
||||
openDiplomacy();
|
||||
|
||||
|
@ -8,11 +8,23 @@
|
||||
<include directory="gui/session/top_panel/"/>
|
||||
|
||||
<!-- ================================ ================================ -->
|
||||
<!-- Some development features -->
|
||||
<!-- "Follow Player" option for observers -->
|
||||
<!-- ================================ ================================ -->
|
||||
<object name="optionFollowPlayer" size="50%+64 4 50%+256 100%" hidden="true">
|
||||
|
||||
<!-- Checkbox -->
|
||||
<object name="followPlayer" type="checkbox" checked="false" style="ModernTickBox" size="0 4 20 100%" font="sans-bold-13">
|
||||
<action on="Press">g_FollowPlayer = !g_FollowPlayer;</action>
|
||||
</object>
|
||||
|
||||
<!-- Label -->
|
||||
<object type="text" size="20 2 100% 100%" text_align="left" textcolor="white">
|
||||
<translatableAttribute id="caption" context="observer mode">Follow Player</translatableAttribute>
|
||||
</object>
|
||||
</object>
|
||||
|
||||
<!-- ================================ ================================ -->
|
||||
<!-- Switch the view perspective to another player's (largely for AI development) -->
|
||||
<!-- Switch the view perspective to another player's (for observers and for eased development) -->
|
||||
<!-- ================================ ================================ -->
|
||||
<object size="100%-415 5 100%-265 100%-5" name="viewPlayer" type="dropdown" hidden="true" style="ModernDropDown" tooltip_style="sessionToolTipBold">
|
||||
<translatableAttribute id="tooltip">Choose player to view</translatableAttribute>
|
||||
|
@ -120,6 +120,7 @@ AttackDetection.prototype.AttackAlert = function(target, attacker)
|
||||
Engine.PostMessage(this.entity, MT_AttackDetected, { "player": cmpPlayer.GetPlayerID(), "event": event });
|
||||
Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface).PushNotification({
|
||||
"type": "attack",
|
||||
"target": target,
|
||||
"players": [cmpPlayer.GetPlayerID()],
|
||||
"attacker": cmpAttackerOwnership.GetOwner(),
|
||||
"targetIsDomesticAnimal": targetIsDomesticAnimal
|
||||
|
@ -23,6 +23,14 @@ function ProcessCommand(player, cmd)
|
||||
if (cmd.entities)
|
||||
data.entities = FilterEntityList(cmd.entities, player, data.controlAllUnits);
|
||||
|
||||
// Allow focusing the camera on recent commands
|
||||
let cmpGuiInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface);
|
||||
cmpGuiInterface.PushNotification({
|
||||
"type": "playercommand",
|
||||
"players": [player],
|
||||
"cmd": cmd
|
||||
});
|
||||
|
||||
// Note: checks of UnitAI targets are not robust enough here, as ownership
|
||||
// can change after the order is issued, they should be checked by UnitAI
|
||||
// when the specific behavior (e.g. attack, garrison) is performed.
|
||||
|
Loading…
Reference in New Issue
Block a user