Dynamic Windows

From Legends of Aria Admin and Modding Wiki
Revision as of 17:26, 1 November 2016 by Yorlik (talk | contribs)
Jump to: navigation, search

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.

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
  • Plus

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,
	--IconText = "LTNG",
	Enabled = true,
	Requirements = RequirementsTable,
	ServerCommand = "",
}

Typing /custom in game allows you to create a custom command with an icon, but is also useful to pick an Icon for the UserActionData.

If you'd prefer the icon had some letters instead of an image, you can specify IconText in place of Icon (Icon will always be chosen if present). Only a few letters will actually fit!

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)