2023-08-14 06:36:02 +00:00
|
|
|
#ifndef GAME_EDITOR_COMPONENT_H
|
|
|
|
#define GAME_EDITOR_COMPONENT_H
|
|
|
|
|
2023-08-14 14:52:17 +00:00
|
|
|
#include <functional>
|
2023-08-14 08:12:06 +00:00
|
|
|
#include <game/client/ui.h>
|
|
|
|
|
2023-08-14 06:36:02 +00:00
|
|
|
class CEditor;
|
|
|
|
class IInput;
|
|
|
|
class IClient;
|
|
|
|
class CConfig;
|
|
|
|
class IConsole;
|
|
|
|
class IEngine;
|
|
|
|
class IGraphics;
|
|
|
|
class ISound;
|
|
|
|
class ITextRender;
|
|
|
|
class IStorage;
|
|
|
|
class CRenderTools;
|
|
|
|
|
|
|
|
class CEditorComponent
|
|
|
|
{
|
|
|
|
public:
|
2023-08-14 06:53:59 +00:00
|
|
|
virtual ~CEditorComponent() = default;
|
2023-08-14 06:36:02 +00:00
|
|
|
|
2023-08-14 14:52:17 +00:00
|
|
|
/**
|
|
|
|
* Initialise the component and interface pointers.
|
|
|
|
* Needs to be the first function that is called.
|
|
|
|
*/
|
2023-08-14 06:53:59 +00:00
|
|
|
virtual void Init(CEditor *pEditor);
|
2023-08-14 08:12:06 +00:00
|
|
|
|
2023-08-14 14:52:17 +00:00
|
|
|
/**
|
|
|
|
* Calls `OnRender` and then maybe `OnHot` or `OnActive`.
|
|
|
|
*/
|
2023-08-14 08:12:06 +00:00
|
|
|
void OnUpdate(CUIRect View);
|
2023-08-14 14:52:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets called before `OnRender`. Should return true
|
|
|
|
* if the event was consumed.
|
|
|
|
*/
|
|
|
|
virtual bool OnInput(const IInput::CEvent &Event);
|
|
|
|
|
2023-08-14 08:12:06 +00:00
|
|
|
virtual void OnRender(CUIRect View);
|
2023-08-14 06:36:02 +00:00
|
|
|
|
2023-08-14 14:52:17 +00:00
|
|
|
/**
|
|
|
|
* Gets called after `OnRender` when the component is hot but not active.
|
|
|
|
* I
|
|
|
|
*/
|
|
|
|
virtual void OnHot();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets called after `OnRender` when the component is active.
|
|
|
|
*/
|
|
|
|
virtual void OnActive();
|
|
|
|
|
|
|
|
virtual void OnReset();
|
|
|
|
virtual void OnMapLoad();
|
|
|
|
|
|
|
|
bool IsHot();
|
|
|
|
void SetHot();
|
|
|
|
void UnsetHot();
|
|
|
|
|
|
|
|
bool IsActive();
|
|
|
|
void SetActive();
|
|
|
|
void SetInactive();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialise all registered subcomponents.
|
|
|
|
* Needs to be called after the interfaces have been initialised.
|
|
|
|
*/
|
|
|
|
void InitSubComponents();
|
|
|
|
void RegisterSubComponent(CEditorComponent &Component);
|
|
|
|
|
2023-08-14 06:53:59 +00:00
|
|
|
CEditor *Editor();
|
2023-08-14 14:52:17 +00:00
|
|
|
const CEditor *Editor() const;
|
2023-08-14 06:53:59 +00:00
|
|
|
IInput *Input();
|
2023-08-14 06:36:02 +00:00
|
|
|
IClient *Client();
|
|
|
|
CConfig *Config();
|
|
|
|
IConsole *Console();
|
|
|
|
IEngine *Engine();
|
|
|
|
IGraphics *Graphics();
|
|
|
|
ISound *Sound();
|
|
|
|
ITextRender *TextRender();
|
|
|
|
IStorage *Storage();
|
|
|
|
CUI *UI();
|
|
|
|
CRenderTools *RenderTools();
|
|
|
|
|
|
|
|
private:
|
2023-08-14 06:53:59 +00:00
|
|
|
CEditor *m_pEditor;
|
|
|
|
IInput *m_pInput;
|
|
|
|
IClient *m_pClient;
|
|
|
|
CConfig *m_pConfig;
|
|
|
|
IConsole *m_pConsole;
|
|
|
|
IEngine *m_pEngine;
|
|
|
|
IGraphics *m_pGraphics;
|
|
|
|
ISound *m_pSound;
|
|
|
|
ITextRender *m_pTextRender;
|
|
|
|
IStorage *m_pStorage;
|
|
|
|
CUI *m_pUI;
|
|
|
|
CRenderTools *m_pRenderTools;
|
2023-08-14 14:52:17 +00:00
|
|
|
|
|
|
|
std::vector<std::reference_wrapper<CEditorComponent>> m_vSubComponents = {};
|
2023-08-14 06:36:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|