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

ui_spreset.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 RESET MENU
00026 
00027 =======================================================================
00028 */
00029 
00030 #include "ui_local.h"
00031 
00032 
00033 #define ART_FRAME                   "menu/art/cut_frame"
00034 
00035 #define ID_NO       100
00036 #define ID_YES      101
00037 
00038 typedef struct
00039 {
00040     menuframework_s menu;
00041     menutext_s      no;
00042     menutext_s      yes;
00043     int             slashX;
00044 } resetMenu_t;
00045 
00046 static resetMenu_t  s_reset;
00047 
00048 
00049 /*
00050 =================
00051 Reset_MenuEvent
00052 =================
00053 */
00054 void Reset_MenuEvent(void* ptr, int event) {
00055     if( event != QM_ACTIVATED ) {
00056         return;
00057     }
00058 
00059     UI_PopMenu();
00060 
00061     if( ((menucommon_s*)ptr)->id == ID_NO ) {
00062         return;
00063     }
00064 
00065     // reset the game, pop the level menu and restart it so it updates
00066     UI_NewGame();
00067     trap_Cvar_SetValue( "ui_spSelection", 0 );
00068     UI_PopMenu();
00069     UI_SPLevelMenu();
00070 }
00071 
00072 
00073 /*
00074 =================
00075 Reset_MenuKey
00076 =================
00077 */
00078 static sfxHandle_t Reset_MenuKey( int key ) {
00079     switch ( key ) {
00080     case K_KP_LEFTARROW:
00081     case K_LEFTARROW:
00082     case K_KP_RIGHTARROW:
00083     case K_RIGHTARROW:
00084         key = K_TAB;
00085         break;
00086 
00087     case 'n':
00088     case 'N':
00089         Reset_MenuEvent( &s_reset.no, QM_ACTIVATED );
00090         break;
00091 
00092     case 'y':
00093     case 'Y':
00094         Reset_MenuEvent( &s_reset.yes, QM_ACTIVATED );
00095         break;
00096     }
00097 
00098     return Menu_DefaultKey( &s_reset.menu, key );
00099 }
00100 
00101 
00102 /*
00103 =================
00104 Reset_MenuDraw
00105 =================
00106 */
00107 static void Reset_MenuDraw( void ) {
00108     UI_DrawNamedPic( 142, 118, 359, 256, ART_FRAME );
00109     UI_DrawProportionalString( 320, 194 + 10, "RESET GAME?", UI_CENTER|UI_INVERSE, color_red );
00110     UI_DrawProportionalString( s_reset.slashX, 265, "/", UI_LEFT|UI_INVERSE, color_red );
00111     Menu_Draw( &s_reset.menu );
00112 
00113     UI_DrawProportionalString( SCREEN_WIDTH/2, 356 + PROP_HEIGHT * 0, "WARNING: This resets all of the", UI_CENTER|UI_SMALLFONT, color_yellow );
00114     UI_DrawProportionalString( SCREEN_WIDTH/2, 356 + PROP_HEIGHT * 1, "single player game variables.", UI_CENTER|UI_SMALLFONT, color_yellow );
00115     UI_DrawProportionalString( SCREEN_WIDTH/2, 356 + PROP_HEIGHT * 2, "Do this only if you want to", UI_CENTER|UI_SMALLFONT, color_yellow );
00116     UI_DrawProportionalString( SCREEN_WIDTH/2, 356 + PROP_HEIGHT * 3, "start over from the beginning.", UI_CENTER|UI_SMALLFONT, color_yellow );
00117 }
00118 
00119 
00120 /*
00121 =================
00122 Reset_Cache
00123 =================
00124 */
00125 void Reset_Cache( void ) {
00126     trap_R_RegisterShaderNoMip( ART_FRAME );
00127 }
00128 
00129 
00130 /*
00131 =================
00132 UI_ResetMenu
00133 =================
00134 */
00135 void UI_ResetMenu(void) {
00136     uiClientState_t cstate;
00137     int n1, n2, n3;
00138     int l1, l2, l3;
00139 
00140     // zero set all our globals
00141     memset( &s_reset, 0, sizeof(s_reset) );
00142 
00143     Reset_Cache();
00144 
00145     n1 = UI_ProportionalStringWidth( "YES/NO" );
00146     n2 = UI_ProportionalStringWidth( "YES" ) + PROP_GAP_WIDTH;
00147     n3 = UI_ProportionalStringWidth( "/" )  + PROP_GAP_WIDTH;
00148     l1 = 320 - ( n1 / 2 );
00149     l2 = l1 + n2;
00150     l3 = l2 + n3;
00151     s_reset.slashX = l2;
00152 
00153     s_reset.menu.draw       = Reset_MenuDraw;
00154     s_reset.menu.key        = Reset_MenuKey;
00155     s_reset.menu.wrapAround = qtrue;
00156 
00157     trap_GetClientState( &cstate );
00158 
00159     if ( cstate.connState >= CA_CONNECTED ) {
00160         // float on top of running game
00161         s_reset.menu.fullscreen = qfalse;
00162     }
00163     else {
00164         // game not running
00165         s_reset.menu.fullscreen = qtrue;
00166     }
00167 
00168     s_reset.yes.generic.type        = MTYPE_PTEXT;      
00169     s_reset.yes.generic.flags       = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS; 
00170     s_reset.yes.generic.callback    = Reset_MenuEvent;
00171     s_reset.yes.generic.id          = ID_YES;
00172     s_reset.yes.generic.x           = l1;
00173     s_reset.yes.generic.y           = 264;
00174     s_reset.yes.string              = "YES";
00175     s_reset.yes.color               = color_red;
00176     s_reset.yes.style               = UI_LEFT;
00177 
00178     s_reset.no.generic.type         = MTYPE_PTEXT;      
00179     s_reset.no.generic.flags        = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS; 
00180     s_reset.no.generic.callback     = Reset_MenuEvent;
00181     s_reset.no.generic.id           = ID_NO;
00182     s_reset.no.generic.x            = l3;
00183     s_reset.no.generic.y            = 264;
00184     s_reset.no.string               = "NO";
00185     s_reset.no.color                = color_red;
00186     s_reset.no.style                = UI_LEFT;
00187 
00188     Menu_AddItem( &s_reset.menu,    &s_reset.yes );             
00189     Menu_AddItem( &s_reset.menu,    &s_reset.no );
00190 
00191     UI_PushMenu( &s_reset.menu );
00192 
00193     Menu_SetCursorToItem( &s_reset.menu, &s_reset.no );
00194 }

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