From f6890e8077133b5dd2cc0a92270d2a328d6c5ab9 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 8 Oct 2022 17:04:40 +0100 Subject: Initial commit of a basic working network editor --- ui/editNetwork.h | 45 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 4 deletions(-) (limited to 'ui/editNetwork.h') diff --git a/ui/editNetwork.h b/ui/editNetwork.h index 0a27609..72e0955 100644 --- a/ui/editNetwork.h +++ b/ui/editNetwork.h @@ -1,12 +1,49 @@ #pragma once #include "gameMainSelector.h" +#include "modeHelper.hpp" +#include "toolbar.h" +#include "worldOverlay.h" +#include +#include +#include class Ray; -class EditNetwork : public GameMainSelector::ClickReceiver { +class EditNetwork : public GameMainSelector::Component, public WorldOverlay { public: - void click(const Ray &) override; - void move(const Ray &) override; - bool handleMove() override; + explicit EditNetwork(Network *); + virtual ~EditNetwork(); + + bool click(const SDL_MouseButtonEvent & e, const Ray &) override; + bool move(const SDL_MouseMotionEvent & e, const Ray &) override; + bool handleInput(const SDL_Event & e, const UIComponent::Position &) override; + void render(const Shader &) const override; + void render(const UIShader & shader, const UIComponent::Position & pos) const override; + + using NetworkClickPos = std::variant; + + class Builder { + public: + virtual ~Builder() = default; + virtual void render(const Shader & shader) const = 0; + virtual std::string hint() const = 0; + virtual void click(Network *, const GeoData *, const SDL_MouseButtonEvent &, const Ray &) = 0; + }; + +private: + using BuilderPtr = std::unique_ptr; + + Network * network; + BuilderPtr builder; + Mode mode {builder}; + Toolbar builderToolbar; +}; + +template class EditNetworkOf : public EditNetwork { +public: + template + EditNetworkOf(P &&... p) : EditNetwork(gameState->world.findOrCreate(), std::forward

(p)...) + { + } }; -- cgit v1.2.3