1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
|
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
Quake III Arena source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Quake III Arena source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
#include "ui_local.h"
#define SERVERINFO_FRAMEL "menu/art/frame2_l"
#define SERVERINFO_FRAMER "menu/art/frame1_r"
#define SERVERINFO_BACK0 "menu/art/back_0"
#define SERVERINFO_BACK1 "menu/art/back_1"
static char* serverinfo_artlist[] =
{
SERVERINFO_FRAMEL,
SERVERINFO_FRAMER,
SERVERINFO_BACK0,
SERVERINFO_BACK1,
NULL
};
#define ID_ADD 100
#define ID_BACK 101
typedef struct
{
menuframework_s menu;
menutext_s banner;
menubitmap_s framel;
menubitmap_s framer;
menubitmap_s back;
menutext_s add;
char info[MAX_INFO_STRING];
int numlines;
} serverinfo_t;
static serverinfo_t s_serverinfo;
/*
=================
Favorites_Add
Add current server to favorites
=================
*/
void Favorites_Add( void )
{
char adrstr[128];
char serverbuff[128];
int i;
int best;
trap_Cvar_VariableStringBuffer( "cl_currentServerAddress", serverbuff, sizeof(serverbuff) );
if (!serverbuff[0])
return;
best = 0;
for (i=0; i<MAX_FAVORITESERVERS; i++)
{
trap_Cvar_VariableStringBuffer( va("server%d",i+1), adrstr, sizeof(adrstr) );
if (!Q_stricmp(serverbuff,adrstr))
{
// already in list
return;
}
// use first empty or non-numeric available slot
if ((adrstr[0] < '0' || adrstr[0] > '9' ) && !best)
best = i+1;
}
if (best)
trap_Cvar_Set( va("server%d",best), serverbuff);
}
/*
=================
ServerInfo_Event
=================
*/
static void ServerInfo_Event( void* ptr, int event )
{
switch (((menucommon_s*)ptr)->id)
{
case ID_ADD:
if (event != QM_ACTIVATED)
break;
Favorites_Add();
UI_PopMenu();
break;
case ID_BACK:
if (event != QM_ACTIVATED)
break;
UI_PopMenu();
break;
}
}
/*
=================
ServerInfo_MenuDraw
=================
*/
static void ServerInfo_MenuDraw( void )
{
const char *s;
char key[MAX_INFO_KEY];
char value[MAX_INFO_VALUE];
int i = 0, y;
y = SCREEN_HEIGHT/2 - s_serverinfo.numlines*(SMALLCHAR_HEIGHT)/2 - 20;
s = s_serverinfo.info;
while ( s && i < s_serverinfo.numlines ) {
Info_NextPair( &s, key, value );
if ( !key[0] ) {
break;
}
Q_strcat( key, MAX_INFO_KEY, ":" );
UI_DrawString(SCREEN_WIDTH*0.50 - 8,y,key,UI_RIGHT|UI_SMALLFONT,color_red);
UI_DrawString(SCREEN_WIDTH*0.50 + 8,y,value,UI_LEFT|UI_SMALLFONT,text_color_normal);
y += SMALLCHAR_HEIGHT;
i++;
}
Menu_Draw( &s_serverinfo.menu );
}
/*
=================
ServerInfo_MenuKey
=================
*/
static sfxHandle_t ServerInfo_MenuKey( int key )
{
return ( Menu_DefaultKey( &s_serverinfo.menu, key ) );
}
/*
=================
ServerInfo_Cache
=================
*/
void ServerInfo_Cache( void )
{
int i;
// touch all our pics
for (i=0; ;i++)
{
if (!serverinfo_artlist[i])
break;
trap_R_RegisterShaderNoMip(serverinfo_artlist[i]);
}
}
/*
=================
UI_ServerInfoMenu
=================
*/
void UI_ServerInfoMenu( void )
{
const char *s;
char key[MAX_INFO_KEY];
char value[MAX_INFO_VALUE];
// zero set all our globals
memset( &s_serverinfo, 0 ,sizeof(serverinfo_t) );
ServerInfo_Cache();
s_serverinfo.menu.draw = ServerInfo_MenuDraw;
s_serverinfo.menu.key = ServerInfo_MenuKey;
s_serverinfo.menu.wrapAround = qtrue;
s_serverinfo.menu.fullscreen = qtrue;
s_serverinfo.banner.generic.type = MTYPE_BTEXT;
s_serverinfo.banner.generic.x = 320;
s_serverinfo.banner.generic.y = 16;
s_serverinfo.banner.string = "SERVER INFO";
s_serverinfo.banner.color = color_white;
s_serverinfo.banner.style = UI_CENTER;
s_serverinfo.framel.generic.type = MTYPE_BITMAP;
s_serverinfo.framel.generic.name = SERVERINFO_FRAMEL;
s_serverinfo.framel.generic.flags = QMF_INACTIVE;
s_serverinfo.framel.generic.x = 0;
s_serverinfo.framel.generic.y = 78;
s_serverinfo.framel.width = 256;
s_serverinfo.framel.height = 329;
s_serverinfo.framer.generic.type = MTYPE_BITMAP;
s_serverinfo.framer.generic.name = SERVERINFO_FRAMER;
s_serverinfo.framer.generic.flags = QMF_INACTIVE;
s_serverinfo.framer.generic.x = 376;
s_serverinfo.framer.generic.y = 76;
s_serverinfo.framer.width = 256;
s_serverinfo.framer.height = 334;
s_serverinfo.add.generic.type = MTYPE_PTEXT;
s_serverinfo.add.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_serverinfo.add.generic.callback = ServerInfo_Event;
s_serverinfo.add.generic.id = ID_ADD;
s_serverinfo.add.generic.x = 320;
s_serverinfo.add.generic.y = 371;
s_serverinfo.add.string = "ADD TO FAVORITES";
s_serverinfo.add.style = UI_CENTER|UI_SMALLFONT;
s_serverinfo.add.color = color_red;
if( trap_Cvar_VariableValue( "sv_running" ) ) {
s_serverinfo.add.generic.flags |= QMF_GRAYED;
}
s_serverinfo.back.generic.type = MTYPE_BITMAP;
s_serverinfo.back.generic.name = SERVERINFO_BACK0;
s_serverinfo.back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
s_serverinfo.back.generic.callback = ServerInfo_Event;
s_serverinfo.back.generic.id = ID_BACK;
s_serverinfo.back.generic.x = 0;
s_serverinfo.back.generic.y = 480-64;
s_serverinfo.back.width = 128;
s_serverinfo.back.height = 64;
s_serverinfo.back.focuspic = SERVERINFO_BACK1;
trap_GetConfigString( CS_SERVERINFO, s_serverinfo.info, MAX_INFO_STRING );
s_serverinfo.numlines = 0;
s = s_serverinfo.info;
while ( s ) {
Info_NextPair( &s, key, value );
if ( !key[0] ) {
break;
}
s_serverinfo.numlines++;
}
if (s_serverinfo.numlines > 16)
s_serverinfo.numlines = 16;
Menu_AddItem( &s_serverinfo.menu, (void*) &s_serverinfo.banner );
Menu_AddItem( &s_serverinfo.menu, (void*) &s_serverinfo.framel );
Menu_AddItem( &s_serverinfo.menu, (void*) &s_serverinfo.framer );
Menu_AddItem( &s_serverinfo.menu, (void*) &s_serverinfo.add );
Menu_AddItem( &s_serverinfo.menu, (void*) &s_serverinfo.back );
UI_PushMenu( &s_serverinfo.menu );
}
|