DGS OOP Class: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 38: Line 38:
</syntaxhighlight>
</syntaxhighlight>
==Functions==
==Functions==
|-
!OOP Functions
!POP Functions
|-
|getPosition
|[[dgsGetPosition]]
|-
|setPosition
|[[dgsSetPosition]]
|-
|getParent
|[[dgsGetParent]]
|-
|setParent
|[[dgsSetParent]]
|-
|getChild
|[[dgsGetChild]]
|-
|getChildren
|[[dgsGetChildren]]
|-
|getSize
|[[dgsGetSize]]
|-
|setSize
|[[dgsSetSize]]
|-
|getType
|[[dgsGetType]]
|-
|setLayer
|[[dgsSetLayer]]
|-
|getLayer
|[[dgsSetLayer]]
|-
|setCurrentLayerIndex
|[[dgsSetCurrentLayerIndex]]
|-
|getCurrentLayerIndex
|[[dgsGetCurrentLayerIndex]]
|-
|getProperty
|[[dgsGetProperty]]
|-
|setProperty
|[[dgsSetProperty]]
|-
|getProperties
|[[dgsGetProperties]]
|-
|setProperties
|[[dgsSetProperties]]
|-
|getVisible
|[[dgsGetVisible]]
|-
|setVisible
|[[dgsGetVisible]]
|-
|getEnabled
|[[dgsGetEnabled]]
|-
|setEnabled
|[[dgsSetEnabled]]
|-
|getSide
|[[dgsGetSide]]
|-
|setSide
|[[dgsSetSide]]
|-
|getAlpha
|[[dgsGetAlpha]]
|-
|setAlpha
|[[dgsSetAlpha]]
|-
|getFont
|[[dgsGetFont]]
|-
|setFont
|[[dgsSetFont]]
|-
|getText
|[[dgsGetText]]
|-
|setText
|[[dgsSetText]]
|-
|bringToFront
|[[dgsBringToFront]]
|-
|simulateClick
|[[dgsSimulateClick]]
|-
|animTo
|[[dgsAnimTo]]
|-
|isAniming
|[[dgsIsAniming]]
|-
|stopAniming
|[[dgsStopAniming]]
|-
|moveTo
|[[dgsMoveTo]]
|-
|isMoving
|[[dgsIsMoving]]
|-
|stopMoving
|[[dgsStopMoving]]
|-
|sizeTo
|[[dgsSizeTo]]
|-
|isSizing
|[[dgsIsSizing]]
|-
|stopSizing
|[[dgsStopSizing]]
|-
|alphaTo
|[[dgsAlphaTo]]
|-
|isAlphaing
|[[dgsIsAlphaing]]
|-
|stopAlphaing
|[[dgsStopAlphaing]]
|-
|getPostGUI
|[[dgsGetPostGUI]]
|-
|setPostGUI
|[[dgsGetPostGUI]]
|-
|destroy
|[[destroyElement]]
|-
|isElement
|[[isElement]]
|-
|getElement
|self.dgsElement
|-
|addMoveHandler
|[[dgsAddMoveHandler]]
|-
|removeMoveHandler
|[[dgsRemoveMoveHandler]]
|-
|isMoveHandled
|[[dgsIsMoveHandled]]
|-
|addSizeHandler
|[[dgsAddSizeHandler]]
|-
|removeSizeHandler
|[[dgsRemoveSizeHandler]]
|-
|isSizeHandled
|[[dgsIsSizeHandled]]
|-
|attachToTranslation
|[[dgsAttachToTranslation]]
|-
|detachFromTranslation
|[[dgsDetachFromTranslation]]
|-
|getTranslationName
|[[dgsGetTranslationName]]
|-
|on
|[[addEventHandler]](Handled By DGS)
|removeOn
|[[removeEventHandler]](Handled By DGS)
|-

Revision as of 15:23, 28 January 2019

DGS provides not only POP ( Procedure Oriented Programming ) but also OOP ( Object Oriented Programming ). This page introduces OOP of dgs.

