
QuitConfirm.visible = false
QuitConfirm.current = 0
QuitConfirm.del_slot = -1

----------------------------------------------------------------------------------------------------
function QuitConfirm_INIT()
    QuitConfirm:set_element_eh('confirm_back', function() end)
    QuitConfirm:set_element_eh('btn_no_01', function()
            QuitConfirm:hide()
        end)
    QuitConfirm:set_element_eh('btn_yes_01', function()
            save_game()
            shutdown()
        end)
    QuitConfirm:set_element_eh('btn_no_02', function()
            QuitConfirm:hide()
        end)
    QuitConfirm:set_element_eh('btn_yes_02', function()
            shutdown()
        end)
    QuitConfirm:set_element_eh('btn_no_03', function()
            QuitConfirm.del_slot = -1
            QuitConfirm:hide()
        end)
    QuitConfirm:set_element_eh('btn_yes_03', function()
            if QuitConfirm.del_slot ~= -1 then
                ProfileList:delete(QuitConfirm.del_slot)
                QuitConfirm.del_slot = -1
                ProfileScreen:onShow()
            end
            QuitConfirm:hide()
        end)

end

----------------------------------------------------------------------------------------------------
function QuitConfirm_UPDATE()
	return 0
end

----------------------------------------------------------------------------------------------------
function QuitConfirm:show(params)
    local screens = {'panel_01', 'panel_02', 'panel_03'}

    local scr = 2
    if params ~= nil and params.del_slot ~= nil and QuitConfirm.current ~= 3 then
        QuitConfirm.del_slot = params.del_slot
        scr = 3
    elseif QuitConfirm.visible and QuitConfirm.current ~= 3 then
        return
    end

    if HOLevel.current == nil and scr ~= 3 then
        scr = 1
    end

    QuitConfirm.visible = true
    QuitConfirm.current = scr

    QuitConfirm:set_visible(true)
    QuitConfirm:set_active(true)

    for i = 1, #screens do
        QuitConfirm:get_element(screens[i]):setVisible(i == scr)
    end
end

----------------------------------------------------------------------------------------------------
function QuitConfirm:hide()
    if not QuitConfirm.visible then
        return
    end

    QuitConfirm.visible = false
    QuitConfirm.current = 0

    QuitConfirm:set_visible(false)
    QuitConfirm:set_active(false)
end

