From 7666c2f54ccc313ec1fc92aef76adb99594fdd1d Mon Sep 17 00:00:00 2001 From: Thilo Schulz Date: Thu, 7 Jul 2011 16:12:53 +0000 Subject: [PATCH] Add fixes to ui menu by Ensiform and DevHC (#5062) --- code/q3_ui/ui_local.h | 3 +++ code/q3_ui/ui_players.c | 39 +++++++++++++++++++++++++++++++++++++ code/q3_ui/ui_preferences.c | 7 ++----- code/q3_ui/ui_qmenu.c | 24 ++++++----------------- 4 files changed, 50 insertions(+), 23 deletions(-) diff --git a/code/q3_ui/ui_local.h b/code/q3_ui/ui_local.h index 464298e1..5db3cef0 100644 --- a/code/q3_ui/ui_local.h +++ b/code/q3_ui/ui_local.h @@ -492,6 +492,9 @@ typedef struct { vec3_t flashDlightColor; int muzzleFlashTime; + vec3_t color1; + byte c1RGBA[4]; + // currently in use drawing parms vec3_t viewAngles; vec3_t moveAngles; diff --git a/code/q3_ui/ui_players.c b/code/q3_ui/ui_players.c index 182b5f0d..a21d906d 100644 --- a/code/q3_ui/ui_players.c +++ b/code/q3_ui/ui_players.c @@ -819,6 +819,12 @@ void UI_DrawPlayer( float x, float y, float w, float h, playerInfo_t *pi, int ti if ( pi->currentWeapon != WP_NONE ) { memset( &gun, 0, sizeof(gun) ); gun.hModel = pi->weaponModel; + if( pi->currentWeapon == WP_RAILGUN ) { + Byte4Copy( pi->c1RGBA, gun.shaderRGBA ); + } + else { + Byte4Copy( colorWhite, gun.shaderRGBA ); + } VectorCopy( origin, gun.lightingOrigin ); UI_PositionEntityOnTag( &gun, &torso, pi->torsoModel, "tag_weapon"); gun.renderfx = renderfx; @@ -857,6 +863,12 @@ void UI_DrawPlayer( float x, float y, float w, float h, playerInfo_t *pi, int ti if ( pi->flashModel ) { memset( &flash, 0, sizeof(flash) ); flash.hModel = pi->flashModel; + if( pi->currentWeapon == WP_RAILGUN ) { + Byte4Copy( pi->c1RGBA, flash.shaderRGBA ); + } + else { + Byte4Copy( colorWhite, flash.shaderRGBA ); + } VectorCopy( origin, flash.lightingOrigin ); UI_PositionEntityOnTag( &flash, &gun, pi->weaponModel, "tag_flash"); flash.renderfx = renderfx; @@ -1140,9 +1152,36 @@ UI_PlayerInfo_SetInfo void UI_PlayerInfo_SetInfo( playerInfo_t *pi, int legsAnim, int torsoAnim, vec3_t viewAngles, vec3_t moveAngles, weapon_t weaponNumber, qboolean chat ) { int currentAnim; weapon_t weaponNum; + int c; pi->chat = chat; + c = (int)trap_Cvar_VariableValue( "color1" ); + + VectorClear( pi->color1 ); + + if( c < 1 || c > 7 ) { + VectorSet( pi->color1, 1, 1, 1 ); + } + else { + if( c & 1 ) { + pi->color1[2] = 1.0f; + } + + if( c & 2 ) { + pi->color1[1] = 1.0f; + } + + if( c & 4 ) { + pi->color1[0] = 1.0f; + } + } + + pi->c1RGBA[0] = 255 * pi->color1[0]; + pi->c1RGBA[1] = 255 * pi->color1[1]; + pi->c1RGBA[2] = 255 * pi->color1[2]; + pi->c1RGBA[3] = 255; + // view angles VectorCopy( viewAngles, pi->viewAngles ); diff --git a/code/q3_ui/ui_preferences.c b/code/q3_ui/ui_preferences.c index 693e3f4b..ca0f628f 100644 --- a/code/q3_ui/ui_preferences.c +++ b/code/q3_ui/ui_preferences.c @@ -111,10 +111,6 @@ static void Preferences_Event( void* ptr, int notification ) { switch( ((menucommon_s*)ptr)->id ) { case ID_CROSSHAIR: - s_preferences.crosshair.curvalue++; - if( s_preferences.crosshair.curvalue == NUM_CROSSHAIRS ) { - s_preferences.crosshair.curvalue = 0; - } trap_Cvar_SetValue( "cg_drawCrosshair", s_preferences.crosshair.curvalue ); break; @@ -252,7 +248,7 @@ static void Preferences_MenuInit( void ) { s_preferences.framer.height = 334; y = 144; - s_preferences.crosshair.generic.type = MTYPE_TEXT; + s_preferences.crosshair.generic.type = MTYPE_SPINCONTROL; s_preferences.crosshair.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT|QMF_NODEFAULTINIT|QMF_OWNERDRAW; s_preferences.crosshair.generic.x = PREFERENCES_X_POS; s_preferences.crosshair.generic.y = y; @@ -264,6 +260,7 @@ static void Preferences_MenuInit( void ) { s_preferences.crosshair.generic.bottom = y + 20; s_preferences.crosshair.generic.left = PREFERENCES_X_POS - ( ( strlen(s_preferences.crosshair.generic.name) + 1 ) * SMALLCHAR_WIDTH ); s_preferences.crosshair.generic.right = PREFERENCES_X_POS + 48; + s_preferences.crosshair.numitems = NUM_CROSSHAIRS; y += BIGCHAR_HEIGHT+2+4; s_preferences.simpleitems.generic.type = MTYPE_RADIOBUTTON; diff --git a/code/q3_ui/ui_qmenu.c b/code/q3_ui/ui_qmenu.c index e955c51c..330b6d2b 100644 --- a/code/q3_ui/ui_qmenu.c +++ b/code/q3_ui/ui_qmenu.c @@ -798,6 +798,8 @@ static sfxHandle_t SpinControl_Key( menulist_s *s, int key ) sound = 0; switch (key) { + case K_KP_RIGHTARROW: + case K_RIGHTARROW: case K_MOUSE1: s->curvalue++; if (s->curvalue >= s->numitems) @@ -807,24 +809,10 @@ static sfxHandle_t SpinControl_Key( menulist_s *s, int key ) case K_KP_LEFTARROW: case K_LEFTARROW: - if (s->curvalue > 0) - { - s->curvalue--; - sound = menu_move_sound; - } - else - sound = menu_buzz_sound; - break; - - case K_KP_RIGHTARROW: - case K_RIGHTARROW: - if (s->curvalue < s->numitems-1) - { - s->curvalue++; - sound = menu_move_sound; - } - else - sound = menu_buzz_sound; + s->curvalue--; + if (s->curvalue < 0) + s->curvalue = s->numitems-1; + sound = menu_move_sound; break; }