blob: 72e0955ed3513ebc2ac3eb7ee197511a08f7b29f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#pragma once
#include "gameMainSelector.h"
#include "modeHelper.hpp"
#include "toolbar.h"
#include "worldOverlay.h"
#include <game/gamestate.h>
#include <game/network/network.h>
#include <optional>
class Ray;
class EditNetwork : public GameMainSelector::Component, public WorldOverlay {
public:
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<glm::vec3, NodePtr>;
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<Builder>;
Network * network;
BuilderPtr builder;
Mode<BuilderPtr, ModeSecondClick::NoAction> mode {builder};
Toolbar builderToolbar;
};
template<typename T> class EditNetworkOf : public EditNetwork {
public:
template<typename... P>
EditNetworkOf(P &&... p) : EditNetwork(gameState->world.findOrCreate<T>(), std::forward<P>(p)...)
{
}
};
|