GuiGetScreenSize: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
mNo edit summary
Line 1: Line 1:
__NOTOC__  
__NOTOC__
{{Client function}}
This function retrieves the local screen size according to the resolution they are using.
This function retrieves the local screen size according to the resolution they are using.


Line 8: Line 9:


===Returns===
===Returns===
This returns two floats of the player's screen size, ''x'' and ''y'', corresponding to the resolution of that axis.
This returns two floats representing the player's screen resolution, ''width'' and ''height''.


==Example==  
==Example==  

Revision as of 09:54, 20 September 2007

This function retrieves the local screen size according to the resolution they are using.

Syntax

float float guiGetScreenSize ()

Returns

This returns two floats representing the player's screen resolution, width and height.

Example

This example checks whether a player is using a low resolution, and warns them that GUI may appear incorrect.

--setup a function when the resource starts
function checkResolutionOnStart ( theResource )
	--if the resource started isnt this resource, don't bother initiating the function
	if theResource ~= getThisResource() then return end
	local x,y = guiGetScreenSize() --get their screen size
	if ( x <= 640 ) and ( y <= 480 ) then --if their resolution is lower or equal to 640x480
		--warn them about GUI problems.
		outputChatBox ( "WARNING: You are running on a low resolution.  Some GUI may be placed or appear incorrectly."
	end
end
--attach the function to the event handler
addEventHandler ( "onClientResourceStart", getRootElement(), checkResolutionOnStart )

See Also

General functions

Browsers

Buttons

Checkboxes

Comboboxes

Edit Boxes

Gridlists

Memos

Progressbars

Radio Buttons

Scrollbars

Scrollpanes

Static Images

Tab Panels

Tabs

Text Labels

Windows