mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-09 04:44:01 +00:00
fix(cockpit): C stays the CCTV shortcut when the bridge cannot be entered
With a vessel selected and no aircraft tracked, Cockpit took C and stopped it even when the bridge gate was shut, so the key did nothing and CCTV no longer toggled. C is now taken only when the bridge can be entered. The arrow keys also stay with comboboxes, spinbuttons, trees, grids, menubars, scrollbars and text boxes on a bridge, which move with them.
This commit is contained in:
1 parent
d55acd2ac5
commit
b98bc4b0dc
2 files changed
+40
-3
No files matched your search
@@ -439,6 +439,27 @@ test('C enters the selected vessel bridge and aircraft-only entry refuses it', a
|
||||
assert.equal(event.defaultPrevented, true);
|
||||
});
|
||||
|
||||
test('C stays the CCTV shortcut when the bridge gate is shut', async (t) => {
|
||||
const { cockpit } = fixture(t, { bridgeAllowed: false });
|
||||
let stopped = false;
|
||||
const event = {
|
||||
key: 'c',
|
||||
target: document.body,
|
||||
defaultPrevented: false,
|
||||
preventDefault() {
|
||||
this.defaultPrevented = true;
|
||||
},
|
||||
stopImmediatePropagation() {
|
||||
stopped = true;
|
||||
},
|
||||
};
|
||||
cockpit.onKeyDown(event);
|
||||
await settle();
|
||||
assert.equal(cockpit.active, false);
|
||||
assert.equal(event.defaultPrevented, false);
|
||||
assert.equal(stopped, false, 'the application shortcut still sees C');
|
||||
});
|
||||
|
||||
test('a slow-frame bridge keeps pace with its ship', async (t) => {
|
||||
// One rendered frame a second, as software rendering manages. The bridge
|
||||
// must still cover the ship's distance, not a capped fraction of it.
|
||||
|
||||
+19
-3
@@ -141,7 +141,18 @@ const LOOK_KEY_OWNERS = [
|
||||
'textarea',
|
||||
'select',
|
||||
'[contenteditable]',
|
||||
'[role=combobox]',
|
||||
'[role=grid]',
|
||||
'[role=menubar]',
|
||||
'[role=menuitemcheckbox]',
|
||||
'[role=menuitemradio]',
|
||||
'[role=scrollbar]',
|
||||
'[role=searchbox]',
|
||||
'[role=slider]',
|
||||
'[role=spinbutton]',
|
||||
'[role=textbox]',
|
||||
'[role=tree]',
|
||||
'[role=treeitem]',
|
||||
'[role=tab]',
|
||||
'[role=tablist]',
|
||||
'[role=radio]',
|
||||
@@ -231,13 +242,18 @@ export function onKeyDown(event) {
|
||||
const cockpitAttempt = !!(
|
||||
this.readAircraftInfo() && this.viewer.trackedEntity?.position
|
||||
);
|
||||
// With no tracked aircraft, C takes the selected vessel's bridge.
|
||||
const bridgeAttempt = !cockpitAttempt && !!this.readVesselInfo();
|
||||
// With no tracked aircraft, C takes the selected vessel's bridge, but
|
||||
// only when the bridge can be entered: otherwise C stays the CCTV
|
||||
// shortcut, as it is with nothing selected.
|
||||
const bridgeAttempt =
|
||||
!cockpitAttempt &&
|
||||
!!this.readVesselInfo() &&
|
||||
this.isBridgeEntryAllowed();
|
||||
if (!cockpitAttempt && !bridgeAttempt) return;
|
||||
if (bridgeAttempt) {
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
if (this.isBridgeEntryAllowed()) this.enter({ kind: 'vessel' });
|
||||
this.enter({ kind: 'vessel' });
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user