| 1 |
/* |
| 2 |
=========================================================================== |
| 3 |
Copyright (C) 1999-2005 Id Software, Inc. |
| 4 |
|
| 5 |
This file is part of Quake III Arena source code. |
| 6 |
|
| 7 |
Quake III Arena source code is free software; you can redistribute it |
| 8 |
and/or modify it under the terms of the GNU General Public License as |
| 9 |
published by the Free Software Foundation; either version 2 of the License, |
| 10 |
or (at your option) any later version.SERVER |
| 11 |
|
| 12 |
Quake III Arena source code is distributed in the hope that it will be |
| 13 |
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
GNU General Public License for more details. |
| 16 |
|
| 17 |
You should have received a copy of the GNU General Public License |
| 18 |
along with Quake III Arena source code; if not, write to the Free Software |
| 19 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 |
=========================================================================== |
| 21 |
*/ |
| 22 |
// |
| 23 |
/* |
| 24 |
======================================================================= |
| 25 |
|
| 26 |
INGAME MENU |
| 27 |
|
| 28 |
======================================================================= |
| 29 |
*/ |
| 30 |
|
| 31 |
|
| 32 |
#include "ui_local.h" |
| 33 |
|
| 34 |
|
| 35 |
#define INGAME_FRAME "menu/art_blueish/addbotframe" |
| 36 |
//#define INGAME_FRAME "menu/art_blueish/cut_frame" |
| 37 |
#define INGAME_MENU_VERTICAL_SPACING 28 |
| 38 |
|
| 39 |
#define ID_TEAM 10 |
| 40 |
#define ID_ADDBOTS 11 |
| 41 |
#define ID_REMOVEBOTS 12 |
| 42 |
#define ID_SETUP 13 |
| 43 |
#define ID_SERVERINFO 14 |
| 44 |
#define ID_LEAVEARENA 15 |
| 45 |
#define ID_RESTART 16 |
| 46 |
#define ID_QUIT 17 |
| 47 |
#define ID_RESUME 18 |
| 48 |
#define ID_TEAMORDERS 19 |
| 49 |
#define ID_VOTE 20 |
| 50 |
|
| 51 |
|
| 52 |
typedef struct { |
| 53 |
menuframework_s menu; |
| 54 |
|
| 55 |
menubitmap_s frame; |
| 56 |
menutext_s team; |
| 57 |
menutext_s setup; |
| 58 |
menutext_s server; |
| 59 |
menutext_s leave; |
| 60 |
menutext_s restart; |
| 61 |
menutext_s addbots; |
| 62 |
menutext_s removebots; |
| 63 |
menutext_s teamorders; |
| 64 |
menutext_s quit; |
| 65 |
menutext_s resume; |
| 66 |
menutext_s vote; |
| 67 |
} ingamemenu_t; |
| 68 |
|
| 69 |
static ingamemenu_t s_ingame; |
| 70 |
|
| 71 |
|
| 72 |
/* |
| 73 |
================= |
| 74 |
InGame_RestartAction |
| 75 |
================= |
| 76 |
*/ |
| 77 |
static void InGame_RestartAction( qboolean result ) { |
| 78 |
if( !result ) { |
| 79 |
return; |
| 80 |
} |
| 81 |
|
| 82 |
UI_PopMenu(); |
| 83 |
trap_Cmd_ExecuteText( EXEC_APPEND, "map_restart 0\n" ); |
| 84 |
} |
| 85 |
|
| 86 |
|
| 87 |
/* |
| 88 |
================= |
| 89 |
InGame_QuitAction |
| 90 |
================= |
| 91 |
*/ |
| 92 |
static void InGame_QuitAction( qboolean result ) { |
| 93 |
if( !result ) { |
| 94 |
return; |
| 95 |
} |
| 96 |
UI_PopMenu(); |
| 97 |
//UI_CreditMenu(); |
| 98 |
trap_Cmd_ExecuteText( EXEC_APPEND, "quit\n" ); |
| 99 |
} |
| 100 |
|
| 101 |
|
| 102 |
/* |
| 103 |
================= |
| 104 |
InGame_Event |
| 105 |
================= |
| 106 |
*/ |
| 107 |
void InGame_Event( void *ptr, int notification ) { |
| 108 |
if( notification != QM_ACTIVATED ) { |
| 109 |
return; |
| 110 |
} |
| 111 |
|
| 112 |
switch( ((menucommon_s*)ptr)->id ) { |
| 113 |
case ID_TEAM: |
| 114 |
UI_TeamMainMenu(); |
| 115 |
break; |
| 116 |
|
| 117 |
case ID_SETUP: |
| 118 |
UI_SetupMenu(); |
| 119 |
break; |
| 120 |
|
| 121 |
case ID_LEAVEARENA: |
| 122 |
trap_Cmd_ExecuteText( EXEC_APPEND, "disconnect\n" ); |
| 123 |
break; |
| 124 |
|
| 125 |
case ID_RESTART: |
| 126 |
UI_ConfirmMenu( "RESTART ARENA?", 0, InGame_RestartAction ); |
| 127 |
break; |
| 128 |
|
| 129 |
case ID_QUIT: |
| 130 |
UI_ConfirmMenu( "EXIT GAME?", 0, InGame_QuitAction ); |
| 131 |
break; |
| 132 |
|
| 133 |
case ID_SERVERINFO: |
| 134 |
UI_ServerInfoMenu(); |
| 135 |
break; |
| 136 |
|
| 137 |
case ID_ADDBOTS: |
| 138 |
UI_AddBotsMenu(); |
| 139 |
break; |
| 140 |
|
| 141 |
case ID_REMOVEBOTS: |
| 142 |
UI_RemoveBotsMenu(); |
| 143 |
break; |
| 144 |
|
| 145 |
case ID_TEAMORDERS: |
| 146 |
UI_TeamOrdersMenu(); |
| 147 |
break; |
| 148 |
|
| 149 |
case ID_RESUME: |
| 150 |
UI_PopMenu(); |
| 151 |
break; |
| 152 |
|
| 153 |
case ID_VOTE: |
| 154 |
UI_VoteMenuMenu(); |
| 155 |
break; |
| 156 |
} |
| 157 |
} |
| 158 |
|
| 159 |
|
| 160 |
/* |
| 161 |
================= |
| 162 |
InGame_MenuInit |
| 163 |
================= |
| 164 |
*/ |
| 165 |
void InGame_MenuInit( void ) { |
| 166 |
int y; |
| 167 |
uiClientState_t cs; |
| 168 |
char info[MAX_INFO_STRING]; |
| 169 |
int team; |
| 170 |
|
| 171 |
memset( &s_ingame, 0 ,sizeof(ingamemenu_t) ); |
| 172 |
|
| 173 |
InGame_Cache(); |
| 174 |
|
| 175 |
s_ingame.menu.wrapAround = qtrue; |
| 176 |
s_ingame.menu.fullscreen = qfalse; |
| 177 |
|
| 178 |
s_ingame.frame.generic.type = MTYPE_BITMAP; |
| 179 |
s_ingame.frame.generic.flags = QMF_INACTIVE; |
| 180 |
s_ingame.frame.generic.name = INGAME_FRAME; |
| 181 |
s_ingame.frame.generic.x = 320-233;//142; |
| 182 |
s_ingame.frame.generic.y = 240-166;//118; |
| 183 |
s_ingame.frame.width = 466;//359; |
| 184 |
s_ingame.frame.height = 332;//256; |
| 185 |
|
| 186 |
//y = 96; |
| 187 |
y = 88; |
| 188 |
s_ingame.team.generic.type = MTYPE_PTEXT; |
| 189 |
s_ingame.team.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS; |
| 190 |
s_ingame.team.generic.x = 320; |
| 191 |
s_ingame.team.generic.y = y; |
| 192 |
s_ingame.team.generic.id = ID_TEAM; |
| 193 |
s_ingame.team.generic.callback = InGame_Event; |
| 194 |
s_ingame.team.string = "START"; |
| 195 |
s_ingame.team.color = color_red; |
| 196 |
s_ingame.team.style = UI_CENTER|UI_SMALLFONT; |
| 197 |
|
| 198 |
y += INGAME_MENU_VERTICAL_SPACING; |
| 199 |
s_ingame.addbots.generic.type = MTYPE_PTEXT; |
| 200 |
s_ingame.addbots.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS; |
| 201 |
s_ingame.addbots.generic.x = 320; |
| 202 |
s_ingame.addbots.generic.y = y; |
| 203 |
s_ingame.addbots.generic.id = ID_ADDBOTS; |
| 204 |
s_ingame.addbots.generic.callback = InGame_Event; |
| 205 |
s_ingame.addbots.string = "ADD BOTS"; |
| 206 |
s_ingame.addbots.color = color_red; |
| 207 |
s_ingame.addbots.style = UI_CENTER|UI_SMALLFONT; |
| 208 |
if( !trap_Cvar_VariableValue( "sv_running" ) || !trap_Cvar_VariableValue( "bot_enable" ) || (trap_Cvar_VariableValue( "g_gametype" ) == GT_SINGLE_PLAYER)) { |
| 209 |
s_ingame.addbots.generic.flags |= QMF_GRAYED; |
| 210 |
} |
| 211 |
|
| 212 |
y += INGAME_MENU_VERTICAL_SPACING; |
| 213 |
s_ingame.removebots.generic.type = MTYPE_PTEXT; |
| 214 |
s_ingame.removebots.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS; |
| 215 |
s_ingame.removebots.generic.x = 320; |
| 216 |
s_ingame.removebots.generic.y = y; |
| 217 |
s_ingame.removebots.generic.id = ID_REMOVEBOTS; |
| 218 |
s_ingame.removebots.generic.callback = InGame_Event; |
| 219 |
s_ingame.removebots.string = "REMOVE BOTS"; |
| 220 |
s_ingame.removebots.color = color_red; |
| 221 |
s_ingame.removebots.style = UI_CENTER|UI_SMALLFONT; |
| 222 |
if( !trap_Cvar_VariableValue( "sv_running" ) || !trap_Cvar_VariableValue( "bot_enable" ) || (trap_Cvar_VariableValue( "g_gametype" ) == GT_SINGLE_PLAYER)) { |
| 223 |
s_ingame.removebots.generic.flags |= QMF_GRAYED; |
| 224 |
} |
| 225 |
|
| 226 |
y += INGAME_MENU_VERTICAL_SPACING; |
| 227 |
s_ingame.teamorders.generic.type = MTYPE_PTEXT; |
| 228 |
s_ingame.teamorders.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS; |
| 229 |
s_ingame.teamorders.generic.x = 320; |
| 230 |
s_ingame.teamorders.generic.y = y; |
| 231 |
s_ingame.teamorders.generic.id = ID_TEAMORDERS; |
| 232 |
s_ingame.teamorders.generic.callback = InGame_Event; |
| 233 |
s_ingame.teamorders.string = "TEAM ORDERS"; |
| 234 |
s_ingame.teamorders.color = color_red; |
| 235 |
s_ingame.teamorders.style = UI_CENTER|UI_SMALLFONT; |
| 236 |
if( !(trap_Cvar_VariableValue( "g_gametype" ) >= GT_TEAM) || (trap_Cvar_VariableValue( "g_gametype" ) == GT_LMS ) ) { |
| 237 |
s_ingame.teamorders.generic.flags |= QMF_GRAYED; |
| 238 |
} |
| 239 |
else { |
| 240 |
trap_GetClientState( &cs ); |
| 241 |
trap_GetConfigString( CS_PLAYERS + cs.clientNum, info, MAX_INFO_STRING ); |
| 242 |
team = atoi( Info_ValueForKey( info, "t" ) ); |
| 243 |
if( team == TEAM_SPECTATOR ) { |
| 244 |
s_ingame.teamorders.generic.flags |= QMF_GRAYED; |
| 245 |
} |
| 246 |
} |
| 247 |
|
| 248 |
y += INGAME_MENU_VERTICAL_SPACING; |
| 249 |
s_ingame.vote.generic.type = MTYPE_PTEXT; |
| 250 |
s_ingame.vote.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS; |
| 251 |
s_ingame.vote.generic.x = 320; |
| 252 |
s_ingame.vote.generic.y = y; |
| 253 |
s_ingame.vote.generic.id = ID_VOTE; |
| 254 |
s_ingame.vote.generic.callback = InGame_Event; |
| 255 |
s_ingame.vote.string = "CALL VOTE"; |
| 256 |
s_ingame.vote.color = color_red; |
| 257 |
s_ingame.vote.style = UI_CENTER|UI_SMALLFONT; |
| 258 |
trap_GetConfigString( CS_SERVERINFO, info, MAX_INFO_STRING ); |
| 259 |
if( atoi( Info_ValueForKey(info,"g_allowVote") )==0 || trap_Cvar_VariableValue("g_gametype")==GT_SINGLE_PLAYER ) { |
| 260 |
s_ingame.vote.generic.flags |= QMF_GRAYED; |
| 261 |
} |
| 262 |
|
| 263 |
y += INGAME_MENU_VERTICAL_SPACING; |
| 264 |
s_ingame.setup.generic.type = MTYPE_PTEXT; |
| 265 |
s_ingame.setup.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS; |
| 266 |
s_ingame.setup.generic.x = 320; |
| 267 |
s_ingame.setup.generic.y = y; |
| 268 |
s_ingame.setup.generic.id = ID_SETUP; |
| 269 |
s_ingame.setup.generic.callback = InGame_Event; |
| 270 |
s_ingame.setup.string = "SETUP"; |
| 271 |
s_ingame.setup.color = color_red; |
| 272 |
s_ingame.setup.style = UI_CENTER|UI_SMALLFONT; |
| 273 |
|
| 274 |
y += INGAME_MENU_VERTICAL_SPACING; |
| 275 |
s_ingame.server.generic.type = MTYPE_PTEXT; |
| 276 |
s_ingame.server.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS; |
| 277 |
s_ingame.server.generic.x = 320; |
| 278 |
s_ingame.server.generic.y = y; |
| 279 |
s_ingame.server.generic.id = ID_SERVERINFO; |
| 280 |
s_ingame.server.generic.callback = InGame_Event; |
| 281 |
s_ingame.server.string = "SERVER INFO"; |
| 282 |
s_ingame.server.color = color_red; |
| 283 |
s_ingame.server.style = UI_CENTER|UI_SMALLFONT; |
| 284 |
|
| 285 |
y += INGAME_MENU_VERTICAL_SPACING; |
| 286 |
s_ingame.restart.generic.type = MTYPE_PTEXT; |
| 287 |
s_ingame.restart.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS; |
| 288 |
s_ingame.restart.generic.x = 320; |
| 289 |
s_ingame.restart.generic.y = y; |
| 290 |
s_ingame.restart.generic.id = ID_RESTART; |
| 291 |
s_ingame.restart.generic.callback = InGame_Event; |
| 292 |
s_ingame.restart.string = "RESTART ARENA"; |
| 293 |
s_ingame.restart.color = color_red; |
| 294 |
s_ingame.restart.style = UI_CENTER|UI_SMALLFONT; |
| 295 |
if( !trap_Cvar_VariableValue( "sv_running" ) ) { |
| 296 |
s_ingame.restart.generic.flags |= QMF_GRAYED; |
| 297 |
} |
| 298 |
|
| 299 |
y += INGAME_MENU_VERTICAL_SPACING; |
| 300 |
s_ingame.resume.generic.type = MTYPE_PTEXT; |
| 301 |
s_ingame.resume.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS; |
| 302 |
s_ingame.resume.generic.x = 320; |
| 303 |
s_ingame.resume.generic.y = y; |
| 304 |
s_ingame.resume.generic.id = ID_RESUME; |
| 305 |
s_ingame.resume.generic.callback = InGame_Event; |
| 306 |
s_ingame.resume.string = "RESUME GAME"; |
| 307 |
s_ingame.resume.color = color_red; |
| 308 |
s_ingame.resume.style = UI_CENTER|UI_SMALLFONT; |
| 309 |
|
| 310 |
y += INGAME_MENU_VERTICAL_SPACING; |
| 311 |
s_ingame.leave.generic.type = MTYPE_PTEXT; |
| 312 |
s_ingame.leave.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS; |
| 313 |
s_ingame.leave.generic.x = 320; |
| 314 |
s_ingame.leave.generic.y = y; |
| 315 |
s_ingame.leave.generic.id = ID_LEAVEARENA; |
| 316 |
s_ingame.leave.generic.callback = InGame_Event; |
| 317 |
s_ingame.leave.string = "LEAVE ARENA"; |
| 318 |
s_ingame.leave.color = color_red; |
| 319 |
s_ingame.leave.style = UI_CENTER|UI_SMALLFONT; |
| 320 |
|
| 321 |
y += INGAME_MENU_VERTICAL_SPACING; |
| 322 |
s_ingame.quit.generic.type = MTYPE_PTEXT; |
| 323 |
s_ingame.quit.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS; |
| 324 |
s_ingame.quit.generic.x = 320; |
| 325 |
s_ingame.quit.generic.y = y; |
| 326 |
s_ingame.quit.generic.id = ID_QUIT; |
| 327 |
s_ingame.quit.generic.callback = InGame_Event; |
| 328 |
s_ingame.quit.string = "EXIT GAME"; |
| 329 |
s_ingame.quit.color = color_red; |
| 330 |
s_ingame.quit.style = UI_CENTER|UI_SMALLFONT; |
| 331 |
|
| 332 |
Menu_AddItem( &s_ingame.menu, &s_ingame.frame ); |
| 333 |
Menu_AddItem( &s_ingame.menu, &s_ingame.team ); |
| 334 |
Menu_AddItem( &s_ingame.menu, &s_ingame.addbots ); |
| 335 |
Menu_AddItem( &s_ingame.menu, &s_ingame.removebots ); |
| 336 |
Menu_AddItem( &s_ingame.menu, &s_ingame.teamorders ); |
| 337 |
Menu_AddItem( &s_ingame.menu, &s_ingame.vote ); |
| 338 |
Menu_AddItem( &s_ingame.menu, &s_ingame.setup ); |
| 339 |
Menu_AddItem( &s_ingame.menu, &s_ingame.server ); |
| 340 |
Menu_AddItem( &s_ingame.menu, &s_ingame.restart ); |
| 341 |
Menu_AddItem( &s_ingame.menu, &s_ingame.resume ); |
| 342 |
Menu_AddItem( &s_ingame.menu, &s_ingame.leave ); |
| 343 |
Menu_AddItem( &s_ingame.menu, &s_ingame.quit ); |
| 344 |
} |
| 345 |
|
| 346 |
|
| 347 |
/* |
| 348 |
================= |
| 349 |
InGame_Cache |
| 350 |
================= |
| 351 |
*/ |
| 352 |
void InGame_Cache( void ) { |
| 353 |
trap_R_RegisterShaderNoMip( INGAME_FRAME ); |
| 354 |
} |
| 355 |
|
| 356 |
|
| 357 |
/* |
| 358 |
================= |
| 359 |
UI_InGameMenu |
| 360 |
================= |
| 361 |
*/ |
| 362 |
void UI_InGameMenu( void ) { |
| 363 |
// force as top level menu |
| 364 |
uis.menusp = 0; |
| 365 |
|
| 366 |
// set menu cursor to a nice location |
| 367 |
uis.cursorx = 319; |
| 368 |
uis.cursory = 80; |
| 369 |
|
| 370 |
InGame_MenuInit(); |
| 371 |
UI_PushMenu( &s_ingame.menu ); |
| 372 |
} |