This commit is contained in:
nephacks
2025-06-04 03:22:50 +02:00
parent f234f23848
commit f12416cffd
14243 changed files with 6446499 additions and 26 deletions

View File

@@ -0,0 +1,44 @@
//===== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ======//
//
// Purpose:
//
//===========================================================================//
#ifndef IGAMECONSOLE_H
#define IGAMECONSOLE_H
#ifdef _WIN32
#pragma once
#endif
#include "tier1/interface.h"
//-----------------------------------------------------------------------------
// Purpose: interface to game/dev console
//-----------------------------------------------------------------------------
abstract_class IGameConsole : public IBaseInterface
{
public:
// activates the console, makes it visible and brings it to the foreground
virtual void Activate() = 0;
virtual void Initialize() = 0;
// hides the console
virtual void Hide() = 0;
// clears the console
virtual void Clear() = 0;
// return true if the console has focus
virtual bool IsConsoleVisible() = 0;
virtual void SetParent( int parent ) = 0;
// hides and deletes panel
virtual void Shutdown( void ) = 0;
};
#define GAMECONSOLE_INTERFACE_VERSION "GameConsole004"
#endif // IGAMECONSOLE_H

141
common/GameUI/IGameUI.h Normal file
View File

@@ -0,0 +1,141 @@
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef IGAMEUI_H
#define IGAMEUI_H
#ifdef _WIN32
#pragma once
#endif
#include "interface.h"
#include "vgui/IPanel.h"
#if !defined( _X360 )
#include "xbox/xboxstubs.h"
#endif
class CCommand;
// reasons why the user can't connect to a game server
enum ESteamLoginFailure
{
STEAMLOGINFAILURE_NONE,
STEAMLOGINFAILURE_BADTICKET,
STEAMLOGINFAILURE_NOSTEAMLOGIN,
STEAMLOGINFAILURE_VACBANNED,
STEAMLOGINFAILURE_LOGGED_IN_ELSEWHERE
};
enum ESystemNotify
{
SYSTEMNOTIFY_STORAGEDEVICES_CHANGED,
SYSTEMNOTIFY_USER_SIGNEDIN,
SYSTEMNOTIFY_USER_SIGNEDOUT,
SYSTEMNOTIFY_XLIVE_LOGON_ESTABLISHED, // we are logged into live service
SYSTEMNOTIFY_XLIVE_LOGON_CLOSED, // no longer logged into live - either from natural (signed out) or unnatural (e.g. severed net connection) causes
SYSTEMNOTIFY_XUIOPENING,
SYSTEMNOTIFY_XUICLOSED,
SYSTEMNOTIFY_INVITE_SHUTDOWN, // Cross-game invite is causing us to shutdown
SYSTEMNOTIFY_MUTECHANGED, // Player changed mute settings
SYSTEMNOTIFY_INPUTDEVICESCHANGED, // Input device has changed (used for controller disconnection)
SYSTEMNOTIFY_PROFILE_UNAVAILABLE, // Profile failed to read or write
};
// these are used to show the modal message box on different slots
enum ECommandMsgBoxSlot
{
CMB_SLOT_FULL_SCREEN = -1,
CMB_SLOT_PLAYER_0,
CMB_SLOT_PLAYER_1,
};
//-----------------------------------------------------------------------------
// Purpose: contains all the functions that the GameUI dll exports
//-----------------------------------------------------------------------------
abstract_class IGameUI
{
public:
// initialization/shutdown
virtual void Initialize( CreateInterfaceFn appFactory ) = 0;
virtual void PostInit() = 0;
// connect to other interfaces at the same level (gameui.dll/server.dll/client.dll)
virtual void Connect( CreateInterfaceFn gameFactory ) = 0;
virtual void Start() = 0;
virtual void Shutdown() = 0;
virtual void RunFrame() = 0;
// notifications
virtual void OnGameUIActivated() = 0;
virtual void OnGameUIHidden() = 0;
// OLD: Use OnConnectToServer2
virtual void OLD_OnConnectToServer(const char *game, int IP, int port) = 0;
virtual void OnDisconnectFromServer_OLD( uint8 eSteamLoginFailure, const char *username ) = 0;
virtual void OnLevelLoadingStarted( const char *levelName, bool bShowProgressDialog ) = 0;
virtual void OnLevelLoadingFinished(bool bError, const char *failureReason, const char *extendedReason) = 0;
virtual void StartLoadingScreenForCommand( const char* command ) = 0;
virtual void StartLoadingScreenForKeyValues( KeyValues* keyValues ) = 0;
// level loading progress, returns true if the screen needs updating
virtual bool UpdateProgressBar(float progress, const char *statusText, bool showDialog = true ) = 0;
// Shows progress desc, returns previous setting... (used with custom progress bars )
virtual bool SetShowProgressText( bool show ) = 0;
virtual bool UpdateSecondaryProgressBar(float progress, const wchar_t *desc ) = 0;
// !!!!!!!!!members added after "GameUI011" initial release!!!!!!!!!!!!!!!!!!!
// Allows the level loading progress to show map-specific info
virtual void SetProgressLevelName( const char *levelName ) = 0;
// Xbox 360
virtual void ShowMessageDialog( const uint nType, vgui::Panel *pOwner ) = 0;
virtual void ShowMessageDialog( const char* messageID, const char* titleID ) = 0;
virtual void CreateCommandMsgBox( const char* pszTitle, const char* pszMessage, bool showOk = true, bool showCancel = false, const char* okCommand = NULL, const char* cancelCommand = NULL, const char* closedCommand = NULL, const char* pszLegend = NULL ) = 0;
virtual void CreateCommandMsgBoxInSlot( ECommandMsgBoxSlot slot, const char* pszTitle, const char* pszMessage, bool showOk = true, bool showCancel = false, const char* okCommand = NULL, const char* cancelCommand = NULL, const char* closedCommand = NULL, const char* pszLegend = NULL ) = 0;
// inserts specified panel as background for level load dialog
virtual void SetLoadingBackgroundDialog( vgui::VPANEL panel ) = 0;
virtual void OnConnectToServer2(const char *game, int IP, int connectionPort, int queryPort) = 0;
virtual void SetProgressOnStart() = 0;
virtual void OnDisconnectFromServer( uint8 eSteamLoginFailure ) = 0;
/*
virtual void OnConfirmQuit( void ) = 0;
virtual bool IsMainMenuVisible( void ) = 0;
// Client DLL is providing us with a panel that it wants to replace the main menu with
virtual void SetMainMenuOverride( vgui::VPANEL panel ) = 0;
// Client DLL is telling us that a main menu command was issued, probably from its custom main menu panel
virtual void SendMainMenuCommand( const char *pszCommand ) = 0;
*/
virtual void NeedConnectionProblemWaitScreen() = 0;
virtual void ShowPasswordUI( char const *pchCurrentPW ) = 0;
#if defined( _X360 ) && defined( _DEMO )
virtual void OnDemoTimeout( void ) = 0;
#endif
virtual bool LoadingProgressWantsIsolatedRender( bool bContextValid ) = 0;
virtual bool IsPlayingFullScreenVideo() = 0;
virtual bool IsTransitionEffectEnabled() = 0;
virtual bool IsInLevel() = 0;
virtual void RestoreTopLevelMenu() = 0;
};
#define GAMEUI_INTERFACE_VERSION "GameUI011"
#endif // IGAMEUI_H

