dofile ('Data/Scripts/Common/Utils/TutorialBase.lua')

class 'Tutorial' (TutorialBase)

function Tutorial:__init(gameScene, tips)
	TutorialBase.__init(self, gameScene, tips)
	self.showTipDelay = 0.0	
end

function Tutorial:showRequestDialog( callback )
	if not getPlayModeParameters().tutorialEnabled then -- not isCasualPlayMode()
		return
	end

	if self:isRequested() then
		callback( self:isActive(), true )
	else
		self.scene:getPlayField():getMouseBlocker():push()

		createYesNoScreen('INTERACTIVE_HELP_NEEDED',
							bind(self.onRequested, self, callback, true),
							bind(self.onRequested, self, callback, false),
							false,
                            nil,
                            YES_NO_SCREEN_INTERACTIVE_HELP_HEADER)
	end
end
-------------------------------------------------------------------------------



-------------------------------------------------------------------------------
-- TIPS REGISTRATION
-------------------------------------------------------------------------------
Tutorial.tips = {}

-------------------------------------------------------------------------------
Tutorial.tips['CLOCK_SCREEN_CLICK'] =
{
constructor =
		function (screen, clock_screen)		
			local target = clock_screen:getEntityNamed(clock_screen.clock_name)	

			screen:setWindowPosition( Vector2f(512, 240) )

			screen:addArrowPointerAtObject( target )
			screen:setForcedObject( target )
		end,

completeCondition =
		function (id)
			return HasGameState('CLOCK_SCREEN_CLICKED', nil, GENERAL_TAG_NAME)
		end

}
-------------------------------------------------------------------------------

-------------------------------------------------------------------------------
Tutorial.tips['FLYNOTE_CLICK'] =
{
constructor =
		function (screen)		
			local target = current_scene:getPlayField():getEntityNamed('area_click_note')	
			
			screen:setWindowPosition( Vector2f(500, 250) )
			screen:addArrowPointerAtObject( target )
			screen:setForcedObject( target )	
		end,

completeCondition =
		function (id)
			return current_scene:getPlayField():isObjectClicked('area_click_note')
		end

}
-------------------------------------------------------------------------------

Tutorial.tips['PHONE'] =
{
constructor =
		function (screen)		
			local target = current_scene:getPanel():getControlsPanel():getEntityNamed('bttn_phone')	

			local pos	= Vector2f(target:getScrX()-150, target:getScrY())
			local size	= Vector2f(100, 150)
			local rect	= screen:addRect(pos, size)

			screen:setWindowPosition( Vector2f(440, 400) )

			screen:addArrowPointerAtObject( target )
			screen:setConfirmCallback(	function(e)
											if e.target:getName() == rect:getName() then
												current_scene:getPanel():getControlsPanel():onPhoneButtonClick(function()
												        current_scene:getTutorial():showTip( 'PANEL_LOCK', 0 )
                                                    end)
											else
											    current_scene:getTutorial():showTip( 'PANEL_LOCK', 0 )
											end											
										end)
		end,

}
-------------------------------------------------------------------------------
Tutorial.tips['PHOTO_CLICK'] =
{
constructor =
		function (screen)		
			local target = current_scene:getPlayField():getEntityNamed('area_find_photo')	
			
			screen:setWindowPosition( Vector2f(300, 450) )
			screen:addArrowPointerAtObject( target )
			screen:setForcedObject( target )	
		end,

completeCondition =
		function (id)
			return current_scene:getPlayField():isObjectClicked('area_find_photo')
		end

}
-------------------------------------------------------------------------------
Tutorial.tips['CLOCK_CLICK'] =
{
constructor =
		function (screen)		
			local target = current_scene:getPlayField():getEntityNamed('area_click_clock_1')	
			
			screen:setWindowPosition( Vector2f(300, 350) )
			screen:addArrowPointerAtObject( target )
			screen:setForcedObject( target )	
		end,

completeCondition =
		function (id)
			return current_scene:getPlayField():isObjectClicked('area_click_clock_1')
		end

}
-------------------------------------------------------------------------------
Tutorial.tips['PANEL_LOCK'] =
{
	constructor =
		function (screen)		
			local level = current_scene:getPlayField()
			local panel = level:getPanel():getControlsPanel()
			local target_1 = current_scene:getPanel():getControlsPanel():getEntityNamed('bttn_lock_on')
			local target_2 = current_scene:getPanel():getControlsPanel():getEntityNamed('bttn_clock')

			panel:setBottomPanelVisible(true, nil, 't_panel_lock')		

			screen:setWindowPosition( Vector2f(512, 400) )
			screen:addArrowPointerAtObject( target_1 )
			screen:addArrowPointerAtObject( target_2 )	
			screen:closeOnPress()	

			screen:setConfirmCallback(	function(e)										
											panel:setBottomPanelVisible(false, nil, 't_panel_lock')
											
											current_scene:getTutorial():showTip( 'PHOTO_CLICK', 0 )	
										end )
		end,
}
-------------------------------------------------------------------------------

