DgsCenterElement: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
(DGS (OOP Syntax)/(Template Organization) Mission)
 
(22 intermediate revisions by 2 users not shown)
Line 1: Line 1:
__NOTOC__
{{Client function}}
==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
element dgsCreateWindow ( float x, float y, float width, float height, string titleBarText, bool relative[, int titlenamecolor = 0xFFFFFFFF, float titsize = 25, element titimg = nil, int titcolor = 0xC8141414, element bgimg = nil, int bgcolor = 0x96141414, float sidesize = 5, bool nooffbutton = false ] )
bool dgsCenterElement ( element dgsElement [, bool remainX, bool remainY ] )
</syntaxhighlight>  
</syntaxhighlight>
{{DGS/OOP|
    Method = DGSElement:center
}}


===Required Arguments===
===Required Arguments===
[[Image:Dx_6.PNG|frame|Example Dx Window.]]
[[File:DgsCenterElement.png|thumb|Example]]
*'''x:''' A float of the 2D x position of the window on a player's screen. This is affected by the ''relative'' argument.
*'''element:''' The DGS element to center
*'''y:''' A float of the 2D y position of the window on a player's screen. This is affected by the ''relative'' argument.
*'''width:''' A float of the width of the window. This is affected by the ''relative'' argument.
*'''height:''' A float of the height of the window. This is affected by the ''relative'' argument.
*'''titleBarText:''' A string of the text that will be displayed in the title bar of the window.
*'''relative:''' This is whether sizes and positioning are relative.  If this is ''true'', then all x,y,width,height floats must be between 0 and 1, representing sizes/positions as a fraction of the screen size. If ''false'', then the size and co-ordinates are based on client's resolution, accessible using [[guiGetScreenSize]].


===Optional Arguments===  
===Optional Arguments===  
{{OptionalArg}}  
{{OptionalArg}}  
*'''titlenamecolor:''' An int of the color of the title text of the window.
*'''remainX:''' A bool indicates whether to remain X position while centering the window
*'''titsize:''' A float of the height of the title of the window.
*'''remainY:''' A bool indicates whether to remain Y position while centering the window
*'''titimg:''' A texture element of the background of the title of the window.
*'''titcolor:''' An int of the color of the title of the window.
*'''bgimg:''' A texture element of the background of the body of the window.
*'''bgcolor:''' An int of the background color of the body of the window.
*'''sidesize:''' A float of the side of the window that affects window sizing.
*'''nooffbutton :''' A bool of whether the window is created without close button.


===Returns===
==Example==
Returns a dgs window element if it was created successfully, false otherwise.
<syntaxhighlight lang="lua">
DGS = exports.dgs
 
window1 = DGS:dgsCreateWindow(100,50,200,200,"Center",false) --Create window1
window2 = DGS:dgsCreateWindow(100,50,200,200,"RemainX",false) --Create window2
window3 = DGS:dgsCreateWindow(100,50,200,200,"RemainY",false) --Create window3
 
DGS:dgsCenterElement(window1) -- center window1
DGS:dgsCenterElement(window2, true, false) -- center window2 with remaining X
DGS:dgsCenterElement(window3, false, true)-- center window3 with remaining Y
</syntaxhighlight>
 
=See Also=
 
==<span style="color:#eb3f00;text-shadow:0.05em 0.05em 0.2em #00000099;">General Functions</span>==
{{DGS General Functions}}
 
==<span style="color:#eb3f00;text-shadow:0.05em 0.05em 0.2em #00000099;">General Events</span>==
{{DGS Events/General}}

Latest revision as of 23:18, 3 May 2021

Syntax

bool dgsCenterElement ( element dgsElement [, bool remainX, bool remainY ] )

DGS OOP Syntax Help! I don't understand this!

Method: DGSElement:center(...)

Required Arguments

Example
  • element: The DGS element to center

Optional Arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments.

  • remainX: A bool indicates whether to remain X position while centering the window
  • remainY: A bool indicates whether to remain Y position while centering the window

Example

DGS = exports.dgs

window1 = DGS:dgsCreateWindow(100,50,200,200,"Center",false)	--Create window1
window2 = DGS:dgsCreateWindow(100,50,200,200,"RemainX",false)	--Create window2
window3 = DGS:dgsCreateWindow(100,50,200,200,"RemainY",false)	--Create window3

DGS:dgsCenterElement(window1) -- center window1
DGS:dgsCenterElement(window2, true, false) -- center window2 with remaining X
DGS:dgsCenterElement(window3, false, true)-- center window3 with remaining Y

See Also

General Functions

General Events