Skip to content

Commit

Permalink
Merge branch 'master' into fix-vor-station-declination
Browse files Browse the repository at this point in the history
  • Loading branch information
2hwk authored Nov 12, 2024
2 parents cce1803 + 305d6af commit e15ff99
Show file tree
Hide file tree
Showing 12 changed files with 281 additions and 53 deletions.
1 change: 1 addition & 0 deletions fbw-a380x/mach.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ module.exports = {
typecheckingPlugin(),
],
instruments: [
msfsAvionicsInstrument('AtcMailbox'),
msfsAvionicsInstrument('Clock'),
msfsAvionicsInstrument('EWD'),
msfsAvionicsInstrument('FCU', 'FcuBaseInstrument.ts'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ pixel_size=768,1024
texture=$SCREEN_DU_SD

htmlgauge00=A380X/SD/sd.html?duID=7, 0,0,768,1024
htmlgauge01=A380X/AtcMailbox/atcmailbox.html?duID=7, 0,0,768,1024

[VCockpit05]
size_mm=768,1024
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1177,7 +1177,7 @@
</Requires>
</Sound>

<!-- ROP/ROW warnings =====================================================================-->
<!-- V1 callout ===================================================================== -->
<Sound WwiseEvent="V1" WwiseData="true" NodeName="Wiper_Base_l" LocalVar="A32NX_AUDIO_V1_CALLOUT" Continuous="false">
<Range LowerBound="1"/>
<Requires SimVar="ELECTRICAL MAIN BUS VOLTAGE" Units="VOLTS" Index="1">
Expand Down
15 changes: 15 additions & 0 deletions fbw-a380x/src/systems/instruments/src/AtcMailbox/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict';

module.exports = {
extends: ['../../../../../../.eslintrc.js', 'plugin:jsdoc/recommended-typescript-error'],

plugins: ['eslint-plugin-jsdoc'],

// overrides airbnb, use sparingly
rules: {
'react/no-unknown-property': 'off',
'react/style-prop-object': 'off',
'arrow-body-style': 'off',
camelcase: 'off',
},
};
61 changes: 61 additions & 0 deletions fbw-a380x/src/systems/instruments/src/AtcMailbox/AtcMailbox.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Copyright (c) 2024 FlyByWire Simulations
// SPDX-License-Identifier: GPL-3.0

import { DisplayComponent, EventBus, FSComponent, Subject, VNode } from '@microsoft/msfs-sdk';
import { Button } from 'instruments/src/MFD/pages/common/Button';
import { MouseCursor } from 'instruments/src/MFD/pages/common/MouseCursor';
import { CdsDisplayUnit, DisplayUnitID } from '../MsfsAvionicsCommon/CdsDisplayUnit';

import './style.scss';

export interface AtcMailboxProps {
readonly bus: EventBus;
}

export class AtcMailbox extends DisplayComponent<AtcMailboxProps> {
private readonly topRef = FSComponent.createRef<HTMLDivElement>();

private readonly mouseCursorRef = FSComponent.createRef<MouseCursor>();

private onMouseMove(ev: MouseEvent) {
this.mouseCursorRef.getOrDefault()?.updatePosition(ev.clientX, ev.clientY - 768);
}

private onMouseMoveHandler = this.onMouseMove.bind(this);

public onAfterRender(node: VNode): void {
super.onAfterRender(node);

this.topRef.instance.addEventListener('mousemove', this.onMouseMoveHandler);
}

destroy(): void {
this.topRef.getOrDefault()?.removeEventListener('mousemove', this.onMouseMoveHandler);

super.destroy();
}

render(): VNode | null {
return (
<CdsDisplayUnit bus={this.props.bus} displayUnitId={DisplayUnitID.Sd}>
<div ref={this.topRef} class="atc-mailbox-top-layout">
<div class="atc-mailbox-left-layout">
<Button label="RECALL" onClick={() => {}} buttonStyle="height: 50px;"></Button>
</div>
<div class="atc-mailbox-center-layout">
<div class="atc-mailbox-center-top"></div>
<div class="atc-mailbox-center-bottom">
<div class="atc-mailbox-cb-1" />
<div class="atc-mailbox-cb-2" />
</div>
</div>
<div class="atc-mailbox-right-layout">
<Button label="CLOSE" onClick={() => {}} buttonStyle="height: 50px; justify-content: flex-end;"></Button>
<Button label="PRINT" onClick={() => {}} buttonStyle="height: 50px; justify-content: flex-end;"></Button>
</div>
<MouseCursor side={Subject.create('CAPT')} ref={this.mouseCursorRef} />
</div>
</CdsDisplayUnit>
);
}
}
5 changes: 5 additions & 0 deletions fbw-a380x/src/systems/instruments/src/AtcMailbox/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"index": "./instrument.tsx",
"name": "AtcMailbox",
"isInteractive": true
}
105 changes: 105 additions & 0 deletions fbw-a380x/src/systems/instruments/src/AtcMailbox/instrument.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import {
FSComponent,
EventBus,
HEventPublisher,
InstrumentBackplane,
FsInstrument,
FsBaseInstrument,
ClockPublisher,
} from '@microsoft/msfs-sdk';
import { FailuresConsumer } from '@flybywiresim/fbw-sdk';
import { AtcMailbox } from 'instruments/src/AtcMailbox/AtcMailbox';

class AtcMailboxInstrument implements FsInstrument {
private readonly bus = new EventBus();

private readonly backplane = new InstrumentBackplane();

private readonly clockPublisher = new ClockPublisher(this.bus);

private readonly hEventPublisher = new HEventPublisher(this.bus);

private readonly failuresConsumer = new FailuresConsumer('A32NX');

constructor(public readonly instrument: BaseInstrument) {
this.hEventPublisher = new HEventPublisher(this.bus);

this.backplane.addPublisher('hEvent', this.hEventPublisher);
this.backplane.addPublisher('clock', this.clockPublisher);

this.doInit();
}

public doInit(): void {
this.backplane.init();

const atcMailbox = document.getElementById('AtcMailbox_CONTENT');

FSComponent.render(<AtcMailbox bus={this.bus} />, document.getElementById('AtcMailbox_CONTENT'));

// Remove "instrument didn't load" text
atcMailbox?.querySelector(':scope > h1')?.remove();
}

/**
* A callback called when the instrument gets a frame update.
*/
public Update(): void {
this.backplane.onUpdate();
this.failuresConsumer.update();
}

public onInteractionEvent(args: string[]): void {
this.hEventPublisher.dispatchHEvent(args[0]);
}

public onGameStateChanged(_oldState: GameState, _newState: GameState): void {
// noop
}

public onFlightStart(): void {
// noop
}

public onSoundEnd(_soundEventId: Name_Z): void {
// noop
}

public onPowerOn(): void {
// noop
}

public onPowerOff(): void {
// noop
}
}

class A380X_AtcMailbox extends FsBaseInstrument<AtcMailboxInstrument> {
public constructInstrument(): AtcMailboxInstrument {
return new AtcMailboxInstrument(this);
}

public get isInteractive(): boolean {
return true;
}

public get templateID(): string {
return 'A380X_AtcMailbox';
}

/** @inheritdoc */
public onPowerOn(): void {
super.onPowerOn();

this.fsInstrument.onPowerOn();
}

/** @inheritdoc */
public onShutDown(): void {
super.onShutDown();

this.fsInstrument.onPowerOff();
}
}

registerInstrument('a380x-atc-mailbox', A380X_AtcMailbox);
54 changes: 54 additions & 0 deletions fbw-a380x/src/systems/instruments/src/AtcMailbox/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Copyright (c) 2024 FlyByWire Simulations
// SPDX-License-Identifier: GPL-3.0

@import "../MsfsAvionicsCommon/definitions.scss";

.atc-mailbox-top-layout {
display: grid;
grid-template-columns: 13% auto 18%;
height: 256px;
width: 768px;
position: absolute;
top: 768px;
}

.atc-mailbox-left-layout {
display: flex;
flex-direction: column;
justify-content: flex-end;
border-right: 2px solid $display-white;
}

.atc-mailbox-center-layout {
display: flex;
flex-direction: column;
justify-content: flex-end;
}

.atc-mailbox-right-layout {
display: flex;
flex-direction: column;
justify-content: space-between;
border-left: 2px solid $display-white;
}

.atc-mailbox-center-bottom {
display: flex;
flex: 1;
flex-direction: row;
}

.atc-mailbox-center-top {
display: flex;
flex: 8;
border-bottom: 2px solid white;
}

.atc-mailbox-cb-1 {
flex: 1;
border-right: 2px solid white;
}

.atc-mailbox-cb-2 {
flex: 1;
}
33 changes: 33 additions & 0 deletions fbw-a380x/src/systems/instruments/src/AtcMailbox/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"extends": "../../../tsconfig.json",

"compilerOptions": {
"incremental": false /* Enables incremental builds */,
"target": "es2017" /* Specifies the ES2017 target, compatible with Coherent GT */,
"module": "es2015" /* Ensures that modules are at least es2015 */,
"strict": true /* Enables strict type checking, highly recommended but optional */,
"esModuleInterop": true /* Emits additional JS to work with CommonJS modules */,
"skipLibCheck": true /* Skip type checking on library .d.ts files */,
"forceConsistentCasingInFileNames": true /* Ensures correct import casing */,
"moduleResolution": "node" /* Enables compatibility with MSFS SDK bare global imports */,
"jsxFactory": "FSComponent.buildComponent" /* Required for FSComponent framework JSX */,
"jsxFragmentFactory": "FSComponent.Fragment" /* Required for FSComponent framework JSX */,
"jsx": "react", /* Required for FSComponent framework JSX */
"paths": {
"@datalink/aoc": ["../../../fbw-common/src/systems/datalink/aoc/src/index.ts"],
"@datalink/atc": ["../../../fbw-common/src/systems/datalink/atc/src/index.ts"],
"@datalink/common": ["../../../fbw-common/src/systems/datalink/common/src/index.ts"],
"@datalink/router": ["../../../fbw-common/src/systems/datalink/router/src/index.ts"],
"@failures": ["./failures/src/index.ts"],
"@fmgc/*": ["./fmgc/src/*"],
"@instruments/common/*": ["./instruments/src/Common/*"],
"@localization/*": ["../localization/*"],
"@sentry/*": ["./sentry-client/src/*"],
"@simbridge/*": ["./simbridge-client/src/*"],
"@shared/*": ["./shared/src/*"],
"@tcas/*": ["./tcas/src/*"],
"@typings/*": ["../../../fbw-common/src/typings/*"],
"@flybywiresim/fbw-sdk": ["../../../fbw-common/src/systems/index-no-react.ts"],
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const DisplayUnitToPotentiometer: { [k in DisplayUnitID]: number } = {
interface DisplayUnitProps {
displayUnitId: DisplayUnitID;
failed?: boolean;
hideBootTestScreens?: boolean;
}

enum DisplayUnitState {
Expand All @@ -63,7 +64,7 @@ function BacklightBleed(props) {
}

export const LegacyCdsDisplayUnit = forwardRef<SVGSVGElement, PropsWithChildren<DisplayUnitProps>>(
({ displayUnitId, failed, children }, ref) => {
({ displayUnitId, failed, hideBootTestScreens, children }, ref) => {
const [coldDark] = useSimVar('L:A32NX_COLD_AND_DARK_SPAWN' /* TODO 380 simvar */, 'Bool', 200);
const [state, setState] = useState(coldDark ? DisplayUnitState.Off : DisplayUnitState.Standby);
const [timer, setTimer] = useState<number | null>(null);
Expand Down Expand Up @@ -167,7 +168,7 @@ export const LegacyCdsDisplayUnit = forwardRef<SVGSVGElement, PropsWithChildren<
);
}

if (state === DisplayUnitState.ThalesBootup) {
if (state === DisplayUnitState.ThalesBootup && !hideBootTestScreens) {
return (
<>
<BacklightBleed homeCockpit={homeCockpit} />
Expand All @@ -181,7 +182,7 @@ export const LegacyCdsDisplayUnit = forwardRef<SVGSVGElement, PropsWithChildren<
);
}

if (state === DisplayUnitState.Selftest) {
if (state === DisplayUnitState.Selftest && !hideBootTestScreens) {
return (
<>
<BacklightBleed homeCockpit={homeCockpit} />
Expand Down
46 changes: 0 additions & 46 deletions fbw-a380x/src/systems/instruments/src/SD/Mailbox.tsx

This file was deleted.

Loading

0 comments on commit e15ff99

Please sign in to comment.