fully ported gameui.dll

This commit is contained in:
EnderZip
2021-10-21 17:04:36 +07:00
parent 9a7ac85064
commit 767c438b25
38 changed files with 9850 additions and 28 deletions

View File

@@ -52,40 +52,24 @@ CCvarSlider::CCvarSlider( Panel *parent, const char *panelName, char const *capt
//-----------------------------------------------------------------------------
void CCvarSlider::SetupSlider( float minValue, float maxValue, const char *cvarname, bool bAllowOutOfRange )
{
// make sure min/max don't go outside cvar range if there's one
ConVarRef var( cvarname, true );
if ( var.IsValid() )
{
float flCVarMin;
if ( var.GetMin( flCVarMin ) )
{
minValue = m_bUseConVarMinMax ? flCVarMin : MAX( minValue, flCVarMin );
}
float flCVarMax;
if ( var.GetMax( flCVarMax ) )
{
maxValue = m_bUseConVarMinMax ? flCVarMax : MIN( maxValue, flCVarMax );
}
}
m_flMinValue = minValue;
m_flMaxValue = maxValue;
// scale by CVARSLIDER_SCALE_FACTOR
SetRange( (int)( CVARSLIDER_SCALE_FACTOR * minValue ), (int)( CVARSLIDER_SCALE_FACTOR * maxValue ) );
SetRange((int)(CVARSLIDER_SCALE_FACTOR * minValue), (int)(CVARSLIDER_SCALE_FACTOR * maxValue));
char szMin[ 32 ];
char szMax[ 32 ];
char szMin[32];
char szMax[32];
Q_snprintf( szMin, sizeof( szMin ), "%.2f", minValue );
Q_snprintf( szMax, sizeof( szMax ), "%.2f", maxValue );
Q_snprintf(szMin, sizeof(szMin), "%.2f", minValue);
Q_snprintf(szMax, sizeof(szMax), "%.2f", maxValue);
SetTickCaptions( szMin, szMax );
SetTickCaptions(szMin, szMax);
Q_strncpy( m_szCvarName, cvarname, sizeof( m_szCvarName ) );
Q_strncpy(m_szCvarName, cvarname, sizeof(m_szCvarName));
m_bModifiedOnce = false;
m_bAllowOutOfRange = bAllowOutOfRange;
m_bModifiedOnce = false;
m_bAllowOutOfRange = bAllowOutOfRange;
// Set slider to current value
Reset();

32
common/IObjectContainer.h Normal file
View File

@@ -0,0 +1,32 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: IObjectContainer.h: interface for the ObjectContainer class.
//
// $NoKeywords: $
//=============================================================================//
#ifndef IOBJECTCONTAINER_H
#define IOBJECTCONTAINER_H
#pragma once
class IObjectContainer
{
public:
virtual ~IObjectContainer() {};
virtual void Init() = 0;
virtual bool Add(void * newObject) = 0;
virtual bool Remove(void * object) = 0;
virtual void Clear(bool freeElementsMemory) = 0;
virtual void * GetFirst() = 0;
virtual void * GetNext() = 0;
virtual int CountElements() = 0;;
virtual bool Contains(void * object) = 0;
virtual bool IsEmpty() = 0;
};
#endif // !defined IOBJECTCONTAINER_H

81
common/IRunGameEngine.h Normal file
View File

@@ -0,0 +1,81 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef IRUNGAMEENGINE_H
#define IRUNGAMEENGINE_H
#ifdef _WIN32
#pragma once
#endif
#include "interface.h"
#ifdef GetUserName
#undef GetUserName
#endif
//-----------------------------------------------------------------------------
// Purpose: Interface to running the game engine
//-----------------------------------------------------------------------------
abstract_class IRunGameEngine : public IBaseInterface
{
public:
// Returns true if the engine is running, false otherwise.
virtual bool IsRunning() = 0;
// Adds text to the engine command buffer. Only works if IsRunning()
// returns true on success, false on failure
virtual bool AddTextCommand(const char *text) = 0;
// runs the engine with the specified command line parameters. Only works if !IsRunning()
// returns true on success, false on failure
virtual bool RunEngine(const char *gameDir, const char *commandLineParams) = 0;
// returns true if the player is currently connected to a game server
virtual bool IsInGame() = 0;
// gets information about the server the engine is currently connected to
// returns true on success, false on failure
virtual bool GetGameInfo(char *infoBuffer, int bufferSize) = 0;
// tells the engine our userID
virtual void SetTrackerUserID(int trackerID, const char *trackerName) = 0;
// this next section could probably moved to another interface
// iterates users
// returns the number of user
virtual int GetPlayerCount() = 0;
// returns a playerID for a player
// playerIndex is in the range [0, GetPlayerCount)
virtual unsigned int GetPlayerFriendsID(int playerIndex) = 0;
// gets the in-game name of another user, returns NULL if that user doesn't exists
virtual const char *GetPlayerName(int friendsID, char *name, int namelen) = 0;
// gets the friends name of a player
virtual const char *GetPlayerFriendsName(int friendsID, char *name, int namelen) = 0;
// returns the engine build number and mod version string for server versioning
virtual unsigned int GetEngineBuildNumber() = 0;
virtual const char *GetProductVersionString() = 0;
// new interface to RunEngine (done so we don't have to roll the interface version)
virtual bool RunEngine2(const char *gameDir, const char *commandLineParams, bool isSourceGame) = 0;
enum ERunResult
{
k_ERunResultOkay = 0,
k_ERunResultModNotInstalled = 1,
k_ERunResultAppNotFound = 2,
k_ERunResultNotInitialized = 3,
};
virtual ERunResult RunEngine( int iAppID, const char *gameDir, const char *commandLineParams ) = 0;
};
#define RUNGAMEENGINE_INTERFACE_VERSION "RunGameEngine005"
#endif // IRUNGAMEENGINE_H

View File

@@ -0,0 +1,173 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================//
#ifndef VALVECDKEYGAMEANDTERRITORYCODES_H
#define VALVECDKEYGAMEANDTERRITORYCODES_H
#ifdef _WIN32
#pragma once
#endif
// imported from MainIntegration/Deliverables/Production/Client/Inc/NewValveCDKeyGenerator.h
// if the enums there change, this needs to change
//!! these need to be moved out into a seperate file in steam, so that src can use the directly published version
//
// GameCode
//
enum EGameCode
{
// DoD uses SteamInstanceId = 1
// DoD CD-key Steam IDs are displayed as VALVE_1:xxxxxxxx where xxxx is the SteamLocalUserId mentioned above.
// DoD CD-keys uses an odd scheme (invented in a rush) whereby the SteamLocalUserID is generated by hashing
// (MD5) the CD key parameters (Territory,GameCode,UniqueSerialNumber) and truncating the resulting hash for
// a reasonable display length (26 bits, i.e. eMaskLargestAcceptableLocalUserId above, which is about 8 decimal digits).
// **The generator must therefore discard any UniqueSerialNumbers that cause hashes to collide.**
// This means that when generating a new batch from a non-zero StartUniqueSerialNumber, the generator has
// to generate them all from 0 anyway to populate an array of 'hash has been used' flags -- it then only
// prints out new keys higher than the requested StartUniqueSerialNumber.
// IMPORTANT: this means that each match of N keys generated consumes MORE THAN N UniqueSerialNumbers --
// so each new batch MUST be started with the correct "Next StartUniqueSerialNumber" that was output
// at the end of the previous batch, or the new batch will overlap with the previous batch.
eDayOfDefeat = 0,
// CZ uses SteamInstanceId = 2 (**as will all future games using this system**)
// CZ CD-key SteamLocalUserIds have
// high32bits = ( GameCode << sc_uNumBitsSalesTerritory) | SalesTerritory
// low32bits = UniqueSerialNumber
// CZ CD-key Steam IDs will be displayed as VALVE_2:GameCode:UniqueSerialNumber
// (i.e. the DoD hashing scheme is *NOT* used).
eConditionZero = 1,
// CyberCafes receive all legacy and future products, under this one code.
// They have their own SalesTerritory codes too.
// If a CDKey has this game code OR a CyberCafe SalesTerritory then it is a 'cybercafe CDkey'.
eCyberCafeBundle = 2,
eHalfLife2 = 3,
eHalfLife2RetailCE = 4,
eHalfLife2Retail = 5,
};
//
// SalesTerritory
//
enum ESalesTerritory
{
// DoD first batch 80,000 keys **Next free 'StartUniqueSerialNumber' = 80032
// DoD second batch 30,000 keys **Next free 'StartUniqueSerialNumber' = 110081
// OLD KEY ... NOTE: this CZ first batch for USA (code 0) of 275,000 may also be distributed in Canada
// OLD KEY ... i.e. they should ideally have had code 11, but we didn't want to re-issue them.
// OLD KEY ConditionZero first batch 275,000 keys **Next free 'StartUniqueSerialNumber' = 275000
// NEW KEY These were moved to region 11 as suggested above (part of first batch of 379,000)
eUSA = 0,
// DoD first batch 7,500 keys **Next free 'StartUniqueSerialNumber' = 7500
eAustralia = 1,
// DoD first batch 15,000 keys **Next free 'StartUniqueSerialNumber' = 15000
eKorea = 2,
// DoD first batch 10,000 keys **Next free 'StartUniqueSerialNumber' = 10000
eTaiwan = 3,
// DoD first batch 5,000 keys **Next free 'StartUniqueSerialNumber' = 5000
eJapan = 4,
// DoD first batch 25,000 keys **Next free 'StartUniqueSerialNumber' = 25003
// ConditionZero first batch 99,000 keys **Next free 'StartUniqueSerialNumber' = 99000
eUK = 5,
// DoD first batch 15,000 keys **Next free 'StartUniqueSerialNumber' = 15002
// ConditionZero first batch 77,000 keys **Next free 'StartUniqueSerialNumber' = 77000
eFrance = 6,
// DoD first batch 3,000 keys **Next free 'StartUniqueSerialNumber' = 3000
// DoD second batch 5,000 keys **Next free 'StartUniqueSerialNumber' = 8002
// ConditionZero first batch 132,000 keys **Next free 'StartUniqueSerialNumber' = 132000
eGermany = 7,
// DoD first batch 3,000 keys **Next free 'StartUniqueSerialNumber' = 3000
// ConditionZero first batch 27,500 keys **Next free 'StartUniqueSerialNumber' = 27500
eSpain = 8,
// DoD first batch 3,000 keys **Next free 'StartUniqueSerialNumber' = 3000
// ConditionZero first batch 44,000 keys **Next free 'StartUniqueSerialNumber' = 44000
eItaly = 9,
// DoD first batch 65,000 keys **Next free 'StartUniqueSerialNumber' = 65039
// DoD second batch 20,000 keys **Next free 'StartUniqueSerialNumber' = 85058
eChina = 10,
// This is ALL 'American' ENGLISH-SPEAKING TERRITORIES (e.g. USA, Austrailia, Canada, NZ, but *NOT* UK).
// Vivendi track sales by language, rather that geographically.
// OLD KEY ... NOTE: CZ first batch for USA (code 0) of 275,000 will also be distributed in these territories
// OLD KEY ... i.e. they should ideally have had this code, but we didn't want to re-issue them.
// OLD KEY ConditionZero first batch 25,000 keys **Next free 'StartUniqueSerialNumber' = 25000
// OLD KEY ConditionZero second batch 79,000 keys **Next free 'StartUniqueSerialNumber' = 104000
// NEW KEY ConditionZero first batch 379,000 keys **Next free 'StartUniqueSerialNumber' =
eEnglish = 11,
// CyberCafe specific territories. If a CDKey has this game code OR a CyberCafe SalesTerritory then it is a 'cybercafe CDkey'.
// CyberCafeBundle first batch 15,000 keys **Next free 'StartUniqueSerialNumber' = 15000
eCyberCafeEurope = 12,
// CyberCafeBundle first batch 15,000 keys **Next free 'StartUniqueSerialNumber' = 15000
eCyberCafeNorthAndSouthAmerica = 13,
// CyberCafeBundle first batch 15,000 keys **Next free 'StartUniqueSerialNumber' = 15000
eCyberCafeKorea = 14,
// CyberCafeBundle first batch 15,000 keys **Next free 'StartUniqueSerialNumber' = 15000
eCyberCafeChinaTaiwan = 15,
// CyberCafeBundle first batch 15,000 keys **Next free 'StartUniqueSerialNumber' = 15000
eCyberCafeRestOfAsia = 16,
// ATI OEM
// *** After intranet security breach, only the first 40,000 of these keys are valid:
// OLD KEY HL2 first batch 250,000 keys
// *** After intranet security breach, these keys use a new MAC key:
// NEW KEY HL2 first batch start=40,000 210,000 keys
eATI_OEM = 17,
// ConditionZero first batch 5,500 keys **Next free 'StartUniqueSerialNumber' = 5500
eLatinAmerica = 18,
// ConditionZero first batch 16,500 keys **Next free 'StartUniqueSerialNumber' = 16500
eBrazil = 19,
// ConditionZero first batch 66,000 keys **Next free 'StartUniqueSerialNumber' = 66000
eNordic = 20,
// This a Vivendi code meaning "Belgium, Luxembourg, French speaking territories of Africa, French overseas departments, Netherlands, Quebec"
// ConditionZero first batch 40,700 keys **Next free 'StartUniqueSerialNumber' = 40700
eExportFrance = 21,
// This a Vivendi code meaning "Austria, Switzerland, Bulgaria, Czech Republic, Hungary, Lithuania, Poland, Romania, Russian Federation, Slovenia, Slovakia"
// ConditionZero first batch 16,500 keys **Next free 'StartUniqueSerialNumber' = 16500
eExportNorth = 22,
// This a Vivendi code meaning "Cyprus, Egypt, Greece, Israel, Lebanon, Malta, Turkey"
// ConditionZero first batch 40,700 keys **Next free 'StartUniqueSerialNumber' = 40700
eExportSouth = 23,
// MISSING ONES ARE ON MI (24..29)
// ATI Rebate
// HL2 first batch 100,000 keys
eATI_Rebate = 30,
// Used for internal and pre-release testing keys.
// DoD first batch 20 keys **Next free 'StartUniqueSerialNumber' = 20
// DoD second batch 150 keys **Next free 'StartUniqueSerialNumber' = 170
// DoD second batch 500 keys **Next free 'StartUniqueSerialNumber' = 670
// ConditionZero first batch 200 keys **Next free 'StartUniqueSerialNumber' = 200
// CyberCafeBundle first batch 100 keys **Next free 'StartUniqueSerialNumber' = 100
eInternal = 255
};
#endif // VALVECDKEYGAMEANDTERRITORYCODES_H

2301
common/imageutils.cpp Normal file

File diff suppressed because it is too large Load Diff

99
common/imageutils.h Normal file
View File

@@ -0,0 +1,99 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
//=======================================================================================//
#ifndef IMAGECONVERSION_H
#define IMAGECONVERSION_H
#ifdef _WIN32
#pragma once
#endif
#include "tier0/basetypes.h"
class CUtlBuffer;
struct Bitmap_t;
enum ConversionErrorType
{
CE_SUCCESS,
CE_MEMORY_ERROR,
CE_CANT_OPEN_SOURCE_FILE,
CE_ERROR_PARSING_SOURCE,
CE_SOURCE_FILE_FORMAT_NOT_SUPPORTED,
CE_SOURCE_FILE_TGA_FORMAT_NOT_SUPPORTED,
CE_SOURCE_FILE_BMP_FORMAT_NOT_SUPPORTED,
CE_SOURCE_FILE_SIZE_NOT_SUPPORTED,
CE_ERROR_WRITING_OUTPUT_FILE,
CE_ERROR_LOADING_DLL
};
enum ImageFileFormat
{
kImageFileFormat_PNG,
kImageFileFormat_JPG,
};
struct TGAHeader {
byte identsize; // size of ID field that follows 18 byte header (0 usually)
byte colourmaptype; // type of colour map 0=none, 1=has palette
byte imagetype; // type of image 0=none,1=indexed,2=rgb,3=grey,+8=rle packed
short colourmapstart; // first colour map entry in palette
short colourmaplength; // number of colours in palette
byte colourmapbits; // number of bits per palette entry 15,16,24,32
short xstart; // image x origin
short ystart; // image y origin
short width; // image width in pixels
short height; // image height in pixels
byte bits; // image bits per pixel 8,16,24,32
byte descriptor; // image descriptor bits (vh flip bits)
};
ConversionErrorType ImgUtl_ConvertJPEGToTGA( const char *jpgPath, const char *tgaPath, bool bRequirePowerOfTwoSize = true );
ConversionErrorType ImgUtl_ConvertBMPToTGA( const char *bmpPath, const char *tgaPath );
ConversionErrorType ImgUtl_ConvertTGA( const char *tgaPath, int nMaxWidth = -1, int nMaxHeight = -1 );
unsigned char *ImgUtl_ReadVTFAsRGBA( const char *vtfPath, int &width, int &height, ConversionErrorType &errcode );
unsigned char *ImgUtl_ReadTGAAsRGBA( const char *tgaPath, int &width, int &height, ConversionErrorType &errcode, TGAHeader &tgaHeader );
unsigned char *ImgUtl_ReadJPEGAsRGBA( const char *jpegPath, int &width, int &height, ConversionErrorType &errcode );
unsigned char *ImgUtl_ReadBMPAsRGBA( const char *bmpPath, int &width, int &height, ConversionErrorType &errcode );
unsigned char *ImgUtl_ReadPNGAsRGBA( const char *bmpPath, int &width, int &height, ConversionErrorType &errcode );
unsigned char *ImgUtl_ReadPNGAsRGBAFromBuffer( CUtlBuffer &buffer, int &width, int &height, ConversionErrorType &errcode );
unsigned char *ImgUtl_ReadImageAsRGBA( const char *path, int &width, int &height, ConversionErrorType &errcode );
ConversionErrorType ImgUtl_StretchRGBAImage( const unsigned char *srcBuf, const int srcWidth, const int srcHeight, unsigned char *destBuf, const int destWidth, const int destHeight );
ConversionErrorType ImgUtl_PadRGBAImage( const unsigned char *srcBuf, const int srcWidth, const int srcHeight, unsigned char *destBuf, const int destWidth, const int destHeight );
ConversionErrorType ImgUtl_ConvertTGAToVTF( const char *tgaPath, int nMaxWidth = -1, int nMaxHeight = -1 );
ConversionErrorType ImgUtl_WriteGenericVMT( const char *vtfPath, const char *pMaterialsSubDir );
ConversionErrorType ImgUtl_WriteRGBAAsPNGToBuffer( const unsigned char *pRGBAData, int nWidth, int nHeight, CUtlBuffer &bufOutData, int nStride = 0 );
ConversionErrorType ImgUtl_WriteRGBAAsJPEGToBuffer( const unsigned char *pRGBAData, int nWidth, int nHeight, CUtlBuffer &bufOutData, int nStride = 0 );
//
// Converts pInPath (which can be a TGA, BMP, or JPG file) to a VTF in pMaterialsSubDir, where
// pMaterialsSubDir is a directory located relative to the game/materials directory. If the
// output directory doesn't exist, it will be created. Dumps a generic VMT in pMaterialsSubDir
// as well.
//
ConversionErrorType ImgUtl_ConvertToVTFAndDumpVMT( const char *pInPath, const char *pMaterialsSubDir,
int nMaxWidth = -1, int nMaxHeight = -1 );
/// Load from image file. We use the file extension to
/// decide what file format to use
ConversionErrorType ImgUtl_LoadBitmap( const char *pszFilename, Bitmap_t &bitmap );
/// Load an image direct from memory buffer
ConversionErrorType ImgUtl_LoadBitmapFromBuffer( CUtlBuffer &fileData, Bitmap_t &bitmap, ImageFileFormat eImageFileFormat );
/// Save a bitmap to memory buffer
ConversionErrorType ImgUtl_SaveBitmapToBuffer( CUtlBuffer &fileData, const Bitmap_t &bitmap, ImageFileFormat eImageFileFormat );
/// Load a PNG direct from memory buffer
ConversionErrorType ImgUtl_LoadPNGBitmapFromBuffer( CUtlBuffer &fileData, Bitmap_t &bitmap );
/// Save a bitmap in PNG format to memory buffer
ConversionErrorType ImgUtl_SavePNGBitmapToBuffer( CUtlBuffer &fileData, const Bitmap_t &bitmap );
/// Resize a bitmap. This currently only works for RGBA images!
ConversionErrorType ImgUtl_ResizeBitmap( Bitmap_t &destBitmap, int nWidth, int nHeight, const Bitmap_t *pImgSource = NULL );
#endif // IMAGECONVERSION_H