blob: 90b1d618a6ea3cad09b5bf40e43584b53599fd25 (
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
|
#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);
}
|