Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(a380x/mfd): Change soft key behaviour to page & add individual line scroll through KCCU in FPLN #9811

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}

Expand Down Expand Up @@ -117,8 +118,6 @@ export class MfdFmsFpln extends FmsPage<MfdFmsFplnProps> {
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
Expand All @@ -135,6 +134,13 @@ export class MfdFmsFpln extends FmsPage<MfdFmsFplnProps> {
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;
Expand Down Expand Up @@ -176,7 +182,6 @@ export class MfdFmsFpln extends FmsPage<MfdFmsFplnProps> {
);
}
this.checkScrollButtons();
console.timeEnd('F-PLN:onNewData');
}

private update(startAtIndex: number, onlyUpdatePredictions = true): void {
Expand Down Expand Up @@ -637,7 +642,7 @@ export class MfdFmsFpln extends FmsPage<MfdFmsFplnProps> {
this.scrollToDest();
}

const sub = this.props.bus.getSubscriber<ClockEvents>();
const sub = this.props.bus.getSubscriber<ClockEvents & InternalKccuKeyEvent>();
this.subs.push(
sub
.on('realTime')
Expand All @@ -646,14 +651,28 @@ export class MfdFmsFpln extends FmsPage<MfdFmsFplnProps> {
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(
Math.min(this.displayFplnFromLineIndex.get() + 1, this.getLastDisplayAllowableIndex()),
);
}
}),
);
}

checkScrollButtons() {
// Line index for "FROM" waypoint
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.getLastDisplayAllowableIndex(),
);
}

private spdAltButton(): VNode {
Expand Down Expand Up @@ -774,6 +793,30 @@ export class MfdFmsFpln extends FmsPage<MfdFmsFplnProps> {
}
}

private scrollPage(up: boolean) {
if (!this.loadedFlightPlan) {
return;
}

if (this.lineData) {
let targetIndex;
if (up) {
targetIndex = this.displayFplnFromLineIndex.get() + 1 - this.renderedLineData.length;
} else {
targetIndex = this.displayFplnFromLineIndex.get() + this.renderedLineData.length - 1;
const maxBottomIndex = this.getLastDisplayAllowableIndex();
if (targetIndex > maxBottomIndex) {
targetIndex = maxBottomIndex;
}
}
this.displayFplnFromLineIndex.set(Math.max(targetIndex, 0));
}
}

private getLastDisplayAllowableIndex() {
return this.lineData.length - this.renderedLineData.length;
}

render(): VNode {
return (
<>
Expand Down Expand Up @@ -904,13 +947,13 @@ export class MfdFmsFpln extends FmsPage<MfdFmsFplnProps> {
<div style="display: flex; flex-direction: row; margin-top: 5px; margin-bottom: 5px;">
<IconButton
icon="double-down"
onClick={() => this.displayFplnFromLineIndex.set(this.displayFplnFromLineIndex.get() + 1)}
onClick={() => this.scrollPage(false)}
disabled={this.disabledScrollDown}
containerStyle="width: 60px; height: 60px;"
/>
<IconButton
icon="double-up"
onClick={() => this.displayFplnFromLineIndex.set(this.displayFplnFromLineIndex.get() - 1)}
onClick={() => this.scrollPage(true)}
disabled={this.disabledScrollUp}
containerStyle="width: 60px; height: 60px;"
/>
Expand Down