summaryrefslogtreecommitdiff
path: root/ui/gameMainSelector.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-11-09 00:40:40 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2023-11-09 00:40:40 +0000
commit9c2c3f71065c94a18c02440111b6ff8ca977b90e (patch)
tree339c9846cdd6937a5e77b37f88e3ee3674f944e5 /ui/gameMainSelector.cpp
parentWIP typedefing all the things - headers (diff)
downloadilt-9c2c3f71065c94a18c02440111b6ff8ca977b90e.tar.bz2
ilt-9c2c3f71065c94a18c02440111b6ff8ca977b90e.tar.xz
ilt-9c2c3f71065c94a18c02440111b6ff8ca977b90e.zip
WIP typedefing all the things - sources
Diffstat (limited to 'ui/gameMainSelector.cpp')
-rw-r--r--ui/gameMainSelector.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/ui/gameMainSelector.cpp b/ui/gameMainSelector.cpp
index 808e0e4..a451ee1 100644
--- a/ui/gameMainSelector.cpp
+++ b/ui/gameMainSelector.cpp
@@ -8,6 +8,7 @@
#include <game/selectable.h>
#include <game/worldobject.h> // IWYU pragma: keep
#include <gfx/gl/camera.h>
+#include <math.h>
#include <optional>
#include <span>
#include <stream_support.h>
@@ -16,7 +17,7 @@
GameMainSelector::GameMainSelector(const Camera * c, ScreenAbsCoord size) : UIComponent {{{}, size}}, camera {c} { }
-constexpr glm::vec2 TargetPos {5, 45};
+constexpr ScreenAbsCoord TargetPos {5, 45};
void
GameMainSelector::render(const UIShader & shader, const Position & parentPos) const
@@ -41,7 +42,7 @@ bool
GameMainSelector::handleInput(const SDL_Event & e, const Position & parentPos)
{
const auto getRay = [this](const auto & e) {
- const auto mouse = glm::vec2 {e.x, e.y} / position.size;
+ const auto mouse = ScreenRelCoord {e.x, e.y} / position.size;
return camera->unProject(mouse);
};
if (target) {
@@ -72,8 +73,8 @@ GameMainSelector::handleInput(const SDL_Event & e, const Position & parentPos)
void
GameMainSelector::defaultClick(const Ray & ray)
{
- glm::vec2 baryPos {};
- float distance;
+ Position2D baryPos {};
+ float distance {};
if (const auto selected
= gameState->world.applyOne<Selectable>(&Selectable::intersectRay, ray, &baryPos, &distance);