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_MOTD_H
4#define GAME_CLIENT_COMPONENTS_MOTD_H
5
6#include <engine/shared/config.h>
7#include <engine/textrender.h>
8
9#include <game/client/component.h>
10#include <game/client/ui_rect.h>
11
12#include <chrono>
13#include <optional>
14
15class CMotd : public CComponent
16{
17 char m_aServerMotd[std::size(g_Config.m_SvMotd)];
18 int64_t m_ServerMotdTime;
19 int64_t m_ServerMotdUpdateTime;
20 std::chrono::nanoseconds m_ShownSince{0}; // when the MOTD last became visible
21 int m_RectQuadContainer = -1;
22 STextContainerIndex m_TextContainerIndex;
23 std::optional<CUIRect> m_TouchRect; // in normalized screen coordinates like the touch finger positions
24 std::optional<IInput::CTouchFinger> m_DismissTouchFinger; // the finger that dismissed the MOTD, ignored until released
25
26public:
27 CMotd();
28 int Sizeof() const override { return sizeof(*this); }
29
30 const char *ServerMotd() const { return m_aServerMotd; }
31 int64_t ServerMotdUpdateTime() const { return m_ServerMotdUpdateTime; }
32 void Clear();
33 bool IsActive() const;
34
35 void OnRender() override;
36 void OnStateChange(int NewState, int OldState) override;
37 void OnWindowResize() override;
38 void OnMessage(int MsgType, void *pRawMsg) override;
39 bool OnInput(const IInput::CEvent &Event) override;
40 bool OnTouchState(std::vector<IInput::CTouchFingerState> &vTouchFingerStates) override;
41};
42
43#endif
44