parent
2abe962aa9
commit
afc197f2dc
@ -0,0 +1,28 @@
|
||||
local eventId = 1
|
||||
local events = { }
|
||||
local orig = { scheduleEvent = scheduleEvent,
|
||||
addEvent = addEvent }
|
||||
|
||||
-- fix original scheduleEvent
|
||||
function scheduleEvent(func, delay)
|
||||
eventId = eventId + 1
|
||||
local id = eventId + 1
|
||||
local function proxyFunc()
|
||||
func()
|
||||
table[id] = nil
|
||||
end
|
||||
table[id] = proxyFunc
|
||||
orig.scheduleEvent(proxyFunc, delay)
|
||||
end
|
||||
|
||||
-- fix original addEvent
|
||||
function addEvent(func)
|
||||
eventId = eventId + 1
|
||||
local id = eventId + 1
|
||||
local function proxyFunc()
|
||||
func()
|
||||
table[id] = nil
|
||||
end
|
||||
table[id] = proxyFunc
|
||||
orig.addEvent(proxyFunc)
|
||||
end
|
@ -0,0 +1,26 @@
|
||||
GFX = { }
|
||||
|
||||
function GFX.fadeIn(widget, time, elapsed)
|
||||
if not elapsed then elapsed = 0 end
|
||||
if not time then time = 750 end
|
||||
widget.opacity = 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 = 750 end
|
||||
widget.opacity = (255*(time - elapsed))/time
|
||||
if elapsed < time then
|
||||
scheduleEvent(function()
|
||||
GFX.fadeOut(widget, time, elapsed + 30)
|
||||
end, 30)
|
||||
else
|
||||
widget:destroy()
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,15 @@
|
||||
Module
|
||||
name: gfx
|
||||
description: Contains utilities for generating graphics effects
|
||||
author: OTClient team
|
||||
website: https://github.com/edubart/otclient
|
||||
version: 0.2
|
||||
autoLoad: true
|
||||
dependencies:
|
||||
- core
|
||||
|
||||
onLoad: |
|
||||
require 'gfx'
|
||||
return true
|
||||
|
||||
|
Loading…
Reference in new issue