| 1 | #ifndef GAME_EDITOR_COMPONENT_H |
| 2 | #define GAME_EDITOR_COMPONENT_H |
| 3 | |
| 4 | #include <engine/input.h> |
| 5 | |
| 6 | #include <game/client/ui_rect.h> |
| 7 | #include <game/editor/editor_object.h> |
| 8 | |
| 9 | #include <functional> |
| 10 | #include <vector> |
| 11 | |
| 12 | class CEditorComponent : public CEditorObject |
| 13 | { |
| 14 | public: |
| 15 | /** |
| 16 | * Initialize the component and interface pointers. |
| 17 | * Needs to be the first function that is called. |
| 18 | * The default implementation also resets the component. |
| 19 | */ |
| 20 | void OnInit(CEditor *pEditor) override; |
| 21 | |
| 22 | virtual void OnReset(); |
| 23 | |
| 24 | virtual void OnMapLoad(); |
| 25 | |
| 26 | /** |
| 27 | * Gets called before @link OnRender @endlink. Should return `true` |
| 28 | * if the event was consumed. |
| 29 | */ |
| 30 | virtual bool OnInput(const IInput::CEvent &Event); |
| 31 | |
| 32 | virtual void OnUpdate(); |
| 33 | |
| 34 | virtual void OnRender(CUIRect View); |
| 35 | |
| 36 | /** |
| 37 | * Initialize all registered subcomponents. |
| 38 | * Needs to be called after the interfaces have been initialized. |
| 39 | */ |
| 40 | void InitSubComponents(); |
| 41 | |
| 42 | // Register a new subcomponent. |
| 43 | void RegisterSubComponent(CEditorComponent &Component); |
| 44 | |
| 45 | private: |
| 46 | std::vector<std::reference_wrapper<CEditorComponent>> m_vSubComponents; |
| 47 | }; |
| 48 | |
| 49 | #endif |
| 50 | |