Refonte pour utiliser le systeme de GUI #112
2 changed files with 27 additions and 16 deletions
|
@ -43,26 +43,32 @@ end
|
||||||
|
|
||||||
function GuiScreen:showSimple(focusElement, widgetId, page)
|
function GuiScreen:showSimple(focusElement, widgetId, page)
|
||||||
focusElement = focusElement or self.defaultFocus
|
focusElement = focusElement or self.defaultFocus
|
||||||
local time = 0
|
|
||||||
if (not self.isVisible) then
|
if (not self.isVisible) then
|
||||||
self.isVisible = true
|
self.isVisible = true
|
||||||
|
local delay = 0
|
||||||
|
if (self.set ~= nil) then
|
||||||
|
delay = self.set:setCurrentScreen(self.name)
|
||||||
|
end
|
||||||
|
|
||||||
if (self.transforms["show"] ~= nil) then
|
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
|
end
|
||||||
|
|
||||||
if (self.subscreens ~= nil) then
|
if (self.subscreens ~= nil) then
|
||||||
self.subscreens:show()
|
self.subscreens:show()
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
function GuiScreen:setDatas(datas)
|
function GuiScreen:setDatas(datas)
|
||||||
|
@ -70,9 +76,10 @@ function GuiScreen:setDatas(datas)
|
||||||
end
|
end
|
||||||
|
|
||||||
function GuiScreen:hide()
|
function GuiScreen:hide()
|
||||||
|
local time = 0
|
||||||
if (self.isVisible) then
|
if (self.isVisible) then
|
||||||
if (self.transforms["hide"] ~= nil) then
|
if (self.transforms["hide"] ~= nil) then
|
||||||
local time = self:playTransform("hide")
|
time = self:playTransform("hide")
|
||||||
self.tweens:newFunc(time, "hide", function ()
|
self.tweens:newFunc(time, "hide", function ()
|
||||||
self.isVisible = false
|
self.isVisible = false
|
||||||
end)
|
end)
|
||||||
|
@ -82,7 +89,7 @@ function GuiScreen:hide()
|
||||||
self.subscreens:hideCurrent()
|
self.subscreens:hideCurrent()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
return time
|
||||||
end
|
end
|
||||||
|
|
||||||
function GuiScreen:addTransform(name, transform)
|
function GuiScreen:addTransform(name, transform)
|
||||||
|
|
|
@ -29,6 +29,7 @@ function ScreenSet:new(owner)
|
||||||
self.defaultScreen = ""
|
self.defaultScreen = ""
|
||||||
self.currentScreen = ""
|
self.currentScreen = ""
|
||||||
self.owner = owner
|
self.owner = owner
|
||||||
|
self.delay = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
function ScreenSet:show(screenName)
|
function ScreenSet:show(screenName)
|
||||||
|
@ -47,15 +48,18 @@ end
|
||||||
|
|
||||||
function ScreenSet:setCurrentScreen(screenName)
|
function ScreenSet:setCurrentScreen(screenName)
|
||||||
screenName = screenName or self.defaultScreen
|
screenName = screenName or self.defaultScreen
|
||||||
self:hideCurrent()
|
local time = self:hideCurrent() + self.delay
|
||||||
self.currentScreen = screenName
|
self.currentScreen = screenName
|
||||||
|
return time
|
||||||
end
|
end
|
||||||
|
|
||||||
function ScreenSet:hideCurrent()
|
function ScreenSet:hideCurrent()
|
||||||
|
local time = 0
|
||||||
if (self.currentScreen ~= "") then
|
if (self.currentScreen ~= "") then
|
||||||
self.set[self.currentScreen]:hide()
|
time = self.set[self.currentScreen]:hide()
|
||||||
self.currentScreen = ""
|
self.currentScreen = ""
|
||||||
end
|
end
|
||||||
|
return time
|
||||||
end
|
end
|
||||||
|
|
||||||
function ScreenSet:add(screen, setAsDefault)
|
function ScreenSet:add(screen, setAsDefault)
|
||||||
|
|
Loading…
Reference in a new issue