#include "ui_local.h"
Include dependency graph for ui_connect.c:

Go to the source code of this file.
Functions | |
| void | UI_DisplayDownloadInfo (const char *downloadName) |
| void | UI_DrawConnectScreen (qboolean overlay) |
| void | UI_KeyConnect (int key) |
| void | UI_PrintTime (char *buf, int bufsize, int time) |
| void | UI_ReadableSize (char *buf, int bufsize, int value) |
Variables | |
| connstate_t | lastConnState |
| char | lastLoadingText [MAX_INFO_VALUE] |
| menufield_s | passwordField |
| qboolean | passwordNeeded = qtrue |
|
|
Definition at line 69 of file ui_connect.c. References color_white, fprintf(), uiStatic_t::frametime, n, uiStatic_t::realtime, s, stderr, trap_Cvar_VariableValue(), UI_DrawProportionalString(), UI_LEFT, UI_PrintTime(), UI_ProportionalSizeScale(), UI_ProportionalStringWidth(), UI_ReadableSize(), UI_SMALLFONT, uis, va(), and width. 00069 {
00070 static char dlText[] = "Downloading:";
00071 static char etaText[] = "Estimated time left:";
00072 static char xferText[] = "Transfer rate:";
00073
00074 int downloadSize, downloadCount, downloadTime;
00075 char dlSizeBuf[64], totalSizeBuf[64], xferRateBuf[64], dlTimeBuf[64];
00076 int xferRate;
00077 int width, leftWidth;
00078 int style = UI_LEFT|UI_SMALLFONT|UI_DROPSHADOW;
00079 const char *s;
00080
00081 downloadSize = trap_Cvar_VariableValue( "cl_downloadSize" );
00082 downloadCount = trap_Cvar_VariableValue( "cl_downloadCount" );
00083 downloadTime = trap_Cvar_VariableValue( "cl_downloadTime" );
00084
00085 #if 0 // bk010104
00086 fprintf( stderr, "\n\n-----------------------------------------------\n");
00087 fprintf( stderr, "DB: downloadSize: %16d\n", downloadSize );
00088 fprintf( stderr, "DB: downloadCount: %16d\n", downloadCount );
00089 fprintf( stderr, "DB: downloadTime: %16d\n", downloadTime );
00090 fprintf( stderr, "DB: UI realtime: %16d\n", uis.realtime ); // bk
00091 fprintf( stderr, "DB: UI frametime: %16d\n", uis.frametime ); // bk
00092 #endif
00093
00094 leftWidth = width = UI_ProportionalStringWidth( dlText ) * UI_ProportionalSizeScale( style );
00095 width = UI_ProportionalStringWidth( etaText ) * UI_ProportionalSizeScale( style );
00096 if (width > leftWidth) leftWidth = width;
00097 width = UI_ProportionalStringWidth( xferText ) * UI_ProportionalSizeScale( style );
00098 if (width > leftWidth) leftWidth = width;
00099 leftWidth += 16;
00100
00101 UI_DrawProportionalString( 8, 128, dlText, style, color_white );
00102 UI_DrawProportionalString( 8, 160, etaText, style, color_white );
00103 UI_DrawProportionalString( 8, 224, xferText, style, color_white );
00104
00105 if (downloadSize > 0) {
00106 s = va( "%s (%d%%)", downloadName, downloadCount * 100 / downloadSize );
00107 } else {
00108 s = downloadName;
00109 }
00110
00111 UI_DrawProportionalString( leftWidth, 128, s, style, color_white );
00112
00113 UI_ReadableSize( dlSizeBuf, sizeof dlSizeBuf, downloadCount );
00114 UI_ReadableSize( totalSizeBuf, sizeof totalSizeBuf, downloadSize );
00115
00116 if (downloadCount < 4096 || !downloadTime) {
00117 UI_DrawProportionalString( leftWidth, 160, "estimating", style, color_white );
00118 UI_DrawProportionalString( leftWidth, 192,
00119 va("(%s of %s copied)", dlSizeBuf, totalSizeBuf), style, color_white );
00120 } else {
00121 // bk010108
00122 //float elapsedTime = (float)(uis.realtime - downloadTime); // current - start (msecs)
00123 //elapsedTime = elapsedTime * 0.001f; // in seconds
00124 //if ( elapsedTime <= 0.0f ) elapsedTime == 0.0f;
00125 if ( (uis.realtime - downloadTime) / 1000) {
00126 xferRate = downloadCount / ((uis.realtime - downloadTime) / 1000);
00127 //xferRate = (int)( ((float)downloadCount) / elapsedTime);
00128 } else {
00129 xferRate = 0;
00130 }
00131
00132 //fprintf( stderr, "DB: elapsedTime: %16.8f\n", elapsedTime ); // bk
00133 //fprintf( stderr, "DB: xferRate: %16d\n", xferRate ); // bk
00134
00135 UI_ReadableSize( xferRateBuf, sizeof xferRateBuf, xferRate );
00136
00137 // Extrapolate estimated completion time
00138 if (downloadSize && xferRate) {
00139 int n = downloadSize / xferRate; // estimated time for entire d/l in secs
00140
00141 // We do it in K (/1024) because we'd overflow around 4MB
00142 n = (n - (((downloadCount/1024) * n) / (downloadSize/1024))) * 1000;
00143
00144 UI_PrintTime ( dlTimeBuf, sizeof dlTimeBuf, n ); // bk010104
00145 //(n - (((downloadCount/1024) * n) / (downloadSize/1024))) * 1000);
00146
00147 UI_DrawProportionalString( leftWidth, 160,
00148 dlTimeBuf, style, color_white );
00149 UI_DrawProportionalString( leftWidth, 192,
00150 va("(%s of %s copied)", dlSizeBuf, totalSizeBuf), style, color_white );
00151 } else {
00152 UI_DrawProportionalString( leftWidth, 160,
00153 "estimating", style, color_white );
00154 if (downloadSize) {
00155 UI_DrawProportionalString( leftWidth, 192,
00156 va("(%s of %s copied)", dlSizeBuf, totalSizeBuf), style, color_white );
00157 } else {
00158 UI_DrawProportionalString( leftWidth, 192,
00159 va("(%s copied)", dlSizeBuf), style, color_white );
00160 }
00161 }
00162
00163 if (xferRate) {
00164 UI_DrawProportionalString( leftWidth, 224,
00165 va("%s/Sec", xferRateBuf), style, color_white );
00166 }
00167 }
00168 }
|
Here is the call graph for this function:

