From 851660c7934e5acd07dd7765002531c8bbbab0c6 Mon Sep 17 00:00:00 2001 From: Frank Date: Fri, 8 Sep 2023 16:11:11 +0200 Subject: [PATCH] NAV --- .../Moose/Navigation/FlightPlan.lua | 16 +++-- Moose Development/Moose/Navigation/NavFix.lua | 6 +- Moose Development/Moose/Ops/FlightGroup.lua | 71 +++++++++++++++++++ 3 files changed, 86 insertions(+), 7 deletions(-) diff --git a/Moose Development/Moose/Navigation/FlightPlan.lua b/Moose Development/Moose/Navigation/FlightPlan.lua index 8a5a6282e..f8f9f74db 100644 --- a/Moose Development/Moose/Navigation/FlightPlan.lua +++ b/Moose Development/Moose/Navigation/FlightPlan.lua @@ -59,13 +59,15 @@ FLIGHTPLAN = { fixes = {} } ---- Type of navaid +--- Type of flightplan. -- @type FLIGHTPLAN.Type --- @field #string VOR VOR --- @field #string NDB NDB +-- @field #string IFRH Instrument Flying Rules High Altitude. +-- @field #string IFRL Instrument Flying Rules Low Altitude. +-- @field #string VFR Visual Flight Rules. FLIGHTPLAN.TYPE={ - VOR="VOR", - NDB="NDB", + IFRH="IFR Heigh", + IFRL="IFR Low", + VFR="VFR", } --- FLIGHTPLAN class version. @@ -198,6 +200,10 @@ end ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + + + + ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/Moose Development/Moose/Navigation/NavFix.lua b/Moose Development/Moose/Navigation/NavFix.lua index 45e387094..281bbc79d 100644 --- a/Moose Development/Moose/Navigation/NavFix.lua +++ b/Moose Development/Moose/Navigation/NavFix.lua @@ -82,6 +82,8 @@ NAVFIX.version="0.0.1" --- Create a new NAVFIX class instance. -- @param #NAVFIX self +-- @param Core.Point#COORDINATE Coordinate of the fix. +-- @param #string Name Name of the fix. Should be unique! -- @return #NAVFIX self function NAVFIX:New(Coordinate, Name) @@ -133,7 +135,7 @@ function NAVFIX:SetCompulsory(Compulsory) return self end ---- Set whether this fix is compulsory. +--- Set whether this is a fly-over fix fix. -- @param #NAVFIX self -- @param #boolean FlyOver If `true`, this is a fly over fix. If `false` or nil, it is not. -- @return #NAVFIX self @@ -142,7 +144,7 @@ function NAVFIX:SetFlyOver(FlyOver) return self end ---- Set whether this is the intermediate fix. +--- Set whether this is the intermediate fix (IF). -- @param #NAVFIX self -- @param #boolean IntermediateFix If `true`, this is an intermediate fix. -- @return #NAVFIX self diff --git a/Moose Development/Moose/Ops/FlightGroup.lua b/Moose Development/Moose/Ops/FlightGroup.lua index ba7cfcf7c..eb68cd0e3 100644 --- a/Moose Development/Moose/Ops/FlightGroup.lua +++ b/Moose Development/Moose/Ops/FlightGroup.lua @@ -3900,6 +3900,7 @@ function FLIGHTGROUP:_InitGroup(Template) self.menu.atc=self.menu.atc or {} --#table self.menu.atc.root=self.menu.atc.root or MENU_GROUP:New(self.group, "ATC") --Core.Menu#MENU_GROUP self.menu.atc.help=self.menu.atc.help or MENU_GROUP:New(self.group, "Help", self.menu.atc.root) --Core.Menu#MENU_GROUP + self.menu.nav.root=self.menu.nav.root or MENU_GROUP:New(self.group, "Navigation") --Core.Menu#MENU_GROUP end -- Units of the group. @@ -5235,6 +5236,76 @@ function FLIGHTGROUP:_GetDistToParking(Spot, Coordinate) return dist end + +--- Create player menu for Navigation. +-- @param #FLIGHTGROUP self +-- @param Core.Menu#MENU_GROUP mainmenu Nav root menu table. +function FLIGHTGROUP:_CreatePlayerMenuNav(mainmenu) + + -- Group info. + local group=self.group + local groupname=self.groupname + local gid=group:GetID() + + -- Get player element. + local player=self:GetPlayerElement() + + -- Debug info. + local text=string.format("Creating NAV player menu for flight %s: in state=%s, player=%s", tostring(self.groupname), self:GetState(), player.status) + self:T(self.lid..text) + + + -- Airbase root menu. + local flightplans=MENU_GROUP:New(group, "Flight Plans", mainmenu) + + for i,_flightplan in pairs(self.flightplans or {}) do + local flightplan=_flightplan --#FLIGHTPLAN + MENU_GROUP_COMMAND:New(group, flightplan.alias, flightplans, self._PlayerSelectFlightplan, self, flightplan) + end + + if self.flightplan then + + local flightplan=MENU_GROUP:New(group, "Current Flight Plan", mainmenu) + + + MENU_GROUP_COMMAND:New(group, "List NavFixes", flightplan, self._PlayerListNavfixes, self, self.flightplan) + end + + + +end + +--- Player selected flightplan from Menu. +-- @param #FLIGHTGROUP self +-- @param Navigation.FlightPlan#FLIGHTPLAN flightplan The flightplan chosen. +function FLIGHTGROUP:_PlayerSelectFlightplan(flightplan) + + self:_SetFlightPlan(flightplan) + + self:_CreatePlayerMenuNav(self.menu.nav) +end + +--- Player selected flightplan from Menu. +-- @param #FLIGHTGROUP self +-- @param Navigation.FlightPlan#FLIGHTPLAN flightplan The flightplan chosen. +function FLIGHTGROUP:_PlayerListNavfixes(flightplan) + + if flightplan then + + local text="Nav Fixes:" + for i,_fix in pairs(flightplan.fixes) do + local fix=_fix --Navigation.NavFix#NAVFIX + + --TODO: parameters of fix to output. + + text=text..string.format("\n%s",fix.name) + end + MESSAGE:New(text, 60):ToGroup(self.group) + + end + +end + ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------