Difference between revisions of "UI.SimpleMenu"

From Nomad DB
 
(7 intermediate revisions by 2 users not shown)
Line 3: Line 3:
 
Creates a ''SimpleMenu'', an ingame menu which can be controlled by the arrow keys & numpad keys. The name comes from its (currently) limited functionality and aims to provide very basic, but useful menu functionality.
 
Creates a ''SimpleMenu'', an ingame menu which can be controlled by the arrow keys & numpad keys. The name comes from its (currently) limited functionality and aims to provide very basic, but useful menu functionality.
  
This function has to be called from inside a [[WD2 ScriptHook: Script|Script]].
+
This function has to be called from inside a [[WD2 ScriptHook: Script|Script]]. If you wish to handle Text input from users, use [[UI.SimpleTextInput]].
  
== Syntax ==
+
==Syntax==
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
 
UI.SimpleMenu()
 
UI.SimpleMenu()
 
</syntaxhighlight>
 
</syntaxhighlight>
* '''Returns''' UISimpleMenu instance
 
  
== Methods ==
+
*'''Returns''' UISimpleMenu instance
* [[UISimpleMenu:SetTitle]]
 
* [[UISimpleMenu:GetTitle]]
 
==== Menu State ====
 
* [[UISimpleMenu:Activate]]
 
* [[UISimpleMenu:Deactivate]]
 
* [[UISimpleMenu:Toggle]]
 
* [[UISimpleMenu:IsActive]]
 
==== Entries ====
 
* [[UISimpleMenu:SetEntryEnabled]]
 
* [[UISimpleMenu:IsEntryEnabled]]
 
==== Checkbox ====
 
* [[UISimpleMenu:AddCheckbox]]
 
* [[UISimpleMenu:IsChecked]]
 
* [[UISimpleMenu:SetChecked]]
 
==== Events ====
 
* [[UISimpleMenu:OnUpdate]]
 
  
== Controls ==
+
==Remarks==
 +
The Menu will be invisible until a call to [[UISimpleMenu:Activate]] or [[UISimpleMenu:Toggle]]. You can easily bind a Menu to a Key, see [[UISimpleMenu:Toggle]] for more information.
 +
===Entry and Entry Index===
 +
Every item inside the SimpleMenu is called ''Entry''. There are different types of Entry (Button, Checkbox, Search, etc.). Every entry that is added to a SimpleMenu receives an "index" which can be used to modify it later.
 +
 
 +
===Entry Types===
 +
{| class="wikitable"
 +
|+
 +
!Supported Versions
 +
!Type
 +
!Screenshot
 +
!Description
 +
!Methods
 +
|-
 +
| rowspan="3" |All
 +
|'''Button'''
 +
|[[File:UI-SimpleMenu-Button.png|center|frameless]]
 +
|A button with text. Triggers a callback when Numpad 5 is pressed.
 +
|[[UISimpleMenu:AddButton]]
 +
|-
 +
|'''Checkbox'''
 +
|[[File:UI-SimpleMenu-Checkbox.png|center|frameless]]
 +
|Can be checked and unchecked using Numpad 5. Triggers an element when the checked state changes.
 +
|[[UISimpleMenu:AddCheckbox]]
 +
 
 +
[[UISimpleMenu:IsChecked]]
 +
 
 +
[[UISimpleMenu:SetChecked]]
 +
|-
 +
|'''Search'''
 +
|[[File:UI-SimpleMenu-Search.png|center|frameless]]
 +
|Allows searching through all the elements in the menu. Once text is entered, they are filtered according to a "Fuzzy"-Search (case-insensitive). Entries which do not fit the filter are hidden. Triggers no callback.
 +
|[[UISimpleMenu:AddSearch]]
 +
|-
 +
| rowspan="2" |Legion ScriptHook & Mafia DE ScriptHook
 +
|'''List'''
 +
|[[File:UI-SimpleMenu-List.png|center|frameless]]
 +
|Supports multiple entries which can be selected using Numpad 4/6 and Arrows Left/Right. A callback is triggered every time the selected element changes.
 +
|[[UISimpleMenu:AddList]]
 +
 
 +
[[UISimpleMenu:AddListEntry]]
 +
 
 +
[[UISimpleMenu:GetSelectedListEntry]]
 +
 
 +
[[UISimpleMenu:SelectListEntryByValue]]
 +
 
 +
[[UISimpleMenu:SelectListEntryByIndex]]
 +
|-
 +
|'''Text'''
 +
|[[File:UI-SimpleMenu-Text.png|center|frameless]]
 +
|Text field which supports multi-line text and word-wrapping. Stretches automatically to fit the size of the text. This entry can not be selected and triggers no callback.
 +
|[[UISimpleMenu:AddText]]
 +
|}
 +
 
 +
==Methods==
 +
 
 +
*[[UISimpleMenu:SetTitle]]
 +
