Squirrel/Client/Functions/GUIWindow/GUIWindow
From Liberty Unleashed Wiki
(Difference between revisions)
(Created page with '{{Squirrel/Title|GUIWindow}} This function creates a GUI window. == Syntax == <code>GUIWindow GUIWindow( VectorScreen pos, ScreenSize size, string titletext )</code> == Argume…') |
(Added an example.) |
||
Line 14: | Line 14: | ||
== Example == | == Example == | ||
− | + | This example creates a window in the center of the client's screen, once they spawn. | |
− | + | ||
− | + | ||
− | + | ||
<code lang="squirrel"> | <code lang="squirrel"> | ||
− | -- | + | function onClientSpawn(spawnclass) |
+ | { | ||
+ | // We use VectorScreen to set the GUI position. When aligning to the center, we minus half the width/height. | ||
+ | local pos = VectorScreen(ScreenWidth/2-245,ScreenHeight/2-50); | ||
+ | |||
+ | // We use ScreenSize to set the GUI size. | ||
+ | local size = ScreenSize(490,100); | ||
+ | |||
+ | // Create the window with the title "Example Window", and declare it TheWindow | ||
+ | TheWindow <- GUIWindow(pos,size,"Example Window"); | ||
+ | |||
+ | // Create a layer for our new window | ||
+ | AddGUILayer(TheWindow); | ||
+ | } | ||
</code> | </code> | ||
=== Notes === | === Notes === | ||
− | + | The function [[Squirrel/Client/Functions/GUILayers/AddGUILayer|AddGUILayer]] was used in this example. More info about this can be found in the corresponding page. | |
== Related Functions == | == Related Functions == | ||
{{Squirrel/Client/Functions/GUIWindow}} | {{Squirrel/Client/Functions/GUIWindow}} |
Latest revision as of 00:43, 27 September 2011
This function creates a GUI window.
[edit] Syntax
GUIWindow GUIWindow( VectorScreen pos, ScreenSize size, string titletext )
[edit] Arguments
- pos - The position of the window on screen
- size - The size of the window as a ScreenSize object
- titletext - The window title text
[edit] Example
This example creates a window in the center of the client's screen, once they spawn.
function onClientSpawn(spawnclass) { // We use VectorScreen to set the GUI position. When aligning to the center, we minus half the width/height. local pos = VectorScreen(ScreenWidth/2-245,ScreenHeight/2-50); // We use ScreenSize to set the GUI size. local size = ScreenSize(490,100); // Create the window with the title "Example Window", and declare it TheWindow TheWindow <- GUIWindow(pos,size,"Example Window"); // Create a layer for our new window AddGUILayer(TheWindow); }
[edit] Notes
The function AddGUILayer was used in this example. More info about this can be found in the corresponding page.