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#include <engine/console.h>
7
8#include <game/client/component.h>
9
10class CSpectator : public CComponent
11{
12 enum
13 {
14 MULTI_VIEW = -4,
15 NO_SELECTION = -3,
16 };
17
18 bool m_Active;
19 bool m_WasActive;
20 bool m_Clicked;
21
22 int m_SelectedSpectatorId;
23 vec2 m_SelectorMouse;
24
25 float m_OldMouseX;
26 float m_OldMouseY;
27
28 float m_MultiViewActivateDelay;
29
30 bool CanChangeSpectator();
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
40public:
41 CSpectator();
42 virtual int Sizeof() const override { return sizeof(*this); }
43
44 virtual void OnConsoleInit() override;
45 virtual bool OnCursorMove(float x, float y, IInput::ECursorType CursorType) override;
46 virtual void OnRender() override;
47 virtual void OnRelease() override;
48 virtual void OnReset() override;
49 virtual bool OnInput(const IInput::CEvent &Event) override;
50
51 void Spectate(int SpectatorId);
52 void SpectateClosest();
53};
54
55#endif
56