Page 1 of 1

transition - time in menu.dat

Posted: Mon Oct 09, 2017 6:56 pm
by Nahuel
My objective is to add some small animations in a menu. dat
It would be just an image transition (like an introduction) before the menu is drawn. Just a couple of images in fade-out and fade-in, using alpha values for the transition.

This would be very simple to do using "time value" in csqc, ypou know, some drawpic + frametime in CSQC_UpdateView. But I can't figure out how I could use time on menu. dat.
There is something like CSQC_UpdateView in menu.dat? I can use something similar to frametime in menu.dat?
Is there any way to code -for example- this: an image displayed for a second, and then becomes transparent. ?????

How can I use time in the. dat menu without using any external data (such as ssqc time)???


I am using darkplaces :)
Any clue is appreciated, thanks :)

Re: transition - time in menu.dat

Posted: Tue Oct 10, 2017 1:12 pm
by pitchatan
Haven't used menu.dat in ages, but if frametime does not exist you can create something similar yourself.

Code: Select all

 
float frametimmenu; // define our float


m_draw(vector screensize)
{
	local float frametimemenu2;

	if(!frametimemenu)
	{
		frametimemenu = time; // if none value, set time.
	}
	else
	{
		frametimemenu2 = time - frametimemenu; // our frametime delta. 
		frametimemenu = time; // value for next frame.
	}
};

This gives fairly accurate results in csqc and should most likely do the same in menuqc.
Keep in mind that time in menuqc is supposedly like cltime in csqc, so don't get them confused. :D

I wouldn't be surprised if spike comes in and gives you a better suggestion later on but what i suggest should work. :)


Alternatively you can define the frametime float yourself as it doesnt seem to be used in menuqc whatsoever, though that is up to you.

Re: transition - time in menu.dat

Posted: Tue Oct 10, 2017 2:12 pm
by Spike
float animtime = (time - starttime) * FRAMESPERSECOND;
float frame = floor(animtime);
float alphavalue = animtime-frame; //sawtooth. will reset to 0 any time it would reach 1.0
drawpic(xy, imageforframe(frame), sz, rgb, 1.0, 0); //alpha should be 1-alphavalue if you're using additive alpha.
drawpic(xy, imageforframe(frame+1), sz, rgb, alphavalue, 0);

be sure to check for frame overflows. you'll probably want to just end your animation then. or loop. whatever. your choice.

Re: transition - time in menu.dat

Posted: Tue Oct 10, 2017 7:05 pm
by Nahuel
Thank you guys!
it works like a charm :)

Is it necessary that I reset the time to 0 after some time?
Because I fear that after a few minutes I might be using "numbers" too high (given by get time).

Could there really be a problem with this? Because gettime doesn't seem to stop at any time (even when the client connects to the game) Should I reset gettime at some point? is this possible?

Would it be problematic if someone were playing for example 24 hours and gettime continued? what is its limit?

Thank you again :)