Fixed issue with menu system Planned Tasks

There was a problem that when multiiple groups were part of the attack
set, then the menus for planned tasks were not correctly generated.
This commit is contained in:
FlightControl_Master
2017-07-25 16:29:57 +02:00
parent c3ee9306f3
commit 713e741299
3 changed files with 20 additions and 17 deletions
+1 -1
View File
@@ -809,7 +809,7 @@ do
function MENU_GROUP:RemoveSubMenus( MenuTime ) function MENU_GROUP:RemoveSubMenus( MenuTime )
--self:F2( { self.MenuPath, MenuTime, self.MenuTime } ) --self:F2( { self.MenuPath, MenuTime, self.MenuTime } )
--self:T( { "Removing Group SubMenus:", self.MenuGroup:GetName(), self.MenuPath } ) self:T( { "Removing Group SubMenus:", MenuTime, self.MenuGroup:GetName(), self.MenuPath } )
for MenuText, Menu in pairs( self.Menus ) do for MenuText, Menu in pairs( self.Menus ) do
Menu:Remove( MenuTime ) Menu:Remove( MenuTime )
end end
@@ -207,6 +207,7 @@ function COMMANDCENTER:New( CommandCenterPositionable, CommandCenterName )
local PlayerGroup = EventData.IniGroup -- The GROUP object should be filled! local PlayerGroup = EventData.IniGroup -- The GROUP object should be filled!
Mission:JoinUnit( PlayerUnit, PlayerGroup ) Mission:JoinUnit( PlayerUnit, PlayerGroup )
end end
self:SetMenu()
end end
) )
+18 -16
View File
@@ -272,7 +272,7 @@ function TASK:JoinUnit( PlayerUnit, PlayerGroup )
-- Check if the PlayerGroup is already assigned to the Task. If yes, the PlayerGroup is added to the Task. -- Check if the PlayerGroup is already assigned to the Task. If yes, the PlayerGroup is added to the Task.
-- If the PlayerGroup is not assigned to the Task, the menu needs to be set. In that case, the PlayerUnit will become the GroupPlayer leader. -- If the PlayerGroup is not assigned to the Task, the menu needs to be set. In that case, the PlayerUnit will become the GroupPlayer leader.
if self:IsStatePlanned() or self:IsStateReplanned() then if self:IsStatePlanned() or self:IsStateReplanned() then
self:SetMenuForGroup( PlayerGroup ) --self:SetMenuForGroup( PlayerGroup )
--self:MessageToGroups( PlayerUnit:GetPlayerName() .. " is planning to join Task " .. self:GetName() ) --self:MessageToGroups( PlayerUnit:GetPlayerName() .. " is planning to join Task " .. self:GetName() )
end end
if self:IsStateAssigned() then if self:IsStateAssigned() then
@@ -738,13 +738,14 @@ function TASK:SetPlannedMenuForGroup( TaskGroup, MenuTime )
--local MissionMenu = Mission:GetMenu( TaskGroup ) --local MissionMenu = Mission:GetMenu( TaskGroup )
local TaskPlannedMenu = MENU_GROUP:New( TaskGroup, "Join Planned Task", MissionMenu, Mission.MenuReportTasksPerStatus, Mission, TaskGroup, "Planned" ):SetTime( MenuTime ) self.MenuPlanned = self.MenuPlanned or {}
local TaskTypeMenu = MENU_GROUP:New( TaskGroup, TaskType, TaskPlannedMenu ):SetTime( MenuTime ):SetRemoveParent( true ) self.MenuPlanned[TaskGroup] = MENU_GROUP:New( TaskGroup, "Join Planned Task", MissionMenu, Mission.MenuReportTasksPerStatus, Mission, TaskGroup, "Planned" ):SetTime( MenuTime )
local TaskTypeMenu = MENU_GROUP:New( TaskGroup, TaskType, self.MenuPlanned[TaskGroup] ):SetTime( MenuTime ):SetRemoveParent( true )
local TaskTypeMenu = MENU_GROUP:New( TaskGroup, TaskText, TaskTypeMenu ):SetTime( MenuTime ):SetRemoveParent( true ) local TaskTypeMenu = MENU_GROUP:New( TaskGroup, TaskText, TaskTypeMenu ):SetTime( MenuTime ):SetRemoveParent( true )
local ReportTaskMenu = MENU_GROUP_COMMAND:New( TaskGroup, string.format( "Report Task Status" ), TaskTypeMenu, self.MenuTaskStatus, self, TaskGroup ):SetTime( MenuTime ):SetRemoveParent( true ) local ReportTaskMenu = MENU_GROUP_COMMAND:New( TaskGroup, string.format( "Report Task Status" ), TaskTypeMenu, self.MenuTaskStatus, self, TaskGroup ):SetTime( MenuTime ):SetRemoveParent( true )
if not Mission:IsGroupAssigned( TaskGroup ) then if not Mission:IsGroupAssigned( TaskGroup ) then
local JoinTaskMenu = MENU_GROUP_COMMAND:New( TaskGroup, string.format( "Join Task" ), TaskTypeMenu, self.MenuAssignToGroup, { self = self, TaskGroup = TaskGroup } ):SetTime( MenuTime ):SetRemoveParent( true ) local JoinTaskMenu = MENU_GROUP_COMMAND:New( TaskGroup, string.format( "Join Task" ), TaskTypeMenu, self.MenuAssignToGroup, self, TaskGroup ):SetTime( MenuTime ):SetRemoveParent( true )
end end
return self return self
@@ -775,9 +776,10 @@ function TASK:SetAssignedMenuForGroup( TaskGroup, MenuTime )
-- local MissionMenu = MENU_GROUP:New( TaskGroup, MissionName, CommandCenterMenu ):SetTime( MenuTime ) -- local MissionMenu = MENU_GROUP:New( TaskGroup, MissionName, CommandCenterMenu ):SetTime( MenuTime )
-- local MissionMenu = Mission:GetMenu( TaskGroup ) -- local MissionMenu = Mission:GetMenu( TaskGroup )
local TaskAssignedMenu = MENU_GROUP:New( TaskGroup, string.format( "Assigned Task %s", TaskName ), MissionMenu ):SetTime( MenuTime ) self.MenuAssigned = self.MenuAssigned or {}
local TaskTypeMenu = MENU_GROUP_COMMAND:New( TaskGroup, string.format( "Report Task Status" ), TaskAssignedMenu, self.MenuTaskStatus, self, TaskGroup ):SetTime( MenuTime ):SetRemoveParent( true ) self.MenuAssigned[TaskGroup] = MENU_GROUP:New( TaskGroup, string.format( "Assigned Task %s", TaskName ), MissionMenu ):SetTime( MenuTime )
local TaskMenu = MENU_GROUP_COMMAND:New( TaskGroup, string.format( "Abort Group from Task" ), TaskAssignedMenu, self.MenuTaskAbort, self, TaskGroup ):SetTime( MenuTime ):SetRemoveParent( true ) local TaskTypeMenu = MENU_GROUP_COMMAND:New( TaskGroup, string.format( "Report Task Status" ), self.MenuAssigned[TaskGroup], self.MenuTaskStatus, self, TaskGroup ):SetTime( MenuTime ):SetRemoveParent( true )
local TaskMenu = MENU_GROUP_COMMAND:New( TaskGroup, string.format( "Abort Group from Task" ), self.MenuAssigned[TaskGroup], self.MenuTaskAbort, self, TaskGroup ):SetTime( MenuTime ):SetRemoveParent( true )
return self return self
end end
@@ -791,9 +793,7 @@ function TASK:RemoveMenu( MenuTime )
for TaskGroupID, TaskGroup in pairs( self.SetGroup:GetSet() ) do for TaskGroupID, TaskGroup in pairs( self.SetGroup:GetSet() ) do
local TaskGroup = TaskGroup -- Wrapper.Group#GROUP local TaskGroup = TaskGroup -- Wrapper.Group#GROUP
if TaskGroup:IsAlive() and TaskGroup:GetPlayerNames() then self:RefreshMenus( TaskGroup, MenuTime )
self:RefreshMenus( TaskGroup, MenuTime )
end
end end
end end
@@ -814,8 +814,11 @@ function TASK:RefreshMenus( TaskGroup, MenuTime )
local MissionMenu = Mission:GetMenu( TaskGroup ) local MissionMenu = Mission:GetMenu( TaskGroup )
local TaskName = self:GetName() local TaskName = self:GetName()
local PlannedMenu = MissionMenu:GetMenu( "Planned Tasks" ) self.MenuPlanned = self.MenuPlanned or {}
local AssignedMenu = MissionMenu:GetMenu( string.format( "Assigned Task %s", TaskName ) ) local PlannedMenu = self.MenuPlanned[TaskGroup]
self.MenuAssigned = self.MenuAssigned or {}
local AssignedMenu = self.MenuAssigned[TaskGroup]
if PlannedMenu then if PlannedMenu then
PlannedMenu:Remove( MenuTime ) PlannedMenu:Remove( MenuTime )
@@ -846,10 +849,9 @@ function TASK:RemoveAssignedMenuForGroup( TaskGroup )
end end
function TASK.MenuAssignToGroup( MenuParam ) --- @param #TASK self
-- @param Wrapper.Group#GROUP TaskGroup
local self = MenuParam.self function TASK:MenuAssignToGroup( TaskGroup )
local TaskGroup = MenuParam.TaskGroup
self:E( "Assigned menu selected") self:E( "Assigned menu selected")