I didn't like how the UI scripting was looking. So I put the UI objects in sub classes of the UI class. At any rate it looks better and is easier to remember syntaxs.
dofile("Scripting\\Base\\Keys.lua")
Scripting_RegisterClass("ui")
Scripting_RegisterClass("engine")
dialogID = nil
function loadUI()
local _width = Engine.GetWindowWidth()
local _height = Engine.GetWindowHeight()
local _offsetX = _width - 160
dialogID = UI.Dialog.Add(0, 0, _width, _height)
UI.Dialog.SetColors(dialogID, 0, 0, 0, UI.ARGB("Blue"))
UI.Dialog.SetCaption(dialogID, "Main Menu", UI.ARGB("White"), 30)
UI.Button.Add(dialogID, 12, "UI Test", _offsetX, _height - 136, 150, 20, "UI.Load('UI Test.lua', true)", -1)
UI.Button.Add(dialogID, 13, "Play", _offsetX, _height - 112, 150, 20, "UI.Load('PlayMenu.lua', true)", Keys.Enter)
UI.Button.Add(dialogID, 14, "Settings", _offsetX, _height - 88, 150, 20, "Engine.ShowVideoSettings()", -1)
UI.Button.Add(dialogID, 15, "Exit", _offsetX, _height - 64, 150, 20, "Engine.CloseWindow()", Keys.Escape)
end
loadUI() -- Is in a function so its attributes drop out of memory once out of scope.
function resize()
local _width = Engine.GetWindowWidth()
local _height = Engine.GetWindowHeight()
local _offsetX = _width - 160
UI.Dialog.SetSize(dialogID, _width, _height)
UI.Button.SetLocation(dialogID, 12, _offsetX, _height - 136)
UI.Button.SetLocation(dialogID, 13, _offsetX, _height - 112)
UI.Button.SetLocation(dialogID, 14, _offsetX, _height - 88)
UI.Button.SetLocation(dialogID, 15, _offsetX, _height - 64)
end