DgsImportOOPClass

From Multi Theft Auto: Wiki
Jump to: navigation, search

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 = dgsGetClass(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

Multi Language Supports

Animation

3D Interface

3D Text

Arrow List

Browser

Button

Check Box

Combo Box

Edit

Ellipse Detect Area

Detect Area

Grid List

Image

Memo

Label

Progress Bar

Radio Button

Scroll Bar

Scroll Pane

Switch Button

Tab Panel

Window

Plugin

Media Browser

Rounded Rectangle

Color Picker