You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
benank edited this page Aug 19, 2020
·
4 revisions
The UI singleton class is a client-side class used to create new UI element for your gamemode using HTML, CSS, and JS. If you want to display information on the screen without using natives, you'll be using this.
UI:Create(args)
Creates a new UIInstance and creates a new HTML window.
args (in table):
name (string): name of the UI instance you want to create. Must be unique.
path (string): path to the HTML page to load. Must be relative to resource, eg lobby/client/html/index.html (where your resource name is gamemode, or anything else. lobby is a module within your resource.)
css (optional, string): extra CSS you would like to apply to this UI instance. Great for restricting the size of a UI instance to only a certain portion of the screen.
returns: UIInstance of the instance you just created
UI:GetSize()
Gets the screen size in pixels.
returns: table containing x and y values of the screen size.
UI:SetCursor(enabled)
Shows/hides the cursor for all UI. Also sets UI focus so keypresses will no longer register in the game.
Ref counted, so every time you call it with true, you must call it with false to hide the cursor.
enabled (bool): whether or not the mouse should be enabled
UI:GetCursor()
Returns the ref count for the cursor.
returns: number containing ref count
UI:CallEvent(args)
Calls an event on a single or all UI instances.
args (in table)
data (table): the table of data you want to send
event_name (string): event name to call
name (optional, string): name of the UI instance you want to send to, nil to call event on all instances