1#ifndef GAME_EDITOR_FONT_TYPER_H
2#define GAME_EDITOR_FONT_TYPER_H
3
4#include "component.h"
5
6#include <base/vmath.h>
7
8#include <engine/graphics.h>
9
10#include <game/client/ui.h>
11
12#include <chrono>
13#include <memory>
14#include <optional>
15
16class CLayer;
17class CLayerTiles;
18
19class CFontTyper : public CEditorComponent
20{
21public:
22 class CState
23 {
24 public:
25 bool m_Active;
26 ivec2 m_TextIndex;
27 // column a newline returns to
28 std::optional<int> m_LineStart;
29 std::shared_ptr<CLayer> m_pLastLayer;
30 int m_TilesPlacedSinceActivate;
31
32 void Reset();
33 };
34
35 void OnInit(CEditor *pEditor) override;
36 bool OnInput(const IInput::CEvent &Event) override;
37 void Render();
38
39 bool IsActive() const;
40
41private:
42 enum
43 {
44 LETTER_OFFSET = 1,
45 NUMBER_OFFSET = 54,
46 };
47 std::chrono::nanoseconds m_CursorRenderTime;
48 IGraphics::CTextureHandle m_CursorTextTexture;
49 CUi::SConfirmPopupContext m_ConfirmActivatePopupContext;
50
51 void SetCursor();
52 void TextModeOff();
53 void TextModeOn();
54 void SetTile(ivec2 Pos, unsigned char Index, const std::shared_ptr<CLayerTiles> &pLayer);
55 void PlaceTile(unsigned char Index, const std::shared_ptr<CLayerTiles> &pLayer);
56};
57
58#endif
59