diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-11-09 00:40:40 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-11-09 00:40:40 +0000 |
commit | 9c2c3f71065c94a18c02440111b6ff8ca977b90e (patch) | |
tree | 339c9846cdd6937a5e77b37f88e3ee3674f944e5 /ui | |
parent | WIP typedefing all the things - headers (diff) | |
download | ilt-9c2c3f71065c94a18c02440111b6ff8ca977b90e.tar.bz2 ilt-9c2c3f71065c94a18c02440111b6ff8ca977b90e.tar.xz ilt-9c2c3f71065c94a18c02440111b6ff8ca977b90e.zip |
WIP typedefing all the things - sources
Diffstat (limited to 'ui')
-rw-r--r-- | ui/builders/straight.cpp | 2 | ||||
-rw-r--r-- | ui/gameMainSelector.cpp | 9 | ||||
-rw-r--r-- | ui/gameMainWindow.cpp | 4 | ||||
-rw-r--r-- | ui/manualCameraController.cpp | 2 |
4 files changed, 9 insertions, 8 deletions
diff --git a/ui/builders/straight.cpp b/ui/builders/straight.cpp index 4fa9585..9b262bb 100644 --- a/ui/builders/straight.cpp +++ b/ui/builders/straight.cpp @@ -47,7 +47,7 @@ BuilderStraight::click(Network * network, const GeoData * geoData, const SDL_Mou } void -BuilderStraight::create(Network * network, glm::vec3 p1, glm::vec3 p2) const +BuilderStraight::create(Network * network, Position3D p1, Position3D p2) const { network->addStraight(p1, p2); } 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); diff --git a/ui/gameMainWindow.cpp b/ui/gameMainWindow.cpp index b94accd..15f1e07 100644 --- a/ui/gameMainWindow.cpp +++ b/ui/gameMainWindow.cpp @@ -31,8 +31,8 @@ public: GameMainWindow::GameMainWindow(size_t w, size_t h) : Window {w, h, "I Like Trains", SDL_WINDOW_OPENGL}, SceneRenderer {Window::size, 0} { - uiComponents.create<ManualCameraController>(glm::vec2 {-1150, -1150}); - auto gms = uiComponents.create<GameMainSelector>(&camera, glm::vec2 {w, h}); + uiComponents.create<ManualCameraController>(Position2D {-1150, -1150}); + auto gms = uiComponents.create<GameMainSelector>(&camera, ScreenAbsCoord {w, h}); uiComponents.create<GameMainToolbar>(gms.get()); } diff --git a/ui/manualCameraController.cpp b/ui/manualCameraController.cpp index 8e52b0e..05c1fc5 100644 --- a/ui/manualCameraController.cpp +++ b/ui/manualCameraController.cpp @@ -59,7 +59,7 @@ ManualCameraController::handleInput(const SDL_Event & e, const Position &) pitch = std::clamp(pitch - 0.01F * static_cast<float>(e.motion.yrel), 0.1F, half_pi); } else { - focus += rotate_flat(-direction) * glm::vec2 {-e.motion.xrel, e.motion.yrel}; + focus += rotate_flat(-direction) * Position2D {-e.motion.xrel, e.motion.yrel}; } } return true; |