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-06-04 14:38:15 +02:00
|
|
|
-- G is used as a global table to save variables in memory between reloads
|
|
|
|
G = G or {}
|
|
|
|
|
2012-03-25 16:10:15 +02:00
|
|
|
function loadUI(otui, parent)
|
|
|
|
local otuiFilePath = resolvepath(otui, 2)
|
|
|
|
return g_ui.loadUI(otuiFilePath, parent)
|
|
|
|
end
|
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-03-24 16:22:40 +01:00
|
|
|
function createWidget(stylename, parent)
|
|
|
|
if type(parent) == 'string' then
|
|
|
|
parent = rootWidget:recursiveGetChildById(parent)
|
2012-01-04 12:24:29 +01:00
|
|
|
end
|
2012-03-24 16:22:40 +01:00
|
|
|
local widget = g_ui.createWidgetFromStyle(stylename, parent)
|
2012-01-03 01:42:53 +01:00
|
|
|
return widget
|
|
|
|
end
|
2012-02-06 20:19:47 +01:00
|
|
|
|
2012-02-20 03:27:08 +01:00
|
|
|
function scheduleEvent(callback, delay)
|
2012-03-14 19:45:15 +01:00
|
|
|
local event = g_eventDispatcher.scheduleEvent(callback, delay)
|
2012-02-20 03:27:08 +01:00
|
|
|
|
|
|
|
-- 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)
|
2012-02-20 03:27:08 +01:00
|
|
|
-- must hold a reference to the callback, otherwise it would be collected
|
|
|
|
event._callback = callback
|
|
|
|
return event
|
|
|
|
end
|
|
|
|
|
2012-03-25 16:10:15 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2012-02-20 03:27:08 +01:00
|
|
|
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
|