------------------------------------------
-- Print On Screen Temp functions



-- old description
-- Prints the given message on the screen, for a duration based on the text's length. 
-- You can optionally specify a duration (in seconds). A duration of 0 will leave the text 
-- on the screen, and you will have to remove it manually with PrintOnScreen_RemoveFromScreen()
-- @result Void
-- @args String text, [Integer duration]



--? @shortdesc Prints a message on the screen
--? @extdesc
--? Prints the given message on the screen. It will stay there until you call PrintOnScreen_RemoveFromScreen()
--? or print another message on the screen to replace it.
--? @result Void
--? @args String text
function PrintOnScreen(...)

	local text = arg[1]
	local duration = 2 + (string.len(text)*0.15)		-- default length of time is based on length of string
	if (table.getn(arg) == 2) then
		duration = arg[2]								-- override default length
	end

	-- if there is still a message hanging about on the screen, remove it
	if (_POS_messageonscreen == true) then
		PrintOnScreen_RemoveFromScreen()
	end
	
	print("Asked to PrintOnScreen - "..text)
	dr_setautoclear("scartext", 0)
	dr_text2d("scartext", 0.5-(string.len(text)*0.003), 0.3, text, 213, 213, 213)

	-- set the flag to indicate that the message is on the screen
	_POS_messageonscreen = true

--	if not Event_IsAnyRunning() then
--		if duration ~= 0 then
--			CTRL.Event_Delay(duration)
--			CTRL.WAIT()
--			PrintOnScreen_RemoveFromScreen()
--		end
--	end
	
end


--? @shortdesc Remove any messages from the screen
--? @extdesc
--? Removes from the screen any messages put there with PrintOnScreen()
--? @result Void
--? @args Void
function PrintOnScreen_RemoveFromScreen()

	dr_clear("scartext")
	_POS_messageonscreen = false

end
