mirror of
https://github.com/edubart/otclient.git
synced 2025-04-30 09:39:21 +02:00

* i'm gradually restoring game functionality with the new modules design, though still a lot to do * you can reload all scripts and modules using Ctrl+R shortcut while playing (finally! this is the reason of all this rework) * a bunch of fixes, but new regression too :P * fix performance issue that could lead freezes in the client in older machines * completely new game module with new design * fix crashs in map render * remove uigame.cpp (now every game input is via lua) * enable DEBUG macro by default, with it you are able to view any possible lua leak while running
71 lines
1.5 KiB
Lua
71 lines
1.5 KiB
Lua
rootWidget = g_ui.getRootWidget()
|
|
|
|
importStyle = g_ui.importStyle
|
|
importFont = g_fonts.importFont
|
|
setDefaultFont = g_fonts.setDefaultFont
|
|
|
|
loadUI = g_ui.loadUI
|
|
|
|
function displayUI(otui, parent)
|
|
parent = parent or rootWidget
|
|
local otuiFilePath = resolvepath(otui, 2)
|
|
return g_ui.loadUI(otuiFilePath, parent)
|
|
end
|
|
|
|
function createWidget(style, parent)
|
|
local className = g_ui.getStyleClass(style)
|
|
if className == "" then
|
|
error('could not find style ' .. style)
|
|
return
|
|
end
|
|
|
|
local class = _G[className]
|
|
if not class then
|
|
error('could not find widget class ' .. className)
|
|
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
|
|
|
|
function scheduleEvent(callback, delay)
|
|
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)
|
|
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
|
|
|
|
function reloadModule(name)
|
|
local module = g_modules.getModule(name)
|
|
if module then
|
|
module:reload()
|
|
end
|
|
end
|
|
|
|
function reloadModules()
|
|
g_modules.reloadModules()
|
|
end
|