mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Fixed abort logic and trace overhead on menus
This commit is contained in:
parent
02e2f21ec6
commit
82477c93d2
@ -810,9 +810,9 @@ do
|
|||||||
-- @param MenuTime
|
-- @param MenuTime
|
||||||
-- @return #MENU_GROUP self
|
-- @return #MENU_GROUP self
|
||||||
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:", 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
|
||||||
@ -825,7 +825,7 @@ do
|
|||||||
-- @param MenuTime
|
-- @param MenuTime
|
||||||
-- @return #nil
|
-- @return #nil
|
||||||
function MENU_GROUP:Remove( MenuTime )
|
function MENU_GROUP:Remove( MenuTime )
|
||||||
self:F( { self.MenuGroupID, self.MenuPath, MenuTime, self.MenuTime } )
|
--self:F2( { self.MenuGroupID, self.MenuPath, MenuTime, self.MenuTime } )
|
||||||
|
|
||||||
self:RemoveSubMenus( MenuTime )
|
self:RemoveSubMenus( MenuTime )
|
||||||
|
|
||||||
@ -844,7 +844,7 @@ do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self:T( { "Removing Group Menu:", self.MenuGroup:GetName(), self.MenuGroup._Menus[self.Path].Path } )
|
self:T( { "Removing Group Menu:", MenuGroup = self.MenuGroup:GetName(), MenuPath = self.MenuGroup._Menus[self.Path].Path } )
|
||||||
self.MenuGroup._Menus[self.Path] = nil
|
self.MenuGroup._Menus[self.Path] = nil
|
||||||
self = nil
|
self = nil
|
||||||
end
|
end
|
||||||
@ -896,7 +896,7 @@ do
|
|||||||
self.MenuText = MenuText
|
self.MenuText = MenuText
|
||||||
self.ParentMenu = ParentMenu
|
self.ParentMenu = ParentMenu
|
||||||
|
|
||||||
self:T( { "Adding Group Command Menu:", MenuGroup:GetName(), MenuText, self.MenuParentPath } )
|
self:T( { "Adding Group Command Menu:", MenuGroup = MenuGroup:GetName(), MenuText = MenuText, MenuPath = 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 self.ParentMenu and self.ParentMenu.Menus then
|
if self.ParentMenu and self.ParentMenu.Menus then
|
||||||
@ -914,14 +914,14 @@ do
|
|||||||
-- @param MenuTime
|
-- @param MenuTime
|
||||||
-- @return #nil
|
-- @return #nil
|
||||||
function MENU_GROUP_COMMAND:Remove( MenuTime )
|
function MENU_GROUP_COMMAND:Remove( MenuTime )
|
||||||
self:F( { self.MenuGroupID, self.MenuPath, MenuTime, self.MenuTime } )
|
--self:F2( { self.MenuGroupID, self.MenuPath, MenuTime, self.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]
|
||||||
|
|
||||||
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:", MenuGroup = self.MenuGroup:GetName(), MenuText = self.MenuText, MenuPath = self.Path } )
|
||||||
|
|
||||||
self.ParentMenu.Menus[self.MenuText] = nil
|
self.ParentMenu.Menus[self.MenuText] = nil
|
||||||
self.ParentMenu.MenuCount = self.ParentMenu.MenuCount - 1
|
self.ParentMenu.MenuCount = self.ParentMenu.MenuCount - 1
|
||||||
|
|||||||
@ -261,13 +261,10 @@ end
|
|||||||
-- @param #TASK self
|
-- @param #TASK self
|
||||||
-- @param Wrapper.Unit#UNIT PlayerUnit The CLIENT or UNIT of the Player aborting the Task.
|
-- @param Wrapper.Unit#UNIT PlayerUnit The CLIENT or UNIT of the Player aborting the Task.
|
||||||
-- @return #boolean true if Unit is part of the Task.
|
-- @return #boolean true if Unit is part of the Task.
|
||||||
function TASK:AbortUnit( PlayerUnit )
|
function TASK:AbortGroup( PlayerGroup )
|
||||||
self:F( { PlayerUnit = PlayerUnit } )
|
self:F( { PlayerGroup = PlayerGroup } )
|
||||||
|
|
||||||
local PlayerUnitAborted = false
|
|
||||||
|
|
||||||
local PlayerGroups = self:GetGroups()
|
local PlayerGroups = self:GetGroups()
|
||||||
local PlayerGroup = PlayerUnit:GetGroup()
|
|
||||||
|
|
||||||
-- Is the PlayerGroup part of the PlayerGroups?
|
-- Is the PlayerGroup part of the PlayerGroups?
|
||||||
if PlayerGroups:IsIncludeObject( PlayerGroup ) then
|
if PlayerGroups:IsIncludeObject( PlayerGroup ) then
|
||||||
@ -278,7 +275,7 @@ function TASK:AbortUnit( PlayerUnit )
|
|||||||
local IsGroupAssigned = self:IsGroupAssigned( PlayerGroup )
|
local IsGroupAssigned = self:IsGroupAssigned( PlayerGroup )
|
||||||
self:E( { IsGroupAssigned = IsGroupAssigned } )
|
self:E( { IsGroupAssigned = IsGroupAssigned } )
|
||||||
if IsGroupAssigned then
|
if IsGroupAssigned then
|
||||||
local PlayerName = PlayerUnit:GetPlayerName()
|
local PlayerName = PlayerGroup:GetUnit(1):GetPlayerName()
|
||||||
self:MessageToGroups( PlayerName .. " aborted Task " .. self:GetName() )
|
self:MessageToGroups( PlayerName .. " aborted Task " .. self:GetName() )
|
||||||
self:UnAssignFromGroup( PlayerGroup )
|
self:UnAssignFromGroup( PlayerGroup )
|
||||||
--self:Abort()
|
--self:Abort()
|
||||||
@ -286,22 +283,24 @@ function TASK:AbortUnit( PlayerUnit )
|
|||||||
-- Now check if the task needs to go to hold...
|
-- Now check if the task needs to go to hold...
|
||||||
-- It will go to hold, if there are no players in the mission...
|
-- It will go to hold, if there are no players in the mission...
|
||||||
|
|
||||||
|
PlayerGroups:Flush()
|
||||||
local IsRemaining = false
|
local IsRemaining = false
|
||||||
for GroupName, AssignedGroup in pairs( PlayerGroups ) do
|
for GroupName, AssignedGroup in pairs( PlayerGroups:GetSet() or {} ) do
|
||||||
IsRemaining = ( IsRemaining == false ) and self:IsGroupAssigned( AssignedGroup ) or IsRemaining
|
IsRemaining = ( ( IsRemaining == false ) and self:IsGroupAssigned( AssignedGroup ) ) or IsRemaining
|
||||||
|
self:F( { Task = self:GetName(), IsRemaining = IsRemaining } )
|
||||||
end
|
end
|
||||||
|
|
||||||
if IsRemaining == false then
|
if IsRemaining == false then
|
||||||
self:Abort()
|
self:Abort()
|
||||||
end
|
end
|
||||||
|
|
||||||
self:PlayerAborted( PlayerUnit )
|
self:PlayerAborted( PlayerGroup:GetUnit(1) )
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return PlayerUnitAborted
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- A PlayerUnit crashed in a Task. Abort the Player.
|
--- A PlayerUnit crashed in a Task. Abort the Player.
|
||||||
@ -369,7 +368,7 @@ do -- Group Assignment
|
|||||||
|
|
||||||
local TaskGroupName = TaskGroup:GetName()
|
local TaskGroupName = TaskGroup:GetName()
|
||||||
|
|
||||||
if self.AssignedGroups[TaskGroupName] == TaskGroup then
|
if self.AssignedGroups[TaskGroupName] then
|
||||||
self:T( { "Task is assigned to:", TaskGroup:GetName() } )
|
self:T( { "Task is assigned to:", TaskGroup:GetName() } )
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@ -808,10 +807,7 @@ end
|
|||||||
-- @param #TASK self
|
-- @param #TASK self
|
||||||
function TASK:MenuTaskAbort( TaskGroup )
|
function TASK:MenuTaskAbort( TaskGroup )
|
||||||
|
|
||||||
for PlayerUnitName, PlayerUnit in pairs( TaskGroup:GetUnits() ) do
|
self:AbortGroup( TaskGroup )
|
||||||
self:AbortUnit( PlayerUnit )
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user