Skip to content

Commit

Permalink
clean up subscription function for light test.
Browse files Browse the repository at this point in the history
  • Loading branch information
heclak committed Nov 28, 2024
1 parent ae37214 commit a26eb27
Showing 1 changed file with 21 additions and 29 deletions.
50 changes: 21 additions & 29 deletions fbw-a380x/src/systems/instruments/src/FCU/Components/NdData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import { NavAidMode } from '@flybywiresim/fbw-sdk';
import {
Subject,
ConsumerSubject,
DisplayComponent,
EventBus,
Expand Down Expand Up @@ -42,14 +41,7 @@ export class NdData extends DisplayComponent<NdDataProps> {
NavAidMode.Off,
);

private lightsTest = Subject.create(false);

onAfterRender(_node: VNode): void {
this.sub
.on('ovhd_ann_lt_test_active')
.whenChanged()
.handle((v) => this.lightsTest.set(v));
}
private readonly isLightTestActive = ConsumerSubject.create(this.sub.on('ovhd_ann_lt_test_active'), false);

render(): VNode | null {
return (
Expand All @@ -63,62 +55,62 @@ export class NdData extends DisplayComponent<NdDataProps> {
<img
style="position: absolute; top: 0; left: 0"
width="620px"
class={{ hidden: this.lightsTest }}
class={{ hidden: this.isLightTestActive }}
src="/Images/fbw-a380x/fcu/CSTR.png"
/>
<img
style="position: absolute; top: 0; left: 890px"
width="620px"
class={{ hidden: this.lightsTest }}
class={{ hidden: this.isLightTestActive }}
src="/Images/fbw-a380x/fcu/WPT.png"
/>
<img
style="position: absolute; top: 0; left: 1840px"
width="620px"
class={{ hidden: this.lightsTest }}
class={{ hidden: this.isLightTestActive }}
src="/Images/fbw-a380x/fcu/VORD.png"
/>
<img
style="position: absolute; top: 0; left: 2790px"
width="620px"
class={{ hidden: this.lightsTest }}
class={{ hidden: this.isLightTestActive }}
src="/Images/fbw-a380x/fcu/NDB.png"
/>
<img
style="position: absolute; top: 0; left: 3740px"
width="620px"
class={{ hidden: this.lightsTest }}
class={{ hidden: this.isLightTestActive }}
src="/Images/fbw-a380x/fcu/ARPT.png"
/>
{/* LIGHT TESTS */}
<img
style="position: absolute; top: 0; left: 0"
width="620px"
class={{ hidden: this.lightsTest.map(SubscribableMapFunctions.not()) }}
class={{ hidden: this.isLightTestActive.map(SubscribableMapFunctions.not()) }}
src="/Images/fbw-a380x/fcu/TEST.png"
/>
<img
style="position: absolute; top: 0; left: 890px"
width="620px"
class={{ hidden: this.lightsTest.map(SubscribableMapFunctions.not()) }}
class={{ hidden: this.isLightTestActive.map(SubscribableMapFunctions.not()) }}
src="/Images/fbw-a380x/fcu/TEST.png"
/>
<img
style="position: absolute; top: 0; left: 1840px"
width="620px"
class={{ hidden: this.lightsTest.map(SubscribableMapFunctions.not()) }}
class={{ hidden: this.isLightTestActive.map(SubscribableMapFunctions.not()) }}
src="/Images/fbw-a380x/fcu/TEST.png"
/>
<img
style="position: absolute; top: 0; left: 2790px"
width="620px"
class={{ hidden: this.lightsTest.map(SubscribableMapFunctions.not()) }}
class={{ hidden: this.isLightTestActive.map(SubscribableMapFunctions.not()) }}
src="/Images/fbw-a380x/fcu/TEST.png"
/>
<img
style="position: absolute; top: 0; left: 3740px"
width="620px"
class={{ hidden: this.lightsTest.map(SubscribableMapFunctions.not()) }}
class={{ hidden: this.isLightTestActive.map(SubscribableMapFunctions.not()) }}
src="/Images/fbw-a380x/fcu/TEST.png"
/>
</div>
Expand All @@ -127,62 +119,62 @@ export class NdData extends DisplayComponent<NdDataProps> {
<img
style="position: absolute; top: 0; left: 0"
width="620px"
class={{ hidden: this.lightsTest }}
class={{ hidden: this.isLightTestActive }}
src={this.navaidMode1.map((v) => NdData.NAVAID_1_IMAGES[v])}
/>
<img
style="position: absolute; top: 0; left: 890px"
width="620px"
class={{ hidden: this.lightsTest }}
class={{ hidden: this.isLightTestActive }}
src="/Images/fbw-a380x/fcu/WX.png"
/>
<img
style="position: absolute; top: 0; left: 1840px"
width="620px"
class={{ hidden: this.lightsTest }}
class={{ hidden: this.isLightTestActive }}
src="/Images/fbw-a380x/fcu/TERR.png"
/>
<img
style="position: absolute; top: 0; left: 2790px"
width="620px"
class={{ hidden: this.lightsTest }}
class={{ hidden: this.isLightTestActive }}
src="/Images/fbw-a380x/fcu/TRAF.png"
/>
<img
style="position: absolute; top: 0; left: 3740px"
width="620px"
class={{ hidden: this.lightsTest }}
class={{ hidden: this.isLightTestActive }}
src={this.navaidMode2.map((v) => NdData.NAVAID_2_IMAGES[v])}
/>
{/* LIGHT TESTS */}
<img
style="position: absolute; top: 0; left: 0"
width="620px"
class={{ hidden: this.lightsTest.map(SubscribableMapFunctions.not()) }}
class={{ hidden: this.isLightTestActive.map(SubscribableMapFunctions.not()) }}
src="/Images/fbw-a380x/fcu/TEST.png"
/>
<img
style="position: absolute; top: 0; left: 890px"
width="620px"
class={{ hidden: this.lightsTest.map(SubscribableMapFunctions.not()) }}
class={{ hidden: this.isLightTestActive.map(SubscribableMapFunctions.not()) }}
src="/Images/fbw-a380x/fcu/TEST.png"
/>
<img
style="position: absolute; top: 0; left: 1840px"
width="620px"
class={{ hidden: this.lightsTest.map(SubscribableMapFunctions.not()) }}
class={{ hidden: this.isLightTestActive.map(SubscribableMapFunctions.not()) }}
src="/Images/fbw-a380x/fcu/TEST.png"
/>
<img
style="position: absolute; top: 0; left: 2790px"
width="620px"
class={{ hidden: this.lightsTest.map(SubscribableMapFunctions.not()) }}
class={{ hidden: this.isLightTestActive.map(SubscribableMapFunctions.not()) }}
src="/Images/fbw-a380x/fcu/TEST.png"
/>
<img
style="position: absolute; top: 0; left: 3740px"
width="620px"
class={{ hidden: this.lightsTest.map(SubscribableMapFunctions.not()) }}
class={{ hidden: this.isLightTestActive.map(SubscribableMapFunctions.not()) }}
src="/Images/fbw-a380x/fcu/TEST.png"
/>
</div>
Expand Down

0 comments on commit a26eb27

Please sign in to comment.