Difference between revisions of "Dynamic Windows"
Supreem CS (talk | contribs) |
Supreem CS (talk | contribs) (→Tips and Tricks) |
||
Line 140: | Line 140: | ||
== Tips and Tricks == | == Tips and Tricks == | ||
+ | * The second parameter to [http://shardsonline.com/lN2rwhz4jSVambqesEBZ/lua-reference/gameobj.html#opendynamicwindow OpenDynamicWindow] tells the engine which object should receive the [http://shardsonline.com/lN2rwhz4jSVambqesEBZ/lua-reference/events.html#dynamicwindowresponse DynamicWindowResponse] event (defaults to this). If you are not seeing the event fire, this is probably why! | ||
* You can use invisible buttons to put tooltips over any area of the window. | * You can use invisible buttons to put tooltips over any area of the window. | ||
* Use invisible window type to add HUD elements (like the quest tracker) | * Use invisible window type to add HUD elements (like the quest tracker) |
Revision as of 14:55, 29 October 2016
Dynamic Windows allow you to create a window on the server and present it to the client. Certain types will trigger a Dynamic Window Response such as DynamicWindow:AddButton, allowing you to control the window dependent on user input.
These examples are made to be copy paste ready, leaving in the comments is strongly recommended. If you don't need all the parameters you can do this:
local dynamicWindow = DynamicWindow( "MyWindow", --(string) Window ID used to uniquely identify the window. It is returned in the DynamicWindowResponse event. "My Window, --(string) Title of the window for the client UI 100, --(number) Width of the window 100 --(number) Height of the window --startX, --(number) Starting X position of the window (chosen by client if not specified) --startY, --(number) Starting Y position of the window (chosen by client if not specified) --windowType, --(string) Window type (optional) --windowAnchor --(string) Window anchor (default "TopLeft") ) gameObj:OpenDynamicWindow(dynamicWindow)
Please notice after the height parameter the comma was removed, this is crucial or you will receive a Lua error similar to unexpected symbol near ')'
Setting a (number) to 0 or (string) to "" is the same as not setting it.
Contents
DynamicWindow
DynamicWindow( windowId, --(string) Window ID used to uniquely identify the window. It is returned in the DynamicWindowResponse event. title, --(string) Title of the window for the client UI width, --(number) Width of the window height, --(number) Height of the window startX, --(number) Starting X position of the window (chosen by client if not specified) startY, --(number) Starting Y position of the window (chosen by client if not specified) windowType, --(string) Window type (optional) windowAnchor --(string) Window anchor (default "TopLeft") )
WindowAnchor options
- Top
- TopLeft
- TopRight
- Bottom
- BottomLeft
- BottomRight
- Left
- Right
- Center
WindowType options
- Default
- Transparent
- NoFrame
- SemiTransparent
- TriplePane
- TransparentCloseButton
- DefaultLongTitle
DynamicWindow:AddImage
dynamicWindow:AddImage( x, --(number) x position in pixels on the window y, --(number) y position in pixels on the window spriteName, --(string) sprite name width, --(number) width of the image height, --(number) height of the image spriteType, --(string) sprite type Simple, Sliced or Object (defaults to Simple) spriteHue, --(string) sprite hue (defaults to white) opacity --(number) (default 1.0) )
When spriteType is set to Object you can put a clientId as a string for spriteName ("317" for a human skull), but not every object will work like this as some objects don't have sprite images.
DynamicWindow:AddLabel
dynamicWindow:AddLabel( x, --(number) x position in pixels on the window y, --(number) y position in pixels on the window text, --(string) text in the label width, --(number) width of the text for wrapping purposes (defaults to width of text) height, --(number) height of the label (defaults to unlimited, text is not clipped) fontSize, --(number) font size (default specific to client) alignment, --(string) alignment "left", "center", or "right" (default "left") scrollable, --(boolean) scrollable (default false) outline, --(boolean) outline (defaults to false) font --(string) name of font on client (optional) )
Fonts
- PermianSlabSerifBold_24
- Kingthings_18
- PermianSlabSerif_16_Dynamic
DynamicWindow:AddButton
dynamicWindow:AddButton( x, --(number) x position in pixels on the window y, --(number) y position in pixels on the window returnId, --(string) return id used in the DynamicWindowResponse event text, --(string) text in the button (defaults to empty string) width, --(number) width of the button (defaults to width of text) height,--(number) height of the button (default decided by type of button) tooltip, --(string) mouseover tooltip for the button (default blank) serverCommand, --(string) server command to send on button click (default to none) closeWindowOnClick, --(boolean) should the window close when this button is clicked? (default true) buttonType, --(string) button type (default "Default") buttonState, --(string) button state (optional, valid options are default,pressed,disabled) customSprites --(table) Table of custom button sprites (normal, hover, pressed. disabled) )
ButtonType options
- Default
- Invisible
- Selection
- SimpleButton
- UpDownLock
- TabButton
- LeftArrow
- RightArrow
- CategoryButton
- SectionButton
- SkillSectionButton
- Selection2
DynamicWindow:AddUserAction
dynamicWindow:AddUserAction( x, --(number) x position in pixels of the window y, --(number) y position in pixels of the window userActionData, --(table) table containing the user action data width, --(number) width in pixels of the window (default decided by client) height --(number) height in pixels of the window (default decided by client) )
UserActionData Example
{ ID = "Lightning", ActionType = "Spell", DisplayName = "Lightning Spell", Tooltip = "This is a powerful spell will fux you up", IconObject = spellData.Icon, Icon = spellData.Icon, Enabled = true, Requirements = RequirementsTable, ServerCommand = "", }
Tips and Tricks
- The second parameter to OpenDynamicWindow tells the engine which object should receive the DynamicWindowResponse event (defaults to this). If you are not seeing the event fire, this is probably why!
- You can use invisible buttons to put tooltips over any area of the window.
- Use invisible window type to add HUD elements (like the quest tracker)