-
Module Menu
-
-
This module contains the MENU classes.
-
-
-
-
There is a small note... When you see a class like MENUCOMMANDCOALITION with COMMAND in italic, it acutally represents it like this: MENU_COMMAND_COALITION.
-
-
-
-
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 scanerios 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
-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.
-On top, MOOSE implements variable parameter passing for command menus.
-
-
There are basically two different MENU class types that you need to use:
-
-
To manage main menus, the classes begin with MENU_:
-
-
-
-
To manage command menus, which are menus that allow the player to issue functions, the classes begin with MENUCOMMAND:
-
-
-
-
-
-
The above menus classes are derived from 2 main abstract classes defined within the MOOSE framework (so don't use these):
-
-
1) MENU_ BASE abstract base classes (don't use them)
-
The underlying base menu classes are NOT to be used within your missions.
-These are simply abstract base classes defining a couple of fields that are used by the
-derived MENU_ classes to manage menus.
-
-
-
The #MENU_BASE class defines the main MENU class where other MENU classes are derived from.
-
-
-
The #MENUCOMMANDBASE class defines the main MENU class where other MENU COMMAND_ classes are derived from, in order to set commands.
-
-
-
-
The next menus define the MENU classes that you can use within your missions.
-
-
2) MENU MISSION classes
-
The underlying classes manage the menus for a complete mission file.
-
-
-
The Core.Menu#MENU_MISSION class 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.
-Using this object reference, you can then remove ALL the menus and submenus underlying automatically with MENU_MISSION.Remove.
-
-
-
The Core.Menu#MENUMISSIONCOMMAND class manages the command menus for a complete mission, which allow players to execute functions during mission execution.
-You can add menus with the MENUMISSIONCOMMAND.New method, which constructs a MENUMISSIONCOMMAND object and returns you the object reference.
-Using this object reference, you can then remove ALL the menus and submenus underlying automatically with MENUMISSIONCOMMAND.Remove.
-
-
-
-
3) MENU COALITION classes
-
The underlying classes manage the menus for whole coalitions.
-
-
-
The Core.Menu#MENU_COALITION class manages the main menus for coalitions.
-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.
-
-
-
The Core.Menu#MENUCOALITIONCOMMAND class manages the command menus for coalitions, which allow players to execute functions during mission execution.
-You can add menus with the MENUCOALITIONCOMMAND.New method, which constructs a MENUCOALITIONCOMMAND object and returns you the object reference.
-Using this object reference, you can then remove ALL the menus and submenus underlying automatically with MENUCOALITIONCOMMAND.Remove.
-
-
-
-
4) MENU GROUP classes
-
The underlying classes manage the menus for groups. Note that groups can be inactive, alive or can be destroyed.
-
-
-
The Core.Menu#MENU_GROUP class manages the main menus for coalitions.
-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.
-
-
-
The Core.Menu#MENUGROUPCOMMAND class manages the command menus for coalitions, which allow players to execute functions during mission execution.
-You can add menus with the MENUGROUPCOMMAND.New method, which constructs a MENUGROUPCOMMAND object and returns you the object reference.
-Using this object reference, you can then remove ALL the menus and submenus underlying automatically with MENUGROUPCOMMAND.Remove.
-
-
-
-
5) MENU CLIENT classes
-
The underlying classes manage the menus for units with skill level client or player.
-
-
-
The Core.Menu#MENU_CLIENT class manages the main menus for coalitions.
-You can add menus with the MENU_CLIENT.New method, which constructs a MENU_CLIENT object and returns you the object reference.
-Using this object reference, you can then remove ALL the menus and submenus underlying automatically with MENU_CLIENT.Remove.
-
-
-
The Core.Menu#MENUCLIENTCOMMAND class manages the command menus for coalitions, which allow players to execute functions during mission execution.
-You can add menus with the MENUCLIENTCOMMAND.New method, which constructs a MENUCLIENTCOMMAND object and returns you the object reference.
-Using this object reference, you can then remove ALL the menus and submenus underlying automatically with MENUCLIENTCOMMAND.Remove.
-
-
-
-
Contributions: -
-
Authors: FlightControl : Design & Programming
-
-
-
Global(s)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Global(s)
-
--
-
- #MENU_BASE
-
-
--
-
-
-
-
-
-
--
-
- #MENU_CLIENT
-
-
--
-
-
-
-
-
-
--
-
- #MENU_CLIENT_COMMAND
-
-MENU_CLIENT_COMMAND
-
-
--
-
-
-
-
-
-
--
-
- #MENU_COALITION
-
-
--
-
-
-
-
-
-
--
-
- #MENU_COALITION_COMMAND
-
-MENU_COALITION_COMMAND
-
-
--
-
-
-
-
-
-
--
-
- #MENU_COMMAND_BASE
-
-MENU_COMMAND_BASE
-
-
--
-
-
-
-
-
-
--
-
- #MENU_GROUP
-
-
--
-
-
-
-
-
-
--
-
- #MENU_GROUP_COMMAND
-
-MENU_GROUP_COMMAND
-
-
--
-
-
-
-
-
-
--
-
- #MENU_MISSION
-
-
--
-
-
-
-
-
-
--
-
- #MENU_MISSION_COMMAND
-
-MENU_MISSION_COMMAND
-
-
--
-
-
-
-
-
-
-
-
-
-
The MENU_BASE class
-
-
Field(s)
-
--
-
- #string
-
-
--
-
-
-
-
-
-
--
-
-
-
--
-
-
-
-
-
-
--
-
-
-
--
-
-
-
-
-
-
--
-
- #string
-
-
--
-
-
-
-
-
-
--
-
-
-
--
-
-
Consructor
-
- Parameters
-
- -
-
-
MenuText :
-
-
- -
-
-
ParentMenu :
-
-
-
-
-
-
-
-
-
MENU_COALITION constructor.
-
-
-
Creates a new radio command item for a coalition, which can invoke a function with parameters.
-
-
Usage:
-
-- This demo creates a menu structure for the two clients of planes.
- -- Each client will receive a different menu structure.
- -- 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.
- -- And play with the Add and Remove menu options.
-
- -- Note that in multi player, this will only work after the DCS clients bug is solved.
-
- local function ShowStatus( PlaneClient, StatusText, Coalition )
-
- MESSAGE:New( Coalition, 15 ):ToRed()
- PlaneClient:Message( StatusText, 15 )
- end
-
- local MenuStatus = {}
-
- local function RemoveStatusMenu( MenuClient )
- local MenuClientName = MenuClient:GetName()
- MenuStatus[MenuClientName]:Remove()
- end
-
- --- @param Wrapper.Client#CLIENT MenuClient
- local function AddStatusMenu( MenuClient )
- local MenuClientName = MenuClient:GetName()
- -- This would create a menu for the red coalition under the MenuCoalitionRed menu object.
- MenuStatus[MenuClientName] = MENU_CLIENT:New( MenuClient, "Status for Planes" )
- MENU_CLIENT_COMMAND:New( MenuClient, "Show Status", MenuStatus[MenuClientName], ShowStatus, MenuClient, "Status of planes is ok!", "Message to Red Coalition" )
- end
-
- SCHEDULER:New( nil,
- function()
- local PlaneClient = CLIENT:FindByName( "Plane 1" )
- if PlaneClient and PlaneClient:IsAlive() then
- local MenuManage = MENU_CLIENT:New( PlaneClient, "Manage Menus" )
- MENU_CLIENT_COMMAND:New( PlaneClient, "Add Status Menu Plane 1", MenuManage, AddStatusMenu, PlaneClient )
- MENU_CLIENT_COMMAND:New( PlaneClient, "Remove Status Menu Plane 1", MenuManage, RemoveStatusMenu, PlaneClient )
- end
- end, {}, 10, 10 )
-
- SCHEDULER:New( nil,
- function()
- local PlaneClient = CLIENT:FindByName( "Plane 2" )
- if PlaneClient and PlaneClient:IsAlive() then
- local MenuManage = MENU_CLIENT:New( PlaneClient, "Manage Menus" )
- MENU_CLIENT_COMMAND:New( PlaneClient, "Add Status Menu Plane 2", MenuManage, AddStatusMenu, PlaneClient )
- MENU_CLIENT_COMMAND:New( PlaneClient, "Remove Status Menu Plane 2", MenuManage, RemoveStatusMenu, PlaneClient )
- end
- end, {}, 10, 10 )
-
-
Field(s)
-
--
-
- #string
-
-
--
-
-
-
-
-
-
--
-
-
-
--
-
-
MENU_CLIENT constructor.
-
-
-Creates a new radio menu item for a client.
-
- Parameters
-
- -
-
-
Wrapper.Client#CLIENT Client :
-The Client owning the menu.
-
-
- -
-
-
#string MenuText :
-The text for the menu.
-
-
- -
-
-
#table ParentMenu :
-The parent menu.
-
-
-
- Return value
-
-#MENU_CLIENT:
-self
-
-
-
-
--
-
-
-
--
-
-
Removes the sub menus recursively of this MENU_CLIENT.
-
- Return value
-
-#nil:
-
-
-
-
-
--
-
-
-
--
-
-
Removes the sub menus recursively of this #MENU_CLIENT.
-
- Return value
-
-#MENU_CLIENT:
-self
-
-
-
-
-
-
-
The MENUCLIENTCOMMAND class
-
-
Field(s)
-
--
-
- #string
-
-MENU_CLIENT_COMMAND.ClassName
-
-
--
-
-
-
-
-
-
--
-
-
-MENU_CLIENT_COMMAND:New(Client, MenuText, ParentMenu, CommandMenuFunction, CommandMenuArgument, MenuClient, ...)
-
-
--
-
-
MENUCLIENTCOMMAND constructor.
-
-
-Creates a new radio command item for a client, which can invoke a function with parameters.
-
- Parameters
-
- -
-
-
Wrapper.Client#CLIENT Client :
-The Client owning the menu.
-
-
- -
-
-
#string MenuText :
-The text for the menu.
-
-
- -
-
-
#MENU_BASE ParentMenu :
-The parent menu.
-
-
- -
-
-
CommandMenuFunction :
-A function that is called when the menu key is pressed.
-
-
- -
-
-
CommandMenuArgument :
-An argument for the function.
-
-
- -
-
-
MenuClient :
-
-
- -
-
-
... :
-
-
-
- Return value
-
-Menu#MENUCLIENTCOMMAND:
-self
-
-
-
-
--
-
-
-MENU_CLIENT_COMMAND:Remove()
-
-
--
-
-
Removes a menu structure for a client.
-
- Return value
-
-#nil:
-
-
-
-
-
-
-
-
The MENU_COALITION class
-
-
Usage:
-
-- This demo creates a menu structure for the planes within the red coalition.
- -- 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.
-
- local Plane1 = CLIENT:FindByName( "Plane 1" )
- local Plane2 = CLIENT:FindByName( "Plane 2" )
-
-
- -- This would create a menu for the red coalition under the main DCS "Others" menu.
- local MenuCoalitionRed = MENU_COALITION:New( coalition.side.RED, "Manage Menus" )
-
-
- local function ShowStatus( StatusText, Coalition )
-
- MESSAGE:New( Coalition, 15 ):ToRed()
- Plane1:Message( StatusText, 15 )
- Plane2:Message( StatusText, 15 )
- end
-
- local MenuStatus -- Menu#MENU_COALITION
- local MenuStatusShow -- Menu#MENU_COALITION_COMMAND
-
- local function RemoveStatusMenu()
- MenuStatus:Remove()
- end
-
- local function AddStatusMenu()
-
- -- This would create a menu for the red coalition under the MenuCoalitionRed menu object.
- 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" )
- end
-
- 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 )
-
-
Field(s)
-
--
-
- #string
-
-
--
-
-
-
-
-
-
--
-
-
-
--
-
-
MENU_COALITION constructor.
-
-
-Creates a new MENU_COALITION object and creates the menu for a complete coalition.
-
- Parameters
-
- -
-
-
Dcs.DCSCoalition#coalition.side Coalition :
-The coalition owning the menu.
-
-
- -
-
-
#string MenuText :
-The text for the menu.
-
-
- -
-
-
#table ParentMenu :
-The parent menu. This parameter can be ignored if you want the menu to be located at the perent menu of DCS world (under F10 other).
-
-
-
- Return value
-
-#MENU_COALITION:
-self
-
-
-
-
--
-
-
-
--
-
-
Removes the main menu and the sub menus recursively of this MENU_COALITION.
-
- Return value
-
-#nil:
-
-
-
-
-
--
-
-
-
--
-
-
Removes the sub menus recursively of this MENU_COALITION.
-
-
-Note that the main menu is kept!
-
- Return value
-
-#MENU_COALITION:
-self
-
-
-
-
-
-
-
The MENUCOALITIONCOMMAND class
-
-
Field(s)
-
--
-
- #string
-
-MENU_COALITION_COMMAND.ClassName
-
-
--
-
-
-
-
-
-
--
-
-
-MENU_COALITION_COMMAND:New(Coalition, MenuText, ParentMenu, CommandMenuFunction, CommandMenuArgument, ...)
-
-
--
-
-
MENU_COALITION constructor.
-
-
-Creates a new radio command item for a coalition, which can invoke a function with parameters.
-
- Parameters
-
- -
-
-
Dcs.DCSCoalition#coalition.side Coalition :
-The coalition owning the menu.
-
-
- -
-
-
#string MenuText :
-The text for the menu.
-
-
- -
-
-
Menu#MENU_COALITION ParentMenu :
-The parent menu.
-
-
- -
-
-
CommandMenuFunction :
-A function that is called when the menu key is pressed.
-
-
- -
-
-
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 value
-
-#MENUCOALITIONCOMMAND:
-self
-
-
-
-
--
-
-
-MENU_COALITION_COMMAND:Remove()
-
-
--
-
-
Removes a radio command item for a coalition
-
- Return value
-
-#nil:
-
-
-
-
-
-
-
-
The MENUCOMMANDBASE class
-
-
Field(s)
-
--
-
- #string
-
-MENU_COMMAND_BASE.ClassName
-
-
--
-
-
-
-
-
-
--
-
-
-MENU_COMMAND_BASE.CommandMenuArgument
-
-
--
-
-
-
-
-
-
--
-
-
-MENU_COMMAND_BASE.CommandMenuFunction
-
-
--
-
-
-
-
-
-
--
-
- #function
-
-MENU_COMMAND_BASE.MenuCallHandler
-
-
--
-
-
-
-
-
-
--
-
-
-MENU_COMMAND_BASE:New(MenuText, ParentMenu, CommandMenuFunction, CommandMenuArguments)
-
-
--
-
-
Constructor
-
- Parameters
-
- -
-
-
MenuText :
-
-
- -
-
-
ParentMenu :
-
-
- -
-
-
CommandMenuFunction :
-
-
- -
-
-
CommandMenuArguments :
-
-
-
-
-
-
-
-
-
The MENU_GROUP class
-
-
Usage:
-
-- This demo creates a menu structure for the two groups of planes.
- -- Each group will receive a different menu structure.
- -- 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.
- -- 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.
-
- local function ShowStatus( PlaneGroup, StatusText, Coalition )
-
- MESSAGE:New( Coalition, 15 ):ToRed()
- PlaneGroup:Message( StatusText, 15 )
- end
-
- local MenuStatus = {}
-
- local function RemoveStatusMenu( MenuGroup )
- local MenuGroupName = MenuGroup:GetName()
- MenuStatus[MenuGroupName]:Remove()
- end
-
- --- @param Wrapper.Group#GROUP MenuGroup
- local function AddStatusMenu( MenuGroup )
- local MenuGroupName = MenuGroup:GetName()
- -- This would create a menu for the red coalition under the MenuCoalitionRed menu object.
- MenuStatus[MenuGroupName] = MENU_GROUP:New( MenuGroup, "Status for Planes" )
- MENU_GROUP_COMMAND:New( MenuGroup, "Show Status", MenuStatus[MenuGroupName], ShowStatus, MenuGroup, "Status of planes is ok!", "Message to Red Coalition" )
- end
-
- SCHEDULER:New( nil,
- function()
- local PlaneGroup = GROUP:FindByName( "Plane 1" )
- if PlaneGroup and PlaneGroup:IsAlive() then
- local MenuManage = MENU_GROUP:New( PlaneGroup, "Manage Menus" )
- MENU_GROUP_COMMAND:New( PlaneGroup, "Add Status Menu Plane 1", MenuManage, AddStatusMenu, PlaneGroup )
- MENU_GROUP_COMMAND:New( PlaneGroup, "Remove Status Menu Plane 1", MenuManage, RemoveStatusMenu, PlaneGroup )
- end
- end, {}, 10, 10 )
-
- SCHEDULER:New( nil,
- function()
- local PlaneGroup = GROUP:FindByName( "Plane 2" )
- if PlaneGroup and PlaneGroup:IsAlive() then
- local MenuManage = MENU_GROUP:New( PlaneGroup, "Manage Menus" )
- MENU_GROUP_COMMAND:New( PlaneGroup, "Add Status Menu Plane 2", MenuManage, AddStatusMenu, PlaneGroup )
- MENU_GROUP_COMMAND:New( PlaneGroup, "Remove Status Menu Plane 2", MenuManage, RemoveStatusMenu, PlaneGroup )
- end
- end, {}, 10, 10 )
-
-
-
Field(s)
-
--
-
- #string
-
-
--
-
-
-
-
-
-
--
-
-
-
-
--
-
-
-
-
-
-
--
-
-
-
-
--
-
-
-
-
-
-
--
-
-
-
-
--
-
-
-
-
-
-
--
-
-
-
-
--
-
-
-
-
-
-
--
-
-
-
-
--
-
-
-
-
-
-
--
-
-
-
--
-
-
MENU_GROUP constructor.
-
-
-Creates a new radio menu item for a group.
-
- Parameters
-
- -
-
-
Wrapper.Group#GROUP MenuGroup :
-The Group owning the menu.
-
-
- -
-
-
#string MenuText :
-The text for the menu.
-
-
- -
-
-
#table ParentMenu :
-The parent menu.
-
-
-
- Return value
-
-#MENU_GROUP:
-self
-
-
-
-
--
-
-
-
-
--
-
-
-
-
-
-
--
-
-
-
-
--
-
-
-
-
-
-
--
-
-
-
--
-
-
Removes the main menu and sub menus recursively of this MENU_GROUP.
-
- Return value
-
-#nil:
-
-
-
-
-
--
-
-
-
--
-
-
Removes the sub menus recursively of this MENU_GROUP.
-
- Return value
-
-#MENU_GROUP:
-self
-
-
-
-
-
-
-
The MENUGROUPCOMMAND class
-
-
Field(s)
-
--
-
- #string
-
-MENU_GROUP_COMMAND.ClassName
-
-
--
-
-
-
-
-
-
--
-
-
-
-MENU_GROUP_COMMAND.MenuGroup
-
-
--
-
-
-
-
-
-
--
-
-
-
-MENU_GROUP_COMMAND.MenuGroupID
-
-
--
-
-
-
-
-
-
--
-
-
-
-MENU_GROUP_COMMAND.MenuPath
-
-
--
-
-
-
-
-
-
--
-
-
-
-MENU_GROUP_COMMAND.MenuText
-
-
--
-
-
-
-
-
-
--
-
-
-MENU_GROUP_COMMAND:New(MenuGroup, MenuText, ParentMenu, CommandMenuFunction, CommandMenuArgument, ...)
-
-
--
-
-
Creates a new radio command item for a group
-
- Parameters
-
- -
-
-
Wrapper.Group#GROUP MenuGroup :
-The Group owning the menu.
-
-
- -
-
-
MenuText :
-The text for the menu.
-
-
- -
-
-
ParentMenu :
-The parent menu.
-
-
- -
-
-
CommandMenuFunction :
-A function that is called when the menu key is pressed.
-
-
- -
-
-
CommandMenuArgument :
-An argument for the function.
-
-
- -
-
-
... :
-
-
-
- Return value
-
-Menu#MENUGROUPCOMMAND:
-self
-
-
-
-
--
-
-
-
-MENU_GROUP_COMMAND.ParentMenu
-
-
--
-
-
-
-
-
-
--
-
-
-
-MENU_GROUP_COMMAND.Path
-
-
--
-
-
-
-
-
-
--
-
-
-MENU_GROUP_COMMAND:Remove()
-
-
--
-
-
Removes a menu structure for a group.
-
- Return value
-
-#nil:
-
-
-
-
-
-
-
-
The MENU_MISSION class
-
-
Field(s)
-
--
-
- #string
-
-
--
-
-
-
-
-
-
--
-
-
-
--
-
-
MENU_MISSION constructor.
-
-
-Creates a new MENU_MISSION object and creates the menu for a complete mission file.
-
- Parameters
-
- Return value
-
-#MENU_MISSION:
-self
-
-
-
-
--
-
-
-
--
-
-
Removes the main menu and the sub menus recursively of this MENU_MISSION.
-
- Return value
-
-#nil:
-
-
-
-
-
--
-
-
-
--
-
-
Removes the sub menus recursively of this MENU_MISSION.
-
-
-Note that the main menu is kept!
-
- Return value
-
-#MENU_MISSION:
-self
-
-
-
-
-
-
-
The MENUMISSIONCOMMAND class
-
-
Field(s)
-
--
-
- #string
-
-MENU_MISSION_COMMAND.ClassName
-
-
--
-
-
-
-
-
-
--
-
-
-MENU_MISSION_COMMAND:New(MenuText, ParentMenu, CommandMenuFunction, CommandMenuArgument, ...)
-
-
--
-
-
MENU_MISSION constructor.
-
-
-Creates a new radio command item for a complete mission file, which can invoke a function with parameters.
-
- Parameters
-
- -
-
-
#string MenuText :
-The text for the menu.
-
-
- -
-
-
Menu#MENU_MISSION ParentMenu :
-The parent menu.
-
-
- -
-
-
CommandMenuFunction :
-A function that is called when the menu key is pressed.
-
-
- -
-
-
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 value
-
-#MENUMISSIONCOMMAND:
-self
-
-
-
-
--
-
-
-MENU_MISSION_COMMAND:Remove()
-
-
--
-
-
Removes a radio command item for a coalition
-
- Return value
-
-#nil:
-
-
-
-
-
-