mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Menu cleanup for Refresh()
This commit is contained in:
parent
e0397dff47
commit
c5ecba3389
@ -64,7 +64,6 @@ MENU_INDEX.Coalition[coalition.side.RED].Menus = {}
|
|||||||
MENU_INDEX.Group = {}
|
MENU_INDEX.Group = {}
|
||||||
|
|
||||||
function MENU_INDEX:ParentPath( ParentMenu, MenuText )
|
function MENU_INDEX:ParentPath( ParentMenu, MenuText )
|
||||||
|
|
||||||
local Path = ParentMenu and "@" .. table.concat( ParentMenu.MenuPath or {}, "@" ) or ""
|
local Path = ParentMenu and "@" .. table.concat( ParentMenu.MenuPath or {}, "@" ) or ""
|
||||||
if ParentMenu then
|
if ParentMenu then
|
||||||
if ParentMenu:IsInstanceOf( "MENU_GROUP" ) or ParentMenu:IsInstanceOf( "MENU_GROUP_COMMAND" ) then
|
if ParentMenu:IsInstanceOf( "MENU_GROUP" ) or ParentMenu:IsInstanceOf( "MENU_GROUP_COMMAND" ) then
|
||||||
@ -92,22 +91,20 @@ function MENU_INDEX:ParentPath( ParentMenu, MenuText )
|
|||||||
|
|
||||||
Path = Path .. "@" .. MenuText
|
Path = Path .. "@" .. MenuText
|
||||||
return Path
|
return Path
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function MENU_INDEX:PrepareMission()
|
function MENU_INDEX:PrepareMission()
|
||||||
self.MenuMission.Menus = self.MenuMission.Menus or {}
|
self.MenuMission.Menus = self.MenuMission.Menus or {}
|
||||||
end
|
end
|
||||||
|
|
||||||
function MENU_INDEX:PrepareCoalition( CoalitionSide )
|
function MENU_INDEX:PrepareCoalition( CoalitionSide )
|
||||||
self.Coalition[CoalitionSide] = self.Coalition[CoalitionSide] or {}
|
self.Coalition[CoalitionSide] = self.Coalition[CoalitionSide] or {}
|
||||||
self.Coalition[CoalitionSide].Menus = self.Coalition[CoalitionSide].Menus or {}
|
self.Coalition[CoalitionSide].Menus = self.Coalition[CoalitionSide].Menus or {}
|
||||||
end
|
end
|
||||||
|
|
||||||
---
|
---
|
||||||
-- @param Wrapper.Group#GROUP Group
|
-- @param Wrapper.Group#GROUP Group
|
||||||
function MENU_INDEX:PrepareGroup( Group )
|
function MENU_INDEX:PrepareGroup( Group )
|
||||||
if Group and Group:IsAlive() ~= nil then -- something was changed here!
|
if Group and Group:IsAlive() ~= nil then -- something was changed here!
|
||||||
local GroupName = Group:GetName()
|
local GroupName = Group:GetName()
|
||||||
self.Group[GroupName] = self.Group[GroupName] or {}
|
self.Group[GroupName] = self.Group[GroupName] or {}
|
||||||
self.Group[GroupName].Menus = self.Group[GroupName].Menus or {}
|
self.Group[GroupName].Menus = self.Group[GroupName].Menus or {}
|
||||||
@ -115,32 +112,22 @@ function MENU_INDEX:PrepareGroup( Group )
|
|||||||
end
|
end
|
||||||
|
|
||||||
function MENU_INDEX:HasMissionMenu( Path )
|
function MENU_INDEX:HasMissionMenu( Path )
|
||||||
|
|
||||||
return self.MenuMission.Menus[Path]
|
return self.MenuMission.Menus[Path]
|
||||||
end
|
end
|
||||||
|
|
||||||
function MENU_INDEX:SetMissionMenu( Path, Menu )
|
function MENU_INDEX:SetMissionMenu( Path, Menu )
|
||||||
|
|
||||||
self.MenuMission.Menus[Path] = Menu
|
self.MenuMission.Menus[Path] = Menu
|
||||||
end
|
end
|
||||||
|
|
||||||
function MENU_INDEX:ClearMissionMenu( Path )
|
function MENU_INDEX:ClearMissionMenu( Path )
|
||||||
|
|
||||||
self.MenuMission.Menus[Path] = nil
|
self.MenuMission.Menus[Path] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
function MENU_INDEX:HasCoalitionMenu( Coalition, Path )
|
function MENU_INDEX:HasCoalitionMenu( Coalition, Path )
|
||||||
|
|
||||||
return self.Coalition[Coalition].Menus[Path]
|
return self.Coalition[Coalition].Menus[Path]
|
||||||
end
|
end
|
||||||
|
|
||||||
function MENU_INDEX:SetCoalitionMenu( Coalition, Path, Menu )
|
function MENU_INDEX:SetCoalitionMenu( Coalition, Path, Menu )
|
||||||
|
|
||||||
self.Coalition[Coalition].Menus[Path] = Menu
|
self.Coalition[Coalition].Menus[Path] = Menu
|
||||||
end
|
end
|
||||||
|
|
||||||
function MENU_INDEX:ClearCoalitionMenu( Coalition, Path )
|
function MENU_INDEX:ClearCoalitionMenu( Coalition, Path )
|
||||||
|
|
||||||
self.Coalition[Coalition].Menus[Path] = nil
|
self.Coalition[Coalition].Menus[Path] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -151,46 +138,36 @@ function MENU_INDEX:HasGroupMenu( Group, Path )
|
|||||||
end
|
end
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
function MENU_INDEX:SetGroupMenu( Group, Path, Menu )
|
function MENU_INDEX:SetGroupMenu( Group, Path, Menu )
|
||||||
|
|
||||||
local MenuGroupName = Group:GetName()
|
local MenuGroupName = Group:GetName()
|
||||||
Group:F( { MenuGroupName = MenuGroupName, Path = Path } )
|
Group:F({MenuGroupName=MenuGroupName,Path=Path})
|
||||||
self.Group[MenuGroupName].Menus[Path] = Menu
|
self.Group[MenuGroupName].Menus[Path] = Menu
|
||||||
end
|
end
|
||||||
|
|
||||||
function MENU_INDEX:ClearGroupMenu( Group, Path )
|
function MENU_INDEX:ClearGroupMenu( Group, Path )
|
||||||
|
|
||||||
local MenuGroupName = Group:GetName()
|
local MenuGroupName = Group:GetName()
|
||||||
self.Group[MenuGroupName].Menus[Path] = nil
|
self.Group[MenuGroupName].Menus[Path] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
function MENU_INDEX:Refresh( Group )
|
function MENU_INDEX:Refresh( Group )
|
||||||
|
for MenuID, Menu in pairs( self.MenuMission.Menus ) do
|
||||||
|
Menu:Refresh()
|
||||||
|
end
|
||||||
|
for MenuID, Menu in pairs( self.Coalition[coalition.side.BLUE].Menus ) do
|
||||||
|
Menu:Refresh()
|
||||||
|
end
|
||||||
|
for MenuID, Menu in pairs( self.Coalition[coalition.side.RED].Menus ) do
|
||||||
|
Menu:Refresh()
|
||||||
|
end
|
||||||
|
local GroupName = Group:GetName()
|
||||||
|
for MenuID, Menu in pairs( self.Group[GroupName].Menus ) do
|
||||||
|
Menu:Refresh()
|
||||||
|
end
|
||||||
|
|
||||||
for MenuID, Menu in pairs( self.MenuMission.Menus ) do
|
return self
|
||||||
Menu:Refresh()
|
|
||||||
end
|
|
||||||
|
|
||||||
for MenuID, Menu in pairs( self.Coalition[coalition.side.BLUE].Menus ) do
|
|
||||||
Menu:Refresh()
|
|
||||||
end
|
|
||||||
|
|
||||||
for MenuID, Menu in pairs( self.Coalition[coalition.side.RED].Menus ) do
|
|
||||||
Menu:Refresh()
|
|
||||||
end
|
|
||||||
|
|
||||||
local GroupName = Group:GetName()
|
|
||||||
for MenuID, Menu in pairs( self.Group[GroupName].Menus ) do
|
|
||||||
Menu:Refresh()
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
do -- MENU_BASE
|
do -- MENU_BASE
|
||||||
|
|
||||||
--- @type MENU_BASE
|
--- @type MENU_BASE
|
||||||
-- @extends Core.Base#BASE
|
-- @extends Core.Base#BASE
|
||||||
|
|
||||||
--- Defines the main MENU class where other MENU classes are derived from.
|
--- Defines the main MENU class where other MENU classes are derived from.
|
||||||
-- This is an abstract class, so don't use it.
|
-- This is an abstract class, so don't use it.
|
||||||
-- @field #MENU_BASE
|
-- @field #MENU_BASE
|
||||||
@ -210,14 +187,13 @@ do -- MENU_BASE
|
|||||||
if ParentMenu ~= nil then
|
if ParentMenu ~= nil then
|
||||||
MenuParentPath = ParentMenu.MenuPath
|
MenuParentPath = ParentMenu.MenuPath
|
||||||
end
|
end
|
||||||
|
|
||||||
local self = BASE:Inherit( self, BASE:New() )
|
local self = BASE:Inherit( self, BASE:New() )
|
||||||
|
|
||||||
self.MenuPath = nil
|
self.MenuPath = nil
|
||||||
self.MenuText = MenuText
|
self.MenuText = MenuText
|
||||||
self.ParentMenu = ParentMenu
|
self.ParentMenu = ParentMenu
|
||||||
self.MenuParentPath = MenuParentPath
|
self.MenuParentPath = MenuParentPath
|
||||||
self.Path = (self.ParentMenu and "@" .. table.concat( self.MenuParentPath or {}, "@" ) or "") .. "@" .. self.MenuText
|
self.Path = ( self.ParentMenu and "@" .. table.concat( self.MenuParentPath or {}, "@" ) or "" ) .. "@" .. self.MenuText
|
||||||
self.Menus = {}
|
self.Menus = {}
|
||||||
self.MenuCount = 0
|
self.MenuCount = 0
|
||||||
self.MenuStamp = timer.getTime()
|
self.MenuStamp = timer.getTime()
|
||||||
@ -230,7 +206,6 @@ do -- MENU_BASE
|
|||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
function MENU_BASE:SetParentMenu( MenuText, Menu )
|
function MENU_BASE:SetParentMenu( MenuText, Menu )
|
||||||
if self.ParentMenu then
|
if self.ParentMenu then
|
||||||
self.ParentMenu.Menus = self.ParentMenu.Menus or {}
|
self.ParentMenu.Menus = self.ParentMenu.Menus or {}
|
||||||
@ -238,23 +213,21 @@ do -- MENU_BASE
|
|||||||
self.ParentMenu.MenuCount = self.ParentMenu.MenuCount + 1
|
self.ParentMenu.MenuCount = self.ParentMenu.MenuCount + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function MENU_BASE:ClearParentMenu( MenuText )
|
function MENU_BASE:ClearParentMenu( MenuText )
|
||||||
if self.ParentMenu and self.ParentMenu.Menus[MenuText] then
|
if self.ParentMenu and self.ParentMenu.Menus[MenuText] then
|
||||||
self.ParentMenu.Menus[MenuText] = nil
|
self.ParentMenu.Menus[MenuText] = nil
|
||||||
self.ParentMenu.MenuCount = self.ParentMenu.MenuCount - 1
|
self.ParentMenu.MenuCount = self.ParentMenu.MenuCount - 1
|
||||||
if self.ParentMenu.MenuCount == 0 then
|
if self.ParentMenu.MenuCount == 0 then
|
||||||
-- self.ParentMenu:Remove()
|
--self.ParentMenu:Remove()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Sets a @{Menu} to remove automatically the parent menu when the menu removed is the last child menu of that parent @{Menu}.
|
--- 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 #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}.
|
-- @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
|
-- @return #MENU_BASE
|
||||||
function MENU_BASE:SetRemoveParent( RemoveParent )
|
function MENU_BASE:SetRemoveParent( RemoveParent )
|
||||||
-- self:F( { RemoveParent } )
|
--self:F( { RemoveParent } )
|
||||||
self.MenuRemoveParent = RemoveParent
|
self.MenuRemoveParent = RemoveParent
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@ -266,7 +239,6 @@ do -- MENU_BASE
|
|||||||
function MENU_BASE:GetMenu( MenuText )
|
function MENU_BASE:GetMenu( MenuText )
|
||||||
return self.Menus[MenuText]
|
return self.Menus[MenuText]
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Sets a menu stamp for later prevention of menu removal.
|
--- Sets a menu stamp for later prevention of menu removal.
|
||||||
-- @param #MENU_BASE self
|
-- @param #MENU_BASE self
|
||||||
-- @param MenuStamp
|
-- @param MenuStamp
|
||||||
@ -276,6 +248,7 @@ do -- MENU_BASE
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Gets a menu stamp for later prevention of menu removal.
|
--- Gets a menu stamp for later prevention of menu removal.
|
||||||
-- @param #MENU_BASE self
|
-- @param #MENU_BASE self
|
||||||
-- @return MenuStamp
|
-- @return MenuStamp
|
||||||
@ -283,6 +256,7 @@ do -- MENU_BASE
|
|||||||
return timer.getTime()
|
return timer.getTime()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Sets a time stamp for later prevention of menu removal.
|
--- Sets a time stamp for later prevention of menu removal.
|
||||||
-- @param #MENU_BASE self
|
-- @param #MENU_BASE self
|
||||||
-- @param MenuStamp
|
-- @param MenuStamp
|
||||||
@ -302,9 +276,7 @@ do -- MENU_BASE
|
|||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
do -- MENU_COMMAND_BASE
|
do -- MENU_COMMAND_BASE
|
||||||
|
|
||||||
--- @type MENU_COMMAND_BASE
|
--- @type MENU_COMMAND_BASE
|
||||||
-- @field #function MenuCallHandler
|
-- @field #function MenuCallHandler
|
||||||
-- @extends Core.Menu#MENU_BASE
|
-- @extends Core.Menu#MENU_BASE
|
||||||
@ -326,7 +298,6 @@ do -- MENU_COMMAND_BASE
|
|||||||
function MENU_COMMAND_BASE:New( MenuText, ParentMenu, CommandMenuFunction, CommandMenuArguments )
|
function MENU_COMMAND_BASE:New( MenuText, ParentMenu, CommandMenuFunction, CommandMenuArguments )
|
||||||
|
|
||||||
local self = BASE:Inherit( self, MENU_BASE:New( MenuText, ParentMenu ) ) -- #MENU_COMMAND_BASE
|
local self = BASE:Inherit( self, MENU_BASE:New( MenuText, ParentMenu ) ) -- #MENU_COMMAND_BASE
|
||||||
|
|
||||||
-- When a menu function goes into error, DCS displays an obscure menu message.
|
-- When a menu function goes into error, DCS displays an obscure menu message.
|
||||||
-- This error handler catches the menu error and displays the full call stack.
|
-- This error handler catches the menu error and displays the full call stack.
|
||||||
local ErrorHandler = function( errmsg )
|
local ErrorHandler = function( errmsg )
|
||||||
@ -359,7 +330,6 @@ do -- MENU_COMMAND_BASE
|
|||||||
self.CommandMenuFunction = CommandMenuFunction
|
self.CommandMenuFunction = CommandMenuFunction
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- This sets the new command arguments of a menu,
|
--- This sets the new command arguments of a menu,
|
||||||
-- so that if a menu is regenerated, or if command arguments change,
|
-- so that if a menu is regenerated, or if command arguments change,
|
||||||
-- that the arguments set for the menu are loosely coupled with the menu itself!!!
|
-- that the arguments set for the menu are loosely coupled with the menu itself!!!
|
||||||
@ -370,14 +340,11 @@ do -- MENU_COMMAND_BASE
|
|||||||
self.CommandMenuArguments = CommandMenuArguments
|
self.CommandMenuArguments = CommandMenuArguments
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
do -- MENU_MISSION
|
do -- MENU_MISSION
|
||||||
|
|
||||||
--- @type MENU_MISSION
|
--- @type MENU_MISSION
|
||||||
-- @extends Core.Menu#MENU_BASE
|
-- @extends Core.Menu#MENU_BASE
|
||||||
|
|
||||||
--- Manages the main menus for a complete mission.
|
--- Manages the main menus for a complete mission.
|
||||||
--
|
--
|
||||||
-- You can add menus with the @{#MENU_MISSION.New} method, which constructs a MENU_MISSION object and returns you the object reference.
|
-- You can add menus with the @{#MENU_MISSION.New} method, which constructs a MENU_MISSION object and returns you the object reference.
|
||||||
@ -397,7 +364,6 @@ do -- MENU_MISSION
|
|||||||
MENU_INDEX:PrepareMission()
|
MENU_INDEX:PrepareMission()
|
||||||
local Path = MENU_INDEX:ParentPath( ParentMenu, MenuText )
|
local Path = MENU_INDEX:ParentPath( ParentMenu, MenuText )
|
||||||
local MissionMenu = MENU_INDEX:HasMissionMenu( Path )
|
local MissionMenu = MENU_INDEX:HasMissionMenu( Path )
|
||||||
|
|
||||||
if MissionMenu then
|
if MissionMenu then
|
||||||
return MissionMenu
|
return MissionMenu
|
||||||
else
|
else
|
||||||
@ -410,17 +376,15 @@ do -- MENU_MISSION
|
|||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Refreshes a radio item for a mission
|
--- Refreshes a radio item for a mission
|
||||||
-- @param #MENU_MISSION self
|
-- @param #MENU_MISSION self
|
||||||
-- @return #MENU_MISSION
|
-- @return #MENU_MISSION
|
||||||
function MENU_MISSION:Refresh()
|
function MENU_MISSION:Refresh()
|
||||||
|
|
||||||
do
|
do
|
||||||
missionCommands.removeItem( self.MenuPath )
|
missionCommands.removeItem( self.MenuPath )
|
||||||
self.MenuPath = missionCommands.addSubMenu( self.MenuText, self.MenuParentPath )
|
self.MenuPath = missionCommands.addSubMenu( self.MenuText, self.MenuParentPath )
|
||||||
end
|
end
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Removes the sub menus recursively of this MENU_MISSION. Note that the main menu is kept!
|
--- Removes the sub menus recursively of this MENU_MISSION. Note that the main menu is kept!
|
||||||
@ -444,11 +408,10 @@ do -- MENU_MISSION
|
|||||||
MENU_INDEX:PrepareMission()
|
MENU_INDEX:PrepareMission()
|
||||||
local Path = MENU_INDEX:ParentPath( self.ParentMenu, self.MenuText )
|
local Path = MENU_INDEX:ParentPath( self.ParentMenu, self.MenuText )
|
||||||
local MissionMenu = MENU_INDEX:HasMissionMenu( Path )
|
local MissionMenu = MENU_INDEX:HasMissionMenu( Path )
|
||||||
|
|
||||||
if MissionMenu == self then
|
if MissionMenu == self then
|
||||||
self:RemoveSubMenus()
|
self:RemoveSubMenus()
|
||||||
if not MenuStamp or self.MenuStamp ~= MenuStamp then
|
if not MenuStamp or self.MenuStamp ~= MenuStamp then
|
||||||
if (not MenuTag) or (MenuTag and self.MenuTag and MenuTag == self.MenuTag) then
|
if ( not MenuTag ) or ( MenuTag and self.MenuTag and MenuTag == self.MenuTag ) then
|
||||||
self:F( { Text = self.MenuText, Path = self.MenuPath } )
|
self:F( { Text = self.MenuText, Path = self.MenuPath } )
|
||||||
if self.MenuPath ~= nil then
|
if self.MenuPath ~= nil then
|
||||||
missionCommands.removeItem( self.MenuPath )
|
missionCommands.removeItem( self.MenuPath )
|
||||||
@ -466,7 +429,6 @@ do -- MENU_MISSION
|
|||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
do -- MENU_MISSION_COMMAND
|
do -- MENU_MISSION_COMMAND
|
||||||
|
|
||||||
--- @type MENU_MISSION_COMMAND
|
--- @type MENU_MISSION_COMMAND
|
||||||
@ -494,7 +456,6 @@ do -- MENU_MISSION_COMMAND
|
|||||||
MENU_INDEX:PrepareMission()
|
MENU_INDEX:PrepareMission()
|
||||||
local Path = MENU_INDEX:ParentPath( ParentMenu, MenuText )
|
local Path = MENU_INDEX:ParentPath( ParentMenu, MenuText )
|
||||||
local MissionMenu = MENU_INDEX:HasMissionMenu( Path )
|
local MissionMenu = MENU_INDEX:HasMissionMenu( Path )
|
||||||
|
|
||||||
if MissionMenu then
|
if MissionMenu then
|
||||||
MissionMenu:SetCommandMenuFunction( CommandMenuFunction )
|
MissionMenu:SetCommandMenuFunction( CommandMenuFunction )
|
||||||
MissionMenu:SetCommandMenuArguments( arg )
|
MissionMenu:SetCommandMenuArguments( arg )
|
||||||
@ -508,17 +469,15 @@ do -- MENU_MISSION_COMMAND
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Refreshes a radio item for a mission
|
--- Refreshes a radio item for a mission
|
||||||
-- @param #MENU_MISSION_COMMAND self
|
-- @param #MENU_MISSION_COMMAND self
|
||||||
-- @return #MENU_MISSION_COMMAND
|
-- @return #MENU_MISSION_COMMAND
|
||||||
function MENU_MISSION_COMMAND:Refresh()
|
function MENU_MISSION_COMMAND:Refresh()
|
||||||
|
|
||||||
do
|
do
|
||||||
missionCommands.removeItem( self.MenuPath )
|
missionCommands.removeItem( self.MenuPath )
|
||||||
missionCommands.addCommand( self.MenuText, self.MenuParentPath, self.MenuCallHandler )
|
missionCommands.addCommand( self.MenuText, self.MenuParentPath, self.MenuCallHandler )
|
||||||
end
|
end
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Removes a radio command item for a coalition
|
--- Removes a radio command item for a coalition
|
||||||
@ -529,10 +488,9 @@ do -- MENU_MISSION_COMMAND
|
|||||||
MENU_INDEX:PrepareMission()
|
MENU_INDEX:PrepareMission()
|
||||||
local Path = MENU_INDEX:ParentPath( self.ParentMenu, self.MenuText )
|
local Path = MENU_INDEX:ParentPath( self.ParentMenu, self.MenuText )
|
||||||
local MissionMenu = MENU_INDEX:HasMissionMenu( Path )
|
local MissionMenu = MENU_INDEX:HasMissionMenu( Path )
|
||||||
|
|
||||||
if MissionMenu == self then
|
if MissionMenu == self then
|
||||||
if not MenuStamp or self.MenuStamp ~= MenuStamp then
|
if not MenuStamp or self.MenuStamp ~= MenuStamp then
|
||||||
if (not MenuTag) or (MenuTag and self.MenuTag and MenuTag == self.MenuTag) then
|
if ( not MenuTag ) or ( MenuTag and self.MenuTag and MenuTag == self.MenuTag ) then
|
||||||
self:F( { Text = self.MenuText, Path = self.MenuPath } )
|
self:F( { Text = self.MenuText, Path = self.MenuPath } )
|
||||||
if self.MenuPath ~= nil then
|
if self.MenuPath ~= nil then
|
||||||
missionCommands.removeItem( self.MenuPath )
|
missionCommands.removeItem( self.MenuPath )
|
||||||
@ -548,11 +506,8 @@ do -- MENU_MISSION_COMMAND
|
|||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
do -- MENU_COALITION
|
do -- MENU_COALITION
|
||||||
|
|
||||||
--- @type MENU_COALITION
|
--- @type MENU_COALITION
|
||||||
-- @extends Core.Menu#MENU_BASE
|
-- @extends Core.Menu#MENU_BASE
|
||||||
|
|
||||||
@ -601,7 +556,7 @@ do -- MENU_COALITION
|
|||||||
--
|
--
|
||||||
-- @field #MENU_COALITION
|
-- @field #MENU_COALITION
|
||||||
MENU_COALITION = {
|
MENU_COALITION = {
|
||||||
ClassName = "MENU_COALITION",
|
ClassName = "MENU_COALITION"
|
||||||
}
|
}
|
||||||
|
|
||||||
--- MENU_COALITION constructor. Creates a new MENU_COALITION object and creates the menu for a complete coalition.
|
--- MENU_COALITION constructor. Creates a new MENU_COALITION object and creates the menu for a complete coalition.
|
||||||
@ -611,15 +566,12 @@ do -- MENU_COALITION
|
|||||||
-- @param #table ParentMenu The parent menu. This parameter can be ignored if you want the menu to be located at the parent menu of DCS world (under F10 other).
|
-- @param #table ParentMenu The parent menu. This parameter can be ignored if you want the menu to be located at the parent menu of DCS world (under F10 other).
|
||||||
-- @return #MENU_COALITION self
|
-- @return #MENU_COALITION self
|
||||||
function MENU_COALITION:New( Coalition, MenuText, ParentMenu )
|
function MENU_COALITION:New( Coalition, MenuText, ParentMenu )
|
||||||
|
|
||||||
MENU_INDEX:PrepareCoalition( Coalition )
|
MENU_INDEX:PrepareCoalition( Coalition )
|
||||||
local Path = MENU_INDEX:ParentPath( ParentMenu, MenuText )
|
local Path = MENU_INDEX:ParentPath( ParentMenu, MenuText )
|
||||||
local CoalitionMenu = MENU_INDEX:HasCoalitionMenu( Coalition, Path )
|
local CoalitionMenu = MENU_INDEX:HasCoalitionMenu( Coalition, Path )
|
||||||
|
|
||||||
if CoalitionMenu then
|
if CoalitionMenu then
|
||||||
return CoalitionMenu
|
return CoalitionMenu
|
||||||
else
|
else
|
||||||
|
|
||||||
local self = BASE:Inherit( self, MENU_BASE:New( MenuText, ParentMenu ) )
|
local self = BASE:Inherit( self, MENU_BASE:New( MenuText, ParentMenu ) )
|
||||||
MENU_INDEX:SetCoalitionMenu( Coalition, Path, self )
|
MENU_INDEX:SetCoalitionMenu( Coalition, Path, self )
|
||||||
|
|
||||||
@ -630,17 +582,15 @@ do -- MENU_COALITION
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Refreshes a radio item for a coalition
|
--- Refreshes a radio item for a coalition
|
||||||
-- @param #MENU_COALITION self
|
-- @param #MENU_COALITION self
|
||||||
-- @return #MENU_COALITION
|
-- @return #MENU_COALITION
|
||||||
function MENU_COALITION:Refresh()
|
function MENU_COALITION:Refresh()
|
||||||
|
|
||||||
do
|
do
|
||||||
missionCommands.removeItemForCoalition( self.Coalition, self.MenuPath )
|
missionCommands.removeItemForCoalition( self.Coalition, self.MenuPath )
|
||||||
missionCommands.addSubMenuForCoalition( self.Coalition, self.MenuText, self.MenuParentPath )
|
missionCommands.addSubMenuForCoalition( self.Coalition, self.MenuText, self.MenuParentPath )
|
||||||
end
|
end
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Removes the sub menus recursively of this MENU_COALITION. Note that the main menu is kept!
|
--- Removes the sub menus recursively of this MENU_COALITION. Note that the main menu is kept!
|
||||||
@ -663,11 +613,10 @@ do -- MENU_COALITION
|
|||||||
MENU_INDEX:PrepareCoalition( self.Coalition )
|
MENU_INDEX:PrepareCoalition( self.Coalition )
|
||||||
local Path = MENU_INDEX:ParentPath( self.ParentMenu, self.MenuText )
|
local Path = MENU_INDEX:ParentPath( self.ParentMenu, self.MenuText )
|
||||||
local CoalitionMenu = MENU_INDEX:HasCoalitionMenu( self.Coalition, Path )
|
local CoalitionMenu = MENU_INDEX:HasCoalitionMenu( self.Coalition, Path )
|
||||||
|
|
||||||
if CoalitionMenu == self then
|
if CoalitionMenu == self then
|
||||||
self:RemoveSubMenus()
|
self:RemoveSubMenus()
|
||||||
if not MenuStamp or self.MenuStamp ~= MenuStamp then
|
if not MenuStamp or self.MenuStamp ~= MenuStamp then
|
||||||
if (not MenuTag) or (MenuTag and self.MenuTag and MenuTag == self.MenuTag) then
|
if ( not MenuTag ) or ( MenuTag and self.MenuTag and MenuTag == self.MenuTag ) then
|
||||||
self:F( { Coalition = self.Coalition, Text = self.MenuText, Path = self.MenuPath } )
|
self:F( { Coalition = self.Coalition, Text = self.MenuText, Path = self.MenuPath } )
|
||||||
if self.MenuPath ~= nil then
|
if self.MenuPath ~= nil then
|
||||||
missionCommands.removeItemForCoalition( self.Coalition, self.MenuPath )
|
missionCommands.removeItemForCoalition( self.Coalition, self.MenuPath )
|
||||||
@ -683,9 +632,7 @@ do -- MENU_COALITION
|
|||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
do -- MENU_COALITION_COMMAND
|
do -- MENU_COALITION_COMMAND
|
||||||
|
|
||||||
--- @type MENU_COALITION_COMMAND
|
--- @type MENU_COALITION_COMMAND
|
||||||
@ -698,7 +645,7 @@ do -- MENU_COALITION_COMMAND
|
|||||||
--
|
--
|
||||||
-- @field #MENU_COALITION_COMMAND
|
-- @field #MENU_COALITION_COMMAND
|
||||||
MENU_COALITION_COMMAND = {
|
MENU_COALITION_COMMAND = {
|
||||||
ClassName = "MENU_COALITION_COMMAND",
|
ClassName = "MENU_COALITION_COMMAND"
|
||||||
}
|
}
|
||||||
|
|
||||||
--- MENU_COALITION constructor. Creates a new radio command item for a coalition, which can invoke a function with parameters.
|
--- MENU_COALITION constructor. Creates a new radio command item for a coalition, which can invoke a function with parameters.
|
||||||
@ -714,7 +661,6 @@ do -- MENU_COALITION_COMMAND
|
|||||||
MENU_INDEX:PrepareCoalition( Coalition )
|
MENU_INDEX:PrepareCoalition( Coalition )
|
||||||
local Path = MENU_INDEX:ParentPath( ParentMenu, MenuText )
|
local Path = MENU_INDEX:ParentPath( ParentMenu, MenuText )
|
||||||
local CoalitionMenu = MENU_INDEX:HasCoalitionMenu( Coalition, Path )
|
local CoalitionMenu = MENU_INDEX:HasCoalitionMenu( Coalition, Path )
|
||||||
|
|
||||||
if CoalitionMenu then
|
if CoalitionMenu then
|
||||||
CoalitionMenu:SetCommandMenuFunction( CommandMenuFunction )
|
CoalitionMenu:SetCommandMenuFunction( CommandMenuFunction )
|
||||||
CoalitionMenu:SetCommandMenuArguments( arg )
|
CoalitionMenu:SetCommandMenuArguments( arg )
|
||||||
@ -729,19 +675,17 @@ do -- MENU_COALITION_COMMAND
|
|||||||
self:SetParentMenu( self.MenuText, self )
|
self:SetParentMenu( self.MenuText, self )
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Refreshes a radio item for a coalition
|
--- Refreshes a radio item for a coalition
|
||||||
-- @param #MENU_COALITION_COMMAND self
|
-- @param #MENU_COALITION_COMMAND self
|
||||||
-- @return #MENU_COALITION_COMMAND
|
-- @return #MENU_COALITION_COMMAND
|
||||||
function MENU_COALITION_COMMAND:Refresh()
|
function MENU_COALITION_COMMAND:Refresh()
|
||||||
|
|
||||||
do
|
do
|
||||||
missionCommands.removeItemForCoalition( self.Coalition, self.MenuPath )
|
missionCommands.removeItemForCoalition( self.Coalition, self.MenuPath )
|
||||||
missionCommands.addCommandForCoalition( self.Coalition, self.MenuText, self.MenuParentPath, self.MenuCallHandler )
|
missionCommands.addCommandForCoalition( self.Coalition, self.MenuText, self.MenuParentPath, self.MenuCallHandler )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Removes a radio command item for a coalition
|
--- Removes a radio command item for a coalition
|
||||||
@ -752,10 +696,9 @@ do -- MENU_COALITION_COMMAND
|
|||||||
MENU_INDEX:PrepareCoalition( self.Coalition )
|
MENU_INDEX:PrepareCoalition( self.Coalition )
|
||||||
local Path = MENU_INDEX:ParentPath( self.ParentMenu, self.MenuText )
|
local Path = MENU_INDEX:ParentPath( self.ParentMenu, self.MenuText )
|
||||||
local CoalitionMenu = MENU_INDEX:HasCoalitionMenu( self.Coalition, Path )
|
local CoalitionMenu = MENU_INDEX:HasCoalitionMenu( self.Coalition, Path )
|
||||||
|
|
||||||
if CoalitionMenu == self then
|
if CoalitionMenu == self then
|
||||||
if not MenuStamp or self.MenuStamp ~= MenuStamp then
|
if not MenuStamp or self.MenuStamp ~= MenuStamp then
|
||||||
if (not MenuTag) or (MenuTag and self.MenuTag and MenuTag == self.MenuTag) then
|
if ( not MenuTag ) or ( MenuTag and self.MenuTag and MenuTag == self.MenuTag ) then
|
||||||
self:F( { Coalition = self.Coalition, Text = self.MenuText, Path = self.MenuPath } )
|
self:F( { Coalition = self.Coalition, Text = self.MenuText, Path = self.MenuPath } )
|
||||||
if self.MenuPath ~= nil then
|
if self.MenuPath ~= nil then
|
||||||
missionCommands.removeItemForCoalition( self.Coalition, self.MenuPath )
|
missionCommands.removeItemForCoalition( self.Coalition, self.MenuPath )
|
||||||
@ -771,11 +714,9 @@ do -- MENU_COALITION_COMMAND
|
|||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- MENU_GROUP
|
--- MENU_GROUP
|
||||||
|
|
||||||
do
|
do
|
||||||
-- This local variable is used to cache the menus registered under groups.
|
-- This local variable is used to cache the menus registered under groups.
|
||||||
-- Menus don't disappear when groups for players are destroyed and restarted.
|
-- Menus don't disappear when groups for players are destroyed and restarted.
|
||||||
@ -783,10 +724,10 @@ do
|
|||||||
-- the same menus twice during initialization logic.
|
-- the same menus twice during initialization logic.
|
||||||
-- These menu classes are handling this logic with this variable.
|
-- These menu classes are handling this logic with this variable.
|
||||||
local _MENUGROUPS = {}
|
local _MENUGROUPS = {}
|
||||||
|
|
||||||
--- @type MENU_GROUP
|
--- @type MENU_GROUP
|
||||||
-- @extends Core.Menu#MENU_BASE
|
-- @extends Core.Menu#MENU_BASE
|
||||||
|
|
||||||
|
|
||||||
--- Manages the main menus for @{Wrapper.Group}s.
|
--- Manages the main menus for @{Wrapper.Group}s.
|
||||||
--
|
--
|
||||||
-- You can add menus with the @{#MENU_GROUP.New} method, which constructs a MENU_GROUP object and returns you the object reference.
|
-- You can add menus with the @{#MENU_GROUP.New} method, which constructs a MENU_GROUP object and returns you the object reference.
|
||||||
@ -844,7 +785,7 @@ do
|
|||||||
--
|
--
|
||||||
-- @field #MENU_GROUP
|
-- @field #MENU_GROUP
|
||||||
MENU_GROUP = {
|
MENU_GROUP = {
|
||||||
ClassName = "MENU_GROUP",
|
ClassName = "MENU_GROUP"
|
||||||
}
|
}
|
||||||
|
|
||||||
--- MENU_GROUP constructor. Creates a new radio menu item for a group.
|
--- MENU_GROUP constructor. Creates a new radio menu item for a group.
|
||||||
@ -858,16 +799,13 @@ do
|
|||||||
MENU_INDEX:PrepareGroup( Group )
|
MENU_INDEX:PrepareGroup( Group )
|
||||||
local Path = MENU_INDEX:ParentPath( ParentMenu, MenuText )
|
local Path = MENU_INDEX:ParentPath( ParentMenu, MenuText )
|
||||||
local GroupMenu = MENU_INDEX:HasGroupMenu( Group, Path )
|
local GroupMenu = MENU_INDEX:HasGroupMenu( Group, Path )
|
||||||
|
|
||||||
if GroupMenu then
|
if GroupMenu then
|
||||||
return GroupMenu
|
return GroupMenu
|
||||||
else
|
else
|
||||||
self = BASE:Inherit( self, MENU_BASE:New( MenuText, ParentMenu ) )
|
self = BASE:Inherit( self, MENU_BASE:New( MenuText, ParentMenu ) )
|
||||||
MENU_INDEX:SetGroupMenu( Group, Path, self )
|
MENU_INDEX:SetGroupMenu( Group, Path, self )
|
||||||
|
|
||||||
self.Group = Group
|
self.Group = Group
|
||||||
self.GroupID = Group:GetID()
|
self.GroupID = Group:GetID()
|
||||||
|
|
||||||
self.MenuPath = missionCommands.addSubMenuForGroup( self.GroupID, MenuText, self.MenuParentPath )
|
self.MenuPath = missionCommands.addSubMenuForGroup( self.GroupID, MenuText, self.MenuParentPath )
|
||||||
|
|
||||||
self:SetParentMenu( self.MenuText, self )
|
self:SetParentMenu( self.MenuText, self )
|
||||||
@ -875,12 +813,10 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Refreshes a new radio item for a group and submenus
|
--- Refreshes a new radio item for a group and submenus
|
||||||
-- @param #MENU_GROUP self
|
-- @param #MENU_GROUP self
|
||||||
-- @return #MENU_GROUP
|
-- @return #MENU_GROUP
|
||||||
function MENU_GROUP:Refresh()
|
function MENU_GROUP:Refresh()
|
||||||
|
|
||||||
do
|
do
|
||||||
missionCommands.removeItemForGroup( self.GroupID, self.MenuPath )
|
missionCommands.removeItemForGroup( self.GroupID, self.MenuPath )
|
||||||
missionCommands.addSubMenuForGroup( self.GroupID, self.MenuText, self.MenuParentPath )
|
missionCommands.addSubMenuForGroup( self.GroupID, self.MenuText, self.MenuParentPath )
|
||||||
@ -890,6 +826,7 @@ do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Removes the sub menus recursively of this MENU_GROUP.
|
--- Removes the sub menus recursively of this MENU_GROUP.
|
||||||
@ -898,7 +835,6 @@ do
|
|||||||
-- @param MenuTag A Tag or Key to filter the menus to be refreshed with the Tag set.
|
-- @param MenuTag A Tag or Key to filter the menus to be refreshed with the Tag set.
|
||||||
-- @return #MENU_GROUP self
|
-- @return #MENU_GROUP self
|
||||||
function MENU_GROUP:RemoveSubMenus( MenuStamp, MenuTag )
|
function MENU_GROUP:RemoveSubMenus( MenuStamp, MenuTag )
|
||||||
|
|
||||||
for MenuText, Menu in pairs( self.Menus or {} ) do
|
for MenuText, Menu in pairs( self.Menus or {} ) do
|
||||||
Menu:Remove( MenuStamp, MenuTag )
|
Menu:Remove( MenuStamp, MenuTag )
|
||||||
end
|
end
|
||||||
@ -913,15 +849,13 @@ do
|
|||||||
-- @param MenuTag A Tag or Key to filter the menus to be refreshed with the Tag set.
|
-- @param MenuTag A Tag or Key to filter the menus to be refreshed with the Tag set.
|
||||||
-- @return #nil
|
-- @return #nil
|
||||||
function MENU_GROUP:Remove( MenuStamp, MenuTag )
|
function MENU_GROUP:Remove( MenuStamp, MenuTag )
|
||||||
|
|
||||||
MENU_INDEX:PrepareGroup( self.Group )
|
MENU_INDEX:PrepareGroup( self.Group )
|
||||||
local Path = MENU_INDEX:ParentPath( self.ParentMenu, self.MenuText )
|
local Path = MENU_INDEX:ParentPath( self.ParentMenu, self.MenuText )
|
||||||
local GroupMenu = MENU_INDEX:HasGroupMenu( self.Group, Path )
|
local GroupMenu = MENU_INDEX:HasGroupMenu( self.Group, Path )
|
||||||
|
|
||||||
if GroupMenu == self then
|
if GroupMenu == self then
|
||||||
self:RemoveSubMenus( MenuStamp, MenuTag )
|
self:RemoveSubMenus( MenuStamp, MenuTag )
|
||||||
if not MenuStamp or self.MenuStamp ~= MenuStamp then
|
if not MenuStamp or self.MenuStamp ~= MenuStamp then
|
||||||
if (not MenuTag) or (MenuTag and self.MenuTag and MenuTag == self.MenuTag) then
|
if ( not MenuTag ) or ( MenuTag and self.MenuTag and MenuTag == self.MenuTag ) then
|
||||||
if self.MenuPath ~= nil then
|
if self.MenuPath ~= nil then
|
||||||
self:F( { Group = self.GroupID, Text = self.MenuText, Path = self.MenuPath } )
|
self:F( { Group = self.GroupID, Text = self.MenuText, Path = self.MenuPath } )
|
||||||
missionCommands.removeItemForGroup( self.GroupID, self.MenuPath )
|
missionCommands.removeItemForGroup( self.GroupID, self.MenuPath )
|
||||||
@ -939,6 +873,7 @@ do
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- @type MENU_GROUP_COMMAND
|
--- @type MENU_GROUP_COMMAND
|
||||||
-- @extends Core.Menu#MENU_COMMAND_BASE
|
-- @extends Core.Menu#MENU_COMMAND_BASE
|
||||||
|
|
||||||
@ -948,7 +883,7 @@ do
|
|||||||
--
|
--
|
||||||
-- @field #MENU_GROUP_COMMAND
|
-- @field #MENU_GROUP_COMMAND
|
||||||
MENU_GROUP_COMMAND = {
|
MENU_GROUP_COMMAND = {
|
||||||
ClassName = "MENU_GROUP_COMMAND",
|
ClassName = "MENU_GROUP_COMMAND"
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Creates a new radio command item for a group
|
--- Creates a new radio command item for a group
|
||||||
@ -960,18 +895,15 @@ do
|
|||||||
-- @param CommandMenuArgument An argument for the function.
|
-- @param CommandMenuArgument An argument for the function.
|
||||||
-- @return #MENU_GROUP_COMMAND
|
-- @return #MENU_GROUP_COMMAND
|
||||||
function MENU_GROUP_COMMAND:New( Group, MenuText, ParentMenu, CommandMenuFunction, ... )
|
function MENU_GROUP_COMMAND:New( Group, MenuText, ParentMenu, CommandMenuFunction, ... )
|
||||||
|
|
||||||
MENU_INDEX:PrepareGroup( Group )
|
MENU_INDEX:PrepareGroup( Group )
|
||||||
local Path = MENU_INDEX:ParentPath( ParentMenu, MenuText )
|
local Path = MENU_INDEX:ParentPath( ParentMenu, MenuText )
|
||||||
local GroupMenu = MENU_INDEX:HasGroupMenu( Group, Path )
|
local GroupMenu = MENU_INDEX:HasGroupMenu( Group, Path )
|
||||||
|
|
||||||
if GroupMenu then
|
if GroupMenu then
|
||||||
GroupMenu:SetCommandMenuFunction( CommandMenuFunction )
|
GroupMenu:SetCommandMenuFunction( CommandMenuFunction )
|
||||||
GroupMenu:SetCommandMenuArguments( arg )
|
GroupMenu:SetCommandMenuArguments( arg )
|
||||||
return GroupMenu
|
return GroupMenu
|
||||||
else
|
else
|
||||||
self = BASE:Inherit( self, MENU_COMMAND_BASE:New( MenuText, ParentMenu, CommandMenuFunction, arg ) )
|
self = BASE:Inherit( self, MENU_COMMAND_BASE:New( MenuText, ParentMenu, CommandMenuFunction, arg ) )
|
||||||
|
|
||||||
MENU_INDEX:SetGroupMenu( Group, Path, self )
|
MENU_INDEX:SetGroupMenu( Group, Path, self )
|
||||||
|
|
||||||
self.Group = Group
|
self.Group = Group
|
||||||
@ -982,19 +914,17 @@ do
|
|||||||
self:SetParentMenu( self.MenuText, self )
|
self:SetParentMenu( self.MenuText, self )
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Refreshes a radio item for a group
|
--- Refreshes a radio item for a group
|
||||||
-- @param #MENU_GROUP_COMMAND self
|
-- @param #MENU_GROUP_COMMAND self
|
||||||
-- @return #MENU_GROUP_COMMAND
|
-- @return #MENU_GROUP_COMMAND
|
||||||
function MENU_GROUP_COMMAND:Refresh()
|
function MENU_GROUP_COMMAND:Refresh()
|
||||||
|
|
||||||
do
|
do
|
||||||
missionCommands.removeItemForGroup( self.GroupID, self.MenuPath )
|
missionCommands.removeItemForGroup( self.GroupID, self.MenuPath )
|
||||||
missionCommands.addCommandForGroup( self.GroupID, self.MenuText, self.MenuParentPath, self.MenuCallHandler )
|
missionCommands.addCommandForGroup( self.GroupID, self.MenuText, self.MenuParentPath, self.MenuCallHandler )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Removes a menu structure for a group.
|
--- Removes a menu structure for a group.
|
||||||
@ -1003,16 +933,14 @@ do
|
|||||||
-- @param MenuTag A Tag or Key to filter the menus to be refreshed with the Tag set.
|
-- @param MenuTag A Tag or Key to filter the menus to be refreshed with the Tag set.
|
||||||
-- @return #nil
|
-- @return #nil
|
||||||
function MENU_GROUP_COMMAND:Remove( MenuStamp, MenuTag )
|
function MENU_GROUP_COMMAND:Remove( MenuStamp, MenuTag )
|
||||||
|
|
||||||
MENU_INDEX:PrepareGroup( self.Group )
|
MENU_INDEX:PrepareGroup( self.Group )
|
||||||
local Path = MENU_INDEX:ParentPath( self.ParentMenu, self.MenuText )
|
local Path = MENU_INDEX:ParentPath( self.ParentMenu, self.MenuText )
|
||||||
local GroupMenu = MENU_INDEX:HasGroupMenu( self.Group, Path )
|
local GroupMenu = MENU_INDEX:HasGroupMenu( self.Group, Path )
|
||||||
|
|
||||||
if GroupMenu == self then
|
if GroupMenu == self then
|
||||||
if not MenuStamp or self.MenuStamp ~= MenuStamp then
|
if not MenuStamp or self.MenuStamp ~= MenuStamp then
|
||||||
if (not MenuTag) or (MenuTag and self.MenuTag and MenuTag == self.MenuTag) then
|
if ( not MenuTag ) or ( MenuTag and self.MenuTag and MenuTag == self.MenuTag ) then
|
||||||
if self.MenuPath ~= nil then
|
if self.MenuPath ~= nil then
|
||||||
self:F( { Group = self.GroupID, Text = self.MenuText, Path = self.MenuPath } )
|
self:F( { Group = self.GroupID, Text = self.MenuText, Path = self.MenuPath } )
|
||||||
missionCommands.removeItemForGroup( self.GroupID, self.MenuPath )
|
missionCommands.removeItemForGroup( self.GroupID, self.MenuPath )
|
||||||
end
|
end
|
||||||
MENU_INDEX:ClearGroupMenu( self.Group, Path )
|
MENU_INDEX:ClearGroupMenu( self.Group, Path )
|
||||||
@ -1026,16 +954,13 @@ do
|
|||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- MENU_GROUP_DELAYED
|
--- MENU_GROUP_DELAYED
|
||||||
|
|
||||||
do
|
do
|
||||||
|
|
||||||
--- @type MENU_GROUP_DELAYED
|
--- @type MENU_GROUP_DELAYED
|
||||||
-- @extends Core.Menu#MENU_BASE
|
-- @extends Core.Menu#MENU_BASE
|
||||||
|
|
||||||
|
|
||||||
--- The MENU_GROUP_DELAYED class manages the main menus for groups.
|
--- The MENU_GROUP_DELAYED class manages the main menus for groups.
|
||||||
-- You can add menus with the @{#MENU_GROUP.New} method, which constructs a MENU_GROUP object and returns you the object reference.
|
-- You can add menus with the @{#MENU_GROUP.New} method, which constructs a MENU_GROUP object and returns you the object reference.
|
||||||
-- Using this object reference, you can then remove ALL the menus and submenus underlying automatically with @{#MENU_GROUP.Remove}.
|
-- Using this object reference, you can then remove ALL the menus and submenus underlying automatically with @{#MENU_GROUP.Remove}.
|
||||||
@ -1045,7 +970,7 @@ do
|
|||||||
--
|
--
|
||||||
-- @field #MENU_GROUP_DELAYED
|
-- @field #MENU_GROUP_DELAYED
|
||||||
MENU_GROUP_DELAYED = {
|
MENU_GROUP_DELAYED = {
|
||||||
ClassName = "MENU_GROUP_DELAYED",
|
ClassName = "MENU_GROUP_DELAYED"
|
||||||
}
|
}
|
||||||
|
|
||||||
--- MENU_GROUP_DELAYED constructor. Creates a new radio menu item for a group.
|
--- MENU_GROUP_DELAYED constructor. Creates a new radio menu item for a group.
|
||||||
@ -1059,16 +984,13 @@ do
|
|||||||
MENU_INDEX:PrepareGroup( Group )
|
MENU_INDEX:PrepareGroup( Group )
|
||||||
local Path = MENU_INDEX:ParentPath( ParentMenu, MenuText )
|
local Path = MENU_INDEX:ParentPath( ParentMenu, MenuText )
|
||||||
local GroupMenu = MENU_INDEX:HasGroupMenu( Group, Path )
|
local GroupMenu = MENU_INDEX:HasGroupMenu( Group, Path )
|
||||||
|
|
||||||
if GroupMenu then
|
if GroupMenu then
|
||||||
return GroupMenu
|
return GroupMenu
|
||||||
else
|
else
|
||||||
self = BASE:Inherit( self, MENU_BASE:New( MenuText, ParentMenu ) )
|
self = BASE:Inherit( self, MENU_BASE:New( MenuText, ParentMenu ) )
|
||||||
MENU_INDEX:SetGroupMenu( Group, Path, self )
|
MENU_INDEX:SetGroupMenu( Group, Path, self )
|
||||||
|
|
||||||
self.Group = Group
|
self.Group = Group
|
||||||
self.GroupID = Group:GetID()
|
self.GroupID = Group:GetID()
|
||||||
|
|
||||||
if self.MenuParentPath then
|
if self.MenuParentPath then
|
||||||
self.MenuPath = UTILS.DeepCopy( self.MenuParentPath )
|
self.MenuPath = UTILS.DeepCopy( self.MenuParentPath )
|
||||||
else
|
else
|
||||||
@ -1086,7 +1008,6 @@ do
|
|||||||
-- @param #MENU_GROUP_DELAYED self
|
-- @param #MENU_GROUP_DELAYED self
|
||||||
-- @return #MENU_GROUP_DELAYED
|
-- @return #MENU_GROUP_DELAYED
|
||||||
function MENU_GROUP_DELAYED:Set()
|
function MENU_GROUP_DELAYED:Set()
|
||||||
|
|
||||||
do
|
do
|
||||||
if not self.MenuSet then
|
if not self.MenuSet then
|
||||||
missionCommands.addSubMenuForGroup( self.GroupID, self.MenuText, self.MenuParentPath )
|
missionCommands.addSubMenuForGroup( self.GroupID, self.MenuText, self.MenuParentPath )
|
||||||
@ -1097,14 +1018,12 @@ do
|
|||||||
Menu:Set()
|
Menu:Set()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Refreshes a new radio item for a group and submenus
|
--- Refreshes a new radio item for a group and submenus
|
||||||
-- @param #MENU_GROUP_DELAYED self
|
-- @param #MENU_GROUP_DELAYED self
|
||||||
-- @return #MENU_GROUP_DELAYED
|
-- @return #MENU_GROUP_DELAYED
|
||||||
function MENU_GROUP_DELAYED:Refresh()
|
function MENU_GROUP_DELAYED:Refresh()
|
||||||
|
|
||||||
do
|
do
|
||||||
missionCommands.removeItemForGroup( self.GroupID, self.MenuPath )
|
missionCommands.removeItemForGroup( self.GroupID, self.MenuPath )
|
||||||
missionCommands.addSubMenuForGroup( self.GroupID, self.MenuText, self.MenuParentPath )
|
missionCommands.addSubMenuForGroup( self.GroupID, self.MenuText, self.MenuParentPath )
|
||||||
@ -1114,6 +1033,7 @@ do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Removes the sub menus recursively of this MENU_GROUP_DELAYED.
|
--- Removes the sub menus recursively of this MENU_GROUP_DELAYED.
|
||||||
@ -1122,7 +1042,6 @@ do
|
|||||||
-- @param MenuTag A Tag or Key to filter the menus to be refreshed with the Tag set.
|
-- @param MenuTag A Tag or Key to filter the menus to be refreshed with the Tag set.
|
||||||
-- @return #MENU_GROUP_DELAYED self
|
-- @return #MENU_GROUP_DELAYED self
|
||||||
function MENU_GROUP_DELAYED:RemoveSubMenus( MenuStamp, MenuTag )
|
function MENU_GROUP_DELAYED:RemoveSubMenus( MenuStamp, MenuTag )
|
||||||
|
|
||||||
for MenuText, Menu in pairs( self.Menus or {} ) do
|
for MenuText, Menu in pairs( self.Menus or {} ) do
|
||||||
Menu:Remove( MenuStamp, MenuTag )
|
Menu:Remove( MenuStamp, MenuTag )
|
||||||
end
|
end
|
||||||
@ -1137,15 +1056,13 @@ do
|
|||||||
-- @param MenuTag A Tag or Key to filter the menus to be refreshed with the Tag set.
|
-- @param MenuTag A Tag or Key to filter the menus to be refreshed with the Tag set.
|
||||||
-- @return #nil
|
-- @return #nil
|
||||||
function MENU_GROUP_DELAYED:Remove( MenuStamp, MenuTag )
|
function MENU_GROUP_DELAYED:Remove( MenuStamp, MenuTag )
|
||||||
|
|
||||||
MENU_INDEX:PrepareGroup( self.Group )
|
MENU_INDEX:PrepareGroup( self.Group )
|
||||||
local Path = MENU_INDEX:ParentPath( self.ParentMenu, self.MenuText )
|
local Path = MENU_INDEX:ParentPath( self.ParentMenu, self.MenuText )
|
||||||
local GroupMenu = MENU_INDEX:HasGroupMenu( self.Group, Path )
|
local GroupMenu = MENU_INDEX:HasGroupMenu( self.Group, Path )
|
||||||
|
|
||||||
if GroupMenu == self then
|
if GroupMenu == self then
|
||||||
self:RemoveSubMenus( MenuStamp, MenuTag )
|
self:RemoveSubMenus( MenuStamp, MenuTag )
|
||||||
if not MenuStamp or self.MenuStamp ~= MenuStamp then
|
if not MenuStamp or self.MenuStamp ~= MenuStamp then
|
||||||
if (not MenuTag) or (MenuTag and self.MenuTag and MenuTag == self.MenuTag) then
|
if ( not MenuTag ) or ( MenuTag and self.MenuTag and MenuTag == self.MenuTag ) then
|
||||||
if self.MenuPath ~= nil then
|
if self.MenuPath ~= nil then
|
||||||
self:F( { Group = self.GroupID, Text = self.MenuText, Path = self.MenuPath } )
|
self:F( { Group = self.GroupID, Text = self.MenuText, Path = self.MenuPath } )
|
||||||
missionCommands.removeItemForGroup( self.GroupID, self.MenuPath )
|
missionCommands.removeItemForGroup( self.GroupID, self.MenuPath )
|
||||||
@ -1163,6 +1080,7 @@ do
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- @type MENU_GROUP_COMMAND_DELAYED
|
--- @type MENU_GROUP_COMMAND_DELAYED
|
||||||
-- @extends Core.Menu#MENU_COMMAND_BASE
|
-- @extends Core.Menu#MENU_COMMAND_BASE
|
||||||
|
|
||||||
@ -1173,7 +1091,7 @@ do
|
|||||||
--
|
--
|
||||||
-- @field #MENU_GROUP_COMMAND_DELAYED
|
-- @field #MENU_GROUP_COMMAND_DELAYED
|
||||||
MENU_GROUP_COMMAND_DELAYED = {
|
MENU_GROUP_COMMAND_DELAYED = {
|
||||||
ClassName = "MENU_GROUP_COMMAND_DELAYED",
|
ClassName = "MENU_GROUP_COMMAND_DELAYED"
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Creates a new radio command item for a group
|
--- Creates a new radio command item for a group
|
||||||
@ -1185,18 +1103,15 @@ do
|
|||||||
-- @param CommandMenuArgument An argument for the function.
|
-- @param CommandMenuArgument An argument for the function.
|
||||||
-- @return #MENU_GROUP_COMMAND_DELAYED
|
-- @return #MENU_GROUP_COMMAND_DELAYED
|
||||||
function MENU_GROUP_COMMAND_DELAYED:New( Group, MenuText, ParentMenu, CommandMenuFunction, ... )
|
function MENU_GROUP_COMMAND_DELAYED:New( Group, MenuText, ParentMenu, CommandMenuFunction, ... )
|
||||||
|
|
||||||
MENU_INDEX:PrepareGroup( Group )
|
MENU_INDEX:PrepareGroup( Group )
|
||||||
local Path = MENU_INDEX:ParentPath( ParentMenu, MenuText )
|
local Path = MENU_INDEX:ParentPath( ParentMenu, MenuText )
|
||||||
local GroupMenu = MENU_INDEX:HasGroupMenu( Group, Path )
|
local GroupMenu = MENU_INDEX:HasGroupMenu( Group, Path )
|
||||||
|
|
||||||
if GroupMenu then
|
if GroupMenu then
|
||||||
GroupMenu:SetCommandMenuFunction( CommandMenuFunction )
|
GroupMenu:SetCommandMenuFunction( CommandMenuFunction )
|
||||||
GroupMenu:SetCommandMenuArguments( arg )
|
GroupMenu:SetCommandMenuArguments( arg )
|
||||||
return GroupMenu
|
return GroupMenu
|
||||||
else
|
else
|
||||||
self = BASE:Inherit( self, MENU_COMMAND_BASE:New( MenuText, ParentMenu, CommandMenuFunction, arg ) )
|
self = BASE:Inherit( self, MENU_COMMAND_BASE:New( MenuText, ParentMenu, CommandMenuFunction, arg ) )
|
||||||
|
|
||||||
MENU_INDEX:SetGroupMenu( Group, Path, self )
|
MENU_INDEX:SetGroupMenu( Group, Path, self )
|
||||||
|
|
||||||
self.Group = Group
|
self.Group = Group
|
||||||
@ -1212,33 +1127,29 @@ do
|
|||||||
self:SetParentMenu( self.MenuText, self )
|
self:SetParentMenu( self.MenuText, self )
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Refreshes a radio item for a group
|
--- Refreshes a radio item for a group
|
||||||
-- @param #MENU_GROUP_COMMAND_DELAYED self
|
-- @param #MENU_GROUP_COMMAND_DELAYED self
|
||||||
-- @return #MENU_GROUP_COMMAND_DELAYED
|
-- @return #MENU_GROUP_COMMAND_DELAYED
|
||||||
function MENU_GROUP_COMMAND_DELAYED:Set()
|
function MENU_GROUP_COMMAND_DELAYED:Set()
|
||||||
|
|
||||||
do
|
do
|
||||||
if not self.MenuSet then
|
if not self.MenuSet then
|
||||||
self.MenuPath = missionCommands.addCommandForGroup( self.GroupID, self.MenuText, self.MenuParentPath, self.MenuCallHandler )
|
self.MenuPath = missionCommands.addCommandForGroup( self.GroupID, self.MenuText, self.MenuParentPath, self.MenuCallHandler )
|
||||||
self.MenuSet = true
|
self.MenuSet = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Refreshes a radio item for a group
|
--- Refreshes a radio item for a group
|
||||||
-- @param #MENU_GROUP_COMMAND_DELAYED self
|
-- @param #MENU_GROUP_COMMAND_DELAYED self
|
||||||
-- @return #MENU_GROUP_COMMAND_DELAYED
|
-- @return #MENU_GROUP_COMMAND_DELAYED
|
||||||
function MENU_GROUP_COMMAND_DELAYED:Refresh()
|
function MENU_GROUP_COMMAND_DELAYED:Refresh()
|
||||||
|
|
||||||
do
|
do
|
||||||
missionCommands.removeItemForGroup( self.GroupID, self.MenuPath )
|
missionCommands.removeItemForGroup( self.GroupID, self.MenuPath )
|
||||||
missionCommands.addCommandForGroup( self.GroupID, self.MenuText, self.MenuParentPath, self.MenuCallHandler )
|
missionCommands.addCommandForGroup( self.GroupID, self.MenuText, self.MenuParentPath, self.MenuCallHandler )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Removes a menu structure for a group.
|
--- Removes a menu structure for a group.
|
||||||
@ -1247,14 +1158,12 @@ do
|
|||||||
-- @param MenuTag A Tag or Key to filter the menus to be refreshed with the Tag set.
|
-- @param MenuTag A Tag or Key to filter the menus to be refreshed with the Tag set.
|
||||||
-- @return #nil
|
-- @return #nil
|
||||||
function MENU_GROUP_COMMAND_DELAYED:Remove( MenuStamp, MenuTag )
|
function MENU_GROUP_COMMAND_DELAYED:Remove( MenuStamp, MenuTag )
|
||||||
|
|
||||||
MENU_INDEX:PrepareGroup( self.Group )
|
MENU_INDEX:PrepareGroup( self.Group )
|
||||||
local Path = MENU_INDEX:ParentPath( self.ParentMenu, self.MenuText )
|
local Path = MENU_INDEX:ParentPath( self.ParentMenu, self.MenuText )
|
||||||
local GroupMenu = MENU_INDEX:HasGroupMenu( self.Group, Path )
|
local GroupMenu = MENU_INDEX:HasGroupMenu( self.Group, Path )
|
||||||
|
|
||||||
if GroupMenu == self then
|
if GroupMenu == self then
|
||||||
if not MenuStamp or self.MenuStamp ~= MenuStamp then
|
if not MenuStamp or self.MenuStamp ~= MenuStamp then
|
||||||
if (not MenuTag) or (MenuTag and self.MenuTag and MenuTag == self.MenuTag) then
|
if ( not MenuTag ) or ( MenuTag and self.MenuTag and MenuTag == self.MenuTag ) then
|
||||||
if self.MenuPath ~= nil then
|
if self.MenuPath ~= nil then
|
||||||
self:F( { Group = self.GroupID, Text = self.MenuText, Path = self.MenuPath } )
|
self:F( { Group = self.GroupID, Text = self.MenuText, Path = self.MenuPath } )
|
||||||
missionCommands.removeItemForGroup( self.GroupID, self.MenuPath )
|
missionCommands.removeItemForGroup( self.GroupID, self.MenuPath )
|
||||||
@ -1270,6 +1179,5 @@ do
|
|||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user