1 /*
2 Copyright (C) 2003-2006 Andrey Nazarov
3 
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8 
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 
13 See the GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18 
19 */
20 
21 #include "ui_local.h"
22 
23 /*
24 =============================================================================
25 
26 CONNECTION / LOADING SCREEN
27 
28 =============================================================================
29 */
30 
31 static uiClientState_t	loadingState;
32 
33 /*
34 ==============
35 UI_DrawLoading
36 ==============
37 */
UI_DrawLoading(int realtime)38 void UI_DrawLoading( int realtime ) {
39 	char buffer[MAX_STRING_CHARS];
40 	char *s;
41 	int x, y;
42 
43 	client.GetClientState( &loadingState );
44 
45 #if 0
46 	if( loadingState.mapname[0] ) {
47 		qhandle_t hPic;
48 
49 		Com_sprintf( buffer, sizeof( buffer ), "/levelshots/%s.jpg", loadingState.mapname );
50 		if( ( hPic = ref.RegisterPic( buffer ) ) != 0 ) {
51 			ref.DrawStretchPic( 0, 0, uis.glconfig.vidWidth, uis.glconfig.vidHeight, hPic );
52 		} else {
53 			ref.DrawFill( 0, 0, uis.glconfig.vidWidth, uis.glconfig.vidHeight, 0x00 );
54 		}
55 	} else
56 #endif
57 	{
58 		ref.DrawFill( 0, 0, uis.glconfig.vidWidth, uis.glconfig.vidHeight, 0x00 );
59 	}
60 
61 	x = uis.glconfig.vidWidth / 2;
62 	y = 8;
63 
64 	Com_sprintf( buffer, sizeof( buffer ), "%s %s", loadingState.demoplayback ? "Playing back" : "Connecting to", loadingState.servername );
65 	UI_DrawString( x, y, NULL, UI_CENTER|UI_DROPSHADOW, buffer );
66 	y += 40;
67 
68 	if( loadingState.fullname[0] ) {
69 		UI_DrawString( x, y, colorYellow, UI_CENTER|UI_DROPSHADOW, loadingState.fullname );
70 	}
71 	y += 60;
72 
73 	switch( loadingState.connState ) {
74 	case ca_challenging:
75 		Com_sprintf( buffer, sizeof( buffer ), "Challenging... %i", loadingState.connectCount );
76         s = buffer;
77 		break;
78 	case ca_connecting:
79 		Com_sprintf( buffer, sizeof( buffer ), "Connecting... %i", loadingState.connectCount );
80         s = buffer;
81 		break;
82 	case ca_connected:
83 		s = "Receiving server data...";
84 		UI_DrawString( x, y, NULL, UI_CENTER|UI_DROPSHADOW, s );
85 		break;
86 	case ca_loading:
87 		Com_sprintf( buffer, sizeof( buffer ), "Loading... %s", loadingState.loadingString );
88         s = buffer;
89 		break;
90     case ca_precached:
91 	    s = "Awaiting server frame...";
92         break;
93 	default:
94 		Com_Error( ERR_DROP, "SCR_DrawLoading: bad cls.state %i", loadingState.connState );
95 		break;
96 	}
97 	UI_DrawString( x, y, NULL, UI_CENTER|UI_DROPSHADOW, s );
98 	y += 64;
99 
100 	if( loadingState.connState > ca_connected ) {
101 		return;
102 	}
103 
104 	// draw message string
105 	if( loadingState.loadingString[0] ) {
106 		UI_DrawString( x, y, colorRed, UI_CENTER|UI_DROPSHADOW|UI_MULTILINE, loadingState.loadingString );
107 	}
108 }
109 
110