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: 2772
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 05 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
knock knock
General | News
By: MIFUNE | Dec 31 2017
 
knock knock
General | News
By: omega | Dec 22 2016
 
knock knock
General | News
By: MIFUNE | Oct 10 2015
 
New HL HUD Message System
Half-Life | Coding | Shared Tutorials
By: chbrules | Dec 31 2011
 
knock knock
General | News
By: Whistler | Nov 05 2011
 
Particle Engine tutorial part 4
Half-Life | Coding | Client Side Tutorials
By: darkPhoenix | Feb 18 2010
 
Particle Engine tutorial part 2
Half-Life | Coding | Client Side Tutorials
By: darkPhoenix | Feb 11 2010
 
Particle Engine tutorial part 3
Half-Life | Coding | Client Side Tutorials
By: darkPhoenix | Feb 11 2010
 
Game Movement Series #2: Analog Jumping and Floating
Half-Life 2 | Coding | Shared Tutorials
By: mars3554 | Oct 26 2009
 
Particle Engine tutorial part 5
Half-Life | Coding | Client Side Tutorials
By: Deadpool | Aug 02 2009
 

Site Info
297 Approved Articless
8 Pending Articles
3940 Registered Members
0 People Online (4 guests)
About - Credits - Contact Us

Wavelength version: 3.0.0.9
Valid XHTML 1.0! Valid CSS!