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 // ui_rankstatus.c 00025 // 00026 00027 #include "ui_local.h" 00028 00029 00030 #define RANKSTATUS_FRAME "menu/art/cut_frame" 00031 00032 #define ID_MESSAGE 100 00033 #define ID_OK 101 00034 00035 00036 typedef struct 00037 { 00038 menuframework_s menu; 00039 menubitmap_s frame; 00040 menutext_s message; 00041 menutext_s ok; 00042 } rankstatus_t; 00043 00044 static rankstatus_t s_rankstatus; 00045 00046 static menuframework_s s_rankstatus_menu; 00047 static menuaction_s s_rankstatus_ok; 00048 00049 static grank_status_t s_status = 0; 00050 static char* s_rankstatus_message = NULL; 00051 00052 static vec4_t s_rankingstatus_color_prompt = {1.00, 0.43, 0.00, 1.00}; 00053 00054 /* 00055 =============== 00056 RankStatus_MenuEvent 00057 =============== 00058 */ 00059 static void RankStatus_MenuEvent( void* ptr, int event ) { 00060 if( event != QM_ACTIVATED ) { 00061 return; 00062 } 00063 00064 switch( ((menucommon_s*)ptr)->id ) { 00065 case ID_OK: 00066 UI_PopMenu(); 00067 00068 switch( s_status ) 00069 { 00070 case QGR_STATUS_NO_USER: 00071 UI_RankingsMenu(); 00072 break; 00073 case QGR_STATUS_BAD_PASSWORD: 00074 UI_RankingsMenu(); 00075 UI_LoginMenu(); 00076 break; 00077 case QGR_STATUS_USER_EXISTS: 00078 UI_RankingsMenu(); 00079 UI_SignupMenu(); 00080 break; 00081 case QGR_STATUS_NO_MEMBERSHIP: 00082 UI_RankingsMenu(); 00083 break; 00084 case QGR_STATUS_TIMEOUT: 00085 UI_RankingsMenu(); 00086 break; 00087 case QGR_STATUS_INVALIDUSER: 00088 UI_RankingsMenu(); 00089 break; 00090 case QGR_STATUS_ERROR: 00091 UI_RankingsMenu(); 00092 break; 00093 default: 00094 break; 00095 } 00096 00097 break; 00098 } 00099 } 00100 00101 00102 /* 00103 =============== 00104 RankStatus_MenuInit 00105 =============== 00106 */ 00107 void RankStatus_MenuInit( void ) { 00108 int y; 00109 00110 memset( &s_rankstatus, 0, sizeof(s_rankstatus) ); 00111 00112 RankStatus_Cache(); 00113 00114 s_rankstatus.menu.wrapAround = qtrue; 00115 s_rankstatus.menu.fullscreen = qfalse; 00116 00117 s_rankstatus.frame.generic.type = MTYPE_BITMAP; 00118 s_rankstatus.frame.generic.flags = QMF_INACTIVE; 00119 s_rankstatus.frame.generic.name = RANKSTATUS_FRAME; 00120 s_rankstatus.frame.generic.x = 142; //320-233; 00121 s_rankstatus.frame.generic.y = 118; //240-166; 00122 s_rankstatus.frame.width = 359; //466; 00123 s_rankstatus.frame.height = 256; //332; 00124 00125 y = 214; 00126 00127 s_rankstatus.message.generic.type = MTYPE_PTEXT; 00128 s_rankstatus.message.generic.flags = QMF_CENTER_JUSTIFY|QMF_INACTIVE; 00129 s_rankstatus.message.generic.id = ID_MESSAGE; 00130 s_rankstatus.message.generic.x = 320; 00131 s_rankstatus.message.generic.y = y; 00132 s_rankstatus.message.string = s_rankstatus_message; 00133 s_rankstatus.message.style = UI_CENTER|UI_SMALLFONT; 00134 s_rankstatus.message.color = s_rankingstatus_color_prompt; 00135 y += 40; 00136 00137 s_rankstatus.ok.generic.type = MTYPE_PTEXT; 00138 s_rankstatus.ok.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS; 00139 s_rankstatus.ok.generic.id = ID_OK; 00140 s_rankstatus.ok.generic.callback = RankStatus_MenuEvent; 00141 s_rankstatus.ok.generic.x = 320; 00142 s_rankstatus.ok.generic.y = y; 00143 s_rankstatus.ok.string = "OK"; 00144 s_rankstatus.ok.style = UI_CENTER|UI_SMALLFONT; 00145 s_rankstatus.ok.color = colorRed; 00146 00147 Menu_AddItem( &s_rankstatus.menu, (void*) &s_rankstatus.frame ); 00148 Menu_AddItem( &s_rankstatus.menu, (void*) &s_rankstatus.message ); 00149 Menu_AddItem( &s_rankstatus.menu, (void*) &s_rankstatus.ok ); 00150 } 00151 00152 00153 /* 00154 =============== 00155 RankStatus_Cache 00156 =============== 00157 */ 00158 void RankStatus_Cache( void ) { 00159 trap_R_RegisterShaderNoMip( RANKSTATUS_FRAME ); 00160 } 00161 00162 00163 /* 00164 =============== 00165 UI_RankStatusMenu 00166 =============== 00167 */ 00168 void UI_RankStatusMenu( void ) { 00169 00170 s_status = (grank_status_t)trap_Cvar_VariableValue("client_status"); 00171 00172 switch( s_status ) 00173 { 00174 case QGR_STATUS_NEW: 00175 return; 00176 case QGR_STATUS_PENDING: 00177 // GRANK_FIXME 00178 return; 00179 case QGR_STATUS_NO_USER: 00180 // GRANK_FIXME - get this when user exists 00181 s_rankstatus_message = "Username unavailable"; 00182 break; 00183 case QGR_STATUS_BAD_PASSWORD: 00184 s_rankstatus_message = "Invalid password"; 00185 break; 00186 case QGR_STATUS_TIMEOUT: 00187 s_rankstatus_message = "Timed out"; 00188 break; 00189 case QGR_STATUS_NO_MEMBERSHIP: 00190 s_rankstatus_message = "No membership"; 00191 break; 00192 case QGR_STATUS_INVALIDUSER: 00193 s_rankstatus_message = "Validation failed"; 00194 break; 00195 case QGR_STATUS_ERROR: 00196 s_rankstatus_message = "Error"; 00197 break; 00198 case QGR_STATUS_SPECTATOR: 00199 case QGR_STATUS_ACTIVE: 00200 UI_ForceMenuOff(); 00201 return; 00202 default: 00203 return; 00204 } 00205 RankStatus_MenuInit(); 00206 trap_CL_UI_RankUserReset(); 00207 UI_PushMenu ( &s_rankstatus.menu ); 00208 } 00209
1.3.9.1