TDX

From Multi Theft Auto: Wiki
Revision as of 17:22, 21 March 2020 by LopSided (talk | contribs)
Jump to navigation Jump to search

Total DX Library (TDX) is a DX GUI library for MTA:SA which aims to replicate all of the features offered by CEGUI - but instead is built upon the existing dxDraw* functions provided by MTA.


Author: LopSided

GitHub: https://github.com/Lpsd/total-dx-lib


Getting Started

It's really simple to implement Total DX Library into your resource/project. Download the latest release from GitHub and drop the dxlib folder from the .zip into your server's resources folder.


Start the dxlib resource and ensure it loads correctly (you should see some output in debugscript).


Next you'll need to import the library into your resource, using the code below. We recommend you put this code inside an onClientResourceStart event for each resource.

loadstring(exports.dxlib:dxLoadFunctions())()


Once the library has been imported, there's no need to use any more exports! You can use all the features documented here as though they were part of MTA itself.


Note: Every TDX GUI element created will be hosted within the parent dxlib resource. Upon restarting the dxlib resource any previous GUI will be re-created (meaning user interaction/input will be lost!) - be careful.


Example Usage

At the core, TDX is object-oriented, which is great for complex GUI systems. However, procedural style is also supported!


OOP (Object-Oriented) Example:

local window = DxWindow:new(300, 300, 300, 300, "Color Picker")
local input = DxInput:new(0, 50, 200, 35, "Lorem Ipsum is simply dummy text of the printing and typesetting industry.")
input:setParent(window)
input:setCentered(true)


Procedural Example:

local window = dxCreateWindow(300, 300, 300, 300, "Color Picker")
local input = dxCreateInput(0, 50, 200, 35, "Lorem Ipsum is simply dummy text of the printing and typesetting industry.")
dxSetParent(input, window)
dxSetCentered(input, true)


Classes

Below you can find a list of currently supported classes - DxClass (dx-type)

  • DxBlank (dx-blank)
  • DxButton (dx-button)
  • DxCheckbox(dx-checkbox)
  • DxCircle (dx-circle)
  • DxColorPicker (dx-colorpicker)
  • DxImage (dx-image)
  • DxInput (dx-input)
  • DxRadioButton (dx-radiobutton)
  • DxRing (dx-ring)
  • DxSlider (dx-slider)
  • DxText (dx-text)
  • DxWindow (dx-window)


All of these classes inherit the base class, DxElement, which provides many of the available methods for each class.


Functions


Button

Template:TDX button functions


Checkbox

Template:TDX checkbox functions


Circle

Template:TDX circle functions


Color Picker

Template:TDX colorpicker functions


Image

Template:TDX image functions


Input

Template:TDX input functions


Radio Button

Template:TDX radiobutton functions


Ring

Template:TDX ring functions


Slider

Template:TDX slider functions


Text

Template:TDX text functions


Window

Template:TDX window functions


Events

  • coming soon