mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
PseudoATC
restructured menu
This commit is contained in:
parent
462564cd01
commit
7dbc9436ed
@ -70,7 +70,7 @@ PSEUDOATC={
|
|||||||
ClassName = "PSEUDOATC",
|
ClassName = "PSEUDOATC",
|
||||||
Debug=false,
|
Debug=false,
|
||||||
player={},
|
player={},
|
||||||
maxairport=9,
|
maxairport=10,
|
||||||
mdur=30,
|
mdur=30,
|
||||||
mrefresh=120,
|
mrefresh=120,
|
||||||
eventsmoose=true,
|
eventsmoose=true,
|
||||||
@ -231,8 +231,16 @@ function PSEUDOATC:_PlayerLanded(EventData)
|
|||||||
-- Get unit, player and place.
|
-- Get unit, player and place.
|
||||||
local _unitName=EventData.IniUnitName
|
local _unitName=EventData.IniUnitName
|
||||||
local _unit, _playername=self:_GetPlayerUnitAndName(_unitName)
|
local _unit, _playername=self:_GetPlayerUnitAndName(_unitName)
|
||||||
local _base=EventData.Place
|
local _base=nil
|
||||||
local _baseName=EventData.PlaceName
|
local _baseName=nil
|
||||||
|
if EventData.place then
|
||||||
|
_base=EventData.place
|
||||||
|
_baseName=EventData.place:getName()
|
||||||
|
end
|
||||||
|
-- if EventData.subplace then
|
||||||
|
-- local _subPlace=EventData.subplace
|
||||||
|
-- local _subPlaceName=EventData.subplace:getName()
|
||||||
|
-- end
|
||||||
|
|
||||||
-- Call landed function.
|
-- Call landed function.
|
||||||
if _unit and _playername and _base then
|
if _unit and _playername and _base then
|
||||||
@ -300,12 +308,13 @@ function PSEUDOATC:PlayerLanded(unit, place)
|
|||||||
local group=unit:GetGroup()
|
local group=unit:GetGroup()
|
||||||
local id=group:GetID()
|
local id=group:GetID()
|
||||||
local PlayerName=self.player[id].playername
|
local PlayerName=self.player[id].playername
|
||||||
local UnitName=self.player[id].playername
|
local Callsign=self.player[id].callsign
|
||||||
|
local UnitName=self.player[id].unitname
|
||||||
local GroupName=self.player[id].groupname
|
local GroupName=self.player[id].groupname
|
||||||
local CallSign=self.player[id].callsign
|
local CallSign=self.player[id].callsign
|
||||||
|
|
||||||
-- Debug message.
|
-- Debug message.
|
||||||
local text=string.format("Player %s (%s) from group %s with ID %d landed at %s", PlayerName, UnitName, GroupName, place)
|
local text=string.format("Player %s (%s) from group %s (ID %d) landed at %s", PlayerName, UnitName, GroupName, id, place)
|
||||||
self:T(PSEUDOATC.id..text)
|
self:T(PSEUDOATC.id..text)
|
||||||
MESSAGE:New(text, 30):ToAllIf(self.Debug)
|
MESSAGE:New(text, 30):ToAllIf(self.Debug)
|
||||||
|
|
||||||
@ -368,26 +377,28 @@ function PSEUDOATC:MenuRefresh(id)
|
|||||||
self:LocalAirports(id)
|
self:LocalAirports(id)
|
||||||
|
|
||||||
-- Create submenu My Positon.
|
-- Create submenu My Positon.
|
||||||
self:MenuAircraft(id)
|
--self:MenuAircraft(id)
|
||||||
|
|
||||||
-- Create submenu airports.
|
-- Create submenu airports.
|
||||||
self:MenuAirports(id)
|
self:MenuAirports(id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Clear player menues.
|
--- Clear player menus.
|
||||||
-- @param #PSEUDOATC self.
|
-- @param #PSEUDOATC self.
|
||||||
-- @param #number id Group id of player unit.
|
-- @param #number id Group id of player unit.
|
||||||
function PSEUDOATC:MenuClear(id)
|
function PSEUDOATC:MenuClear(id)
|
||||||
self:F(id)
|
self:F(id)
|
||||||
|
|
||||||
-- Debug message.
|
-- Debug message.
|
||||||
local text=string.format("Clearing menues for player %s in group %s.", self.player[id].playername, self.player[id].groupname)
|
local text=string.format("Clearing menus for player %s in group %s.", self.player[id].playername, self.player[id].groupname)
|
||||||
self:T(PSEUDOATC.id..text)
|
self:T(PSEUDOATC.id..text)
|
||||||
MESSAGE:New(text,30):ToAllIf(self.Debug)
|
MESSAGE:New(text,30):ToAllIf(self.Debug)
|
||||||
|
|
||||||
|
|
||||||
if self.player[id].menu_airports then
|
if self.player[id].menu_airports then
|
||||||
|
missionCommands.removeItemForGroup(id, self.player[id].menu_airports)
|
||||||
|
--[[
|
||||||
for name,item in pairs(self.player[id].menu_airports) do
|
for name,item in pairs(self.player[id].menu_airports) do
|
||||||
|
|
||||||
-- Debug message.
|
-- Debug message.
|
||||||
@ -396,7 +407,7 @@ function PSEUDOATC:MenuClear(id)
|
|||||||
-- Remove menu item.
|
-- Remove menu item.
|
||||||
missionCommands.removeItemForGroup(id, self.player[id].menu_airports[name])
|
missionCommands.removeItemForGroup(id, self.player[id].menu_airports[name])
|
||||||
end
|
end
|
||||||
|
]]
|
||||||
else
|
else
|
||||||
self:T2(PSEUDOATC.id.."No airports to clear menus.")
|
self:T2(PSEUDOATC.id.."No airports to clear menus.")
|
||||||
end
|
end
|
||||||
@ -407,7 +418,7 @@ function PSEUDOATC:MenuClear(id)
|
|||||||
end
|
end
|
||||||
|
|
||||||
self.player[id].menu_airports=nil
|
self.player[id].menu_airports=nil
|
||||||
self.player[id].menu_aircraft=nil
|
--self.player[id].menu_aircraft=nil
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Create "F10/Pseudo ATC" menu items "Airport Data".
|
--- Create "F10/Pseudo ATC" menu items "Airport Data".
|
||||||
@ -417,7 +428,7 @@ function PSEUDOATC:MenuAirports(id)
|
|||||||
self:F(id)
|
self:F(id)
|
||||||
|
|
||||||
-- Table for menu entries.
|
-- Table for menu entries.
|
||||||
self.player[id].menu_airports={}
|
self.player[id].menu_airports=missionCommands.addSubMenuForGroup(id, "Airports", self.player[id].menu_main)
|
||||||
|
|
||||||
local i=0
|
local i=0
|
||||||
for _,airport in pairs(self.player[id].airports) do
|
for _,airport in pairs(self.player[id].airports) do
|
||||||
@ -432,15 +443,15 @@ function PSEUDOATC:MenuAirports(id)
|
|||||||
local pos=AIRBASE:FindByName(name):GetCoordinate()
|
local pos=AIRBASE:FindByName(name):GetCoordinate()
|
||||||
|
|
||||||
--F10menu_ATC_airports[ID][name] = missionCommands.addSubMenuForGroup(ID, name, F10menu_ATC)
|
--F10menu_ATC_airports[ID][name] = missionCommands.addSubMenuForGroup(ID, name, F10menu_ATC)
|
||||||
local submenu=missionCommands.addSubMenuForGroup(id, name, self.player[id].menu_main)
|
local submenu=missionCommands.addSubMenuForGroup(id, name, self.player[id].menu_airports)
|
||||||
self.player[id].menu_airports[name]=submenu
|
--self.player[id].menu_airports[name]=submenu
|
||||||
|
|
||||||
-- Create menu reporting commands
|
-- Create menu reporting commands
|
||||||
missionCommands.addCommandForGroup(id, "Weather Report", submenu, self.ReportWeather, self, id, pos, name)
|
missionCommands.addCommandForGroup(id, "Weather Report", submenu, self.ReportWeather, self, id, pos, name)
|
||||||
missionCommands.addCommandForGroup(id, "Request QFE", submenu, self.ReportPressure, self, id, "QFE", pos, name)
|
--missionCommands.addCommandForGroup(id, "Request QFE", submenu, self.ReportPressure, self, id, "QFE", pos, name)
|
||||||
missionCommands.addCommandForGroup(id, "Request QNH", submenu, self.ReportPressure, self, id, "QNH", pos, name)
|
--missionCommands.addCommandForGroup(id, "Request QNH", submenu, self.ReportPressure, self, id, "QNH", pos, name)
|
||||||
missionCommands.addCommandForGroup(id, "Request Wind", submenu, self.ReportWind, self, id, pos, name)
|
--missionCommands.addCommandForGroup(id, "Request Wind", submenu, self.ReportWind, self, id, pos, name)
|
||||||
missionCommands.addCommandForGroup(id, "Request Temperature", submenu, self.ReportTemperature, self, id, pos, name)
|
--missionCommands.addCommandForGroup(id, "Request Temperature", submenu, self.ReportTemperature, self, id, pos, name)
|
||||||
missionCommands.addCommandForGroup(id, "Request BR", submenu, self.ReportBR, self, id, pos, name)
|
missionCommands.addCommandForGroup(id, "Request BR", submenu, self.ReportBR, self, id, pos, name)
|
||||||
|
|
||||||
-- Debug message.
|
-- Debug message.
|
||||||
@ -455,7 +466,7 @@ function PSEUDOATC:MenuAircraft(id)
|
|||||||
self:F(id)
|
self:F(id)
|
||||||
|
|
||||||
-- Table for menu entries.
|
-- Table for menu entries.
|
||||||
self.player[id].menu_aircraft={}
|
--self.player[id].menu_aircraft={}
|
||||||
|
|
||||||
local unit=self.player[id].unit --Wrapper.Unit#UNIT
|
local unit=self.player[id].unit --Wrapper.Unit#UNIT
|
||||||
local callsign=self.player[id].callsign
|
local callsign=self.player[id].callsign
|
||||||
@ -465,14 +476,13 @@ function PSEUDOATC:MenuAircraft(id)
|
|||||||
self:T(PSEUDOATC.id..string.format("Creating menu item %s for ID %d", name,id))
|
self:T(PSEUDOATC.id..string.format("Creating menu item %s for ID %d", name,id))
|
||||||
|
|
||||||
-- F10/PseudoATC/My Aircraft (callsign)
|
-- F10/PseudoATC/My Aircraft (callsign)
|
||||||
self.player[id].menu_aircraft.main = missionCommands.addSubMenuForGroup(id, name, self.player[id].menu_main)
|
--self.player[id].menu_aircraft.main = missionCommands.addSubMenuForGroup(id, name, self.player[id].menu_main)
|
||||||
|
|
||||||
|
|
||||||
-- F10/PseudoATC/My Aircraft (callsign)/Waypoints
|
|
||||||
if #self.player[id].waypoints>0 then
|
if #self.player[id].waypoints>0 then
|
||||||
|
|
||||||
--F10menu_ATC_waypoints[ID]={}
|
-- F10/PseudoATC/Waypoints
|
||||||
self.player[id].menu_aircraft_waypoints={}
|
self.player[id].menu_waypoints=missionCommands.addSubMenuForGroup(id, "Waypoints", self.player[id].menu_main)
|
||||||
self.player[id].menu_aircraft_waypoints.main=missionCommands.addSubMenuForGroup(id, "Waypoints", self.player[id].menu_aircraft.main)
|
|
||||||
|
|
||||||
local j=0
|
local j=0
|
||||||
for i, wp in pairs(self.player[id].waypoints) do
|
for i, wp in pairs(self.player[id].waypoints) do
|
||||||
@ -483,27 +493,26 @@ function PSEUDOATC:MenuAircraft(id)
|
|||||||
break -- max ten menu entries
|
break -- max ten menu entries
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Position of Waypoint
|
||||||
local pos=COORDINATE:New(wp.x,wp.alt,wp.z)
|
local pos=COORDINATE:New(wp.x,wp.alt,wp.z)
|
||||||
|
local name=string.format("Waypoint %d", i-1)
|
||||||
local fname=string.format("Waypoint %d for %s", i-1, callsign)
|
|
||||||
local pname=string.format("Waypoint %d", i-1)
|
|
||||||
|
|
||||||
-- "F10/PseudoATC/My Aircraft (callsign)/Waypoints/Waypoint X"
|
-- "F10/PseudoATC/Waypoints/Waypoint X"
|
||||||
local submenu=missionCommands.addSubMenuForGroup(id, pname, self.player[id].menu_aircraft_waypoints.main)
|
local submenu=missionCommands.addSubMenuForGroup(id, name, self.player[id].menu_waypoints)
|
||||||
self.player[id].menu_aircraft_waypoints.pname=submenu
|
|
||||||
|
|
||||||
-- Menu commands for each waypoint "F10/PseudoATC/My Aircraft (callsign)/Waypoints/Waypoint X/<Commands>"
|
-- Menu commands for each waypoint "F10/PseudoATC/My Aircraft (callsign)/Waypoints/Waypoint X/<Commands>"
|
||||||
missionCommands.addCommandForGroup(id, "Weather Report", submenu, self.ReportWeather, self, id, pos, pname)
|
missionCommands.addCommandForGroup(id, "Weather Report", submenu, self.ReportWeather, self, id, pos, name)
|
||||||
missionCommands.addCommandForGroup(id, "Request QFE", submenu, self.ReportPressure, self, id, "QFE", pos, pname)
|
--missionCommands.addCommandForGroup(id, "Request QFE", submenu, self.ReportPressure, self, id, "QFE", pos, pname)
|
||||||
missionCommands.addCommandForGroup(id, "Request QNH", submenu, self.ReportPressure, self, id, "QNH", pos, pname)
|
--missionCommands.addCommandForGroup(id, "Request QNH", submenu, self.ReportPressure, self, id, "QNH", pos, pname)
|
||||||
missionCommands.addCommandForGroup(id, "Request Wind", submenu, self.ReportWind, self, id, pos, pname)
|
--missionCommands.addCommandForGroup(id, "Request Wind", submenu, self.ReportWind, self, id, pos, pname)
|
||||||
missionCommands.addCommandForGroup(id, "Request Temperature", submenu, self.ReportTemperature, self, id, pos, pname)
|
--missionCommands.addCommandForGroup(id, "Request Temperature", submenu, self.ReportTemperature, self, id, pos, pname)
|
||||||
missionCommands.addCommandForGroup(id, "Request BR", submenu, self.ReportBR, self, id, pos, pname)
|
missionCommands.addCommandForGroup(id, "Request BR", submenu, self.ReportBR, self, id, pos, name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
missionCommands.addCommandForGroup(id, "Request current altitude AGL", self.player[id].menu_aircraft.main, self.ReportHeight, self, id)
|
|
||||||
missionCommands.addCommandForGroup(id, "Report altitude until touchdown", self.player[id].menu_aircraft.main, self.AltidudeStartTimer, self, id)
|
missionCommands.addCommandForGroup(id, "Request current altitude AGL", self.player[id].menu_main, self.ReportHeight, self, id)
|
||||||
missionCommands.addCommandForGroup(id, "Quit reporting altitude", self.player[id].menu_aircraft.main, self.AltidudeStopTimer, self, id)
|
missionCommands.addCommandForGroup(id, "Report altitude until touchdown", self.player[id].menu_main, self.AltidudeStartTimer, self, id)
|
||||||
|
missionCommands.addCommandForGroup(id, "Quit reporting altitude", self.player[id].menu_main, self.AltidudeStopTimer, self, id)
|
||||||
end
|
end
|
||||||
|
|
||||||
-----------------------------------------------------------------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@ -211,6 +211,9 @@
|
|||||||
--
|
--
|
||||||
-- The function @{#RANGE.DebugON}() can be used to send messages on screen. It also smokes all defined strafe and bombing targets, the strafe pit approach boxes and the range zone.
|
-- The function @{#RANGE.DebugON}() can be used to send messages on screen. It also smokes all defined strafe and bombing targets, the strafe pit approach boxes and the range zone.
|
||||||
--
|
--
|
||||||
|
-- Note that it can happen that the RANGE radio menu is not shown. Check that the range object is defined as a **global** variable rather than a local one.
|
||||||
|
-- The could avoid the lua garbage collection to accidentally/falsely deallocate the RANGE objects.
|
||||||
|
--
|
||||||
--
|
--
|
||||||
--
|
--
|
||||||
-- @field #RANGE
|
-- @field #RANGE
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user