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_IMPORTANT_ALERT_H
4#define GAME_CLIENT_COMPONENTS_IMPORTANT_ALERT_H
5
6#include <engine/textrender.h>
7
8#include <game/client/component.h>
9#include <game/client/ui_rect.h>
10
11#include <chrono>
12#include <optional>
13
14class CImportantAlert : public CComponent
15{
16 bool m_Active = false;
17 float m_ActiveSince;
18 std::chrono::nanoseconds m_ActiveSinceNanos{0};
19 float m_FadeOutSince;
20 char m_aTitleText[128];
21 char m_aMessageText[1024];
22 STextContainerIndex m_TitleTextContainerIndex;
23 STextContainerIndex m_MessageTextContainerIndex;
24 STextContainerIndex m_CloseHintTextContainerIndex;
25 bool m_CloseHintShownForTouch = false; // whether the close hint text was created for touch controls
26 std::optional<CUIRect> m_DismissTouchRect; // in normalized screen coordinates like the touch finger positions
27 std::optional<IInput::CTouchFinger> m_DismissTouchFinger; // the finger that dismissed the alert, ignored until released
28
29 void DeleteTextContainers();
30 void RenderImportantAlert();
31 void DoImportantAlert(const char *pTitle, const char *pLogGroup, const char *pMessage);
32 float SecondsActive() const;
33
34public:
35 int Sizeof() const override { return sizeof(*this); }
36 void OnReset() override;
37 void OnWindowResize() override;
38 void OnRender() override;
39 void OnMessage(int MsgType, void *pRawMsg) override;
40 bool OnInput(const IInput::CEvent &Event) override;
41 bool OnTouchState(std::vector<IInput::CTouchFingerState> &vTouchFingerStates) override;
42
43 bool IsActive() const;
44};
45
46#endif
47