tibia-client/modules/core_lib/globals.lua

71 lines
1.5 KiB
Lua
Raw Normal View History

rootWidget = g_ui.getRootWidget()
importStyle = g_ui.importStyle
importFont = g_fonts.importFont
setDefaultFont = g_fonts.setDefaultFont
2012-01-05 02:28:29 +01:00
loadUI = g_ui.loadUI
function displayUI(otui, parent)
parent = parent or rootWidget
2012-02-08 00:06:52 +01:00
local otuiFilePath = resolvepath(otui, 2)
return g_ui.loadUI(otuiFilePath, parent)
end
function createWidget(style, parent)
local className = g_ui.getStyleClass(style)
2012-01-04 12:24:29 +01:00
if className == "" then
error('could not find style ' .. style)
return
end
local class = _G[className]
2012-01-04 12:24:29 +01:00
if not class then
error('could not find widget class ' .. className)
2012-01-04 12:24:29 +01:00
return
end
local widget = class.create()
if parent then
if type(parent) == 'string' then
parent = rootWidget:recursiveGetChildById(parent)
end
parent:addChild(widget)
end
widget:setStyle(style)
return widget
end
2012-02-06 20:19:47 +01:00
function scheduleEvent(callback, delay)
2012-03-14 19:45:15 +01:00
local event = g_eventDispatcher.scheduleEvent(callback, delay)
-- must hold a reference to the callback, otherwise it would be collected
event._callback = callback
return event
end
function addEvent(callback, front)
2012-03-14 19:45:15 +01:00
local event = g_eventDispatcher.addEvent(callback, front)
-- must hold a reference to the callback, otherwise it would be collected
event._callback = callback
return event
end
function removeEvent(event)
if event then
event:cancel()
event._callback = nil
end
end
2012-02-06 20:19:47 +01:00
function reloadModule(name)
local module = g_modules.getModule(name)
if module then
module:reload()
end
end
function reloadModules()
g_modules.reloadModules()
end