Welcome, Guest! Login | Register

UI Tutorial #2 [Print this Article]
Posted by: IoN_PuLse
Date posted: May 05 2003
User Rating: N/A
Number of views: 1324
Number of comments: 0
Description: Text buttons
Main Menu Button Position Manipulation

Buttons positions are determined with x and y coordinates. You may remember these annoying buggers from high school math, and they haunt many of us to this day, sometimes even with their buddy the z axis. But not to worry, he doesn’t show up in the main menu of Quake3. Here is the code for the positioning of the SinglePlayer button. I will detail with a commented line what each line does:

 CODE  

// gives y’s definition, you don’t need this , specify y yourself.
    y = 134;
// tells what MTYPE the button is. It can also be MTYPE_BITMAP
    s_main.singleplayer.generic.type  = MTYPE_PTEXT;
//  flags to tell how it acts and stuff
    s_main.singleplayer.generic.flags  = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
// it’s position on the x plane. (up and down)(goes from 480 to 0)
    s_main.singleplayer.generic.x      = 320;
// it’s position on the y plane. (left and right)(goes from 640 to 0)
    s_main.singleplayer.generic.y      = y;
// the ID for it (makes reference to the CASE ID_whatever above
    s_main.singleplayer.generic.id     = ID_SINGLEPLAYER;
// what menu it’s making the command under
    s_main.singleplayer.generic.callback    = Main_MenuEvent;
// what text shows up
    s_main.singleplayer.string    = "SINGLE PLAYER";
// The color of the text, can be color_black; color_white; color_yellow; color_blue; color_orange;
    s_main.singleplayer.color    = color_red;
// the style of the text, and the value they give is “style”, which is defined above (top of this function)
    s_main.singleplayer.style    = style;


Now with this you can do many wonderful things. First of all, to demonstrate something you could do, let’s move the SinglePlayer button somewhere else on the screen, and call it “Bot Play” in the color blue. To do this, you’ll need to change the following:
(note: you will need to change the original code to this or paste this after the original and comment out the original in order for it to work)

 CODE  

    s_main.singleplayer.generic.type  = MTYPE_PTEXT;
    s_main.singleplayer.generic.flags  = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
// everything above we keep the same, but notice the following differences
// x coordinate is same (middle of screen left and right)
    s_main.singleplayer.generic.x      = 320;
// no more y for the y coordinate! now the y coordinate is 20, higher up on the screen
    s_main.singleplayer.generic.y      = 20;
//  still acts the same when clicked
    s_main.singleplayer.generic.id     = ID_SINGLEPLAYER;
// same menu called
    s_main.singleplayer.generic.callback    = Main_MenuEvent;
// we’ve changed the text to BOT MODE, which will show up in the menu instead of singleplayer
    s_main.singleplayer.string    = "BOT MODE";
// here we changed the text color to orange
    s_main.singleplayer.color    = color_orange;
// style is the same, no need to change it
    s_main.singleplayer.style    = style;


I hope you understand the main menu of Quake3 even better, and I look forward to seeing some interesting menus later on! I will deal with images for buttons and more in later tutorials!

Rate This Article
This article has not yet been rated.

You have to register to rate this article.
User Comments

No User Comments

You must register to post a comment. If you have already registered, you must login.

Latest Articles
3rd person View in Multiplayer
Half-Life 2 | Coding | Client Side Tutorials
How to enable it in HL2DM

By: cct | Nov 13 2006

Making a Camera
Half-Life 2 | Level Design
This camera is good for when you join a map, it gives you a view of the map before you join a team

By: slackiller | Mar 04 2006

Making a camera , Part 2
Half-Life 2 | Level Design
these cameras are working monitors that turn on when a button is pushed.

By: slackiller | Mar 04 2006

Storing weapons on ladder
Half-Life 2 | Coding | Snippets
like Raven Sheild or BF2

By: British_Bomber | Dec 24 2005

Implementation of a string lookup table
Half-Life 2 | Coding | Snippets
A string lookup table is a set of functions that is used to convert strings to pre-defined values

By: deathz0rz | Nov 13 2005


Latest Comments
Spinning Corpses Simple Fix
Half-Life | Coding | Snippets
By: darkPhoenix | Sep 05 2008
 
Where do we go from here
General | News
By: MIFUNE | Jun 09 2008
 
The Input/Output system
Half-Life 2 | Level Design
By: nazitaco | Dec 23 2007
 
Where do we go from here
General | News
By: Rob_F | Nov 22 2007
 
Rescaling Half-Life
Half-Life | Coding | Shared Tutorials
By: christoph | Nov 12 2007
 
GameUI
Half-Life 2 | Coding | Client Side Tutorials
By: Evil_j | Oct 29 2007
 
3 State Zoom For Any Weapon
Half-Life 2 | Coding | Server Side Tutorials
By: Ennuified | Oct 18 2007
 
Storing weapons on ladder
Half-Life 2 | Coding | Snippets
By: cct | Sep 07 2007
 
CTF Gameplay Part 1
Half-Life | Coding | Shared Tutorials
By: DarkNight | Aug 28 2007
 
CTF Gameplay Part 1
Half-Life | Coding | Shared Tutorials
By: deedok | Aug 20 2007
 

Site Info
296 Approved Articless
5 Pending Articles
3940 Registered Members
4 People Online (26 guests)
About - Credits - Contact Us

Wavelength version: 3.0.0.9
Valid XHTML 1.0! Valid CSS!