pMap = GetBoolParam("map", true)
pQuicksave = GetBoolParam("quicksave", true)

function init()
	frame = 0
	pickFrame = 0
	grabFrame = 0
	mapFrame = 0
	
	usedMap = false
	usedTool = false
	usedVehicle = false
	usedGrab = false
	usedThrow = false
	
	escapeNotification = false
	mapNotification = false
	saveNotification = false
	escapeFrame=0
end


function notify(str, t)
	SetString("hud.notification", str)
	SetInt("hud.notification.numicons", 0)
end

function notifyIcon1(fmt, str, t)
	SetString("hud.notification", fmt)
	SetInt("hud.notification.numicons", 1)
	SetString("hud.notification.icon1", str)
end

function notifyIcon4(fmt, str1, str2, str3, str4, t)
	SetString("hud.notification", fmt)
	SetInt("hud.notification.numicons", 4)
	SetString("hud.notification.icon1", str1)
	SetString("hud.notification.icon2", str2)
	SetString("hud.notification.icon3", str3)
	SetString("hud.notification.icon4", str4)
end

function tick(dt)
	local missionDone = (frame > 60 and not GetBool("level.alarm") and GetBool("level.complete"))
	local alarm = GetBool("level.alarm")

	--Track game state
	if not usedMap and GetBool("game.map.enabled") then 
		usedMap = true 
	end
	if GetBool("game.paused") then
		return
	end
	
	--Generic hints. Only show if no other notifications are showing.
	if pMap then
		if not GetBool("hud.hasnotification") then
			if (frame%1500 == 300) and not usedMap and not missionDone and not alarm then
				local s = string.upper(GetString("game.input.map.icon"))
				if s ~= "" then
					notifyIcon1("Îãêðìöé # èï¿ óôòõðòöôã îãôöº ì üéïéí", s, 4)
				else
					s = string.upper(GetString("game.input.map"))
					notify("Îãêðìöé "..s.." èï¿ óôòõðòöôã îãôöº ì üéïéí", 4)
				end
			end
		end
	end

	if pQuicksave and not GetBool("hud.hasnotification") then
		if (frame > 4000) and usedMap and not saveNotification and not missionDone and not alarm then
			local s = string.upper(GetString("game.input.pause.icon"))
			if s ~= "" then
				notifyIcon1("Òòûôãñìöé óôòçôéõõ å ï¾äòé åôéð¿, ñãêãå îñòóîù # ì åºäôãå äºõöô. õòûô.", s, 4)
			else
				s = string.upper(GetString("game.input.pause"))
				notify("Òòûôãñìöé óôòçôéõõ å ï¾äòé åôéð¿, ñãêãå îñòóîù "..s.." ì åºäôãå äºõöô. õòûô.", 4)
			end
			saveNotification = true
		end
	end
	
	if GetBool("game.map.enabled") then
		mapFrame = mapFrame + 1
		if mapFrame > 60 and not mapNotification then
			local s1 = string.upper(GetString("game.input.lmb.icon"))
			local s2 = string.upper(GetString("game.input.mousex.icon"))
			local s3 = string.upper(GetString("game.input.scroll_up.icon"))
			local s4 = string.upper(GetString("game.input.scroll_down.icon"))
			if s1 ~= "" and s2 ~= "" and s3 ~= "" and s4 ~= "" then
				notifyIcon4("Drag and zoom map with #", s1, s2, s3, s4, 4)
			else
				notify("Äåìçãíöé, ðéñ¿íöé ðãõþöãä îãôöº õ óòðòÿ¼¾ ðºþì.", 4)
			end
			mapNotification = true
		end
	end

	if missionDone and not GetBool("game.map.enabled") then
		if escapeFrame%600==0 then
			notify("Íìõõì¿ åºóòïñéñã. Áéçìöé î õåòéðù öôãñõóòôöù.", 4)
		end
		escapeFrame = escapeFrame + 1
	end
end


function update(dt)
	if GetBool("game.paused") or GetBool("game.map.enabled") then
		return
	end
	frame = frame + 1
end
