two direction connections with blockers working
This commit is contained in:
+21
-5
@@ -1,17 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
#include "button.h"
|
||||
#include "node.h"
|
||||
|
||||
class Connection{
|
||||
|
||||
public:
|
||||
Connection() {}
|
||||
Connection(Node* from, Node* to) : from(from), to(to) {}
|
||||
Connection(Node* v1, Node* v2) : v1(v1), v2(v2) {}
|
||||
|
||||
Node* v1;
|
||||
Node* v2;
|
||||
|
||||
bool v1_v2 = true;
|
||||
bool v2_v1 = true;
|
||||
bool active = false;
|
||||
|
||||
Node* from;
|
||||
Node* to;
|
||||
|
||||
void draw(){
|
||||
|
||||
Vec2D<float> v1_position = v1->position - ((v1->position - v2->position)).norm() * (v1->radius + 10.0f);
|
||||
Vec2D<float> v2_position = v2->position - ((v2->position - v1->position)).norm() * (v2->radius + 10.0f);
|
||||
|
||||
Color c = {229, 181, 103, 255};
|
||||
if(active) c = {108, 153, 187, 255};
|
||||
DrawLine(v1_position.x, v1_position.y, v2_position.x, v2_position.y, c);
|
||||
|
||||
Vec2D<float> from_to_handle = v1->position - ((v1->position - v2->position)).norm() * (v1->radius + 35);
|
||||
Vec2D<float> to_from_handle = v2->position - ((v2->position - v1->position)).norm() * (v2->radius + 35);
|
||||
|
||||
if(ViButton(from_to_handle.x, from_to_handle.y, 8.0f, v1_v2 ? (Color){232, 125, 62, 255} : (Color){232, 50, 32, 255} )) v1_v2 = !v1_v2;
|
||||
if(ViButton(to_from_handle.x, to_from_handle.y, 8.0f, v2_v1 ? (Color){232, 125, 62, 255} : (Color){232, 50, 32, 255} )) v2_v1 = !v2_v1;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user