Tutorial.tips['ZOOM_ZONE'] =
{
	constructor =
		function (screen)
			local target = current_scene:getPlayField():getEntityNamed('area_zoom_Fishing_net')

			screen:setWindowPosition( Vector2f(650, 250) )
			screen:addArrowPointerAtObject( target )
			screen:setForcedObject( target )
		end,

	completeCondition =
		function (id)
			return isZoomZoneVisited('Fishing_net', current_scene:getPlayField():getName())
		end
}
-------------------------------------------------------------------------------

Tutorial.tips['FLYNOTE'] =
{
	constructor =
		function (screen)
			local target = current_scene:getPlayField():getEntityNamed('area_click_note_paper')

			screen:setWindowPosition( Vector2f(210, 200) )
			screen:addArrowPointerAtObject( target )
			screen:setForcedObject( target )
		end,

	completeCondition =
		function (id)
			return current_scene:getPlayField():isNoteAdded('Note_01_paper')
		end
}
-------------------------------------------------------------------------------

Tutorial.tips['NOTEBOOK'] =
{
	constructor =
		function (screen)
			screen:setWindowPosition( Vector2f(650, 400) )

			--[[
			local target = current_scene:getPanel():getControlsPanel().bttn_diary
			screen:addArrowPointerAtObject( target )
			screen:setForcedObject( target )
			--]]

			
			local pos	= Vector2f(150,720)
			local size	= Vector2f(100,150)
			local rect	= screen:addRect(pos, size)

			screen:addArrowPointerAt( pos )
			screen:setConfirmCallback(	function(e)
											if e.target:getName() == rect:getName() then
												current_scene:getPanel():getControlsPanel():onNotesButtonClick()
											end
										end)
		end,

	-- completeCondition =
	-- 	function (id)
	-- 		return current_scene:getPlayField():isObjectClicked('area_zoom_paper')
	-- 	end
}
-------------------------------------------------------------------------------

Tutorial.tips['FIND_TOOL'] =
{
	constructor =
		function (screen)
			local target = current_scene:getPlayField():getEntityNamed('area_find_zf_number_key_1')

			screen:setWindowPosition( Vector2f(300, 150) )
			screen:addArrowPointerAtObject( target )
			screen:setForcedObject( target )
		end,

	completeCondition =
		function (id)
			return IsToolFound('01_number_key_1')
		end
}
-------------------------------------------------------------------------------

Tutorial.tips['APPLY_TOOL'] =
{
	constructor =
		function (screen)
			local level = current_scene:getPlayField()
			local panel = level:getPanel():getControlsPanel()
			local inv 	= level:getInventory()
			local target = level:getEntityNamed('area_apply_zf_pliers')			
			local tool_info = inv:getToolInfoByName('01_pliers')
			local cell_info = inv:getCellInfoByToolInfo(tool_info)

			panel:setBottomPanelVisible(true, nil, 't_panel_lock')

			screen:setWindowPosition( Vector2f(250, 450) )
			screen:addArrowPointerAtObject( target )
			screen:addArrowPointerAtObject( cell_info.cell_entity )
			screen:setForcedObject( cell_info.cell_entity )

			screen:setConfirmCallback(	function(e)										
											panel:setBottomPanelVisible(false, nil, 't_panel_lock')	
										end )			
		end,

	completeCondition =
		function (id)
			return IsToolApplied('01_pliers')
		end
}
-------------------------------------------------------------------------------

Tutorial.tips['HINT'] =
{
constructor =
		function (screen)
			screen:setWindowPosition( Vector2f(650, 400) )			
			
			local pos	= Vector2f(920,700)
			local size	= Vector2f(150,150)		
			screen:addArrowPointerAt( pos )
			screen:closeOnPress()

			screen:setConfirmCallback(	function(e)		
											current_scene:getTutorial():showTip( 'ZOOM_ZONE', 0 )	
										end )
		end,	
}
-------------------------------------------------------------------------------

Tutorial.tips['NUTBOX'] =
{
constructor =
		function (screen)
			screen:setWindowPosition( Vector2f(500, 350) )

			--[[
			local target = current_scene:getPanel():getControlsPanel().bttn_diary
			screen:addArrowPointerAtObject( target )
			screen:setForcedObject( target )
			--]]

			
			local pos	= Vector2f(880,710)
			local size	= Vector2f(150,150)
			local rect	= screen:addRect(pos, size)

			screen:addArrowPointerAt( pos )
			screen:setConfirmCallback(	function(e)
											if e.target:getName() == rect:getName() then
												current_scene:getPanel():getControlsPanel():onNutBoxClick()
											end
										end)
		end,

	-- completeCondition =
	-- 	function (id)
	-- 		return current_scene:getPlayField():isObjectClicked('area_click_ballerina')
	-- 	end
}
-------------------------------------------------------------------------------

