MOOSE/Menu.lua
svenvandevelde 10341b7045 First Commit
2015-10-25 10:40:52 +01:00

108 lines
2.4 KiB
Lua

--- Encapsulation of DCS World Menu system in a set of MENU classes.
-- @classmod MENU
Include.File( "Routines" )
Include.File( "Base" )
MENU = {
ClassName = "MENU",
MenuPath = nil,
MenuText = "",
MenuParentPath = nil
}
---
function MENU:New( MenuText, MenuParentPath )
-- Arrange meta tables
local Child = BASE:Inherit( self, BASE:New() )
Child.MenuPath = nil
Child.MenuText = MenuText
Child.MenuParentPath = MenuParentPath
return Child
end
COMMANDMENU = {
ClassName = "COMMANDMENU",
CommandMenuFunction = nil,
CommandMenuArgument = nil
}
function COMMANDMENU:New( MenuText, ParentMenu, CommandMenuFunction, CommandMenuArgument )
-- Arrange meta tables
local MenuParentPath = nil
if ParentMenu ~= nil then
MenuParentPath = ParentMenu.MenuPath
end
local Child = BASE:Inherit( self, MENU:New( MenuText, MenuParentPath ) )
Child.MenuPath = missionCommands.addCommand( MenuText, MenuParentPath, CommandMenuFunction, CommandMenuArgument )
Child.CommandMenuFunction = CommandMenuFunction
Child.CommandMenuArgument = CommandMenuArgument
return Child
end
---
SUBMENU = {
ClassName = "SUBMENU"
}
function SUBMENU:New( MenuText, ParentMenu )
-- Arrange meta tables
local MenuParentPath = nil
if ParentMenu ~= nil then
MenuParentPath = ParentMenu.MenuPath
end
local Child = BASE:Inherit( self, MENU:New( MenuText, MenuParentPath ) )
Child.MenuPath = missionCommands.addSubMenu( MenuText, MenuParentPath )
return Child
end
MENU_SUB_GROUP = {
ClassName = "MENU_SUB_GROUP"
}
function MENU_SUB_GROUP:New( GroupID, MenuText, ParentMenu )
-- Arrange meta tables
local MenuParentPath = nil
if ParentMenu ~= nil then
MenuParentPath = ParentMenu.MenuPath
end
local self = BASE:Inherit( self, MENU:New( MenuText, MenuParentPath ) )
self.MenuPath = missionCommands.addSubMenuForGroup( GroupID, MenuText, MenuParentPath )
return self
end
MENU_COMMAND_GROUP = {
ClassName = "MENU_COMMAND_GROUP"
}
function MENU_COMMAND_GROUP:New( GroupID, MenuText, ParentMenu, CommandMenuFunction, CommandMenuArgument )
-- Arrange meta tables
local MenuParentPath = nil
if ParentMenu ~= nil then
MenuParentPath = ParentMenu.MenuPath
end
local self = BASE:Inherit( self, MENU:New( MenuText, MenuParentPath ) )
self.MenuPath = missionCommands.addCommandForGroup( GroupID, MenuText, MenuParentPath, CommandMenuFunction, CommandMenuArgument )
self.CommandMenuFunction = CommandMenuFunction
self.CommandMenuArgument = CommandMenuArgument
return self
end