mirror of
https://github.com/edubart/otclient.git
synced 2025-10-14 19:44:54 +02:00
new lua function for creating widgets: createWidget
This commit is contained in:
@@ -1,17 +1,21 @@
|
||||
UI = { }
|
||||
UI.root = getRootWidget()
|
||||
-- globals
|
||||
rootWidget = g_ui.getRootWidget()
|
||||
|
||||
-- public functions
|
||||
function UI.display(arg1, options)
|
||||
function importStyle(otui)
|
||||
g_ui.importStyle(resolveFileFullPath(otui, 2))
|
||||
end
|
||||
|
||||
function displayUI(arg1, options)
|
||||
local widget
|
||||
local parent
|
||||
if options then parent = options.parent end
|
||||
parent = parent or UI.root
|
||||
parent = parent or rootWidget
|
||||
|
||||
-- display otui files
|
||||
if type(arg1) == 'string' then
|
||||
local otuiFilePath = resolveFileFullPath(arg1, 2)
|
||||
widget = loadUI(otuiFilePath, parent)
|
||||
widget = g_ui.loadUI(otuiFilePath, parent)
|
||||
-- display already loaded widgets
|
||||
else
|
||||
widget = arg1
|
||||
@@ -40,3 +44,14 @@ function UI.display(arg1, options)
|
||||
end
|
||||
return widget
|
||||
end
|
||||
|
||||
function createWidget(style, parent)
|
||||
local className = g_ui.getStyleClass(style)
|
||||
local class = _G[className]
|
||||
local widget = class.create()
|
||||
if parent then
|
||||
parent:addChild(widget)
|
||||
end
|
||||
widget:setStyle(style)
|
||||
return widget
|
||||
end
|
||||
|
Reference in New Issue
Block a user