Skip to content
This repository has been archived by the owner on Nov 27, 2018. It is now read-only.

QuickMenu

James Wilkinson edited this page Aug 11, 2017 · 2 revisions

An easy and quick way to display simplified menus and dialogs to the player. More advanced menus should use the official dialog implementation provided by the game.

QuickMenu:new( title, message, options, show_immediately )

Creates a QuickMenu using the provided title, message, and options and returns it as a class variable.
title The display title of the menu.
message The message to be displayed in the menu. This can be a multiline string.
options An array of options containing data to use for the options of the menu. Specifying a nil value or an empty array will create a default "OK" button.
show_immediately If this QuickMenu should pop-up immediately without requiring the menu to be stored and have show expressly called on it.
returns A QuickMenu object.

options: text The text to display on this button.
options: callback The callback to run if this button is pressed by the user.
options: is_cancel_button If this button should do nothing other than close the menu.

local menu_title = managers.localization:text("base_mod_updates_show_multiple_update_available")
local menu_message = managers.localization:text("base_mod_updates_show_multiple_update_available_message")
local menu_options = {
	[1] = {
		text = managers.localization:text("base_mod_updates_open_update_manager"),
		callback = LuaModUpdates.OpenUpdateManagerNode,
	},
	[2] = {
		text = managers.localization:text("base_mod_updates_update_later"),
		is_cancel_button = true,
	},
}
local menu = QuickMenu:new( menu_title, menu_message, menu_options )
menu:Show()

QuickMenu:show()

Can also be called with QuickMenu:Show()
Displays the specified QuickMenu to the user.

local menu = QuickMenu:new( "My Title", "A test message.", {} )
menu:Show()

QuickMenu:hide()

Can also be called with QuickMenu:Hide()
Hides the specified QuickMenu without removing it, so that it can be shown to the user again.

local menu = QuickMenu:new( "My Title", "A test message.", {}, true )
menu:Hide()