tibia-client/modules/corelib/globals.lua

88 lines
2.0 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
-- G is used as a global table to save variables in memory between reloads
G = G or {}
function loadUI(otui, parent)
local otuiFilePath = resolvepath(otui, 2)
return g_ui.loadUI(otuiFilePath, parent)
end
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(stylename, parent)
if type(parent) == 'string' then
parent = rootWidget:recursiveGetChildById(parent)
2012-01-04 12:24:29 +01:00
end
local widget = g_ui.createWidgetFromStyle(stylename, parent)
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
2012-06-06 22:14:53 +02:00
function cycleEvent(callback, front)
local event = g_eventDispatcher.cycleEvent(callback, front)
-- must hold a reference to the callback, otherwise it would be collected
event._callback = callback
return event
end
function periodicalEvent(eventFunc, conditionFunc, delay, autoRepeatDelay)
delay = delay or 30
autoRepeatDelay = autoRepeatDelay or delay
local func
func = function()
if conditionFunc and not conditionFunc() then
func = nil
return
end
eventFunc()
scheduleEvent(func, delay)
end
scheduleEvent(function()
func()
end, autoRepeatDelay)
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