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

function PostLoad(screen)
	game_state.title = CreateTextEntity("Calisto_MT_31", GetString("Q_DELETE_TITLE"))
	game_state.title:AttachTo(screen:GetObject('BG'))
	game_state.title:SetZ(90)
	game_state.title:SetY(-110)
    game_state.te = CreateTextEntity("SchoolbookBI31", GetString("Q_DELETE"))
	game_state.te:AttachTo(screen:GetObject('BG'))
	game_state.te:SetScale(0.8)
	game_state.te:SetZ(90)
	game_state.te:SetY(-60)
end

function OnButtonPress(title)    
    dialog:SetAllowInput(false) 
    local move_time = 0.1
    
    DefaultOnButtonPress(title)
    
    local arrow = dialog:GetObject('strelka')
	
	local af = CreateAnimationEffector()	
	af:AttachTo(arrow)
	af:SetMode(_ANIM_FWD + _ANIM_NOLOOP)
	af:SetKey(_TRACK_A, 0, arrow:GetAngle());
    
    DefaultOnButtonPress(title)
    
    local OnMoveFinish = function()            
        DefaultOnButtonPress(title)
        if title == "No" then          
            dialog:ScreenDestroy()
        end
        if title == "Yes" then            
            dialog:ScreenDestroy()
            local profile_manager = GetProfileManager()
            profile_manager:DeleteProfile(dialog.profile_to_delete) --profile_manager:GetCurrentProfile():GetName())
            if profile_manager:GetProfileCount() ~= 0 then
			    profile_manager:SetCurrentProfile(profile_manager:GetFirstProfile():GetName())
			end
        end
    end
    
    if title == "Yes" then
		af:SetKey(_TRACK_A, move_time, -45 / 180 * M_PI);
	end
	if title == "No" then
	    af:SetKey(_TRACK_A, move_time, 45 / 180 * M_PI);		
	end	
    
    af:Play()
	TimerDo(dialog:GetTimer(), move_time, OnMoveFinish, title)
end
