mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Added link in Core.Menu to the demo missions.
This commit is contained in:
parent
07a76ced88
commit
3a0d2a5c51
@ -1,9 +1,9 @@
|
|||||||
--- **Core** - Manage hierarchical menu structures and commands for players within a mission.
|
--- **Core** - Manage hierarchical menu structures and commands for players within a mission.
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
-- ### Features:
|
-- ## Features:
|
||||||
--
|
--
|
||||||
-- * Setup mission sub menus.
|
-- * Setup mission sub menus.
|
||||||
-- * Setup mission command menus.
|
-- * Setup mission command menus.
|
||||||
-- * Setup coalition sub menus.
|
-- * Setup coalition sub menus.
|
||||||
@ -21,35 +21,39 @@
|
|||||||
-- * Update the parameters and the receiving methods, without updating the menu within DCS!
|
-- * Update the parameters and the receiving methods, without updating the menu within DCS!
|
||||||
-- * Provide a great performance boost in menu management.
|
-- * Provide a great performance boost in menu management.
|
||||||
-- * Provide a great tool to manage menus in your code.
|
-- * Provide a great tool to manage menus in your code.
|
||||||
--
|
--
|
||||||
-- DCS Menus can be managed using the MENU classes.
|
-- DCS Menus can be managed using the MENU classes.
|
||||||
-- The advantage of using MENU classes is that it hides the complexity of dealing with menu management in more advanced scenarios where you need to
|
-- The advantage of using MENU classes is that it hides the complexity of dealing with menu management in more advanced scenarios where you need to
|
||||||
-- set menus and later remove them, and later set them again. You'll find while using use normal DCS scripting functions, that setting and removing
|
-- set menus and later remove them, and later set them again. You'll find while using use normal DCS scripting functions, that setting and removing
|
||||||
-- menus is not a easy feat if you have complex menu hierarchies defined.
|
-- menus is not a easy feat if you have complex menu hierarchies defined.
|
||||||
-- Using the MOOSE menu classes, the removal and refreshing of menus are nicely being handled within these classes, and becomes much more easy.
|
-- Using the MOOSE menu classes, the removal and refreshing of menus are nicely being handled within these classes, and becomes much more easy.
|
||||||
-- On top, MOOSE implements **variable parameter** passing for command menus.
|
-- On top, MOOSE implements **variable parameter** passing for command menus.
|
||||||
--
|
--
|
||||||
-- There are basically two different MENU class types that you need to use:
|
-- There are basically two different MENU class types that you need to use:
|
||||||
--
|
--
|
||||||
-- ### To manage **main menus**, the classes begin with **MENU_**:
|
-- ### To manage **main menus**, the classes begin with **MENU_**:
|
||||||
--
|
--
|
||||||
-- * @{Core.Menu#MENU_MISSION}: Manages main menus for whole mission file.
|
-- * @{Core.Menu#MENU_MISSION}: Manages main menus for whole mission file.
|
||||||
-- * @{Core.Menu#MENU_COALITION}: Manages main menus for whole coalition.
|
-- * @{Core.Menu#MENU_COALITION}: Manages main menus for whole coalition.
|
||||||
-- * @{Core.Menu#MENU_GROUP}: Manages main menus for GROUPs.
|
-- * @{Core.Menu#MENU_GROUP}: Manages main menus for GROUPs.
|
||||||
--
|
--
|
||||||
-- ### To manage **command menus**, which are menus that allow the player to issue **functions**, the classes begin with **MENU_COMMAND_**:
|
-- ### To manage **command menus**, which are menus that allow the player to issue **functions**, the classes begin with **MENU_COMMAND_**:
|
||||||
--
|
--
|
||||||
-- * @{Core.Menu#MENU_MISSION_COMMAND}: Manages command menus for whole mission file.
|
-- * @{Core.Menu#MENU_MISSION_COMMAND}: Manages command menus for whole mission file.
|
||||||
-- * @{Core.Menu#MENU_COALITION_COMMAND}: Manages command menus for whole coalition.
|
-- * @{Core.Menu#MENU_COALITION_COMMAND}: Manages command menus for whole coalition.
|
||||||
-- * @{Core.Menu#MENU_GROUP_COMMAND}: Manages command menus for GROUPs.
|
-- * @{Core.Menu#MENU_GROUP_COMMAND}: Manages command menus for GROUPs.
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
---
|
--
|
||||||
|
-- ### [Demo Missions](https://github.com/FlightControl-Master/MOOSE_Demos/tree/master/Core/Menu)
|
||||||
|
--
|
||||||
|
-- ===
|
||||||
|
--
|
||||||
-- ### Author: **FlightControl**
|
-- ### Author: **FlightControl**
|
||||||
-- ### Contributions:
|
-- ### Contributions:
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
-- @module Core.Menu
|
-- @module Core.Menu
|
||||||
-- @image Core_Menu.JPG
|
-- @image Core_Menu.JPG
|
||||||
|
|
||||||
@ -65,18 +69,18 @@ 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
|
||||||
local GroupName = ParentMenu.Group:GetName()
|
local GroupName = ParentMenu.Group:GetName()
|
||||||
if not self.Group[GroupName].Menus[Path] then
|
if not self.Group[GroupName].Menus[Path] then
|
||||||
BASE:E( { Path = Path, GroupName = GroupName } )
|
BASE:E( { Path = Path, GroupName = GroupName } )
|
||||||
error( "Parent path not found in menu index for group menu" )
|
error( "Parent path not found in menu index for group menu" )
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
elseif ParentMenu:IsInstanceOf( "MENU_COALITION" ) or ParentMenu:IsInstanceOf( "MENU_COALITION_COMMAND" ) then
|
elseif ParentMenu:IsInstanceOf( "MENU_COALITION" ) or ParentMenu:IsInstanceOf( "MENU_COALITION_COMMAND" ) then
|
||||||
local Coalition = ParentMenu.Coalition
|
local Coalition = ParentMenu.Coalition
|
||||||
if not self.Coalition[Coalition].Menus[Path] then
|
if not self.Coalition[Coalition].Menus[Path] then
|
||||||
BASE:E( { Path = Path, Coalition = Coalition } )
|
BASE:E( { Path = Path, Coalition = Coalition } )
|
||||||
error( "Parent path not found in menu index for coalition menu" )
|
error( "Parent path not found in menu index for coalition menu" )
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
@ -88,7 +92,7 @@ function MENU_INDEX:ParentPath( ParentMenu, MenuText )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Path = Path .. "@" .. MenuText
|
Path = Path .. "@" .. MenuText
|
||||||
return Path
|
return Path
|
||||||
end
|
end
|
||||||
@ -149,19 +153,19 @@ function MENU_INDEX:ClearGroupMenu( Group, Path )
|
|||||||
end
|
end
|
||||||
function MENU_INDEX:Refresh( Group )
|
function MENU_INDEX:Refresh( Group )
|
||||||
for MenuID, Menu in pairs( self.MenuMission.Menus ) do
|
for MenuID, Menu in pairs( self.MenuMission.Menus ) do
|
||||||
Menu:Refresh()
|
Menu:Refresh()
|
||||||
end
|
end
|
||||||
for MenuID, Menu in pairs( self.Coalition[coalition.side.BLUE].Menus ) do
|
for MenuID, Menu in pairs( self.Coalition[coalition.side.BLUE].Menus ) do
|
||||||
Menu:Refresh()
|
Menu:Refresh()
|
||||||
end
|
end
|
||||||
for MenuID, Menu in pairs( self.Coalition[coalition.side.RED].Menus ) do
|
for MenuID, Menu in pairs( self.Coalition[coalition.side.RED].Menus ) do
|
||||||
Menu:Refresh()
|
Menu:Refresh()
|
||||||
end
|
end
|
||||||
local GroupName = Group:GetName()
|
local GroupName = Group:GetName()
|
||||||
for MenuID, Menu in pairs( self.Group[GroupName].Menus ) do
|
for MenuID, Menu in pairs( self.Group[GroupName].Menus ) do
|
||||||
Menu:Refresh()
|
Menu:Refresh()
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -177,19 +181,19 @@ do -- MENU_BASE
|
|||||||
MenuText = "",
|
MenuText = "",
|
||||||
MenuParentPath = nil,
|
MenuParentPath = nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Constructor
|
--- Constructor
|
||||||
-- @param #MENU_BASE
|
-- @param #MENU_BASE
|
||||||
-- @return #MENU_BASE
|
-- @return #MENU_BASE
|
||||||
function MENU_BASE:New( MenuText, ParentMenu )
|
function MENU_BASE:New( MenuText, ParentMenu )
|
||||||
|
|
||||||
local MenuParentPath = {}
|
local MenuParentPath = {}
|
||||||
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
|
||||||
@ -198,12 +202,12 @@ do -- MENU_BASE
|
|||||||
self.MenuCount = 0
|
self.MenuCount = 0
|
||||||
self.MenuStamp = timer.getTime()
|
self.MenuStamp = timer.getTime()
|
||||||
self.MenuRemoveParent = false
|
self.MenuRemoveParent = false
|
||||||
|
|
||||||
if self.ParentMenu then
|
if self.ParentMenu then
|
||||||
self.ParentMenu.Menus = self.ParentMenu.Menus or {}
|
self.ParentMenu.Menus = self.ParentMenu.Menus or {}
|
||||||
self.ParentMenu.Menus[MenuText] = self
|
self.ParentMenu.Menus[MenuText] = self
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
function MENU_BASE:SetParentMenu( MenuText, Menu )
|
function MENU_BASE:SetParentMenu( MenuText, Menu )
|
||||||
@ -231,7 +235,7 @@ do -- MENU_BASE
|
|||||||
self.MenuRemoveParent = RemoveParent
|
self.MenuRemoveParent = RemoveParent
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Gets a @{Menu} from a parent @{Menu}
|
--- Gets a @{Menu} from a parent @{Menu}
|
||||||
-- @param #MENU_BASE self
|
-- @param #MENU_BASE self
|
||||||
-- @param #string MenuText The text of the child menu.
|
-- @param #string MenuText The text of the child menu.
|
||||||
@ -239,7 +243,7 @@ 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
|
||||||
@ -248,16 +252,16 @@ do -- MENU_BASE
|
|||||||
self.MenuStamp = MenuStamp
|
self.MenuStamp = MenuStamp
|
||||||
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
|
||||||
function MENU_BASE:GetStamp()
|
function MENU_BASE:GetStamp()
|
||||||
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
|
||||||
@ -266,7 +270,7 @@ do -- MENU_BASE
|
|||||||
self.MenuStamp = MenuStamp
|
self.MenuStamp = MenuStamp
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Sets a tag for later selection of menu refresh.
|
--- Sets a tag for later selection of menu refresh.
|
||||||
-- @param #MENU_BASE self
|
-- @param #MENU_BASE self
|
||||||
-- @param #string MenuTag A Tag or Key that will filter only menu items set with this key.
|
-- @param #string MenuTag A Tag or Key that will filter only menu items set with this key.
|
||||||
@ -275,16 +279,16 @@ do -- MENU_BASE
|
|||||||
self.MenuTag = MenuTag
|
self.MenuTag = MenuTag
|
||||||
return self
|
return self
|
||||||
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
|
||||||
|
|
||||||
--- Defines the main MENU class where other MENU COMMAND_
|
--- Defines the main MENU class where other MENU COMMAND_
|
||||||
-- classes are derived from, in order to set commands.
|
-- classes are derived from, in order to set commands.
|
||||||
--
|
--
|
||||||
-- @field #MENU_COMMAND_BASE
|
-- @field #MENU_COMMAND_BASE
|
||||||
MENU_COMMAND_BASE = {
|
MENU_COMMAND_BASE = {
|
||||||
ClassName = "MENU_COMMAND_BASE",
|
ClassName = "MENU_COMMAND_BASE",
|
||||||
@ -292,12 +296,12 @@ do -- MENU_COMMAND_BASE
|
|||||||
CommandMenuArgument = nil,
|
CommandMenuArgument = nil,
|
||||||
MenuCallHandler = nil,
|
MenuCallHandler = nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Constructor
|
--- Constructor
|
||||||
-- @param #MENU_COMMAND_BASE
|
-- @param #MENU_COMMAND_BASE
|
||||||
-- @return #MENU_COMMAND_BASE
|
-- @return #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.
|
||||||
@ -308,20 +312,20 @@ do -- MENU_COMMAND_BASE
|
|||||||
end
|
end
|
||||||
return errmsg
|
return errmsg
|
||||||
end
|
end
|
||||||
|
|
||||||
self:SetCommandMenuFunction( CommandMenuFunction )
|
self:SetCommandMenuFunction( CommandMenuFunction )
|
||||||
self:SetCommandMenuArguments( CommandMenuArguments )
|
self:SetCommandMenuArguments( CommandMenuArguments )
|
||||||
self.MenuCallHandler = function()
|
self.MenuCallHandler = function()
|
||||||
local function MenuFunction()
|
local function MenuFunction()
|
||||||
return self.CommandMenuFunction( unpack( self.CommandMenuArguments ) )
|
return self.CommandMenuFunction( unpack( self.CommandMenuArguments ) )
|
||||||
end
|
end
|
||||||
local Status, Result = xpcall( MenuFunction, ErrorHandler )
|
local Status, Result = xpcall( MenuFunction, ErrorHandler )
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- This sets the new command function of a menu,
|
--- This sets the new command function of a menu,
|
||||||
-- so that if a menu is regenerated, or if command function changes,
|
-- so that if a menu is regenerated, or if command function changes,
|
||||||
-- that the function set for the menu is loosely coupled with the menu itself!!!
|
-- that the function set for the menu is loosely coupled with the menu itself!!!
|
||||||
-- If the function changes, no new menu needs to be generated if the menu text is the same!!!
|
-- If the function changes, no new menu needs to be generated if the menu text is the same!!!
|
||||||
@ -331,7 +335,7 @@ 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!!!
|
||||||
-- If the arguments change, no new menu needs to be generated if the menu text is the same!!!
|
-- If the arguments change, no new menu needs to be generated if the menu text is the same!!!
|
||||||
@ -346,38 +350,38 @@ 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.
|
||||||
-- Using this object reference, you can then remove ALL the menus and submenus underlying automatically with @{#MENU_MISSION.Remove}.
|
-- Using this object reference, you can then remove ALL the menus and submenus underlying automatically with @{#MENU_MISSION.Remove}.
|
||||||
-- @field #MENU_MISSION
|
-- @field #MENU_MISSION
|
||||||
MENU_MISSION = {
|
MENU_MISSION = {
|
||||||
ClassName = "MENU_MISSION",
|
ClassName = "MENU_MISSION",
|
||||||
}
|
}
|
||||||
|
|
||||||
--- MENU_MISSION constructor. Creates a new MENU_MISSION object and creates the menu for a complete mission file.
|
--- MENU_MISSION constructor. Creates a new MENU_MISSION object and creates the menu for a complete mission file.
|
||||||
-- @param #MENU_MISSION self
|
-- @param #MENU_MISSION self
|
||||||
-- @param #string MenuText The text for the menu.
|
-- @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 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_MISSION
|
-- @return #MENU_MISSION
|
||||||
function MENU_MISSION:New( MenuText, ParentMenu )
|
function MENU_MISSION:New( MenuText, ParentMenu )
|
||||||
|
|
||||||
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
|
||||||
local self = BASE:Inherit( self, MENU_BASE:New( MenuText, ParentMenu ) )
|
local self = BASE:Inherit( self, MENU_BASE:New( MenuText, ParentMenu ) )
|
||||||
MENU_INDEX:SetMissionMenu( Path, self )
|
MENU_INDEX:SetMissionMenu( Path, self )
|
||||||
|
|
||||||
self.MenuPath = missionCommands.addSubMenu( self.MenuText, self.MenuParentPath )
|
self.MenuPath = missionCommands.addSubMenu( self.MenuText, self.MenuParentPath )
|
||||||
self:SetParentMenu( self.MenuText, self )
|
self:SetParentMenu( self.MenuText, self )
|
||||||
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 self
|
-- @param #MENU_MISSION self
|
||||||
-- @return #MENU_MISSION
|
-- @return #MENU_MISSION
|
||||||
@ -388,28 +392,28 @@ do -- MENU_MISSION
|
|||||||
end
|
end
|
||||||
return self
|
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!
|
||||||
-- @param #MENU_MISSION self
|
-- @param #MENU_MISSION self
|
||||||
-- @return #MENU_MISSION
|
-- @return #MENU_MISSION
|
||||||
function MENU_MISSION:RemoveSubMenus()
|
function MENU_MISSION:RemoveSubMenus()
|
||||||
|
|
||||||
for MenuID, Menu in pairs( self.Menus or {} ) do
|
for MenuID, Menu in pairs( self.Menus or {} ) do
|
||||||
Menu:Remove()
|
Menu:Remove()
|
||||||
end
|
end
|
||||||
|
|
||||||
self.Menus = nil
|
self.Menus = nil
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Removes the main menu and the sub menus recursively of this MENU_MISSION.
|
--- Removes the main menu and the sub menus recursively of this MENU_MISSION.
|
||||||
-- @param #MENU_MISSION self
|
-- @param #MENU_MISSION self
|
||||||
-- @return #nil
|
-- @return #nil
|
||||||
function MENU_MISSION:Remove( MenuStamp, MenuTag )
|
function MENU_MISSION:Remove( MenuStamp, MenuTag )
|
||||||
|
|
||||||
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
|
||||||
@ -426,26 +430,26 @@ do -- MENU_MISSION
|
|||||||
else
|
else
|
||||||
BASE:E( { "Cannot Remove MENU_MISSION", Path = Path, ParentMenu = self.ParentMenu, MenuText = self.MenuText } )
|
BASE:E( { "Cannot Remove MENU_MISSION", Path = Path, ParentMenu = self.ParentMenu, MenuText = self.MenuText } )
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
do -- MENU_MISSION_COMMAND
|
do -- MENU_MISSION_COMMAND
|
||||||
|
|
||||||
--- @type MENU_MISSION_COMMAND
|
--- @type MENU_MISSION_COMMAND
|
||||||
-- @extends Core.Menu#MENU_COMMAND_BASE
|
-- @extends Core.Menu#MENU_COMMAND_BASE
|
||||||
|
|
||||||
--- Manages the command menus for a complete mission, which allow players to execute functions during mission execution.
|
--- Manages the command menus for a complete mission, which allow players to execute functions during mission execution.
|
||||||
--
|
--
|
||||||
-- You can add menus with the @{#MENU_MISSION_COMMAND.New} method, which constructs a MENU_MISSION_COMMAND object and returns you the object reference.
|
-- You can add menus with the @{#MENU_MISSION_COMMAND.New} method, which constructs a MENU_MISSION_COMMAND object and returns you the object reference.
|
||||||
-- Using this object reference, you can then remove ALL the menus and submenus underlying automatically with @{#MENU_MISSION_COMMAND.Remove}.
|
-- Using this object reference, you can then remove ALL the menus and submenus underlying automatically with @{#MENU_MISSION_COMMAND.Remove}.
|
||||||
--
|
--
|
||||||
-- @field #MENU_MISSION_COMMAND
|
-- @field #MENU_MISSION_COMMAND
|
||||||
MENU_MISSION_COMMAND = {
|
MENU_MISSION_COMMAND = {
|
||||||
ClassName = "MENU_MISSION_COMMAND",
|
ClassName = "MENU_MISSION_COMMAND",
|
||||||
}
|
}
|
||||||
|
|
||||||
--- MENU_MISSION constructor. Creates a new radio command item for a complete mission file, which can invoke a function with parameters.
|
--- MENU_MISSION constructor. Creates a new radio command item for a complete mission file, which can invoke a function with parameters.
|
||||||
-- @param #MENU_MISSION_COMMAND self
|
-- @param #MENU_MISSION_COMMAND self
|
||||||
-- @param #string MenuText The text for the menu.
|
-- @param #string MenuText The text for the menu.
|
||||||
@ -454,10 +458,10 @@ do -- MENU_MISSION_COMMAND
|
|||||||
-- @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.
|
-- @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_MISSION_COMMAND self
|
-- @return #MENU_MISSION_COMMAND self
|
||||||
function MENU_MISSION_COMMAND:New( MenuText, ParentMenu, CommandMenuFunction, ... )
|
function MENU_MISSION_COMMAND:New( MenuText, ParentMenu, CommandMenuFunction, ... )
|
||||||
|
|
||||||
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 )
|
||||||
@ -465,7 +469,7 @@ do -- MENU_MISSION_COMMAND
|
|||||||
else
|
else
|
||||||
local self = BASE:Inherit( self, MENU_COMMAND_BASE:New( MenuText, ParentMenu, CommandMenuFunction, arg ) )
|
local self = BASE:Inherit( self, MENU_COMMAND_BASE:New( MenuText, ParentMenu, CommandMenuFunction, arg ) )
|
||||||
MENU_INDEX:SetMissionMenu( Path, self )
|
MENU_INDEX:SetMissionMenu( Path, self )
|
||||||
|
|
||||||
self.MenuPath = missionCommands.addCommand( MenuText, self.MenuParentPath, self.MenuCallHandler )
|
self.MenuPath = missionCommands.addCommand( MenuText, self.MenuParentPath, self.MenuCallHandler )
|
||||||
self:SetParentMenu( self.MenuText, self )
|
self:SetParentMenu( self.MenuText, self )
|
||||||
return self
|
return self
|
||||||
@ -481,15 +485,15 @@ do -- MENU_MISSION_COMMAND
|
|||||||
end
|
end
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Removes a radio command item for a coalition
|
--- Removes a radio command item for a coalition
|
||||||
-- @param #MENU_MISSION_COMMAND self
|
-- @param #MENU_MISSION_COMMAND self
|
||||||
-- @return #nil
|
-- @return #nil
|
||||||
function MENU_MISSION_COMMAND:Remove()
|
function MENU_MISSION_COMMAND:Remove()
|
||||||
|
|
||||||
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
|
||||||
@ -505,19 +509,19 @@ do -- MENU_MISSION_COMMAND
|
|||||||
else
|
else
|
||||||
BASE:E( { "Cannot Remove MENU_MISSION_COMMAND", Path = Path, ParentMenu = self.ParentMenu, MenuText = self.MenuText } )
|
BASE:E( { "Cannot Remove MENU_MISSION_COMMAND", Path = Path, ParentMenu = self.ParentMenu, MenuText = self.MenuText } )
|
||||||
end
|
end
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
--- Manages the main menus for DCS.coalition.
|
--- Manages the main menus for DCS.coalition.
|
||||||
--
|
--
|
||||||
-- You can add menus with the @{#MENU_COALITION.New} method, which constructs a MENU_COALITION object and returns you the object reference.
|
-- You can add menus with the @{#MENU_COALITION.New} method, which constructs a MENU_COALITION object and returns you the object reference.
|
||||||
-- Using this object reference, you can then remove ALL the menus and submenus underlying automatically with @{#MENU_COALITION.Remove}.
|
-- Using this object reference, you can then remove ALL the menus and submenus underlying automatically with @{#MENU_COALITION.Remove}.
|
||||||
--
|
--
|
||||||
--
|
--
|
||||||
-- @usage
|
-- @usage
|
||||||
-- -- This demo creates a menu structure for the planes within the red coalition.
|
-- -- This demo creates a menu structure for the planes within the red coalition.
|
||||||
@ -547,7 +551,7 @@ do -- MENU_COALITION
|
|||||||
-- end
|
-- end
|
||||||
--
|
--
|
||||||
-- local function AddStatusMenu()
|
-- local function AddStatusMenu()
|
||||||
--
|
--
|
||||||
-- -- This would create a menu for the red coalition under the MenuCoalitionRed menu object.
|
-- -- This would create a menu for the red coalition under the MenuCoalitionRed menu object.
|
||||||
-- MenuStatus = MENU_COALITION:New( coalition.side.RED, "Status for Planes" )
|
-- MenuStatus = MENU_COALITION:New( coalition.side.RED, "Status for Planes" )
|
||||||
-- MenuStatusShow = MENU_COALITION_COMMAND:New( coalition.side.RED, "Show Status", MenuStatus, ShowStatus, "Status of planes is ok!", "Message to Red Coalition" )
|
-- MenuStatusShow = MENU_COALITION_COMMAND:New( coalition.side.RED, "Show Status", MenuStatus, ShowStatus, "Status of planes is ok!", "Message to Red Coalition" )
|
||||||
@ -555,12 +559,12 @@ do -- MENU_COALITION
|
|||||||
--
|
--
|
||||||
-- local MenuAdd = MENU_COALITION_COMMAND:New( coalition.side.RED, "Add Status Menu", MenuCoalitionRed, AddStatusMenu )
|
-- local MenuAdd = MENU_COALITION_COMMAND:New( coalition.side.RED, "Add Status Menu", MenuCoalitionRed, AddStatusMenu )
|
||||||
-- local MenuRemove = MENU_COALITION_COMMAND:New( coalition.side.RED, "Remove Status Menu", MenuCoalitionRed, RemoveStatusMenu )
|
-- local MenuRemove = MENU_COALITION_COMMAND:New( coalition.side.RED, "Remove Status Menu", MenuCoalitionRed, RemoveStatusMenu )
|
||||||
--
|
--
|
||||||
-- @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.
|
||||||
-- @param #MENU_COALITION self
|
-- @param #MENU_COALITION self
|
||||||
-- @param DCS#coalition.side Coalition The coalition owning the menu.
|
-- @param DCS#coalition.side Coalition The coalition owning the menu.
|
||||||
@ -570,15 +574,15 @@ do -- MENU_COALITION
|
|||||||
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 )
|
||||||
|
|
||||||
self.Coalition = Coalition
|
self.Coalition = Coalition
|
||||||
|
|
||||||
self.MenuPath = missionCommands.addSubMenuForCoalition( Coalition, MenuText, self.MenuParentPath )
|
self.MenuPath = missionCommands.addSubMenuForCoalition( Coalition, MenuText, self.MenuParentPath )
|
||||||
self:SetParentMenu( self.MenuText, self )
|
self:SetParentMenu( self.MenuText, self )
|
||||||
return self
|
return self
|
||||||
@ -594,27 +598,27 @@ do -- MENU_COALITION
|
|||||||
end
|
end
|
||||||
return self
|
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!
|
||||||
-- @param #MENU_COALITION self
|
-- @param #MENU_COALITION self
|
||||||
-- @return #MENU_COALITION
|
-- @return #MENU_COALITION
|
||||||
function MENU_COALITION:RemoveSubMenus()
|
function MENU_COALITION:RemoveSubMenus()
|
||||||
|
|
||||||
for MenuID, Menu in pairs( self.Menus or {} ) do
|
for MenuID, Menu in pairs( self.Menus or {} ) do
|
||||||
Menu:Remove()
|
Menu:Remove()
|
||||||
end
|
end
|
||||||
|
|
||||||
self.Menus = nil
|
self.Menus = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Removes the main menu and the sub menus recursively of this MENU_COALITION.
|
--- Removes the main menu and the sub menus recursively of this MENU_COALITION.
|
||||||
-- @param #MENU_COALITION self
|
-- @param #MENU_COALITION self
|
||||||
-- @return #nil
|
-- @return #nil
|
||||||
function MENU_COALITION:Remove( MenuStamp, MenuTag )
|
function MENU_COALITION:Remove( MenuStamp, MenuTag )
|
||||||
|
|
||||||
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
|
||||||
@ -631,17 +635,17 @@ do -- MENU_COALITION
|
|||||||
else
|
else
|
||||||
BASE:E( { "Cannot Remove MENU_COALITION", Path = Path, ParentMenu = self.ParentMenu, MenuText = self.MenuText, Coalition = self.Coalition } )
|
BASE:E( { "Cannot Remove MENU_COALITION", Path = Path, ParentMenu = self.ParentMenu, MenuText = self.MenuText, Coalition = self.Coalition } )
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
do -- MENU_COALITION_COMMAND
|
do -- MENU_COALITION_COMMAND
|
||||||
|
|
||||||
--- @type MENU_COALITION_COMMAND
|
--- @type MENU_COALITION_COMMAND
|
||||||
-- @extends Core.Menu#MENU_COMMAND_BASE
|
-- @extends Core.Menu#MENU_COMMAND_BASE
|
||||||
|
|
||||||
--- Manages the command menus for coalitions, which allow players to execute functions during mission execution.
|
--- Manages the command menus for coalitions, which allow players to execute functions during mission execution.
|
||||||
--
|
--
|
||||||
-- You can add menus with the @{#MENU_COALITION_COMMAND.New} method, which constructs a MENU_COALITION_COMMAND object and returns you the object reference.
|
-- You can add menus with the @{#MENU_COALITION_COMMAND.New} method, which constructs a MENU_COALITION_COMMAND object and returns you the object reference.
|
||||||
-- Using this object reference, you can then remove ALL the menus and submenus underlying automatically with @{#MENU_COALITION_COMMAND.Remove}.
|
-- Using this object reference, you can then remove ALL the menus and submenus underlying automatically with @{#MENU_COALITION_COMMAND.Remove}.
|
||||||
--
|
--
|
||||||
@ -649,7 +653,7 @@ do -- 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.
|
||||||
-- @param #MENU_COALITION_COMMAND self
|
-- @param #MENU_COALITION_COMMAND self
|
||||||
-- @param DCS#coalition.side Coalition The coalition owning the menu.
|
-- @param DCS#coalition.side Coalition The coalition owning the menu.
|
||||||
@ -659,19 +663,19 @@ do -- MENU_COALITION_COMMAND
|
|||||||
-- @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.
|
-- @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
|
-- @return #MENU_COALITION_COMMAND
|
||||||
function MENU_COALITION_COMMAND:New( Coalition, MenuText, ParentMenu, CommandMenuFunction, ... )
|
function MENU_COALITION_COMMAND:New( Coalition, MenuText, ParentMenu, CommandMenuFunction, ... )
|
||||||
|
|
||||||
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 )
|
||||||
return CoalitionMenu
|
return CoalitionMenu
|
||||||
else
|
else
|
||||||
|
|
||||||
local self = BASE:Inherit( self, MENU_COMMAND_BASE:New( MenuText, ParentMenu, CommandMenuFunction, arg ) )
|
local self = BASE:Inherit( self, MENU_COMMAND_BASE:New( MenuText, ParentMenu, CommandMenuFunction, arg ) )
|
||||||
MENU_INDEX:SetCoalitionMenu( Coalition, Path, self )
|
MENU_INDEX:SetCoalitionMenu( Coalition, Path, self )
|
||||||
|
|
||||||
self.Coalition = Coalition
|
self.Coalition = Coalition
|
||||||
self.MenuPath = missionCommands.addCommandForCoalition( self.Coalition, MenuText, self.MenuParentPath, self.MenuCallHandler )
|
self.MenuPath = missionCommands.addCommandForCoalition( self.Coalition, MenuText, self.MenuParentPath, self.MenuCallHandler )
|
||||||
self:SetParentMenu( self.MenuText, self )
|
self:SetParentMenu( self.MenuText, self )
|
||||||
@ -686,18 +690,18 @@ do -- MENU_COALITION_COMMAND
|
|||||||
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
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Removes a radio command item for a coalition
|
--- Removes a radio command item for a coalition
|
||||||
-- @param #MENU_COALITION_COMMAND self
|
-- @param #MENU_COALITION_COMMAND self
|
||||||
-- @return #nil
|
-- @return #nil
|
||||||
function MENU_COALITION_COMMAND:Remove( MenuStamp, MenuTag )
|
function MENU_COALITION_COMMAND:Remove( MenuStamp, MenuTag )
|
||||||
|
|
||||||
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
|
||||||
@ -713,7 +717,7 @@ do -- MENU_COALITION_COMMAND
|
|||||||
else
|
else
|
||||||
BASE:E( { "Cannot Remove MENU_COALITION_COMMAND", Path = Path, ParentMenu = self.ParentMenu, MenuText = self.MenuText, Coalition = self.Coalition } )
|
BASE:E( { "Cannot Remove MENU_COALITION_COMMAND", Path = Path, ParentMenu = self.ParentMenu, MenuText = self.MenuText, Coalition = self.Coalition } )
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -728,20 +732,20 @@ do
|
|||||||
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.
|
||||||
-- 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}.
|
||||||
--
|
--
|
||||||
-- @usage
|
-- @usage
|
||||||
-- -- This demo creates a menu structure for the two groups of planes.
|
-- -- This demo creates a menu structure for the two groups of planes.
|
||||||
-- -- Each group will receive a different menu structure.
|
-- -- Each group will receive a different menu structure.
|
||||||
-- -- To test, join the planes, then look at the other radio menus (Option F10).
|
-- -- To test, join the planes, then look at the other radio menus (Option F10).
|
||||||
-- -- Then switch planes and check if the menu is still there.
|
-- -- Then switch planes and check if the menu is still there.
|
||||||
-- -- And play with the Add and Remove menu options.
|
-- -- And play with the Add and Remove menu options.
|
||||||
--
|
--
|
||||||
-- -- Note that in multi player, this will only work after the DCS groups bug is solved.
|
-- -- Note that in multi player, this will only work after the DCS groups bug is solved.
|
||||||
--
|
--
|
||||||
-- local function ShowStatus( PlaneGroup, StatusText, Coalition )
|
-- local function ShowStatus( PlaneGroup, StatusText, Coalition )
|
||||||
@ -789,7 +793,7 @@ do
|
|||||||
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.
|
||||||
-- @param #MENU_GROUP self
|
-- @param #MENU_GROUP self
|
||||||
-- @param Wrapper.Group#GROUP Group The Group owning the menu.
|
-- @param Wrapper.Group#GROUP Group The Group owning the menu.
|
||||||
@ -797,7 +801,7 @@ do
|
|||||||
-- @param #table ParentMenu The parent menu.
|
-- @param #table ParentMenu The parent menu.
|
||||||
-- @return #MENU_GROUP self
|
-- @return #MENU_GROUP self
|
||||||
function MENU_GROUP:New( Group, MenuText, ParentMenu )
|
function MENU_GROUP:New( Group, MenuText, ParentMenu )
|
||||||
|
|
||||||
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 )
|
||||||
@ -809,13 +813,13 @@ do
|
|||||||
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 )
|
||||||
return self
|
return self
|
||||||
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
|
||||||
@ -823,15 +827,15 @@ do
|
|||||||
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 )
|
||||||
|
|
||||||
for MenuText, Menu in pairs( self.Menus or {} ) do
|
for MenuText, Menu in pairs( self.Menus or {} ) do
|
||||||
Menu:Refresh()
|
Menu:Refresh()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Refreshes a new radio item for a group and submenus, ordering by (numerical) MenuTag
|
--- Refreshes a new radio item for a group and submenus, ordering by (numerical) MenuTag
|
||||||
-- @param #MENU_GROUP self
|
-- @param #MENU_GROUP self
|
||||||
-- @return #MENU_GROUP
|
-- @return #MENU_GROUP
|
||||||
@ -840,7 +844,7 @@ do
|
|||||||
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 )
|
||||||
|
|
||||||
local MenuTable = {}
|
local MenuTable = {}
|
||||||
for MenuText, Menu in pairs( self.Menus or {} ) do
|
for MenuText, Menu in pairs( self.Menus or {} ) do
|
||||||
local tag = Menu.MenuTag or math.random(1,10000)
|
local tag = Menu.MenuTag or math.random(1,10000)
|
||||||
@ -849,12 +853,12 @@ do
|
|||||||
table.sort(MenuTable, function (k1, k2) return k1.tag < k2.tag end )
|
table.sort(MenuTable, function (k1, k2) return k1.tag < k2.tag end )
|
||||||
for _, Menu in pairs( MenuTable ) do
|
for _, Menu in pairs( MenuTable ) do
|
||||||
Menu.Entry:Refresh()
|
Menu.Entry:Refresh()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Removes the sub menus recursively of this MENU_GROUP.
|
--- Removes the sub menus recursively of this MENU_GROUP.
|
||||||
-- @param #MENU_GROUP self
|
-- @param #MENU_GROUP self
|
||||||
-- @param MenuStamp
|
-- @param MenuStamp
|
||||||
@ -864,9 +868,9 @@ do
|
|||||||
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
|
||||||
|
|
||||||
self.Menus = nil
|
self.Menus = nil
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Removes the main menu and sub menus recursively of this MENU_GROUP.
|
--- Removes the main menu and sub menus recursively of this MENU_GROUP.
|
||||||
@ -877,7 +881,7 @@ do
|
|||||||
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
|
||||||
@ -895,15 +899,15 @@ do
|
|||||||
BASE:E( { "Cannot Remove MENU_GROUP", Path = Path, ParentMenu = self.ParentMenu, MenuText = self.MenuText, Group = self.Group } )
|
BASE:E( { "Cannot Remove MENU_GROUP", Path = Path, ParentMenu = self.ParentMenu, MenuText = self.MenuText, Group = self.Group } )
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
--- The @{Core.Menu#MENU_GROUP_COMMAND} class manages the command menus for coalitions, which allow players to execute functions during mission execution.
|
--- The @{Core.Menu#MENU_GROUP_COMMAND} class manages the command menus for coalitions, which allow players to execute functions during mission execution.
|
||||||
-- You can add menus with the @{#MENU_GROUP_COMMAND.New} method, which constructs a MENU_GROUP_COMMAND object and returns you the object reference.
|
-- You can add menus with the @{#MENU_GROUP_COMMAND.New} method, which constructs a MENU_GROUP_COMMAND 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_COMMAND.Remove}.
|
-- Using this object reference, you can then remove ALL the menus and submenus underlying automatically with @{#MENU_GROUP_COMMAND.Remove}.
|
||||||
--
|
--
|
||||||
@ -911,7 +915,7 @@ do
|
|||||||
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
|
||||||
-- @param #MENU_GROUP_COMMAND self
|
-- @param #MENU_GROUP_COMMAND self
|
||||||
-- @param Wrapper.Group#GROUP Group The Group owning the menu.
|
-- @param Wrapper.Group#GROUP Group The Group owning the menu.
|
||||||
@ -923,7 +927,7 @@ do
|
|||||||
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 )
|
||||||
@ -931,12 +935,12 @@ do
|
|||||||
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
|
||||||
self.GroupID = Group:GetID()
|
self.GroupID = Group:GetID()
|
||||||
|
|
||||||
self.MenuPath = missionCommands.addCommandForGroup( self.GroupID, MenuText, self.MenuParentPath, self.MenuCallHandler )
|
self.MenuPath = missionCommands.addCommandForGroup( self.GroupID, MenuText, self.MenuParentPath, self.MenuCallHandler )
|
||||||
|
|
||||||
self:SetParentMenu( self.MenuText, self )
|
self:SetParentMenu( self.MenuText, self )
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@ -949,10 +953,10 @@ 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
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Removes a menu structure for a group.
|
--- Removes a menu structure for a group.
|
||||||
-- @param #MENU_GROUP_COMMAND self
|
-- @param #MENU_GROUP_COMMAND self
|
||||||
-- @param MenuStamp
|
-- @param MenuStamp
|
||||||
@ -961,7 +965,7 @@ do
|
|||||||
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
|
||||||
@ -977,7 +981,7 @@ do
|
|||||||
else
|
else
|
||||||
BASE:E( { "Cannot Remove MENU_GROUP_COMMAND", Path = Path, ParentMenu = self.ParentMenu, MenuText = self.MenuText, Group = self.Group } )
|
BASE:E( { "Cannot Remove MENU_GROUP_COMMAND", Path = Path, ParentMenu = self.ParentMenu, MenuText = self.MenuText, Group = self.Group } )
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -985,20 +989,20 @@ end
|
|||||||
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}.
|
||||||
-- The creation of the menu item is delayed however, and must be created using the @{#MENU_GROUP.Set} method.
|
-- The creation of the menu item is delayed however, and must be created using the @{#MENU_GROUP.Set} method.
|
||||||
-- This method is most of the time called after the "old" menu items have been removed from the sub menu.
|
-- This method is most of the time called after the "old" menu items have been removed from the sub menu.
|
||||||
--
|
--
|
||||||
--
|
--
|
||||||
-- @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.
|
||||||
-- @param #MENU_GROUP_DELAYED self
|
-- @param #MENU_GROUP_DELAYED self
|
||||||
-- @param Wrapper.Group#GROUP Group The Group owning the menu.
|
-- @param Wrapper.Group#GROUP Group The Group owning the menu.
|
||||||
@ -1006,7 +1010,7 @@ do
|
|||||||
-- @param #table ParentMenu The parent menu.
|
-- @param #table ParentMenu The parent menu.
|
||||||
-- @return #MENU_GROUP_DELAYED self
|
-- @return #MENU_GROUP_DELAYED self
|
||||||
function MENU_GROUP_DELAYED:New( Group, MenuText, ParentMenu )
|
function MENU_GROUP_DELAYED:New( Group, MenuText, ParentMenu )
|
||||||
|
|
||||||
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 )
|
||||||
@ -1023,11 +1027,11 @@ do
|
|||||||
self.MenuPath = {}
|
self.MenuPath = {}
|
||||||
end
|
end
|
||||||
table.insert( self.MenuPath, self.MenuText )
|
table.insert( self.MenuPath, self.MenuText )
|
||||||
|
|
||||||
self:SetParentMenu( self.MenuText, self )
|
self:SetParentMenu( self.MenuText, self )
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Refreshes a new radio item for a group and submenus
|
--- Refreshes a new radio item for a group and submenus
|
||||||
@ -1039,7 +1043,7 @@ do
|
|||||||
missionCommands.addSubMenuForGroup( self.GroupID, self.MenuText, self.MenuParentPath )
|
missionCommands.addSubMenuForGroup( self.GroupID, self.MenuText, self.MenuParentPath )
|
||||||
self.MenuSet = true
|
self.MenuSet = true
|
||||||
end
|
end
|
||||||
|
|
||||||
for MenuText, Menu in pairs( self.Menus or {} ) do
|
for MenuText, Menu in pairs( self.Menus or {} ) do
|
||||||
Menu:Set()
|
Menu:Set()
|
||||||
end
|
end
|
||||||
@ -1053,15 +1057,15 @@ do
|
|||||||
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 )
|
||||||
|
|
||||||
for MenuText, Menu in pairs( self.Menus or {} ) do
|
for MenuText, Menu in pairs( self.Menus or {} ) do
|
||||||
Menu:Refresh()
|
Menu:Refresh()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Removes the sub menus recursively of this MENU_GROUP_DELAYED.
|
--- Removes the sub menus recursively of this MENU_GROUP_DELAYED.
|
||||||
-- @param #MENU_GROUP_DELAYED self
|
-- @param #MENU_GROUP_DELAYED self
|
||||||
-- @param MenuStamp
|
-- @param MenuStamp
|
||||||
@ -1071,9 +1075,9 @@ do
|
|||||||
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
|
||||||
|
|
||||||
self.Menus = nil
|
self.Menus = nil
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Removes the main menu and sub menus recursively of this MENU_GROUP.
|
--- Removes the main menu and sub menus recursively of this MENU_GROUP.
|
||||||
@ -1084,7 +1088,7 @@ do
|
|||||||
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
|
||||||
@ -1102,16 +1106,16 @@ do
|
|||||||
BASE:E( { "Cannot Remove MENU_GROUP_DELAYED", Path = Path, ParentMenu = self.ParentMenu, MenuText = self.MenuText, Group = self.Group } )
|
BASE:E( { "Cannot Remove MENU_GROUP_DELAYED", Path = Path, ParentMenu = self.ParentMenu, MenuText = self.MenuText, Group = self.Group } )
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
--- Manages the command menus for coalitions, which allow players to execute functions during mission execution.
|
--- Manages the command menus for coalitions, which allow players to execute functions during mission execution.
|
||||||
--
|
--
|
||||||
-- You can add menus with the @{#MENU_GROUP_COMMAND_DELAYED.New} method, which constructs a MENU_GROUP_COMMAND_DELAYED object and returns you the object reference.
|
-- You can add menus with the @{#MENU_GROUP_COMMAND_DELAYED.New} method, which constructs a MENU_GROUP_COMMAND_DELAYED 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_COMMAND_DELAYED.Remove}.
|
-- Using this object reference, you can then remove ALL the menus and submenus underlying automatically with @{#MENU_GROUP_COMMAND_DELAYED.Remove}.
|
||||||
--
|
--
|
||||||
@ -1119,7 +1123,7 @@ do
|
|||||||
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
|
||||||
-- @param #MENU_GROUP_COMMAND_DELAYED self
|
-- @param #MENU_GROUP_COMMAND_DELAYED self
|
||||||
-- @param Wrapper.Group#GROUP Group The Group owning the menu.
|
-- @param Wrapper.Group#GROUP Group The Group owning the menu.
|
||||||
@ -1131,7 +1135,7 @@ do
|
|||||||
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 )
|
||||||
@ -1139,17 +1143,17 @@ do
|
|||||||
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
|
||||||
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
|
||||||
self.MenuPath = {}
|
self.MenuPath = {}
|
||||||
end
|
end
|
||||||
table.insert( self.MenuPath, self.MenuText )
|
table.insert( self.MenuPath, self.MenuText )
|
||||||
|
|
||||||
self:SetParentMenu( self.MenuText, self )
|
self:SetParentMenu( self.MenuText, self )
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@ -1165,7 +1169,7 @@ do
|
|||||||
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
|
||||||
@ -1174,10 +1178,10 @@ 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
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Removes a menu structure for a group.
|
--- Removes a menu structure for a group.
|
||||||
-- @param #MENU_GROUP_COMMAND_DELAYED self
|
-- @param #MENU_GROUP_COMMAND_DELAYED self
|
||||||
-- @param MenuStamp
|
-- @param MenuStamp
|
||||||
@ -1186,7 +1190,7 @@ do
|
|||||||
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
|
||||||
@ -1202,7 +1206,7 @@ do
|
|||||||
else
|
else
|
||||||
BASE:E( { "Cannot Remove MENU_GROUP_COMMAND_DELAYED", Path = Path, ParentMenu = self.ParentMenu, MenuText = self.MenuText, Group = self.Group } )
|
BASE:E( { "Cannot Remove MENU_GROUP_COMMAND_DELAYED", Path = Path, ParentMenu = self.ParentMenu, MenuText = self.MenuText, Group = self.Group } )
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user