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_SCOREBOARD_H
4#define GAME_CLIENT_COMPONENTS_SCOREBOARD_H
5
6#include <engine/console.h>
7#include <engine/graphics.h>
8
9#include <game/client/component.h>
10#include <game/client/ui.h>
11#include <game/client/ui_rect.h>
12
13class CScoreboard : public CComponent
14{
15 struct CScoreboardRenderState
16 {
17 float m_TeamStartX;
18 float m_TeamStartY;
19 int m_CurrentDDTeamSize;
20
21 CScoreboardRenderState() :
22 m_TeamStartX(0), m_TeamStartY(0), m_CurrentDDTeamSize(0) {}
23 };
24
25 void RenderTitle(CUIRect TitleBar, int Team, const char *pTitle);
26 void RenderGoals(CUIRect Goals);
27 void RenderSpectators(CUIRect Spectators);
28 void RenderScoreboard(CUIRect Scoreboard, int Team, int CountStart, int CountEnd, CScoreboardRenderState &State);
29 void RenderRecordingNotification(float x);
30
31 static void ConKeyScoreboard(IConsole::IResult *pResult, void *pUserData);
32 static void ConToggleScoreboardCursor(IConsole::IResult *pResult, void *pUserData);
33
34 const char *GetTeamName(int Team) const;
35
36 bool m_Active;
37 float m_ServerRecord;
38
39 IGraphics::CTextureHandle m_DeadTeeTexture;
40
41 std::optional<vec2> m_LastMousePos;
42 bool m_MouseUnlocked = false;
43
44 void SetUiMousePos(vec2 Pos);
45 void LockMouse();
46
47 class CScoreboardPopupContext : public SPopupMenuId
48 {
49 public:
50 CScoreboard *m_pScoreboard = nullptr;
51 CButtonContainer m_FriendAction;
52 CButtonContainer m_MuteAction;
53 CButtonContainer m_EmoticonAction;
54
55 CButtonContainer m_SpectateButton;
56
57 int m_ClientId;
58 bool m_IsLocal;
59 bool m_IsSpectating;
60 } m_ScoreboardPopupContext;
61
62 static CUi::EPopupMenuFunctionResult PopupScoreboard(void *pContext, CUIRect View, bool Active);
63
64 class CPlayerElement
65 {
66 public:
67 char m_PlayerButtonId;
68 char m_SpectatorSecondLineButtonId;
69 };
70 CPlayerElement m_aPlayers[MAX_CLIENTS];
71
72public:
73 CScoreboard();
74 int Sizeof() const override { return sizeof(*this); }
75 void OnConsoleInit() override;
76 void OnInit() override;
77 void OnReset() override;
78 void OnRender() override;
79 void OnRelease() override;
80 void OnMessage(int MsgType, void *pRawMsg) override;
81 bool OnCursorMove(float x, float y, IInput::ECursorType CursorType) override;
82 bool OnInput(const IInput::CEvent &Event) override;
83
84 bool IsActive() const;
85};
86
87#endif
88