| 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. |
| 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 |
RESET MENU |
| 26 |
|
| 27 |
======================================================================= |
| 28 |
*/ |
| 29 |
|
| 30 |
#include "ui_local.h" |
| 31 |
|
| 32 |
|
| 33 |
#define ART_FRAME "menu/art/cut_frame" |
| 34 |
|
| 35 |
#define ID_NO 100 |
| 36 |
#define ID_YES 101 |
| 37 |
|
| 38 |
typedef struct |
| 39 |
{ |
| 40 |
menuframework_s menu; |
| 41 |
menutext_s no; |
| 42 |
menutext_s yes; |
| 43 |
int slashX; |
| 44 |
} resetMenu_t; |
| 45 |
|
| 46 |
static resetMenu_t s_reset; |
| 47 |
|
| 48 |
|
| 49 |
/* |
| 50 |
================= |
| 51 |
Reset_MenuEvent |
| 52 |
================= |
| 53 |
*/ |
| 54 |
void Reset_MenuEvent(void* ptr, int event) { |
| 55 |
if( event != QM_ACTIVATED ) { |
| 56 |
return; |
| 57 |
} |
| 58 |
|
| 59 |
UI_PopMenu(); |
| 60 |
|
| 61 |
if( ((menucommon_s*)ptr)->id == ID_NO ) { |
| 62 |
return; |
| 63 |
} |
| 64 |
|
| 65 |
// reset the game, pop the level menu and restart it so it updates |
| 66 |
UI_NewGame(); |
| 67 |
trap_Cvar_SetValue( "ui_spSelection", 0 ); |
| 68 |
UI_PopMenu(); |
| 69 |
UI_SPLevelMenu(); |
| 70 |
} |
| 71 |
|
| 72 |
|
| 73 |
/* |
| 74 |
================= |
| 75 |
Reset_MenuKey |
| 76 |
================= |
| 77 |
*/ |
| 78 |
static sfxHandle_t Reset_MenuKey( int key ) { |
| 79 |
switch ( key ) { |
| 80 |
case K_LEFTARROW: |
| 81 |
case K_RIGHTARROW: |
| 82 |
key = K_TAB; |
| 83 |
break; |
| 84 |
|
| 85 |
case 'n': |
| 86 |
case 'N': |
| 87 |
Reset_MenuEvent( &s_reset.no, QM_ACTIVATED ); |
| 88 |
break; |
| 89 |
|
| 90 |
case 'y': |
| 91 |
case 'Y': |
| 92 |
Reset_MenuEvent( &s_reset.yes, QM_ACTIVATED ); |
| 93 |
break; |
| 94 |
} |
| 95 |
|
| 96 |
return Menu_DefaultKey( &s_reset.menu, key ); |
| 97 |
} |
| 98 |
|
| 99 |
|
| 100 |
/* |
| 101 |
================= |
| 102 |
Reset_MenuDraw |
| 103 |
================= |
| 104 |
*/ |
| 105 |
static void Reset_MenuDraw( void ) { |
| 106 |
UI_DrawNamedPic( 142, 118, 359, 256, ART_FRAME ); |
| 107 |
UI_DrawProportionalString( 320, 194 + 10, "RESET GAME?", UI_CENTER|UI_INVERSE, color_red ); |
| 108 |
UI_DrawProportionalString( s_reset.slashX, 265, "/", UI_LEFT|UI_INVERSE, color_red ); |
| 109 |
Menu_Draw( &s_reset.menu ); |
| 110 |
|
| 111 |
UI_DrawProportionalString( SCREEN_WIDTH/2, 356 + PROP_HEIGHT * 0, "WARNING: This resets all of the", UI_CENTER|UI_SMALLFONT, color_yellow ); |
| 112 |
UI_DrawProportionalString( SCREEN_WIDTH/2, 356 + PROP_HEIGHT * 1, "single player game variables.", UI_CENTER|UI_SMALLFONT, color_yellow ); |
| 113 |
UI_DrawProportionalString( SCREEN_WIDTH/2, 356 + PROP_HEIGHT * 2, "Do this only if you want to", UI_CENTER|UI_SMALLFONT, color_yellow ); |
| 114 |
UI_DrawProportionalString( SCREEN_WIDTH/2, 356 + PROP_HEIGHT * 3, "start over from the beginning.", UI_CENTER|UI_SMALLFONT, color_yellow ); |
| 115 |
} |
| 116 |
|
| 117 |
|
| 118 |
/* |
| 119 |
================= |
| 120 |
Reset_Cache |
| 121 |
================= |
| 122 |
*/ |
| 123 |
void Reset_Cache( void ) { |
| 124 |
trap_R_RegisterShaderNoMip( ART_FRAME ); |
| 125 |
} |
| 126 |
|
| 127 |
|
| 128 |
/* |
| 129 |
================= |
| 130 |
UI_ResetMenu |
| 131 |
================= |
| 132 |
*/ |
| 133 |
void UI_ResetMenu(void) { |
| 134 |
uiClientState_t cstate; |
| 135 |
int n1, n2, n3; |
| 136 |
int l1, l2, l3; |
| 137 |
|
| 138 |
// zero set all our globals |
| 139 |
memset( &s_reset, 0, sizeof(s_reset) ); |
| 140 |
|
| 141 |
Reset_Cache(); |
| 142 |
|
| 143 |
n1 = UI_ProportionalStringWidth( "YES/NO" ); |
| 144 |
n2 = UI_ProportionalStringWidth( "YES" ) + PROP_GAP_WIDTH; |
| 145 |
n3 = UI_ProportionalStringWidth( "/" ) + PROP_GAP_WIDTH; |
| 146 |
l1 = 320 - ( n1 / 2 ); |
| 147 |
l2 = l1 + n2; |
| 148 |
l3 = l2 + n3; |
| 149 |
s_reset.slashX = l2; |
| 150 |
|
| 151 |
s_reset.menu.draw = Reset_MenuDraw; |
| 152 |
s_reset.menu.key = Reset_MenuKey; |
| 153 |
s_reset.menu.wrapAround = qtrue; |
| 154 |
|
| 155 |
trap_GetClientState( &cstate ); |
| 156 |
|
| 157 |
if ( cstate.connState >= CA_CONNECTED ) { |
| 158 |
// float on top of running game |
| 159 |
s_reset.menu.fullscreen = qfalse; |
| 160 |
} |
| 161 |
else { |
| 162 |
// game not running |
| 163 |
s_reset.menu.fullscreen = qtrue; |
| 164 |
} |
| 165 |
|
| 166 |
s_reset.yes.generic.type = MTYPE_PTEXT; |
| 167 |
s_reset.yes.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS; |
| 168 |
s_reset.yes.generic.callback = Reset_MenuEvent; |
| 169 |
s_reset.yes.generic.id = ID_YES; |
| 170 |
s_reset.yes.generic.x = l1; |
| 171 |
s_reset.yes.generic.y = 264; |
| 172 |
s_reset.yes.string = "YES"; |
| 173 |
s_reset.yes.color = color_red; |
| 174 |
s_reset.yes.style = UI_LEFT; |
| 175 |
|
| 176 |
s_reset.no.generic.type = MTYPE_PTEXT; |
| 177 |
s_reset.no.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS; |
| 178 |
s_reset.no.generic.callback = Reset_MenuEvent; |
| 179 |
s_reset.no.generic.id = ID_NO; |
| 180 |
s_reset.no.generic.x = l3; |
| 181 |
s_reset.no.generic.y = 264; |
| 182 |
s_reset.no.string = "NO"; |
| 183 |
s_reset.no.color = color_red; |
| 184 |
s_reset.no.style = UI_LEFT; |
| 185 |
|
| 186 |
Menu_AddItem( &s_reset.menu, &s_reset.yes ); |
| 187 |
Menu_AddItem( &s_reset.menu, &s_reset.no ); |
| 188 |
|
| 189 |
UI_PushMenu( &s_reset.menu ); |
| 190 |
|
| 191 |
Menu_SetCursorToItem( &s_reset.menu, &s_reset.no ); |
| 192 |
} |