]> git.localhorst.tv Git - blank.git/blob - src/ui/Interface.hpp
reorganize basic rendering functionality
[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 FrameCounter;
21 class Viewport;
22 class World;
23
24 class Interface {
25
26 public:
27         struct Config {
28                 float move_velocity = 0.005f;
29                 float pitch_sensitivity = -0.0025f;
30                 float yaw_sensitivity = -0.001f;
31
32                 bool keyboard_disabled = false;
33                 bool mouse_disabled = false;
34                 bool visual_disabled = false;
35         };
36
37         Interface(const Config &, const Assets &, const FrameCounter &, World &);
38
39         void HandlePress(const SDL_KeyboardEvent &);
40         void HandleRelease(const SDL_KeyboardEvent &);
41         void Handle(const SDL_MouseMotionEvent &);
42         void HandlePress(const SDL_MouseButtonEvent &);
43         void HandleRelease(const SDL_MouseButtonEvent &);
44         void Handle(const SDL_MouseWheelEvent &);
45
46         void Resize(const Viewport &);
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(Viewport &) 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         float counter_x;
96         SDL_Color counter_color;
97
98         Config config;
99
100         IntervalTimer place_timer;
101         IntervalTimer remove_timer;
102
103         Block remove;
104         Block selection;
105
106         glm::tvec3<int> fwd, rev;
107
108 };
109
110 }
111
112 #endif