This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
gui_api [2018/04/18 14:13] – fxfire | gui_api [2023/04/21 07:34] (current) – kali | ||
---|---|---|---|
Line 3: | Line 3: | ||
====GUI API Documentation==== | ====GUI API Documentation==== | ||
You can easily build your own ingame GUI or draw custom shapes / icons / pictures through LUA. | You can easily build your own ingame GUI or draw custom shapes / icons / pictures through LUA. | ||
- | Each rendered frame the " | + | Each rendered frame the " |
+ | |||
+ | Simple demo code {{ :: | ||
+ | |||
+ | Example: | ||
To get you started, let's draw a simple window with a slider, create a new .lua file, add it to your addon' | To get you started, let's draw a simple window with a slider, create a new .lua file, add it to your addon' | ||
<code lua> | <code lua> | ||
Line 30: | Line 34: | ||
end | end | ||
end | end | ||
- | RegisterEventHandler(" | + | RegisterEventHandler(" |
</ | </ | ||
Line 36: | Line 40: | ||
===Important Information=== | ===Important Information=== | ||
* To get an overview what is possible with the GUI, open the ingame console (CTRL + C) and execute this command: '' | * To get an overview what is possible with the GUI, open the ingame console (CTRL + C) and execute this command: '' | ||
+ | * **AUTOMATIC TRANSLATIONS** - Wrap all your static text like: GUI: | ||
* If you find something in that Testwindow but you are not sure how to code the same in LUA, have a look in the c++ source of it: [[https:// | * If you find something in that Testwindow but you are not sure how to code the same in LUA, have a look in the c++ source of it: [[https:// | ||
Line 48: | Line 53: | ||
GUI: | GUI: | ||
GUI: | GUI: | ||
+ | Example: Different name in UI, same internal identifier with auto **Translations**: | ||
+ | GUI: | ||
+ | GUI: | ||
</ | </ | ||
Line 124: | Line 132: | ||
*Returns: //number// witdth | *Returns: //number// witdth | ||
- | ***'' | + | ***'' |
*set next window position. call before Begin() | *set next window position. call before Begin() | ||
Line 236: | Line 244: | ||
*size (also height in pixels) of current font with current scale applied | *size (also height in pixels) of current font with current scale applied | ||
- | ***'' | + | ***'' |
*per-window font scale. Adjust IO.FontGlobalScale if you want to scale all windows | *per-window font scale. Adjust IO.FontGlobalScale if you want to scale all windows | ||
Line 247: | Line 255: | ||
===Layout=== | ===Layout=== | ||
+ | ***'' | ||
+ | * If a line does not start with text but with an Icon or other GUI Element, call this before drawing the text to align the height correctly. | ||
+ | |||
***'' | ***'' | ||
*horizontal line | *horizontal line | ||
Line 278: | Line 289: | ||
***'' | ***'' | ||
- | *setup number of columns. use an identifier to distinguish multiple column sets. close with Columns(1). | + | *setup number of columns. use an identifier to distinguish multiple column sets. **close with Columns(1)**. |
***'' | ***'' | ||
Line 461: | Line 472: | ||
***'' | ***'' | ||
*Returns: //string// text, //bool// changed | *Returns: //string// text, //bool// changed | ||
+ | |||
+ | ***'' | ||
+ | *Returns: //string// text, //bool// changed | ||
+ | *Lua syntax highlighting version of GUI: | ||
***'' | ***'' | ||
Line 578: | Line 593: | ||
===Widgets Lists=== | ===Widgets Lists=== | ||
***'' | ***'' | ||
- | *Returns: //bool// changed | + | *Returns: |
*size.x==0.0: | *size.x==0.0: | ||
Line 595: | Line 610: | ||
===Widgets Tooltip=== | ===Widgets Tooltip=== | ||
***'' | ***'' | ||
- | *set tooltip under mouse-cursor, | + | *set tooltip under mouse-cursor, |
***'' | ***'' | ||
*use to create full-featured tooltip windows that aren't just text | *use to create full-featured tooltip windows that aren't just text | ||
Line 800: | Line 815: | ||
***'' | ***'' | ||
*set text data to the clipboard | *set text data to the clipboard | ||
+ | |||
+ | |||
+ | |||
+ | ===Custom Widgets=== | ||
+ | ***'' | ||
+ | *Returns: //number// virtualKey, //string// keyName, //boolean// changed | ||
+ | *Clicking the widget will start a listener for the next key press event | ||
Line 823: | Line 845: | ||
***'' | ***'' | ||
+ | |||
+ | ***'' | ||
+ | *Returns: //number// X1, //number// Y1, screenpos | ||
+ | *USE THIS ONE IF POSSIBLE, it is A LOT FASTER than the one below! Converts a worldposition x,y,z to a screenposition x,y , IF that point is currently visible on the screen | ||
***'' | ***'' | ||
*Returns: //table// screenpos | *Returns: //table// screenpos | ||
*Converts a worldposition x,y,z to a screenposition x,y , IF that point is currently visible on the screen | *Converts a worldposition x,y,z to a screenposition x,y , IF that point is currently visible on the screen | ||
+ | |||
===Enums & Flags=== | ===Enums & Flags=== | ||
These are registered values in the GUI metatable. //Usage: d(GUI.WindowFlags_NoMove)// | These are registered values in the GUI metatable. //Usage: d(GUI.WindowFlags_NoMove)// | ||
Line 867: | Line 894: | ||
* GUI.InputTextFlags_NoUndoRedo | * GUI.InputTextFlags_NoUndoRedo | ||
* GUI.InputTextFlags_CharsScientific | * GUI.InputTextFlags_CharsScientific | ||
+ | * GUI.InputTextFlags_Password | ||