diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2022-10-08 18:40:58 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2022-10-08 18:40:58 +0100 |
commit | 920ae293f6830833146a524345dfbf00669e785b (patch) | |
tree | b971a645b4bb3347ac1ccac31efc05b9445b4ca4 /ui/builders/join.cpp | |
parent | Move addStraight to impl.h (diff) | |
download | ilt-920ae293f6830833146a524345dfbf00669e785b.tar.bz2 ilt-920ae293f6830833146a524345dfbf00669e785b.tar.xz ilt-920ae293f6830833146a524345dfbf00669e785b.zip |
Add a rather dumb builder for joining nodes
Diffstat (limited to 'ui/builders/join.cpp')
-rw-r--r-- | ui/builders/join.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/ui/builders/join.cpp b/ui/builders/join.cpp new file mode 100644 index 0000000..90b1d61 --- /dev/null +++ b/ui/builders/join.cpp @@ -0,0 +1,43 @@ +#include "join.h" +#include <game/geoData.h> + +void +BuilderJoin::render(const Shader &) const +{ +} + +std::string +BuilderJoin::hint() const +{ + if (p1) { + return "Pick second node"; + } + return "Pick first node"; +} + +void +BuilderJoin::click(Network * network, const GeoData *, const SDL_MouseButtonEvent & e, const Ray & ray) +{ + switch (e.button) { + case SDL_BUTTON_LEFT: + if (const auto p = network->intersectRayNodes(ray)) { + if (p1) { + create(network, p1, p); + p1.reset(); + } + else { + p1 = p; + } + } + return; + case SDL_BUTTON_MIDDLE: + p1.reset(); + return; + } +} + +void +BuilderJoin::create(Network * network, const NodePtr & p1, const NodePtr & p2) const +{ + network->addJoins(p1->pos, p2->pos); +} |