prelim TLR
This commit is contained in:
+44
-5
@@ -1,18 +1,57 @@
|
||||
/// <reference types="@microsoft/msfs-types/Pages/VCockpit/Core/VCockpit" />
|
||||
import './index.scss';
|
||||
|
||||
import { FSComponent } from "@microsoft/msfs-sdk";
|
||||
import { Test } from "./components/test/test";
|
||||
import { EventBus, FSComponent, SimVarPublisher, SimVarValueType, Subject } from '@microsoft/msfs-sdk';
|
||||
import { TLR } from './components/tlr/tlr';
|
||||
|
||||
export interface NewDataEvents {
|
||||
newData: boolean;
|
||||
}
|
||||
|
||||
class KH_FE_FPLAN extends BaseInstrument {
|
||||
private readonly bus = new EventBus();
|
||||
|
||||
private readonly newDataPublisher = new SimVarPublisher<NewDataEvents>(
|
||||
new Map([['newData', { name: 'L:KH_FE_FPLAN_NEW_DATA', type: SimVarValueType.Bool }]]),
|
||||
this.bus
|
||||
);
|
||||
|
||||
private contentPLAN = Subject.create<string>('');
|
||||
private contentTLR = Subject.create<string>('');
|
||||
|
||||
get templateID(): string {
|
||||
return "KH_FE_FPLAN";
|
||||
return 'kh-fe-fplan';
|
||||
}
|
||||
|
||||
get isInteractive() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public connectedCallback(): void {
|
||||
super.connectedCallback();
|
||||
|
||||
FSComponent.render(<Test />, document.getElementById("InstrumentContent"));
|
||||
this.newDataPublisher.startPublish();
|
||||
this.bus
|
||||
.getSubscriber<NewDataEvents>()
|
||||
.on('newData')
|
||||
.handle((flag) => {
|
||||
if (!flag) return;
|
||||
SimVar.SetSimVarValue('L:KH_FE_FPLAN_NEW_DATA', 'bool', 0);
|
||||
this.contentPLAN.set(JSON.parse(window.localStorage.getItem('KH_FE_FPLAN_PLAN') ?? ''));
|
||||
this.contentTLR.set(JSON.parse(window.localStorage.getItem('KH_FE_FPLAN_TLR') ?? ''));
|
||||
});
|
||||
|
||||
window.localStorage.removeItem('KH_FE_FPLAN_PLAN');
|
||||
window.localStorage.removeItem('KH_FE_FPLAN_TLR');
|
||||
|
||||
FSComponent.render(<TLR content={this.contentTLR} />, document.getElementById('root'));
|
||||
}
|
||||
|
||||
protected Update(): void {
|
||||
super.Update();
|
||||
|
||||
this.newDataPublisher.onUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
registerInstrument("KH_FE_FPLAN", KH_FE_FPLAN);
|
||||
registerInstrument('kh-fe-fplan', KH_FE_FPLAN);
|
||||
|
||||
Reference in New Issue
Block a user