dofile('data/Lua/Screens/DialogYesNo.lua')

function OnSceneLoad(screen)
    LoadData(screen)

    dialog = screen
    dialog:SetAllowInput(true)
    local bttn_yes = create_button_ex(screen, 'data/Texture/GUI/Button/bttn_yes.png', 'yes', 403, 476, 110)
    bttn_yes:SetHotKey(HGEK_ENTER)
    local bttn_no = create_button_ex(screen, 'data/Texture/GUI/Button/bttn_no.png', 'no', 629, 476, 110)
    bttn_no:SetHotKey(HGEK_ESCAPE)
    SetCaptions(screen)
    PlaySound("opening_window")
    
    SetCursor( GetCursorArrow() )
    
    -- Create  darkening
    local anim = CreateAnimation('data/Texture/Scenes/Common/pixel.jpg',0,0,8,8,1,0)
	anim:SetHotSpot(4,4)
	anim:SetBlendMode(2)
	anim:SetColor('0xDD000000')
	screen:CreateObject('pixel_bg',anim,512,384,70,0,1280,960)
	
	screen:SetXY(171, 0)
end

function SetCaptions(screen)
	text = CreateTextEntity("WindowText28", GetString("Q_EXIT_TO_MENU"))
	text:AttachTo( screen:GetObject('YesNoScreen') )
	text:SetScale(1)
	text:SetZ(190)
	text:SetXY(-250, -80)
	text:SetBorderSize(500, 100)
	text:SetTextAlignment(HGETEXT_TOP + HGETEXT_CENTER)
end

function OnButtonPress(title)
    DefaultOnButtonPress(title)
    
    -- destroy this screen
    dialog:SetAllowInput(false)
    dialog:ScreenDestroy()
    dialog = nil
    
    if title == 'yes' then
        if game_state and game_state.screen_mini_game then
            game_state.screen_mini_game:Destroy()
        end
        ExitToMainMenu()
    end
    
    if title == 'no' then
        local screen = load_screen('data/Lua/Screens/OptionsScreen.lua')
        screen:SetLayer(LAYER_OPTIONS)
        
        if game_state and game_state.screen_mini_game then
            screen:SetXY(-200, 0)
        end
        
    end    
end
