Centered Menus For My Stock Quake Engine
Moderator: InsideQC Admins
9 posts
• Page 1 of 1
Centered Menus For My Stock Quake Engine
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. 
- Stroggos
- Posts: 50
- Joined: Tue Apr 14, 2009 11:40 am
- Location: Australia
Have a look in menu.c; here's the original M_DrawPic function as an example:
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.
- 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
We knew the words, we knew the score, we knew what we were fighting for
-

mh - Posts: 2292
- Joined: Sat Jan 12, 2008 1:38 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.
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
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
9 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest