Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

ui_team.c

Go to the documentation of this file.
00001 /*
00002 ===========================================================================
00003 Copyright (C) 1999-2005 Id Software, Inc.
00004 
00005 This file is part of Quake III Arena source code.
00006 
00007 Quake III Arena source code is free software; you can redistribute it
00008 and/or modify it under the terms of the GNU General Public License as
00009 published by the Free Software Foundation; either version 2 of the License,
00010 or (at your option) any later version.
00011 
00012 Quake III Arena source code is distributed in the hope that it will be
00013 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 GNU General Public License for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Foobar; if not, write to the Free Software
00019 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00020 ===========================================================================
00021 */
00022 //
00023 //
00024 // ui_team.c
00025 //
00026 
00027 #include "ui_local.h"
00028 
00029 
00030 #define TEAMMAIN_FRAME  "menu/art/cut_frame"
00031 
00032 #define ID_JOINRED      100
00033 #define ID_JOINBLUE     101
00034 #define ID_JOINGAME     102
00035 #define ID_SPECTATE     103
00036 
00037 
00038 typedef struct
00039 {
00040     menuframework_s menu;
00041     menubitmap_s    frame;
00042     menutext_s      joinred;
00043     menutext_s      joinblue;
00044     menutext_s      joingame;
00045     menutext_s      spectate;
00046 } teammain_t;
00047 
00048 static teammain_t   s_teammain;
00049 
00050 // bk001204 - unused
00051 //static menuframework_s    s_teammain_menu;
00052 //static menuaction_s       s_teammain_orders;
00053 //static menuaction_s       s_teammain_voice;
00054 //static menuaction_s       s_teammain_joinred;
00055 //static menuaction_s       s_teammain_joinblue;
00056 //static menuaction_s       s_teammain_joingame;
00057 //static menuaction_s       s_teammain_spectate;
00058 
00059 
00060 /*
00061 ===============
00062 TeamMain_MenuEvent
00063 ===============
00064 */
00065 static void TeamMain_MenuEvent( void* ptr, int event ) {
00066     if( event != QM_ACTIVATED ) {
00067         return;
00068     }
00069 
00070     switch( ((menucommon_s*)ptr)->id ) {
00071     case ID_JOINRED:
00072         trap_Cmd_ExecuteText( EXEC_APPEND, "cmd team red\n" );
00073         UI_ForceMenuOff();
00074         break;
00075 
00076     case ID_JOINBLUE:
00077         trap_Cmd_ExecuteText( EXEC_APPEND, "cmd team blue\n" );
00078         UI_ForceMenuOff();
00079         break;
00080 
00081     case ID_JOINGAME:
00082         trap_Cmd_ExecuteText( EXEC_APPEND, "cmd team free\n" );
00083         UI_ForceMenuOff();
00084         break;
00085 
00086     case ID_SPECTATE:
00087         trap_Cmd_ExecuteText( EXEC_APPEND, "cmd team spectator\n" );
00088         UI_ForceMenuOff();
00089         break;
00090     }
00091 }
00092 
00093 
00094 /*
00095 ===============
00096 TeamMain_MenuInit
00097 ===============
00098 */
00099 void TeamMain_MenuInit( void ) {
00100     int     y;
00101     int     gametype;
00102     char    info[MAX_INFO_STRING];
00103 
00104     memset( &s_teammain, 0, sizeof(s_teammain) );
00105 
00106     TeamMain_Cache();
00107 
00108     s_teammain.menu.wrapAround = qtrue;
00109     s_teammain.menu.fullscreen = qfalse;
00110 
00111     s_teammain.frame.generic.type   = MTYPE_BITMAP;
00112     s_teammain.frame.generic.flags  = QMF_INACTIVE;
00113     s_teammain.frame.generic.name   = TEAMMAIN_FRAME;
00114     s_teammain.frame.generic.x      = 142;
00115     s_teammain.frame.generic.y      = 118;
00116     s_teammain.frame.width          = 359;
00117     s_teammain.frame.height         = 256;
00118 
00119     y = 194;
00120 
00121     s_teammain.joinred.generic.type     = MTYPE_PTEXT;
00122     s_teammain.joinred.generic.flags    = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
00123     s_teammain.joinred.generic.id       = ID_JOINRED;
00124     s_teammain.joinred.generic.callback = TeamMain_MenuEvent;
00125     s_teammain.joinred.generic.x        = 320;
00126     s_teammain.joinred.generic.y        = y;
00127     s_teammain.joinred.string           = "JOIN RED";
00128     s_teammain.joinred.style            = UI_CENTER|UI_SMALLFONT;
00129     s_teammain.joinred.color            = colorRed;
00130     y += 20;
00131 
00132     s_teammain.joinblue.generic.type     = MTYPE_PTEXT;
00133     s_teammain.joinblue.generic.flags    = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
00134     s_teammain.joinblue.generic.id       = ID_JOINBLUE;
00135     s_teammain.joinblue.generic.callback = TeamMain_MenuEvent;
00136     s_teammain.joinblue.generic.x        = 320;
00137     s_teammain.joinblue.generic.y        = y;
00138     s_teammain.joinblue.string           = "JOIN BLUE";
00139     s_teammain.joinblue.style            = UI_CENTER|UI_SMALLFONT;
00140     s_teammain.joinblue.color            = colorRed;
00141     y += 20;
00142 
00143     s_teammain.joingame.generic.type     = MTYPE_PTEXT;
00144     s_teammain.joingame.generic.flags    = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
00145     s_teammain.joingame.generic.id       = ID_JOINGAME;
00146     s_teammain.joingame.generic.callback = TeamMain_MenuEvent;
00147     s_teammain.joingame.generic.x        = 320;
00148     s_teammain.joingame.generic.y        = y;
00149     s_teammain.joingame.string           = "JOIN GAME";
00150     s_teammain.joingame.style            = UI_CENTER|UI_SMALLFONT;
00151     s_teammain.joingame.color            = colorRed;
00152     y += 20;
00153 
00154     s_teammain.spectate.generic.type     = MTYPE_PTEXT;
00155     s_teammain.spectate.generic.flags    = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
00156     s_teammain.spectate.generic.id       = ID_SPECTATE;
00157     s_teammain.spectate.generic.callback = TeamMain_MenuEvent;
00158     s_teammain.spectate.generic.x        = 320;
00159     s_teammain.spectate.generic.y        = y;
00160     s_teammain.spectate.string           = "SPECTATE";
00161     s_teammain.spectate.style            = UI_CENTER|UI_SMALLFONT;
00162     s_teammain.spectate.color            = colorRed;
00163     y += 20;
00164 
00165     trap_GetConfigString(CS_SERVERINFO, info, MAX_INFO_STRING);   
00166     gametype = atoi( Info_ValueForKey( info,"g_gametype" ) );
00167                   
00168     // set initial states
00169     switch( gametype ) {
00170     case GT_SINGLE_PLAYER:
00171     case GT_FFA:
00172     case GT_TOURNAMENT:
00173         s_teammain.joinred.generic.flags  |= QMF_GRAYED;
00174         s_teammain.joinblue.generic.flags |= QMF_GRAYED;
00175         break;
00176 
00177     default:
00178     case GT_TEAM:
00179     case GT_CTF:
00180         s_teammain.joingame.generic.flags |= QMF_GRAYED;
00181         break;
00182     }
00183 
00184     Menu_AddItem( &s_teammain.menu, (void*) &s_teammain.frame );
00185     Menu_AddItem( &s_teammain.menu, (void*) &s_teammain.joinred );
00186     Menu_AddItem( &s_teammain.menu, (void*) &s_teammain.joinblue );
00187     Menu_AddItem( &s_teammain.menu, (void*) &s_teammain.joingame );
00188     Menu_AddItem( &s_teammain.menu, (void*) &s_teammain.spectate );
00189 }
00190 
00191 
00192 /*
00193 ===============
00194 TeamMain_Cache
00195 ===============
00196 */
00197 void TeamMain_Cache( void ) {
00198     trap_R_RegisterShaderNoMip( TEAMMAIN_FRAME );
00199 }
00200 
00201 
00202 /*
00203 ===============
00204 UI_TeamMainMenu
00205 ===============
00206 */
00207 void UI_TeamMainMenu( void ) {
00208     TeamMain_MenuInit();
00209     UI_PushMenu ( &s_teammain.menu );
00210 }

Generated on Thu Aug 25 12:37:45 2005 for Quake III Arena by  doxygen 1.3.9.1