summaryrefslogtreecommitdiff
path: root/ui/editNetwork.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2022-10-08 17:04:40 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2022-10-08 17:04:40 +0100
commitf6890e8077133b5dd2cc0a92270d2a328d6c5ab9 (patch)
treee24cf13bf3e5d90409ed46a86f87668718e48fcf /ui/editNetwork.cpp
parentAdd collection methods for finding and/or creating objects (diff)
downloadilt-f6890e8077133b5dd2cc0a92270d2a328d6c5ab9.tar.bz2
ilt-f6890e8077133b5dd2cc0a92270d2a328d6c5ab9.tar.xz
ilt-f6890e8077133b5dd2cc0a92270d2a328d6c5ab9.zip
Initial commit of a basic working network editor
Diffstat (limited to 'ui/editNetwork.cpp')
-rw-r--r--ui/editNetwork.cpp48
1 files changed, 42 insertions, 6 deletions
diff --git a/ui/editNetwork.cpp b/ui/editNetwork.cpp
index 6cf0eae..a51d7fb 100644
--- a/ui/editNetwork.cpp
+++ b/ui/editNetwork.cpp
@@ -1,17 +1,53 @@
#include "editNetwork.h"
+#include "builders/straight.h"
+#include "text.h"
+#include <game/gamestate.h>
+#include <game/geoData.h>
-void
-EditNetwork::click(const Ray &)
+EditNetwork::EditNetwork(Network * n) :
+ network {n}, builderToolbar {
+ {"ui/icon/network.png", mode.toggle<BuilderStraight>()},
+ }
{
}
-void
-EditNetwork::move(const Ray &)
+EditNetwork::~EditNetwork() = default;
+
+bool
+EditNetwork::click(const SDL_MouseButtonEvent & e, const Ray & ray)
+{
+ if (builder) {
+ builder->click(network, gameState->geoData.get(), e, ray);
+ return true;
+ }
+ return false;
+}
+
+bool
+EditNetwork::move(const SDL_MouseMotionEvent &, const Ray &)
{
+ return false;
}
bool
-EditNetwork::handleMove()
+EditNetwork::handleInput(const SDL_Event & e, const UIComponent::Position & parentPos)
+{
+ return builderToolbar.handleInput(e, parentPos);
+}
+
+void
+EditNetwork::render(const Shader & shader) const
+{
+ if (builder) {
+ builder->render(shader);
+ }
+}
+
+void
+EditNetwork::render(const UIShader & shader, const UIComponent::Position & parentPos) const
{
- return true;
+ if (builder) {
+ Text {builder->hint(), {{50, 10}, {0, 15}}, {1, 1, 0}}.render(shader, parentPos);
+ }
+ builderToolbar.render(shader, parentPos);
}