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
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
|
/*
===========================================================================
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
===========================================================================
*/
//
/*
=======================================================================
REMOVE BOTS MENU
=======================================================================
*/
#include "ui_local.h"
#define ART_BACKGROUND "menu/art/addbotframe"
#define ART_BACK0 "menu/art/back_0"
#define ART_BACK1 "menu/art/back_1"
#define ART_DELETE0 "menu/art/delete_0"
#define ART_DELETE1 "menu/art/delete_1"
#define ART_ARROWS "menu/art/arrows_vert_0"
#define ART_ARROWUP "menu/art/arrows_vert_top"
#define ART_ARROWDOWN "menu/art/arrows_vert_bot"
#define ID_UP 10
#define ID_DOWN 11
#define ID_DELETE 12
#define ID_BACK 13
#define ID_BOTNAME0 20
#define ID_BOTNAME1 21
#define ID_BOTNAME2 22
#define ID_BOTNAME3 23
#define ID_BOTNAME4 24
#define ID_BOTNAME5 25
#define ID_BOTNAME6 26
typedef struct {
menuframework_s menu;
menutext_s banner;
menubitmap_s background;
menubitmap_s arrows;
menubitmap_s up;
menubitmap_s down;
menutext_s bots[7];
menubitmap_s delete;
menubitmap_s back;
int numBots;
int baseBotNum;
int selectedBotNum;
char botnames[7][32];
int botClientNums[MAX_BOTS];
} removeBotsMenuInfo_t;
static removeBotsMenuInfo_t removeBotsMenuInfo;
/*
=================
UI_RemoveBotsMenu_SetBotNames
=================
*/
static void UI_RemoveBotsMenu_SetBotNames( void ) {
int n;
char info[MAX_INFO_STRING];
for ( n = 0; (n < 7) && (removeBotsMenuInfo.baseBotNum + n < removeBotsMenuInfo.numBots); n++ ) {
trap_GetConfigString( CS_PLAYERS + removeBotsMenuInfo.botClientNums[removeBotsMenuInfo.baseBotNum + n], info, MAX_INFO_STRING );
Q_strncpyz( removeBotsMenuInfo.botnames[n], Info_ValueForKey( info, "n" ), sizeof(removeBotsMenuInfo.botnames[n]) );
Q_CleanStr( removeBotsMenuInfo.botnames[n] );
}
}
/*
=================
UI_RemoveBotsMenu_DeleteEvent
=================
*/
static void UI_RemoveBotsMenu_DeleteEvent( void* ptr, int event ) {
if (event != QM_ACTIVATED) {
return;
}
trap_Cmd_ExecuteText( EXEC_APPEND, va("clientkick %i\n", removeBotsMenuInfo.botClientNums[removeBotsMenuInfo.baseBotNum + removeBotsMenuInfo.selectedBotNum]) );
}
/*
=================
UI_RemoveBotsMenu_BotEvent
=================
*/
static void UI_RemoveBotsMenu_BotEvent( void* ptr, int event ) {
if (event != QM_ACTIVATED) {
return;
}
removeBotsMenuInfo.bots[removeBotsMenuInfo.selectedBotNum].color = color_orange;
removeBotsMenuInfo.selectedBotNum = ((menucommon_s*)ptr)->id - ID_BOTNAME0;
removeBotsMenuInfo.bots[removeBotsMenuInfo.selectedBotNum].color = color_white;
}
/*
=================
UI_RemoveAddBotsMenu_BackEvent
=================
*/
static void UI_RemoveBotsMenu_BackEvent( void* ptr, int event ) {
if (event != QM_ACTIVATED) {
return;
}
UI_PopMenu();
}
/*
=================
UI_RemoveBotsMenu_UpEvent
=================
*/
static void UI_RemoveBotsMenu_UpEvent( void* ptr, int event ) {
if (event != QM_ACTIVATED) {
return;
}
if( removeBotsMenuInfo.baseBotNum > 0 ) {
removeBotsMenuInfo.baseBotNum--;
UI_RemoveBotsMenu_SetBotNames();
}
}
/*
=================
UI_RemoveBotsMenu_DownEvent
=================
*/
static void UI_RemoveBotsMenu_DownEvent( void* ptr, int event ) {
if (event != QM_ACTIVATED) {
return;
}
if( removeBotsMenuInfo.baseBotNum + 7 < removeBotsMenuInfo.numBots ) {
removeBotsMenuInfo.baseBotNum++;
UI_RemoveBotsMenu_SetBotNames();
}
}
/*
=================
UI_RemoveBotsMenu_GetBots
=================
*/
static void UI_RemoveBotsMenu_GetBots( void ) {
int numPlayers;
int isBot;
int n;
char info[MAX_INFO_STRING];
trap_GetConfigString( CS_SERVERINFO, info, sizeof(info) );
numPlayers = atoi( Info_ValueForKey( info, "sv_maxclients" ) );
removeBotsMenuInfo.numBots = 0;
for( n = 0; n < numPlayers; n++ ) {
trap_GetConfigString( CS_PLAYERS + n, info, MAX_INFO_STRING );
isBot = atoi( Info_ValueForKey( info, "skill" ) );
if( !isBot ) {
continue;
}
removeBotsMenuInfo.botClientNums[removeBotsMenuInfo.numBots] = n;
removeBotsMenuInfo.numBots++;
}
}
/*
=================
UI_RemoveBots_Cache
=================
*/
void UI_RemoveBots_Cache( void ) {
trap_R_RegisterShaderNoMip( ART_BACKGROUND );
trap_R_RegisterShaderNoMip( ART_BACK0 );
trap_R_RegisterShaderNoMip( ART_BACK1 );
trap_R_RegisterShaderNoMip( ART_DELETE0 );
trap_R_RegisterShaderNoMip( ART_DELETE1 );
}
/*
=================
UI_RemoveBotsMenu_Init
=================
*/
static void UI_RemoveBotsMenu_Init( void ) {
int n;
int count;
int y;
memset( &removeBotsMenuInfo, 0 ,sizeof(removeBotsMenuInfo) );
removeBotsMenuInfo.menu.fullscreen = qfalse;
removeBotsMenuInfo.menu.wrapAround = qtrue;
UI_RemoveBots_Cache();
UI_RemoveBotsMenu_GetBots();
UI_RemoveBotsMenu_SetBotNames();
count = removeBotsMenuInfo.numBots < 7 ? removeBotsMenuInfo.numBots : 7;
removeBotsMenuInfo.banner.generic.type = MTYPE_BTEXT;
removeBotsMenuInfo.banner.generic.x = 320;
removeBotsMenuInfo.banner.generic.y = 16;
removeBotsMenuInfo.banner.string = "REMOVE BOTS";
removeBotsMenuInfo.banner.color = color_white;
removeBotsMenuInfo.banner.style = UI_CENTER;
removeBotsMenuInfo.background.generic.type = MTYPE_BITMAP;
removeBotsMenuInfo.background.generic.name = ART_BACKGROUND;
removeBotsMenuInfo.background.generic.flags = QMF_INACTIVE;
removeBotsMenuInfo.background.generic.x = 320-233;
removeBotsMenuInfo.background.generic.y = 240-166;
removeBotsMenuInfo.background.width = 466;
removeBotsMenuInfo.background.height = 332;
removeBotsMenuInfo.arrows.generic.type = MTYPE_BITMAP;
removeBotsMenuInfo.arrows.generic.name = ART_ARROWS;
removeBotsMenuInfo.arrows.generic.flags = QMF_INACTIVE;
removeBotsMenuInfo.arrows.generic.x = 200;
removeBotsMenuInfo.arrows.generic.y = 128;
removeBotsMenuInfo.arrows.width = 64;
removeBotsMenuInfo.arrows.height = 128;
removeBotsMenuInfo.up.generic.type = MTYPE_BITMAP;
removeBotsMenuInfo.up.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
removeBotsMenuInfo.up.generic.x = 200;
removeBotsMenuInfo.up.generic.y = 128;
removeBotsMenuInfo.up.generic.id = ID_UP;
removeBotsMenuInfo.up.generic.callback = UI_RemoveBotsMenu_UpEvent;
removeBotsMenuInfo.up.width = 64;
removeBotsMenuInfo.up.height = 64;
removeBotsMenuInfo.up.focuspic = ART_ARROWUP;
removeBotsMenuInfo.down.generic.type = MTYPE_BITMAP;
removeBotsMenuInfo.down.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
removeBotsMenuInfo.down.generic.x = 200;
removeBotsMenuInfo.down.generic.y = 128+64;
removeBotsMenuInfo.down.generic.id = ID_DOWN;
removeBotsMenuInfo.down.generic.callback = UI_RemoveBotsMenu_DownEvent;
removeBotsMenuInfo.down.width = 64;
removeBotsMenuInfo.down.height = 64;
removeBotsMenuInfo.down.focuspic = ART_ARROWDOWN;
for( n = 0, y = 120; n < count; n++, y += 20 ) {
removeBotsMenuInfo.bots[n].generic.type = MTYPE_PTEXT;
removeBotsMenuInfo.bots[n].generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
removeBotsMenuInfo.bots[n].generic.id = ID_BOTNAME0 + n;
removeBotsMenuInfo.bots[n].generic.x = 320 - 56;
removeBotsMenuInfo.bots[n].generic.y = y;
removeBotsMenuInfo.bots[n].generic.callback = UI_RemoveBotsMenu_BotEvent;
removeBotsMenuInfo.bots[n].string = removeBotsMenuInfo.botnames[n];
removeBotsMenuInfo.bots[n].color = color_orange;
removeBotsMenuInfo.bots[n].style = UI_LEFT|UI_SMALLFONT;
}
removeBotsMenuInfo.delete.generic.type = MTYPE_BITMAP;
removeBotsMenuInfo.delete.generic.name = ART_DELETE0;
removeBotsMenuInfo.delete.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
removeBotsMenuInfo.delete.generic.id = ID_DELETE;
removeBotsMenuInfo.delete.generic.callback = UI_RemoveBotsMenu_DeleteEvent;
removeBotsMenuInfo.delete.generic.x = 320+128-128;
removeBotsMenuInfo.delete.generic.y = 256+128-64;
removeBotsMenuInfo.delete.width = 128;
removeBotsMenuInfo.delete.height = 64;
removeBotsMenuInfo.delete.focuspic = ART_DELETE1;
removeBotsMenuInfo.back.generic.type = MTYPE_BITMAP;
removeBotsMenuInfo.back.generic.name = ART_BACK0;
removeBotsMenuInfo.back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
removeBotsMenuInfo.back.generic.id = ID_BACK;
removeBotsMenuInfo.back.generic.callback = UI_RemoveBotsMenu_BackEvent;
removeBotsMenuInfo.back.generic.x = 320-128;
removeBotsMenuInfo.back.generic.y = 256+128-64;
removeBotsMenuInfo.back.width = 128;
removeBotsMenuInfo.back.height = 64;
removeBotsMenuInfo.back.focuspic = ART_BACK1;
Menu_AddItem( &removeBotsMenuInfo.menu, &removeBotsMenuInfo.background );
Menu_AddItem( &removeBotsMenuInfo.menu, &removeBotsMenuInfo.banner );
Menu_AddItem( &removeBotsMenuInfo.menu, &removeBotsMenuInfo.arrows );
Menu_AddItem( &removeBotsMenuInfo.menu, &removeBotsMenuInfo.up );
Menu_AddItem( &removeBotsMenuInfo.menu, &removeBotsMenuInfo.down );
for( n = 0; n < count; n++ ) {
Menu_AddItem( &removeBotsMenuInfo.menu, &removeBotsMenuInfo.bots[n] );
}
Menu_AddItem( &removeBotsMenuInfo.menu, &removeBotsMenuInfo.delete );
Menu_AddItem( &removeBotsMenuInfo.menu, &removeBotsMenuInfo.back );
removeBotsMenuInfo.baseBotNum = 0;
removeBotsMenuInfo.selectedBotNum = 0;
removeBotsMenuInfo.bots[0].color = color_white;
}
/*
=================
UI_RemoveBotsMenu
=================
*/
void UI_RemoveBotsMenu( void ) {
UI_RemoveBotsMenu_Init();
UI_PushMenu( &removeBotsMenuInfo.menu );
}
|