Skyline Lua API
Version 1.0 RC1
Lua Script Reference for Skyline Game Engine.
|
#include <LUA_API_Gui.h>
Public Member Functions | |
void | setFontFamily (String bodyId, String ElementID, String fontName) |
Sets the styles current font name. More... | |
void | setFontWeight (String bodyId, String ElementID, String weight) |
Sets the current fonts weight this can be either normal or bold. More... | |
void | setFontStyle (String bodyId, String ElementID, String style) |
Sets the current fonts style this can be either normal or italic. More... | |
void | setFontSize (String bodyId, String ElementID, String size) |
Sets the current fonts size. More... | |
void | setProperty (String bodyId, String ElementID, String param, String value) |
This command can be use to set various style sheet properties. More... | |
void | setBackgroundColor (String bodyId, String ElementID, String color) |
Sets the element background to the color pass in the color arg.. More... | |
void | setFontColor (String bodyId, String ElementID, String color) |
Sets the current fonts color. More... | |
void | setText (String bodyId, String childID, String text) |
Sets the body text in the element. More... | |
void | getText (String bodyId, String childID) |
Returns the text between an element div tag including any HTML code. More... | |
void | setPosition (String bodyId, String childID, int x, int y) |
Set the position of an element. More... | |
void | setPosY (String bodyId, String childID, int y) |
Set the Y position of an element. More... | |
void | setPosX (String bodyId, String childID, int x) |
Set the Y position of an element. More... | |
void | setScaleX (String bodyId, String childID, int w) |
Set the width scale of an element in pixels. More... | |
void | setScaleXCent (String bodyId, String childID, int w) |
Set the width scale of an element in %. More... | |
void | setScaleY (String bodyId, String childID, int h) |
Set the height scale of an element in pixels. More... | |
void | setScaleYCent (String bodyId, String childID, int h) |
Set the width scale of an element in %. More... | |
void | show (String bodyId, String ElementID) |
Shows an already loaded document. More... | |
void | hide (String bodyId, String ElementID) |
Hides an already visibly loaded document. More... | |
void | setFullScreen (String bodyId) |
Sets the document to the current screens size. More... | |
void | setWindowPosition (String bodyId, int x, int y) |
Sets the position of a document. More... | |
void | setWindowSize (String bodyId, int w, int h) |
Sets the width and height of a document. More... | |
void | workSpace (String workspace_folder) |
A document must have its workspace folder defined prior to loading the file. This ensures that all images, style sheets and fonts are available. if the gui document files are on the root of the GUI folder the workspace is defined by passing "" as an arg eg.gui.workSpace(""). Important: Only documents from with in this workspace can be loaded. More... | |
String | load (String FileName, int posX, int posY) |
Loads a document file fromt he workspace folder and displays it on screen at an optional xy position.The bodyID of the new document is returned. More... | |
close (String bodyID) | |
Closes an open gui document. More... | |
void | enableGameInput (int state_keys, int state_mouse) |
Special feature to disable key and mouse movement. This can be used when getting user data from a text input to prevent input to the game. More... | |
void | hideCursor () |
Hide the gui cursor . More... | |
void | showCursor () |
Show the gui cursor. . More... | |
void gui | loadFromTemplate () |
Load From Template. . More... | |
void gui | setAttribute (bodyID, elementID, param, value) |
gui.setAttribute(bodyID, elementID, param, value); More... | |
loadFromTemplate (string"gui_doc.rml", int posX, int posY) | |
Load from Template. More... | |
string | workSpace (string"workspaceFolder/") |
Set the working forlder for the GUI's. More... | |
setWindowPositionCent (string bodyID, int posx, int posy) | |
Set the position in screen. More... | |
setAttribute (string bodyID, string elementName, string property, string value) | |
Set attribute of a elements property. More... | |
string | getProperty (string bodyID, string elementName, string property) |
Get property of an element. More... | |
string | getAttribute (string bodyID, string elementName, string property) |
Get property of an element. More... | |
Public Attributes | |
void | string = gui.getProperty(bodyID, elementID, param) |
gui.getProperty(bodyID, elementID, param); More... | |
The gui class is responsible for handling Skyline built in User Interface for dynamic content.
Most commands require that you pass the document bodyID and an elementID of the tag you wish to affect.
In some cases if the command is to affect the complete window then the bodyID can also be passed to the elementID arg. The Tag ids can be located by opening the ui document into the Skyline GUI Editor and look for the id="myID".
All documents must exist in a folder that also contains all of the required images and external style sheets files(if required)
This folder is refered to as the workspace. You can have many workspace folders but only one can be active at any one time. Use as gui.function()
For more information on how these functions can be used please visit the User Manual - http://www.chi-ad.com/Skyline/SDN/ and load the GUI Tech Demos for working examples.
function setup() if(SHOW_UI==1) then gui.workSpace("");--root of gui folder uiStart = gui.load("PearlDiver_StartScreen.rml",0,0); uiOver = gui.load("PearlDiver_GameOverScreen.rml",0,0); gui.hide(uiOver,uiOver); end end
gui::close | ( | String | bodyID | ) |
Closes an open gui document.
bodyID | : The body ID of the document you want to close. Here is a Small Example of how to use this function: gui.close(bodyID) |
void gui::enableGameInput | ( | int | state_keys, |
int | state_mouse | ||
) |
Special feature to disable key and mouse movement. This can be used when getting user data from a text input to prevent input to the game.
state_keys | : enable/disable game key input use 1 or 0 |
state_mouse | : enable/disable game mouse input use 1 or 0 Here is a Small Example of how to use this function: gui.workSpace("Pearl Diver"); bodyId = gui.load("PearlDiver_StartScreen.rml",0,0); gui.enableGameInput(0,1); |
Get property of an element.
param | bodyID : - - bodyID represents the id of the gui document loaded |
param | elemeName : - Name of the element you wish to get the attribute of. |
param | property : - The porperty you want to get the attribute of. Get Attribute return the value of an elements set parameters. e.g. "id", "class", "width", "height", etc..... function string getAttribute(string bodyID, string elementName, string property); end |
Get property of an element.
param | bodyID : - - bodyID represents the id of the gui document loaded |
param | elemeName : - Name of the element you wish to get the attribute of. |
param | property : - The porperty you want to get the attribute of. GetProperty is used to return stylesheet specific commands such as "background-color" or "color" function string getProperty(string bodyID, string elementName, string property); end |
void gui::getText | ( | String | bodyId, |
String | childID | ||
) |
Returns the text between an element div tag including any HTML code.
bodyId | : The main documents bodyID |
ElementID | : The element to which you want to affect. |
Here is a Small Example of how to use this function:
win1=0; function onInit(objID) sky.lprint("LUA: GUI Scripts active!"); obj = objID; gui.workSpace("SkyUI/"); win1 = gui.load("label_text.rml",20,20); end function onKeyDown( key ) text = gui.getText(win1,"text" ); lprint("text: "..text); end
void gui::hide | ( | String | bodyId, |
String | ElementID | ||
) |
Hides an already visibly loaded document.
bodyId | : The main documents bodyID |
ElementID | : The element to which you want to hide. |
Here is a Small Example of how to use this function:
gui.workSpace("Pearl Diver"); bodyId = gui.load("PearlDiver_StartScreen.rml",0,0); gui.hide(bodyId,bodyId);
void gui::hideCursor | ( | ) |
Hide the gui cursor
.
Here is a Small Example of how to use this function:
gui.workSpace("Pearl Diver"); bodyId = gui.load("PearlDiver_StartScreen.rml",0,0); gui.hideCursor();
String gui::load | ( | String | FileName, |
int | posX, | ||
int | posY | ||
) |
Loads a document file fromt he workspace folder and displays it on screen at an optional xy position.The bodyID of the new document is returned.
FileName | : The file name of the document |
x | : Optional x position. |
y | : Optional y position. |
gui.workSpace("Pearl Diver"); bodyId = gui.load("PearlDiver_StartScreen.rml",0,0);
void gui gui::loadFromTemplate | ( | ) |
Load From Template.
.
This generates a unique document name every time, it is usefull for enemy healthbardocuments, design 1, reuse many times
example coming soon
gui::loadFromTemplate | ( | string"gui_doc.rml" | , |
int | posX, | ||
int | posY | ||
) |
Load from Template.
param | string : - .rml files are the filetype for gui's |
param | int posX : - |
param | int posY : - function loadFromTemplate (string "gui_doc.rml", int posX, int posY) end |
void gui gui::setAttribute | ( | bodyID | , |
elementID | , | ||
param | , | ||
value | |||
) |
gui.setAttribute(bodyID, elementID, param, value);
param | bodyID : - Body ID of the document. |
param | elementID : - The ID of the element you want to change attributes of. |
param | param : - The Parameter that you want to change the attribute of. |
param | value : - The value you want to change it to. gui.setAttribute(bodyID, elementID, param, value); |
Set attribute of a elements property.
param | bodyID : - - bodyID represents the id of the gui document loaded |
param | elemeName : - Name of the element you wish to set the attribute for. |
param | property : - The porperty you want to set the attribute for. |
param | value : - The value you want to set. function setAttribute(string bodyID, string elementName, string property, string value); end |
void gui::setBackgroundColor | ( | String | bodyId, |
String | ElementID, | ||
String | color | ||
) |
Sets the element background to the color pass in the color arg..
bodyId | : The main documents bodyID |
ElementID | : The element to which you want to affect. |
color | : the color in the standard ccs format. |
Here is a Small Example of how to use this function:
gui.workSpace("Pearl Diver"); bodyId = gui.load("PearlDiver_StartScreen.rml",0,0); gui.setBackgroundColor(bodyId,"testElement", "#FF0000FF");
void gui::setFontColor | ( | String | bodyId, |
String | ElementID, | ||
String | color | ||
) |
Sets the current fonts color.
bodyId | : The main documents bodyID |
ElementID | : The element to which you want to affect. |
color | : the color in the standard ccs format. |
Here is a Small Example of how to use this function:
gui.workSpace("Pearl Diver"); bodyId = gui.load("PearlDiver_StartScreen.rml",0,0); gui.setFontColor(bodyId,"testElement", "#FF0000FF");
void gui::setFontFamily | ( | String | bodyId, |
String | ElementID, | ||
String | fontName | ||
) |
Sets the styles current font name.
bodyId | : The main documents bodyID |
ElementID | : The element to which you want to change the style sheets font. |
fontName | : A string containing the name of the font. |
The font must reside in the workspace font folder and be loaded by the system before this command can be called.
Here is a Small Example of how to use this function:
gui.workSpace("Pearl Diver"); bodyId = gui.load("PearlDiver_StartScreen.rml",0,0); gui.setFontFamily(bodyId,"testElement", "Days");
void gui::setFontSize | ( | String | bodyId, |
String | ElementID, | ||
String | size | ||
) |
Sets the current fonts size.
bodyId | : The main documents bodyID |
ElementID | : The element to which you want to affect. |
size | : the font size to use. |
Here is a Small Example of how to use this function:
gui.workSpace("Pearl Diver"); bodyId = gui.load("PearlDiver_StartScreen.rml",0,0); gui.setFontSize(bodyId,"testElement","24");
void gui::setFontStyle | ( | String | bodyId, |
String | ElementID, | ||
String | style | ||
) |
Sets the current fonts style this can be either normal or italic.
bodyId | : The main documents bodyID |
ElementID | : The element to which you want to affect. |
style | : pass either "normal" or "italic". |
Here is a Small Example of how to use this function:
gui.workSpace("Pearl Diver"); bodyId = gui.load("PearlDiver_StartScreen.rml",0,0); gui.setFontStyle(bodyId,"testElement", "italic");
void gui::setFontWeight | ( | String | bodyId, |
String | ElementID, | ||
String | weight | ||
) |
Sets the current fonts weight this can be either normal or bold.
bodyId | : The main documents bodyID |
ElementID | : The element to which you want to change the style sheets font. |
weight | : pass either "normal" or "bold". |
Here is a Small Example of how to use this function:
gui.workSpace("Pearl Diver"); bodyId = gui.load("PearlDiver_StartScreen.rml",0,0); gui.setFontWeight(bodyId,"testElement", "bold");
void gui::setFullScreen | ( | String | bodyId | ) |
Sets the document to the current screens size.
bodyId | : The main documents bodyID |
ElementID | : The element to which you want to affect. |
Here is a Small Example of how to use this function:
gui.workSpace("Pearl Diver"); bodyId = gui.load("PearlDiver_StartScreen.rml",0,0); gui.setFullScreen(bodyId);
void gui::setPosition | ( | String | bodyId, |
String | childID, | ||
int | x, | ||
int | y | ||
) |
Set the position of an element.
bodyId | : The main documents bodyID |
ElementID | : The element to which you want to affect. |
x | : X position. |
y | : Y position. |
Here is a Small Example of how to use this function:
gui.workSpace("Pearl Diver"); bodyId = gui.load("PearlDiver_StartScreen.rml",0,0); gui.setPosition(bodyId,"testElement", 10,100);
void gui::setPosX | ( | String | bodyId, |
String | childID, | ||
int | x | ||
) |
Set the Y position of an element.
bodyId | : The main documents bodyID |
ElementID | :The element to which you want to affect. |
x | : x position. |
Here is a Small Example of how to use this function:
gui.workSpace("Pearl Diver"); bodyId = gui.load("PearlDiver_StartScreen.rml",0,0); gui.setPosX(bodyId,"testElement", 10);
void gui::setPosY | ( | String | bodyId, |
String | childID, | ||
int | y | ||
) |
Set the Y position of an element.
bodyId | : The main documents bodyID |
ElementID | : The element to which you want to affect. |
y | : y position. |
Here is a Small Example of how to use this function:
gui.workSpace("Pearl Diver"); bodyId = gui.load("PearlDiver_StartScreen.rml",0,0); gui.setPosY(bodyId,"testElement", 10);
void gui::setProperty | ( | String | bodyId, |
String | ElementID, | ||
String | param, | ||
String | value | ||
) |
This command can be use to set various style sheet properties.
bodyId | : The main documents bodyID |
ElementID | :The element to which you want to affect. |
param | : the styles property name. |
value | : the value for the named property. |
Here is a Small Example of how to use this function:
gui.workSpace("Pearl Diver"); bodyId = gui.load("PearlDiver_StartScreen.rml",0,0); gui.setProperty(bodyId,"testElement", "color", "#FF0000FF");
void gui::setScaleX | ( | String | bodyId, |
String | childID, | ||
int | w | ||
) |
Set the width scale of an element in pixels.
bodyId | : The main documents bodyID |
ElementID | : The element to which you want to affect. |
w | : the required pixel width. |
Here is a Small Example of how to use this function:
gui.workSpace("Pearl Diver"); bodyId = gui.load("PearlDiver_StartScreen.rml",0,0); gui.setScaleX(bodyId,"testElement", 50);
void gui::setScaleXCent | ( | String | bodyId, |
String | childID, | ||
int | w | ||
) |
Set the width scale of an element in %.
bodyId | : The main documents bodyID |
ElementID | :The element to which you want to affect. |
w | : the required % width. |
Here is a Small Example of how to use this function:
gui.workSpace("Pearl Diver"); bodyId = gui.load("PearlDiver_StartScreen.rml",0,0); gui.setScaleX(bodyId,"testElement", 50);
void gui::setScaleY | ( | String | bodyId, |
String | childID, | ||
int | h | ||
) |
Set the height scale of an element in pixels.
bodyId | : The main documents bodyID |
ElementID | : The element to which you want to affect. |
h | : the required pixel width. |
Here is a Small Example of how to use this function:
gui.workSpace("Pearl Diver"); bodyId = gui.load("PearlDiver_StartScreen.rml",0,0); gui.setScaleX(bodyId,"testElement", 50);
void gui::setScaleYCent | ( | String | bodyId, |
String | childID, | ||
int | h | ||
) |
Set the width scale of an element in %.
bodyId | : The main documents bodyID |
ElementID | : The element to which you want to affect. |
h | : the required % width. |
Here is a Small Example of how to use this function:
gui.workSpace("Pearl Diver"); bodyId = gui.load("PearlDiver_StartScreen.rml",0,0); gui.setScaleX(bodyId,"testElement", 50);
void gui::setText | ( | String | bodyId, |
String | childID, | ||
String | text | ||
) |
Sets the body text in the element.
bodyId | : The main documents bodyID |
ElementID | : The element to which you want to affect. |
text | : The text to be displayed. |
Here is a Small Example of how to use this function:
win1=0; function onInit(objID) sky.lprint("LUA: GUI Scripts active!"); obj = objID; gui.workSpace("SkyUI/"); win1 = gui.load("label_text.rml",20,20); end function onKeyDown( key ) sky.lprint("You Pressed the "..key.." Key"); gui.setText(win1,"text",key ); end
void gui::setWindowPosition | ( | String | bodyId, |
int | x, | ||
int | y | ||
) |
Sets the position of a document.
bodyId | : The main documents bodyID |
ElementID | : The element to which you want to affect. |
x | : The x position |
y | : The y position |
Here is a Small Example of how to use this function:
gui.workSpace("Pearl Diver"); bodyId = gui.load("PearlDiver_StartScreen.rml",0,0); gui.setWindowPosition(bodyId,0,0);
gui::setWindowPositionCent | ( | string | bodyID, |
int | posx, | ||
int | posy | ||
) |
Set the position in screen.
param | bodyID : - - bodyID represents the id of the gui document loaded |
param | int posX : - Position n the X axis, postions are set in %, so 0 to 100 |
param | int posY : - Position n the Y axis, postions are set in %, so 0 to 100 function setWindowPositionCent(string bodyID, int posx, int posy ); end |
void gui::setWindowSize | ( | String | bodyId, |
int | w, | ||
int | h | ||
) |
Sets the width and height of a document.
bodyId | : The main documents bodyID |
ElementID | : The element to which you want to affect. |
w | : The width of the window. |
h | : The height of the window. |
Here is a Small Example of how to use this function:
gui.workSpace("Pearl Diver"); bodyId = gui.load("PearlDiver_StartScreen.rml",0,0); gui.setWindowSize(bodyId,0,0);
void gui::show | ( | String | bodyId, |
String | ElementID | ||
) |
Shows an already loaded document.
bodyId | : The main documents bodyID |
ElementID | : The element to which you want to show. |
Here is a Small Example of how to use this function:
gui.workSpace("Pearl Diver"); bodyId = gui.load("PearlDiver_StartScreen.rml",0,0); gui.show(bodyId,"testElement");
void gui::showCursor | ( | ) |
Show the gui cursor.
.
Here is a Small Example of how to use this function:
gui.workSpace("Pearl Diver"); bodyId = gui.load("PearlDiver_StartScreen.rml",0,0); gui.showCursor();
void gui::workSpace | ( | String | workspace_folder | ) |
A document must have its workspace folder defined prior to loading the file. This ensures that all images, style sheets and fonts are available.
if the gui document files are on the root of the GUI folder the workspace is defined by passing "" as an arg eg.gui.workSpace("").
Important: Only documents from with in this workspace can be loaded.
bodyId | : The main documents bodyID |
ElementID | : The element to which you want to affect. |
Here is a Small Example of how to use this function:
gui.workSpace("Pearl Diver"); bodyId = gui.load("PearlDiver_StartScreen.rml",0,0);
Set the working forlder for the GUI's.
param | workspace folder : - the folder that the .rml GUI files are stored in. This sets the folder to load the gui's from in the "Asset Library/GUI/" folder \n function workSpace (string "workspaceFolder/"); end |
void gui::string = gui.getProperty(bodyID, elementID, param) |
gui.getProperty(bodyID, elementID, param);
gui.getAttribute(bodyID, elementID, param);
bodyID | : ID of the body |
elementID | : The ID of the element |
param | : example coming soon |