forked from a1batross/Paranoia2_original
155 lines
3.6 KiB
C++
155 lines
3.6 KiB
C++
/***
|
|
*
|
|
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
|
*
|
|
* This product contains software technology licensed from Id
|
|
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
|
* All Rights Reserved.
|
|
*
|
|
* Use, distribution, and modification of this source code and/or resulting
|
|
* object code is restricted to non-commercial enhancements to products from
|
|
* Valve LLC. All other use, distribution, or modification is prohibited
|
|
* without written permission from Valve LLC.
|
|
*
|
|
****/
|
|
//
|
|
// ammohistory.h
|
|
//
|
|
|
|
// this is the max number of items in each bucket
|
|
#define MAX_WEAPON_POSITIONS MAX_WEAPON_SLOTS
|
|
extern WEAPON *gpActiveSel;
|
|
|
|
class WeaponsResource
|
|
{
|
|
public: // buz: made public to access from drawing code (valves idea about WR is suxx)
|
|
// Information about weapons & ammo
|
|
WEAPON rgWeapons[MAX_WEAPONS]; // Weapons Array
|
|
|
|
// counts of weapons * ammo
|
|
WEAPON* rgSlots[MAX_WEAPON_SLOTS+1][MAX_WEAPON_POSITIONS+1]; // The slots currently in use by weapons. The value is a pointer to the weapon; if it's NULL, no weapon is there
|
|
int riAmmo[MAX_AMMO_SLOTS]; // count of each ammo type
|
|
|
|
public:
|
|
void Init( void )
|
|
{
|
|
memset( rgWeapons, 0, sizeof rgWeapons );
|
|
Reset();
|
|
}
|
|
|
|
void Reset( void )
|
|
{
|
|
iOldWeaponBits = 0;
|
|
m_iSelectedColumn = -1;
|
|
memset( rgSlots, 0, sizeof rgSlots );
|
|
memset( riAmmo, 0, sizeof riAmmo );
|
|
}
|
|
|
|
///// WEAPON /////
|
|
int iOldWeaponBits;
|
|
|
|
WEAPON *GetWeapon( int iId ) { return &rgWeapons[iId]; }
|
|
void AddWeapon( WEAPON *wp )
|
|
{
|
|
rgWeapons[ wp->iId ] = *wp;
|
|
LoadWeaponSprites( &rgWeapons[ wp->iId ] );
|
|
}
|
|
|
|
void PickupWeapon( WEAPON *wp )
|
|
{
|
|
rgSlots[ wp->iSlot ][ wp->iSlotPos ] = wp;
|
|
if ((m_iSelectedColumn == wp->iSlot) && !gpActiveSel) // buz: menu active, but no weapons in this category
|
|
gpActiveSel = wp;
|
|
}
|
|
|
|
void DropWeapon( WEAPON *wp )
|
|
{
|
|
rgSlots[ wp->iSlot ][ wp->iSlotPos ] = NULL;
|
|
if (wp == gpActiveSel) // buz: removed current weapon
|
|
gpActiveSel = GetFirstPos( wp->iSlot );
|
|
}
|
|
|
|
void DropAllWeapons( void )
|
|
{
|
|
for ( int i = 0; i < MAX_WEAPONS; i++ )
|
|
{
|
|
if ( rgWeapons[i].iId )
|
|
DropWeapon( &rgWeapons[i] );
|
|
}
|
|
}
|
|
|
|
WEAPON* GetWeaponSlot( int slot, int pos ) { return rgSlots[slot][pos]; }
|
|
|
|
void LoadWeaponSprites( WEAPON* wp );
|
|
void LoadAllWeaponSprites( void );
|
|
WEAPON* GetFirstPos( int iSlot );
|
|
WEAPON* GetLastPos( int iSlot ); // buz
|
|
void SelectSlot( int iSlot, int fAdvance, int iDirection );
|
|
WEAPON* GetNextActivePos( int iSlot, int iSlotPos );
|
|
WEAPON* GetPrevActivePos( int iSlot, int iSlotPos ); // buz
|
|
|
|
int HasAmmo( WEAPON *p );
|
|
|
|
///// AMMO /////
|
|
AMMO GetAmmo( int iId ) { return iId; }
|
|
|
|
void SetAmmo( int iId, int iCount ) { riAmmo[ iId ] = iCount; }
|
|
|
|
int CountAmmo( int iId );
|
|
|
|
HSPRITE* GetAmmoPicFromWeapon( int iAmmoId, wrect_t& rect );
|
|
|
|
int m_iSelectedColumn; // buz: -1 means menu inactive
|
|
float m_rgColumnSizes[MAX_WEAPON_SLOTS]; // buz
|
|
};
|
|
|
|
extern WeaponsResource gWR;
|
|
|
|
|
|
#define MAX_HISTORY 12
|
|
enum {
|
|
HISTSLOT_EMPTY,
|
|
HISTSLOT_AMMO,
|
|
HISTSLOT_WEAP,
|
|
HISTSLOT_ITEM,
|
|
};
|
|
|
|
class HistoryResource
|
|
{
|
|
private:
|
|
struct HIST_ITEM {
|
|
int type;
|
|
float DisplayTime; // the time at which this item should be removed from the history
|
|
int iCount;
|
|
int iId;
|
|
};
|
|
|
|
HIST_ITEM rgAmmoHistory[MAX_HISTORY];
|
|
|
|
public:
|
|
|
|
void Init( void )
|
|
{
|
|
Reset();
|
|
}
|
|
|
|
void Reset( void )
|
|
{
|
|
memset( rgAmmoHistory, 0, sizeof rgAmmoHistory );
|
|
}
|
|
|
|
int iHistoryGap;
|
|
int iCurrentHistorySlot;
|
|
|
|
void AddToHistory( int iType, int iId, int iCount = 0 );
|
|
void AddToHistory( int iType, const char *szName, int iCount = 0 );
|
|
|
|
void CheckClearHistory( void );
|
|
int DrawAmmoHistory( float flTime );
|
|
};
|
|
|
|
extern HistoryResource gHR;
|
|
|
|
|
|
|