mirror of
https://github.com/edubart/otclient.git
synced 2025-10-14 11:34:54 +02:00
reorganize modules
This commit is contained in:
@@ -7,19 +7,17 @@ Module
|
||||
autoLoad: true
|
||||
dependencies:
|
||||
- core_fonts
|
||||
- core_ui
|
||||
- core_styles
|
||||
|
||||
onLoad: |
|
||||
require 'ext/table'
|
||||
require 'ext/string'
|
||||
require 'constants'
|
||||
require 'util'
|
||||
require 'widget'
|
||||
require 'messagebox/messagebox'
|
||||
require 'dispatcher'
|
||||
|
||||
require 'widget'
|
||||
require 'ui'
|
||||
require 'gfx'
|
||||
require 'messagebox/messagebox'
|
||||
return true
|
||||
|
||||
onUnload: |
|
||||
rootWidget = nil
|
||||
|
||||
|
26
modules/core/gfx.lua
Normal file
26
modules/core/gfx.lua
Normal file
@@ -0,0 +1,26 @@
|
||||
GFX = { }
|
||||
|
||||
function GFX.fadeIn(widget, time, elapsed)
|
||||
if not elapsed then elapsed = 0 end
|
||||
if not time then time = 250 end
|
||||
widget:setOpacity(math.min((255*elapsed)/time, 255))
|
||||
if elapsed < time then
|
||||
scheduleEvent(function()
|
||||
GFX.fadeIn(widget, time, elapsed + 30)
|
||||
end, 30)
|
||||
end
|
||||
end
|
||||
|
||||
function GFX.fadeOut(widget, time, elapsed)
|
||||
if not elapsed then elapsed = 0 end
|
||||
if not time then time = 250 end
|
||||
widget:setOpacity((255*(time - elapsed))/time)
|
||||
if elapsed < time then
|
||||
scheduleEvent(function()
|
||||
GFX.fadeOut(widget, time, elapsed + 30)
|
||||
end, 30)
|
||||
else
|
||||
widget:destroy()
|
||||
end
|
||||
end
|
||||
|
22
modules/core/ui.lua
Normal file
22
modules/core/ui.lua
Normal file
@@ -0,0 +1,22 @@
|
||||
UI = { }
|
||||
UI.root = getRootWidget()
|
||||
|
||||
function UI.loadAndDisplayLocked(otuiFile)
|
||||
local widget = loadUI(otuiFile, UI.root)
|
||||
UI.root:lockChild(widget)
|
||||
return widget
|
||||
end
|
||||
|
||||
function UI.loadAndDisplay(otuiFile)
|
||||
local widget = loadUI(otuiFile, UI.root)
|
||||
return widget
|
||||
end
|
||||
|
||||
function UI.display(widget)
|
||||
UI.root:addChild(widget)
|
||||
end
|
||||
|
||||
function UI.displayLocked(widget)
|
||||
UI.root:addChild(widget)
|
||||
UI.root:lockChild(widget)
|
||||
end
|
Reference in New Issue
Block a user