1#ifndef GAME_EDITOR_EDITOR_OBJECT_H
2#define GAME_EDITOR_EDITOR_OBJECT_H
3
4#include <functional>
5
6#include <engine/input.h>
7#include <game/client/ui_rect.h>
8
9class CUi;
10class CEditor;
11class IClient;
12class CConfig;
13class IConsole;
14class IEngine;
15class IGraphics;
16class ISound;
17class ITextRender;
18class IStorage;
19class CRenderTools;
20
21class CEditorObject
22{
23public:
24 virtual ~CEditorObject() = default;
25
26 /**
27 * Initialise the component and interface pointers.
28 * Needs to be the first function that is called.
29 * The default implentation also resets the component.
30 */
31 virtual void Init(CEditor *pEditor);
32
33 /**
34 * Maybe calls `OnHot` or `OnActive`.
35 */
36 virtual void OnUpdate();
37
38 /**
39 * Gets called before `OnRender`. Should return true
40 * if the event was consumed.
41 */
42 virtual bool OnInput(const IInput::CEvent &Event);
43
44 virtual void OnRender(CUIRect View);
45
46 /**
47 * Gets called after `OnRender` when the component is hot but not active.
48 */
49 virtual void OnHot();
50
51 /**
52 * Gets called after `OnRender` when the component is active.
53 */
54 virtual void OnActive();
55
56 virtual void OnReset();
57 virtual void OnMapLoad();
58
59 bool IsHot();
60 void SetHot();
61 void UnsetHot();
62
63 bool IsActive();
64 void SetActive();
65 void SetInactive();
66
67 CEditor *Editor();
68 const CEditor *Editor() const;
69 IInput *Input();
70 IClient *Client();
71 CConfig *Config();
72 IConsole *Console();
73 IEngine *Engine();
74 IGraphics *Graphics();
75 ISound *Sound();
76 ITextRender *TextRender();
77 IStorage *Storage();
78 CUi *Ui();
79 CRenderTools *RenderTools();
80
81private:
82 CEditor *m_pEditor;
83};
84
85#endif
86