| 1 |
/* |
| 2 |
=========================================================================== |
| 3 |
Copyright (C) 1999-2005 Id Software, Inc. |
| 4 |
|
| 5 |
This file is part of Quake III Arena source code. |
| 6 |
|
| 7 |
Quake III Arena source code is free software; you can redistribute it |
| 8 |
and/or modify it under the terms of the GNU General Public License as |
| 9 |
published by the Free Software Foundation; either version 2 of the License, |
| 10 |
or (at your option) any later version. |
| 11 |
|
| 12 |
Quake III Arena source code is distributed in the hope that it will be |
| 13 |
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
GNU General Public License for more details. |
| 16 |
|
| 17 |
You should have received a copy of the GNU General Public License |
| 18 |
along with Quake III Arena source code; if not, write to the Free Software |
| 19 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 |
=========================================================================== |
| 21 |
*/ |
| 22 |
// |
| 23 |
#include "ui_local.h" |
| 24 |
|
| 25 |
/********************************************************************************* |
| 26 |
SPECIFY SERVER |
| 27 |
*********************************************************************************/ |
| 28 |
|
| 29 |
#define MAX_LISTBOXITEMS 128 |
| 30 |
#define MAX_LISTBOXWIDTH 40 |
| 31 |
#define MAX_LEAGUENAME 80 |
| 32 |
|
| 33 |
#define SPECIFYLEAGUE_FRAMEL "menu/art_blueish/frame2_l" |
| 34 |
#define SPECIFYLEAGUE_FRAMER "menu/art_blueish/frame1_r" |
| 35 |
#define SPECIFYLEAGUE_BACK0 "menu/art_blueish/back_0" |
| 36 |
#define SPECIFYLEAGUE_BACK1 "menu/art_blueish/back_1" |
| 37 |
#define SPECIFYLEAGUE_ARROWS0 "menu/art_blueish/arrows_vert_0" |
| 38 |
#define SPECIFYLEAGUE_UP "menu/art_blueish/arrows_vert_top" |
| 39 |
#define SPECIFYLEAGUE_DOWN "menu/art_blueish/arrows_vert_bot" |
| 40 |
#define GLOBALRANKINGS_LOGO "menu/art/gr/grlogo" |
| 41 |
#define GLOBALRANKINGS_LETTERS "menu/art/gr/grletters" |
| 42 |
|
| 43 |
#define ID_SPECIFYLEAGUENAME 100 |
| 44 |
#define ID_SPECIFYLEAGUELIST 101 |
| 45 |
#define ID_SPECIFYLEAGUEUP 102 |
| 46 |
#define ID_SPECIFYLEAGUEDOWN 103 |
| 47 |
#define ID_SPECIFYLEAGUEBACK 104 |
| 48 |
|
| 49 |
static char* specifyleague_artlist[] = |
| 50 |
{ |
| 51 |
SPECIFYLEAGUE_FRAMEL, |
| 52 |
SPECIFYLEAGUE_FRAMER, |
| 53 |
SPECIFYLEAGUE_ARROWS0, |
| 54 |
SPECIFYLEAGUE_UP, |
| 55 |
SPECIFYLEAGUE_DOWN, |
| 56 |
SPECIFYLEAGUE_BACK0, |
| 57 |
SPECIFYLEAGUE_BACK1, |
| 58 |
GLOBALRANKINGS_LOGO, |
| 59 |
GLOBALRANKINGS_LETTERS, |
| 60 |
NULL |
| 61 |
}; |
| 62 |
|
| 63 |
static char playername[80]; |
| 64 |
|
| 65 |
typedef struct |
| 66 |
{ |
| 67 |
menuframework_s menu; |
| 68 |
menutext_s banner; |
| 69 |
menubitmap_s framel; |
| 70 |
menubitmap_s framer; |
| 71 |
menufield_s rankname; |
| 72 |
menulist_s list; |
| 73 |
menubitmap_s arrows; |
| 74 |
menubitmap_s up; |
| 75 |
menubitmap_s down; |
| 76 |
menubitmap_s back; |
| 77 |
menubitmap_s grlogo; |
| 78 |
menubitmap_s grletters; |
| 79 |
} specifyleague_t; |
| 80 |
|
| 81 |
static specifyleague_t s_specifyleague; |
| 82 |
|
| 83 |
|
| 84 |
typedef struct { |
| 85 |
char buff[MAX_LISTBOXWIDTH]; |
| 86 |
char leaguename[MAX_LEAGUENAME]; |
| 87 |
} table_t; |
| 88 |
|
| 89 |
table_t league_table[MAX_LISTBOXITEMS]; |
| 90 |
char *leaguename_items[MAX_LISTBOXITEMS]; |
| 91 |
|
| 92 |
|
| 93 |
static void SpecifyLeague_GetList() |
| 94 |
{ |
| 95 |
int count = 0; |
| 96 |
int i; |
| 97 |
/* The Player Name has changed. We need to perform another search */ |
| 98 |
Q_strncpyz( playername, |
| 99 |
s_specifyleague.rankname.field.buffer, |
| 100 |
sizeof(playername) ); |
| 101 |
|
| 102 |
count = trap_CL_UI_RankGetLeauges( playername ); |
| 103 |
|
| 104 |
for(i = 0; i < count; i++) |
| 105 |
{ |
| 106 |
char s[MAX_LEAGUENAME]; |
| 107 |
const char *var; |
| 108 |
var = va( "leaguename%i", i+1 ); |
| 109 |
trap_Cvar_VariableStringBuffer( var, s, sizeof(s) ); |
| 110 |
Q_strncpyz(league_table[i].leaguename, s, sizeof(league_table[i].leaguename) ); |
| 111 |
Q_strncpyz(league_table[i].buff, league_table[i].leaguename, sizeof(league_table[i].buff) ); |
| 112 |
} |
| 113 |
|
| 114 |
s_specifyleague.list.numitems = count; |
| 115 |
} |
| 116 |
|
| 117 |
/* |
| 118 |
================= |
| 119 |
SpecifyLeague_Event |
| 120 |
================= |
| 121 |
*/ |
| 122 |
static void SpecifyLeague_Event( void* ptr, int event ) |
| 123 |
{ |
| 124 |
int id; |
| 125 |
id = ((menucommon_s*)ptr)->id; |
| 126 |
//if( event != QM_ACTIVATED && id != ID_SPECIFYLEAGUELIST ) { |
| 127 |
// return; |
| 128 |
//} |
| 129 |
|
| 130 |
switch (id) |
| 131 |
{ |
| 132 |
case ID_SPECIFYLEAGUELIST: |
| 133 |
if( event == QM_GOTFOCUS ) { |
| 134 |
//ArenaServers_UpdatePicture(); |
| 135 |
} |
| 136 |
break; |
| 137 |
|
| 138 |
case ID_SPECIFYLEAGUEUP: |
| 139 |
if( event == QM_ACTIVATED ) |
| 140 |
ScrollList_Key( &s_specifyleague.list, K_UPARROW ); |
| 141 |
break; |
| 142 |
|
| 143 |
case ID_SPECIFYLEAGUEDOWN: |
| 144 |
if( event == QM_ACTIVATED ) |
| 145 |
ScrollList_Key( &s_specifyleague.list, K_DOWNARROW ); |
| 146 |
break; |
| 147 |
|
| 148 |
case ID_SPECIFYLEAGUENAME: |
| 149 |
if( (event == QM_LOSTFOCUS) && |
| 150 |
(Q_strncmp(playername, |
| 151 |
s_specifyleague.rankname.field.buffer, |
| 152 |
strlen(s_specifyleague.rankname.field.buffer)) != 0)) |
| 153 |
{ |
| 154 |
SpecifyLeague_GetList(); |
| 155 |
} |
| 156 |
break; |
| 157 |
|
| 158 |
case ID_SPECIFYLEAGUEBACK: |
| 159 |
if( event == QM_ACTIVATED ) |
| 160 |
{ |
| 161 |
trap_Cvar_Set( "sv_leagueName", league_table[s_specifyleague.list.curvalue].leaguename); |
| 162 |
UI_PopMenu(); |
| 163 |
} |
| 164 |
break; |
| 165 |
} |
| 166 |
} |
| 167 |
|
| 168 |
/* |
| 169 |
================= |
| 170 |
SpecifyLeague_MenuInit |
| 171 |
================= |
| 172 |
*/ |
| 173 |
void SpecifyLeague_MenuInit( void ) |
| 174 |
{ |
| 175 |
int i; |
| 176 |
// zero set all our globals |
| 177 |
memset( &s_specifyleague, 0 ,sizeof(specifyleague_t) ); |
| 178 |
|
| 179 |
SpecifyLeague_Cache(); |
| 180 |
|
| 181 |
s_specifyleague.menu.wrapAround = qtrue; |
| 182 |
s_specifyleague.menu.fullscreen = qtrue; |
| 183 |
|
| 184 |
s_specifyleague.banner.generic.type = MTYPE_BTEXT; |
| 185 |
s_specifyleague.banner.generic.x = 320; |
| 186 |
s_specifyleague.banner.generic.y = 16; |
| 187 |
s_specifyleague.banner.string = "CHOOSE LEAGUE"; |
| 188 |
s_specifyleague.banner.color = color_white; |
| 189 |
s_specifyleague.banner.style = UI_CENTER; |
| 190 |
|
| 191 |
s_specifyleague.framel.generic.type = MTYPE_BITMAP; |
| 192 |
s_specifyleague.framel.generic.name = SPECIFYLEAGUE_FRAMEL; |
| 193 |
s_specifyleague.framel.generic.flags = QMF_INACTIVE; |
| 194 |
s_specifyleague.framel.generic.x = 0; |
| 195 |
s_specifyleague.framel.generic.y = 78; |
| 196 |
s_specifyleague.framel.width = 256; |
| 197 |
s_specifyleague.framel.height = 334; |
| 198 |
|
| 199 |
s_specifyleague.framer.generic.type = MTYPE_BITMAP; |
| 200 |
s_specifyleague.framer.generic.name = SPECIFYLEAGUE_FRAMER; |
| 201 |
s_specifyleague.framer.generic.flags = QMF_INACTIVE; |
| 202 |
s_specifyleague.framer.generic.x = 376; |
| 203 |
s_specifyleague.framer.generic.y = 76; |
| 204 |
s_specifyleague.framer.width = 256; |
| 205 |
s_specifyleague.framer.height = 334; |
| 206 |
|
| 207 |
s_specifyleague.grlogo.generic.type = MTYPE_BITMAP; |
| 208 |
s_specifyleague.grlogo.generic.name = GLOBALRANKINGS_LOGO; |
| 209 |
s_specifyleague.grlogo.generic.flags = QMF_INACTIVE; |
| 210 |
s_specifyleague.grlogo.generic.x = 0; |
| 211 |
s_specifyleague.grlogo.generic.y = 0; |
| 212 |
s_specifyleague.grlogo.width = 64; |
| 213 |
s_specifyleague.grlogo.height = 128; |
| 214 |
|
| 215 |
s_specifyleague.rankname.generic.type = MTYPE_FIELD; |
| 216 |
s_specifyleague.rankname.generic.name = "Player Name:"; |
| 217 |
s_specifyleague.rankname.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT; |
| 218 |
s_specifyleague.rankname.generic.callback = SpecifyLeague_Event; |
| 219 |
s_specifyleague.rankname.generic.id = ID_SPECIFYLEAGUENAME; |
| 220 |
s_specifyleague.rankname.generic.x = 226; |
| 221 |
s_specifyleague.rankname.generic.y = 128; |
| 222 |
s_specifyleague.rankname.field.widthInChars = 32; |
| 223 |
s_specifyleague.rankname.field.maxchars = 80; |
| 224 |
|
| 225 |
s_specifyleague.list.generic.type = MTYPE_SCROLLLIST; |
| 226 |
s_specifyleague.list.generic.flags = QMF_HIGHLIGHT_IF_FOCUS; |
| 227 |
s_specifyleague.list.generic.id = ID_SPECIFYLEAGUELIST; |
| 228 |
s_specifyleague.list.generic.callback = SpecifyLeague_Event; |
| 229 |
s_specifyleague.list.generic.x = 160; |
| 230 |
s_specifyleague.list.generic.y = 200; |
| 231 |
s_specifyleague.list.width = MAX_LISTBOXWIDTH; |
| 232 |
s_specifyleague.list.height = 8; |
| 233 |
s_specifyleague.list.itemnames = (const char **)leaguename_items; |
| 234 |
s_specifyleague.list.numitems = 0; |
| 235 |
for( i = 0; i < MAX_LISTBOXITEMS; i++ ) { |
| 236 |
league_table[i].buff[0] = 0; |
| 237 |
league_table[i].leaguename[0] = 0; |
| 238 |
leaguename_items[i] = league_table[i].buff; |
| 239 |
} |
| 240 |
|
| 241 |
s_specifyleague.arrows.generic.type = MTYPE_BITMAP; |
| 242 |
s_specifyleague.arrows.generic.name = SPECIFYLEAGUE_ARROWS0; |
| 243 |
s_specifyleague.arrows.generic.flags = QMF_LEFT_JUSTIFY|QMF_INACTIVE; |
| 244 |
s_specifyleague.arrows.generic.callback = SpecifyLeague_Event; |
| 245 |
s_specifyleague.arrows.generic.x = 512; |
| 246 |
s_specifyleague.arrows.generic.y = 240-64+16; |
| 247 |
s_specifyleague.arrows.width = 64; |
| 248 |
s_specifyleague.arrows.height = 128; |
| 249 |
|
| 250 |
s_specifyleague.up.generic.type = MTYPE_BITMAP; |
| 251 |
s_specifyleague.up.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_MOUSEONLY; |
| 252 |
s_specifyleague.up.generic.callback = SpecifyLeague_Event; |
| 253 |
s_specifyleague.up.generic.id = ID_SPECIFYLEAGUEUP; |
| 254 |
s_specifyleague.up.generic.x = 512; |
| 255 |
s_specifyleague.up.generic.y = 240-64+16; |
| 256 |
s_specifyleague.up.width = 64; |
| 257 |
s_specifyleague.up.height = 64; |
| 258 |
s_specifyleague.up.focuspic = SPECIFYLEAGUE_UP; |
| 259 |
|
| 260 |
s_specifyleague.down.generic.type = MTYPE_BITMAP; |
| 261 |
s_specifyleague.down.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_MOUSEONLY; |
| 262 |
s_specifyleague.down.generic.callback = SpecifyLeague_Event; |
| 263 |
s_specifyleague.down.generic.id = ID_SPECIFYLEAGUEDOWN; |
| 264 |
s_specifyleague.down.generic.x = 512; |
| 265 |
s_specifyleague.down.generic.y = 240+16; |
| 266 |
s_specifyleague.down.width = 64; |
| 267 |
s_specifyleague.down.height = 64; |
| 268 |
s_specifyleague.down.focuspic = SPECIFYLEAGUE_DOWN; |
| 269 |
|
| 270 |
s_specifyleague.back.generic.type = MTYPE_BITMAP; |
| 271 |
s_specifyleague.back.generic.name = SPECIFYLEAGUE_BACK0; |
| 272 |
s_specifyleague.back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS; |
| 273 |
s_specifyleague.back.generic.callback = SpecifyLeague_Event; |
| 274 |
s_specifyleague.back.generic.id = ID_SPECIFYLEAGUEBACK; |
| 275 |
s_specifyleague.back.generic.x = 0; |
| 276 |
s_specifyleague.back.generic.y = 480-64; |
| 277 |
s_specifyleague.back.width = 128; |
| 278 |
s_specifyleague.back.height = 64; |
| 279 |
s_specifyleague.back.focuspic = SPECIFYLEAGUE_BACK1; |
| 280 |
|
| 281 |
Menu_AddItem( &s_specifyleague.menu, &s_specifyleague.banner ); |
| 282 |
Menu_AddItem( &s_specifyleague.menu, &s_specifyleague.framel ); |
| 283 |
Menu_AddItem( &s_specifyleague.menu, &s_specifyleague.framer ); |
| 284 |
Menu_AddItem( &s_specifyleague.menu, &s_specifyleague.grlogo ); |
| 285 |
Menu_AddItem( &s_specifyleague.menu, &s_specifyleague.rankname ); |
| 286 |
Menu_AddItem( &s_specifyleague.menu, &s_specifyleague.list ); |
| 287 |
Menu_AddItem( &s_specifyleague.menu, &s_specifyleague.arrows ); |
| 288 |
Menu_AddItem( &s_specifyleague.menu, &s_specifyleague.up ); |
| 289 |
Menu_AddItem( &s_specifyleague.menu, &s_specifyleague.down ); |
| 290 |
Menu_AddItem( &s_specifyleague.menu, &s_specifyleague.back ); |
| 291 |
|
| 292 |
|
| 293 |
// initialize any menu variables |
| 294 |
Q_strncpyz( s_specifyleague.rankname.field.buffer, |
| 295 |
UI_Cvar_VariableString("name"), |
| 296 |
sizeof(s_specifyleague.rankname.field.buffer) ); |
| 297 |
|
| 298 |
Q_strncpyz( playername, |
| 299 |
UI_Cvar_VariableString("name"), |
| 300 |
sizeof(playername) ); |
| 301 |
|
| 302 |
SpecifyLeague_GetList(); |
| 303 |
} |
| 304 |
|
| 305 |
/* |
| 306 |
================= |
| 307 |
SpecifyLeague_Cache |
| 308 |
================= |
| 309 |
*/ |
| 310 |
void SpecifyLeague_Cache( void ) |
| 311 |
{ |
| 312 |
int i; |
| 313 |
|
| 314 |
// touch all our pics |
| 315 |
for (i=0; ;i++) |
| 316 |
{ |
| 317 |
if (!specifyleague_artlist[i]) |
| 318 |
break; |
| 319 |
trap_R_RegisterShaderNoMip(specifyleague_artlist[i]); |
| 320 |
} |
| 321 |
} |
| 322 |
|
| 323 |
/* |
| 324 |
================= |
| 325 |
UI_SpecifyLeagueMenu |
| 326 |
================= |
| 327 |
*/ |
| 328 |
void UI_SpecifyLeagueMenu( void ) |
| 329 |
{ |
| 330 |
SpecifyLeague_MenuInit(); |
| 331 |
UI_PushMenu( &s_specifyleague.menu ); |
| 332 |
} |
| 333 |
|