Squirrel/Client/Functions/GUIWindow/GUIWindow

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
(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 ==
  
{{Squirrel/NeedsExample}}
+
This example creates a window in the center of the client's screen, once they spawn.
 
+
Explanation here.
+
 
+
 
<code lang="squirrel">
 
<code lang="squirrel">
-- todo
+
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 ===
  
Used functions and other notes here.
+
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

Home   |   Squirrel Scripting   |   Server Functions   |   Server Events   |   Client Functions   |   Client Events

This function creates a GUI window.

[edit] Syntax

  1. 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.

  1.  
  2. function onClientSpawn(spawnclass)
  3. {
  4. // We use VectorScreen to set the GUI position. When aligning to the center, we minus half the width/height.
  5. local pos = VectorScreen(ScreenWidth/2-245,ScreenHeight/2-50);
  6. // We use ScreenSize to set the GUI size.
  7. local size = ScreenSize(490,100);
  8. // Create the window with the title "Example Window", and declare it TheWindow
  9. TheWindow <- GUIWindow(pos,size,"Example Window");
  10. // Create a layer for our new window
  11. AddGUILayer(TheWindow);
  12. }
  13.  

[edit] Notes

The function AddGUILayer was used in this example. More info about this can be found in the corresponding page.

[edit] Related Functions

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox