1
0
forked from mirrors/0ad

Add a hotkey to focus on the last attack alarm

Fix #5608

Differential Revision: https://code.wildfiregames.com/D4101
This was SVN commit r25715.
This commit is contained in:
Imarok
2021-06-06 18:29:48 +00:00
parent e0b492a83a
commit eb2e489898
4 changed files with 29 additions and 7 deletions
+2 -1
View File
@@ -218,6 +218,7 @@ quickload = "Shift+F8"
reset = "R" ; Reset camera rotation to default.
follow = "F" ; Follow the first unit in the selection
rallypointfocus = "" ; Focus the camera on the rally point of the selected building
lastattackfocus = "Space" ; Focus the camera on the last notified attack
zoom.in = Plus, NumPlus ; Zoom camera in (continuous control)
zoom.out = Minus, NumMinus ; Zoom camera out (continuous control)
zoom.wheel.in = WheelUp ; Zoom camera in (stepped control)
@@ -385,7 +386,7 @@ noconfirmation = Shift ; Do not ask confirmation when deleting a game
8 = Comma ; add eighth unit type to queue
[hotkey.session.timewarp]
fastforward = Space ; If timewarp mode enabled, speed up the game
fastforward = "Ctrl+Space" ; If timewarp mode enabled, speed up the game
rewind = "Shift+Backspace" ; If timewarp mode enabled, go back to earlier point in the game
[hotkey.tab]
@@ -21,12 +21,8 @@ ChatMessageFormatSimulation.attack = class
"icon": '[icon="icon_focusattacked"]',
"attacker": colorizePlayernameByID(msg.attacker)
}),
"callback": ((entityId, position) => function() {
let entState = entityId && GetEntityState(entityId);
if (entState && hasClass(entState, "Unit"))
setCameraFollow(entityId);
else
Engine.SetCameraTarget(position.x, position.y, position.z);
"callback": ((target, position) => function() {
focusAttack({ "target": target, "position": position });
})(msg.target, msg.position),
"tooltip": translate("Click to focus on the attacked unit.")
};
@@ -9,6 +9,12 @@
<action on="Press">performCommand(g_Selection.toList().map(ent => GetEntityState(ent)), "focus-rally");</action>
</object>
<object hotkey="camera.lastattackfocus">
<action on="Press">
focusAttack(g_LastAttack);
</action>
</object>
<!-- Camera jumping - press a hotkey to mark a position and another hotkey to jump back there -->
<object hotkey="camera.jump.1">
<action on="Press">jumpCamera(1);</action>
@@ -105,6 +105,8 @@ var g_PlayerStateMessages = {
"defeated": translate("You have been defeated!")
};
var g_LastAttack;
/**
* Defines how the GUI reacts to notifications that are sent by the simulation.
* Don't open new pages (message boxes) here! Otherwise further notifications
@@ -206,6 +208,8 @@ var g_NotificationsTypes =
g_Selection.addList([notification.target]);
}
g_LastAttack = { "target": notification.target, "position": notification.position };
if (Engine.ConfigDB_GetValue("user", "gui.session.notifications.attack") !== "true")
return;
@@ -355,6 +359,21 @@ function handleNotifications()
}
}
function focusAttack(attack)
{
if (!attack)
return;
const entState = attack.target && GetEntityState(attack.target);
if (entState && hasClass(entState, "Unit"))
setCameraFollow(attack.target);
else
{
const position = attack.position;
Engine.SetCameraTarget(position.x, position.y, position.z);
}
}
function toggleTutorial()
{
let tutorialPanel = Engine.GetGUIObjectByName("tutorialPanel");