-- events for ui screen


function OnLoad ()
	--CacheSound ("logos/sound.ogg");
end;

timer = 0;
leaving = false;

function OnEnter ()
	--PlaySound ("logos/sound.ogg");
	leaving = false;
end;

function OnLeave ()
end;


function OnClick (name)
	
end;


function clamp01 (value)

	value = math.min (value, 1);
	value = math.max (value, 0);
	return value;
end;


function OnUpdate (tdelta)

	if (tdelta > 0.1) then
		tdelta = 0.05;
	end;

	timer = timer + tdelta;
	
	t = 1.1 * timer;
	
	trans = GetActiveScreenTransPhase ();
	local alpha = 0;
	
	if (t < 1) then
		alpha = trans * clamp01 (4*t);
	else
		alpha = trans * (1-clamp01 (4*(t - 1.5)));
	end;
	
	SetProperty ("logo:alpha", alpha);
	--SetProperty ("logo:position_offset.y", math.min (0, 2*t * 50));

	
	-- show it for a couple of secs after it's complete, then fade away
	if (t > 2) then
		if (leaving == false) then
			SwitchScreen ("LogoSplashMythPeople");
			leaving = true;
			--PopScreen ();
		end;
	end;
end;


function OnDraw ()

end;
