View previous topic :: View next topic |
Author |
Message |
Stroggos
Joined: 14 Apr 2009 Posts: 43
|
Posted: Thu Aug 13, 2009 10:28 pm Post subject: 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.  _________________ Dont even try to port Quake 4 to the ipod |
|
Back to top |
|
 |
mh

Joined: 12 Jan 2008 Posts: 909
|
Posted: Thu Aug 13, 2009 11:10 pm Post subject: |
|
|
Have a look in menu.c; here's the original M_DrawPic function as an example: Code: | 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. _________________ DirectQ Engine - New release 1.8.666a, 9th August 2010
MHQuake Blog (General)
Direct3D 8 Quake Engines |
|
Back to top |
|
 |
Stroggos
Joined: 14 Apr 2009 Posts: 43
|
Posted: Fri Aug 14, 2009 6:42 am Post subject: |
|
|
thanks mh!!!!!! _________________ Dont even try to port Quake 4 to the ipod |
|
Back to top |
|
 |
Spike
Joined: 05 Nov 2004 Posts: 944 Location: UK
|
Posted: Fri Aug 14, 2009 7:39 am Post subject: |
|
|
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. _________________ What's a signature? |
|
Back to top |
|
 |
mh

Joined: 12 Jan 2008 Posts: 909
|
|
Back to top |
|
 |
Spike
Joined: 05 Nov 2004 Posts: 944 Location: UK
|
Posted: Fri Aug 14, 2009 7:13 pm Post subject: |
|
|
and bored, too. _________________ What's a signature? |
|
Back to top |
|
 |
Stroggos
Joined: 14 Apr 2009 Posts: 43
|
Posted: Sat Aug 15, 2009 1:39 am Post subject: |
|
|
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. _________________ Dont even try to port Quake 4 to the ipod |
|
Back to top |
|
 |
mh

Joined: 12 Jan 2008 Posts: 909
|
|
Back to top |
|
 |
Stroggos
Joined: 14 Apr 2009 Posts: 43
|
Posted: Sun Aug 16, 2009 12:59 am Post subject: |
|
|
Oh, Okay _________________ Dont even try to port Quake 4 to the ipod |
|
Back to top |
|
 |
|