X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=src%2Finterface.hpp;h=9f43f4f6f662b6ba10b71d0706ebf5b202e9887b;hb=e53a0e2e711a7d8bd9b0ddacd1360aa14370643f;hp=68173050bbb036bdd95b0f6a0f76935678b95555;hpb=d242294d15e7465f915d4c79ce563a557afc74d8;p=blank.git diff --git a/src/interface.hpp b/src/interface.hpp index 6817305..9f43f4f 100644 --- a/src/interface.hpp +++ b/src/interface.hpp @@ -3,11 +3,14 @@ #include "block.hpp" #include "controller.hpp" +#include "geometry.hpp" #include "hud.hpp" #include "model.hpp" #include "shader.hpp" +#include "timer.hpp" #include +#include namespace blank { @@ -18,22 +21,36 @@ class World; class Interface { public: - explicit Interface(World &); + struct Config { + float move_velocity = 0.005f; + float pitch_sensitivity = -0.0025f; + float yaw_sensitivity = -0.001f; - void Handle(const SDL_KeyboardEvent &); + bool keyboard_disabled = false; + bool mouse_disabled = false; + bool visual_disabled = false; + }; + + Interface(const Config &, World &); + + void HandlePress(const SDL_KeyboardEvent &); + void HandleRelease(const SDL_KeyboardEvent &); void Handle(const SDL_MouseMotionEvent &); - void Handle(const SDL_MouseButtonEvent &); + void HandlePress(const SDL_MouseButtonEvent &); + void HandleRelease(const SDL_MouseButtonEvent &); void Handle(const SDL_MouseWheelEvent &); - void Handle(const SDL_WindowEvent &); + void Handle(const SDL_WindowEvent &) noexcept; void FaceBlock(); void TurnBlock(); void PickBlock(); void PlaceBlock(); - void RemoveBlock(); + void RemoveBlock() noexcept; void PrintBlockInfo(); + void PrintChunkInfo(); + void PrintLightInfo(); void PrintSelectionInfo(); void Print(const Block &); @@ -42,13 +59,17 @@ public: void Update(int dt); - void Render(DirectionalLighting &); + void Render(DirectionalLighting &) noexcept; + +private: + void CheckAim(); private: World &world; FPSController ctrl; HUD hud; + Ray aim; Chunk *aim_chunk; int aim_block; glm::vec3 aim_normal; @@ -56,14 +77,15 @@ private: OutlineModel outline; glm::mat4 outline_transform; - float move_velocity; - float pitch_sensitivity; - float yaw_sensitivity; + Config config; + + IntervalTimer place_timer; + IntervalTimer remove_timer; Block remove; Block selection; - bool front, back, left, right, up, down; + glm::tvec3 fwd, rev; };