Forum

Centered Menus For My Stock Quake Engine

Discuss programming topics for the various GPL'd game engine sources.

Moderator: InsideQC Admins

Centered Menus For My Stock Quake Engine

Postby Stroggos » Thu Aug 13, 2009 10:28 pm

I been trying to figure this out for a few months now and I can't fathom it. How can you center the menus in a stock quake engine? I know its possible because it's in FitzQuake. But I can't seem to do it. :twisted:
Stroggos
 
Posts: 50
Joined: Tue Apr 14, 2009 11:40 am
Location: Australia

Postby mh » Thu Aug 13, 2009 11:10 pm

Have a look in menu.c; here's the original M_DrawPic function as an example:
Code: Select all
void M_DrawPic (int x, int y, qpic_t *pic)
{
   Draw_Pic (x + ((vid.width - 320)>>1), y, pic);
}


Now, the "x + ((vid.width - 320)>>1)" part is used for centering the menu horizontally, so to center it vertically you would do something similar for the y coord, only use "y + ((vid.height - 240)>>1)" instead.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Postby Stroggos » Fri Aug 14, 2009 6:42 am

thanks mh!!!!!!
Stroggos
 
Posts: 50
Joined: Tue Apr 14, 2009 11:40 am
Location: Australia

Postby Spike » Fri Aug 14, 2009 7:39 am

pos = screenalignmentpoint - imagealignmentpoint

top left in the top left, alignmentpoint is 0 in all cases, meaning pos = 0
align the top left of the image to the center of the screen and you want screencenter - 0. align the right of the image to the center of the screen and its screencenter - imagesize. align the bottom right of the image to the bottom right of the screen and its screensize-imagesize.
the center of the image or screen is the size in pixels divided by 2.
and if you're aligning the center of the image at the center of the screen then (swidth-iwidth)/2 is the same as swidth/2-iwidth/2, just a bit more optimised.

320 is used for the menu because the menu is logically drawn as a 320*200 or so wide image, aligned to the horizontal center and top of the screen. Any M_DrawPic offsets will use x and x+width between 0 and 320.
So to center the y value too, decide on your virtual menu 'image' height, and do (sheight-mheight)/2.
The minimum resolution quake generally allows is 200 high, not 240. if you use 240, your y offset could become negative and parts of your menu could go missing/offscreen.
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Postby mh » Fri Aug 14, 2009 10:20 am

Spike is, of course, correct here. :D
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Postby Spike » Fri Aug 14, 2009 7:13 pm

and bored, too.
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Postby Stroggos » Sat Aug 15, 2009 1:39 am

Okay, I have done all of that and the menus look great all central. Now the only problem is i can't align the "Player Setup Pic" in the multiplayer player setup menu. IF that makes ANY sense at all. If it doesn't i'll take a screenshot.
Stroggos
 
Posts: 50
Joined: Tue Apr 14, 2009 11:40 am
Location: Australia

Postby mh » Sat Aug 15, 2009 3:03 pm

Look for M_DrawTransPicTranslate in menu.c
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Postby Stroggos » Sun Aug 16, 2009 12:59 am

Oh, Okay
Stroggos
 
Posts: 50
Joined: Tue Apr 14, 2009 11:40 am
Location: Australia


Return to Engine Programming

Who is online

Users browsing this forum: No registered users and 1 guest