UI - Paradigm-MP/oof GitHub Wiki
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, eglobby/client/html/index.html
(where your resource name isgamemode
, 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
andy
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 withfalse
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 sendevent_name
(string): event name to callname
(optional, string): name of the UI instance you want to send to, nil to call event on all instances
UI:Remove(name)
- Removes a UI instance by name.
name
(string): name of the UI instance to remove