Examples - schlangster/skyui-lib GitHub Wiki
NOTE: UILIB_N is a general variant of this library's API. For specific versions of the library you would then replace N with the version number. So UILIB_N becomes UILIB_1 for version 1 of the library.
The library consists of global functions, non-global functions, and events.
The non-global functions require the API script to be attached to an object in the mod, preferably to the object that also has the script, which makes use of the library. The functions can then be accessed in the following manner:
;UILIB_N is attached to the same object that this script is attached to
String sInput = ((Self as Form) as UILIB_N).ShowTextInput("Title", "Initial text")
It is also possible to attach the API script to an object that is then shared by all other scripts in the mod.
Quest Property UILib Auto ;Could be other types of objects, UILIB_N is attached to the object that this property is filled with
Event SomeEvent()
;UILIB_N is attached to another object
String sInput = (UILib as UILIB_N).ShowTextInput("Title", "Initial text")
EndEvent
;UILIB_N is attached to another object
UILIB_N UILib = Game.GetFormFromFile(sFORMID, sPLUGINNAME) as UILIB_N
String[] sOptions = new String[5]
sOptions[0] = "First"
sOptions[1] = "Second"
sOptions[2] = "Third"
sOptions[3] = "Fourth"
sOptions[4] = "Fifth"
Int iInput = UILib.ShowList("Title", sOptions, 1, 3)
Events and global functions can be accessed by any script in the following manner:
UILIB_N.ShowNotificationIcon("Icon Notification", "testicon.swf", 0, "#3399FF")
Event SomeEvent()
UILIB_N.TextInputMenu_Open(Self)
EndEvent
Event OnTextInputOpen(String asEventName, String asStringArg, Float afNumArg, Form akSender)
UILIB_N.TextInputMenu_SetData("Title", "Initial text")
EndEvent
Event OnTextInputClose(String asEventName, String asText, Float afCancelled, Form akSender)
If(afCancelled as Bool)
;Input cancelled, disregard the value of asText
Else
;Input confirmed
EndIf
UILIB_N.TextInputMenu_Release(Self)
EndEvent
Text input menu
Non-global function
;UILIB_N is attached to the same object that this script is attached to
String sInput = ((Self as Form) as UILIB_N).ShowTextInput("Title", "Initial text")
Events and global functions
Event SomeEvent()
UILIB_N.TextInputMenu_Open(Self)
EndEvent
Event OnTextInputOpen(String asEventName, String asStringArg, Float afNumArg, Form akSender)
UILIB_N.TextInputMenu_SetData("Title", "Text")
EndEvent
Event OnTextInputClose(String asEventName, String asText, Float afCancelled, Form akSender)
UILIB_N.TextInputMenu_Release(Self)
If(afCancelled as Bool)
;The input was cancelled, so asText should be disregarded.
Debug.Trace("Text input was cancelled.")
Else
;The input was confirmed, so asText can be used.
Debug.Trace("Text input: " + asText)
EndIf
EndEvent
List menu
Non-global function
;UILIB_N is attached to the same object that this script is attached to
String sOptions = new String[5]
sOptions[0] = "First"
sOptions[1] = "Second"
sOptions[2] = "Third"
sOptions[3] = "Fourth"
sOptions[4] = "Fifth"
Int iInput = ((Self as Form) as UILIB_N).ShowList("Title", "Initial text")
Debug.Trace("Selected option: " + sOptions[iInput])
Events and global functions
String[] sOptions
Event SomeEvent()
sOptions = new String[5]
sOptions[0] = "First"
sOptions[1] = "Second"
sOptions[2] = "Third"
sOptions[3] = "Fourth"
sOptions[4] = "Fifth"
UILIB_N.ListMenu_Open(Self)
EndEvent
Event OnListMenuOpen(String asEventName, String asStringArg, Float afNumArg, Form akSender)
UILIB_N.ListMenu_SetData("Title", sOptions, 0, 2)
EndEvent
Event OnListMenuClose(String asEventName, String asStringArg, Float afIndex, Form akSender)
UILIB_N.ListMenu_Release(Self)
Debug.Trace("Selected option: " + sOptions[afIndex as Int])
EndEvent
Notification area
Non-global functions
;UILIB_N is attached to the same object that this script is attached to
((Self as Form) as UILIB_N).ShowNotification("A message", "#FF3300")
((Self as Form) as UILIB_N).ShowNotificationIcon("Another message with an icon", "testicon.swf", 0, "#3399FF")