From a6830237f4793c509759d3eeeac892c25c0ae857 Mon Sep 17 00:00:00 2001 From: FlightControl_Master Date: Wed, 26 Jul 2017 22:17:15 +0200 Subject: [PATCH] Fixed bug in MENU_GROUP_COMMAND --- Moose Development/Moose/Core/Menu.lua | 47 +++++++++++++----------- Moose Development/Moose/Tasking/Task.lua | 1 + 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/Moose Development/Moose/Core/Menu.lua b/Moose Development/Moose/Core/Menu.lua index f6e828f24..b3af2daff 100644 --- a/Moose Development/Moose/Core/Menu.lua +++ b/Moose Development/Moose/Core/Menu.lua @@ -140,8 +140,9 @@ do -- MENU_COMMAND_BASE local self = BASE:Inherit( self, MENU_BASE:New( MenuText, ParentMenu ) ) self.CommandMenuFunction = CommandMenuFunction - self.MenuCallHandler = function( CommandMenuArguments ) - self.CommandMenuFunction( unpack( CommandMenuArguments ) ) + self.CommandMenuArguments = CommandMenuArguments + self.MenuCallHandler = function() + self.CommandMenuFunction( unpack( self.CommandMenuArguments ) ) end return self @@ -893,28 +894,30 @@ do if MenuGroup._Menus[Path] then self = MenuGroup._Menus[Path] self:F2( { "Re-using Group Command Menu:", MenuGroup:GetName(), MenuText } ) - else - self = BASE:Inherit( self, MENU_COMMAND_BASE:New( MenuText, ParentMenu, CommandMenuFunction, arg ) ) + missionCommands.removeItemForGroup( self.MenuGroupID, self.MenuPath ) - --if MenuGroup:IsAlive() then - MenuGroup._Menus[Path] = self - --end - - self.Path = Path - self.MenuGroup = MenuGroup - self.MenuGroupID = MenuGroup:GetID() - self.MenuText = MenuText - self.ParentMenu = ParentMenu - - self:F( { "Adding Group Command Menu:", MenuGroup = MenuGroup:GetName(), MenuText = MenuText, MenuPath = self.MenuParentPath } ) - self.MenuPath = missionCommands.addCommandForGroup( self.MenuGroupID, MenuText, self.MenuParentPath, self.MenuCallHandler, arg ) - - if self.ParentMenu and self.ParentMenu.Menus then - self.ParentMenu.Menus[MenuText] = self - self.ParentMenu.MenuCount = self.ParentMenu.MenuCount + 1 - self:F2( { ParentMenu.Menus, MenuText } ) - end end + self = BASE:Inherit( self, MENU_COMMAND_BASE:New( MenuText, ParentMenu, CommandMenuFunction, arg ) ) + + --if MenuGroup:IsAlive() then + MenuGroup._Menus[Path] = self + --end + + self.Path = Path + self.MenuGroup = MenuGroup + self.MenuGroupID = MenuGroup:GetID() + self.MenuText = MenuText + self.ParentMenu = ParentMenu + + self:F( { "Adding Group Command Menu:", MenuGroup = MenuGroup:GetName(), MenuText = MenuText, MenuPath = self.MenuParentPath } ) + self.MenuPath = missionCommands.addCommandForGroup( self.MenuGroupID, MenuText, self.MenuParentPath, self.MenuCallHandler, arg ) + + if self.ParentMenu and self.ParentMenu.Menus then + self.ParentMenu.Menus[MenuText] = self + self.ParentMenu.MenuCount = self.ParentMenu.MenuCount + 1 + self:F2( { ParentMenu.Menus, MenuText } ) + end +-- end return self end diff --git a/Moose Development/Moose/Tasking/Task.lua b/Moose Development/Moose/Tasking/Task.lua index 01b3f0f8a..fcbf35d69 100644 --- a/Moose Development/Moose/Tasking/Task.lua +++ b/Moose Development/Moose/Tasking/Task.lua @@ -745,6 +745,7 @@ function TASK:SetPlannedMenuForGroup( TaskGroup, MenuTime ) local ReportTaskMenu = MENU_GROUP_COMMAND:New( TaskGroup, string.format( "Report Task Status" ), TaskTypeMenu, self.MenuTaskStatus, self, TaskGroup ):SetTime( MenuTime ):SetTag( "Tasking" ):SetRemoveParent( true ) if not Mission:IsGroupAssigned( TaskGroup ) then + self:F( { "Replacing Join Task menu" } ) local JoinTaskMenu = MENU_GROUP_COMMAND:New( TaskGroup, string.format( "Join Task" ), TaskTypeMenu, self.MenuAssignToGroup, self, TaskGroup ):SetTime( MenuTime ):SetTag( "Tasking" ):SetRemoveParent( true ) end