]> git.localhorst.tv Git - blank.git/blob - src/ui/Interface.hpp
display frame counter
[blank.git] / src / ui / Interface.hpp
1 #ifndef BLANK_UI_INTERFACE_HPP_
2 #define BLANK_UI_INTERFACE_HPP_
3
4 #include "HUD.hpp"
5 #include "../app/FPSController.hpp"
6 #include "../app/IntervalTimer.hpp"
7 #include "../graphics/Font.hpp"
8 #include "../model/geometry.hpp"
9 #include "../model/OutlineModel.hpp"
10 #include "../world/Block.hpp"
11
12 #include <SDL.h>
13 #include <glm/glm.hpp>
14
15
16 namespace blank {
17
18 class Assets;
19 class Chunk;
20 class BlendedSprite;
21 class DirectionalLighting;
22 class FrameCounter;
23 class World;
24
25 class Interface {
26
27 public:
28         struct Config {
29                 float move_velocity = 0.005f;
30                 float pitch_sensitivity = -0.0025f;
31                 float yaw_sensitivity = -0.001f;
32
33                 bool keyboard_disabled = false;
34                 bool mouse_disabled = false;
35                 bool visual_disabled = false;
36         };
37
38         Interface(const Config &, const Assets &, const FrameCounter &, World &);
39
40         void HandlePress(const SDL_KeyboardEvent &);
41         void HandleRelease(const SDL_KeyboardEvent &);
42         void Handle(const SDL_MouseMotionEvent &);
43         void HandlePress(const SDL_MouseButtonEvent &);
44         void HandleRelease(const SDL_MouseButtonEvent &);
45         void Handle(const SDL_MouseWheelEvent &);
46         void Handle(const SDL_WindowEvent &) noexcept;
47
48         void FaceBlock();
49         void TurnBlock();
50
51         void ToggleCollision();
52
53         void PickBlock();
54         void PlaceBlock();
55         void RemoveBlock() noexcept;
56
57         void PrintBlockInfo();
58         void PrintChunkInfo();
59         void PrintLightInfo();
60         void PrintSelectionInfo();
61         void Print(const Block &);
62
63         void SelectNext();
64         void SelectPrevious();
65
66         void ToggleCounter();
67         void UpdateCounter();
68
69         void Update(int dt);
70
71         void Render(DirectionalLighting &, BlendedSprite &) noexcept;
72
73 private:
74         void CheckAim();
75
76 private:
77         const FrameCounter &counter;
78         World &world;
79         FPSController ctrl;
80         Font font;
81         HUD hud;
82
83         Ray aim;
84         Chunk *aim_chunk;
85         int aim_block;
86         glm::vec3 aim_normal;
87
88         OutlineModel outline;
89         glm::mat4 outline_transform;
90
91         bool show_counter;
92         Texture counter_tex;
93         SpriteModel counter_sprite;
94         glm::mat4 counter_transform;
95         SDL_Color counter_color;
96
97         Config config;
98
99         IntervalTimer place_timer;
100         IntervalTimer remove_timer;
101
102         Block remove;
103         Block selection;
104
105         glm::tvec3<int> fwd, rev;
106
107 };
108
109 }
110
111 #endif