Navigation

 UI Coding Tutorial #3 - Images For Buttons Feature Type: Coding Tutorials     Added: 09/05  
  Author: IoN_PuLse 

How would you like to have a BFG explosion for an exit button in Quake3? Well...not many of you probably want that but you have learn how to do it!

Ok to basically outline what this tutorial will entail, I will show you how to change the main menu of Quake3, specifically changing the ďEXITĒ button into a BFG explosion two-frame animation. Simple? Actually it is. I recommend you read my previous tutorials before attempting this one, if you want to understand absolutely everything. Hereís what you need to do first, near the top of ui_menu.c:

Add
#define ART_EXIT0 "models/weaphits/bfgboom/bfgboom_2"
#define ART_EXIT1 "models/weaphits/bfgboom/bfgboom_3"

// Image locations

After
#define ID_EXIT 16


Then right below that comment out:
menutext_s exit;

And instead put:
menubitmap_s exit;

// tells Quake3 that youíre using an image not text

Then scroll down and find MainMenu_Cache and add:
trap_R_RegisterShaderNoMip( ART_EXIT0 );
trap_R_RegisterShaderNoMip( ART_EXIT1 );

// caching of the images defined above

And last but not least (most important part actually) comment out the follow like I have already done:
y += MAIN_MENU_VERTICAL_SPACING;
/* s_main.exit.generic.type = MTYPE_PTEXT;
s_main.exit.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_main.exit.generic.x = 320;
s_main.exit.generic.y = y;
s_main.exit.generic.id = ID_EXIT;
s_main.exit.generic.callback = Main_MenuEvent;
s_main.exit.string = "EXIT";
s_main.exit.color = color_red;
s_main.exit.style = style; */


And below paste:

s_main.exit.generic.type = MTYPE_BITMAP;

// image, not text

s_main.exit.generic.name = ART_EXIT0;

// first image to display, when the mouse isnít on it

s_main.exit.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
// flags
s_main.exit.generic.callback = Main_MenuEvent;

// what menu to issue the command in

s_main.exit.generic.id = ID_EXIT;
// the ID for what the button does when clicked
s_main.exit.generic.x = 300;

// x coordinate

s_main.exit.generic.y = y;
// y coordinate
s_main.exit.width = 70;
// image width
s_main.exit.height = 70;
// image height
s_main.exit.focuspic = ART_EXIT1;
// image that it flashes to when the mouse is over it

You donít need any extra pk3ís for this, just compile the source and run Quake with the fs_game command or selecting the folder in the MODS menu. Now you have a nifty BFG explosion for a quit button =)

-IoN_PuLse

Comments »



  Page 1

  Comments ( 0 )


  Features Index

  Home

Copyright © 2001 MGON International AB - Privacy statement