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

function PostLoad(screen)
	game_state.title = CreateTextEntity("Calisto_MT_31", GetString("Q_TUTORIAL_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_TUTORIAL"))
	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 InitButtons(screen)
    local up = screen:GetObject("buttonleftup"):GetAnimationPtr()
	local over = screen:GetObject("buttonleftover"):GetAnimationPtr()	
	local down = screen:GetObject("buttonleftdown"):GetAnimationPtr()	
	game_state.exit_button = CreateButton(up, over, down, "Yes", screen)
	game_state.exit_button:AttachTo(screen)
	game_state.exit_button:SetXY(484, 417)
	game_state.exit_button:SetZ(140)
	
	local up = screen:GetObject("buttonrightup"):GetAnimationPtr()
	local over = screen:GetObject("buttonrightover"):GetAnimationPtr()	
	local down = screen:GetObject("buttonrightdown"):GetAnimationPtr()	
	game_state.resume_button = CreateButton(up, over, down, "No", screen)
	game_state.resume_button:AttachTo(screen)
	game_state.resume_button:SetXY(565, 414)
	game_state.resume_button:SetZ(140)
end

function OnUpdate(dt)
	local ch = GetChar()
	
	if ch == HGEK_ESCAPE then
		dialog:ScreenDestroy()            
		play_field:Go()
	end
end

function OnButtonPress(title)
    dialog:SetAllowInput(false)    
    DefaultOnButtonPress(title)
        
    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()            
        if title == "No" then
			--GetProfileManager():GetCurrentProfile().is_missed_cigar_tutorial_shown = true
			GetProfileManager():SaveProfiles()
            dialog:ScreenDestroy()            
        end
        if title == "Yes" then
			--game_state.screen:Destroy();
            dialog:ScreenDestroy()
            game_state.is_tutorial_must_be_shown = true
	        game_state.locker:AddRef()
	        game_state.locked_objects['cigar4']	= true
        end
        play_field:Go()
    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

function OnMouseMove(previous_pos, current_pos)
end

function OnSetTool(tool)
end

function CanBeHinted(obj)
    if locked_object[obj] ~= true then
        return true
    else
        return false
    end
end

-- CLEAR_ON_SAVE_BEGIN
-- Do not edit code listed below (generated by the editor on each save)
function LoadData(screen)
	local anim = CreateAnimation('data/Texture/GUI/Options/front.png',0,0,597,186,1,0)
	anim:SetHotSpot(298,93)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('front',anim,524,472,136,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/pixel.jpg',0,0,8,8,1,0)
	anim:SetHotSpot(4,4)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	screen:CreateObject('pixel',anim,592,327,137,0,5,5)
	local anim = CreateAnimation('data/Texture/Scenes/Common/pixel.jpg',0,0,8,8,1,0)
	anim:SetHotSpot(4,4)
	anim:SetBlendMode(2)
	anim:SetColor('0x88FFFFFF')
	screen:CreateObject('bg',anim,512,384,88,0,128,96)
	local anim = CreateAnimation('data/Texture/GUI/Options/buttonbig.png',0,0,166,70,1,0)
	anim:SetHotSpot(83,35)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	screen:CreateObject('buttonbigup',anim,870,113,140,0,1,1)
	local anim = CreateAnimation('data/Texture/GUI/Options/buttonbig.png',0,70,166,70,1,0)
	anim:SetHotSpot(83,35)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	screen:CreateObject('buttonbigover',anim,864,159,100,0,1,1)
	local anim = CreateAnimation('data/Texture/GUI/Options/buttonbig.png',0,140,166,70,1,0)
	anim:SetHotSpot(83,35)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	screen:CreateObject('buttonbigdown',anim,858,221,100,0,1,1)
	local anim = CreateAnimation('data/Texture/GUI/Dialog/yes.png',0,0,88,72,1,0)
	anim:SetHotSpot(44,36)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	screen:CreateObject('buttonleftup',anim,522,48,100,0,1,1)
	local anim = CreateAnimation('data/Texture/GUI/Dialog/yes.png',0,72,88,72,1,0)
	anim:SetHotSpot(44,36)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	screen:CreateObject('buttonleftover',anim,530,88,101,0,1,1)
	local anim = CreateAnimation('data/Texture/GUI/Dialog/yes.png',0,144,88,72,1,0)
	anim:SetHotSpot(44,36)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	screen:CreateObject('buttonleftdown',anim,529,139,100,0,1,1)
	local anim = CreateAnimation('data/Texture/GUI/Dialog/no.png',0,0,86,68,1,0)
	anim:SetHotSpot(43,34)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	screen:CreateObject('buttonrightup',anim,866,51,100,0,1,1)
	local anim = CreateAnimation('data/Texture/GUI/Dialog/no.png',0,68,86,68,1,0)
	anim:SetHotSpot(43,34)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	screen:CreateObject('buttonrightover',anim,860,109,100,0,1,1)
	local anim = CreateAnimation('data/Texture/GUI/Dialog/no.png',0,136,86,68,1,0)
	anim:SetHotSpot(43,34)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	screen:CreateObject('buttonrightdown',anim,856,167,100,0,1,1)
	local anim = CreateAnimation('data/Texture/GUI/Dialog/BG.png',0,0,584,379,1,0)
	anim:SetHotSpot(292,189)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('BG',anim,523,361,100,0,1,1)
	local anim = CreateAnimation('data/Texture/GUI/Options/strelka.png',0,0,62,153,1,0)
	anim:SetHotSpot(26,116)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('strelka',anim,521,466,134,0,1,1)
end

function FreeData(screen)
end
-- CLEAR_ON_SAVE_END