Tutorial.tips['LINK_SCENE'] =
{
	constructor =
		function (screen)
			local target = current_scene:getPlayField():getEntityNamed('area_link_02')

			screen:setWindowPosition( Vector2f(300, 450) )
			screen:addArrowPointerAtObject( target )
			screen:setForcedObject( target )
			screen:closeOnPress()
		end,

	-- completeCondition =
	-- 	function (id)
	-- 		return current_scene:getPlayField():isObjectClicked('area_click_link_02')
	-- 	end
}
-------------------------------------------------------------------------------

Tutorial.tips['MG_SKIP'] =
{
	constructor =
		function (screen)
			screen:setWindowPosition( Vector2f(650, 400) )			
			
			local pos	= Vector2f(920,700)
			local size	= Vector2f(150,150)
			local rect	= screen:addRect(pos, size)

			screen:addArrowPointerAt( pos )
			screen:closeOnPress()
			--[[screen:setConfirmCallback(	function(e)
											if e.target:getName() == rect:getName() then
												current_scene:getPanel():getControlsPanel():getHintAnimationLogic():onSkipButtonClick()
											end
										end)]]
		end,	
}
-------------------------------------------------------------------------------

Tutorial.tips['HO_ZONE'] =
{
	constructor =
		function (screen)
			local target = current_scene:getPlayField():getEntityNamed('area_link_ho')

			screen:setWindowPosition( Vector2f(210, 150) )
			screen:addArrowPointerAtObject( target )
			screen:closeOnPress()
			screen:setForcedObject( target )
		end,
}
-------------------------------------------------------------------------------

Tutorial.tips['HO_DRAG'] =
{
	constructor =
		function (screen)
			local target_1 = current_scene:getPlayField():getEntityNamed('area_get_badge')
			local target_2 = current_scene:getPlayField():getEntityNamed('area_drop_badge')

			screen:setWindowPosition( Vector2f(750, 300) )
			screen:addArrowPointerAtObject( target_1 )
			screen:addArrowPointerAtObject( target_2 )
			screen:setForcedObject( target_1 )
		end,

	-- completeCondition =
	-- 	function (id)
	-- 		return current_scene:getPlayField():isAmuletUsed('air', 'area_apply_amulet')
	-- 	end
}
-------------------------------------------------------------------------------

Tutorial.tips['HO_TASK'] =
{
	constructor =
		function (screen)
			local target = current_scene:getPlayField():getEntityNamed('amphora')

			screen:setWindowPosition( Vector2f(650, 300) )
			screen:addArrowPointerAtObject( target )
			--screen:addArrowPointerAtObject( current_scene:getPlayField():getEntityNamed('area_drop_badge') )
			screen:setForcedObject( target )

			screen:setConfirmCallback(	function(e)
											current_scene:getTutorial():showTip( 'HO_MATCH3', 0 )
										end )
		end,
}
-------------------------------------------------------------------------------

Tutorial.tips['HO_HINT'] =
{
	constructor =
		function (screen)
			screen:setWindowPosition( Vector2f(650, 400) )
			
			local pos	= Vector2f(920,700)
			local size	= Vector2f(150,150)
			local rect	= screen:addRect(pos, size)

			screen:addArrowPointerAt( pos )
			screen:closeOnPress()
			screen:setConfirmCallback(	function(e)
											if e.target:getName() == rect:getName() then
												current_scene:getPanel():getControlsPanel():getHintAnimationLogic():onHintButtonClick()
											end
										end)
		end,
}
-------------------------------------------------------------------------------

Tutorial.tips['HO_MATCH3'] =
{
	constructor =
		function (screen)
			local target = current_scene:getPanel():getControlsPanel():getEntityNamed('bttn_m3')

			screen:setWindowPosition( Vector2f(650, 250) )
			screen:addArrowPointerAtObject( target )
			
			local pos	 = current_scene:getPanel():getControlsPanel():getMainEntity():screenToLocal(target:getScrPosition())
			local target = target:getBoundingBox()			
			local size	= Vector2f(target:getWidth(), target:getHeight())
			local rect	= screen:addRect(pos, size)

			screen:closeOnPress()
			
			screen:setConfirmCallback(	function(e)
											if e.target:getName() == rect:getName() then
											    current_scene:getPanel():getControlsPanel():OnM3ButtonClick()
											end											
										end)
		end,
}
-------------------------------------------------------------------------------