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

ui_ingame.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 =======================================================================
00025 
00026 INGAME MENU
00027 
00028 =======================================================================
00029 */
00030 
00031 
00032 #include "ui_local.h"
00033 
00034 
00035 #define INGAME_FRAME                    "menu/art/addbotframe"
00036 //#define INGAME_FRAME                  "menu/art/cut_frame"
00037 #define INGAME_MENU_VERTICAL_SPACING    28
00038 
00039 #define ID_TEAM                 10
00040 #define ID_ADDBOTS              11
00041 #define ID_REMOVEBOTS           12
00042 #define ID_SETUP                13
00043 #define ID_SERVERINFO           14
00044 #define ID_LEAVEARENA           15
00045 #define ID_RESTART              16
00046 #define ID_QUIT                 17
00047 #define ID_RESUME               18
00048 #define ID_TEAMORDERS           19
00049 
00050 
00051 typedef struct {
00052     menuframework_s menu;
00053 
00054     menubitmap_s    frame;
00055     menutext_s      team;
00056     menutext_s      setup;
00057     menutext_s      server;
00058     menutext_s      leave;
00059     menutext_s      restart;
00060     menutext_s      addbots;
00061     menutext_s      removebots;
00062     menutext_s      teamorders;
00063     menutext_s      quit;
00064     menutext_s      resume;
00065 } ingamemenu_t;
00066 
00067 static ingamemenu_t s_ingame;
00068 
00069 
00070 /*
00071 =================
00072 InGame_RestartAction
00073 =================
00074 */
00075 static void InGame_RestartAction( qboolean result ) {
00076     if( !result ) {
00077         return;
00078     }
00079 
00080     UI_PopMenu();
00081     trap_Cmd_ExecuteText( EXEC_APPEND, "map_restart 0\n" );
00082 }
00083 
00084 
00085 /*
00086 =================
00087 InGame_QuitAction
00088 =================
00089 */
00090 static void InGame_QuitAction( qboolean result ) {
00091     if( !result ) {
00092         return;
00093     }
00094     UI_PopMenu();
00095     UI_CreditMenu();
00096 }
00097 
00098 
00099 /*
00100 =================
00101 InGame_Event
00102 =================
00103 */
00104 void InGame_Event( void *ptr, int notification ) {
00105     if( notification != QM_ACTIVATED ) {
00106         return;
00107     }
00108 
00109     switch( ((menucommon_s*)ptr)->id ) {
00110     case ID_TEAM:
00111         UI_TeamMainMenu();
00112         break;
00113 
00114     case ID_SETUP:
00115         UI_SetupMenu();
00116         break;
00117 
00118     case ID_LEAVEARENA:
00119         trap_Cmd_ExecuteText( EXEC_APPEND, "disconnect\n" );
00120         break;
00121 
00122     case ID_RESTART:
00123         UI_ConfirmMenu( "RESTART ARENA?", (voidfunc_f)NULL, InGame_RestartAction );
00124         break;
00125 
00126     case ID_QUIT:
00127         UI_ConfirmMenu( "EXIT GAME?",  (voidfunc_f)NULL, InGame_QuitAction );
00128         break;
00129 
00130     case ID_SERVERINFO:
00131         UI_ServerInfoMenu();
00132         break;
00133 
00134     case ID_ADDBOTS:
00135         UI_AddBotsMenu();
00136         break;
00137 
00138     case ID_REMOVEBOTS:
00139         UI_RemoveBotsMenu();
00140         break;
00141 
00142     case ID_TEAMORDERS:
00143         UI_TeamOrdersMenu();
00144         break;
00145 
00146     case ID_RESUME:
00147         UI_PopMenu();
00148         break;
00149     }
00150 }
00151 
00152 
00153 /*
00154 =================
00155 InGame_MenuInit
00156 =================
00157 */
00158 void InGame_MenuInit( void ) {
00159     int     y;
00160     uiClientState_t cs;
00161     char    info[MAX_INFO_STRING];
00162     int     team;
00163 
00164     memset( &s_ingame, 0 ,sizeof(ingamemenu_t) );
00165 
00166     InGame_Cache();
00167 
00168     s_ingame.menu.wrapAround = qtrue;
00169     s_ingame.menu.fullscreen = qfalse;
00170 
00171     s_ingame.frame.generic.type         = MTYPE_BITMAP;
00172     s_ingame.frame.generic.flags        = QMF_INACTIVE;
00173     s_ingame.frame.generic.name         = INGAME_FRAME;
00174     s_ingame.frame.generic.x            = 320-233;//142;
00175     s_ingame.frame.generic.y            = 240-166;//118;
00176     s_ingame.frame.width                = 466;//359;
00177     s_ingame.frame.height               = 332;//256;
00178 
00179     //y = 96;
00180     y = 88;
00181     s_ingame.team.generic.type          = MTYPE_PTEXT;
00182     s_ingame.team.generic.flags         = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
00183     s_ingame.team.generic.x             = 320;
00184     s_ingame.team.generic.y             = y;
00185     s_ingame.team.generic.id            = ID_TEAM;
00186     s_ingame.team.generic.callback      = InGame_Event; 
00187     s_ingame.team.string                = "START";
00188     s_ingame.team.color                 = color_red;
00189     s_ingame.team.style                 = UI_CENTER|UI_SMALLFONT;
00190 
00191     y += INGAME_MENU_VERTICAL_SPACING;
00192     s_ingame.addbots.generic.type       = MTYPE_PTEXT;
00193     s_ingame.addbots.generic.flags      = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
00194     s_ingame.addbots.generic.x          = 320;
00195     s_ingame.addbots.generic.y          = y;
00196     s_ingame.addbots.generic.id         = ID_ADDBOTS;
00197     s_ingame.addbots.generic.callback   = InGame_Event; 
00198     s_ingame.addbots.string             = "ADD BOTS";
00199     s_ingame.addbots.color              = color_red;
00200     s_ingame.addbots.style              = UI_CENTER|UI_SMALLFONT;
00201     if( !trap_Cvar_VariableValue( "sv_running" ) || !trap_Cvar_VariableValue( "bot_enable" ) || (trap_Cvar_VariableValue( "g_gametype" ) == GT_SINGLE_PLAYER)) {
00202         s_ingame.addbots.generic.flags |= QMF_GRAYED;
00203     }
00204 
00205     y += INGAME_MENU_VERTICAL_SPACING;
00206     s_ingame.removebots.generic.type        = MTYPE_PTEXT;
00207     s_ingame.removebots.generic.flags       = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
00208     s_ingame.removebots.generic.x           = 320;
00209     s_ingame.removebots.generic.y           = y;
00210     s_ingame.removebots.generic.id          = ID_REMOVEBOTS;
00211     s_ingame.removebots.generic.callback    = InGame_Event; 
00212     s_ingame.removebots.string              = "REMOVE BOTS";
00213     s_ingame.removebots.color               = color_red;
00214     s_ingame.removebots.style               = UI_CENTER|UI_SMALLFONT;
00215     if( !trap_Cvar_VariableValue( "sv_running" ) || !trap_Cvar_VariableValue( "bot_enable" ) || (trap_Cvar_VariableValue( "g_gametype" ) == GT_SINGLE_PLAYER)) {
00216         s_ingame.removebots.generic.flags |= QMF_GRAYED;
00217     }
00218 
00219     y += INGAME_MENU_VERTICAL_SPACING;
00220     s_ingame.teamorders.generic.type        = MTYPE_PTEXT;
00221     s_ingame.teamorders.generic.flags       = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
00222     s_ingame.teamorders.generic.x           = 320;
00223     s_ingame.teamorders.generic.y           = y;
00224     s_ingame.teamorders.generic.id          = ID_TEAMORDERS;
00225     s_ingame.teamorders.generic.callback    = InGame_Event; 
00226     s_ingame.teamorders.string              = "TEAM ORDERS";
00227     s_ingame.teamorders.color               = color_red;
00228     s_ingame.teamorders.style               = UI_CENTER|UI_SMALLFONT;
00229     if( !(trap_Cvar_VariableValue( "g_gametype" ) >= GT_TEAM) ) {
00230         s_ingame.teamorders.generic.flags |= QMF_GRAYED;
00231     }
00232     else {
00233         trap_GetClientState( &cs );
00234         trap_GetConfigString( CS_PLAYERS + cs.clientNum, info, MAX_INFO_STRING );
00235         team = atoi( Info_ValueForKey( info, "t" ) );
00236         if( team == TEAM_SPECTATOR ) {
00237             s_ingame.teamorders.generic.flags |= QMF_GRAYED;
00238         }
00239     }
00240 
00241     y += INGAME_MENU_VERTICAL_SPACING;
00242     s_ingame.setup.generic.type         = MTYPE_PTEXT;
00243     s_ingame.setup.generic.flags        = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
00244     s_ingame.setup.generic.x            = 320;
00245     s_ingame.setup.generic.y            = y;
00246     s_ingame.setup.generic.id           = ID_SETUP;
00247     s_ingame.setup.generic.callback     = InGame_Event; 
00248     s_ingame.setup.string               = "SETUP";
00249     s_ingame.setup.color                = color_red;
00250     s_ingame.setup.style                = UI_CENTER|UI_SMALLFONT;
00251 
00252     y += INGAME_MENU_VERTICAL_SPACING;
00253     s_ingame.server.generic.type        = MTYPE_PTEXT;
00254     s_ingame.server.generic.flags       = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
00255     s_ingame.server.generic.x           = 320;
00256     s_ingame.server.generic.y           = y;
00257     s_ingame.server.generic.id          = ID_SERVERINFO;
00258     s_ingame.server.generic.callback    = InGame_Event; 
00259     s_ingame.server.string              = "SERVER INFO";
00260     s_ingame.server.color               = color_red;
00261     s_ingame.server.style               = UI_CENTER|UI_SMALLFONT;
00262 
00263     y += INGAME_MENU_VERTICAL_SPACING;
00264     s_ingame.restart.generic.type       = MTYPE_PTEXT;
00265     s_ingame.restart.generic.flags      = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
00266     s_ingame.restart.generic.x          = 320;
00267     s_ingame.restart.generic.y          = y;
00268     s_ingame.restart.generic.id         = ID_RESTART;
00269     s_ingame.restart.generic.callback   = InGame_Event; 
00270     s_ingame.restart.string             = "RESTART ARENA";
00271     s_ingame.restart.color              = color_red;
00272     s_ingame.restart.style              = UI_CENTER|UI_SMALLFONT;
00273     if( !trap_Cvar_VariableValue( "sv_running" ) ) {
00274         s_ingame.restart.generic.flags |= QMF_GRAYED;
00275     }
00276 
00277     y += INGAME_MENU_VERTICAL_SPACING;
00278     s_ingame.resume.generic.type            = MTYPE_PTEXT;
00279     s_ingame.resume.generic.flags           = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
00280     s_ingame.resume.generic.x               = 320;
00281     s_ingame.resume.generic.y               = y;
00282     s_ingame.resume.generic.id              = ID_RESUME;
00283     s_ingame.resume.generic.callback        = InGame_Event; 
00284     s_ingame.resume.string                  = "RESUME GAME";
00285     s_ingame.resume.color                   = color_red;
00286     s_ingame.resume.style                   = UI_CENTER|UI_SMALLFONT;
00287 
00288     y += INGAME_MENU_VERTICAL_SPACING;
00289     s_ingame.leave.generic.type         = MTYPE_PTEXT;
00290     s_ingame.leave.generic.flags        = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
00291     s_ingame.leave.generic.x            = 320;
00292     s_ingame.leave.generic.y            = y;
00293     s_ingame.leave.generic.id           = ID_LEAVEARENA;
00294     s_ingame.leave.generic.callback     = InGame_Event; 
00295     s_ingame.leave.string               = "LEAVE ARENA";
00296     s_ingame.leave.color                = color_red;
00297     s_ingame.leave.style                = UI_CENTER|UI_SMALLFONT;
00298 
00299     y += INGAME_MENU_VERTICAL_SPACING;
00300     s_ingame.quit.generic.type          = MTYPE_PTEXT;
00301     s_ingame.quit.generic.flags         = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
00302     s_ingame.quit.generic.x             = 320;
00303     s_ingame.quit.generic.y             = y;
00304     s_ingame.quit.generic.id            = ID_QUIT;
00305     s_ingame.quit.generic.callback      = InGame_Event; 
00306     s_ingame.quit.string                = "EXIT GAME";
00307     s_ingame.quit.color                 = color_red;
00308     s_ingame.quit.style                 = UI_CENTER|UI_SMALLFONT;
00309 
00310     Menu_AddItem( &s_ingame.menu, &s_ingame.frame );
00311     Menu_AddItem( &s_ingame.menu, &s_ingame.team );
00312     Menu_AddItem( &s_ingame.menu, &s_ingame.addbots );
00313     Menu_AddItem( &s_ingame.menu, &s_ingame.removebots );
00314     Menu_AddItem( &s_ingame.menu, &s_ingame.teamorders );
00315     Menu_AddItem( &s_ingame.menu, &s_ingame.setup );
00316     Menu_AddItem( &s_ingame.menu, &s_ingame.server );
00317     Menu_AddItem( &s_ingame.menu, &s_ingame.restart );
00318     Menu_AddItem( &s_ingame.menu, &s_ingame.resume );
00319     Menu_AddItem( &s_ingame.menu, &s_ingame.leave );
00320     Menu_AddItem( &s_ingame.menu, &s_ingame.quit );
00321 }
00322 
00323 
00324 /*
00325 =================
00326 InGame_Cache
00327 =================
00328 */
00329 void InGame_Cache( void ) {
00330     trap_R_RegisterShaderNoMip( INGAME_FRAME );
00331 }
00332 
00333 
00334 /*
00335 =================
00336 UI_InGameMenu
00337 =================
00338 */
00339 void UI_InGameMenu( void ) {
00340     // force as top level menu
00341     uis.menusp = 0;  
00342 
00343     // set menu cursor to a nice location
00344     uis.cursorx = 319;
00345     uis.cursory = 80;
00346 
00347     InGame_MenuInit();
00348     UI_PushMenu( &s_ingame.menu );
00349 }

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