started working on ini parser
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
#define FUNNY_FORMAT_H
|
||||
|
||||
#include "tier0/platform.h"
|
||||
#include "ifilesystem.h"
|
||||
#include "tier2/ifilesystem.h"
|
||||
#include "tier1/utlvector.h"
|
||||
|
||||
struct FunnyFormatParameter_t
|
||||
|
||||
119
public/icvar.h
119
public/icvar.h
@@ -0,0 +1,119 @@
|
||||
#ifndef CONSOLE_H
|
||||
#define CONSOLE_H
|
||||
|
||||
#include "iappsystem.h"
|
||||
#include "tier0/platform.h"
|
||||
#include "tier1/utlstring.h"
|
||||
#include "tier1/utlvector.h"
|
||||
|
||||
class ConVar;
|
||||
class ConCommand;
|
||||
|
||||
|
||||
typedef void(*ConCommandFn)(int argc, char **argv);
|
||||
|
||||
abstract_class IConsole: public IAppSystem
|
||||
{
|
||||
public:
|
||||
// Variables
|
||||
virtual void RegisterVar( ConVar *cvar ) = 0;
|
||||
virtual void UnRegisterVar( ConVar *cvar ) = 0;
|
||||
virtual ConVar *FindVar( const char *pName ) = 0;
|
||||
|
||||
// Commands
|
||||
virtual void RegisterCommand( ConCommand *cvar ) = 0;
|
||||
virtual void UnRegisterCommand( ConCommand *cvar ) = 0;
|
||||
virtual ConCommand *FindCommand( const char *pName ) = 0;
|
||||
|
||||
// Command buffer
|
||||
virtual void Execute( void ) = 0;
|
||||
virtual void ExecuteArguments( CUtlVector<CUtlString> &args ) = 0;
|
||||
virtual CUtlVector<CUtlVector<CUtlString>> ParseCommandLine( CUtlString psz ) = 0;
|
||||
|
||||
virtual void AddCommand( const char *psz ) = 0;
|
||||
virtual void InsertCommand( const char *psz ) = 0;
|
||||
|
||||
CUtlVector<ConVar*> m_convars;
|
||||
CUtlVector<ConCommand*> m_commands;
|
||||
};
|
||||
|
||||
IConsole *Console();
|
||||
|
||||
|
||||
#define FCVAR_NONE 0
|
||||
#define FCVAR_DEVELOPMENTONLY 0x1
|
||||
#define FCVAR_GAMEDLL 0x2
|
||||
#define FCVAR_CLIENTDLL 0x4
|
||||
#define FCVAR_HIDDEN 0x8
|
||||
|
||||
#define FCVAR_PROTECTED 0x10
|
||||
#define FCVAR_SPONLY 0x20
|
||||
#define FCVAR_ARCHIVE 0x40
|
||||
#define FCVAR_NOTIFY 0x80
|
||||
#define FCVAR_CHEAT 0x100
|
||||
#define FCVAR_REPLICATED 0x200
|
||||
|
||||
class ConVar
|
||||
{
|
||||
public:
|
||||
ConVar( const char *pName, const char *pDefaultValue, int flags );
|
||||
ConVar( const char *pName, const char *pDefaultValue, int flags,
|
||||
const char *pHelpString );
|
||||
ConVar( const char *pName, const char *pDefaultValue, int flags,
|
||||
const char *pHelpString, ConCommandFn callback );
|
||||
|
||||
bool IsFlagSet( int flag );
|
||||
const char *GetHelpText( void );
|
||||
bool IsRegistered( void );
|
||||
const char *GetName( void );
|
||||
void AddFlags( int flags );
|
||||
bool IsCommand( void );
|
||||
|
||||
void InstallChangeCallback( ConCommandFn );
|
||||
|
||||
float GetFloat( void );
|
||||
int GetInt( void );
|
||||
bool GetBool( void );
|
||||
const char *GetString( void );
|
||||
|
||||
void SetValue( const char *szValue );
|
||||
void SetValue( float fValue );
|
||||
void SetValue( int iValue );
|
||||
private:
|
||||
CUtlString m_szName;
|
||||
CUtlString m_szHelpString;
|
||||
CUtlString m_szDefaultValue;
|
||||
|
||||
CUtlString m_szValue;
|
||||
float m_fValue;
|
||||
int m_nValue;
|
||||
|
||||
int m_flags;
|
||||
};
|
||||
|
||||
|
||||
class ConCommand
|
||||
{
|
||||
public:
|
||||
ConCommand(const char *pName, ConCommandFn callback,
|
||||
const char *pHelpString=0, int flags=0);
|
||||
|
||||
const char *GetName( void );
|
||||
const char *GetHelpText( void );
|
||||
ConCommandFn GetCallback( void );
|
||||
private:
|
||||
CUtlString m_szName;
|
||||
CUtlString m_szHelpString = NULL;
|
||||
ConCommandFn m_callback;
|
||||
|
||||
int m_flags;
|
||||
};
|
||||
|
||||
#undef V_printf
|
||||
#define V_printf(...) Msg(CUtlString(__VA_ARGS__).GetString())
|
||||
|
||||
void Msg( const char* message );
|
||||
void Warning( const char* message );
|
||||
void Error( const char* message );
|
||||
|
||||
#endif
|
||||
|
||||
@@ -4,10 +4,24 @@
|
||||
#include "iappsystem.h"
|
||||
#include "tier0/platform.h"
|
||||
|
||||
enum EGraphicsAPI
|
||||
{
|
||||
GRAPHICS_API_METAL,
|
||||
GRAPHICS_API_VULKAN,
|
||||
};
|
||||
|
||||
abstract_class IGameWindow: public IAppSystem
|
||||
{
|
||||
public:
|
||||
virtual void UpdateWindow() = 0;
|
||||
|
||||
virtual EGraphicsAPI GetGraphicsAPI() = 0;
|
||||
|
||||
virtual int GetVulkanInstanceExtensionCount() = 0;
|
||||
virtual const char **GetVulkanInstanceExtensions() = 0;
|
||||
virtual void CreateVulkanSurface( void *pInstance ) = 0;
|
||||
virtual void DestroyVulkanSurface( void *pInstance ) = 0;
|
||||
virtual void *GetVulkanSurface() = 0;
|
||||
};
|
||||
|
||||
extern IGameWindow *gamewindow;
|
||||
|
||||
@@ -61,31 +61,30 @@ enum EMultisampleType
|
||||
abstract_class IImage : public IRenderingObject
|
||||
{
|
||||
public:
|
||||
virtual void BlitTo( IImage *pImage );
|
||||
|
||||
};
|
||||
abstract_class IRenderContext: public IAppSystem
|
||||
{
|
||||
public:
|
||||
virtual void Frame( float fTime ) = 0;
|
||||
|
||||
virtual IVertexBuffer *CreateVertexBuffer( uint32_t nSize ) = 0;
|
||||
virtual IIndexBuffer *CreateIndexBuffer( uint32_t nSize ) = 0;
|
||||
virtual IImage *CreateRenderTarget( uint32_t x, uint32_t y, EImageFormat eFormat, EMultisampleType eMultisampleType );
|
||||
virtual IImage *CreateStorageImage( uint32_t x, uint32_t y, EImageFormat eFormat, EMultisampleType eMultisampleType );
|
||||
virtual IImage *CreateRenderTarget( uint32_t x, uint32_t y, EImageFormat eFormat, EMultisampleType eMultisampleType ) = 0;
|
||||
virtual IImage *CreateStorageImage( uint32_t x, uint32_t y, EImageFormat eFormat, EMultisampleType eMultisampleType ) = 0;
|
||||
|
||||
virtual void DestroyBuffer( IBuffer *pBuffer );
|
||||
virtual void DestroyImage( IImage *pImage );
|
||||
virtual void DestroyBuffer( IBuffer *pBuffer ) = 0;
|
||||
virtual void DestroyImage( IImage *pImage ) = 0;
|
||||
};
|
||||
|
||||
abstract_class IMaterialSystem: public IAppSystem
|
||||
{
|
||||
public:
|
||||
virtual void Init();
|
||||
virtual void Frame( float fTime );
|
||||
virtual void Shutdown();
|
||||
virtual void Frame( float fTime ) = 0;
|
||||
|
||||
IRenderContext *GetRenderContext();
|
||||
virtual IRenderContext *GetRenderContext( void) = 0;
|
||||
};
|
||||
|
||||
extern IMaterialSystem *materials;
|
||||
IMaterialSystem *Materials( void );
|
||||
|
||||
#endif
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "string.h"
|
||||
#include "stdio.h"
|
||||
#include "stdlib.h"
|
||||
#include "ctype.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// string.h
|
||||
@@ -106,4 +107,24 @@
|
||||
#define V_atoi atoi
|
||||
#define V_atof atof
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ctype.h
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#define V_isalnum isalnum
|
||||
#define V_isalpha isalpha
|
||||
#define V_isblank isblank
|
||||
#define V_iscntrl iscntrl
|
||||
#define V_isdigit isdigit
|
||||
#define V_isgraph isgraph
|
||||
#define V_islower islower
|
||||
#define V_isprint isprint
|
||||
#define V_ispunct ispunct
|
||||
#define V_isspace isspace
|
||||
#define V_isupper isupper
|
||||
#define V_isxdigit isxdigit
|
||||
#define V_tolower tolower
|
||||
#define V_toupper toupper
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -23,10 +23,11 @@ template <typename T>
|
||||
class CUtlBuffer
|
||||
{
|
||||
public:
|
||||
CUtlBuffer( void );
|
||||
CUtlBuffer( void );
|
||||
CUtlBuffer( size_t nSize );
|
||||
CUtlBuffer( const CUtlBuffer<T>& buffer );
|
||||
CUtlBuffer( const CUtlResizableBuffer<T>& buffer );
|
||||
~CUtlBuffer( void );
|
||||
|
||||
size_t GetSize( void ) const;
|
||||
T* GetMemory(void) const;
|
||||
@@ -81,6 +82,12 @@ CUtlBuffer<T>::CUtlBuffer( const CUtlResizableBuffer<T>& buffer ) : m_nSize(buff
|
||||
V_memcpy(m_pData,buffer.pData,sizeof(T)*buffer.nSize);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
CUtlBuffer<T>::~CUtlBuffer()
|
||||
{
|
||||
if ( m_pData != 0)
|
||||
V_free(m_pData);
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
// Gets memory size.
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -145,9 +152,10 @@ CUtlBuffer<T>& CUtlBuffer<T>::operator=(const CUtlBuffer<T>& other)
|
||||
if ( m_pData != 0)
|
||||
V_free(m_pData);
|
||||
m_pData = (T*)V_malloc(sizeof(T)*other.m_nSize);
|
||||
m_nSize = other.m_nSize;
|
||||
V_memcpy(m_pData, other.m_pData, sizeof(T)*other.m_nSize);
|
||||
}
|
||||
return this;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "tier0/platform.h"
|
||||
#include "tier1/utlstring.h"
|
||||
#include "tier1/utlvector.h"
|
||||
|
||||
abstract_class IINISection
|
||||
{
|
||||
@@ -16,7 +17,7 @@ public:
|
||||
abstract_class IINIFile
|
||||
{
|
||||
public:
|
||||
virtual void GetSection( const char *szSectionName ) = 0;
|
||||
virtual IINISection *GetSection( const char *szSectionName ) = 0;
|
||||
};
|
||||
|
||||
abstract_class IINIManager
|
||||
|
||||
@@ -11,15 +11,9 @@ enum EFileMode
|
||||
FILEMODE_APPEND = 0x04,
|
||||
};
|
||||
|
||||
enum EFileType {
|
||||
FILETYPE_NONE,
|
||||
FILETYPE_SYSTEM,
|
||||
FILETYPE_PAK,
|
||||
};
|
||||
|
||||
enum ESeekMode
|
||||
{
|
||||
SEEKMODE_SET,
|
||||
SEEKMODE_RELATIVE_CURRENT,
|
||||
SEEKMODE_RELATIVE_START,
|
||||
SEEKMODE_RELATIVE_END,
|
||||
};
|
||||
@@ -35,6 +29,7 @@ public:
|
||||
size_t Read( void *pData, size_t nDataSize );
|
||||
size_t Seek( ESeekMode eSeekMode, size_t nOffset );
|
||||
size_t Tell( void );
|
||||
size_t Size( void );
|
||||
void Close( void );
|
||||
|
||||
|
||||
@@ -56,12 +51,28 @@ public:
|
||||
|
||||
virtual size_t Seek( IFileHandle *pFile, ESeekMode eSeekMode, size_t nOffset ) = 0;
|
||||
virtual size_t Tell( IFileHandle *pFile ) = 0;
|
||||
virtual size_t Size( IFileHandle *pFile ) = 0;
|
||||
|
||||
virtual void Close( IFileHandle *pFile ) = 0;
|
||||
|
||||
IFileSystem *m_pNext;
|
||||
|
||||
void RegisterFileSystem();
|
||||
};
|
||||
|
||||
extern IFileSystem *filesystem;
|
||||
extern IFileSystem *filesystem_backend;
|
||||
extern IFileSystem *filesystem_pak;
|
||||
extern IFileSystem *g_pFileSystems;
|
||||
|
||||
typedef IFileSystem *( *InstantiateFileSystemFn )( void );
|
||||
class CFileSystemRegistry
|
||||
{
|
||||
public:
|
||||
CFileSystemRegistry( InstantiateFileSystemFn fn, const char *szFileSystem );
|
||||
};
|
||||
|
||||
#define EXPOSE_FILESYSTEM( className, filesystemName ) \
|
||||
static IFileSystem *__Create##className##_filesystem() { return ( IFileSystem* )( new className ); }; \
|
||||
static CFileSystemRegistry __Create##className##_registry( __Create##className##_filesystem, filesystemName );
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user