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.MenuParentPath = MenuParentPath
|
||||
self.Menus = {}
|
||||
self.MenuCount = 0
|
||||
self.MenuRemoveParent = false
|
||||
self.MenuTime = timer.getTime()
|
||||
|
||||
|
||||
return self
|
||||
end
|
||||
@ -168,6 +169,16 @@ do -- MENU_BASE
|
||||
return self.Menus[MenuText]
|
||||
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.
|
||||
-- @param #MENU_BASE self
|
||||
@ -804,9 +815,10 @@ do
|
||||
self:T( { "Adding Menu ", MenuText, self.MenuParentPath } )
|
||||
self.MenuPath = missionCommands.addSubMenuForGroup( self.MenuGroupID, MenuText, self.MenuParentPath )
|
||||
|
||||
if ParentMenu and ParentMenu.Menus then
|
||||
ParentMenu.Menus[MenuText] = self
|
||||
self:F( { ParentMenu.Menus, MenuText } )
|
||||
if self.ParentMenu and self.ParentMenu.Menus then
|
||||
self.ParentMenu.Menus[MenuText] = self
|
||||
self:F( { self.ParentMenu.Menus, MenuText } )
|
||||
self.ParentMenu.MenuCount = self.ParentMenu.MenuCount + 1
|
||||
end
|
||||
end
|
||||
|
||||
@ -829,13 +841,16 @@ do
|
||||
|
||||
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 MenuTime
|
||||
-- @return #nil
|
||||
function MENU_GROUP:RemoveTop( MenuTime )
|
||||
function MENU_GROUP:Remove( MenuTime )
|
||||
self:F( { self.MenuGroupID, self.MenuPath, MenuTime, self.MenuTime } )
|
||||
|
||||
self:RemoveSubMenus( MenuTime )
|
||||
|
||||
if not MenuTime or self.MenuTime ~= MenuTime then
|
||||
if self.MenuGroup._Menus[self.Path] then
|
||||
self = self.MenuGroup._Menus[self.Path]
|
||||
@ -843,25 +858,19 @@ do
|
||||
missionCommands.removeItemForGroup( self.MenuGroupID, self.MenuPath )
|
||||
if self.ParentMenu then
|
||||
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
|
||||
self:T( { "Removing Group Menu:", self.MenuGroup:GetName(), self.MenuGroup._Menus[self.Path].Path } )
|
||||
self.MenuGroup._Menus[self.Path] = nil
|
||||
self = nil
|
||||
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
|
||||
end
|
||||
@ -902,14 +911,13 @@ do
|
||||
self:T( { "Adding Group Command Menu:", MenuGroup:GetName(), MenuText, self.MenuParentPath } )
|
||||
self.MenuPath = missionCommands.addCommandForGroup( self.MenuGroupID, MenuText, self.MenuParentPath, self.MenuCallHandler, arg )
|
||||
|
||||
if ParentMenu and ParentMenu.Menus then
|
||||
ParentMenu.Menus[MenuText] = self
|
||||
if self.ParentMenu and self.ParentMenu.Menus then
|
||||
self.ParentMenu.Menus[MenuText] = self
|
||||
self.ParentMenu.MenuCount = self.ParentMenu.MenuCount + 1
|
||||
self:F( { ParentMenu.Menus, MenuText } )
|
||||
end
|
||||
end
|
||||
|
||||
--self:F( { MenuGroup:GetName(), MenuText, ParentMenu.MenuPath } )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
@ -926,7 +934,16 @@ do
|
||||
|
||||
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.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 = nil
|
||||
end
|
||||
@ -935,17 +952,5 @@ do
|
||||
return nil
|
||||
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
|
||||
|
||||
|
||||
@ -20,7 +20,9 @@ function REPORT:New( Title )
|
||||
local self = BASE:Inherit( self, BASE:New() )
|
||||
|
||||
self.Report = {}
|
||||
self.Report[#self.Report+1] = Title
|
||||
if Title then
|
||||
self.Report[#self.Report+1] = Title
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
@ -31,7 +33,7 @@ end
|
||||
-- @return #REPORT
|
||||
function REPORT:Add( Text )
|
||||
self.Report[#self.Report+1] = Text
|
||||
return self.Report[#self.Report+1]
|
||||
return self.Report[#self.Report]
|
||||
end
|
||||
|
||||
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.
|
||||
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
|
||||
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 Wrapper.Group#GROUP TaskGroup
|
||||
-- @return #TASK
|
||||
@ -355,12 +355,11 @@ function TASK:AssignToGroup( TaskGroup )
|
||||
TaskGroup:SetState( TaskGroup, "Assigned", self )
|
||||
|
||||
local Mission = self:GetMission()
|
||||
local CommandCenter = Mission:GetCommandCenter()
|
||||
|
||||
CommandCenter:SetMenu()
|
||||
local MissionMenu = Mission:GetMenu( TaskGroup )
|
||||
MissionMenu:RemoveSubMenus()
|
||||
|
||||
--self:RemoveMenuForGroup( TaskGroup )
|
||||
--self:SetAssignedMenuForGroup( TaskGroup )
|
||||
self:SetAssignedMenuForGroup( TaskGroup )
|
||||
|
||||
local TaskUnits = TaskGroup:GetUnits()
|
||||
for UnitID, UnitData in pairs( TaskUnits ) do
|
||||
@ -474,7 +473,7 @@ function TASK:UnAssignFromGroup( TaskGroup )
|
||||
|
||||
TaskGroup:SetState( TaskGroup, "Assigned", nil )
|
||||
|
||||
self:RemoveMenuForGroup( TaskGroup )
|
||||
self:RemoveAssignedMenuForGroup( TaskGroup )
|
||||
|
||||
local TaskUnits = TaskGroup:GetUnits()
|
||||
for UnitID, UnitData in pairs( TaskUnits ) do
|
||||
@ -549,21 +548,6 @@ function TASK:SetMenu( MenuTime )
|
||||
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
|
||||
-- @param #TASK self
|
||||
@ -602,7 +586,7 @@ function TASK:SetPlannedMenuForGroup( TaskGroup, MenuText, MenuTime )
|
||||
|
||||
local TaskType = self:GetType()
|
||||
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
|
||||
end
|
||||
@ -626,12 +610,30 @@ function TASK:SetAssignedMenuForGroup( TaskGroup, MenuTime )
|
||||
return self
|
||||
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}.
|
||||
-- @param #TASK self
|
||||
-- @param Wrapper.Group#GROUP TaskGroup
|
||||
-- @param #number MenuTime
|
||||
-- @return #TASK self
|
||||
function TASK:RemoveMenuForGroup( TaskGroup, MenuTime )
|
||||
function TASK:RemovePlannedMenuForGroup( TaskGroup, MenuTime )
|
||||
self:F()
|
||||
|
||||
local Mission = self:GetMission()
|
||||
@ -646,12 +648,28 @@ function TASK:RemoveMenuForGroup( TaskGroup, MenuTime )
|
||||
if TypeMenu then
|
||||
local TaskMenu = TypeMenu:GetMenu( self:GetTaskName() )
|
||||
if TaskMenu then
|
||||
TaskMenu:RemoveTop( MenuTime )
|
||||
TaskMenu:Remove( MenuTime )
|
||||
end
|
||||
TypeMenu:RemoveTop( MenuTime )
|
||||
end
|
||||
|
||||
MissionMenu:RemoveTop( MenuTime )
|
||||
end
|
||||
|
||||
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
|
||||
@ -670,7 +688,10 @@ end
|
||||
-- @param #TASK self
|
||||
function TASK:MenuTaskStatus( TaskGroup )
|
||||
|
||||
self:ReportDetails()
|
||||
local ReportText = self:ReportDetails()
|
||||
|
||||
self:T( ReportText )
|
||||
self:GetMission():GetCommandCenter():MessageToGroup( ReportText, TaskGroup )
|
||||
|
||||
end
|
||||
|
||||
@ -1112,24 +1133,19 @@ function TASK:ReportDetails()
|
||||
-- Determine the status of the Task.
|
||||
local State = self:GetState()
|
||||
|
||||
|
||||
-- Loop each Unit active in the Task, and find Player Names.
|
||||
local PlayerNames = {}
|
||||
for PlayerGroupID, PlayerGroup in pairs( self:GetGroups():GetSet() ) do
|
||||
local Player = PlayerGroup -- Wrapper.Group#GROUP
|
||||
for PlayerUnitID, PlayerUnit in pairs( PlayerGroup:GetUnits() ) do
|
||||
local PlayerUnit = PlayerUnit -- Wrapper.Unit#UNIT
|
||||
if PlayerUnit and PlayerUnit:IsAlive() then
|
||||
local PlayerName = PlayerUnit:GetPlayerName()
|
||||
PlayerNames[#PlayerNames+1] = PlayerName
|
||||
end
|
||||
local PlayerReport = REPORT:New( " - Players:" )
|
||||
for PlayerGroupID, PlayerGroupData in pairs( self:GetGroups():GetSet() ) do
|
||||
local PlayerGroup = PlayerGroupData -- Wrapper.Group#GROUP
|
||||
PlayerNames = PlayerGroup:GetPlayerNames()
|
||||
if PlayerNames then
|
||||
PlayerReport:Add( " -- Group " .. PlayerGroup:GetCallsign() .. ": " .. table.concat( PlayerNames, ", " ) )
|
||||
end
|
||||
local PlayerNameText = table.concat( PlayerNames, ", " )
|
||||
Report:Add( "Task " .. Name .. " - State '" .. State .. "' - Players " .. PlayerNameText )
|
||||
end
|
||||
|
||||
-- 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()
|
||||
end
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user