GuiGetScreenSize: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
This function retrieves the local screen size according to the resolution they are using. | |||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
float float guiGetScreenSize ( ) | float float guiGetScreenSize () | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== | ===Returns=== | ||
This returns two floats of the player's screen size, ''x'' and ''y'', corresponding to the resolution of that axis. | |||
==Example== | ==Example== | ||
This example checks whether a player is using a low resolution, and warns them that GUI may appear incorrect. | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
-- | --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 ) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{GUI_functions}} | |||
{{ | |||
Revision as of 14:51, 1 August 2007
This function retrieves the local screen size according to the resolution they are using.
Syntax
float float guiGetScreenSize ()
Returns
This returns two floats of the player's screen size, x and y, corresponding to the resolution of that axis.
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
- guiBringToFront
- getChatboxLayout
- getChatboxCharacterLimit
- guiCreateFont
- guiBlur
- guiFocus
- guiGetAlpha
- guiGetCursorType
- guiGetEnabled
- guiGetFont
- guiGetInputEnabled
- guiGetInputMode
- guiGetPosition
- guiGetProperties
- guiGetProperty
- guiGetScreenSize
- guiGetSize
- guiGetText
- guiGetVisible
- guiMoveToBack
- guiSetAlpha
- guiSetEnabled
- guiSetFont
- guiSetInputEnabled
- guiSetInputMode
- guiSetPosition
- guiSetProperty
- guiSetSize
- guiSetText
- guiSetVisible
- isChatBoxInputActive
- isConsoleActive
- isDebugViewActive
- isMainMenuActive
- isMTAWindowActive
- isTransferBoxActive
- setChatboxCharacterLimit
- setDebugViewActive
Browsers
Buttons
Checkboxes
Comboboxes
- guiCreateComboBox
- guiComboBoxAddItem
- guiComboBoxClear
- guiComboBoxGetItemCount
- guiComboBoxGetItemText
- guiComboBoxGetSelected
- guiComboBoxIsOpen
- guiComboBoxRemoveItem
- guiComboBoxSetItemText
- guiComboBoxSetOpen
- guiComboBoxSetSelected
Edit Boxes
- guiCreateEdit
- guiEditGetCaretIndex
- guiEditGetMaxLength
- guiEditIsMasked
- guiEditIsReadOnly
- guiEditSetCaretIndex
- guiEditSetMasked
- guiEditSetMaxLength
- guiEditSetReadOnly
Gridlists
- guiCreateGridList
- guiGridListAddColumn
- guiGridListAddRow
- guiGridListAutoSizeColumn
- guiGridListClear
- guiGridListGetColumnCount
- guiGridListGetColumnTitle
- guiGridListGetColumnWidth
- guiGridListGetHorizontalScrollPosition
- guiGridListGetItemColor
- guiGridListGetItemData
- guiGridListGetItemText
- guiGridListGetRowCount
- guiGridListGetSelectedCount
- guiGridListGetSelectedItem
- guiGridListGetSelectedItems
- guiGridListGetSelectionMode
- guiGridListIsSortingEnabled
- guiGridListGetVerticalScrollPosition
- guiGridListInsertRowAfter
- guiGridListRemoveColumn
- guiGridListRemoveRow
- guiGridListSetColumnTitle
- guiGridListSetColumnWidth
- guiGridListSetHorizontalScrollPosition
- guiGridListSetItemColor
- guiGridListSetItemData
- guiGridListSetItemText
- guiGridListSetScrollBars
- guiGridListSetSelectedItem
- guiGridListSetSelectionMode
- guiGridListSetSortingEnabled
- guiGridListSetVerticalScrollPosition
Memos
- guiCreateMemo
- guiMemoGetCaretIndex
- guiMemoGetVerticalScrollPosition
- guiMemoSetVerticalScrollPosition
- guiMemoIsReadOnly
- guiMemoSetCaretIndex
- guiMemoSetReadOnly
Progressbars
Radio Buttons
Scrollbars
Scrollpanes
- guiCreateScrollPane
- guiScrollPaneGetHorizontalScrollPosition
- guiScrollPaneGetVerticalScrollPosition
- guiScrollPaneSetHorizontalScrollPosition
- guiScrollPaneSetScrollBars
- guiScrollPaneSetVerticalScrollPosition
Static Images
Tab Panels
Tabs
Text Labels
- guiCreateLabel
- guiLabelGetColor
- guiLabelGetFontHeight
- guiLabelGetTextExtent
- guiLabelSetColor
- guiLabelSetHorizontalAlign
- guiLabelSetVerticalAlign