From 79e682405a1073e15e9d3574face2677c7b96563 Mon Sep 17 00:00:00 2001 From: BravoMike99 <119708186+BravoMike99@users.noreply.github.com> Date: Tue, 28 Jan 2025 20:11:37 +0000 Subject: [PATCH 1/5] fix(mfd): change FPLN scroll with KKCU & soft key --- .../src/MFD/pages/FMS/F-PLN/MfdFmsFpln.tsx | 37 +++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/fbw-a380x/src/systems/instruments/src/MFD/pages/FMS/F-PLN/MfdFmsFpln.tsx b/fbw-a380x/src/systems/instruments/src/MFD/pages/FMS/F-PLN/MfdFmsFpln.tsx index fc573bc1172..bab8ae87be0 100644 --- a/fbw-a380x/src/systems/instruments/src/MFD/pages/FMS/F-PLN/MfdFmsFpln.tsx +++ b/fbw-a380x/src/systems/instruments/src/MFD/pages/FMS/F-PLN/MfdFmsFpln.tsx @@ -34,6 +34,7 @@ import { Units, LegType, TurnDirection, AltitudeDescriptor } from '@flybywiresim import { MfdFmsFplnVertRev } from 'instruments/src/MFD/pages/FMS/F-PLN/MfdFmsFplnVertRev'; import { AltitudeConstraint, SpeedConstraint } from '@fmgc/flightplanning/data/constraint'; import { ConditionalComponent } from '../../../../MsfsAvionicsCommon/UiWidgets/ConditionalComponent'; +import { InternalKccuKeyEvent } from 'instruments/src/MFD/shared/MFDSimvarPublisher'; interface MfdFmsFplnProps extends AbstractMfdPageProps {} @@ -637,7 +638,7 @@ export class MfdFmsFpln extends FmsPage { this.scrollToDest(); } - const sub = this.props.bus.getSubscriber(); + const sub = this.props.bus.getSubscriber(); this.subs.push( sub .on('realTime') @@ -646,6 +647,16 @@ export class MfdFmsFpln extends FmsPage { this.onNewData(); }), ); + + this.subs.push( + sub.on('kccuKeyEvent').handle((k) => { + if (k === 'UP') { + this.displayFplnFromLineIndex.set(this.displayFplnFromLineIndex.get() - 1); + } else if (k === 'DOWN') { + this.displayFplnFromLineIndex.set(this.displayFplnFromLineIndex.get() + 1); + } + }), + ); } checkScrollButtons() { @@ -774,6 +785,26 @@ export class MfdFmsFpln extends FmsPage { } } + private scrollPage(up: boolean) { + if (!this.loadedFlightPlan) { + return; + } + + let targetIndex; + if (up) { + targetIndex = this.displayFplnFromLineIndex.get() - this.renderedFplnLines.length; + if (targetIndex < 0) { + this.displayFplnFromLineIndex.set(0); + } + } else { + targetIndex = this.displayFplnFromLineIndex.get() + this.renderedFplnLines.length; + if (targetIndex > this.lineData.length) { + targetIndex = this.lineData.length; + } + } + this.displayFplnFromLineIndex.set(targetIndex); + } + render(): VNode { return ( <> @@ -904,13 +935,13 @@ export class MfdFmsFpln extends FmsPage {
this.displayFplnFromLineIndex.set(this.displayFplnFromLineIndex.get() + 1)} + onClick={() => this.scrollPage(false)} disabled={this.disabledScrollDown} containerStyle="width: 60px; height: 60px;" /> this.displayFplnFromLineIndex.set(this.displayFplnFromLineIndex.get() - 1)} + onClick={() => this.scrollPage(true)} disabled={this.disabledScrollUp} containerStyle="width: 60px; height: 60px;" /> From 39cb20a43eaccfc4ba2b934fbf5389b200ac0052 Mon Sep 17 00:00:00 2001 From: BravoMike99 <119708186+BravoMike99@users.noreply.github.com> Date: Tue, 28 Jan 2025 20:12:01 +0000 Subject: [PATCH 2/5] chore: delete console time --- .../systems/instruments/src/MFD/pages/FMS/F-PLN/MfdFmsFpln.tsx | 3 --- 1 file changed, 3 deletions(-) diff --git a/fbw-a380x/src/systems/instruments/src/MFD/pages/FMS/F-PLN/MfdFmsFpln.tsx b/fbw-a380x/src/systems/instruments/src/MFD/pages/FMS/F-PLN/MfdFmsFpln.tsx index bab8ae87be0..59119494ffe 100644 --- a/fbw-a380x/src/systems/instruments/src/MFD/pages/FMS/F-PLN/MfdFmsFpln.tsx +++ b/fbw-a380x/src/systems/instruments/src/MFD/pages/FMS/F-PLN/MfdFmsFpln.tsx @@ -118,8 +118,6 @@ export class MfdFmsFpln extends FmsPage { return; } - console.time('F-PLN:onNewData'); - // update(...) is the most costly function. First performance improvement: Don't render everything completely new every time, just update with refs // Delete and re-render FPLN lines only if: // a) activeLegIndex changes @@ -177,7 +175,6 @@ export class MfdFmsFpln extends FmsPage { ); } this.checkScrollButtons(); - console.timeEnd('F-PLN:onNewData'); } private update(startAtIndex: number, onlyUpdatePredictions = true): void { From 2f263b2f4730a501cb0dc2b4b7411f32978561d9 Mon Sep 17 00:00:00 2001 From: BravoMike99 <119708186+BravoMike99@users.noreply.github.com> Date: Tue, 28 Jan 2025 21:26:11 +0000 Subject: [PATCH 3/5] fix(mfd/fpln): keep one waypoint in page nav --- .../src/MFD/pages/FMS/F-PLN/MfdFmsFpln.tsx | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/fbw-a380x/src/systems/instruments/src/MFD/pages/FMS/F-PLN/MfdFmsFpln.tsx b/fbw-a380x/src/systems/instruments/src/MFD/pages/FMS/F-PLN/MfdFmsFpln.tsx index 59119494ffe..14853886f84 100644 --- a/fbw-a380x/src/systems/instruments/src/MFD/pages/FMS/F-PLN/MfdFmsFpln.tsx +++ b/fbw-a380x/src/systems/instruments/src/MFD/pages/FMS/F-PLN/MfdFmsFpln.tsx @@ -787,19 +787,25 @@ export class MfdFmsFpln extends FmsPage { return; } - let targetIndex; - if (up) { - targetIndex = this.displayFplnFromLineIndex.get() - this.renderedFplnLines.length; - if (targetIndex < 0) { - this.displayFplnFromLineIndex.set(0); - } - } else { - targetIndex = this.displayFplnFromLineIndex.get() + this.renderedFplnLines.length; - if (targetIndex > this.lineData.length) { - targetIndex = this.lineData.length; + if (this.lineData) { + let targetIndex; + if (up) { + targetIndex = this.displayFplnFromLineIndex.get() + 1 - this.renderedFplnLines.length; + } else { + targetIndex = this.displayFplnFromLineIndex.get() + this.renderedFplnLines.length - 1; + if (targetIndex > this.lineData.length) { + targetIndex = this.lineData.findIndex( + (it) => + it && + it.originalLegIndex === + (this.loadedFlightPlan?.alternateFlightPlan + ? this.loadedFlightPlan.alternateFlightPlan.lastIndex + : this.loadedFlightPlan?.lastIndex), + ); + } } + this.displayFplnFromLineIndex.set(Math.max(targetIndex, 0)); } - this.displayFplnFromLineIndex.set(targetIndex); } render(): VNode { From 0273ce2eb0f46323c298f30b2925f837f9d0bed3 Mon Sep 17 00:00:00 2001 From: BravoMike99 <119708186+BravoMike99@users.noreply.github.com> Date: Tue, 28 Jan 2025 22:12:17 +0000 Subject: [PATCH 4/5] fix(mfd/fpln): clamp navigation to end of fpln --- .../src/MFD/pages/FMS/F-PLN/MfdFmsFpln.tsx | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/fbw-a380x/src/systems/instruments/src/MFD/pages/FMS/F-PLN/MfdFmsFpln.tsx b/fbw-a380x/src/systems/instruments/src/MFD/pages/FMS/F-PLN/MfdFmsFpln.tsx index 14853886f84..3a8a206972b 100644 --- a/fbw-a380x/src/systems/instruments/src/MFD/pages/FMS/F-PLN/MfdFmsFpln.tsx +++ b/fbw-a380x/src/systems/instruments/src/MFD/pages/FMS/F-PLN/MfdFmsFpln.tsx @@ -650,7 +650,9 @@ export class MfdFmsFpln extends FmsPage { if (k === 'UP') { this.displayFplnFromLineIndex.set(this.displayFplnFromLineIndex.get() - 1); } else if (k === 'DOWN') { - this.displayFplnFromLineIndex.set(this.displayFplnFromLineIndex.get() + 1); + this.displayFplnFromLineIndex.set( + Math.min(this.displayFplnFromLineIndex.get() + 1, this.getLastAllowableIndex()), + ); } }), ); @@ -661,7 +663,7 @@ export class MfdFmsFpln extends FmsPage { this.disabledScrollUp.set( !this.lineData || this.displayFplnFromLineIndex.get() <= (this.loadedFlightPlan?.activeLegIndex ?? 1) - 1, ); - this.disabledScrollDown.set(!this.lineData || this.displayFplnFromLineIndex.get() >= this.lineData.length - 1); + this.disabledScrollDown.set(!this.lineData || this.displayFplnFromLineIndex.get() >= this.getLastAllowableIndex()); } private spdAltButton(): VNode { @@ -793,21 +795,19 @@ export class MfdFmsFpln extends FmsPage { targetIndex = this.displayFplnFromLineIndex.get() + 1 - this.renderedFplnLines.length; } else { targetIndex = this.displayFplnFromLineIndex.get() + this.renderedFplnLines.length - 1; - if (targetIndex > this.lineData.length) { - targetIndex = this.lineData.findIndex( - (it) => - it && - it.originalLegIndex === - (this.loadedFlightPlan?.alternateFlightPlan - ? this.loadedFlightPlan.alternateFlightPlan.lastIndex - : this.loadedFlightPlan?.lastIndex), - ); + const maxBottomIndex = this.getLastAllowableIndex(); + if (targetIndex > maxBottomIndex) { + targetIndex = maxBottomIndex; } } this.displayFplnFromLineIndex.set(Math.max(targetIndex, 0)); } } + private getLastAllowableIndex() { + return this.lineData.length - this.renderedFplnLines.length; + } + render(): VNode { return ( <> From 5425a454841b2be6381cb01d2c8fa8e2b21f5111 Mon Sep 17 00:00:00 2001 From: BravoMike99 <119708186+BravoMike99@users.noreply.github.com> Date: Wed, 29 Jan 2025 00:41:36 +0000 Subject: [PATCH 5/5] fix(mfd): handle tmpy fpln case --- .github/CHANGELOG.md | 1 + .../src/MFD/pages/FMS/F-PLN/MfdFmsFpln.tsx | 23 +++++++++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index cb838a49cb1..ef508a5f238 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -140,6 +140,7 @@ 1. [EFB] Set EFB Auto Brightness to default to On - @MrJigs7 (MrJigs) 1. [FMS] Allow airport to be loaded as fixes in instrument procedures - @tracernz (Mike) 1. [A380X/ND] Fix Terr text wrong position on terrain radar - @MrJigs7 (MrJigs.) +1. [A380X/FMS] Add page scroll via soft keys & individual scroll via KCCU on MFD F-PLN - @BravoMike99 (bruno_pt99) ## 0.12.0 diff --git a/fbw-a380x/src/systems/instruments/src/MFD/pages/FMS/F-PLN/MfdFmsFpln.tsx b/fbw-a380x/src/systems/instruments/src/MFD/pages/FMS/F-PLN/MfdFmsFpln.tsx index 3a8a206972b..0d1f2912a3c 100644 --- a/fbw-a380x/src/systems/instruments/src/MFD/pages/FMS/F-PLN/MfdFmsFpln.tsx +++ b/fbw-a380x/src/systems/instruments/src/MFD/pages/FMS/F-PLN/MfdFmsFpln.tsx @@ -134,6 +134,13 @@ export class MfdFmsFpln extends FmsPage { return; } + // If we ended beyond flightplan end due to TMPY deletion, scroll back to fit the flightplan + const lastAllowableIndex = this.getLastDisplayAllowableIndex(); + if (this.displayFplnFromLineIndex.get() > this.getLastDisplayAllowableIndex()) { + this.displayFplnFromLineIndex.set(lastAllowableIndex); + return; + } + this.update(this.displayFplnFromLineIndex.get(), onlyUpdatePredictions); this.lastRenderedActiveLegIndex = this.loadedFlightPlan.activeLegIndex ?? null; @@ -651,7 +658,7 @@ export class MfdFmsFpln extends FmsPage { this.displayFplnFromLineIndex.set(this.displayFplnFromLineIndex.get() - 1); } else if (k === 'DOWN') { this.displayFplnFromLineIndex.set( - Math.min(this.displayFplnFromLineIndex.get() + 1, this.getLastAllowableIndex()), + Math.min(this.displayFplnFromLineIndex.get() + 1, this.getLastDisplayAllowableIndex()), ); } }), @@ -663,7 +670,9 @@ export class MfdFmsFpln extends FmsPage { this.disabledScrollUp.set( !this.lineData || this.displayFplnFromLineIndex.get() <= (this.loadedFlightPlan?.activeLegIndex ?? 1) - 1, ); - this.disabledScrollDown.set(!this.lineData || this.displayFplnFromLineIndex.get() >= this.getLastAllowableIndex()); + this.disabledScrollDown.set( + !this.lineData || this.displayFplnFromLineIndex.get() >= this.getLastDisplayAllowableIndex(), + ); } private spdAltButton(): VNode { @@ -792,10 +801,10 @@ export class MfdFmsFpln extends FmsPage { if (this.lineData) { let targetIndex; if (up) { - targetIndex = this.displayFplnFromLineIndex.get() + 1 - this.renderedFplnLines.length; + targetIndex = this.displayFplnFromLineIndex.get() + 1 - this.renderedLineData.length; } else { - targetIndex = this.displayFplnFromLineIndex.get() + this.renderedFplnLines.length - 1; - const maxBottomIndex = this.getLastAllowableIndex(); + targetIndex = this.displayFplnFromLineIndex.get() + this.renderedLineData.length - 1; + const maxBottomIndex = this.getLastDisplayAllowableIndex(); if (targetIndex > maxBottomIndex) { targetIndex = maxBottomIndex; } @@ -804,8 +813,8 @@ export class MfdFmsFpln extends FmsPage { } } - private getLastAllowableIndex() { - return this.lineData.length - this.renderedFplnLines.length; + private getLastDisplayAllowableIndex() { + return this.lineData.length - this.renderedLineData.length; } render(): VNode {