From ced16a1bb9ef735a2fe44b64ac594bf9b4a7f9bf Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Wed, 19 Mar 2025 01:44:18 +0000 Subject: Replace basic rail builder UI with a ImGui version --- ui/gameMainWindow.cpp | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) (limited to 'ui/gameMainWindow.cpp') diff --git a/ui/gameMainWindow.cpp b/ui/gameMainWindow.cpp index d88bab5..c1e135b 100644 --- a/ui/gameMainWindow.cpp +++ b/ui/gameMainWindow.cpp @@ -1,10 +1,8 @@ #include "gameMainWindow.h" #include "editNetwork.h" #include "gameMainSelector.h" +#include "imgui_extras.h" #include "manualCameraController.h" -#include "modeHelper.h" -#include "toolbar.h" -#include "window.h" #include #include #include @@ -17,15 +15,33 @@ #include #include -class GameMainToolbar : Mode, public Toolbar { +class GameMainToolbar : public UIComponent { public: - explicit GameMainToolbar(GameMainSelector * gms_) : - Mode {gms_->target}, - Toolbar { - {"ui/icon/network.png", toggle>()}, + static constexpr auto TOOLBAR_HEIGHT = 54.F; + static constexpr ImVec2 TOOLBAR_ICON_SIZE {32, 32}; + + explicit GameMainToolbar(GameMainSelector * gms) : UIComponent {{{}, {}}}, gms {gms} { } + + void + render(const UIShader &, const Position &) const override + { + if (IltGui::BeginToolbar("bottomBar", ImGuiDir_Down, TOOLBAR_HEIGHT)) { + if (ImGui::ImageButton("Build rails", *buildRailsIcon, TOOLBAR_ICON_SIZE)) { + gms->target = std::make_unique>(); + } + IltGui::EndToolbar(); } + } + + bool + handleInput(const SDL_Event &, const Position &) override { + return false; } + +private: + Icon buildRailsIcon {"ui/icon/network.png"}; + GameMainSelector * gms; }; GameMainWindow::GameMainWindow(size_t w, size_t h) : WindowContent {w, h}, SceneRenderer {{w, h}, 0} -- cgit v1.2.3