ui_rankstatus.c (5076B)
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 Foobar; 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 // ui_rankstatus.c 25 // 26 27 #include "ui_local.h" 28 29 30 #define RANKSTATUS_FRAME "menu/art/cut_frame" 31 32 #define ID_MESSAGE 100 33 #define ID_OK 101 34 35 36 typedef struct 37 { 38 menuframework_s menu; 39 menubitmap_s frame; 40 menutext_s message; 41 menutext_s ok; 42 } rankstatus_t; 43 44 static rankstatus_t s_rankstatus; 45 46 static menuframework_s s_rankstatus_menu; 47 static menuaction_s s_rankstatus_ok; 48 49 static grank_status_t s_status = 0; 50 static char* s_rankstatus_message = NULL; 51 52 static vec4_t s_rankingstatus_color_prompt = {1.00, 0.43, 0.00, 1.00}; 53 54 /* 55 =============== 56 RankStatus_MenuEvent 57 =============== 58 */ 59 static void RankStatus_MenuEvent( void* ptr, int event ) { 60 if( event != QM_ACTIVATED ) { 61 return; 62 } 63 64 switch( ((menucommon_s*)ptr)->id ) { 65 case ID_OK: 66 UI_PopMenu(); 67 68 switch( s_status ) 69 { 70 case QGR_STATUS_NO_USER: 71 UI_RankingsMenu(); 72 break; 73 case QGR_STATUS_BAD_PASSWORD: 74 UI_RankingsMenu(); 75 UI_LoginMenu(); 76 break; 77 case QGR_STATUS_USER_EXISTS: 78 UI_RankingsMenu(); 79 UI_SignupMenu(); 80 break; 81 case QGR_STATUS_NO_MEMBERSHIP: 82 UI_RankingsMenu(); 83 break; 84 case QGR_STATUS_TIMEOUT: 85 UI_RankingsMenu(); 86 break; 87 case QGR_STATUS_INVALIDUSER: 88 UI_RankingsMenu(); 89 break; 90 case QGR_STATUS_ERROR: 91 UI_RankingsMenu(); 92 break; 93 default: 94 break; 95 } 96 97 break; 98 } 99 } 100 101 102 /* 103 =============== 104 RankStatus_MenuInit 105 =============== 106 */ 107 void RankStatus_MenuInit( void ) { 108 int y; 109 110 memset( &s_rankstatus, 0, sizeof(s_rankstatus) ); 111 112 RankStatus_Cache(); 113 114 s_rankstatus.menu.wrapAround = qtrue; 115 s_rankstatus.menu.fullscreen = qfalse; 116 117 s_rankstatus.frame.generic.type = MTYPE_BITMAP; 118 s_rankstatus.frame.generic.flags = QMF_INACTIVE; 119 s_rankstatus.frame.generic.name = RANKSTATUS_FRAME; 120 s_rankstatus.frame.generic.x = 142; //320-233; 121 s_rankstatus.frame.generic.y = 118; //240-166; 122 s_rankstatus.frame.width = 359; //466; 123 s_rankstatus.frame.height = 256; //332; 124 125 y = 214; 126 127 s_rankstatus.message.generic.type = MTYPE_PTEXT; 128 s_rankstatus.message.generic.flags = QMF_CENTER_JUSTIFY|QMF_INACTIVE; 129 s_rankstatus.message.generic.id = ID_MESSAGE; 130 s_rankstatus.message.generic.x = 320; 131 s_rankstatus.message.generic.y = y; 132 s_rankstatus.message.string = s_rankstatus_message; 133 s_rankstatus.message.style = UI_CENTER|UI_SMALLFONT; 134 s_rankstatus.message.color = s_rankingstatus_color_prompt; 135 y += 40; 136 137 s_rankstatus.ok.generic.type = MTYPE_PTEXT; 138 s_rankstatus.ok.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS; 139 s_rankstatus.ok.generic.id = ID_OK; 140 s_rankstatus.ok.generic.callback = RankStatus_MenuEvent; 141 s_rankstatus.ok.generic.x = 320; 142 s_rankstatus.ok.generic.y = y; 143 s_rankstatus.ok.string = "OK"; 144 s_rankstatus.ok.style = UI_CENTER|UI_SMALLFONT; 145 s_rankstatus.ok.color = colorRed; 146 147 Menu_AddItem( &s_rankstatus.menu, (void*) &s_rankstatus.frame ); 148 Menu_AddItem( &s_rankstatus.menu, (void*) &s_rankstatus.message ); 149 Menu_AddItem( &s_rankstatus.menu, (void*) &s_rankstatus.ok ); 150 } 151 152 153 /* 154 =============== 155 RankStatus_Cache 156 =============== 157 */ 158 void RankStatus_Cache( void ) { 159 trap_R_RegisterShaderNoMip( RANKSTATUS_FRAME ); 160 } 161 162 163 /* 164 =============== 165 UI_RankStatusMenu 166 =============== 167 */ 168 void UI_RankStatusMenu( void ) { 169 170 s_status = (grank_status_t)trap_Cvar_VariableValue("client_status"); 171 172 switch( s_status ) 173 { 174 case QGR_STATUS_NEW: 175 return; 176 case QGR_STATUS_PENDING: 177 // GRANK_FIXME 178 return; 179 case QGR_STATUS_NO_USER: 180 // GRANK_FIXME - get this when user exists 181 s_rankstatus_message = "Username unavailable"; 182 break; 183 case QGR_STATUS_BAD_PASSWORD: 184 s_rankstatus_message = "Invalid password"; 185 break; 186 case QGR_STATUS_TIMEOUT: 187 s_rankstatus_message = "Timed out"; 188 break; 189 case QGR_STATUS_NO_MEMBERSHIP: 190 s_rankstatus_message = "No membership"; 191 break; 192 case QGR_STATUS_INVALIDUSER: 193 s_rankstatus_message = "Validation failed"; 194 break; 195 case QGR_STATUS_ERROR: 196 s_rankstatus_message = "Error"; 197 break; 198 case QGR_STATUS_SPECTATOR: 199 case QGR_STATUS_ACTIVE: 200 UI_ForceMenuOff(); 201 return; 202 default: 203 return; 204 } 205 RankStatus_MenuInit(); 206 trap_CL_UI_RankUserReset(); 207 UI_PushMenu ( &s_rankstatus.menu ); 208 } 209