aboutsummaryrefslogtreecommitdiff
path: root/src/client/window/basic_window.hh
diff options
context:
space:
mode:
authorNicolas James <Eele1Ephe7uZahRie@tutanota.com>2025-02-12 21:57:46 +1100
committerNicolas James <Eele1Ephe7uZahRie@tutanota.com>2025-02-12 21:57:46 +1100
commite4483eca01b48b943cd0461e24a74ae1a3139ed4 (patch)
treeed58c3c246e3af1af337697695d780aa31f6ad9a /src/client/window/basic_window.hh
parent1cc08c51eb4b0f95c30c0a98ad1fc5ad3459b2df (diff)
Update to most recent version (old initial commit)
Diffstat (limited to 'src/client/window/basic_window.hh')
-rw-r--r--src/client/window/basic_window.hh52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/client/window/basic_window.hh b/src/client/window/basic_window.hh
new file mode 100644
index 0000000..292cc64
--- /dev/null
+++ b/src/client/window/basic_window.hh
@@ -0,0 +1,52 @@
+#ifndef CLIENT_WINDOW_BASIC_WINDOW_HH_
+#define CLIENT_WINDOW_BASIC_WINDOW_HH_
+
+#include <glm/glm.hpp>
+
+#include "client/entity/player.hh"
+#include "client/render/render.hh"
+#include "client/render/struct.hh"
+
+namespace client {
+namespace window {
+
+// All window objects should derive from basic_window, and make use of multiple
+// inheritance for specific behaviours.
+class basic_window {
+protected:
+ // Colours borrowed from arc-dark(er).
+ static constexpr glm::vec3 primary_clr{0.21f, 0.23f, 0.29f}; // dark
+ static constexpr glm::vec3 secondary_clr{0.29f, 0.32f, 0.38f}; // less dark
+ static constexpr glm::vec3 tertiary_clr{0.48, 0.50, 0.54}; // less dark ^2
+ static constexpr glm::vec3 highlight_clr{0.32, 0.58, 0.88}; // light blue
+ static constexpr glm::vec3 font_colour{0.88, 0.88, 0.88}; // light grey
+
+protected:
+ static constexpr float OUTLINE_WIDTH = 2.0f;
+ float get_item_size() const noexcept { return this->size.x / 10.0f; }
+
+protected:
+ glm::vec2 pos;
+ glm::vec2 size;
+
+public:
+ // Test if a vec2 v is inside a square starting at position p with size s.
+ static bool is_inside(const glm::vec2& v, const glm::vec2& p,
+ const glm::vec2& s) noexcept;
+ // Test if v is inside this->pos, this->size
+ bool is_inside(const glm::vec2& v) const noexcept;
+
+public:
+ basic_window(const client::render::relative_arg& pos,
+ const client::render::relative_arg& size) noexcept
+ : pos(pos.to_vec2()), size(size.to_vec2()) {}
+ virtual ~basic_window() noexcept {}
+
+ virtual bool maybe_handle_event(const SDL_Event&) noexcept { return false; }
+ virtual void draw() noexcept;
+};
+
+} // namespace window
+} // namespace client
+
+#endif