feat: add delay to screen changes
This commit is contained in:
parent
e902ad6d82
commit
13803e7560
2 changed files with 27 additions and 16 deletions
|
@ -43,26 +43,32 @@ end
|
|||
|
||||
function GuiScreen:showSimple(focusElement, widgetId, page)
|
||||
focusElement = focusElement or self.defaultFocus
|
||||
local time = 0
|
||||
if (not self.isVisible) then
|
||||
self.isVisible = true
|
||||
local delay = 0
|
||||
if (self.set ~= nil) then
|
||||
delay = self.set:setCurrentScreen(self.name)
|
||||
end
|
||||
|
||||
if (self.transforms["show"] ~= nil) then
|
||||
time = self:playTransform("show")
|
||||
if (delay == 0) then
|
||||
self:showWithSubScreen(focusElement, widgetId, page)
|
||||
else
|
||||
self.tweens:newFunc(delay, "focus", function () self:showWithSubScreen(focusElement, widgetId, page) end)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function GuiScreen:showWithSubScreen(focusElement, widgetId, page)
|
||||
self:playTransform("show")
|
||||
if (focusElement ~= nil) then
|
||||
self.gui:setFocus(focusElement, widgetId, page)
|
||||
end
|
||||
|
||||
if (self.subscreens ~= nil) then
|
||||
self.subscreens:show()
|
||||
end
|
||||
|
||||
if (self.set ~= nil) then
|
||||
self.set:setCurrentScreen(self.name)
|
||||
end
|
||||
|
||||
if (focusElement) then
|
||||
self.tweens:newFunc(time, "focus", function () self.gui:setFocus(focusElement, widgetId, page) end)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function GuiScreen:setDatas(datas)
|
||||
|
@ -70,9 +76,10 @@ function GuiScreen:setDatas(datas)
|
|||
end
|
||||
|
||||
function GuiScreen:hide()
|
||||
local time = 0
|
||||
if (self.isVisible) then
|
||||
if (self.transforms["hide"] ~= nil) then
|
||||
local time = self:playTransform("hide")
|
||||
time = self:playTransform("hide")
|
||||
self.tweens:newFunc(time, "hide", function ()
|
||||
self.isVisible = false
|
||||
end)
|
||||
|
@ -82,7 +89,7 @@ function GuiScreen:hide()
|
|||
self.subscreens:hideCurrent()
|
||||
end
|
||||
end
|
||||
|
||||
return time
|
||||
end
|
||||
|
||||
function GuiScreen:addTransform(name, transform)
|
||||
|
|
|
@ -29,6 +29,7 @@ function ScreenSet:new(owner)
|
|||
self.defaultScreen = ""
|
||||
self.currentScreen = ""
|
||||
self.owner = owner
|
||||
self.delay = 0
|
||||
end
|
||||
|
||||
function ScreenSet:show(screenName)
|
||||
|
@ -47,15 +48,18 @@ end
|
|||
|
||||
function ScreenSet:setCurrentScreen(screenName)
|
||||
screenName = screenName or self.defaultScreen
|
||||
self:hideCurrent()
|
||||
local time = self:hideCurrent() + self.delay
|
||||
self.currentScreen = screenName
|
||||
return time
|
||||
end
|
||||
|
||||
function ScreenSet:hideCurrent()
|
||||
local time = 0
|
||||
if (self.currentScreen ~= "") then
|
||||
self.set[self.currentScreen]:hide()
|
||||
time = self.set[self.currentScreen]:hide()
|
||||
self.currentScreen = ""
|
||||
end
|
||||
return time
|
||||
end
|
||||
|
||||
function ScreenSet:add(screen, setAsDefault)
|
||||
|
|
Loading…
Reference in a new issue