summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Angus <tim@ngus.net>2002-04-05 23:56:11 +0000
committerTim Angus <tim@ngus.net>2002-04-05 23:56:11 +0000
commit0f4a33d3db91faaa7194ec4b25a570bf02e976e0 (patch)
treec38658ac309224844b5f1309024417f0e810ead8
parent19e91b98123bc08aadb9c6842e820b820b593872 (diff)
Ownerdrawn weapon selection
-rw-r--r--src/cgame/cg_draw.c11
-rw-r--r--src/cgame/cg_local.h4
-rw-r--r--src/cgame/cg_weapons.c190
-rw-r--r--src/game/bg_misc.c10
-rw-r--r--ui/menudef.h2
5 files changed, 138 insertions, 79 deletions
diff --git a/src/cgame/cg_draw.c b/src/cgame/cg_draw.c
index bd497cc5..5b512a0e 100644
--- a/src/cgame/cg_draw.c
+++ b/src/cgame/cg_draw.c
@@ -18,8 +18,6 @@
#include "cg_local.h"
-#include "../ui/ui_shared.h"
-
// used for scoreboard
extern displayContextDef_t cgDC;
menuDef_t *menuScoreboard = NULL;
@@ -638,6 +636,12 @@ void CG_OwnerDraw( float x, float y, float w, float h, float text_x,
case CG_KILLER:
CG_DrawKiller( &rect, scale, color, shader, textStyle );
break;
+ case CG_PLAYER_SELECT:
+ CG_DrawWeaponSelect( &rect );
+ break;
+ case CG_PLAYER_SELECTTEXT:
+ CG_DrawWeaponSelectText( &rect, scale, textStyle );
+ break;
default:
break;
}
@@ -2075,8 +2079,6 @@ static void CG_Draw2D( void )
{
if( cg_drawStatus.integer )
{
- /*Menu_PaintAll();*/
- /*CG_DrawTimedMenus();*/
Menu_Paint(
Menus_FindByName(
BG_FindHudNameForClass( cg.predictedPlayerState.stats[ STAT_PCLASS ] ) ), qtrue );
@@ -2084,7 +2086,6 @@ static void CG_Draw2D( void )
CG_DrawAmmoWarning();
CG_DrawCrosshair();
- CG_DrawWeaponSelect();
if( BG_gotItem( UP_HELMET, cg.snap->ps.stats ) )
CG_Scanner( );
diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h
index c5bfc6bd..bcde7efe 100644
--- a/src/cgame/cg_local.h
+++ b/src/cgame/cg_local.h
@@ -18,6 +18,7 @@
#include "tr_types.h"
#include "../game/bg_public.h"
#include "cg_public.h"
+#include "../ui/ui_shared.h"
// The entire cgame module is unloaded and reloaded on each level change,
// so there is NO persistant data between levels on the client side.
@@ -1449,7 +1450,8 @@ void CG_TeslaTrail( vec3_t start, vec3_t end );
void CG_GrappleTrail( centity_t *ent, const weaponInfo_t *wi );
void CG_AddViewWeapon (playerState_t *ps);
void CG_AddPlayerWeapon( refEntity_t *parent, playerState_t *ps, centity_t *cent );
-void CG_DrawWeaponSelect( void );
+void CG_DrawWeaponSelect( rectDef_t *rect );
+void CG_DrawWeaponSelectText( rectDef_t *rect, float scale, int textStyle );
void CG_OutOfAmmoChange( void ); // should this be in pmove?
diff --git a/src/cgame/cg_weapons.c b/src/cgame/cg_weapons.c
index 21527d52..b67267db 100644
--- a/src/cgame/cg_weapons.c
+++ b/src/cgame/cg_weapons.c
@@ -1389,107 +1389,162 @@ WEAPON SELECTION
==============================================================================
*/
+qboolean haveWeapon( int *weapons, int num, int weapon )
+{
+ int i;
+
+ for( i = 0; i < num; i++ )
+ {
+ if( weapons[ i ] == weapon )
+ return qtrue;
+ }
+
+ return qfalse;
+}
+
+qboolean haveUpgrade( int *upgrades, int num, int upgrade )
+{
+ int i;
+
+ for( i = 0; i < num; i++ )
+ {
+ if( upgrades[ i ] == upgrade )
+ return qtrue;
+ }
+
+ return qfalse;
+}
+
+#define ICON_BORDER 4
+
/*
===================
CG_DrawWeaponSelect
-
===================
*/
-void CG_DrawWeaponSelect( void ) {
- int i;
- //int count;
- int x, y, w;
- char *name;
- float *color;
- int ammo, clips, maxclips;
+void CG_DrawWeaponSelect( rectDef_t *rect )
+{
+ int i;
+ int x = rect->x;
+ int y = rect->y;
+ int width = rect->w;
+ int height = rect->h;
+ int iconsize;
+ int items[ 64 ];
+ int numItems = 0, selectedItem;
+ int length;
+ int selectWindow;
+ qboolean vertical;
// don't display if dead
- if ( cg.predictedPlayerState.stats[STAT_HEALTH] <= 0 ) {
+ if( cg.predictedPlayerState.stats[STAT_HEALTH] <= 0 )
return;
- }
-
- color = CG_FadeColor( cg.weaponSelectTime, WEAPON_SELECT_TIME );
- if ( !color ) {
- return;
- }
- trap_R_SetColor( color );
// showing weapon select clears pickup item display, but not the blend blob
cg.itemPickupTime = 0;
- /*// count the number of weapons owned
- count = 0;
- for ( i = WP_GAUNTLET; i < WP_NUM_WEAPONS; i++ ) {
- if ( BG_gotWeapon( i, cg.snap->ps.stats ) ) {
- count++;
- }
- }*/
+ if( height > width )
+ {
+ vertical = qtrue;
+ iconsize = width;
+ length = height / width;
+ }
+ else if( height <= width )
+ {
+ vertical = qfalse;
+ iconsize = height;
+ length = width / height;
+ }
- //x = 320 - count * 20;
- //y = 380;
-
- x = 10;
- y = 10;
-
- for ( i = WP_NONE + 1; i < WP_NUM_WEAPONS; i++ ) {
+ selectWindow = length / 2;
+
+ for( i = WP_NONE + 1; i < WP_NUM_WEAPONS; i++ )
+ {
if( !BG_gotWeapon( i, cg.snap->ps.stats ) )
continue;
- CG_RegisterWeapon( i );
-
- // draw weapon icon
- CG_DrawPic( x, y, 16, 16, cg_weapons[i].weaponIcon );
-
- // draw selection marker
- if ( i == cg.weaponSelect ) {
- CG_DrawPic( x-2, y-2, 20, 20, cgs.media.selectShader );
- }
-
- BG_unpackAmmoArray( i, cg.snap->ps.ammo, cg.snap->ps.powerups, &ammo, &clips, &maxclips );
+ if( i == cg.weaponSelect )
+ selectedItem = numItems;
- // no ammo cross on top
- if ( !ammo && !clips && !BG_FindInfinteAmmoForWeapon( i ) ) {
- CG_DrawPic( x, y, 16, 16, cgs.media.noammoShader );
- }
-
- y += 20;
+ CG_RegisterWeapon( i );
+ items[ numItems ] = i;
+ numItems++;
}
-
- for ( i = UP_TORCH; i < UP_NUM_UPGRADES; i++ ) {
+
+ for( i = UP_NONE + 1; i < UP_NUM_UPGRADES; i++ )
+ {
if( !BG_gotItem( i, cg.snap->ps.stats ) )
continue;
+
+ if( i == cg.weaponSelect - 32 )
+ selectedItem = numItems;
CG_RegisterUpgrade( i );
+ items[ numItems ] = i + 32;
+ numItems++;
+ }
- // draw weapon icon
- CG_DrawPic( x, y, 16, 16, cg_upgrades[i].upgradeIcon );
-
- // draw selection marker
- if ( i == ( cg.weaponSelect - 32 ) ) {
- CG_DrawPic( x-2, y-2, 20, 20, cgs.media.selectShader );
+ for( i = 0; i < length; i++ )
+ {
+ int displacement = i - selectWindow;
+ int item = displacement + selectedItem;
+
+ if( ( item >= 0 ) && ( item < numItems ) )
+ {
+ if( items[ item ] <= 32 )
+ CG_DrawPic( x + ICON_BORDER, y + ICON_BORDER, iconsize - 2 * ICON_BORDER, iconsize - 2 * ICON_BORDER,
+ cg_weapons[ items[ item ] ].weaponIcon );
+ else if( items[ item ] > 32 )
+ CG_DrawPic( x + ICON_BORDER, y + ICON_BORDER, iconsize - 2 * ICON_BORDER, iconsize - 2 * ICON_BORDER,
+ cg_upgrades[ items[ item ] - 32 ].upgradeIcon );
+
+ if( displacement == 0 )
+ CG_DrawPic( x, y, iconsize, iconsize, cgs.media.selectShader );
}
- y += 20;
+ if( vertical )
+ y += iconsize;
+ else
+ x += iconsize;
}
- //TA: yuck! :)
+ /*//TA: yuck! :)
if( y == 10 )
{
trap_R_SetColor( NULL );
return;
- }
+ }*/
+
+}
+
+/*
+===================
+CG_DrawWeaponSelectText
+===================
+*/
+void CG_DrawWeaponSelectText( rectDef_t *rect, float scale, int textStyle )
+{
+ int x, w;
+ char *name;
+ float *color;
+
+ color = CG_FadeColor( cg.weaponSelectTime, WEAPON_SELECT_TIME );
+ if( !color )
+ return;
+
+ trap_R_SetColor( color );
+
// draw the selected name
if( cg.weaponSelect <= 32 )
{
if( cg_weapons[ cg.weaponSelect ].registered )
{
- name = cg_weapons[ cg.weaponSelect ].humanName;
- if ( name )
+ if( name = cg_weapons[ cg.weaponSelect ].humanName )
{
- w = CG_DrawStrlen( name ) * BIGCHAR_WIDTH;
- x = ( SCREEN_WIDTH - w ) / 2;
- CG_DrawBigStringColor(x, y - 22, name, color);
+ w = CG_Text_Width( name, scale, 0 );
+ x = rect->x + rect->w / 2;
+ CG_Text_Paint( x - w / 2, rect->y + rect->h, scale, color, name, 0, 0, textStyle );
}
}
}
@@ -1497,12 +1552,11 @@ void CG_DrawWeaponSelect( void ) {
{
if( cg_upgrades[ cg.weaponSelect - 32 ].registered )
{
- name = cg_upgrades[ cg.weaponSelect - 32 ].humanName;
- if ( name )
+ if( name = cg_upgrades[ cg.weaponSelect - 32 ].humanName )
{
- w = CG_DrawStrlen( name ) * BIGCHAR_WIDTH;
- x = ( SCREEN_WIDTH - w ) / 2;
- CG_DrawBigStringColor(x, y - 22, name, color);
+ w = CG_Text_Width( name, scale, 0 );
+ x = rect->x + rect->w / 2;
+ CG_Text_Paint( x - w / 2, rect->y + rect->h, scale, color, name, 0, 0, textStyle );
}
}
}
diff --git a/src/game/bg_misc.c b/src/game/bg_misc.c
index c9249823..c6241fbd 100644
--- a/src/game/bg_misc.c
+++ b/src/game/bg_misc.c
@@ -2736,7 +2736,7 @@ upgradeAttributes_t bg_upgrades[ ] =
SLOT_NONE, //int slots;
"torch", //char *upgradeName;
"Torch", //char *upgradeHumanName;
- "icons/iconw_gauntlet",
+ "icons/iconw_machinegun",
WP_NONE, //weapon_t weaponAmmo;
0, //int ammo;
0, //int clips;
@@ -2749,7 +2749,7 @@ upgradeAttributes_t bg_upgrades[ ] =
SLOT_HEAD, //int slots;
"nvg", //char *upgradeName;
"NVG", //char *upgradeHumanName;
- "icons/iconw_gauntlet",
+ "icons/iconw_plasma",
WP_NONE, //weapon_t weaponAmmo;
0, //int ammo;
0, //int clips;
@@ -2762,7 +2762,7 @@ upgradeAttributes_t bg_upgrades[ ] =
SLOT_TORSO, //int slots;
"carmour", //char *upgradeName;
"Chest Armour", //char *upgradeHumanName;
- "icons/iconw_gauntlet",
+ "icons/iconw_bfg",
WP_NONE, //weapon_t weaponAmmo;
0, //int ammo;
0, //int clips;
@@ -2775,7 +2775,7 @@ upgradeAttributes_t bg_upgrades[ ] =
SLOT_ARMS|SLOT_LEGS, //int slots;
"larmour", //char *upgradeName;
"Limb Armour", //char *upgradeHumanName;
- "icons/iconw_gauntlet",
+ "icons/iconw_plasma",
WP_NONE, //weapon_t weaponAmmo;
0, //int ammo;
0, //int clips;
@@ -2801,7 +2801,7 @@ upgradeAttributes_t bg_upgrades[ ] =
SLOT_NONE, //int slots;
"atoxin", //char *upgradeName;
"Anti-toxin", //char *upgradeHumanName;
- "icons/iconw_gauntlet",
+ "icons/iconw_machinegun",
WP_NONE, //weapon_t weaponAmmo;
0, //int ammo;
0, //int clips;
diff --git a/ui/menudef.h b/ui/menudef.h
index 1d76d598..b4c77b8f 100644
--- a/ui/menudef.h
+++ b/ui/menudef.h
@@ -134,6 +134,8 @@
#define CG_PLAYER_CREDITS_VALUE 71
#define CG_PLAYER_BANK_VALUE 72
#define CG_PLAYER_STAMINA 73
+#define CG_PLAYER_SELECT 74
+#define CG_PLAYER_SELECTTEXT 75
#define CG_SELECTEDPLAYER_HEAD 7
#define CG_SELECTEDPLAYER_NAME 8
#define CG_SELECTEDPLAYER_LOCATION 9