2012-01-03 01:42:53 +01:00
|
|
|
rootWidget = g_ui.getRootWidget()
|
2011-08-26 17:06:52 +02:00
|
|
|
|
2012-02-20 03:27:08 +01:00
|
|
|
importStyle = g_ui.importStyle
|
|
|
|
importFont = g_fonts.importFont
|
|
|
|
setDefaultFont = g_fonts.setDefaultFont
|
2012-01-05 02:28:29 +01:00
|
|
|
|
2012-02-20 03:27:08 +01:00
|
|
|
loadUI = g_ui.loadUI
|
2012-01-03 01:42:53 +01:00
|
|
|
|
2012-02-20 03:27:08 +01:00
|
|
|
function displayUI(otui, parent)
|
2012-01-03 01:42:53 +01:00
|
|
|
parent = parent or rootWidget
|
2012-02-08 00:06:52 +01:00
|
|
|
local otuiFilePath = resolvepath(otui, 2)
|
|
|
|
return g_ui.loadUI(otuiFilePath, parent)
|
|
|
|
end
|
|
|
|
|
2012-01-03 01:42:53 +01:00
|
|
|
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
|
|
|
|
|
2012-01-03 01:42:53 +01:00
|
|
|
local class = _G[className]
|
2012-01-04 12:24:29 +01:00
|
|
|
if not class then
|
2012-02-20 03:27:08 +01:00
|
|
|
error('could not find widget class ' .. className)
|
2012-01-04 12:24:29 +01:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2012-01-03 01:42:53 +01:00
|
|
|
local widget = class.create()
|
|
|
|
if parent then
|
2012-01-10 23:13:40 +01:00
|
|
|
if type(parent) == 'string' then
|
|
|
|
parent = rootWidget:recursiveGetChildById(parent)
|
|
|
|
end
|
2012-01-03 01:42:53 +01:00
|
|
|
parent:addChild(widget)
|
|
|
|
end
|
|
|
|
widget:setStyle(style)
|
|
|
|
return widget
|
|
|
|
end
|
2012-02-06 20:19:47 +01:00
|
|
|
|
2012-02-20 03:27:08 +01:00
|
|
|
function scheduleEvent(callback, delay)
|
|
|
|
local event = g_dispatcher.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)
|
|
|
|
local event = g_dispatcher.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
|
|
|
|
|
|
|
|
|