summaryrefslogtreecommitdiff
path: root/ui/gameMainSelector.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2024-01-01 17:56:26 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2024-01-01 17:56:26 +0000
commitd5cdbbf38380239524e351cb69aec94090884ca5 (patch)
tree5d7dff2f2775701069806eceb4eaef23b22eba3f /ui/gameMainSelector.cpp
parentReformat with new clang-format (diff)
parentRemove more use of legacy types (diff)
downloadilt-d5cdbbf38380239524e351cb69aec94090884ca5.tar.bz2
ilt-d5cdbbf38380239524e351cb69aec94090884ca5.tar.xz
ilt-d5cdbbf38380239524e351cb69aec94090884ca5.zip
Merge remote-tracking branch 'origin/terrain'
Diffstat (limited to 'ui/gameMainSelector.cpp')
-rw-r--r--ui/gameMainSelector.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/ui/gameMainSelector.cpp b/ui/gameMainSelector.cpp
index 6c6935c..a451ee1 100644
--- a/ui/gameMainSelector.cpp
+++ b/ui/gameMainSelector.cpp
@@ -8,15 +8,16 @@
#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>
#include <typeinfo>
#include <vector>
-GameMainSelector::GameMainSelector(const Camera * c, glm::vec2 size) : UIComponent {{{}, size}}, camera {c} { }
+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);