View File

@@ -0,0 +1,247 @@
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//
//=============================================================================//
#include <stdio.h>
// dgoodenough - malloc.h doesn't exist on PS3
// PS3_BUILDFIX
#if !defined( _PS3 )
#include <malloc.h>
#endif
#include "ObjectList.h"
#include "tier1/strtools.h"
//#include "port.h"
//#include "mem.h"
// memdbgon must be the last include file in a .cpp file!!!
#include <tier0/memdbgon.h>
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
ObjectList::ObjectList()
{
head = tail = current = NULL;
number = 0;
}
ObjectList::~ObjectList()
{
Clear( false );
}
bool ObjectList::AddHead(void * newObject)
{
// create new element
element_t * newElement = (element_t *) calloc(1, sizeof(element_t));
if (newElement == NULL )
return false; // out of memory
// insert element
newElement->object = newObject;
if (head)
{
newElement->next = head;
head->prev = newElement;
};
head = newElement;
// if list was empty set new tail
if (tail==NULL) tail = head;
number++;
return true;
}
void * ObjectList::RemoveHead()
{
void * retObj;
// check head is present
if (head)
{
retObj = head->object;
element_t * newHead = head->next;
if (newHead) newHead->prev = NULL;
// if only one element is in list also update tail
// if we remove this prev element
if (tail==head) tail = NULL;
free(head);
head = newHead;
number--;
} else
retObj = NULL;
return retObj;
}
bool ObjectList::AddTail(void * newObject)
{
element_t * newElement = (element_t *) calloc(1, sizeof(element_t));
if (newElement == NULL)
return false; // out of memory;
newElement->object = newObject;
if (tail)
{
newElement->prev = tail;
tail->next = newElement;
}
tail = newElement;
// if list was empty set new head
if (head==NULL) head = tail;
number++;
return true;
}
void * ObjectList::RemoveTail()
{
void * retObj;
// check tail is present
if (tail)
{
retObj = tail->object;
element_t * newTail = tail->prev;
if (newTail) newTail->next = NULL;
// if only one element is in list also update tail
// if we remove this prev element
if (head==tail) head = NULL;
free(tail);
tail = newTail;
number--;
} else
retObj = NULL;
return retObj;
}
bool ObjectList::IsEmpty()
{
return ( head == NULL );
}
int ObjectList::CountElements()
{
return number;
}
bool ObjectList::Contains(void * object)
{
element_t * e = head;
while(e && e->object!=object) { e = e->next;}
if ( e )
{
current = e;
return true;
}
else
{
return false;
}
}
void ObjectList::Clear( bool freeElementsMemory )
{
element_t * ne;
element_t * e = head;
while(e)
{
ne = e->next;
if ( freeElementsMemory && e->object )
free( e->object );
free(e);
e = ne;
}
head = tail = current = NULL;
number = 0;
}
bool ObjectList::Remove( void * object )
{
element_t * e = head;
while(e && e->object!=object) { e = e->next;}
if (e!=NULL)
{
if (e->prev) e->prev->next = e->next;
if (e->next) e->next->prev = e->prev;
if (head==e) head = e->next;
if (tail==e) tail = e->prev;
if (current == e) current= e->next;
free(e);
number--;
}
return (e!=NULL);
}
void ObjectList::Init()
{
head = tail = current = NULL;
number = 0;
}
void * ObjectList::GetFirst()
{
if (head)
{
current = head->next;
return head->object;
}
else
{
current = NULL;
return NULL;
};
}
void * ObjectList::GetNext()
{
void * retObj = NULL;
if (current)
{
retObj = current->object;
current = current->next;
}
return retObj;
}
bool ObjectList::Add(void *newObject)
{
return AddTail( newObject );
}

