summaryrefslogtreecommitdiff
path: root/ui/gameMainSelector.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2025-03-19 03:19:38 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2025-03-19 03:19:38 +0000
commit0d432961a29d509cd0d1fa80361f04009dcf9c17 (patch)
treebc7536b0ac454a3c466c904123b41498dc6b1905 /ui/gameMainSelector.cpp
parentReplace basic query tool with a ImGui version (diff)
downloadilt-0d432961a29d509cd0d1fa80361f04009dcf9c17.tar.bz2
ilt-0d432961a29d509cd0d1fa80361f04009dcf9c17.tar.xz
ilt-0d432961a29d509cd0d1fa80361f04009dcf9c17.zip
Remove lots of stuff not required or superseded with ImGui use
Diffstat (limited to 'ui/gameMainSelector.cpp')
-rw-r--r--ui/gameMainSelector.cpp26
1 files changed, 11 insertions, 15 deletions
diff --git a/ui/gameMainSelector.cpp b/ui/gameMainSelector.cpp
index 55977ed..7878eb4 100644
--- a/ui/gameMainSelector.cpp
+++ b/ui/gameMainSelector.cpp
@@ -1,5 +1,4 @@
#include "gameMainSelector.h"
-#include "text.h"
#include "ui/uiComponent.h"
#include <SDL2/SDL.h>
#include <game/gamestate.h>
@@ -9,20 +8,15 @@
#include <gfx/camera.h>
#include <stream_support.h>
-const std::filesystem::path fontpath {"/usr/share/fonts/hack/Hack-Regular.ttf"};
-
-GameMainSelector::GameMainSelector(const Camera * c, ScreenAbsCoord size) :
- UIComponent {{{}, size}}, camera {c}, font {fontpath, 15}
-{
-}
+GameMainSelector::GameMainSelector(const Camera * c) : camera {c} { }
constexpr ScreenAbsCoord TargetPos {5, 45};
void
-GameMainSelector::render(const UIShader & shader, const Position & parentPos) const
+GameMainSelector::render(const UIShader & shader) const
{
if (target) {
- target->render(shader, parentPos + position + TargetPos);
+ target->render(shader);
}
}
@@ -35,10 +29,12 @@ GameMainSelector::render(const SceneShader & shader, const Frustum & frustum) co
}
bool
-GameMainSelector::handleInput(const SDL_Event & e, const Position & parentPos)
+GameMainSelector::handleInput(const SDL_Event & e)
{
- const auto getRay = [this](const auto & e) {
- const auto mouse = ScreenRelCoord {e.x, e.y} / position.size;
+ const auto getRay = [this, &window = e.window](const auto & e) {
+ glm::ivec2 size {};
+ SDL_GetWindowSizeInPixels(SDL_GetWindowFromID(window.windowID), &size.x, &size.y);
+ const auto mouse = ScreenRelCoord {e.x, e.y} / ScreenRelCoord {size};
return camera->unProject(mouse);
};
if (target) {
@@ -54,7 +50,7 @@ GameMainSelector::handleInput(const SDL_Event & e, const Position & parentPos)
}
break;
}
- return target->handleInput(e, parentPos + position + TargetPos);
+ return target->handleInput(e);
}
else {
switch (e.type) {
@@ -84,13 +80,13 @@ GameMainSelector::Component::move(const SDL_MouseMotionEvent &, const Ray<Global
}
bool
-GameMainSelector::Component::handleInput(const SDL_Event &, const Position &)
+GameMainSelector::Component::handleInput(const SDL_Event &)
{
return false;
}
void
-GameMainSelector::Component::render(const UIShader &, const UIComponent::Position &)
+GameMainSelector::Component::render(const UIShader &)
{
}