-------------------------------------------------------------------------------
PopUpScreenManagerClass = CreateInheritedClass(LuaStack)
-------------------------------------------------------------------------------
function PopUpScreenManagerClass:push(screen, hideActiveScreen, onScreenDestroyHandler, time_show)
    hideActiveScreen = (hideActiveScreen == nil and true or hideActiveScreen)
	screen.onDestroyHandler = onScreenDestroyHandler
	
    local curScr = self:GetTop()
    local orderCurScr = 1.0
    if curScr then
        if hideActiveScreen then
            curScr:hide(time_show)
        else
            curScr:stop()
        end
        
        orderCurScr = curScr:getWindow():getOrder()
    end
    
    LuaStack.Push(self, screen)
    
    screen:getWindow():setOrder(orderCurScr + 1)
    screen:show(time_show)
end
-------------------------------------------------------------------------------
function PopUpScreenManagerClass:destroyScreen(screen)
    assert(screen)

    if screen.onDestroyHandler then
        screen.onDestroyHandler()
    end
    
    screen:destroyScreen()
end
-------------------------------------------------------------------------------
function PopUpScreenManagerClass:pop()
    local curScr = self:GetTop()
    assert(curScr ~= nil)
    
    LuaStack.Pop(self)
    
    self:destroyScreen(curScr)
    
    curScr = self:GetTop()
    if curScr then
		if not curScr:isVisible() then
			curScr:show()
		end
		curScr:go()
    end
end
-------------------------------------------------------------------------------
function PopUpScreenManagerClass:destroyAll()
    local screen = PopUpScreensMgr:GetTop()
    while (screen)
    do
        self:destroyScreen(screen)
        LuaStack.Pop(self)
        screen = PopUpScreensMgr:GetTop()
    end
    
    --TODO: вместо InteractiveHelp нужно использовать Tutorial
    if InteractiveHelp then
        InteractiveHelp.tutorialScreen = nil
    end
end
-------------------------------------------------------------------------------
PopUpScreensMgr = PopUpScreenManagerClass:New()
-------------------------------------------------------------------------------