View File

@@ -0,0 +1,58 @@
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//
//=============================================================================//
// ObjectList.h: interface for the ObjectList class.
//
//////////////////////////////////////////////////////////////////////
#ifndef OBJECTLIST_H
#define OBJECTLIST_H
#pragma once
#include "IObjectContainer.h" // Added by ClassView
class ObjectList : public IObjectContainer
{
public:
void Init();
bool Add( void * newObject );
void * GetFirst();
void * GetNext();
ObjectList();
virtual ~ObjectList();
void Clear( bool freeElementsMemory );
int CountElements();
void * RemoveTail();
void * RemoveHead();
bool AddTail(void * newObject);
bool AddHead(void * newObject);
bool Remove(void * object);
bool Contains(void * object);
bool IsEmpty();
typedef struct element_s {
element_s * prev; // pointer to the last element or NULL
element_s * next; // pointer to the next elemnet or NULL
void * object; // the element's object
} element_t;
protected:
element_t * head; // first element in list
element_t * tail; // last element in list
element_t * current; // current element in list
int number;
};
#endif // !defined

129
common/GameUI/Random.cpp Normal file
View File

@@ -0,0 +1,129 @@
//===== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ======//
//
// Purpose: Basic random number generator
//
// $NoKeywords: $
//===========================================================================//
#include <time.h>
#include "Random.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
#define IA 16807
#define IM 2147483647
#define IQ 127773
#define IR 2836
#define NTAB 32
#define NDIV (1+(IM-1)/NTAB)
static long idum = 0;
void SeedRandomNumberGenerator(long lSeed)
{
if (lSeed)
{
idum = lSeed;
}
else
{
idum = -time(NULL);
}
if (1000 < idum)
{
idum = -idum;
}
else if (-1000 < idum)
{
idum -= 22261048;
}
}
long ran1(void)
{
int j;
long k;
static long iy=0;
static long iv[NTAB];
if (idum <= 0 || !iy)
{
if (-(idum) < 1) idum=1;
else idum = -(idum);
for (j=NTAB+7;j>=0;j--)
{
k=(idum)/IQ;
idum=IA*(idum-k*IQ)-IR*k;
if (idum < 0) idum += IM;
if (j < NTAB) iv[j] = idum;
}
iy=iv[0];
}
k=(idum)/IQ;
idum=IA*(idum-k*IQ)-IR*k;
if (idum < 0) idum += IM;
j=iy/NDIV;
iy=iv[j];
iv[j] = idum;
return iy;
}
// fran1 -- return a random floating-point number on the interval [0,1)
//
#define AM (1.0/IM)
#define EPS 1.2e-7
#define RNMX (1.0-EPS)
float fran1(void)
{
float temp = (float)AM*ran1();
if (temp > RNMX) return (float)RNMX;
else return temp;
}
float RandomFloat( float flLow, float flHigh )
{
if (idum == 0)
{
SeedRandomNumberGenerator(0);
}
float fl = fran1(); // float in [0,1)
return (fl * (flHigh-flLow)) + flLow; // float in [low,high)
}
long RandomLong( long lLow, long lHigh )
{
if (idum == 0)
{
SeedRandomNumberGenerator(0);
}
unsigned long maxAcceptable;
unsigned long x = lHigh-lLow+1;
unsigned long n;
if (x <= 0 || MAX_RANDOM_RANGE < x-1)
{
return lLow;
}
// The following maps a uniform distribution on the interval [0,MAX_RANDOM_RANGE]
// to a smaller, client-specified range of [0,x-1] in a way that doesn't bias
// the uniform distribution unfavorably. Even for a worst case x, the loop is
// guaranteed to be taken no more than half the time, so for that worst case x,
// the average number of times through the loop is 2. For cases where x is
// much smaller than MAX_RANDOM_RANGE, the average number of times through the
// loop is very close to 1.
//
maxAcceptable = MAX_RANDOM_RANGE - ((MAX_RANDOM_RANGE+1) % x );
do
{
n = ran1();
} while (n > maxAcceptable);
return lLow + (n % x);
}

30
common/GameUI/Random.h Normal file
View File

@@ -0,0 +1,30 @@
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose: Generalized 32-bit random number generator
// Range is 0x00000000 - 0x7FFFFFFF
//
// $NoKeywords: $
//=============================================================================//
#ifndef RANDOM_H
#define RANDOM_H
#ifdef _WIN32
#pragma once
#endif
// the random number seeding is automatic
#define MAX_RANDOM_RANGE 0x7FFFFFFFUL
// restarts random generator
// setting lSeed to 0 causes the current time to be used as the seed
// random number generator will automatically seed itself on first use with current time if this is not called
extern void SeedRandomNumberGenerator(long lSeed = 0);
// returns a random integer of range [low, high]
extern long RandomLong( long lLow, long lHigh );
// returns a random float of range [low, high)
extern float RandomFloat( float flLow, float flHigh );
#endif // RANDOM_H