Structure

When using DGS OOP, DGS objects to be operated are no longer elements, instead, they will be tables ( table is the only type whose call methods can be defined in lua ) . Here is the structure of DGS OOP Object:

DGSDxObject = {
	DGSElement = DGSElement -- The actual dgs element
	function1,
	function2,
	...
}
  • The built-in functions are non-modifiable
  • Any variable of the table are get/set via dgsSetProperty/dgsGetProperty ( Exclude DGSElement )
  • After importing DGS OOP Class, there is a table called : DGSClass

Get Started

Instead of using

 label = exports.dgs:dgsCreateLabel(0, 0, 0.5, 0.1, "text", true)
 DGS = exports.dgs
 label = DGS:dgsCreateLabel(0,0,0.5,0.1,"text",true)
 loadstring(exports.dgs:dgsImportFunction())()-- load functions
 label = dgsCreateLabel(0,0,0.5,0.1,"text",true) --create a label

We provides Object Oriented Programming

 loadstring(exports.dgs:dgsImportOOPClass())()-- load OOP class
 window = DGSClass:createWindow(0,0,0.5,0.1,"test",true) --create a window with oop
 label = window:createLabel(0,0,1,1,"label",true) --create a label inside the window
 label.text = "DGS OOP Test" --set text

Functions

|- !OOP Functions !POP Functions |- |getPosition |dgsGetPosition |- |setPosition |dgsSetPosition |- |getParent |dgsGetParent |- |setParent |dgsSetParent |- |getChild |dgsGetChild |- |getChildren |dgsGetChildren |- |getSize |dgsGetSize |- |setSize |dgsSetSize |- |getType |dgsGetType |- |setLayer |dgsSetLayer |- |getLayer |dgsSetLayer |- |setCurrentLayerIndex |dgsSetCurrentLayerIndex |- |getCurrentLayerIndex |dgsGetCurrentLayerIndex |- |getProperty |dgsGetProperty |- |setProperty |dgsSetProperty |- |getProperties |dgsGetProperties |- |setProperties |dgsSetProperties |- |getVisible |dgsGetVisible |- |setVisible |dgsGetVisible |- |getEnabled |dgsGetEnabled |- |setEnabled |dgsSetEnabled |- |getSide |dgsGetSide |- |setSide |dgsSetSide |- |getAlpha |dgsGetAlpha |- |setAlpha |dgsSetAlpha |- |getFont |dgsGetFont |- |setFont |dgsSetFont |- |getText |dgsGetText |- |setText |dgsSetText |- |bringToFront |dgsBringToFront |- |simulateClick |dgsSimulateClick |- |animTo |dgsAnimTo |- |isAniming |dgsIsAniming |- |stopAniming |dgsStopAniming |- |moveTo |dgsMoveTo |- |isMoving |dgsIsMoving |- |stopMoving |dgsStopMoving |- |sizeTo |dgsSizeTo |- |isSizing |dgsIsSizing |- |stopSizing |dgsStopSizing |- |alphaTo |dgsAlphaTo |- |isAlphaing |dgsIsAlphaing |- |stopAlphaing |dgsStopAlphaing |- |getPostGUI |dgsGetPostGUI |- |setPostGUI |dgsGetPostGUI |- |destroy |destroyElement |- |isElement |isElement |- |getElement |self.dgsElement |- |addMoveHandler |dgsAddMoveHandler |- |removeMoveHandler |dgsRemoveMoveHandler |- |isMoveHandled |dgsIsMoveHandled |- |addSizeHandler |dgsAddSizeHandler |- |removeSizeHandler |dgsRemoveSizeHandler |- |isSizeHandled |dgsIsSizeHandled |- |attachToTranslation |dgsAttachToTranslation |- |detachFromTranslation |dgsDetachFromTranslation |- |getTranslationName |dgsGetTranslationName |- |on |addEventHandler(Handled By DGS) |removeOn |removeEventHandler(Handled By DGS) |-