| 1 | /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ |
| 2 | /* If you are missing that file, acquire a complete release at teeworlds.com. */ |
| 3 | #ifndef GAME_CLIENT_COMPONENTS_SPECTATOR_H |
| 4 | #define GAME_CLIENT_COMPONENTS_SPECTATOR_H |
| 5 | #include <base/vmath.h> |
| 6 | |
| 7 | #include <engine/console.h> |
| 8 | |
| 9 | #include <game/client/component.h> |
| 10 | #include <game/client/ui.h> |
| 11 | |
| 12 | class CSpectator : public CComponent |
| 13 | { |
| 14 | enum |
| 15 | { |
| 16 | MULTI_VIEW = -4, |
| 17 | NO_SELECTION = -3, |
| 18 | }; |
| 19 | |
| 20 | bool m_Active; |
| 21 | bool m_WasActive; |
| 22 | |
| 23 | int m_SelectedSpectatorId; |
| 24 | vec2 m_SelectorMouse; |
| 25 | |
| 26 | CUi::CTouchState m_TouchState; |
| 27 | |
| 28 | float m_MultiViewActivateDelay; |
| 29 | |
| 30 | bool CanChangeSpectatorId(); |
| 31 | void SpectateNext(bool Reverse); |
| 32 | |
| 33 | static void ConKeySpectator(IConsole::IResult *pResult, void *pUserData); |
| 34 | static void ConSpectate(IConsole::IResult *pResult, void *pUserData); |
| 35 | static void ConSpectateNext(IConsole::IResult *pResult, void *pUserData); |
| 36 | static void ConSpectatePrevious(IConsole::IResult *pResult, void *pUserData); |
| 37 | static void ConSpectateClosest(IConsole::IResult *pResult, void *pUserData); |
| 38 | static void ConMultiView(IConsole::IResult *pResult, void *pUserData); |
| 39 | |
| 40 | public: |
| 41 | CSpectator(); |
| 42 | int Sizeof() const override { return sizeof(*this); } |
| 43 | |
| 44 | void OnConsoleInit() override; |
| 45 | bool OnCursorMove(float x, float y, IInput::ECursorType CursorType) override; |
| 46 | bool OnInput(const IInput::CEvent &Event) override; |
| 47 | void OnRender() override; |
| 48 | void OnRelease() override; |
| 49 | void OnReset() override; |
| 50 | |
| 51 | void Spectate(int SpectatorId); |
| 52 | void SpectateClosest(); |
| 53 | |
| 54 | bool IsActive() const { return m_Active; } |
| 55 | }; |
| 56 | |
| 57 | #endif |
| 58 | |