|
|
Definition at line 178 of file ui_connect.c. 00178 {
00179 char *s;
00180 uiClientState_t cstate;
00181 char info[MAX_INFO_VALUE];
00182
00183 Menu_Cache();
00184
00185 if ( !overlay ) {
00186 // draw the dialog background
00187 UI_SetColor( color_white );
00188 UI_DrawHandlePic( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, uis.menuBackShader );
00189 }
00190
00191 // see what information we should display
00192 trap_GetClientState( &cstate );
00193
00194 info[0] = '\0';
00195 if( trap_GetConfigString( CS_SERVERINFO, info, sizeof(info) ) ) {
00196 UI_DrawProportionalString( 320, 16, va( "Loading %s", Info_ValueForKey( info, "mapname" ) ), UI_BIGFONT|UI_CENTER|UI_DROPSHADOW, color_white );
00197 }
00198
00199 UI_DrawProportionalString( 320, 64, va("Connecting to %s", cstate.servername), UI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, menu_text_color );
00200 //UI_DrawProportionalString( 320, 96, "Press Esc to abort", UI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, menu_text_color );
00201
00202 // display global MOTD at bottom
00203 UI_DrawProportionalString( SCREEN_WIDTH/2, SCREEN_HEIGHT-32,
00204 Info_ValueForKey( cstate.updateInfoString, "motd" ), UI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, menu_text_color );
00205
00206 // print any server info (server full, bad version, etc)
00207 if ( cstate.connState < CA_CONNECTED ) {
00208 UI_DrawProportionalString_AutoWrapped( 320, 192, 630, 20, cstate.messageString, UI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, menu_text_color );
00209 }
00210
00211 #if 0
00212 // display password field
00213 if ( passwordNeeded ) {
00214 s_ingame_menu.x = SCREEN_WIDTH * 0.50 - 128;
00215 s_ingame_menu.nitems = 0;
00216 s_ingame_menu.wrapAround = qtrue;
00217
00218 passwordField.generic.type = MTYPE_FIELD;
00219 passwordField.generic.name = "Password:";
00220 passwordField.generic.callback = 0;
00221 passwordField.generic.x = 10;
00222 passwordField.generic.y = 180;
00223 Field_Clear( &passwordField.field );
00224 passwordField.width = 256;
00225 passwordField.field.widthInChars = 16;
00226 Q_strncpyz( passwordField.field.buffer, Cvar_VariableString("password"),
00227 sizeof(passwordField.field.buffer) );
00228
00229 Menu_AddItem( &s_ingame_menu, ( void * ) &s_customize_player_action );
00230
00231 MField_Draw( &passwordField );
00232 }
00233 #endif
00234
00235 if ( lastConnState > cstate.connState ) {
00236 lastLoadingText[0] = '\0';
00237 }
00238 lastConnState = cstate.connState;
00239
00240 switch ( cstate.connState ) {
00241 case CA_CONNECTING:
00242 s = va("Awaiting challenge...%i", cstate.connectPacketCount);
00243 break;
00244 case CA_CHALLENGING:
00245 s = va("Awaiting connection...%i", cstate.connectPacketCount);
00246 break;
00247 case CA_CONNECTED: {
00248 char downloadName[MAX_INFO_VALUE];
00249
00250 trap_Cvar_VariableStringBuffer( "cl_downloadName", downloadName, sizeof(downloadName) );
00251 if (*downloadName) {
00252 UI_DisplayDownloadInfo( downloadName );
00253 return;
00254 }
00255 }
00256 s = "Awaiting gamestate...";
00257 break;
00258 case CA_LOADING:
00259 return;
00260 case CA_PRIMED:
00261 return;
00262 default:
00263 return;
00264 }
00265
00266 UI_DrawProportionalString( 320, 128, s, UI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, color_white );
00267
00268 // password required / connection rejected information goes here
00269 }
|
|
|
Definition at line 277 of file ui_connect.c. References EXEC_APPEND, and trap_Cmd_ExecuteText(). 00277 {
00278 if ( key == K_ESCAPE ) {
00279 trap_Cmd_ExecuteText( EXEC_APPEND, "disconnect\n" );
00280 return;
00281 }
00282 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 57 of file ui_connect.c. References Com_sprintf(), and time(). 00057 {
00058 time /= 1000; // change to seconds
00059
00060 if (time > 3600) { // in the hours range
00061 Com_sprintf( buf, bufsize, "%d hr %d min", time / 3600, (time % 3600) / 60 );
00062 } else if (time > 60) { // mins
00063 Com_sprintf( buf, bufsize, "%d min %d sec", time / 60, time % 60 );
00064 } else { // secs
00065 Com_sprintf( buf, bufsize, "%d sec", time );
00066 }
00067 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 39 of file ui_connect.c. References Com_sprintf(), strlen(), and value. 00040 {
00041 if (value > 1024*1024*1024 ) { // gigs
00042 Com_sprintf( buf, bufsize, "%d", value / (1024*1024*1024) );
00043 Com_sprintf( buf+strlen(buf), bufsize-strlen(buf), ".%02d GB",
00044 (value % (1024*1024*1024))*100 / (1024*1024*1024) );
00045 } else if (value > 1024*1024 ) { // megs
00046 Com_sprintf( buf, bufsize, "%d", value / (1024*1024) );
00047 Com_sprintf( buf+strlen(buf), bufsize-strlen(buf), ".%02d MB",
00048 (value % (1024*1024))*100 / (1024*1024) );
00049 } else if (value > 1024 ) { // kilos
00050 Com_sprintf( buf, bufsize, "%d KB", value / 1024 );
00051 } else { // bytes
00052 Com_sprintf( buf, bufsize, "%d bytes", value );
00053 }
00054 }
|
Here is the call graph for this function:

|
|
Definition at line 36 of file ui_connect.c. Referenced by UI_DrawConnectScreen(). |
|
|
Definition at line 37 of file ui_connect.c. Referenced by UI_DrawConnectScreen(). |
|
|
Definition at line 34 of file ui_connect.c. Referenced by UI_DrawConnectScreen(). |
|
|
Definition at line 33 of file ui_connect.c. |
1.3.9.1