mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Menu optimization
This commit is contained in:
parent
4c64548bea
commit
af55214c52
@ -108,7 +108,7 @@ do -- ACT_ASSIST
|
||||
function ACT_ASSIST:onafterStart( ProcessUnit, From, Event, To )
|
||||
|
||||
local ProcessGroup = ProcessUnit:GetGroup()
|
||||
local MissionMenu = self:GetMission():GetMissionMenu( ProcessGroup )
|
||||
local MissionMenu = self:GetMission():GetMenu( ProcessGroup )
|
||||
|
||||
local function MenuSmoke( MenuParam )
|
||||
self:E( MenuParam )
|
||||
|
||||
@ -138,6 +138,8 @@ do -- MENU_BASE
|
||||
}
|
||||
|
||||
--- Consructor
|
||||
-- @param #MENU_BASE
|
||||
-- @return #MENU_BASE
|
||||
function MENU_BASE:New( MenuText, ParentMenu )
|
||||
|
||||
local MenuParentPath = {}
|
||||
@ -150,10 +152,32 @@ do -- MENU_BASE
|
||||
self.MenuPath = nil
|
||||
self.MenuText = MenuText
|
||||
self.MenuParentPath = MenuParentPath
|
||||
self.Menus = {}
|
||||
self.MenuTime = timer.getTime()
|
||||
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Gets a @{Menu} from a parent @{Menu}
|
||||
-- @param #MENU_BASE self
|
||||
-- @param #string MenuText The text of the child menu.
|
||||
-- @return #MENU_BASE
|
||||
function MENU_BASE:GetMenu( MenuText )
|
||||
self:F( { self.Menus, MenuText } )
|
||||
return self.Menus[MenuText]
|
||||
end
|
||||
|
||||
|
||||
--- Sets a time stamp for later prevention of menu removal.
|
||||
-- @param #MENU_BASE self
|
||||
-- @param MenuTime
|
||||
-- @return #MENU_BASE
|
||||
function MENU_BASE:SetTime( MenuTime )
|
||||
self.MenuTime = MenuTime
|
||||
return self
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
do -- MENU_COMMAND_BASE
|
||||
@ -161,7 +185,7 @@ do -- MENU_COMMAND_BASE
|
||||
--- The MENU_COMMAND_BASE class
|
||||
-- @type MENU_COMMAND_BASE
|
||||
-- @field #function MenuCallHandler
|
||||
-- @extends Menu#MENU_BASE
|
||||
-- @extends Core.Menu#MENU_BASE
|
||||
MENU_COMMAND_BASE = {
|
||||
ClassName = "MENU_COMMAND_BASE",
|
||||
CommandMenuFunction = nil,
|
||||
@ -170,6 +194,8 @@ do -- MENU_COMMAND_BASE
|
||||
}
|
||||
|
||||
--- Constructor
|
||||
-- @param #MENU_COMMAND_BASE
|
||||
-- @return #MENU_COMMAND_BASE
|
||||
function MENU_COMMAND_BASE:New( MenuText, ParentMenu, CommandMenuFunction, CommandMenuArguments )
|
||||
|
||||
local self = BASE:Inherit( self, MENU_BASE:New( MenuText, ParentMenu ) )
|
||||
@ -189,7 +215,7 @@ do -- MENU_MISSION
|
||||
|
||||
--- The MENU_MISSION class
|
||||
-- @type MENU_MISSION
|
||||
-- @extends Menu#MENU_BASE
|
||||
-- @extends Core.Menu#MENU_BASE
|
||||
MENU_MISSION = {
|
||||
ClassName = "MENU_MISSION"
|
||||
}
|
||||
@ -198,7 +224,7 @@ do -- MENU_MISSION
|
||||
-- @param #MENU_MISSION self
|
||||
-- @param #string MenuText The text for the menu.
|
||||
-- @param #table ParentMenu The parent menu. This parameter can be ignored if you want the menu to be located at the perent menu of DCS world (under F10 other).
|
||||
-- @return #MENU_MISSION self
|
||||
-- @return #MENU_MISSION
|
||||
function MENU_MISSION:New( MenuText, ParentMenu )
|
||||
|
||||
local self = BASE:Inherit( self, MENU_BASE:New( MenuText, ParentMenu ) )
|
||||
@ -225,7 +251,7 @@ do -- MENU_MISSION
|
||||
|
||||
--- Removes the sub menus recursively of this MENU_MISSION. Note that the main menu is kept!
|
||||
-- @param #MENU_MISSION self
|
||||
-- @return #MENU_MISSION self
|
||||
-- @return #MENU_MISSION
|
||||
function MENU_MISSION:RemoveSubMenus()
|
||||
self:F( self.MenuPath )
|
||||
|
||||
@ -256,7 +282,7 @@ do -- MENU_MISSION_COMMAND
|
||||
|
||||
--- The MENU_MISSION_COMMAND class
|
||||
-- @type MENU_MISSION_COMMAND
|
||||
-- @extends Menu#MENU_COMMAND_BASE
|
||||
-- @extends Core.Menu#MENU_COMMAND_BASE
|
||||
MENU_MISSION_COMMAND = {
|
||||
ClassName = "MENU_MISSION_COMMAND"
|
||||
}
|
||||
@ -306,7 +332,7 @@ do -- MENU_COALITION
|
||||
|
||||
--- The MENU_COALITION class
|
||||
-- @type MENU_COALITION
|
||||
-- @extends Menu#MENU_BASE
|
||||
-- @extends Core.Menu#MENU_BASE
|
||||
-- @usage
|
||||
-- -- This demo creates a menu structure for the planes within the red coalition.
|
||||
-- -- To test, join the planes, then look at the other radio menus (Option F10).
|
||||
@ -380,7 +406,7 @@ do -- MENU_COALITION
|
||||
|
||||
--- Removes the sub menus recursively of this MENU_COALITION. Note that the main menu is kept!
|
||||
-- @param #MENU_COALITION self
|
||||
-- @return #MENU_COALITION self
|
||||
-- @return #MENU_COALITION
|
||||
function MENU_COALITION:RemoveSubMenus()
|
||||
self:F( self.MenuPath )
|
||||
|
||||
@ -411,7 +437,7 @@ do -- MENU_COALITION_COMMAND
|
||||
|
||||
--- The MENU_COALITION_COMMAND class
|
||||
-- @type MENU_COALITION_COMMAND
|
||||
-- @extends Menu#MENU_COMMAND_BASE
|
||||
-- @extends Core.Menu#MENU_COMMAND_BASE
|
||||
MENU_COALITION_COMMAND = {
|
||||
ClassName = "MENU_COALITION_COMMAND"
|
||||
}
|
||||
@ -423,7 +449,7 @@ do -- MENU_COALITION_COMMAND
|
||||
-- @param Menu#MENU_COALITION ParentMenu The parent menu.
|
||||
-- @param CommandMenuFunction A function that is called when the menu key is pressed.
|
||||
-- @param CommandMenuArgument An argument for the function. There can only be ONE argument given. So multiple arguments must be wrapped into a table. See the below example how to do this.
|
||||
-- @return #MENU_COALITION_COMMAND self
|
||||
-- @return #MENU_COALITION_COMMAND
|
||||
function MENU_COALITION_COMMAND:New( Coalition, MenuText, ParentMenu, CommandMenuFunction, ... )
|
||||
|
||||
local self = BASE:Inherit( self, MENU_COMMAND_BASE:New( MenuText, ParentMenu, CommandMenuFunction, arg ) )
|
||||
@ -468,7 +494,7 @@ do -- MENU_CLIENT
|
||||
|
||||
--- MENU_COALITION constructor. Creates a new radio command item for a coalition, which can invoke a function with parameters.
|
||||
-- @type MENU_CLIENT
|
||||
-- @extends Menu#MENU_BASE
|
||||
-- @extends Core.Menu#MENU_BASE
|
||||
-- @usage
|
||||
-- -- This demo creates a menu structure for the two clients of planes.
|
||||
-- -- Each client will receive a different menu structure.
|
||||
@ -609,7 +635,7 @@ do -- MENU_CLIENT
|
||||
|
||||
--- The MENU_CLIENT_COMMAND class
|
||||
-- @type MENU_CLIENT_COMMAND
|
||||
-- @extends Menu#MENU_COMMAND
|
||||
-- @extends Core.Menu#MENU_COMMAND
|
||||
MENU_CLIENT_COMMAND = {
|
||||
ClassName = "MENU_CLIENT_COMMAND"
|
||||
}
|
||||
@ -695,7 +721,7 @@ do
|
||||
|
||||
--- The MENU_GROUP class
|
||||
-- @type MENU_GROUP
|
||||
-- @extends Menu#MENU_BASE
|
||||
-- @extends Core.Menu#MENU_BASE
|
||||
-- @usage
|
||||
-- -- This demo creates a menu structure for the two groups of planes.
|
||||
-- -- Each group will receive a different menu structure.
|
||||
@ -769,8 +795,6 @@ do
|
||||
self = BASE:Inherit( self, MENU_BASE:New( MenuText, ParentMenu ) )
|
||||
MenuGroup._Menus[Path] = self
|
||||
|
||||
self.Menus = {}
|
||||
|
||||
self.MenuGroup = MenuGroup
|
||||
self.Path = Path
|
||||
self.MenuGroupID = MenuGroup:GetID()
|
||||
@ -781,7 +805,8 @@ do
|
||||
self.MenuPath = missionCommands.addSubMenuForGroup( self.MenuGroupID, MenuText, self.MenuParentPath )
|
||||
|
||||
if ParentMenu and ParentMenu.Menus then
|
||||
ParentMenu.Menus[self.MenuPath] = self
|
||||
ParentMenu.Menus[MenuText] = self
|
||||
self:F( { ParentMenu.Menus, MenuText } )
|
||||
end
|
||||
end
|
||||
|
||||
@ -792,43 +817,59 @@ do
|
||||
|
||||
--- Removes the sub menus recursively of this MENU_GROUP.
|
||||
-- @param #MENU_GROUP self
|
||||
-- @param MenuTime
|
||||
-- @return #MENU_GROUP self
|
||||
function MENU_GROUP:RemoveSubMenus()
|
||||
self:F2( self.MenuPath )
|
||||
function MENU_GROUP:RemoveSubMenus( MenuTime )
|
||||
self:F2( { self.MenuPath, MenuTime, self.MenuTime } )
|
||||
|
||||
self:T( { "Removing Group SubMenus:", self.MenuGroup:GetName(), self.MenuPath } )
|
||||
for MenuID, Menu in pairs( self.Menus ) do
|
||||
Menu:Remove()
|
||||
for MenuText, Menu in pairs( self.Menus ) do
|
||||
Menu:Remove( MenuTime )
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--- Removes the main menu of this MENU_GROUP.
|
||||
-- @param #MENU_GROUP self
|
||||
-- @param MenuTime
|
||||
-- @return #nil
|
||||
function MENU_GROUP:RemoveTop( MenuTime )
|
||||
self:F( { self.MenuGroupID, self.MenuPath, MenuTime, self.MenuTime } )
|
||||
|
||||
if not MenuTime or self.MenuTime ~= MenuTime then
|
||||
if self.MenuGroup._Menus[self.Path] then
|
||||
self = self.MenuGroup._Menus[self.Path]
|
||||
|
||||
missionCommands.removeItemForGroup( self.MenuGroupID, self.MenuPath )
|
||||
if self.ParentMenu then
|
||||
self.ParentMenu.Menus[self.MenuText] = nil
|
||||
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()
|
||||
self:F2( { self.MenuGroupID, self.MenuPath } )
|
||||
function MENU_GROUP:Remove( MenuTime )
|
||||
self:F( { self.MenuGroupID, self.MenuPath } )
|
||||
|
||||
self:RemoveSubMenus()
|
||||
|
||||
if self.MenuGroup._Menus[self.Path] then
|
||||
self = self.MenuGroup._Menus[self.Path]
|
||||
self:RemoveSubMenus( MenuTime )
|
||||
|
||||
missionCommands.removeItemForGroup( self.MenuGroupID, self.MenuPath )
|
||||
if self.ParentMenu then
|
||||
self.ParentMenu.Menus[self.MenuPath] = nil
|
||||
end
|
||||
self:T( { "Removing Group Menu:", self.MenuGroup:GetName(), self.MenuGroup._Menus[self.Path].Path } )
|
||||
self.MenuGroup._Menus[self.Path] = nil
|
||||
self = nil
|
||||
end
|
||||
self:RemoveTop( MenuTime )
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
--- The MENU_GROUP_COMMAND class
|
||||
-- @type MENU_GROUP_COMMAND
|
||||
-- @extends Menu#MENU_BASE
|
||||
-- @extends Core.Menu#MENU_BASE
|
||||
MENU_GROUP_COMMAND = {
|
||||
ClassName = "MENU_GROUP_COMMAND"
|
||||
}
|
||||
@ -840,13 +881,14 @@ do
|
||||
-- @param ParentMenu The parent menu.
|
||||
-- @param CommandMenuFunction A function that is called when the menu key is pressed.
|
||||
-- @param CommandMenuArgument An argument for the function.
|
||||
-- @return Menu#MENU_GROUP_COMMAND self
|
||||
-- @return #MENU_GROUP_COMMAND
|
||||
function MENU_GROUP_COMMAND:New( MenuGroup, MenuText, ParentMenu, CommandMenuFunction, ... )
|
||||
|
||||
MenuGroup._Menus = MenuGroup._Menus or {}
|
||||
local Path = ( ParentMenu and ( table.concat( ParentMenu.MenuPath or {}, "@" ) .. "@" .. MenuText ) ) or MenuText
|
||||
if MenuGroup._Menus[Path] then
|
||||
self = MenuGroup._Menus[Path]
|
||||
self:T( { "Re-using Group Command Menu:", MenuGroup:GetName(), MenuText } )
|
||||
else
|
||||
self = BASE:Inherit( self, MENU_COMMAND_BASE:New( MenuText, ParentMenu, CommandMenuFunction, arg ) )
|
||||
MenuGroup._Menus[Path] = self
|
||||
@ -861,7 +903,8 @@ do
|
||||
self.MenuPath = missionCommands.addCommandForGroup( self.MenuGroupID, MenuText, self.MenuParentPath, self.MenuCallHandler, arg )
|
||||
|
||||
if ParentMenu and ParentMenu.Menus then
|
||||
ParentMenu.Menus[self.MenuPath] = self
|
||||
ParentMenu.Menus[MenuText] = self
|
||||
self:F( { ParentMenu.Menus, MenuText } )
|
||||
end
|
||||
end
|
||||
|
||||
@ -872,22 +915,37 @@ do
|
||||
|
||||
--- Removes a menu structure for a group.
|
||||
-- @param #MENU_GROUP_COMMAND self
|
||||
-- @param MenuTime
|
||||
-- @return #nil
|
||||
function MENU_GROUP_COMMAND:Remove()
|
||||
self:F2( { self.MenuGroupID, self.MenuPath } )
|
||||
function MENU_GROUP_COMMAND:Remove( MenuTime )
|
||||
self:F( { self.MenuGroupID, self.MenuPath, MenuTime, self.MenuTime } )
|
||||
|
||||
if self.MenuGroup._Menus[self.Path] then
|
||||
self = self.MenuGroup._Menus[self.Path]
|
||||
|
||||
missionCommands.removeItemForGroup( self.MenuGroupID, self.MenuPath )
|
||||
self.ParentMenu.Menus[self.MenuPath] = nil
|
||||
self:T( { "Removing Group Command Menu:", self.MenuGroup:GetName(), self.MenuGroup._Menus[self.Path].Path } )
|
||||
self.MenuGroup._Menus[self.Path] = nil
|
||||
self = nil
|
||||
if not MenuTime or self.MenuTime ~= MenuTime then
|
||||
if self.MenuGroup._Menus[self.Path] then
|
||||
self = self.MenuGroup._Menus[self.Path]
|
||||
|
||||
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.MenuGroup._Menus[self.Path] = nil
|
||||
self = nil
|
||||
end
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
|
||||
@ -1298,10 +1298,11 @@ do -- DETECTION_UNITS
|
||||
local DetectedItemSet = DetectedItem.Set -- Core.Set#SET_UNIT
|
||||
local DetectedTypeName = DetectedItem.Type
|
||||
|
||||
for DetectedUnitName, DetectedUnitData in pairs( DetectedItemSet ) do
|
||||
for DetectedUnitName, DetectedUnitData in pairs( DetectedItemSet:GetSet() ) do
|
||||
local DetectedUnit = DetectedUnitData -- Wrapper.Unit#UNIT
|
||||
|
||||
local DetectedObject = nil
|
||||
self:E( DetectedUnit )
|
||||
if DetectedUnit:IsAlive() then
|
||||
--self:E(DetectedUnit:GetName())
|
||||
DetectedObject = self:GetDetectedObject( DetectedUnit:GetName() )
|
||||
|
||||
@ -194,17 +194,26 @@ function COMMANDCENTER:SetMenu()
|
||||
|
||||
self.CommandCenterMenu = self.CommandCenterMenu or MENU_COALITION:New( self.CommandCenterCoalition, "Command Center (" .. self:GetName() .. ")" )
|
||||
|
||||
local MenuTime = timer.getTime()
|
||||
for MissionID, Mission in pairs( self:GetMissions() ) do
|
||||
local Mission = Mission -- Tasking.Mission#MISSION
|
||||
Mission:RemoveMenu()
|
||||
Mission:SetMenu( MenuTime )
|
||||
end
|
||||
|
||||
for MissionID, Mission in pairs( self:GetMissions() ) do
|
||||
local Mission = Mission -- Tasking.Mission#MISSION
|
||||
Mission:RemoveMenu( MenuTime )
|
||||
end
|
||||
|
||||
for MissionID, Mission in pairs( self:GetMissions() ) do
|
||||
local Mission = Mission -- Tasking.Mission#MISSION
|
||||
Mission:SetMenu()
|
||||
end
|
||||
end
|
||||
|
||||
--- Gets the commandcenter menu structure governed by the HQ command center.
|
||||
-- @param #COMMANDCENTER self
|
||||
-- @return Core.Menu#MENU_COALITION
|
||||
function COMMANDCENTER:GetMenu()
|
||||
self:F()
|
||||
return self.CommandCenterMenu
|
||||
end
|
||||
|
||||
--- Checks of the COMMANDCENTER has a GROUP.
|
||||
-- @param #COMMANDCENTER self
|
||||
|
||||
@ -363,23 +363,25 @@ end
|
||||
|
||||
--- Sets the Planned Task menu.
|
||||
-- @param #MISSION self
|
||||
function MISSION:SetMenu()
|
||||
-- @param #number MenuTime
|
||||
function MISSION:SetMenu( MenuTime )
|
||||
self:F()
|
||||
|
||||
for _, Task in pairs( self:GetTasks() ) do
|
||||
local Task = Task -- Tasking.Task#TASK
|
||||
Task:SetMenu()
|
||||
for _, TaskData in pairs( self:GetTasks() ) do
|
||||
local Task = TaskData -- Tasking.Task#TASK
|
||||
Task:SetMenu( MenuTime )
|
||||
end
|
||||
end
|
||||
|
||||
--- Removes the Planned Task menu.
|
||||
-- @param #MISSION self
|
||||
function MISSION:RemoveMenu()
|
||||
-- @param #number MenuTime
|
||||
function MISSION:RemoveMenu( MenuTime )
|
||||
self:F()
|
||||
|
||||
for _, Task in pairs( self:GetTasks() ) do
|
||||
local Task = Task -- Tasking.Task#TASK
|
||||
Task:RemoveMenu()
|
||||
Task:RemoveMenu( MenuTime )
|
||||
end
|
||||
end
|
||||
|
||||
@ -391,20 +393,6 @@ function MISSION:GetCommandCenter()
|
||||
return self.CommandCenter
|
||||
end
|
||||
|
||||
--- Sets the Assigned Task menu.
|
||||
-- @param #MISSION self
|
||||
-- @param Tasking.Task#TASK Task
|
||||
-- @param #string MenuText The menu text.
|
||||
-- @return #MISSION self
|
||||
function MISSION:SetAssignedMenu( Task )
|
||||
|
||||
for _, Task in pairs( self.Tasks ) do
|
||||
local Task = Task -- Tasking.Task#TASK
|
||||
Task:RemoveMenu()
|
||||
Task:SetAssignedMenu()
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--- Removes a Task menu.
|
||||
-- @param #MISSION self
|
||||
@ -420,28 +408,18 @@ end
|
||||
-- @param #MISSION self
|
||||
-- @param Wrapper.Group#GROUP TaskGroup
|
||||
-- @return Core.Menu#MENU_COALITION self
|
||||
function MISSION:GetMissionMenu( TaskGroup )
|
||||
function MISSION:GetMenu( TaskGroup )
|
||||
|
||||
local CommandCenter = self:GetCommandCenter()
|
||||
local CommandCenterMenu = CommandCenter.CommandCenterMenu
|
||||
local CommandCenterMenu = CommandCenter:GetMenu()
|
||||
|
||||
local MissionName = self:GetName()
|
||||
|
||||
local TaskGroupName = TaskGroup:GetName()
|
||||
local MissionMenu = MENU_GROUP:New( TaskGroup, MissionName, CommandCenterMenu )
|
||||
local MissionMenu = CommandCenterMenu:GetMenu( MissionName )
|
||||
|
||||
return MissionMenu
|
||||
end
|
||||
|
||||
|
||||
--- Clears the mission menu for the coalition.
|
||||
-- @param #MISSION self
|
||||
-- @return #MISSION self
|
||||
function MISSION:ClearMissionMenu()
|
||||
self.MissionMenu:Remove()
|
||||
self.MissionMenu = nil
|
||||
end
|
||||
|
||||
--- Get the TASK identified by the TaskNumber from the Mission. This function is useful in GoalFunctions.
|
||||
-- @param #string TaskName The Name of the @{Task} within the @{Mission}.
|
||||
-- @return Tasking.Task#TASK The Task
|
||||
|
||||
@ -354,8 +354,13 @@ function TASK:AssignToGroup( TaskGroup )
|
||||
|
||||
TaskGroup:SetState( TaskGroup, "Assigned", self )
|
||||
|
||||
self:RemoveMenuForGroup( TaskGroup )
|
||||
self:SetAssignedMenuForGroup( TaskGroup )
|
||||
local Mission = self:GetMission()
|
||||
local CommandCenter = Mission:GetCommandCenter()
|
||||
|
||||
CommandCenter:SetMenu()
|
||||
|
||||
--self:RemoveMenuForGroup( TaskGroup )
|
||||
--self:SetAssignedMenuForGroup( TaskGroup )
|
||||
|
||||
local TaskUnits = TaskGroup:GetUnits()
|
||||
for UnitID, UnitData in pairs( TaskUnits ) do
|
||||
@ -527,13 +532,18 @@ end
|
||||
|
||||
--- Set the menu options of the @{Task} to all the groups in the SetGroup.
|
||||
-- @param #TASK self
|
||||
function TASK:SetMenu()
|
||||
-- @param #number MenuTime
|
||||
-- @return #TASK
|
||||
function TASK:SetMenu( MenuTime )
|
||||
self:F()
|
||||
|
||||
self.SetGroup:Flush()
|
||||
for TaskGroupID, TaskGroup in pairs( self.SetGroup:GetSet() ) do
|
||||
if self:IsStatePlanned() or self:IsStateReplanned() then
|
||||
self:SetMenuForGroup( TaskGroup )
|
||||
for TaskGroupID, TaskGroupData in pairs( self.SetGroup:GetSet() ) do
|
||||
local TaskGroup = TaskGroupData -- Wrapper.Group#GROUP
|
||||
if TaskGroup:IsAlive() and TaskGroup:GetPlayerNames() then
|
||||
if self:IsStatePlanned() or self:IsStateReplanned() then
|
||||
self:SetMenuForGroup( TaskGroup, MenuTime )
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -541,17 +551,15 @@ end
|
||||
|
||||
--- Remove the menu options of the @{Task} to all the groups in the SetGroup.
|
||||
-- @param #TASK self
|
||||
-- @return #TASK self
|
||||
function TASK:RemoveMenu()
|
||||
|
||||
-- @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() then
|
||||
if not TaskGroup:GetState( TaskGroup, "Assigned" ) then
|
||||
self:T( { "Remove Menu for Group:", TaskGroup:GetName() } )
|
||||
self:RemoveMenuForGroup( TaskGroup )
|
||||
end
|
||||
if TaskGroup:IsAlive() and TaskGroup:GetPlayerNames() then
|
||||
self:RemoveMenuForGroup( TaskGroup, MenuTime )
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -559,13 +567,15 @@ end
|
||||
|
||||
--- Set the Menu for a Group
|
||||
-- @param #TASK self
|
||||
function TASK:SetMenuForGroup( TaskGroup )
|
||||
-- @param #number MenuTime
|
||||
-- @return #TASK
|
||||
function TASK:SetMenuForGroup( TaskGroup, MenuTime )
|
||||
|
||||
if not TaskGroup:GetState( TaskGroup, "Assigned" ) then
|
||||
self:SetPlannedMenuForGroup( TaskGroup, self:GetTaskName() )
|
||||
self:SetPlannedMenuForGroup( TaskGroup, self:GetTaskName(), MenuTime )
|
||||
else
|
||||
if not self:IsAssignedToGroup( TaskGroup ) then
|
||||
self:SetAssignedMenuForGroup( TaskGroup )
|
||||
self:SetAssignedMenuForGroup( TaskGroup, MenuTime )
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -575,16 +585,24 @@ end
|
||||
-- @param #TASK self
|
||||
-- @param Wrapper.Group#GROUP TaskGroup
|
||||
-- @param #string MenuText The menu text.
|
||||
-- @param #number MenuTime
|
||||
-- @return #TASK self
|
||||
function TASK:SetPlannedMenuForGroup( TaskGroup, MenuText )
|
||||
function TASK:SetPlannedMenuForGroup( TaskGroup, MenuText, MenuTime )
|
||||
self:E( TaskGroup:GetName() )
|
||||
|
||||
local Mission = self:GetMission()
|
||||
local MissionMenu = Mission:GetMissionMenu( TaskGroup )
|
||||
local MissionName = Mission:GetName()
|
||||
local CommandCenter = Mission:GetCommandCenter()
|
||||
local CommandCenterMenu = CommandCenter:GetMenu()
|
||||
|
||||
local MissionMenu = MENU_GROUP:New( TaskGroup, MissionName, CommandCenterMenu ):SetTime( MenuTime )
|
||||
|
||||
|
||||
local MissionMenu = Mission:GetMenu( TaskGroup )
|
||||
|
||||
local TaskType = self:GetType()
|
||||
local TaskTypeMenu = MENU_GROUP:New( TaskGroup, TaskType, MissionMenu )
|
||||
local TaskMenu = MENU_GROUP_COMMAND:New( TaskGroup, MenuText, TaskTypeMenu, self.MenuAssignToGroup, { self = self, TaskGroup = TaskGroup } )
|
||||
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 )
|
||||
|
||||
return self
|
||||
end
|
||||
@ -592,17 +610,18 @@ end
|
||||
--- Set the assigned menu options of the @{Task}.
|
||||
-- @param #TASK self
|
||||
-- @param Wrapper.Group#GROUP TaskGroup
|
||||
-- @param #number MenuTime
|
||||
-- @return #TASK self
|
||||
function TASK:SetAssignedMenuForGroup( TaskGroup )
|
||||
function TASK:SetAssignedMenuForGroup( TaskGroup, MenuTime )
|
||||
self:E( TaskGroup:GetName() )
|
||||
|
||||
local Mission = self:GetMission()
|
||||
local MissionMenu = Mission:GetMissionMenu( TaskGroup )
|
||||
local MissionMenu = Mission:GetMenu( TaskGroup )
|
||||
|
||||
self:E( { MissionMenu = MissionMenu } )
|
||||
|
||||
local TaskTypeMenu = MENU_GROUP_COMMAND:New( TaskGroup, "Task Status", MissionMenu, self.MenuTaskStatus, self, TaskGroup )
|
||||
local TaskMenu = MENU_GROUP_COMMAND:New( TaskGroup, "Abort Task", MissionMenu, self.MenuTaskAbort, self, TaskGroup )
|
||||
local TaskTypeMenu = MENU_GROUP_COMMAND:New( TaskGroup, "Task Status", MissionMenu, self.MenuTaskStatus, self, TaskGroup ):SetTime( MenuTime )
|
||||
local TaskMenu = MENU_GROUP_COMMAND:New( TaskGroup, "Abort Task", MissionMenu, self.MenuTaskAbort, self, TaskGroup ):SetTime( MenuTime )
|
||||
|
||||
return self
|
||||
end
|
||||
@ -610,14 +629,31 @@ 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 )
|
||||
function TASK:RemoveMenuForGroup( TaskGroup, MenuTime )
|
||||
self:F()
|
||||
|
||||
local Mission = self:GetMission()
|
||||
local MissionName = Mission:GetName()
|
||||
|
||||
local MissionMenu = Mission:GetMissionMenu( TaskGroup )
|
||||
MissionMenu:Remove()
|
||||
|
||||
local MissionMenu = Mission:GetMenu( TaskGroup )
|
||||
|
||||
if MissionMenu then
|
||||
local TaskType = self:GetType()
|
||||
local TypeMenu = MissionMenu:GetMenu( TaskType )
|
||||
|
||||
if TypeMenu then
|
||||
local TaskMenu = TypeMenu:GetMenu( self:GetTaskName() )
|
||||
if TaskMenu then
|
||||
TaskMenu:RemoveTop( MenuTime )
|
||||
end
|
||||
TypeMenu:RemoveTop( MenuTime )
|
||||
end
|
||||
|
||||
MissionMenu:RemoveTop( MenuTime )
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function TASK.MenuAssignToGroup( MenuParam )
|
||||
|
||||
@ -926,3 +926,29 @@ do -- Event Handling
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
do -- Players
|
||||
|
||||
--- Get player names
|
||||
-- @param #GROUP self
|
||||
-- @return #table The group has players, an array of player names is returned.
|
||||
-- @return #nil The group has no players
|
||||
function GROUP:GetPlayerNames()
|
||||
|
||||
local PlayerNames = nil
|
||||
|
||||
local Units = self:GetUnits()
|
||||
for UnitID, UnitData in pairs( Units ) do
|
||||
local Unit = UnitData -- Wrapper.Unit#UNIT
|
||||
local PlayerName = Unit:GetPlayerName()
|
||||
if PlayerName and PlayerName ~= "" then
|
||||
PlayerNames = PlayerNames or {}
|
||||
table.insert( PlayerNames, PlayerName )
|
||||
end
|
||||
end
|
||||
|
||||
self:F( PlayerNames )
|
||||
return PlayerNames
|
||||
end
|
||||
|
||||
end
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user