DgsImportOOPClass: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
 
(One intermediate revision by the same user not shown)
Line 59: Line 59:
loadstring(exports.dgs:dgsImportOOPClass())()
loadstring(exports.dgs:dgsImportOOPClass())()
local buttonElement = dgsCreateButton(200,200,300,300,"Test",false)
local buttonElement = dgsCreateButton(200,200,300,300,"Test",false)
local button = dgsGetClass(buttonElement)
local button = dgsGetInstance(buttonElement)
button.text = "=Test="
button.text = "=Test="
</syntaxhighlight>
</syntaxhighlight>

Latest revision as of 02:44, 17 July 2021

This function allows developers to import DGS OOP Class into his script.

[[{{{image}}}|link=|]] Note: DGS OOP Class returns tables which can not use original functions directly. See Example 1.


What we used to do is

local label = exports.dgs:dgsCreateLabel(0,0,1,1,"DGS",true)

or

DGS = exports.dgs
local label = DGS:dgsCreateLabel(0,0,1,1,"DGS",true)

with import function

loadstring(exports.dgs:dgsImportFunction())()
local label = dgsCreateLabel(0,0,1,1,"DGS",true)

with OOP Class

loadstring(exports.dgs:dgsImportOOPClass())()
local image = DGSClass:createImage(200,200,200,100,false,tocolor(0,0,0,255))
local label = image:createLabel(0,0,1,1,"DGS",true)
label.text = "Hello"

Predefine

When you load dgs API with dgsImportOOPClass, there will be some predefine functions/variables

  • Variable:
    • DGSClass: The root of all evil.
  • Function:
    • dgsGetClass: Converts normal dgs element into OOP Table.

Syntax

string dgsImportOOPClass( )

Required Arguments

None

Returns

Returns a string which can be loaded by loadstring, false otherwise.

Example

Example 1

This example shows how to convert normal dgs element into oop table

loadstring(exports.dgs:dgsImportFunction())()
loadstring(exports.dgs:dgsImportOOPClass())()
local buttonElement = dgsCreateButton(200,200,300,300,"Test",false)
local button = dgsGetInstance(buttonElement)
button.text = "=Test="

Example 2

This example shows how to convert dgs oop table into normal dgs element

loadstring(exports.dgs:dgsImportFunction())()
loadstring(exports.dgs:dgsImportOOPClass())()
local button = DGSClass:createButton(200,200,300,300,"Test",false)
local buttonElement = button.dgsElement
dgsSetText(buttonElement,"=Test=")

See Also

Custom Cursor Functions

Multi Language Supports

Animation

3D Element

3D Interface

3D Line

3D Image

3D Text

Browser

Button

Check Box

Combo Box

Custom Renderer

Edit

Detect Area

Drag'N Drop

Grid List

Image

Memo

Menu

Label

Layout

Line

Progress Bar

Radio Button

Scale Pane

Scroll Bar

Scroll Pane

Selector

Style

Switch Button

Tab Panel

Window

Basic Shape Plugins

Circle

Quadrilateral

Rounded Rectangle

Other Plugins

Blur Box

Canvas

Chart

Color Picker

Effect 3D

Gradient

Mask

Media Browser

Nine Slice

Object Preview Supports

Paste Handler

QRCode

Remote Image

Screen Source

SVG

Tooltips