| 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 |
#include "ui_local.h" |
| 33 |
|
| 34 |
#define ART_BACK0 "menu/art/back_0" |
| 35 |
#define ART_BACK1 "menu/art/back_1" |
| 36 |
#define ART_FRAMEL "menu/art/frame2_l" |
| 37 |
#define ART_FRAMER "menu/art/frame1_r" |
| 38 |
|
| 39 |
|
| 40 |
typedef struct { |
| 41 |
char *command; |
| 42 |
char *label; |
| 43 |
int id; |
| 44 |
int anim; |
| 45 |
int defaultbind1; |
| 46 |
int defaultbind2; |
| 47 |
int bind1; |
| 48 |
int bind2; |
| 49 |
} bind_t; |
| 50 |
|
| 51 |
typedef struct |
| 52 |
{ |
| 53 |
char* name; |
| 54 |
float defaultvalue; |
| 55 |
float value; |
| 56 |
} configcvar_t; |
| 57 |
|
| 58 |
#define SAVE_NOOP 0 |
| 59 |
#define SAVE_YES 1 |
| 60 |
#define SAVE_NO 2 |
| 61 |
#define SAVE_CANCEL 3 |
| 62 |
|
| 63 |
|
| 64 |
#define C_MOVEMENT 0 |
| 65 |
#define C_LOOKING 1 |
| 66 |
#define C_WEAPONS 2 |
| 67 |
#define C_MISC 3 |
| 68 |
#define C_MAX 4 |
| 69 |
|
| 70 |
#define ID_MOVEMENT 100 |
| 71 |
#define ID_LOOKING 101 |
| 72 |
#define ID_WEAPONS 102 |
| 73 |
#define ID_MISC 103 |
| 74 |
#define ID_DEFAULTS 104 |
| 75 |
#define ID_BACK 105 |
| 76 |
#define ID_SAVEANDEXIT 106 |
| 77 |
#define ID_EXIT 107 |
| 78 |
|
| 79 |
|
| 80 |
#define ID_SHOWSCORES 0 |
| 81 |
#define ID_USEITEM 1 |
| 82 |
#define ID_SPEED 2 |
| 83 |
#define ID_FORWARD 3 |
| 84 |
#define ID_BACKPEDAL 4 |
| 85 |
#define ID_MOVELEFT 5 |
| 86 |
#define ID_MOVERIGHT 6 |
| 87 |
#define ID_MOVEUP 7 |
| 88 |
#define ID_MOVEDOWN 8 |
| 89 |
#define ID_LEFT 9 |
| 90 |
#define ID_RIGHT 10 |
| 91 |
#define ID_STRAFE 11 |
| 92 |
#define ID_LOOKUP 12 |
| 93 |
#define ID_LOOKDOWN 13 |
| 94 |
#define ID_MOUSELOOK 14 |
| 95 |
#define ID_CENTERVIEW 15 |
| 96 |
#define ID_ZOOMVIEW 16 |
| 97 |
#define ID_WEAPON1 17 |
| 98 |
#define ID_WEAPON2 18 |
| 99 |
#define ID_WEAPON3 19 |
| 100 |
#define ID_WEAPON4 20 |
| 101 |
#define ID_WEAPON5 21 |
| 102 |
#define ID_WEAPON6 22 |
| 103 |
#define ID_WEAPON7 23 |
| 104 |
#define ID_WEAPON8 24 |
| 105 |
#define ID_WEAPON9 25 |
| 106 |
#define ID_ATTACK 26 |
| 107 |
#define ID_WEAPPREV 27 |
| 108 |
#define ID_WEAPNEXT 28 |
| 109 |
#define ID_GESTURE 29 |
| 110 |
#define ID_CHAT 30 |
| 111 |
#define ID_CHAT2 31 |
| 112 |
#define ID_CHAT3 32 |
| 113 |
#define ID_CHAT4 33 |
| 114 |
#define ID_TOGGLEMENU 34 |
| 115 |
|
| 116 |
|
| 117 |
#define ID_FREELOOK 35 |
| 118 |
#define ID_INVERTMOUSE 36 |
| 119 |
#define ID_ALWAYSRUN 37 |
| 120 |
#define ID_AUTOSWITCH 38 |
| 121 |
#define ID_MOUSESPEED 39 |
| 122 |
#define ID_JOYENABLE 40 |
| 123 |
#define ID_JOYTHRESHOLD 41 |
| 124 |
#define ID_SMOOTHMOUSE 42 |
| 125 |
|
| 126 |
#define ANIM_IDLE 0 |
| 127 |
#define ANIM_RUN 1 |
| 128 |
#define ANIM_WALK 2 |
| 129 |
#define ANIM_BACK 3 |
| 130 |
#define ANIM_JUMP 4 |
| 131 |
#define ANIM_CROUCH 5 |
| 132 |
#define ANIM_STEPLEFT 6 |
| 133 |
#define ANIM_STEPRIGHT 7 |
| 134 |
#define ANIM_TURNLEFT 8 |
| 135 |
#define ANIM_TURNRIGHT 9 |
| 136 |
#define ANIM_LOOKUP 10 |
| 137 |
#define ANIM_LOOKDOWN 11 |
| 138 |
#define ANIM_WEAPON1 12 |
| 139 |
#define ANIM_WEAPON2 13 |
| 140 |
#define ANIM_WEAPON3 14 |
| 141 |
#define ANIM_WEAPON4 15 |
| 142 |
#define ANIM_WEAPON5 16 |
| 143 |
#define ANIM_WEAPON6 17 |
| 144 |
#define ANIM_WEAPON7 18 |
| 145 |
#define ANIM_WEAPON8 19 |
| 146 |
#define ANIM_WEAPON9 20 |
| 147 |
#define ANIM_WEAPON10 21 |
| 148 |
#define ANIM_ATTACK 22 |
| 149 |
#define ANIM_GESTURE 23 |
| 150 |
#define ANIM_DIE 24 |
| 151 |
#define ANIM_CHAT 25 |
| 152 |
|
| 153 |
typedef struct |
| 154 |
{ |
| 155 |
menuframework_s menu; |
| 156 |
|
| 157 |
menutext_s banner; |
| 158 |
menubitmap_s framel; |
| 159 |
menubitmap_s framer; |
| 160 |
menubitmap_s player; |
| 161 |
|
| 162 |
menutext_s movement; |
| 163 |
menutext_s looking; |
| 164 |
menutext_s weapons; |
| 165 |
menutext_s misc; |
| 166 |
|
| 167 |
menuaction_s walkforward; |
| 168 |
menuaction_s backpedal; |
| 169 |
menuaction_s stepleft; |
| 170 |
menuaction_s stepright; |
| 171 |
menuaction_s moveup; |
| 172 |
menuaction_s movedown; |
| 173 |
menuaction_s turnleft; |
| 174 |
menuaction_s turnright; |
| 175 |
menuaction_s sidestep; |
| 176 |
menuaction_s run; |
| 177 |
menuaction_s machinegun; |
| 178 |
menuaction_s chainsaw; |
| 179 |
menuaction_s shotgun; |
| 180 |
menuaction_s grenadelauncher; |
| 181 |
menuaction_s rocketlauncher; |
| 182 |
menuaction_s lightning; |
| 183 |
menuaction_s railgun; |
| 184 |
menuaction_s plasma; |
| 185 |
menuaction_s bfg; |
| 186 |
menuaction_s attack; |
| 187 |
menuaction_s prevweapon; |
| 188 |
menuaction_s nextweapon; |
| 189 |
menuaction_s lookup; |
| 190 |
menuaction_s lookdown; |
| 191 |
menuaction_s mouselook; |
| 192 |
menuradiobutton_s freelook; |
| 193 |
menuaction_s centerview; |
| 194 |
menuaction_s zoomview; |
| 195 |
menuaction_s gesture; |
| 196 |
menuradiobutton_s invertmouse; |
| 197 |
menuslider_s sensitivity; |
| 198 |
menuradiobutton_s smoothmouse; |
| 199 |
menuradiobutton_s alwaysrun; |
| 200 |
menuaction_s showscores; |
| 201 |
menuradiobutton_s autoswitch; |
| 202 |
menuaction_s useitem; |
| 203 |
playerInfo_t playerinfo; |
| 204 |
qboolean changesmade; |
| 205 |
menuaction_s chat; |
| 206 |
menuaction_s chat2; |
| 207 |
menuaction_s chat3; |
| 208 |
menuaction_s chat4; |
| 209 |
menuaction_s togglemenu; |
| 210 |
menuradiobutton_s joyenable; |
| 211 |
menuslider_s joythreshold; |
| 212 |
int section; |
| 213 |
qboolean waitingforkey; |
| 214 |
char playerModel[64]; |
| 215 |
vec3_t playerViewangles; |
| 216 |
vec3_t playerMoveangles; |
| 217 |
int playerLegs; |
| 218 |
int playerTorso; |
| 219 |
weapon_t playerWeapon; |
| 220 |
qboolean playerChat; |
| 221 |
|
| 222 |
menubitmap_s back; |
| 223 |
menutext_s name; |
| 224 |
} controls_t; |
| 225 |
|
| 226 |
static controls_t s_controls; |
| 227 |
|
| 228 |
static vec4_t controls_binding_color = {1.00f, 0.43f, 0.00f, 1.00f}; |
| 229 |
|
| 230 |
static bind_t g_bindings[] = |
| 231 |
{ |
| 232 |
{"+scores", "show scores", ID_SHOWSCORES, ANIM_IDLE, K_TAB, -1, -1, -1}, |
| 233 |
{"+button2", "use item", ID_USEITEM, ANIM_IDLE, K_ENTER, -1, -1, -1}, |
| 234 |
{"+speed", "run / walk", ID_SPEED, ANIM_RUN, K_SHIFT, -1, -1, -1}, |
| 235 |
{"+forward", "walk forward", ID_FORWARD, ANIM_WALK, K_UPARROW, -1, -1, -1}, |
| 236 |
{"+back", "backpedal", ID_BACKPEDAL, ANIM_BACK, K_DOWNARROW, -1, -1, -1}, |
| 237 |
{"+moveleft", "step left", ID_MOVELEFT, ANIM_STEPLEFT, ',', -1, -1, -1}, |
| 238 |
{"+moveright", "step right", ID_MOVERIGHT, ANIM_STEPRIGHT, '.', -1, -1, -1}, |
| 239 |
{"+moveup", "up / jump", ID_MOVEUP, ANIM_JUMP, K_SPACE, -1, -1, -1}, |
| 240 |
{"+movedown", "down / crouch", ID_MOVEDOWN, ANIM_CROUCH, 'c', -1, -1, -1}, |
| 241 |
{"+left", "turn left", ID_LEFT, ANIM_TURNLEFT, K_LEFTARROW, -1, -1, -1}, |
| 242 |
{"+right", "turn right", ID_RIGHT, ANIM_TURNRIGHT, K_RIGHTARROW, -1, -1, -1}, |
| 243 |
{"+strafe", "sidestep / turn", ID_STRAFE, ANIM_IDLE, K_ALT, -1, -1, -1}, |
| 244 |
{"+lookup", "look up", ID_LOOKUP, ANIM_LOOKUP, K_PGDN, -1, -1, -1}, |
| 245 |
{"+lookdown", "look down", ID_LOOKDOWN, ANIM_LOOKDOWN, K_DEL, -1, -1, -1}, |
| 246 |
{"+mlook", "mouse look", ID_MOUSELOOK, ANIM_IDLE, '/', -1, -1, -1}, |
| 247 |
{"centerview", "center view", ID_CENTERVIEW, ANIM_IDLE, K_END, -1, -1, -1}, |
| 248 |
{"+zoom", "zoom view", ID_ZOOMVIEW, ANIM_IDLE, -1, -1, -1, -1}, |
| 249 |
{"weapon 1", "gauntlet", ID_WEAPON1, ANIM_WEAPON1, '1', -1, -1, -1}, |
| 250 |
{"weapon 2", "machinegun", ID_WEAPON2, ANIM_WEAPON2, '2', -1, -1, -1}, |
| 251 |
{"weapon 3", "shotgun", ID_WEAPON3, ANIM_WEAPON3, '3', -1, -1, -1}, |
| 252 |
{"weapon 4", "grenade launcher", ID_WEAPON4, ANIM_WEAPON4, '4', -1, -1, -1}, |
| 253 |
{"weapon 5", "rocket launcher", ID_WEAPON5, ANIM_WEAPON5, '5', -1, -1, -1}, |
| 254 |
{"weapon 6", "lightning", ID_WEAPON6, ANIM_WEAPON6, '6', -1, -1, -1}, |
| 255 |
{"weapon 7", "railgun", ID_WEAPON7, ANIM_WEAPON7, '7', -1, -1, -1}, |
| 256 |
{"weapon 8", "plasma gun", ID_WEAPON8, ANIM_WEAPON8, '8', -1, -1, -1}, |
| 257 |
{"weapon 9", "BFG", ID_WEAPON9, ANIM_WEAPON9, '9', -1, -1, -1}, |
| 258 |
{"+attack", "attack", ID_ATTACK, ANIM_ATTACK, K_CTRL, -1, -1, -1}, |
| 259 |
{"weapprev", "prev weapon", ID_WEAPPREV, ANIM_IDLE, '[', -1, -1, -1}, |
| 260 |
{"weapnext", "next weapon", ID_WEAPNEXT, ANIM_IDLE, ']', -1, -1, -1}, |
| 261 |
{"+button3", "gesture", ID_GESTURE, ANIM_GESTURE, K_MOUSE3, -1, -1, -1}, |
| 262 |
{"messagemode", "chat", ID_CHAT, ANIM_CHAT, 't', -1, -1, -1}, |
| 263 |
{"messagemode2", "chat - team", ID_CHAT2, ANIM_CHAT, -1, -1, -1, -1}, |
| 264 |
{"messagemode3", "chat - target", ID_CHAT3, ANIM_CHAT, -1, -1, -1, -1}, |
| 265 |
{"messagemode4", "chat - attacker", ID_CHAT4, ANIM_CHAT, -1, -1, -1, -1}, |
| 266 |
{"togglemenu", "toggle menu", ID_TOGGLEMENU, ANIM_IDLE, K_ESCAPE, -1, -1, -1}, |
| 267 |
{(char*)NULL, (char*)NULL, 0, 0, -1, -1, -1, -1}, |
| 268 |
}; |
| 269 |
|
| 270 |
static configcvar_t g_configcvars[] = |
| 271 |
{ |
| 272 |
{"cl_run", 0, 0}, |
| 273 |
{"m_pitch", 0, 0}, |
| 274 |
{"cg_autoswitch", 0, 0}, |
| 275 |
{"sensitivity", 0, 0}, |
| 276 |
{"in_joystick", 0, 0}, |
| 277 |
{"joy_threshold", 0, 0}, |
| 278 |
{"m_filter", 0, 0}, |
| 279 |
{"cl_freelook", 0, 0}, |
| 280 |
{NULL, 0, 0} |
| 281 |
}; |
| 282 |
|
| 283 |
static menucommon_s *g_movement_controls[] = |
| 284 |
{ |
| 285 |
(menucommon_s *)&s_controls.alwaysrun, |
| 286 |
(menucommon_s *)&s_controls.run, |
| 287 |
(menucommon_s *)&s_controls.walkforward, |
| 288 |
(menucommon_s *)&s_controls.backpedal, |
| 289 |
(menucommon_s *)&s_controls.stepleft, |
| 290 |
(menucommon_s *)&s_controls.stepright, |
| 291 |
(menucommon_s *)&s_controls.moveup, |
| 292 |
(menucommon_s *)&s_controls.movedown, |
| 293 |
(menucommon_s *)&s_controls.turnleft, |
| 294 |
(menucommon_s *)&s_controls.turnright, |
| 295 |
(menucommon_s *)&s_controls.sidestep, |
| 296 |
NULL |
| 297 |
}; |
| 298 |
|
| 299 |
static menucommon_s *g_weapons_controls[] = { |
| 300 |
(menucommon_s *)&s_controls.attack, |
| 301 |
(menucommon_s *)&s_controls.nextweapon, |
| 302 |
(menucommon_s *)&s_controls.prevweapon, |
| 303 |
(menucommon_s *)&s_controls.autoswitch, |
| 304 |
(menucommon_s *)&s_controls.chainsaw, |
| 305 |
(menucommon_s *)&s_controls.machinegun, |
| 306 |
(menucommon_s *)&s_controls.shotgun, |
| 307 |
(menucommon_s *)&s_controls.grenadelauncher, |
| 308 |
(menucommon_s *)&s_controls.rocketlauncher, |
| 309 |
(menucommon_s *)&s_controls.lightning, |
| 310 |
(menucommon_s *)&s_controls.railgun, |
| 311 |
(menucommon_s *)&s_controls.plasma, |
| 312 |
(menucommon_s *)&s_controls.bfg, |
| 313 |
NULL, |
| 314 |
}; |
| 315 |
|
| 316 |
static menucommon_s *g_looking_controls[] = { |
| 317 |
(menucommon_s *)&s_controls.sensitivity, |
| 318 |
(menucommon_s *)&s_controls.smoothmouse, |
| 319 |
(menucommon_s *)&s_controls.invertmouse, |
| 320 |
(menucommon_s *)&s_controls.lookup, |
| 321 |
(menucommon_s *)&s_controls.lookdown, |
| 322 |
(menucommon_s *)&s_controls.mouselook, |
| 323 |
(menucommon_s *)&s_controls.freelook, |
| 324 |
(menucommon_s *)&s_controls.centerview, |
| 325 |
(menucommon_s *)&s_controls.zoomview, |
| 326 |
(menucommon_s *)&s_controls.joyenable, |
| 327 |
(menucommon_s *)&s_controls.joythreshold, |
| 328 |
NULL, |
| 329 |
}; |
| 330 |
|
| 331 |
static menucommon_s *g_misc_controls[] = { |
| 332 |
(menucommon_s *)&s_controls.showscores, |
| 333 |
(menucommon_s *)&s_controls.useitem, |
| 334 |
(menucommon_s *)&s_controls.gesture, |
| 335 |
(menucommon_s *)&s_controls.chat, |
| 336 |
(menucommon_s *)&s_controls.chat2, |
| 337 |
(menucommon_s *)&s_controls.chat3, |
| 338 |
(menucommon_s *)&s_controls.chat4, |
| 339 |
(menucommon_s *)&s_controls.togglemenu, |
| 340 |
NULL, |
| 341 |
}; |
| 342 |
|
| 343 |
static menucommon_s **g_controls[] = { |
| 344 |
g_movement_controls, |
| 345 |
g_looking_controls, |
| 346 |
g_weapons_controls, |
| 347 |
g_misc_controls, |
| 348 |
}; |
| 349 |
|
| 350 |
|
| 351 |
|
| 352 |
|
| 353 |
|
| 354 |
|
| 355 |
static void Controls_InitCvars( void ) |
| 356 |
{ |
| 357 |
configcvar_t* cvarptr; |
| 358 |
|
| 359 |
cvarptr = g_configcvars; |
| 360 |
for (;;cvarptr++) |
| 361 |
{ |
| 362 |
if (!cvarptr->name) |
| 363 |
break; |
| 364 |
|
| 365 |
|
| 366 |
cvarptr->value = trap_Cvar_VariableValue( cvarptr->name ); |
| 367 |
|
| 368 |
|
| 369 |
trap_Cvar_Reset( cvarptr->name ); |
| 370 |
cvarptr->defaultvalue = trap_Cvar_VariableValue( cvarptr->name ); |
| 371 |
|
| 372 |
|
| 373 |
trap_Cvar_SetValue( cvarptr->name, cvarptr->value ); |
| 374 |
} |
| 375 |
} |
| 376 |
|
| 377 |
|
| 378 |
|
| 379 |
|
| 380 |
|
| 381 |
|
| 382 |
static float Controls_GetCvarDefault( char* name ) |
| 383 |
{ |
| 384 |
configcvar_t* cvarptr; |
| 385 |
|
| 386 |
cvarptr = g_configcvars; |
| 387 |
for (;;cvarptr++) |
| 388 |
{ |
| 389 |
if (!cvarptr->name) |
| 390 |
return (0); |
| 391 |
|
| 392 |
if (!strcmp(cvarptr->name,name)) |
| 393 |
break; |
| 394 |
} |
| 395 |
|
| 396 |
return (cvarptr->defaultvalue); |
| 397 |
} |
| 398 |
|
| 399 |
|
| 400 |
|
| 401 |
|
| 402 |
|
| 403 |
|
| 404 |
static float Controls_GetCvarValue( char* name ) |
| 405 |
{ |
| 406 |
configcvar_t* cvarptr; |
| 407 |
|
| 408 |
cvarptr = g_configcvars; |
| 409 |
for (;;cvarptr++) |
| 410 |
{ |
| 411 |
if (!cvarptr->name) |
| 412 |
return (0); |
| 413 |
|
| 414 |
if (!strcmp(cvarptr->name,name)) |
| 415 |
break; |
| 416 |
} |
| 417 |
|
| 418 |
return (cvarptr->value); |
| 419 |
} |
| 420 |
|
| 421 |
|
| 422 |
|
| 423 |
|
| 424 |
|
| 425 |
|
| 426 |
|
| 427 |
static void Controls_UpdateModel( int anim ) { |
| 428 |
VectorClear( s_controls.playerViewangles ); |
| 429 |
VectorClear( s_controls.playerMoveangles ); |
| 430 |
s_controls.playerViewangles[YAW] = 180 - 30; |
| 431 |
s_controls.playerMoveangles[YAW] = s_controls.playerViewangles[YAW]; |
| 432 |
s_controls.playerLegs = LEGS_IDLE; |
| 433 |
s_controls.playerTorso = TORSO_STAND; |
| 434 |
s_controls.playerWeapon = WP_NUM_WEAPONS; |
| 435 |
s_controls.playerChat = qfalse; |
| 436 |
|
| 437 |
switch( anim ) { |
| 438 |
case ANIM_RUN: |
| 439 |
s_controls.playerLegs = LEGS_RUN; |
| 440 |
break; |
| 441 |
|
| 442 |
case ANIM_WALK: |
| 443 |
s_controls.playerLegs = LEGS_WALK; |
| 444 |
break; |
| 445 |
|
| 446 |
case ANIM_BACK: |
| 447 |
s_controls.playerLegs = LEGS_BACK; |
| 448 |
break; |
| 449 |
|
| 450 |
case ANIM_JUMP: |
| 451 |
s_controls.playerLegs = LEGS_JUMP; |
| 452 |
break; |
| 453 |
|
| 454 |
case ANIM_CROUCH: |
| 455 |
s_controls.playerLegs = LEGS_IDLECR; |
| 456 |
break; |
| 457 |
|
| 458 |
case ANIM_TURNLEFT: |
| 459 |
s_controls.playerViewangles[YAW] += 90; |
| 460 |
break; |
| 461 |
|
| 462 |
case ANIM_TURNRIGHT: |
| 463 |
s_controls.playerViewangles[YAW] -= 90; |
| 464 |
break; |
| 465 |
|
| 466 |
case ANIM_STEPLEFT: |
| 467 |
s_controls.playerLegs = LEGS_WALK; |
| 468 |
s_controls.playerMoveangles[YAW] = s_controls.playerViewangles[YAW] + 90; |
| 469 |
break; |
| 470 |
|
| 471 |
case ANIM_STEPRIGHT: |
| 472 |
s_controls.playerLegs = LEGS_WALK; |
| 473 |
s_controls.playerMoveangles[YAW] = s_controls.playerViewangles[YAW] - 90; |
| 474 |
break; |
| 475 |
|
| 476 |
case ANIM_LOOKUP: |
| 477 |
s_controls.playerViewangles[PITCH] = -45; |
| 478 |
break; |
| 479 |
|
| 480 |
case ANIM_LOOKDOWN: |
| 481 |
s_controls.playerViewangles[PITCH] = 45; |
| 482 |
break; |
| 483 |
|
| 484 |
case ANIM_WEAPON1: |
| 485 |
s_controls.playerWeapon = WP_GAUNTLET; |
| 486 |
break; |
| 487 |
|
| 488 |
case ANIM_WEAPON2: |
| 489 |
s_controls.playerWeapon = WP_MACHINEGUN; |
| 490 |
break; |
| 491 |
|
| 492 |
case ANIM_WEAPON3: |
| 493 |
s_controls.playerWeapon = WP_SHOTGUN; |
| 494 |
break; |
| 495 |
|
| 496 |
case ANIM_WEAPON4: |
| 497 |
s_controls.playerWeapon = WP_GRENADE_LAUNCHER; |
| 498 |
break; |
| 499 |
|
| 500 |
case ANIM_WEAPON5: |
| 501 |
s_controls.playerWeapon = WP_ROCKET_LAUNCHER; |
| 502 |
break; |
| 503 |
|
| 504 |
case ANIM_WEAPON6: |
| 505 |
s_controls.playerWeapon = WP_LIGHTNING; |
| 506 |
break; |
| 507 |
|
| 508 |
case ANIM_WEAPON7: |
| 509 |
s_controls.playerWeapon = WP_RAILGUN; |
| 510 |
break; |
| 511 |
|
| 512 |
case ANIM_WEAPON8: |
| 513 |
s_controls.playerWeapon = WP_PLASMAGUN; |
| 514 |
break; |
| 515 |
|
| 516 |
case ANIM_WEAPON9: |
| 517 |
s_controls.playerWeapon = WP_BFG; |
| 518 |
break; |
| 519 |
|
| 520 |
case ANIM_WEAPON10: |
| 521 |
s_controls.playerWeapon = WP_GRAPPLING_HOOK; |
| 522 |
break; |
| 523 |
|
| 524 |
case ANIM_ATTACK: |
| 525 |
s_controls.playerTorso = TORSO_ATTACK; |
| 526 |
break; |
| 527 |
|
| 528 |
case ANIM_GESTURE: |
| 529 |
s_controls.playerTorso = TORSO_GESTURE; |
| 530 |
break; |
| 531 |
|
| 532 |
case ANIM_DIE: |
| 533 |
s_controls.playerLegs = BOTH_DEATH1; |
| 534 |
s_controls.playerTorso = BOTH_DEATH1; |
| 535 |
s_controls.playerWeapon = WP_NONE; |
| 536 |
break; |
| 537 |
|
| 538 |
case ANIM_CHAT: |
| 539 |
s_controls.playerChat = qtrue; |
| 540 |
break; |
| 541 |
|
| 542 |
default: |
| 543 |
break; |
| 544 |
} |
| 545 |
|
| 546 |
UI_PlayerInfo_SetInfo( &s_controls.playerinfo, s_controls.playerLegs, s_controls.playerTorso, s_controls.playerViewangles, s_controls.playerMoveangles, s_controls.playerWeapon, s_controls.playerChat ); |
| 547 |
} |
| 548 |
|
| 549 |
|
| 550 |
|
| 551 |
|
| 552 |
|
| 553 |
|
| 554 |
|
| 555 |
static void Controls_Update( void ) { |
| 556 |
int i; |
| 557 |
int j; |
| 558 |
int y; |
| 559 |
menucommon_s **controls; |
| 560 |
menucommon_s *control; |
| 561 |
|
| 562 |
|
| 563 |
for( i = 0; i < C_MAX; i++ ) { |
| 564 |
controls = g_controls[i]; |
| 565 |
for( j = 0; (control = controls[j]) ; j++ ) { |
| 566 |
control->flags |= (QMF_HIDDEN|QMF_INACTIVE); |
| 567 |
} |
| 568 |
} |
| 569 |
|
| 570 |
controls = g_controls[s_controls.section]; |
| 571 |
|
| 572 |
|
| 573 |
for( j = 0; (control = controls[j]) ; j++ ) { |
| 574 |
control->flags &= ~(QMF_GRAYED|QMF_HIDDEN|QMF_INACTIVE); |
| 575 |
} |
| 576 |
|
| 577 |
|
| 578 |
y = ( SCREEN_HEIGHT - j * SMALLCHAR_HEIGHT ) / 2; |
| 579 |
for( j = 0; (control = controls[j]) ; j++, y += SMALLCHAR_HEIGHT ) { |
| 580 |
control->x = 320; |
| 581 |
control->y = y; |
| 582 |
control->left = 320 - 19*SMALLCHAR_WIDTH; |
| 583 |
control->right = 320 + 21*SMALLCHAR_WIDTH; |
| 584 |
control->top = y; |
| 585 |
control->bottom = y + SMALLCHAR_HEIGHT; |
| 586 |
} |
| 587 |
|
| 588 |
if( s_controls.waitingforkey ) { |
| 589 |
|
| 590 |
for( i = 0; i < s_controls.menu.nitems; i++ ) { |
| 591 |
((menucommon_s*)(s_controls.menu.items[i]))->flags |= QMF_GRAYED; |
| 592 |
} |
| 593 |
|
| 594 |
|
| 595 |
((menucommon_s*)(s_controls.menu.items[s_controls.menu.cursor]))->flags &= ~QMF_GRAYED; |
| 596 |
|
| 597 |
|
| 598 |
s_controls.name.generic.flags &= ~QMF_GRAYED; |
| 599 |
|
| 600 |
return; |
| 601 |
} |
| 602 |
|
| 603 |
|
| 604 |
for( i = 0; i < s_controls.menu.nitems; i++ ) { |
| 605 |
((menucommon_s*)(s_controls.menu.items[i]))->flags &= ~QMF_GRAYED; |
| 606 |
} |
| 607 |
|
| 608 |
|
| 609 |
s_controls.looking.generic.flags &= ~(QMF_GRAYED|QMF_HIGHLIGHT|QMF_HIGHLIGHT_IF_FOCUS); |
| 610 |
s_controls.movement.generic.flags &= ~(QMF_GRAYED|QMF_HIGHLIGHT|QMF_HIGHLIGHT_IF_FOCUS); |
| 611 |
s_controls.weapons.generic.flags &= ~(QMF_GRAYED|QMF_HIGHLIGHT|QMF_HIGHLIGHT_IF_FOCUS); |
| 612 |
s_controls.misc.generic.flags &= ~(QMF_GRAYED|QMF_HIGHLIGHT|QMF_HIGHLIGHT_IF_FOCUS); |
| 613 |
|
| 614 |
s_controls.looking.generic.flags |= QMF_PULSEIFFOCUS; |
| 615 |
s_controls.movement.generic.flags |= QMF_PULSEIFFOCUS; |
| 616 |
s_controls.weapons.generic.flags |= QMF_PULSEIFFOCUS; |
| 617 |
s_controls.misc.generic.flags |= QMF_PULSEIFFOCUS; |
| 618 |
|
| 619 |
|
| 620 |
switch( s_controls.section ) { |
| 621 |
case C_MOVEMENT: |
| 622 |
s_controls.movement.generic.flags &= ~QMF_PULSEIFFOCUS; |
| 623 |
s_controls.movement.generic.flags |= (QMF_HIGHLIGHT|QMF_HIGHLIGHT_IF_FOCUS); |
| 624 |
break; |
| 625 |
|
| 626 |
case C_LOOKING: |
| 627 |
s_controls.looking.generic.flags &= ~QMF_PULSEIFFOCUS; |
| 628 |
s_controls.looking.generic.flags |= (QMF_HIGHLIGHT|QMF_HIGHLIGHT_IF_FOCUS); |
| 629 |
break; |
| 630 |
|
| 631 |
case C_WEAPONS: |
| 632 |
s_controls.weapons.generic.flags &= ~QMF_PULSEIFFOCUS; |
| 633 |
s_controls.weapons.generic.flags |= (QMF_HIGHLIGHT|QMF_HIGHLIGHT_IF_FOCUS); |
| 634 |
break; |
| 635 |
|
| 636 |
case C_MISC: |
| 637 |
s_controls.misc.generic.flags &= ~QMF_PULSEIFFOCUS; |
| 638 |
s_controls.misc.generic.flags |= (QMF_HIGHLIGHT|QMF_HIGHLIGHT_IF_FOCUS); |
| 639 |
break; |
| 640 |
} |
| 641 |
} |
| 642 |
|
| 643 |
|
| 644 |
|
| 645 |
|
| 646 |
|
| 647 |
|
| 648 |
|
| 649 |
static void Controls_DrawKeyBinding( void *self ) |
| 650 |
{ |
| 651 |
menuaction_s* a; |
| 652 |
int x; |
| 653 |
int y; |
| 654 |
int b1; |
| 655 |
int b2; |
| 656 |
qboolean c; |
| 657 |
char name[32]; |
| 658 |
char name2[32]; |
| 659 |
|
| 660 |
a = (menuaction_s*) self; |
| 661 |
|
| 662 |
x = a->generic.x; |
| 663 |
y = a->generic.y; |
| 664 |
|
| 665 |
c = (Menu_ItemAtCursor( a->generic.parent ) == a); |
| 666 |
|
| 667 |
b1 = g_bindings[a->generic.id].bind1; |
| 668 |
if (b1 == -1) |
| 669 |
strcpy(name,"???"); |
| 670 |
else |
| 671 |
{ |
| 672 |
trap_Key_KeynumToStringBuf( b1, name, 32 ); |
| 673 |
Q_strupr(name); |
| 674 |
|
| 675 |
b2 = g_bindings[a->generic.id].bind2; |
| 676 |
if (b2 != -1) |
| 677 |
{ |
| 678 |
trap_Key_KeynumToStringBuf( b2, name2, 32 ); |
| 679 |
Q_strupr(name2); |
| 680 |
|
| 681 |
strcat( name, " or " ); |
| 682 |
strcat( name, name2 ); |
| 683 |
} |
| 684 |
} |
| 685 |
|
| 686 |
if (c) |
| 687 |
{ |
| 688 |
UI_FillRect( a->generic.left, a->generic.top, a->generic.right-a->generic.left+1, a->generic.bottom-a->generic.top+1, listbar_color ); |
| 689 |
|
| 690 |
UI_DrawString( x - SMALLCHAR_WIDTH, y, g_bindings[a->generic.id].label, UI_RIGHT|UI_SMALLFONT, text_color_highlight ); |
| 691 |
UI_DrawString( x + SMALLCHAR_WIDTH, y, name, UI_LEFT|UI_SMALLFONT|UI_PULSE, text_color_highlight ); |
| 692 |
|
| 693 |
if (s_controls.waitingforkey) |
| 694 |
{ |
| 695 |
UI_DrawChar( x, y, '=', UI_CENTER|UI_BLINK|UI_SMALLFONT, text_color_highlight); |
| 696 |
UI_DrawString(SCREEN_WIDTH * 0.50, SCREEN_HEIGHT * 0.80, "Waiting for new key ... ESCAPE to cancel", UI_SMALLFONT|UI_CENTER|UI_PULSE, colorWhite ); |
| 697 |
} |
| 698 |
else |
| 699 |
{ |
| 700 |
UI_DrawChar( x, y, 13, UI_CENTER|UI_BLINK|UI_SMALLFONT, text_color_highlight); |
| 701 |
UI_DrawString(SCREEN_WIDTH * 0.50, SCREEN_HEIGHT * 0.78, "Press ENTER or CLICK to change", UI_SMALLFONT|UI_CENTER, colorWhite ); |
| 702 |
UI_DrawString(SCREEN_WIDTH * 0.50, SCREEN_HEIGHT * 0.82, "Press BACKSPACE to clear", UI_SMALLFONT|UI_CENTER, colorWhite ); |
| 703 |
} |
| 704 |
} |
| 705 |
else |
| 706 |
{ |
| 707 |
if (a->generic.flags & QMF_GRAYED) |
| 708 |
{ |
| 709 |
UI_DrawString( x - SMALLCHAR_WIDTH, y, g_bindings[a->generic.id].label, UI_RIGHT|UI_SMALLFONT, text_color_disabled ); |
| 710 |
UI_DrawString( x + SMALLCHAR_WIDTH, y, name, UI_LEFT|UI_SMALLFONT, text_color_disabled ); |
| 711 |
} |
| 712 |
else |
| 713 |
{ |
| 714 |
UI_DrawString( x - SMALLCHAR_WIDTH, y, g_bindings[a->generic.id].label, UI_RIGHT|UI_SMALLFONT, controls_binding_color ); |
| 715 |
UI_DrawString( x + SMALLCHAR_WIDTH, y, name, UI_LEFT|UI_SMALLFONT, controls_binding_color ); |
| 716 |
} |
| 717 |
} |
| 718 |
} |
| 719 |
|
| 720 |
|
| 721 |
|
| 722 |
|
| 723 |
|
| 724 |
|
| 725 |
static void Controls_StatusBar( void *self ) |
| 726 |
{ |
| 727 |
UI_DrawString(SCREEN_WIDTH * 0.50, SCREEN_HEIGHT * 0.80, "Use Arrow Keys or CLICK to change", UI_SMALLFONT|UI_CENTER, colorWhite ); |
| 728 |
} |
| 729 |
|
| 730 |
|
| 731 |
|
| 732 |
|
| 733 |
|
| 734 |
|
| 735 |
|
| 736 |
static void Controls_DrawPlayer( void *self ) { |
| 737 |
menubitmap_s *b; |
| 738 |
char buf[MAX_QPATH]; |
| 739 |
|
| 740 |
trap_Cvar_VariableStringBuffer( "model", buf, sizeof( buf ) ); |
| 741 |
if ( strcmp( buf, s_controls.playerModel ) != 0 ) { |
| 742 |
UI_PlayerInfo_SetModel( &s_controls.playerinfo, buf ); |
| 743 |
strcpy( s_controls.playerModel, buf ); |
| 744 |
Controls_UpdateModel( ANIM_IDLE ); |
| 745 |
} |
| 746 |
|
| 747 |
b = (menubitmap_s*) self; |
| 748 |
UI_DrawPlayer( b->generic.x, b->generic.y, b->width, b->height, &s_controls.playerinfo, uis.realtime/2 ); |
| 749 |
} |
| 750 |
|
| 751 |
|
| 752 |
|
| 753 |
|
| 754 |
|
| 755 |
|
| 756 |
|
| 757 |
static void Controls_GetKeyAssignment (char *command, int *twokeys) |
| 758 |
{ |
| 759 |
int count; |
| 760 |
int j; |
| 761 |
char b[256]; |
| 762 |
|
| 763 |
twokeys[0] = twokeys[1] = -1; |
| 764 |
count = 0; |
| 765 |
|
| 766 |
for ( j = 0; j < 256; j++ ) |
| 767 |
{ |
| 768 |
trap_Key_GetBindingBuf( j, b, 256 ); |
| 769 |
if ( *b == 0 ) { |
| 770 |
continue; |
| 771 |
} |
| 772 |
if ( !Q_stricmp( b, command ) ) { |
| 773 |
twokeys[count] = j; |
| 774 |
count++; |
| 775 |
if (count == 2) |
| 776 |
break; |
| 777 |
} |
| 778 |
} |
| 779 |
} |
| 780 |
|
| 781 |
|
| 782 |
|
| 783 |
|
| 784 |
|
| 785 |
|
| 786 |
static void Controls_GetConfig( void ) |
| 787 |
{ |
| 788 |
int twokeys[2]; |
| 789 |
bind_t* bindptr; |
| 790 |
|
| 791 |
|
| 792 |
bindptr = g_bindings; |
| 793 |
|
| 794 |
|
| 795 |
for (;;bindptr++) |
| 796 |
{ |
| 797 |
if (!bindptr->label) |
| 798 |
break; |
| 799 |
|
| 800 |
Controls_GetKeyAssignment(bindptr->command, twokeys); |
| 801 |
|
| 802 |
bindptr->bind1 = twokeys[0]; |
| 803 |
bindptr->bind2 = twokeys[1]; |
| 804 |
} |
| 805 |
|
| 806 |
s_controls.invertmouse.curvalue = Controls_GetCvarValue( "m_pitch" ) < 0; |
| 807 |
s_controls.smoothmouse.curvalue = UI_ClampCvar( 0, 1, Controls_GetCvarValue( "m_filter" ) ); |
| 808 |
s_controls.alwaysrun.curvalue = UI_ClampCvar( 0, 1, Controls_GetCvarValue( "cl_run" ) ); |
| 809 |
s_controls.autoswitch.curvalue = UI_ClampCvar( 0, 1, Controls_GetCvarValue( "cg_autoswitch" ) ); |
| 810 |
s_controls.sensitivity.curvalue = UI_ClampCvar( 2, 30, Controls_GetCvarValue( "sensitivity" ) ); |
| 811 |
s_controls.joyenable.curvalue = UI_ClampCvar( 0, 1, Controls_GetCvarValue( "in_joystick" ) ); |
| 812 |
s_controls.joythreshold.curvalue = UI_ClampCvar( 0.05f, 0.75f, Controls_GetCvarValue( "joy_threshold" ) ); |
| 813 |
s_controls.freelook.curvalue = UI_ClampCvar( 0, 1, Controls_GetCvarValue( "cl_freelook" ) ); |
| 814 |
} |
| 815 |
|
| 816 |
|
| 817 |
|
| 818 |
|
| 819 |
|
| 820 |
|
| 821 |
static void Controls_SetConfig( void ) |
| 822 |
{ |
| 823 |
bind_t* bindptr; |
| 824 |
|
| 825 |
|
| 826 |
bindptr = g_bindings; |
| 827 |
|
| 828 |
|
| 829 |
for (;;bindptr++) |
| 830 |
{ |
| 831 |
if (!bindptr->label) |
| 832 |
break; |
| 833 |
|
| 834 |
if (bindptr->bind1 != -1) |
| 835 |
{ |
| 836 |
trap_Key_SetBinding( bindptr->bind1, bindptr->command ); |
| 837 |
|
| 838 |
if (bindptr->bind2 != -1) |
| 839 |
trap_Key_SetBinding( bindptr->bind2, bindptr->command ); |
| 840 |
} |
| 841 |
} |
| 842 |
|
| 843 |
if ( s_controls.invertmouse.curvalue ) |
| 844 |
trap_Cvar_SetValue( "m_pitch", -fabs( trap_Cvar_VariableValue( "m_pitch" ) ) ); |
| 845 |
else |
| 846 |
trap_Cvar_SetValue( "m_pitch", fabs( trap_Cvar_VariableValue( "m_pitch" ) ) ); |
| 847 |
|
| 848 |
trap_Cvar_SetValue( "m_filter", s_controls.smoothmouse.curvalue ); |
| 849 |
trap_Cvar_SetValue( "cl_run", s_controls.alwaysrun.curvalue ); |
| 850 |
trap_Cvar_SetValue( "cg_autoswitch", s_controls.autoswitch.curvalue ); |
| 851 |
trap_Cvar_SetValue( "sensitivity", s_controls.sensitivity.curvalue ); |
| 852 |
trap_Cvar_SetValue( "in_joystick", s_controls.joyenable.curvalue ); |
| 853 |
trap_Cvar_SetValue( "joy_threshold", s_controls.joythreshold.curvalue ); |
| 854 |
trap_Cvar_SetValue( "cl_freelook", s_controls.freelook.curvalue ); |
| 855 |
trap_Cmd_ExecuteText( EXEC_APPEND, "in_restart\n" ); |
| 856 |
} |
| 857 |
|
| 858 |
|
| 859 |
|
| 860 |
|
| 861 |
|
| 862 |
|
| 863 |
static void Controls_SetDefaults( void ) |
| 864 |
{ |
| 865 |
bind_t* bindptr; |
| 866 |
|
| 867 |
|
| 868 |
bindptr = g_bindings; |
| 869 |
|
| 870 |
|
| 871 |
for (;;bindptr++) |
| 872 |
{ |
| 873 |
if (!bindptr->label) |
| 874 |
break; |
| 875 |
|
| 876 |
bindptr->bind1 = bindptr->defaultbind1; |
| 877 |
bindptr->bind2 = bindptr->defaultbind2; |
| 878 |
} |
| 879 |
|
| 880 |
s_controls.invertmouse.curvalue = Controls_GetCvarDefault( "m_pitch" ) < 0; |
| 881 |
s_controls.smoothmouse.curvalue = Controls_GetCvarDefault( "m_filter" ); |
| 882 |
s_controls.alwaysrun.curvalue = Controls_GetCvarDefault( "cl_run" ); |
| 883 |
s_controls.autoswitch.curvalue = Controls_GetCvarDefault( "cg_autoswitch" ); |
| 884 |
s_controls.sensitivity.curvalue = Controls_GetCvarDefault( "sensitivity" ); |
| 885 |
s_controls.joyenable.curvalue = Controls_GetCvarDefault( "in_joystick" ); |
| 886 |
s_controls.joythreshold.curvalue = Controls_GetCvarDefault( "joy_threshold" ); |
| 887 |
s_controls.freelook.curvalue = Controls_GetCvarDefault( "cl_freelook" ); |
| 888 |
} |
| 889 |
|
| 890 |
|
| 891 |
|
| 892 |
|
| 893 |
|
| 894 |
|
| 895 |
static sfxHandle_t Controls_MenuKey( int key ) |
| 896 |
{ |
| 897 |
int id; |
| 898 |
qboolean found; |
| 899 |
bind_t* bindptr; |
| 900 |
found = qfalse; |
| 901 |
|
| 902 |
if (!s_controls.waitingforkey) |
| 903 |
{ |
| 904 |
switch (key) |
| 905 |
{ |
| 906 |
case K_BACKSPACE: |
| 907 |
case K_DEL: |
| 908 |
case K_KP_DEL: |
| 909 |
key = -1; |
| 910 |
break; |
| 911 |
|
| 912 |
case K_MOUSE2: |
| 913 |
case K_ESCAPE: |
| 914 |
if (s_controls.changesmade) |
| 915 |
Controls_SetConfig(); |
| 916 |
goto ignorekey; |
| 917 |
|
| 918 |
default: |
| 919 |
goto ignorekey; |
| 920 |
} |
| 921 |
} |
| 922 |
else |
| 923 |
{ |
| 924 |
if (key & K_CHAR_FLAG) |
| 925 |
goto ignorekey; |
| 926 |
|
| 927 |
switch (key) |
| 928 |
{ |
| 929 |
case K_ESCAPE: |
| 930 |
s_controls.waitingforkey = qfalse; |
| 931 |
Controls_Update(); |
| 932 |
return (menu_out_sound); |
| 933 |
|
| 934 |
case '`': |
| 935 |
goto ignorekey; |
| 936 |
} |
| 937 |
} |
| 938 |
|
| 939 |
s_controls.changesmade = qtrue; |
| 940 |
|
| 941 |
if (key != -1) |
| 942 |
{ |
| 943 |
|
| 944 |
bindptr = g_bindings; |
| 945 |
for (;;bindptr++) |
| 946 |
{ |
| 947 |
if (!bindptr->label) |
| 948 |
break; |
| 949 |
|
| 950 |
if (bindptr->bind2 == key) |
| 951 |
bindptr->bind2 = -1; |
| 952 |
|
| 953 |
if (bindptr->bind1 == key) |
| 954 |
{ |
| 955 |
bindptr->bind1 = bindptr->bind2; |
| 956 |
bindptr->bind2 = -1; |
| 957 |
} |
| 958 |
} |
| 959 |
} |
| 960 |
|
| 961 |
|
| 962 |
id = ((menucommon_s*)(s_controls.menu.items[s_controls.menu.cursor]))->id; |
| 963 |
bindptr = g_bindings; |
| 964 |
for (;;bindptr++) |
| 965 |
{ |
| 966 |
if (!bindptr->label) |
| 967 |
break; |
| 968 |
|
| 969 |
if (bindptr->id == id) |
| 970 |
{ |
| 971 |
found = qtrue; |
| 972 |
if (key == -1) |
| 973 |
{ |
| 974 |
if( bindptr->bind1 != -1 ) { |
| 975 |
trap_Key_SetBinding( bindptr->bind1, "" ); |
| 976 |
bindptr->bind1 = -1; |
| 977 |
} |
| 978 |
if( bindptr->bind2 != -1 ) { |
| 979 |
trap_Key_SetBinding( bindptr->bind2, "" ); |
| 980 |
bindptr->bind2 = -1; |
| 981 |
} |
| 982 |
} |
| 983 |
else if (bindptr->bind1 == -1) { |
| 984 |
bindptr->bind1 = key; |
| 985 |
} |
| 986 |
else if (bindptr->bind1 != key && bindptr->bind2 == -1) { |
| 987 |
bindptr->bind2 = key; |
| 988 |
} |
| 989 |
else |
| 990 |
{ |
| 991 |
trap_Key_SetBinding( bindptr->bind1, "" ); |
| 992 |
trap_Key_SetBinding( bindptr->bind2, "" ); |
| 993 |
bindptr->bind1 = key; |
| 994 |
bindptr->bind2 = -1; |
| 995 |
} |
| 996 |
break; |
| 997 |
} |
| 998 |
} |
| 999 |
|
| 1000 |
s_controls.waitingforkey = qfalse; |
| 1001 |
|
| 1002 |
if (found) |
| 1003 |
{ |
| 1004 |
Controls_Update(); |
| 1005 |
return (menu_out_sound); |
| 1006 |
} |
| 1007 |
|
| 1008 |
ignorekey: |
| 1009 |
return Menu_DefaultKey( &s_controls.menu, key ); |
| 1010 |
} |
| 1011 |
|
| 1012 |
|
| 1013 |
|
| 1014 |
|
| 1015 |
|
| 1016 |
|
| 1017 |
static void Controls_ResetDefaults_Action( qboolean result ) { |
| 1018 |
if( !result ) { |
| 1019 |
return; |
| 1020 |
} |
| 1021 |
|
| 1022 |
s_controls.changesmade = qtrue; |
| 1023 |
Controls_SetDefaults(); |
| 1024 |
Controls_Update(); |
| 1025 |
} |
| 1026 |
|
| 1027 |
|
| 1028 |
|
| 1029 |
|
| 1030 |
|
| 1031 |
|
| 1032 |
static void Controls_ResetDefaults_Draw( void ) { |
| 1033 |
UI_DrawProportionalString( SCREEN_WIDTH/2, 356 + PROP_HEIGHT * 0, "WARNING: This will reset all", UI_CENTER|UI_SMALLFONT, color_yellow ); |
| 1034 |
UI_DrawProportionalString( SCREEN_WIDTH/2, 356 + PROP_HEIGHT * 1, "controls to their default values.", UI_CENTER|UI_SMALLFONT, color_yellow ); |
| 1035 |
} |
| 1036 |
|
| 1037 |
|
| 1038 |
|
| 1039 |
|
| 1040 |
|
| 1041 |
|
| 1042 |
static void Controls_MenuEvent( void* ptr, int event ) |
| 1043 |
{ |
| 1044 |
switch (((menucommon_s*)ptr)->id) |
| 1045 |
{ |
| 1046 |
case ID_MOVEMENT: |
| 1047 |
if (event == QM_ACTIVATED) |
| 1048 |
{ |
| 1049 |
s_controls.section = C_MOVEMENT; |
| 1050 |
Controls_Update(); |
| 1051 |
} |
| 1052 |
break; |
| 1053 |
|
| 1054 |
case ID_LOOKING: |
| 1055 |
if (event == QM_ACTIVATED) |
| 1056 |
{ |
| 1057 |
s_controls.section = C_LOOKING; |
| 1058 |
Controls_Update(); |
| 1059 |
} |
| 1060 |
break; |
| 1061 |
|
| 1062 |
case ID_WEAPONS: |
| 1063 |
if (event == QM_ACTIVATED) |
| 1064 |
{ |
| 1065 |
s_controls.section = C_WEAPONS; |
| 1066 |
Controls_Update(); |
| 1067 |
} |
| 1068 |
break; |
| 1069 |
|
| 1070 |
case ID_MISC: |
| 1071 |
if (event == QM_ACTIVATED) |
| 1072 |
{ |
| 1073 |
s_controls.section = C_MISC; |
| 1074 |
Controls_Update(); |
| 1075 |
} |
| 1076 |
break; |
| 1077 |
|
| 1078 |
case ID_DEFAULTS: |
| 1079 |
if (event == QM_ACTIVATED) |
| 1080 |
{ |
| 1081 |
UI_ConfirmMenu( "SET TO DEFAULTS?", Controls_ResetDefaults_Draw, Controls_ResetDefaults_Action ); |
| 1082 |
} |
| 1083 |
break; |
| 1084 |
|
| 1085 |
case ID_BACK: |
| 1086 |
if (event == QM_ACTIVATED) |
| 1087 |
{ |
| 1088 |
if (s_controls.changesmade) |
| 1089 |
Controls_SetConfig(); |
| 1090 |
UI_PopMenu(); |
| 1091 |
} |
| 1092 |
break; |
| 1093 |
|
| 1094 |
case ID_SAVEANDEXIT: |
| 1095 |
if (event == QM_ACTIVATED) |
| 1096 |
{ |
| 1097 |
Controls_SetConfig(); |
| 1098 |
UI_PopMenu(); |
| 1099 |
} |
| 1100 |
break; |
| 1101 |
|
| 1102 |
case ID_EXIT: |
| 1103 |
if (event == QM_ACTIVATED) |
| 1104 |
{ |
| 1105 |
UI_PopMenu(); |
| 1106 |
} |
| 1107 |
break; |
| 1108 |
|
| 1109 |
case ID_FREELOOK: |
| 1110 |
case ID_MOUSESPEED: |
| 1111 |
case ID_INVERTMOUSE: |
| 1112 |
case ID_SMOOTHMOUSE: |
| 1113 |
case ID_ALWAYSRUN: |
| 1114 |
case ID_AUTOSWITCH: |
| 1115 |
case ID_JOYENABLE: |
| 1116 |
case ID_JOYTHRESHOLD: |
| 1117 |
if (event == QM_ACTIVATED) |
| 1118 |
{ |
| 1119 |
s_controls.changesmade = qtrue; |
| 1120 |
} |
| 1121 |
break; |
| 1122 |
} |
| 1123 |
} |
| 1124 |
|
| 1125 |
|
| 1126 |
|
| 1127 |
|
| 1128 |
|
| 1129 |
|
| 1130 |
static void Controls_ActionEvent( void* ptr, int event ) |
| 1131 |
{ |
| 1132 |
if (event == QM_LOSTFOCUS) |
| 1133 |
{ |
| 1134 |
Controls_UpdateModel( ANIM_IDLE ); |
| 1135 |
} |
| 1136 |
else if (event == QM_GOTFOCUS) |
| 1137 |
{ |
| 1138 |
Controls_UpdateModel( g_bindings[((menucommon_s*)ptr)->id].anim ); |
| 1139 |
} |
| 1140 |
else if ((event == QM_ACTIVATED) && !s_controls.waitingforkey) |
| 1141 |
{ |
| 1142 |
s_controls.waitingforkey = 1; |
| 1143 |
Controls_Update(); |
| 1144 |
} |
| 1145 |
} |
| 1146 |
|
| 1147 |
|
| 1148 |
|
| 1149 |
|
| 1150 |
|
| 1151 |
|
| 1152 |
static void Controls_InitModel( void ) |
| 1153 |
{ |
| 1154 |
memset( &s_controls.playerinfo, 0, sizeof(playerInfo_t) ); |
| 1155 |
|
| 1156 |
UI_PlayerInfo_SetModel( &s_controls.playerinfo, UI_Cvar_VariableString( "model" ) ); |
| 1157 |
|
| 1158 |
Controls_UpdateModel( ANIM_IDLE ); |
| 1159 |
} |
| 1160 |
|
| 1161 |
|
| 1162 |
|
| 1163 |
|
| 1164 |
|
| 1165 |
|
| 1166 |
static void Controls_InitWeapons( void ) { |
| 1167 |
gitem_t * item; |
| 1168 |
|
| 1169 |
for ( item = bg_itemlist + 1 ; item->classname ; item++ ) { |
| 1170 |
if ( item->giType != IT_WEAPON ) { |
| 1171 |
continue; |
| 1172 |
} |
| 1173 |
trap_R_RegisterModel( item->world_model[0] ); |
| 1174 |
} |
| 1175 |
} |
| 1176 |
|
| 1177 |
|
| 1178 |
|
| 1179 |
|
| 1180 |
|
| 1181 |
|
| 1182 |
static void Controls_MenuInit( void ) |
| 1183 |
{ |
| 1184 |
static char playername[32]; |
| 1185 |
|
| 1186 |
|
| 1187 |
memset( &s_controls, 0 ,sizeof(controls_t) ); |
| 1188 |
|
| 1189 |
Controls_Cache(); |
| 1190 |
|
| 1191 |
s_controls.menu.key = Controls_MenuKey; |
| 1192 |
s_controls.menu.wrapAround = qtrue; |
| 1193 |
s_controls.menu.fullscreen = qtrue; |
| 1194 |
|
| 1195 |
s_controls.banner.generic.type = MTYPE_BTEXT; |
| 1196 |
s_controls.banner.generic.flags = QMF_CENTER_JUSTIFY; |
| 1197 |
s_controls.banner.generic.x = 320; |
| 1198 |
s_controls.banner.generic.y = 16; |
| 1199 |
s_controls.banner.string = "CONTROLS"; |
| 1200 |
s_controls.banner.color = color_white; |
| 1201 |
s_controls.banner.style = UI_CENTER; |
| 1202 |
|
| 1203 |
s_controls.framel.generic.type = MTYPE_BITMAP; |
| 1204 |
s_controls.framel.generic.name = ART_FRAMEL; |
| 1205 |
s_controls.framel.generic.flags = QMF_LEFT_JUSTIFY|QMF_INACTIVE; |
| 1206 |
s_controls.framel.generic.x = 0; |
| 1207 |
s_controls.framel.generic.y = 78; |
| 1208 |
s_controls.framel.width = 256; |
| 1209 |
s_controls.framel.height = 329; |
| 1210 |
|
| 1211 |
s_controls.framer.generic.type = MTYPE_BITMAP; |
| 1212 |
s_controls.framer.generic.name = ART_FRAMER; |
| 1213 |
s_controls.framer.generic.flags = QMF_LEFT_JUSTIFY|QMF_INACTIVE; |
| 1214 |
s_controls.framer.generic.x = 376; |
| 1215 |
s_controls.framer.generic.y = 76; |
| 1216 |
s_controls.framer.width = 256; |
| 1217 |
s_controls.framer.height = 334; |
| 1218 |
|
| 1219 |
s_controls.looking.generic.type = MTYPE_PTEXT; |
| 1220 |
s_controls.looking.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS; |
| 1221 |
s_controls.looking.generic.id = ID_LOOKING; |
| 1222 |
s_controls.looking.generic.callback = Controls_MenuEvent; |
| 1223 |
s_controls.looking.generic.x = 152; |
| 1224 |
s_controls.looking.generic.y = 240 - 2 * PROP_HEIGHT; |
| 1225 |
s_controls.looking.string = "LOOK"; |
| 1226 |
s_controls.looking.style = UI_RIGHT; |
| 1227 |
s_controls.looking.color = color_red; |
| 1228 |
|
| 1229 |
s_controls.movement.generic.type = MTYPE_PTEXT; |
| 1230 |
s_controls.movement.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS; |
| 1231 |
s_controls.movement.generic.id = ID_MOVEMENT; |
| 1232 |
s_controls.movement.generic.callback = Controls_MenuEvent; |
| 1233 |
s_controls.movement.generic.x = 152; |
| 1234 |
s_controls.movement.generic.y = 240 - PROP_HEIGHT; |
| 1235 |
s_controls.movement.string = "MOVE"; |
| 1236 |
s_controls.movement.style = UI_RIGHT; |
| 1237 |
s_controls.movement.color = color_red; |
| 1238 |
|
| 1239 |
s_controls.weapons.generic.type = MTYPE_PTEXT; |
| 1240 |
s_controls.weapons.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS; |
| 1241 |
s_controls.weapons.generic.id = ID_WEAPONS; |
| 1242 |
s_controls.weapons.generic.callback = Controls_MenuEvent; |
| 1243 |
s_controls.weapons.generic.x = 152; |
| 1244 |
s_controls.weapons.generic.y = 240; |
| 1245 |
s_controls.weapons.string = "SHOOT"; |
| 1246 |
s_controls.weapons.style = UI_RIGHT; |
| 1247 |
s_controls.weapons.color = color_red; |
| 1248 |
|
| 1249 |
s_controls.misc.generic.type = MTYPE_PTEXT; |
| 1250 |
s_controls.misc.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS; |
| 1251 |
s_controls.misc.generic.id = ID_MISC; |
| 1252 |
s_controls.misc.generic.callback = Controls_MenuEvent; |
| 1253 |
s_controls.misc.generic.x = 152; |
| 1254 |
s_controls.misc.generic.y = 240 + PROP_HEIGHT; |
| 1255 |
s_controls.misc.string = "MISC"; |
| 1256 |
s_controls.misc.style = UI_RIGHT; |
| 1257 |
s_controls.misc.color = color_red; |
| 1258 |
|
| 1259 |
s_controls.back.generic.type = MTYPE_BITMAP; |
| 1260 |
s_controls.back.generic.name = ART_BACK0; |
| 1261 |
s_controls.back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS; |
| 1262 |
s_controls.back.generic.x = 0; |
| 1263 |
s_controls.back.generic.y = 480-64; |
| 1264 |
s_controls.back.generic.id = ID_BACK; |
| 1265 |
s_controls.back.generic.callback = Controls_MenuEvent; |
| 1266 |
s_controls.back.width = 128; |
| 1267 |
s_controls.back.height = 64; |
| 1268 |
s_controls.back.focuspic = ART_BACK1; |
| 1269 |
|
| 1270 |
s_controls.player.generic.type = MTYPE_BITMAP; |
| 1271 |
s_controls.player.generic.flags = QMF_INACTIVE; |
| 1272 |
s_controls.player.generic.ownerdraw = Controls_DrawPlayer; |
| 1273 |
s_controls.player.generic.x = 400; |
| 1274 |
s_controls.player.generic.y = -40; |
| 1275 |
s_controls.player.width = 32*10; |
| 1276 |
s_controls.player.height = 56*10; |
| 1277 |
|
| 1278 |
s_controls.walkforward.generic.type = MTYPE_ACTION; |
| 1279 |
s_controls.walkforward.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN; |
| 1280 |
s_controls.walkforward.generic.callback = Controls_ActionEvent; |
| 1281 |
s_controls.walkforward.generic.ownerdraw = Controls_DrawKeyBinding; |
| 1282 |
s_controls.walkforward.generic.id = ID_FORWARD; |
| 1283 |
|
| 1284 |
s_controls.backpedal.generic.type = MTYPE_ACTION; |
| 1285 |
s_controls.backpedal.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN; |
| 1286 |
s_controls.backpedal.generic.callback = Controls_ActionEvent; |
| 1287 |
s_controls.backpedal.generic.ownerdraw = Controls_DrawKeyBinding; |
| 1288 |
s_controls.backpedal.generic.id = ID_BACKPEDAL; |
| 1289 |
|
| 1290 |
s_controls.stepleft.generic.type = MTYPE_ACTION; |
| 1291 |
s_controls.stepleft.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN; |
| 1292 |
s_controls.stepleft.generic.callback = Controls_ActionEvent; |
| 1293 |
s_controls.stepleft.generic.ownerdraw = Controls_DrawKeyBinding; |
| 1294 |
s_controls.stepleft.generic.id = ID_MOVELEFT; |
| 1295 |
|
| 1296 |
s_controls.stepright.generic.type = MTYPE_ACTION; |
| 1297 |
s_controls.stepright.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN; |
| 1298 |
s_controls.stepright.generic.callback = Controls_ActionEvent; |
| 1299 |
s_controls.stepright.generic.ownerdraw = Controls_DrawKeyBinding; |
| 1300 |
s_controls.stepright.generic.id = ID_MOVERIGHT; |
| 1301 |
|
| 1302 |
s_controls.moveup.generic.type = MTYPE_ACTION; |
| 1303 |
s_controls.moveup.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN; |
| 1304 |
s_controls.moveup.generic.callback = Controls_ActionEvent; |
| 1305 |
s_controls.moveup.generic.ownerdraw = Controls_DrawKeyBinding; |
| 1306 |
s_controls.moveup.generic.id = ID_MOVEUP; |
| 1307 |
|
| 1308 |
s_controls.movedown.generic.type = MTYPE_ACTION; |
| 1309 |
s_controls.movedown.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN; |
| 1310 |
s_controls.movedown.generic.callback = Controls_ActionEvent; |
| 1311 |
s_controls.movedown.generic.ownerdraw = Controls_DrawKeyBinding; |
| 1312 |
s_controls.movedown.generic.id = ID_MOVEDOWN; |
| 1313 |
|
| 1314 |
s_controls.turnleft.generic.type = MTYPE_ACTION; |
| 1315 |
s_controls.turnleft.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN; |
| 1316 |
s_controls.turnleft.generic.callback = Controls_ActionEvent; |
| 1317 |
s_controls.turnleft.generic.ownerdraw = Controls_DrawKeyBinding; |
| 1318 |
s_controls.turnleft.generic.id = ID_LEFT; |
| 1319 |
|
| 1320 |
s_controls.turnright.generic.type = MTYPE_ACTION; |
| 1321 |
s_controls.turnright.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN; |
| 1322 |
s_controls.turnright.generic.callback = Controls_ActionEvent; |
| 1323 |
s_controls.turnright.generic.ownerdraw = Controls_DrawKeyBinding; |
| 1324 |
s_controls.turnright.generic.id = ID_RIGHT; |
| 1325 |
|
| 1326 |
s_controls.sidestep.generic.type = MTYPE_ACTION; |
| 1327 |
s_controls.sidestep.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN; |
| 1328 |
s_controls.sidestep.generic.callback = Controls_ActionEvent; |
| 1329 |
s_controls.sidestep.generic.ownerdraw = Controls_DrawKeyBinding; |
| 1330 |
s_controls.sidestep.generic.id = ID_STRAFE; |
| 1331 |
|
| 1332 |
s_controls.run.generic.type = MTYPE_ACTION; |
| 1333 |
s_controls.run.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN; |
| 1334 |
s_controls.run.generic.callback = Controls_ActionEvent; |
| 1335 |
s_controls.run.generic.ownerdraw = Controls_DrawKeyBinding; |
| 1336 |
s_controls.run.generic.id = ID_SPEED; |
| 1337 |
|
| 1338 |
s_controls.chainsaw.generic.type = MTYPE_ACTION; |
| 1339 |
s_controls.chainsaw.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN; |
| 1340 |
s_controls.chainsaw.generic.callback = Controls_ActionEvent; |
| 1341 |
s_controls.chainsaw.generic.ownerdraw = Controls_DrawKeyBinding; |
| 1342 |
s_controls.chainsaw.generic.id = ID_WEAPON1; |
| 1343 |
|
| 1344 |
s_controls.machinegun.generic.type = MTYPE_ACTION; |
| 1345 |
s_controls.machinegun.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN; |
| 1346 |
s_controls.machinegun.generic.callback = Controls_ActionEvent; |
| 1347 |
s_controls.machinegun.generic.ownerdraw = Controls_DrawKeyBinding; |
| 1348 |
s_controls.machinegun.generic.id = ID_WEAPON2; |
| 1349 |
|
| 1350 |
s_controls.shotgun.generic.type = MTYPE_ACTION; |
| 1351 |
s_controls.shotgun.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN; |
| 1352 |
s_controls.shotgun.generic.callback = Controls_ActionEvent; |
| 1353 |
s_controls.shotgun.generic.ownerdraw = Controls_DrawKeyBinding; |
| 1354 |
s_controls.shotgun.generic.id = ID_WEAPON3; |
| 1355 |
|
| 1356 |
s_controls.grenadelauncher.generic.type = MTYPE_ACTION; |
| 1357 |
s_controls.grenadelauncher.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN; |
| 1358 |
s_controls.grenadelauncher.generic.callback = Controls_ActionEvent; |
| 1359 |
s_controls.grenadelauncher.generic.ownerdraw = Controls_DrawKeyBinding; |
| 1360 |
s_controls.grenadelauncher.generic.id = ID_WEAPON4; |
| 1361 |
|
| 1362 |
s_controls.rocketlauncher.generic.type = MTYPE_ACTION; |
| 1363 |
s_controls.rocketlauncher.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN; |
| 1364 |
s_controls.rocketlauncher.generic.callback = Controls_ActionEvent; |
| 1365 |
s_controls.rocketlauncher.generic.ownerdraw = Controls_DrawKeyBinding; |
| 1366 |
s_controls.rocketlauncher.generic.id = ID_WEAPON5; |
| 1367 |
|
| 1368 |
s_controls.lightning.generic.type = MTYPE_ACTION; |
| 1369 |
s_controls.lightning.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN; |
| 1370 |
s_controls.lightning.generic.callback = Controls_ActionEvent; |
| 1371 |
s_controls.lightning.generic.ownerdraw = Controls_DrawKeyBinding; |
| 1372 |
s_controls.lightning.generic.id = ID_WEAPON6; |
| 1373 |
|
| 1374 |
s_controls.railgun.generic.type = MTYPE_ACTION; |
| 1375 |
s_controls.railgun.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN; |
| 1376 |
s_controls.railgun.generic.callback = Controls_ActionEvent; |
| 1377 |
s_controls.railgun.generic.ownerdraw = Controls_DrawKeyBinding; |
| 1378 |
s_controls.railgun.generic.id = ID_WEAPON7; |
| 1379 |
|
| 1380 |
s_controls.plasma.generic.type = MTYPE_ACTION; |
| 1381 |
s_controls.plasma.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN; |
| 1382 |
s_controls.plasma.generic.callback = Controls_ActionEvent; |
| 1383 |
s_controls.plasma.generic.ownerdraw = Controls_DrawKeyBinding; |
| 1384 |
s_controls.plasma.generic.id = ID_WEAPON8; |
| 1385 |
|
| 1386 |
s_controls.bfg.generic.type = MTYPE_ACTION; |
| 1387 |
s_controls.bfg.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN; |
| 1388 |
s_controls.bfg.generic.callback = Controls_ActionEvent; |
| 1389 |
s_controls.bfg.generic.ownerdraw = Controls_DrawKeyBinding; |
| 1390 |
s_controls.bfg.generic.id = ID_WEAPON9; |
| 1391 |
|
| 1392 |
s_controls.attack.generic.type = MTYPE_ACTION; |
| 1393 |
s_controls.attack.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN; |
| 1394 |
s_controls.attack.generic.callback = Controls_ActionEvent; |
| 1395 |
s_controls.attack.generic.ownerdraw = Controls_DrawKeyBinding; |
| 1396 |
s_controls.attack.generic.id = ID_ATTACK; |
| 1397 |
|
| 1398 |
s_controls.prevweapon.generic.type = MTYPE_ACTION; |
| 1399 |
s_controls.prevweapon.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN; |
| 1400 |
s_controls.prevweapon.generic.callback = Controls_ActionEvent; |
| 1401 |
s_controls.prevweapon.generic.ownerdraw = Controls_DrawKeyBinding; |
| 1402 |
s_controls.prevweapon.generic.id = ID_WEAPPREV; |
| 1403 |
|
| 1404 |
s_controls.nextweapon.generic.type = MTYPE_ACTION; |
| 1405 |
s_controls.nextweapon.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN; |
| 1406 |
s_controls.nextweapon.generic.callback = Controls_ActionEvent; |
| 1407 |
s_controls.nextweapon.generic.ownerdraw = Controls_DrawKeyBinding; |
| 1408 |
s_controls.nextweapon.generic.id = ID_WEAPNEXT; |
| 1409 |
|
| 1410 |
s_controls.lookup.generic.type = MTYPE_ACTION; |
| 1411 |
s_controls.lookup.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN; |
| 1412 |
s_controls.lookup.generic.callback = Controls_ActionEvent; |
| 1413 |
s_controls.lookup.generic.ownerdraw = Controls_DrawKeyBinding; |
| 1414 |
s_controls.lookup.generic.id = ID_LOOKUP; |
| 1415 |
|
| 1416 |
s_controls.lookdown.generic.type = MTYPE_ACTION; |
| 1417 |
s_controls.lookdown.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN; |
| 1418 |
s_controls.lookdown.generic.callback = Controls_ActionEvent; |
| 1419 |
s_controls.lookdown.generic.ownerdraw = Controls_DrawKeyBinding; |
| 1420 |
s_controls.lookdown.generic.id = ID_LOOKDOWN; |
| 1421 |
|
| 1422 |
s_controls.mouselook.generic.type = MTYPE_ACTION; |
| 1423 |
s_controls.mouselook.generic.flags = QMF_LEFT_JUSTIFY|QMF_HIGHLIGHT_IF_FOCUS|QMF_GRAYED|QMF_HIDDEN; |
| 1424 |
s_controls.mouselook.generic.callback = Controls_ActionEvent; |
| 1425 |
s_controls.mouselook.generic.ownerdraw = Controls_DrawKeyBinding; |
| 1426 |
s_controls.mouselook.generic.id = ID_MOUSELOOK; |
| 1427 |
|
| 1428 |
s_controls.freelook.generic.type = MTYPE_RADIOBUTTON; |
| 1429 |
s_controls.freelook.generic.flags = QMF_SMALLFONT; |
| 1430 |
s_controls.freelook.generic.x = SCREEN_WIDTH/2; |
| 1431 |
s_controls.freelook.generic.name = "free look"; |
| 1432 |
s_controls.freelook.generic.id = ID_FREELOOK; |
| 1433 |
s_controls.freelook.generic.callback = Controls_MenuEvent; |
| 1434 |
s_controls.freelook.generic.statusbar = Controls_StatusBar; |
| 1435 |
|
| 1436 |
s_controls.centerview.generic.type = MTYPE_ACTION; |
| 1437 |
s_controls.centerview.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN; |
| 1438 |
s_controls.centerview.generic.callback = Controls_ActionEvent; |
| 1439 |
s_controls.centerview.generic.ownerdraw = Controls_DrawKeyBinding; |
| 1440 |
s_controls.centerview.generic.id = ID_CENTERVIEW; |
| 1441 |
|
| 1442 |
s_controls.zoomview.generic.type = MTYPE_ACTION; |
| 1443 |
s_controls.zoomview.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN; |
| 1444 |
s_controls.zoomview.generic.callback = Controls_ActionEvent; |
| 1445 |
s_controls.zoomview.generic.ownerdraw = Controls_DrawKeyBinding; |
| 1446 |
s_controls.zoomview.generic.id = ID_ZOOMVIEW; |
| 1447 |
|
| 1448 |
s_controls.useitem.generic.type = MTYPE_ACTION; |
| 1449 |
s_controls.useitem.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN; |
| 1450 |
s_controls.useitem.generic.callback = Controls_ActionEvent; |
| 1451 |
s_controls.useitem.generic.ownerdraw = Controls_DrawKeyBinding; |
| 1452 |
s_controls.useitem.generic.id = ID_USEITEM; |
| 1453 |
|
| 1454 |
s_controls.showscores.generic.type = MTYPE_ACTION; |
| 1455 |
s_controls.showscores.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN; |
| 1456 |
s_controls.showscores.generic.callback = Controls_ActionEvent; |
| 1457 |
s_controls.showscores.generic.ownerdraw = Controls_DrawKeyBinding; |
| 1458 |
s_controls.showscores.generic.id = ID_SHOWSCORES; |
| 1459 |
|
| 1460 |
s_controls.invertmouse.generic.type = MTYPE_RADIOBUTTON; |
| 1461 |
s_controls.invertmouse.generic.flags = QMF_SMALLFONT; |
| 1462 |
s_controls.invertmouse.generic.x = SCREEN_WIDTH/2; |
| 1463 |
s_controls.invertmouse.generic.name = "invert mouse"; |
| 1464 |
s_controls.invertmouse.generic.id = ID_INVERTMOUSE; |
| 1465 |
s_controls.invertmouse.generic.callback = Controls_MenuEvent; |
| 1466 |
s_controls.invertmouse.generic.statusbar = Controls_StatusBar; |
| 1467 |
|
| 1468 |
s_controls.smoothmouse.generic.type = MTYPE_RADIOBUTTON; |
| 1469 |
s_controls.smoothmouse.generic.flags = QMF_SMALLFONT; |
| 1470 |
s_controls.smoothmouse.generic.x = SCREEN_WIDTH/2; |
| 1471 |
s_controls.smoothmouse.generic.name = "smooth mouse"; |
| 1472 |
s_controls.smoothmouse.generic.id = ID_SMOOTHMOUSE; |
| 1473 |
s_controls.smoothmouse.generic.callback = Controls_MenuEvent; |
| 1474 |
s_controls.smoothmouse.generic.statusbar = Controls_StatusBar; |
| 1475 |
|
| 1476 |
s_controls.alwaysrun.generic.type = MTYPE_RADIOBUTTON; |
| 1477 |
s_controls.alwaysrun.generic.flags = QMF_SMALLFONT; |
| 1478 |
s_controls.alwaysrun.generic.x = SCREEN_WIDTH/2; |
| 1479 |
s_controls.alwaysrun.generic.name = "always run"; |
| 1480 |
s_controls.alwaysrun.generic.id = ID_ALWAYSRUN; |
| 1481 |
s_controls.alwaysrun.generic.callback = Controls_MenuEvent; |
| 1482 |
s_controls.alwaysrun.generic.statusbar = Controls_StatusBar; |
| 1483 |
|
| 1484 |
s_controls.autoswitch.generic.type = MTYPE_RADIOBUTTON; |
| 1485 |
s_controls.autoswitch.generic.flags = QMF_SMALLFONT; |
| 1486 |
s_controls.autoswitch.generic.x = SCREEN_WIDTH/2; |
| 1487 |
s_controls.autoswitch.generic.name = "autoswitch weapons"; |
| 1488 |
s_controls.autoswitch.generic.id = ID_AUTOSWITCH; |
| 1489 |
s_controls.autoswitch.generic.callback = Controls_MenuEvent; |
| 1490 |
s_controls.autoswitch.generic.statusbar = Controls_StatusBar; |
| 1491 |
|
| 1492 |
s_controls.sensitivity.generic.type = MTYPE_SLIDER; |
| 1493 |
s_controls.sensitivity.generic.x = SCREEN_WIDTH/2; |
| 1494 |
s_controls.sensitivity.generic.flags = QMF_SMALLFONT; |
| 1495 |
s_controls.sensitivity.generic.name = "mouse speed"; |
| 1496 |
s_controls.sensitivity.generic.id = ID_MOUSESPEED; |
| 1497 |
s_controls.sensitivity.generic.callback = Controls_MenuEvent; |
| 1498 |
s_controls.sensitivity.minvalue = 2; |
| 1499 |
s_controls.sensitivity.maxvalue = 30; |
| 1500 |
s_controls.sensitivity.generic.statusbar = Controls_StatusBar; |
| 1501 |
|
| 1502 |
s_controls.gesture.generic.type = MTYPE_ACTION; |
| 1503 |
s_controls.gesture.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN; |
| 1504 |
s_controls.gesture.generic.callback = Controls_ActionEvent; |
| 1505 |
s_controls.gesture.generic.ownerdraw = Controls_DrawKeyBinding; |
| 1506 |
s_controls.gesture.generic.id = ID_GESTURE; |
| 1507 |
|
| 1508 |
s_controls.chat.generic.type = MTYPE_ACTION; |
| 1509 |
s_controls.chat.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN; |
| 1510 |
s_controls.chat.generic.callback = Controls_ActionEvent; |
| 1511 |
s_controls.chat.generic.ownerdraw = Controls_DrawKeyBinding; |
| 1512 |
s_controls.chat.generic.id = ID_CHAT; |
| 1513 |
|
| 1514 |
s_controls.chat2.generic.type = MTYPE_ACTION; |
| 1515 |
s_controls.chat2.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN; |
| 1516 |
s_controls.chat2.generic.callback = Controls_ActionEvent; |
| 1517 |
s_controls.chat2.generic.ownerdraw = Controls_DrawKeyBinding; |
| 1518 |
s_controls.chat2.generic.id = ID_CHAT2; |
| 1519 |
|
| 1520 |
s_controls.chat3.generic.type = MTYPE_ACTION; |
| 1521 |
s_controls.chat3.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN; |
| 1522 |
s_controls.chat3.generic.callback = Controls_ActionEvent; |
| 1523 |
s_controls.chat3.generic.ownerdraw = Controls_DrawKeyBinding; |
| 1524 |
s_controls.chat3.generic.id = ID_CHAT3; |
| 1525 |
|
| 1526 |
s_controls.chat4.generic.type = MTYPE_ACTION; |
| 1527 |
s_controls.chat4.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN; |
| 1528 |
s_controls.chat4.generic.callback = Controls_ActionEvent; |
| 1529 |
s_controls.chat4.generic.ownerdraw = Controls_DrawKeyBinding; |
| 1530 |
s_controls.chat4.generic.id = ID_CHAT4; |
| 1531 |
|
| 1532 |
s_controls.togglemenu.generic.type = MTYPE_ACTION; |
| 1533 |
s_controls.togglemenu.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN; |
| 1534 |
s_controls.togglemenu.generic.callback = Controls_ActionEvent; |
| 1535 |
s_controls.togglemenu.generic.ownerdraw = Controls_DrawKeyBinding; |
| 1536 |
s_controls.togglemenu.generic.id = ID_TOGGLEMENU; |
| 1537 |
|
| 1538 |
s_controls.joyenable.generic.type = MTYPE_RADIOBUTTON; |
| 1539 |
s_controls.joyenable.generic.flags = QMF_SMALLFONT; |
| 1540 |
s_controls.joyenable.generic.x = SCREEN_WIDTH/2; |
| 1541 |
s_controls.joyenable.generic.name = "joystick"; |
| 1542 |
s_controls.joyenable.generic.id = ID_JOYENABLE; |
| 1543 |
s_controls.joyenable.generic.callback = Controls_MenuEvent; |
| 1544 |
s_controls.joyenable.generic.statusbar = Controls_StatusBar; |
| 1545 |
|
| 1546 |
s_controls.joythreshold.generic.type = MTYPE_SLIDER; |
| 1547 |
s_controls.joythreshold.generic.x = SCREEN_WIDTH/2; |
| 1548 |
s_controls.joythreshold.generic.flags = QMF_SMALLFONT; |
| 1549 |
s_controls.joythreshold.generic.name = "joystick threshold"; |
| 1550 |
s_controls.joythreshold.generic.id = ID_JOYTHRESHOLD; |
| 1551 |
s_controls.joythreshold.generic.callback = Controls_MenuEvent; |
| 1552 |
s_controls.joythreshold.minvalue = 0.05f; |
| 1553 |
s_controls.joythreshold.maxvalue = 0.75f; |
| 1554 |
s_controls.joythreshold.generic.statusbar = Controls_StatusBar; |
| 1555 |
|
| 1556 |
s_controls.name.generic.type = MTYPE_PTEXT; |
| 1557 |
s_controls.name.generic.flags = QMF_CENTER_JUSTIFY|QMF_INACTIVE; |
| 1558 |
s_controls.name.generic.x = 320; |
| 1559 |
s_controls.name.generic.y = 440; |
| 1560 |
s_controls.name.string = playername; |
| 1561 |
s_controls.name.style = UI_CENTER; |
| 1562 |
s_controls.name.color = text_color_normal; |
| 1563 |
|
| 1564 |
Menu_AddItem( &s_controls.menu, &s_controls.banner ); |
| 1565 |
Menu_AddItem( &s_controls.menu, &s_controls.framel ); |
| 1566 |
Menu_AddItem( &s_controls.menu, &s_controls.framer ); |
| 1567 |
Menu_AddItem( &s_controls.menu, &s_controls.player ); |
| 1568 |
Menu_AddItem( &s_controls.menu, &s_controls.name ); |
| 1569 |
|
| 1570 |
Menu_AddItem( &s_controls.menu, &s_controls.looking ); |
| 1571 |
Menu_AddItem( &s_controls.menu, &s_controls.movement ); |
| 1572 |
Menu_AddItem( &s_controls.menu, &s_controls.weapons ); |
| 1573 |
Menu_AddItem( &s_controls.menu, &s_controls.misc ); |
| 1574 |
|
| 1575 |
Menu_AddItem( &s_controls.menu, &s_controls.sensitivity ); |
| 1576 |
Menu_AddItem( &s_controls.menu, &s_controls.smoothmouse ); |
| 1577 |
Menu_AddItem( &s_controls.menu, &s_controls.invertmouse ); |
| 1578 |
Menu_AddItem( &s_controls.menu, &s_controls.lookup ); |
| 1579 |
Menu_AddItem( &s_controls.menu, &s_controls.lookdown ); |
| 1580 |
Menu_AddItem( &s_controls.menu, &s_controls.mouselook ); |
| 1581 |
Menu_AddItem( &s_controls.menu, &s_controls.freelook ); |
| 1582 |
Menu_AddItem( &s_controls.menu, &s_controls.centerview ); |
| 1583 |
Menu_AddItem( &s_controls.menu, &s_controls.zoomview ); |
| 1584 |
Menu_AddItem( &s_controls.menu, &s_controls.joyenable ); |
| 1585 |
Menu_AddItem( &s_controls.menu, &s_controls.joythreshold ); |
| 1586 |
|
| 1587 |
Menu_AddItem( &s_controls.menu, &s_controls.alwaysrun ); |
| 1588 |
Menu_AddItem( &s_controls.menu, &s_controls.run ); |
| 1589 |
Menu_AddItem( &s_controls.menu, &s_controls.walkforward ); |
| 1590 |
Menu_AddItem( &s_controls.menu, &s_controls.backpedal ); |
| 1591 |
Menu_AddItem( &s_controls.menu, &s_controls.stepleft ); |
| 1592 |
Menu_AddItem( &s_controls.menu, &s_controls.stepright ); |
| 1593 |
Menu_AddItem( &s_controls.menu, &s_controls.moveup ); |
| 1594 |
Menu_AddItem( &s_controls.menu, &s_controls.movedown ); |
| 1595 |
Menu_AddItem( &s_controls.menu, &s_controls.turnleft ); |
| 1596 |
Menu_AddItem( &s_controls.menu, &s_controls.turnright ); |
| 1597 |
Menu_AddItem( &s_controls.menu, &s_controls.sidestep ); |
| 1598 |
|
| 1599 |
Menu_AddItem( &s_controls.menu, &s_controls.attack ); |
| 1600 |
Menu_AddItem( &s_controls.menu, &s_controls.nextweapon ); |
| 1601 |
Menu_AddItem( &s_controls.menu, &s_controls.prevweapon ); |
| 1602 |
Menu_AddItem( &s_controls.menu, &s_controls.autoswitch ); |
| 1603 |
Menu_AddItem( &s_controls.menu, &s_controls.chainsaw ); |
| 1604 |
Menu_AddItem( &s_controls.menu, &s_controls.machinegun ); |
| 1605 |
Menu_AddItem( &s_controls.menu, &s_controls.shotgun ); |
| 1606 |
Menu_AddItem( &s_controls.menu, &s_controls.grenadelauncher ); |
| 1607 |
Menu_AddItem( &s_controls.menu, &s_controls.rocketlauncher ); |
| 1608 |
Menu_AddItem( &s_controls.menu, &s_controls.lightning ); |
| 1609 |
Menu_AddItem( &s_controls.menu, &s_controls.railgun ); |
| 1610 |
Menu_AddItem( &s_controls.menu, &s_controls.plasma ); |
| 1611 |
Menu_AddItem( &s_controls.menu, &s_controls.bfg ); |
| 1612 |
|
| 1613 |
Menu_AddItem( &s_controls.menu, &s_controls.showscores ); |
| 1614 |
Menu_AddItem( &s_controls.menu, &s_controls.useitem ); |
| 1615 |
Menu_AddItem( &s_controls.menu, &s_controls.gesture ); |
| 1616 |
Menu_AddItem( &s_controls.menu, &s_controls.chat ); |
| 1617 |
Menu_AddItem( &s_controls.menu, &s_controls.chat2 ); |
| 1618 |
Menu_AddItem( &s_controls.menu, &s_controls.chat3 ); |
| 1619 |
Menu_AddItem( &s_controls.menu, &s_controls.chat4 ); |
| 1620 |
Menu_AddItem( &s_controls.menu, &s_controls.togglemenu ); |
| 1621 |
|
| 1622 |
Menu_AddItem( &s_controls.menu, &s_controls.back ); |
| 1623 |
|
| 1624 |
trap_Cvar_VariableStringBuffer( "name", s_controls.name.string, 16 ); |
| 1625 |
Q_CleanStr( s_controls.name.string ); |
| 1626 |
|
| 1627 |
|
| 1628 |
Controls_InitCvars(); |
| 1629 |
|
| 1630 |
|
| 1631 |
Controls_GetConfig(); |
| 1632 |
|
| 1633 |
|
| 1634 |
Controls_InitModel(); |
| 1635 |
|
| 1636 |
|
| 1637 |
Controls_InitWeapons (); |
| 1638 |
|
| 1639 |
|
| 1640 |
s_controls.section = C_LOOKING; |
| 1641 |
|
| 1642 |
|
| 1643 |
Controls_Update(); |
| 1644 |
} |
| 1645 |
|
| 1646 |
|
| 1647 |
|
| 1648 |
|
| 1649 |
|
| 1650 |
|
| 1651 |
|
| 1652 |
void Controls_Cache( void ) { |
| 1653 |
trap_R_RegisterShaderNoMip( ART_BACK0 ); |
| 1654 |
trap_R_RegisterShaderNoMip( ART_BACK1 ); |
| 1655 |
trap_R_RegisterShaderNoMip( ART_FRAMEL ); |
| 1656 |
trap_R_RegisterShaderNoMip( ART_FRAMER ); |
| 1657 |
} |
| 1658 |
|
| 1659 |
|
| 1660 |
|
| 1661 |
|
| 1662 |
|
| 1663 |
|
| 1664 |
|
| 1665 |
void UI_ControlsMenu( void ) { |
| 1666 |
Controls_MenuInit(); |
| 1667 |
UI_PushMenu( &s_controls.menu ); |
| 1668 |
} |