*[[UISimpleMenu:GetTitle]]
 +
 
 +
====Menu State====
 +
 
 +
*[[UISimpleMenu:Activate]]
 +
*[[UISimpleMenu:Deactivate]]
 +
*[[UISimpleMenu:Toggle]]
 +
*[[UISimpleMenu:IsActive]]
 +
 
 +
====Entries====
 +
 
 +
*[[UISimpleMenu:SetEntryEnabled]]
 +
*[[UISimpleMenu:IsEntryEnabled]]
 +
*[[UISimpleMenu:SetEntryText]]
 +
*[[UISimpleMenu:AddSearch]]
 +
*[[UISimpleMenu:AddText]]
 +
 
 +
=====Button=====
 +
 
 +
*[[UISimpleMenu:AddButton]]
 +
 
 +
=====Checkbox=====
 +
 
 +
*[[UISimpleMenu:AddCheckbox]]
 +
*[[UISimpleMenu:IsChecked]]
 +
*[[UISimpleMenu:SetChecked]]
 +
 
 +
====List====
 +
 
 +
*[[UISimpleMenu:AddList]]
 +
*[[UISimpleMenu:AddListEntry]]
 +
*[[UISimpleMenu:GetSelectedListEntry]]
 +
*[[UISimpleMenu:SelectListEntryByValue]]
 +
*[[UISimpleMenu:SelectListEntryByIndex]]
 +
 
 +
====Events====
 +
 
 +
*[[UISimpleMenu:OnUpdate]]
 +
*[[UISimpleMenu:OnSelection]]
 +
*[[UISimpleMenu:OnActivate]]
 +
*[[UISimpleMenu:OnDeactivate]]
 +
 
 +
==Controls==
 
{{WD2SH:MenuControls}}
 
{{WD2SH:MenuControls}}
  
== Related Pages ==
+
==Related Pages==
* [[WD2 ScriptHook: UI|UI Overview]]
+
 
* [[WD2 ScriptHook: Trainer]]
+
*[[WD2 ScriptHook: UI|UI Overview]]
 +
*[[WD2 ScriptHook: Trainer]]
  
[[Category:WD2 ScriptHook]] [[Category:WD2 ScriptHook Lua]]
+
[[Category:WD2 ScriptHook]]  
 +
[[Category:WD2 ScriptHook Lua]]

Latest revision as of 19:43, 20 October 2021

SimpleMenu from Trainer

Creates a SimpleMenu, an ingame menu which can be controlled by the arrow keys & numpad keys. The name comes from its (currently) limited functionality and aims to provide very basic, but useful menu functionality.

This function has to be called from inside a Script. If you wish to handle Text input from users, use UI.SimpleTextInput.

Syntax

UI.SimpleMenu()
  • Returns UISimpleMenu instance

Remarks

The Menu will be invisible until a call to UISimpleMenu:Activate or UISimpleMenu:Toggle. You can easily bind a Menu to a Key, see UISimpleMenu:Toggle for more information.

Entry and Entry Index

Every item inside the SimpleMenu is called Entry. There are different types of Entry (Button, Checkbox, Search, etc.). Every entry that is added to a SimpleMenu receives an "index" which can be used to modify it later.

Entry Types

Supported Versions Type Screenshot Description Methods
All Button
UI-SimpleMenu-Button.png
A button with text. Triggers a callback when Numpad 5 is pressed. UISimpleMenu:AddButton
Checkbox
UI-SimpleMenu-Checkbox.png
Can be checked and unchecked using Numpad 5. Triggers an element when the checked state changes. UISimpleMenu:AddCheckbox

UISimpleMenu:IsChecked

UISimpleMenu:SetChecked

Search
UI-SimpleMenu-Search.png
Allows searching through all the elements in the menu. Once text is entered, they are filtered according to a "Fuzzy"-Search (case-insensitive). Entries which do not fit the filter are hidden. Triggers no callback. UISimpleMenu:AddSearch
Legion ScriptHook & Mafia DE ScriptHook List
UI-SimpleMenu-List.png
Supports multiple entries which can be selected using Numpad 4/6 and Arrows Left/Right. A callback is triggered every time the selected element changes. UISimpleMenu:AddList

UISimpleMenu:AddListEntry

UISimpleMenu:GetSelectedListEntry

UISimpleMenu:SelectListEntryByValue

UISimpleMenu:SelectListEntryByIndex

Text
UI-SimpleMenu-Text.png
Text field which supports multi-line text and word-wrapping. Stretches automatically to fit the size of the text. This entry can not be selected and triggers no callback. UISimpleMenu:AddText

Methods

Menu State

Entries

Button
Checkbox

List

Events

Controls

Up/Down Arrows Navigation
Numpad 8(Up), Numpad 9 (Down)
Enter Confirm Option
Numpad 5
Delete Key, Numpad 0 Return back to previous menu
ESC Close the menu

Related Pages