--script de la classe vignette
--pour la navigation
.namespace LocationPhoto


function OnEnable()
end

function OnWbpMouseLDown()
	return true
end


function OnWbpMouseLUp()
	if not CanClickOn() then
		return false
	end
	if self.active == false then
		return false
	end
	if NewTutorialManager.g_message == "TU_07" then
		NewTutorialManager.ClosePopupTuto()
	end		
	NavigationManager.SwitchTo(nil,self.Lieu)

	PlaySoundEffect("int_hoverloc")

	return true
end

function SetCursor()
	Cursor.ChangeCursor(CURSOR_GENERIQUE)
	return true
end


function IIM_OnMouseOnDo()
	if not self.CanClickOn() then
		return
	end

		PlaySoundEffect("int_hoverloc")
		SetTextToThisVignette()

		for i=1,5 do
			vignette = OPUnitFactory.GetUnit("Location_polaroid0"..i)
			if vignette.Name ~= self.Name then
					vignette.Rotation = 0.2
					vignette.Scale_X = 0.75
					vignette.Scale_Y = 0.75
					vignette.Layer = LayerPopup
					vignette.Color.g = 128
					vignette.Color.b = 128
					vignette.Color.r = 128
			end
		end	
		self.Scale_X = 1
		self.Scale_Y = 1
		self.Rotation = 0
		self.Layer = LayerPopup01
		self.Color.g = 255
		self.Color.b = 255
		self.Color.r = 255

	
end


function SetTextToThisVignette()
		Locations_txt.Text =  GlobalFunctions.GetText(string.gsub(self.Lieu,"_SearchSite",""))
end

function CanClickOn()
	local res = IsVisible(self)

	res = res and ( IsEqualVariables("CurrentGamePhase","SearchSite") or IsEqualVariables("CurrentGamePhase","Closeup") 
					or  (IsEqualVariables("CurrentGamePhase","Tutorial")  and NewTutorialManager.g_state == "waitforaction" and NewTutorialManager.g_message == "TU_07"))
	
	return res
end