mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
OK. Menu is working again ...
This commit is contained in:
parent
af55214c52
commit
83ed29a90a
@ -153,8 +153,9 @@ do -- MENU_BASE
|
|||||||
self.MenuText = MenuText
|
self.MenuText = MenuText
|
||||||
self.MenuParentPath = MenuParentPath
|
self.MenuParentPath = MenuParentPath
|
||||||
self.Menus = {}
|
self.Menus = {}
|
||||||
|
self.MenuCount = 0
|
||||||
|
self.MenuRemoveParent = false
|
||||||
self.MenuTime = timer.getTime()
|
self.MenuTime = timer.getTime()
|
||||||
|
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@ -168,6 +169,16 @@ do -- MENU_BASE
|
|||||||
return self.Menus[MenuText]
|
return self.Menus[MenuText]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Sets a @{Menu} to remove automatically the parent menu when the menu removed is the last child menu of that parent @{Menu}.
|
||||||
|
-- @param #MENU_BASE self
|
||||||
|
-- @param #boolean RemoveParent If true, the parent menu is automatically removed when this menu is the last child menu of that parent @{Menu}.
|
||||||
|
-- @return #MENU_BASE
|
||||||
|
function MENU_BASE:SetRemoveParent( RemoveParent )
|
||||||
|
self:F( { RemoveParent } )
|
||||||
|
self.MenuRemoveParent = RemoveParent
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Sets a time stamp for later prevention of menu removal.
|
--- Sets a time stamp for later prevention of menu removal.
|
||||||
-- @param #MENU_BASE self
|
-- @param #MENU_BASE self
|
||||||
@ -804,9 +815,10 @@ do
|
|||||||
self:T( { "Adding Menu ", MenuText, self.MenuParentPath } )
|
self:T( { "Adding Menu ", MenuText, self.MenuParentPath } )
|
||||||
self.MenuPath = missionCommands.addSubMenuForGroup( self.MenuGroupID, MenuText, self.MenuParentPath )
|
self.MenuPath = missionCommands.addSubMenuForGroup( self.MenuGroupID, MenuText, self.MenuParentPath )
|
||||||
|
|
||||||
if ParentMenu and ParentMenu.Menus then
|
if self.ParentMenu and self.ParentMenu.Menus then
|
||||||
ParentMenu.Menus[MenuText] = self
|
self.ParentMenu.Menus[MenuText] = self
|
||||||
self:F( { ParentMenu.Menus, MenuText } )
|
self:F( { self.ParentMenu.Menus, MenuText } )
|
||||||
|
self.ParentMenu.MenuCount = self.ParentMenu.MenuCount + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -829,13 +841,16 @@ do
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Removes the main menu of this MENU_GROUP.
|
|
||||||
|
--- Removes the main menu and sub menus recursively of this MENU_GROUP.
|
||||||
-- @param #MENU_GROUP self
|
-- @param #MENU_GROUP self
|
||||||
-- @param MenuTime
|
-- @param MenuTime
|
||||||
-- @return #nil
|
-- @return #nil
|
||||||
function MENU_GROUP:RemoveTop( MenuTime )
|
function MENU_GROUP:Remove( MenuTime )
|
||||||
self:F( { self.MenuGroupID, self.MenuPath, MenuTime, self.MenuTime } )
|
self:F( { self.MenuGroupID, self.MenuPath, MenuTime, self.MenuTime } )
|
||||||
|
|
||||||
|
self:RemoveSubMenus( MenuTime )
|
||||||
|
|
||||||
if not MenuTime or self.MenuTime ~= MenuTime then
|
if not MenuTime or self.MenuTime ~= MenuTime then
|
||||||
if self.MenuGroup._Menus[self.Path] then
|
if self.MenuGroup._Menus[self.Path] then
|
||||||
self = self.MenuGroup._Menus[self.Path]
|
self = self.MenuGroup._Menus[self.Path]
|
||||||
@ -843,25 +858,19 @@ do
|
|||||||
missionCommands.removeItemForGroup( self.MenuGroupID, self.MenuPath )
|
missionCommands.removeItemForGroup( self.MenuGroupID, self.MenuPath )
|
||||||
if self.ParentMenu then
|
if self.ParentMenu then
|
||||||
self.ParentMenu.Menus[self.MenuText] = nil
|
self.ParentMenu.Menus[self.MenuText] = nil
|
||||||
|
self.ParentMenu.MenuCount = self.ParentMenu.MenuCount - 1
|
||||||
|
if self.ParentMenu.MenuCount == 0 then
|
||||||
|
if self.MenuRemoveParent == true then
|
||||||
|
self:T( "Removing Parent Menu " )
|
||||||
|
self.ParentMenu:Remove()
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
self:T( { "Removing Group Menu:", self.MenuGroup:GetName(), self.MenuGroup._Menus[self.Path].Path } )
|
self:T( { "Removing Group Menu:", self.MenuGroup:GetName(), self.MenuGroup._Menus[self.Path].Path } )
|
||||||
self.MenuGroup._Menus[self.Path] = nil
|
self.MenuGroup._Menus[self.Path] = nil
|
||||||
self = nil
|
self = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return nil
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Removes the main menu and sub menus recursively of this MENU_GROUP.
|
|
||||||
-- @param #MENU_GROUP self
|
|
||||||
-- @param MenuTime
|
|
||||||
-- @return #nil
|
|
||||||
function MENU_GROUP:Remove( MenuTime )
|
|
||||||
self:F( { self.MenuGroupID, self.MenuPath } )
|
|
||||||
|
|
||||||
self:RemoveSubMenus( MenuTime )
|
|
||||||
|
|
||||||
self:RemoveTop( MenuTime )
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
@ -902,14 +911,13 @@ do
|
|||||||
self:T( { "Adding Group Command Menu:", MenuGroup:GetName(), MenuText, self.MenuParentPath } )
|
self:T( { "Adding Group Command Menu:", MenuGroup:GetName(), MenuText, self.MenuParentPath } )
|
||||||
self.MenuPath = missionCommands.addCommandForGroup( self.MenuGroupID, MenuText, self.MenuParentPath, self.MenuCallHandler, arg )
|
self.MenuPath = missionCommands.addCommandForGroup( self.MenuGroupID, MenuText, self.MenuParentPath, self.MenuCallHandler, arg )
|
||||||
|
|
||||||
if ParentMenu and ParentMenu.Menus then
|
if self.ParentMenu and self.ParentMenu.Menus then
|
||||||
ParentMenu.Menus[MenuText] = self
|
self.ParentMenu.Menus[MenuText] = self
|
||||||
|
self.ParentMenu.MenuCount = self.ParentMenu.MenuCount + 1
|
||||||
self:F( { ParentMenu.Menus, MenuText } )
|
self:F( { ParentMenu.Menus, MenuText } )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--self:F( { MenuGroup:GetName(), MenuText, ParentMenu.MenuPath } )
|
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -926,7 +934,16 @@ do
|
|||||||
|
|
||||||
missionCommands.removeItemForGroup( self.MenuGroupID, self.MenuPath )
|
missionCommands.removeItemForGroup( self.MenuGroupID, self.MenuPath )
|
||||||
self:T( { "Removing Group Command Menu:", self.MenuGroup:GetName(), self.MenuText, self.Path, self.MenuGroup._Menus[self.Path].Path } )
|
self:T( { "Removing Group Command Menu:", self.MenuGroup:GetName(), self.MenuText, self.Path, self.MenuGroup._Menus[self.Path].Path } )
|
||||||
|
|
||||||
self.ParentMenu.Menus[self.MenuText] = nil
|
self.ParentMenu.Menus[self.MenuText] = nil
|
||||||
|
self.ParentMenu.MenuCount = self.ParentMenu.MenuCount - 1
|
||||||
|
if self.ParentMenu.MenuCount == 0 then
|
||||||
|
if self.MenuRemoveParent == true then
|
||||||
|
self:T( "Removing Parent Menu " )
|
||||||
|
self.ParentMenu:Remove()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
self.MenuGroup._Menus[self.Path] = nil
|
self.MenuGroup._Menus[self.Path] = nil
|
||||||
self = nil
|
self = nil
|
||||||
end
|
end
|
||||||
@ -935,17 +952,5 @@ do
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Removes a menu for a group.
|
|
||||||
-- @param #MENU_GROUP_COMMAND self
|
|
||||||
-- @param MenuTime
|
|
||||||
-- @return #nil
|
|
||||||
function MENU_GROUP_COMMAND:RemoveTop( MenuTime )
|
|
||||||
self:F( { self.MenuGroupID, self.MenuPath, MenuTime, self.MenuTime } )
|
|
||||||
|
|
||||||
self:Remove( MenuTime )
|
|
||||||
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -20,7 +20,9 @@ function REPORT:New( Title )
|
|||||||
local self = BASE:Inherit( self, BASE:New() )
|
local self = BASE:Inherit( self, BASE:New() )
|
||||||
|
|
||||||
self.Report = {}
|
self.Report = {}
|
||||||
self.Report[#self.Report+1] = Title
|
if Title then
|
||||||
|
self.Report[#self.Report+1] = Title
|
||||||
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@ -31,7 +33,7 @@ end
|
|||||||
-- @return #REPORT
|
-- @return #REPORT
|
||||||
function REPORT:Add( Text )
|
function REPORT:Add( Text )
|
||||||
self.Report[#self.Report+1] = Text
|
self.Report[#self.Report+1] = Text
|
||||||
return self.Report[#self.Report+1]
|
return self.Report[#self.Report]
|
||||||
end
|
end
|
||||||
|
|
||||||
function REPORT:Text()
|
function REPORT:Text()
|
||||||
@ -249,7 +251,8 @@ end
|
|||||||
-- @param #sring Name (optional) The name of the Group used as a prefix for the message to the Group. If not provided, there will be nothing shown.
|
-- @param #sring Name (optional) The name of the Group used as a prefix for the message to the Group. If not provided, there will be nothing shown.
|
||||||
function COMMANDCENTER:MessageToGroup( Message, TaskGroup, Name )
|
function COMMANDCENTER:MessageToGroup( Message, TaskGroup, Name )
|
||||||
|
|
||||||
local Prefix = Name and "@ Group (" .. Name .. "): " or ''
|
local Prefix = "@ Group"
|
||||||
|
Prefix = Prefix .. ( Name and " (" .. Name .. "): " or '' )
|
||||||
Message = Prefix .. Message
|
Message = Prefix .. Message
|
||||||
self:GetPositionable():MessageToGroup( Message , 20, TaskGroup, self:GetName() )
|
self:GetPositionable():MessageToGroup( Message , 20, TaskGroup, self:GetName() )
|
||||||
|
|
||||||
|
|||||||
@ -343,7 +343,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- Assign the @{Task}to a @{Group}.
|
--- Assign the @{Task} to a @{Group}.
|
||||||
-- @param #TASK self
|
-- @param #TASK self
|
||||||
-- @param Wrapper.Group#GROUP TaskGroup
|
-- @param Wrapper.Group#GROUP TaskGroup
|
||||||
-- @return #TASK
|
-- @return #TASK
|
||||||
@ -355,12 +355,11 @@ function TASK:AssignToGroup( TaskGroup )
|
|||||||
TaskGroup:SetState( TaskGroup, "Assigned", self )
|
TaskGroup:SetState( TaskGroup, "Assigned", self )
|
||||||
|
|
||||||
local Mission = self:GetMission()
|
local Mission = self:GetMission()
|
||||||
local CommandCenter = Mission:GetCommandCenter()
|
local MissionMenu = Mission:GetMenu( TaskGroup )
|
||||||
|
MissionMenu:RemoveSubMenus()
|
||||||
CommandCenter:SetMenu()
|
|
||||||
|
|
||||||
--self:RemoveMenuForGroup( TaskGroup )
|
--self:RemoveMenuForGroup( TaskGroup )
|
||||||
--self:SetAssignedMenuForGroup( TaskGroup )
|
self:SetAssignedMenuForGroup( TaskGroup )
|
||||||
|
|
||||||
local TaskUnits = TaskGroup:GetUnits()
|
local TaskUnits = TaskGroup:GetUnits()
|
||||||
for UnitID, UnitData in pairs( TaskUnits ) do
|
for UnitID, UnitData in pairs( TaskUnits ) do
|
||||||
@ -474,7 +473,7 @@ function TASK:UnAssignFromGroup( TaskGroup )
|
|||||||
|
|
||||||
TaskGroup:SetState( TaskGroup, "Assigned", nil )
|
TaskGroup:SetState( TaskGroup, "Assigned", nil )
|
||||||
|
|
||||||
self:RemoveMenuForGroup( TaskGroup )
|
self:RemoveAssignedMenuForGroup( TaskGroup )
|
||||||
|
|
||||||
local TaskUnits = TaskGroup:GetUnits()
|
local TaskUnits = TaskGroup:GetUnits()
|
||||||
for UnitID, UnitData in pairs( TaskUnits ) do
|
for UnitID, UnitData in pairs( TaskUnits ) do
|
||||||
@ -549,21 +548,6 @@ function TASK:SetMenu( MenuTime )
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Remove the menu options of the @{Task} to all the groups in the SetGroup.
|
|
||||||
-- @param #TASK self
|
|
||||||
-- @param #number MenuTime
|
|
||||||
-- @return #TASK
|
|
||||||
function TASK:RemoveMenu( MenuTime )
|
|
||||||
self:F()
|
|
||||||
|
|
||||||
for TaskGroupID, TaskGroup in pairs( self.SetGroup:GetSet() ) do
|
|
||||||
local TaskGroup = TaskGroup -- Wrapper.Group#GROUP
|
|
||||||
if TaskGroup:IsAlive() and TaskGroup:GetPlayerNames() then
|
|
||||||
self:RemoveMenuForGroup( TaskGroup, MenuTime )
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
--- Set the Menu for a Group
|
--- Set the Menu for a Group
|
||||||
-- @param #TASK self
|
-- @param #TASK self
|
||||||
@ -602,7 +586,7 @@ function TASK:SetPlannedMenuForGroup( TaskGroup, MenuText, MenuTime )
|
|||||||
|
|
||||||
local TaskType = self:GetType()
|
local TaskType = self:GetType()
|
||||||
local TaskTypeMenu = MENU_GROUP:New( TaskGroup, TaskType, MissionMenu ):SetTime( MenuTime )
|
local TaskTypeMenu = MENU_GROUP:New( TaskGroup, TaskType, MissionMenu ):SetTime( MenuTime )
|
||||||
local TaskMenu = MENU_GROUP_COMMAND:New( TaskGroup, MenuText, TaskTypeMenu, self.MenuAssignToGroup, { self = self, TaskGroup = TaskGroup } ):SetTime( MenuTime )
|
local TaskMenu = MENU_GROUP_COMMAND:New( TaskGroup, MenuText, TaskTypeMenu, self.MenuAssignToGroup, { self = self, TaskGroup = TaskGroup } ):SetTime( MenuTime ):SetRemoveParent( true )
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@ -626,12 +610,30 @@ function TASK:SetAssignedMenuForGroup( TaskGroup, MenuTime )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Remove the menu options of the @{Task} to all the groups in the SetGroup.
|
||||||
|
-- @param #TASK self
|
||||||
|
-- @param #number MenuTime
|
||||||
|
-- @return #TASK
|
||||||
|
function TASK:RemoveMenu( MenuTime )
|
||||||
|
self:F()
|
||||||
|
|
||||||
|
for TaskGroupID, TaskGroup in pairs( self.SetGroup:GetSet() ) do
|
||||||
|
local TaskGroup = TaskGroup -- Wrapper.Group#GROUP
|
||||||
|
if TaskGroup:IsAlive() and TaskGroup:GetPlayerNames() then
|
||||||
|
if not self:IsAssignedToGroup( TaskGroup ) then
|
||||||
|
self:RemovePlannedMenuForGroup( TaskGroup, MenuTime )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Remove the menu option of the @{Task} for a @{Group}.
|
--- Remove the menu option of the @{Task} for a @{Group}.
|
||||||
-- @param #TASK self
|
-- @param #TASK self
|
||||||
-- @param Wrapper.Group#GROUP TaskGroup
|
-- @param Wrapper.Group#GROUP TaskGroup
|
||||||
-- @param #number MenuTime
|
-- @param #number MenuTime
|
||||||
-- @return #TASK self
|
-- @return #TASK self
|
||||||
function TASK:RemoveMenuForGroup( TaskGroup, MenuTime )
|
function TASK:RemovePlannedMenuForGroup( TaskGroup, MenuTime )
|
||||||
self:F()
|
self:F()
|
||||||
|
|
||||||
local Mission = self:GetMission()
|
local Mission = self:GetMission()
|
||||||
@ -646,12 +648,28 @@ function TASK:RemoveMenuForGroup( TaskGroup, MenuTime )
|
|||||||
if TypeMenu then
|
if TypeMenu then
|
||||||
local TaskMenu = TypeMenu:GetMenu( self:GetTaskName() )
|
local TaskMenu = TypeMenu:GetMenu( self:GetTaskName() )
|
||||||
if TaskMenu then
|
if TaskMenu then
|
||||||
TaskMenu:RemoveTop( MenuTime )
|
TaskMenu:Remove( MenuTime )
|
||||||
end
|
end
|
||||||
TypeMenu:RemoveTop( MenuTime )
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
MissionMenu:RemoveTop( MenuTime )
|
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Remove the assigned menu option of the @{Task} for a @{Group}.
|
||||||
|
-- @param #TASK self
|
||||||
|
-- @param Wrapper.Group#GROUP TaskGroup
|
||||||
|
-- @param #number MenuTime
|
||||||
|
-- @return #TASK self
|
||||||
|
function TASK:RemoveAssignedMenuForGroup( TaskGroup )
|
||||||
|
self:F()
|
||||||
|
|
||||||
|
local Mission = self:GetMission()
|
||||||
|
local MissionName = Mission:GetName()
|
||||||
|
|
||||||
|
local MissionMenu = Mission:GetMenu( TaskGroup )
|
||||||
|
|
||||||
|
if MissionMenu then
|
||||||
|
MissionMenu:RemoveSubMenus()
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -670,7 +688,10 @@ end
|
|||||||
-- @param #TASK self
|
-- @param #TASK self
|
||||||
function TASK:MenuTaskStatus( TaskGroup )
|
function TASK:MenuTaskStatus( TaskGroup )
|
||||||
|
|
||||||
self:ReportDetails()
|
local ReportText = self:ReportDetails()
|
||||||
|
|
||||||
|
self:T( ReportText )
|
||||||
|
self:GetMission():GetCommandCenter():MessageToGroup( ReportText, TaskGroup )
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1112,24 +1133,19 @@ function TASK:ReportDetails()
|
|||||||
-- Determine the status of the Task.
|
-- Determine the status of the Task.
|
||||||
local State = self:GetState()
|
local State = self:GetState()
|
||||||
|
|
||||||
|
|
||||||
-- Loop each Unit active in the Task, and find Player Names.
|
-- Loop each Unit active in the Task, and find Player Names.
|
||||||
local PlayerNames = {}
|
local PlayerNames = {}
|
||||||
for PlayerGroupID, PlayerGroup in pairs( self:GetGroups():GetSet() ) do
|
local PlayerReport = REPORT:New( " - Players:" )
|
||||||
local Player = PlayerGroup -- Wrapper.Group#GROUP
|
for PlayerGroupID, PlayerGroupData in pairs( self:GetGroups():GetSet() ) do
|
||||||
for PlayerUnitID, PlayerUnit in pairs( PlayerGroup:GetUnits() ) do
|
local PlayerGroup = PlayerGroupData -- Wrapper.Group#GROUP
|
||||||
local PlayerUnit = PlayerUnit -- Wrapper.Unit#UNIT
|
PlayerNames = PlayerGroup:GetPlayerNames()
|
||||||
if PlayerUnit and PlayerUnit:IsAlive() then
|
if PlayerNames then
|
||||||
local PlayerName = PlayerUnit:GetPlayerName()
|
PlayerReport:Add( " -- Group " .. PlayerGroup:GetCallsign() .. ": " .. table.concat( PlayerNames, ", " ) )
|
||||||
PlayerNames[#PlayerNames+1] = PlayerName
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
local PlayerNameText = table.concat( PlayerNames, ", " )
|
|
||||||
Report:Add( "Task " .. Name .. " - State '" .. State .. "' - Players " .. PlayerNameText )
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Loop each Process in the Task, and find Reporting Details.
|
-- Loop each Process in the Task, and find Reporting Details.
|
||||||
|
Report:Add( string.format( " - Task %s\n -- State '%s'\n%s", Name, State, PlayerReport:Text() ) )
|
||||||
return Report:Text()
|
return Report:Text()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user