-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
feat(a380x/mfd): Add DATA/WAYPOINT page #9786
Draft
Slightlyclueless
wants to merge
14
commits into
flybywiresim:master
Choose a base branch
from
Slightlyclueless:fms-data-waypoint
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+249
−1
Draft
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
4d63983
Initial implementation
Slightlyclueless 6c865e1
Fix positioning
Slightlyclueless b8c0061
Actually have a footer
Slightlyclueless 565b53a
Minor styling fix
Slightlyclueless 6e10db0
Styling updates
Slightlyclueless b2a8015
pilot stored waypoint selection line initial
Slightlyclueless 90eb9e7
Merge branch 'master' into fms-data-waypoint
Slightlyclueless 71bea66
Change import location due to MFD UI widgets refactor
Slightlyclueless b1c0ff3
styling
Slightlyclueless 98fc1b8
I'm good at naming commits
Slightlyclueless 5942ac1
I don't know if this'll work
Slightlyclueless f6609fa
Merge branch 'master' into fms-data-waypoint
Slightlyclueless d9f7fcc
Add FPLN element retained to the FMS error messages
Slightlyclueless f914d6d
Grab new waypoints in a less dumb way
Slightlyclueless File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
fbw-a380x/src/systems/instruments/src/MFD/pages/FMS/DATA/MfdFmsDataWaypoint.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
@import "../../../../MsfsAvionicsCommon/definitions"; | ||
|
||
.mfd-data-waypoint-input-container { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
margin-top: 20px; | ||
} | ||
|
||
.mfd-data-waypoint-info { | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
margin-top: 150px; | ||
} | ||
|
||
.mfd-data-latlong-text { | ||
display: flex; | ||
flex-direction: row; | ||
} | ||
|
||
.mfd-data-waypoint-stored-container { | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
margin-top: 45px; | ||
} | ||
|
||
.mfd-data-waypoint-stored-ident-row { | ||
display: flex; | ||
flex-direction: row; | ||
} | ||
|
||
.mfd-data-waypoint-list-container { | ||
display: flex; | ||
direction: row; | ||
} |
194 changes: 194 additions & 0 deletions
194
fbw-a380x/src/systems/instruments/src/MFD/pages/FMS/DATA/MfdFmsDataWaypoint.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,194 @@ | ||
import { ArraySubject, FSComponent, Subject, VNode } from '@microsoft/msfs-sdk'; | ||
import { AbstractMfdPageProps } from 'instruments/src/MFD/MFD'; | ||
import { WaypointFormat } from 'instruments/src/MFD/pages/common/DataEntryFormats'; | ||
import { FmsPage } from 'instruments/src/MFD/pages/common/FmsPage'; | ||
import { InputField } from 'instruments/src/MsfsAvionicsCommon/UiWidgets/InputField'; | ||
import { TopTabNavigator, TopTabNavigatorPage } from 'instruments/src/MsfsAvionicsCommon/UiWidgets/TopTabNavigator'; | ||
|
||
import './MfdFmsDataWaypoint.scss'; | ||
import { ConditionalComponent } from 'instruments/src/MsfsAvionicsCommon/UiWidgets/ConditionalComponent'; | ||
import { coordinateToString } from '@flybywiresim/fbw-sdk'; | ||
import { Footer } from 'instruments/src/MFD/pages/common/Footer'; | ||
import { DropdownMenu } from 'instruments/src/MsfsAvionicsCommon/UiWidgets/DropdownMenu'; | ||
import { IconButton } from 'instruments/src/MsfsAvionicsCommon/UiWidgets/IconButton'; | ||
import { PilotWaypoint } from '@fmgc/flightplanning/DataManager'; | ||
import { NavigationDatabaseService } from '@fmgc/flightplanning/NavigationDatabaseService'; | ||
|
||
interface MfdFmsDataWaypointProps extends AbstractMfdPageProps {} | ||
|
||
export class MfdFmsDataWaypoint extends FmsPage<MfdFmsDataWaypointProps> { | ||
private readonly selectedPageIndex = Subject.create<number>(0); | ||
private readonly pilotStoredWaypointsIndex = Subject.create<number | null>(0); | ||
|
||
private readonly waypointIdent = Subject.create<string | null>(null); | ||
|
||
private readonly waypointCoords = Subject.create(''); | ||
|
||
private readonly pilotStoredWaypointsList = ArraySubject.create<PilotWaypoint>([]); | ||
private readonly pilotStoredWaypointNames = ArraySubject.create<string>([]); | ||
|
||
private readonly disabledScrollLeft = Subject.create(true); | ||
private readonly disabledScrollRight = Subject.create(false); | ||
|
||
private readonly db = NavigationDatabaseService.activeDatabase; | ||
|
||
private readonly isWaypointDataVisible = Subject.create<boolean>(false); | ||
private readonly anyPilotStoredWaypoints = Subject.create<boolean>(false); | ||
|
||
protected onNewData(): void { | ||
const pilotStoredWaypoints = this.props.fmcService.master?.getDataManager()?.getAllStoredWaypoints() ?? []; | ||
|
||
this.anyPilotStoredWaypoints.set(pilotStoredWaypoints.length > 0); | ||
this.pilotStoredWaypointsList.set(pilotStoredWaypoints); | ||
} | ||
|
||
private async loadWaypoint(ident: string | null) { | ||
if (ident) { | ||
const waypoint = await this.db.searchWaypoint(ident); | ||
const selectedWaypoint = await this.props.mfd.deduplicateFacilities(waypoint); | ||
|
||
if (selectedWaypoint) { | ||
const waypointCoords = coordinateToString(selectedWaypoint.location.lat, selectedWaypoint.location.long, false); | ||
this.waypointCoords.set(waypointCoords); | ||
} | ||
} | ||
} | ||
|
||
private scrollStoredWaypointButtons(direction: 'left' | 'right'): void { | ||
const currentIndex = this.pilotStoredWaypointsIndex.get() ?? 0; | ||
|
||
this.pilotStoredWaypointsIndex.set(currentIndex + (direction === 'left' ? -1 : 1)); | ||
} | ||
|
||
public onAfterRender(node: VNode): void { | ||
super.onAfterRender(node); | ||
this.waypointIdent.sub((ident: string | null) => { | ||
if (ident) { | ||
this.loadWaypoint(ident); | ||
this.isWaypointDataVisible.set(true); | ||
} else { | ||
this.isWaypointDataVisible.set(false); | ||
} | ||
}); | ||
|
||
this.subs.push( | ||
this.props.mfd.uiService.activeUri.sub((val) => { | ||
if (val.extra === 'database') { | ||
this.selectedPageIndex.set(0); | ||
} else if (val.extra === 'pilot-stored') { | ||
this.selectedPageIndex.set(1); | ||
} | ||
}, true), | ||
); | ||
} | ||
|
||
public render(): VNode { | ||
return ( | ||
<> | ||
{super.render()} | ||
<div class="mfd-page-container"> | ||
<TopTabNavigator | ||
pageTitles={Subject.create(['DATABASE WPTs', 'PILOT STORED WPTs'])} | ||
selectedPageIndex={this.selectedPageIndex} | ||
pageChangeCallback={(val) => { | ||
this.selectedPageIndex.set(val); | ||
}} | ||
selectedTabTextColor="white" | ||
tabBarSlantedEdgeAngle={25} | ||
> | ||
<TopTabNavigatorPage containerStyle="height: 680px;"> | ||
<div class="mfd-data-waypoint-input-container"> | ||
<div class="mfd-label" style="position: relative; right: 65px"> | ||
WPT IDENT | ||
</div> | ||
<InputField<string> | ||
dataEntryFormat={new WaypointFormat()} | ||
dataHandlerDuringValidation={async (v) => this.waypointIdent.set(v)} | ||
mandatory={Subject.create(true)} | ||
canBeCleared={Subject.create(false)} | ||
value={this.waypointIdent} | ||
alignText="center" | ||
errorHandler={(e) => this.props.fmcService.master?.showFmsErrorMessage(e)} | ||
hEventConsumer={this.props.mfd.hEventConsumer} | ||
interactionMode={this.props.mfd.interactionMode} | ||
containerStyle="position: relative; right: 60px;" | ||
/> | ||
</div> | ||
|
||
<div class="mfd-data-waypoint-info-container"> | ||
<ConditionalComponent | ||
condition={this.isWaypointDataVisible} | ||
componentIfTrue={ | ||
<div class="mfd-data-waypoint-info"> | ||
<div class="mfd-data-latlong-text"> | ||
<div class="mfd-label" style="position: relative; right: 75px;"> | ||
LAT | ||
</div> | ||
<div class="mfd-label" style="position: relative; left: 75px;"> | ||
LONG | ||
</div> | ||
</div> | ||
<div class="mfd-value bigger mfd-data-airport-coords">{this.waypointCoords}</div> | ||
</div> | ||
} | ||
componentIfFalse={<></>} | ||
/> | ||
</div> | ||
</TopTabNavigatorPage> | ||
<TopTabNavigatorPage containerStyle="height: 680px;"> | ||
<ConditionalComponent | ||
condition={this.anyPilotStoredWaypoints} | ||
componentIfTrue={ | ||
<div class="mfd-data-waypoint-list-container"> | ||
<div class="mfd-label" style="align-self:center; position: relative; top: 45px;"> | ||
WPT IDENT | ||
</div> | ||
<DropdownMenu | ||
values={this.pilotStoredWaypointNames} | ||
selectedIndex={this.pilotStoredWaypointsIndex} | ||
freeTextAllowed={false} | ||
idPrefix={`${this.props.mfd.uiService.captOrFo}_MFD_dataWaypointListDropdown`} | ||
hEventConsumer={this.props.mfd.hEventConsumer} | ||
interactionMode={this.props.mfd.interactionMode} | ||
/> | ||
<div class="mfd-data-waypoint-stored-list-scroll-buttons"> | ||
<IconButton | ||
icon="double-left" | ||
onClick={() => this.scrollStoredWaypointButtons('left')} | ||
disabled={this.disabledScrollLeft} | ||
containerStyle="width: 50px; height: 50px; margin-right: 5px" | ||
/> | ||
<IconButton | ||
icon="double-right" | ||
onClick={() => this.scrollStoredWaypointButtons('right')} | ||
disabled={this.disabledScrollRight} | ||
containerStyle="width: 50px; height: 50px;" | ||
/> | ||
</div> | ||
<div class="mfd-label">{this.pilotStoredWaypointsList.length.toString().padStart(2, '0')}</div> | ||
<div class="mfd-data-waypoint-stored-ll-display"> | ||
<div class="mfd-lable">LAT</div> | ||
<div class="mfd-lable">LAT</div> | ||
</div> | ||
</div> | ||
} | ||
componentIfFalse={ | ||
<div class="mfd-data-waypoint-stored-container"> | ||
<div class="mfd-data-waypoint-stored-ident-row"> | ||
<div class="mfd-label" style="position: relative;"> | ||
NO PILOT STORED WPT | ||
</div> | ||
</div> | ||
</div> | ||
} | ||
></ConditionalComponent> | ||
</TopTabNavigatorPage> | ||
</TopTabNavigator> | ||
<div style="flex-grow: 1;" /> | ||
{/* fill space vertically */} | ||
</div> | ||
<Footer bus={this.props.bus} mfd={this.props.mfd} fmcService={this.props.fmcService} /> | ||
</> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be better to just return undefined though rather than allocating an array every call when it's empty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, I dislike returning undefined for elements like this. This shouldn't be called that often so I feel like the allocation is not going to be that bad (this may be C/Rust brain thinking where an allocation for that slice would be tiny)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then why not have this.storedWaypoints always an array instead? If this is being called every time the page updates it's allocating quite a lot of unneeded objects across a flight. It's death by a thousand cuts with GC pauses = microstutter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just checked, it already is (Line 61). So this function doesn't need any nullish coaliescing at all, it can just return the array