User Tools

Site Tools



gui_api

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
gui_api [2019/12/11 17:17] – Added GUI:InputTextEditor kaligui_api [2024/06/23 13:09] (current) – [Layout] husbandomax
Line 40: 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: ''ml_gui.showtestwindow = true''\\   * To get an overview what is possible with the GUI, open the ingame console (CTRL + C) and execute this command: ''ml_gui.showtestwindow = true''\\
 +  * **AUTOMATIC TRANSLATIONS** - Wrap all your static text like: GUI:Button("I am a Label") to GUI:Button(GetString("I am a Label")), this will allow automatic translation to all languages later on.
   * 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://github.com/ocornut/imgui/blob/master/imgui_demo.cpp]], the used function names and syntax are 99% the same, just the arguments might be slightly different due to LUA not supporting references.\\   * 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://github.com/ocornut/imgui/blob/master/imgui_demo.cpp]], the used function names and syntax are 99% the same, just the arguments might be slightly different due to LUA not supporting references.\\
  
Line 52: Line 53:
 GUI:Button("Banana###123hohoho" GUI:Button("Banana###123hohoho"
 GUI:Button("Pineapple###123hohoho") GUI:Button("Pineapple###123hohoho")
 +Example: Different name in UI, same internal identifier with auto **Translations**: 
 +GUI:Button(GetString("Banana").."###123hohoho"
 +GUI:Button(GetString("Pineapple").."###123hohoho")
 </code> </code>
  
Line 320: Line 324:
     *Returns: //number//  FontSize + style.FramePadding.y * 2 + style.ItemSpacing.y (distance in pixels between 2 consecutive lines of framed widgets)     *Returns: //number//  FontSize + style.FramePadding.y * 2 + style.ItemSpacing.y (distance in pixels between 2 consecutive lines of framed widgets)
  
 +  ***''GUI:BeginTable()''**
 +    *Description: Begins a new table.
  
 +  ***''GUI:EndTable()''**
 +    *Description: Ends the current table.
 +
 +  ***''GUI:TableNextRow()''**
 +    *Description: Moves to the next row in the table.
 +
 +  ***''GUI:TableNextColumn()''**
 +    *Description: Moves to the next column in the current row of the table.
 +
 +  ***''GUI:TableSetColumnIndex(//number// column_index)''**
 +    *Description: Sets the current column index.
 +    *Parameter:
 +    *column_index: //number// — The index of the column to set.
 +
 +  ***''GUI:TableGetColumnIndex()''**
 +    *Returns: //number// — The current column index.
 +
 +  ***''GUI:TableGetRowIndex()''**
 +    *Returns: //number// — The current row index.
 +
 +  ***''GUI:TableGetColumnCount()''**
 +    *Returns: //number// — The //number// of columns in the table.
 +
 +  ***''GUI:TableGetColumnFlags(//number// column_index)''**
 +    *Returns: //number// — The flags of the specified column.
 +    *Parameter:
 +    *column_index: //number// — The index of the column.
 +
 +  ***''GUI:TableSetBgColor(//number// color)''**
 +    *Description: Sets the background color for the table.
 +    *Parameter:
 +    *color: //number// — The color value.
 +
 +  ***''GUI:TableSetColumnWidth(//number// column_index, //number// width)''**
 +    *Description: Sets the width of the specified column.
 +    *Parameters:
 +    *column_index: //number// — The index of the column.
 +    *width: //number// — The width to set.
 +
 +  ***''GUI:TableSetColumnSortDirection(//number// column_index, //boolean// ascending)''**
 +    *Description: Sets the sort direction for the specified column.
 +    *Parameters:
 +    *column_index: //number// — The index of the column.
 +    *ascending: //boolean// — true for ascending, false for descending.
 +
 +  ***''GUI:TableSetupColumn(//string// label, //number// flags, //number// init_width_or_weight)''**
 +    *Description: Sets up a column with the specified label and parameters.
 +    *Parameters:
 +    *label: //string// — The label of the column.
 +    *flags: //number// — The flags for the column.
 +    *init_width_or_weight: //number// — The initial width or weight of the column.
 +
 +  ***''GUI:TableHeadersRow()''**
 +    *Description: Adds a row of headers to the table.
 +
 +  ***''GUI:TableHeader(//string// label)''**
 +    *Description: Adds a header to the table.
 +    *Parameter:
 +    *label: //string// — The label of the header.
 +
 +  ***''GUI:TableSetupScrollFreeze(//number// cols, //number// rows)''**
 +    *Description: Freezes the specified number of columns and rows for scrolling.
 +    *Parameters:
 +    *cols: //number// — The number of columns to freeze.
 +    *rows: //number// — The number of rows to freeze.
 +
 +  ***''GUI:TableGetColumnName(//number// column_index)''**
 +    *Returns: //string// — The name of the specified column.
 +    *Parameter:
 +    *column_index: //number// — The index of the column.
 +
 +  ***''GUI:TableSetColumnEnabled(//number// column_index, //boolean// enabled)''**
 +    *Description: Sets the specified column as enabled or disabled.
 +    *Parameters:
 +    *column_index: //number// — The index of the column.
 +    *enabled: //boolean// — true to enable, false to disable.
 +
 +  ***''GUI:BeginTabBar()''**
 +    *Description: Begins a new tab bar.
 +
 +  ***''GUI:EndTabBar()''**
 +    *Description: Ends the current tab bar.
 +
 +  ***''GUI:BeginTabItem(//string// label)''**
 +    *Description: Begins a new tab item with the specified label.
 +    *Parameter:
 +    *label: //string// — The label of the tab item.
 +
 +  ***''GUI:EndTabItem()''**
 +    *Description: Ends the current tab item.
 +
 +  ***''GUI:TabItemButton(//string// label)''**
 +    *Description: Adds a button to the tab item with the specified label.
 +    *Parameter:
 +    *label: //string// — The label of the button.
 +
 +  ***''GUI:SetTabItemClosed(//string// label)''**
 +    *Description: Closes the tab item with the specified label.
 +    *Parameter:
 +    *label: //string// — The label of the tab item to close.
 ===Cursor=== ===Cursor===
   ***''GUI:GetCursorPos( )''**   ***''GUI:GetCursorPos( )''**
Line 606: Line 712:
 ===Widgets Tooltip=== ===Widgets Tooltip===
   ***''GUI:SetTooltip( //string// label )''**   ***''GUI:SetTooltip( //string// label )''**
-    *set tooltip under mouse-cursor, typically use with GUI:IsHovered(). last call wins+    *set tooltip under mouse-cursor, typically use with GUI:IsItemHovered. last call wins
   ***''GUI:BeginTooltip( )''**   ***''GUI:BeginTooltip( )''**
     *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 805: Line 911:
   ***''GUI:ResetMouseDragDelta( __//number// button__)''**   ***''GUI:ResetMouseDragDelta( __//number// button__)''**
     *Banana ;)     *Banana ;)
 +
 +  ***''GUI:GetMouseScroll( __//number// button__)''**
 +    *Returns: //number// scrollV, //number// scrollH     
  
   ***''GUI:GetClipboardText()''**   ***''GUI:GetClipboardText()''**
Line 811: Line 920:
   ***''GUI:SetClipboardText( //string// input)''**   ***''GUI:SetClipboardText( //string// input)''**
     *set text data to the clipboard     *set text data to the clipboard
 +
 +  ***''GUI:IsItemEdited()''**
 +    *Returns: //boolean// — true if the item was edited.
 +
 +  ***''GUI:IsItemActivated()''**
 +    *Returns: //boolean// — true if the item was activated.
 +
 +  ***''GUI:IsItemDeactivated()''**
 +    *Returns: //boolean// — true if the item was deactivated.
 +
 +  ***''GUI:IsItemDeactivatedAfterEdit()''**
 +    *Returns: //boolean// — true if the item was deactivated after an edit.
 +
 +  ***''GUI:IsItemToggledOpen()''**
 +    *Returns: //boolean// — true if the item was toggled open.
 +
 +  ***''GUI:GetItemID()''**
 +    *Returns: //number// — The ID of the item.
 +
 +  ***''GUI:GetMouseClickedCount(//number// button)''**
 +    *Returns: //number// — The number of times the specified mouse button was clicked.
 +    *Parameter:
 +    *button: //number// — The mouse button.
 +
 +  ***''GUI:IsMousePosValid()''**
 +    *Returns: //boolean// — true if the mouse position is valid.
 +
 +  ***''GUI:IsAnyMouseDown()''**
 +    *Returns: //boolean// — true if any mouse button is down.
 +
 +===Custom Widgets===
 +  ***''GUI:Keybind( //string// label, //number// virtualKey, __//number// width__)''**
 +    *Returns: //number// virtualKey, //string// keyName, //boolean// changed
 +    *Clicking the widget will start a listener for the next key press event
  
  
Line 834: Line 977:
  
   ***''GUI:AddImage( //string// texturepath, //number// X1, //number// Y1, //number// X2, //number// Y2)''**   ***''GUI:AddImage( //string// texturepath, //number// X1, //number// Y1, //number// X2, //number// Y2)''**
 +
 +  ***''RenderManager:WorldToScreen(//table// worldpos, //bool// true)''**
 +    *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
  
   ***''RenderManager:WorldToScreen(//table// worldpos)''**   ***''RenderManager:WorldToScreen(//table// worldpos)''**
     *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)// will print "2" into the console. These are registered values in the GUI metatable. //Usage: d(GUI.WindowFlags_NoMove)// will print "2" into the console.
gui_api.1576084638.txt.gz · Last modified: 2019/12/11 17:17 by kali