Inside3D!
     

Centered Menus For My Stock Quake Engine

 
Post new topic   Reply to topic    Inside3d Forums Forum Index -> Engine Programming
View previous topic :: View next topic  
Author Message
Stroggos



Joined: 14 Apr 2009
Posts: 43

PostPosted: Thu Aug 13, 2009 10:28 pm    Post subject: Centered Menus For My Stock Quake Engine Reply with quote

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 Evil
_________________
Dont even try to port Quake 4 to the ipod
Back to top
View user's profile Send private message
mh



Joined: 12 Jan 2008
Posts: 909

PostPosted: Thu Aug 13, 2009 11:10 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Stroggos



Joined: 14 Apr 2009
Posts: 43

PostPosted: Fri Aug 14, 2009 6:42 am    Post subject: Reply with quote

thanks mh!!!!!!
_________________
Dont even try to port Quake 4 to the ipod
Back to top
View user's profile Send private message
Spike



Joined: 05 Nov 2004
Posts: 944
Location: UK

PostPosted: Fri Aug 14, 2009 7:39 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
mh



Joined: 12 Jan 2008
Posts: 909

PostPosted: Fri Aug 14, 2009 10:20 am    Post subject: Reply with quote

Spike is, of course, correct here. Very Happy
_________________
DirectQ Engine - New release 1.8.666a, 9th August 2010
MHQuake Blog (General)
Direct3D 8 Quake Engines
Back to top
View user's profile Send private message Visit poster's website
Spike



Joined: 05 Nov 2004
Posts: 944
Location: UK

PostPosted: Fri Aug 14, 2009 7:13 pm    Post subject: Reply with quote

and bored, too.
_________________
What's a signature?
Back to top
View user's profile Send private message Visit poster's website
Stroggos



Joined: 14 Apr 2009
Posts: 43

PostPosted: Sat Aug 15, 2009 1:39 am    Post subject: Reply with quote

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
View user's profile Send private message
mh



Joined: 12 Jan 2008
Posts: 909

PostPosted: Sat Aug 15, 2009 3:03 pm    Post subject: Reply with quote

Look for M_DrawTransPicTranslate in menu.c
_________________
DirectQ Engine - New release 1.8.666a, 9th August 2010
MHQuake Blog (General)
Direct3D 8 Quake Engines
Back to top
View user's profile Send private message Visit poster's website
Stroggos



Joined: 14 Apr 2009
Posts: 43

PostPosted: Sun Aug 16, 2009 12:59 am    Post subject: Reply with quote

Oh, Okay
_________________
Dont even try to port Quake 4 to the ipod
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Inside3d Forums Forum Index -> Engine Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2004 phpBB Group