Files
Seaside/SpyCustom/sdk/hudelement.h

160 lines
3.8 KiB
C
Raw Normal View History

2021-06-16 18:46:33 +03:00
#if !defined( HUDELEMENT_H )
#define HUDELEMENT_H
#ifdef _WIN32
#pragma once
#endif
#include "hud.h"
#include "hud_element_helper.h"
#include "networkvar.h"
#include "GameEventListener.h"
#include "memdbgon.h"
2022-11-12 14:43:02 +03:00
#include "panel2d.h"
2021-06-16 18:46:33 +03:00
#undef new
class CHudElement : public CGameEventListener
{
public:
DECLARE_CLASS_NOBASE(CHudElement);
2022-11-12 14:43:02 +03:00
CHudElement() {}
explicit CHudElement(const char* pElementName);
2021-06-16 18:46:33 +03:00
virtual ~CHudElement();
2022-11-12 14:43:02 +03:00
virtual void SetHud(CHud* pHud);
2021-06-16 18:46:33 +03:00
virtual void Init(void) { return; }
virtual void VidInit(void) { return; }
virtual void LevelInit(void) { return; };
virtual void LevelShutdown(void) { return; };
virtual void Reset(void) { return; }
virtual void ProcessInput(void) { return; }
2022-11-12 14:43:02 +03:00
// Called once per frame whether the element is visible or not
virtual void Think(void) { return; }
// Called when time warping occurs, i.e. when instant replay rewinds or forwards client's time
virtual void OnTimeJump(void) { return; }
2021-06-16 18:46:33 +03:00
virtual const char* GetName(void) const { return m_pElementName; };
virtual bool ShouldDraw(void);
virtual bool IsActive(void) { return m_bActive; };
virtual void SetActive(bool bActive);
virtual void SetHiddenBits(int iBits);
2022-11-12 14:43:02 +03:00
virtual void SetIgnoreGlobalHudDisable(bool hide);
virtual bool GetIgnoreGlobalHudDisable(void);
2021-06-16 18:46:33 +03:00
bool IsParentedToClientDLLRootPanel() const;
void SetParentedToClientDLLRootPanel(bool parented);
2022-11-12 14:43:02 +03:00
// Return true if this HUD element expects an entry in HudLayout.res
virtual bool WantsHudLayoutEntry(void) const { return true; }
2021-06-16 18:46:33 +03:00
void* operator new(size_t stAllocateBlock)
{
Assert(stAllocateBlock != 0);
void* pMem = malloc(stAllocateBlock);
memset(pMem, 0, stAllocateBlock);
return pMem;
}
void* operator new(size_t stAllocateBlock, int nBlockUse, const char* pFileName, int nLine)
{
Assert(stAllocateBlock != 0);
void* pMem = MemAlloc_Alloc(stAllocateBlock, pFileName, nLine);
memset(pMem, 0, stAllocateBlock);
return pMem;
}
void operator delete(void* pMem)
{
#if defined( _DEBUG )
int size = _msize(pMem);
memset(pMem, 0xcd, size);
#endif
free(pMem);
}
void operator delete(void* pMem, int nBlockUse, const char* pFileName, int nLine)
{
operator delete(pMem);
}
void SetNeedsRemove(bool needsremove);
void RegisterForRenderGroup(const char* pszName);
void UnregisterForRenderGroup(const char* pszGroupName);
void HideLowerPriorityHudElementsInGroup(const char* pszGroupName);
void UnhideLowerPriorityHudElementsInGroup(const char* pszGroupName);
virtual int GetRenderGroupPriority();
2022-11-12 14:43:02 +03:00
void SetSplitScreenPlayerSlot(int nSlot);
int GetSplitScreenPlayerSlot() const;
virtual void OnSplitScreenStateChanged() {}
2021-06-16 18:46:33 +03:00
public:
virtual void FireGameEvent(IGameEvent* event) {}
2022-11-12 14:43:02 +03:00
//protected:
void InitCHudElementAfterConstruction(const char* pElementName);
2021-06-16 18:46:33 +03:00
public:
bool m_bActive;
2022-11-12 14:43:02 +03:00
//protected:
2021-06-16 18:46:33 +03:00
int m_iHiddenBits;
2022-11-12 14:43:02 +03:00
int m_nSplitScreenPlayerSlot;
bool m_ignoreGlobalHudDisable;
2021-06-16 18:46:33 +03:00
2022-11-12 14:43:02 +03:00
//private:
const char* m_pElementName;
2021-06-16 18:46:33 +03:00
bool m_bNeedsRemove;
bool m_bIsParentedToClientDLLRootPanel;
CUtlVector< int > m_HudRenderGroups;
2022-11-12 14:43:02 +03:00
CHud* m_pHud;
//
panorama::CPanel2D* GetPanel2D()
{
return reinterpret_cast<panorama::CPanel2D*>(uintptr_t(this) - 0x14);
}
2021-06-16 18:46:33 +03:00
};
#include "utlpriorityqueue.h"
inline bool RenderGroupLessFunc(CHudElement* const& lhs, CHudElement* const& rhs)
{
return (lhs->GetRenderGroupPriority() < rhs->GetRenderGroupPriority());
}
class CHudRenderGroup
{
public:
CHudRenderGroup()
{
m_pLockingElements.SetLessFunc(RenderGroupLessFunc);
bHidden = false;
}
bool bHidden;
CUtlPriorityQueue< CHudElement* > m_pLockingElements;
};
#include "memdbgoff.h"
#endif