added main menus, improved shading
This commit is contained in:
@@ -12,6 +12,7 @@ enum EPredictionMode {
|
||||
PREDICTION_MODE_DESTROYED,
|
||||
PREDICTION_MODE_NONE,
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Base server entity class.
|
||||
// It is updated every 1/tickrate (64) of a second. Does not require special
|
||||
@@ -22,11 +23,36 @@ class CBaseEntity
|
||||
public:
|
||||
CBaseEntity();
|
||||
virtual void Precache() = 0;
|
||||
|
||||
virtual void Spawn( void ) = 0;
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
//
|
||||
//---------------------------------------------------------------------
|
||||
virtual void Destroy( void ) = 0;
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// Reads the parameter from the level file. szName indicates of the
|
||||
// parameter that is sent to be deserialized. szValue is value encoded
|
||||
// as a string.
|
||||
//---------------------------------------------------------------------
|
||||
virtual void ReadParameter( const char *szName, const char *szValue );
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// Update at constant rate (+-tickrate times a second).
|
||||
//---------------------------------------------------------------------
|
||||
virtual void Think( float fDelta ) = 0;
|
||||
virtual void Sync( void *pData, uint32_t nDataSize ) = 0;
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// Used to send data from an actual server.
|
||||
//---------------------------------------------------------------------
|
||||
virtual void SendToServer() = 0;
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// Used to recieve data from an actual server.
|
||||
//---------------------------------------------------------------------
|
||||
virtual void RecieveFromServer( void *pData, uint32_t nDataSize ) = 0;
|
||||
|
||||
void SetPosition( vec3 position );
|
||||
void SetRotationEuler( vec3 euler );
|
||||
void SetRotationQuat( vec4 quaternion );
|
||||
|
||||
@@ -32,7 +32,8 @@ public:
|
||||
virtual void ReadParameter( const char *szName, const char *szValue ) override;
|
||||
virtual void Destroy( void ) override;
|
||||
virtual void Think( float fDelta ) override;
|
||||
virtual void Sync( void *pData, uint32_t nDataSize ) override;
|
||||
virtual void SendToServer() override;
|
||||
virtual void RecieveFromServer( void *pData, uint32_t nDataSize ) override;
|
||||
|
||||
CUtlVector<Triangle_t> m_mesh;
|
||||
Collider *m_collider;
|
||||
|
||||
@@ -10,9 +10,24 @@ class ConCommand;
|
||||
|
||||
typedef void(*ConCommandFn)(int argc, char **argv);
|
||||
|
||||
interface IConsoleUI
|
||||
{
|
||||
public:
|
||||
static void Init();
|
||||
static void Frame();
|
||||
static void Deinit();
|
||||
|
||||
static void SetVisibility(bool bIsVisisble);
|
||||
static bool IsVisibile();
|
||||
};
|
||||
|
||||
interface IConsole
|
||||
{
|
||||
public:
|
||||
static void Init();
|
||||
static void Frame();
|
||||
static void Deinit();
|
||||
|
||||
// Variables
|
||||
static void RegisterVar( ConVar *cvar );
|
||||
static void UnRegisterVar( ConVar *cvar );
|
||||
@@ -103,6 +118,9 @@ private:
|
||||
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 );
|
||||
|
||||
@@ -31,6 +31,8 @@ public:
|
||||
static void Frame( void );
|
||||
static void AppendWidget( CFGUI_Widget *pWidget );
|
||||
static void DestroyWidget( CFGUI_Widget *pWidget );
|
||||
static void AddOffset( float x, float y);
|
||||
static void ResetOffset();
|
||||
|
||||
static void SetRectColor( float r, float g, float b, float a );
|
||||
static void DrawRect( int32_t iPosX, int32_t iPosY, uint32_t uSizeX, uint32_t uSizeY );
|
||||
@@ -38,6 +40,7 @@ public:
|
||||
static CFont *LoadFont( CUtlString szFontPath );
|
||||
static void SetTextFont( CFont *pFont );
|
||||
static void SetTextPos( float x, float y );
|
||||
static void SetGlyphScale( float x, float y );
|
||||
static void SetTextColor( float r, float g, float b, float a );
|
||||
static void DrawText( CUtlString psz );
|
||||
};
|
||||
|
||||
@@ -10,17 +10,21 @@ public:
|
||||
CFGUI_Label();
|
||||
~CFGUI_Label();
|
||||
|
||||
CUtlString m_szText;
|
||||
float m_fLabelColor[3];
|
||||
|
||||
void SetFont( CUtlString font );
|
||||
void SetColor( float r, float g, float b );
|
||||
void SetLabel( CUtlString text );
|
||||
void SetLabelSize( uint32_t nSize );
|
||||
void SetGlyphSize( uint32_t nSize );
|
||||
void SetGlyphSize( uint32_t nSizeX, uint32_t nSizeY );
|
||||
|
||||
virtual void Event( FGUI_Event_t event ) override;
|
||||
virtual void Draw() override;
|
||||
virtual void Frame() override;
|
||||
|
||||
private:
|
||||
CUtlString m_szText;
|
||||
float m_fLabelColor[3];
|
||||
float m_fGlyphScale[2] = {1,1};
|
||||
CFont *m_pFont;
|
||||
};
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ public:
|
||||
|
||||
virtual void Event( FGUI_Event_t event ) override;
|
||||
virtual void Draw() override;
|
||||
virtual void Frame() override;
|
||||
|
||||
float m_fBoxColor[4];
|
||||
};
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "tier0/platform.h"
|
||||
#include "fgui.h"
|
||||
#include <cstdint>
|
||||
|
||||
class CFGUI_Widget
|
||||
{
|
||||
@@ -15,14 +16,18 @@ public:
|
||||
void SetSize( uint32_t nX, uint32_t nY );
|
||||
void SetParent( CFGUI_Widget *pParent );
|
||||
|
||||
void ComputeOffset( );
|
||||
bool IsVisible( );
|
||||
|
||||
virtual void Event( FGUI_Event_t event ) = 0;
|
||||
virtual void Draw() = 0;
|
||||
virtual void Frame() = 0;
|
||||
virtual void SetVisibility( bool bValue );
|
||||
|
||||
static void SetDefaultParent(CFGUI_Widget *pParent);
|
||||
|
||||
int32_t m_iPosition[2];
|
||||
uint32_t m_iSize[2];
|
||||
CFGUI_Widget *m_pParent;
|
||||
CFGUI_Widget *m_pParent = NULL;
|
||||
bool m_bIsVisible = true;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef GAMEMODE_H
|
||||
#define GAMEMODE_H
|
||||
|
||||
#include "interface.h"
|
||||
#include "tier0/platform.h"
|
||||
|
||||
class CGameMode
|
||||
@@ -11,18 +12,17 @@ public:
|
||||
bool bCanPlayerSpawnMidRound;
|
||||
};
|
||||
|
||||
interface IGameModeManager
|
||||
interface IGameModeManager: public IInterface
|
||||
{
|
||||
public:
|
||||
static void Init( void );
|
||||
static void Frame( void );
|
||||
|
||||
static void StartGameMode( const char *szName );
|
||||
static const char *GetCurrentGameMode( void );
|
||||
static CGameMode *GetCurrentGameModeClass( void );
|
||||
static void RestartCurrentGameMode( void );
|
||||
virtual void StartGameMode( const char *szName ) = 0;
|
||||
virtual const char *GetCurrentGameMode( void ) = 0;
|
||||
virtual CGameMode *GetCurrentGameModeClass( void ) = 0;
|
||||
virtual void RestartCurrentGameMode( void ) = 0;
|
||||
};
|
||||
|
||||
extern IGameModeManager *GameModeManager();
|
||||
|
||||
typedef CGameMode*(*GameModeRegistryFn)();
|
||||
class CGameModeRegistry
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define INPUT_H
|
||||
|
||||
#include "tier0/platform.h"
|
||||
#include "tier1/utlvector.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Keys include mouse buttons and gamepad buttons as well.
|
||||
@@ -17,6 +18,13 @@ enum EKeyEventType
|
||||
enum EInputKey
|
||||
{
|
||||
KEY_NONE = 0,
|
||||
|
||||
KEY_MOUSE_BUTTON_0,
|
||||
KEY_MOUSE_BUTTON_1,
|
||||
KEY_MOUSE_BUTTON_2,
|
||||
KEY_MOUSE_BUTTON_3,
|
||||
KEY_MOUSE_BUTTON_4,
|
||||
|
||||
KEY_ESCAPE,
|
||||
KEY_TAB,
|
||||
KEY_TILDE,
|
||||
@@ -102,19 +110,23 @@ enum EInputAxis
|
||||
AXIS_NUM_AXIS = AXIS_MAX,
|
||||
};
|
||||
|
||||
enum EMouseMode
|
||||
enum EInputMode
|
||||
{
|
||||
MOUSE_MODE_GAME,
|
||||
MOUSE_MODE_MENU,F
|
||||
INPUT_MODE_GAME,
|
||||
INPUT_MODE_MENU,
|
||||
INPUT_MODE_CONSOLE,
|
||||
INPUT_MODE_INPUT_FIELD,
|
||||
};
|
||||
|
||||
extern CUtlVector<EInputMode> g_inputModeStack;
|
||||
|
||||
interface IInput
|
||||
{
|
||||
public:
|
||||
static void Init( void );
|
||||
static void KeyEvent( EInputKey key, EKeyEventType event );
|
||||
static void AxisEvent( EInputAxis axis, float fValue );
|
||||
static void SetMouseMode( EMouseMode mode );
|
||||
static void SetInputMode( EInputMode mode );
|
||||
static void Frame( void );
|
||||
static void Deinit( void );
|
||||
};
|
||||
|
||||
34
public/interface.h
Normal file
34
public/interface.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#ifndef INTERFACE_H
|
||||
#define INTERFACE_H
|
||||
|
||||
#include "tier0/platform.h"
|
||||
|
||||
abstract_class IInterface
|
||||
{
|
||||
public:
|
||||
virtual void Init() = 0;
|
||||
virtual void Frame() = 0;
|
||||
virtual void Deinit() = 0;
|
||||
};
|
||||
|
||||
typedef IInterface*( *InterfaceRegistryFn )( void );
|
||||
|
||||
class CInterfaceRegistry
|
||||
{
|
||||
public:
|
||||
CInterfaceRegistry( const char *szName, InterfaceRegistryFn pfn );
|
||||
};
|
||||
|
||||
|
||||
#define DECLARE_INTERFACE(iface, impl) \
|
||||
IInterface *__interface_alloc_##impl() \
|
||||
{ \
|
||||
return new impl; \
|
||||
}; \
|
||||
CInterfaceRegistry __interface_##name##_registry(#iface, __interface_alloc_##impl); \
|
||||
I##iface *iface() { \
|
||||
static I##iface *pInterface = (I##iface*)__interface_alloc_##impl(); \
|
||||
return pInterface; \
|
||||
}
|
||||
|
||||
#endif
|
||||
18
public/mainmenu.h
Normal file
18
public/mainmenu.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef MAIN_MENU_H
|
||||
#define MAIN_MENU_H
|
||||
|
||||
#include "interface.h"
|
||||
|
||||
interface IMainMenu: public IInterface
|
||||
{
|
||||
public:
|
||||
virtual void Init() override {}
|
||||
virtual void Frame() override {}
|
||||
virtual void Deinit() override {}
|
||||
|
||||
virtual void SetVisibility( bool bIsVisible ) = 0;
|
||||
};
|
||||
|
||||
extern IMainMenu *MainMenu();
|
||||
|
||||
#endif
|
||||
@@ -13,7 +13,8 @@ public:
|
||||
virtual void ReadParameter( const char *szName, const char *szValue ) override;
|
||||
virtual void Destroy( void ) override;
|
||||
virtual void Think( float fDelta ) override;
|
||||
virtual void Sync( void *pData, uint32_t nDataSize ) override;
|
||||
virtual void SendToServer() override;
|
||||
virtual void RecieveFromServer( void *pData, uint32_t nDataSize ) override;
|
||||
virtual void RoundEnd( void );
|
||||
virtual void RoundStart( IIClient *pClient );
|
||||
|
||||
|
||||
@@ -106,6 +106,8 @@ enum EBarrierMemoryPermissions
|
||||
BARRIER_MEMORY_PERMISSIONS_DEPTH_WRITE = 0x100,
|
||||
BARRIER_MEMORY_PERMISSIONS_COPY_READ = 0x200,
|
||||
BARRIER_MEMORY_PERMISSIONS_COPY_WRITE = 0x400,
|
||||
BARRIER_MEMORY_PERMISSIONS_BLIT_READ = 0x800,
|
||||
BARRIER_MEMORY_PERMISSIONS_BLIT_WRITE = 0x1000,
|
||||
};
|
||||
enum EBarrierStage
|
||||
{
|
||||
@@ -114,10 +116,14 @@ enum EBarrierStage
|
||||
BARRIER_STAGE_VERTEX_SHADER = 0x4,
|
||||
BARRIER_STAGE_GEOMETRY_SHADER = 0x8,
|
||||
BARRIER_STAGE_FRAGMENT_SHADER = 0x10,
|
||||
BARRIER_STAGE_COLOR_OUTPUT = 0x20,
|
||||
BARRIER_STAGE_COMPUTE_SHADER = 0x40,
|
||||
BARRIER_STAGE_RAY_TRACING_SHADER = 0x80,
|
||||
BARRIER_STAGE_BOTTOM = 0x100,
|
||||
BARRIER_STAGE_DEPTH_OUTPUT = 0x20,
|
||||
BARRIER_STAGE_COLOR_OUTPUT = 0x40,
|
||||
BARRIER_STAGE_COMPUTE_SHADER = 0x80,
|
||||
BARRIER_STAGE_RAY_TRACING_SHADER = 0x100,
|
||||
BARRIER_STAGE_BOTTOM = 0x200,
|
||||
BARRIER_STAGE_BLIT = 0x400,
|
||||
BARRIER_STAGE_COPY = 0x800,
|
||||
BARRIER_STAGE_IMAGE_OUPUT = 0x1000,
|
||||
};
|
||||
|
||||
enum EAttachmentLoadMode
|
||||
@@ -226,6 +232,8 @@ abstract_class IPipeline
|
||||
{
|
||||
public:
|
||||
EPipelineType type;
|
||||
virtual void PushBindings() = 0;
|
||||
virtual void BindData( uint32_t binding, IBuffer *pBuffer, IImage* pImage) = 0;
|
||||
};
|
||||
typedef IPipeline IGraphicsPipeline;
|
||||
typedef IPipeline IComputePipeline;
|
||||
@@ -258,14 +266,14 @@ public:
|
||||
|
||||
struct BufferBarrier_t
|
||||
{
|
||||
EBarrierMemoryPermissions in;
|
||||
EBarrierMemoryPermissions out;
|
||||
uint32_t in;
|
||||
uint32_t out;
|
||||
IBuffer *pBuffer;
|
||||
};
|
||||
struct ImageBarrier_t
|
||||
{
|
||||
EBarrierMemoryPermissions in;
|
||||
EBarrierMemoryPermissions out;
|
||||
uint32_t in;
|
||||
uint32_t out;
|
||||
IImage *pImage;
|
||||
};
|
||||
|
||||
@@ -316,18 +324,16 @@ public:
|
||||
|
||||
static void SetConstants( uint32_t nSize, void *pData );
|
||||
static void Barrier( uint32_t stageIn, uint32_t stageOut, CUtlVector<BufferBarrier_t> buffers, CUtlVector<ImageBarrier_t> images );
|
||||
static void BindData( uint32_t binding, IBuffer *pBuffer, IImage* pImage);
|
||||
static void BindPipeline( IPipeline *pPipeline );
|
||||
static void PushBindings();
|
||||
|
||||
|
||||
static void Begin( uint32_t nWidth, uint32_t nHeight, CUtlVector<RenderingColorAttachment_t> attachments, RenderingDepthAttachment_t depth );
|
||||
static void ResetState();
|
||||
static void SetDepthMode( EDepthMode mode );
|
||||
static void Draw( IVertexBuffer *pVertex, IIndexBuffer *pIndex );
|
||||
static void End();
|
||||
|
||||
static void Dispatch( uint32_t x, uint32_t y, uint32_t z );
|
||||
static void TraceRays( uint32_t x, uint32_t y, uint32_t z );
|
||||
static void End();
|
||||
|
||||
static IGraphicsPipeline *CreateGraphicsPipeline(
|
||||
CUtlVector<Shader_t> shaders,
|
||||
|
||||
Reference in New Issue
Block a user