id is not set correctly, fix needed
This commit is contained in:
+25
-4
@@ -86,9 +86,15 @@ int main(){
|
||||
app.settings = graph.at("settings");
|
||||
|
||||
// app.gm = graph["graphmanager"].get<VISEQ::GRAPH::GraphManager>();
|
||||
int highest_id = 0;
|
||||
std::shared_ptr<Node> hid;
|
||||
for(auto n : graph.at("graphmanager").at("nodes")){
|
||||
std::shared_ptr<MidiNode> mn = n;
|
||||
app.gm.nodes.push_back(mn);
|
||||
if(mn->id > highest_id) {
|
||||
highest_id = mn->id;
|
||||
hid = mn;
|
||||
}
|
||||
std::cout << std::format("adding node {}", mn->id) << std::endl;
|
||||
}
|
||||
|
||||
@@ -312,9 +318,25 @@ int main(){
|
||||
case InteractionState::CONNECT_NODE:
|
||||
{
|
||||
Vec2Df connector_position = connecting_nodes.front()->position - ((connecting_nodes.front()->position - mouse_pos)).norm() * (connecting_nodes.front()->radius + 14.0f);
|
||||
Vec2Df target_position = mouse_pos;
|
||||
|
||||
if(IsKeyDown(KEY_LEFT_CONTROL)) {
|
||||
target_position.x = round((mouse_pos.x) / app.settings.grid) * app.settings.grid;
|
||||
target_position.y = round((mouse_pos.y) / app.settings.grid) * app.settings.grid;
|
||||
} else if(IsKeyDown(KEY_LEFT_SHIFT)){
|
||||
std::shared_ptr<Node> closest = app.gm.getClosestNode(mouse_pos);
|
||||
float steps = round((closest->position.dist(mouse_pos)) / app.settings.grid) * app.settings.grid;
|
||||
float pol_r = steps;
|
||||
float pol_theta = Vector2Angle(Vec2Df{1,0},(mouse_pos - closest->position));
|
||||
|
||||
Vec2Df polar = VISEQ::VMATH::polarToCartesian(pol_r, pol_theta);
|
||||
target_position = closest->position + polar;
|
||||
} else {
|
||||
target_position = mouse_pos;
|
||||
}
|
||||
|
||||
if(connecting_nodes.front()->connecting && mouse_down){
|
||||
DrawLine(connector_position.x, connector_position.y, mouse_pos.x, mouse_pos.y, (Color){229, 181, 103, 255});
|
||||
DrawLine(connector_position.x, connector_position.y, target_position.x, target_position.y, (Color){229, 181, 103, 255});
|
||||
connecting_nodes.front()->hovering = true;
|
||||
connecting_nodes.front()->hover_connect = true;
|
||||
}
|
||||
@@ -332,8 +354,7 @@ int main(){
|
||||
} else if(!hovering_connectors.empty()){
|
||||
app.gm.addConnection(connecting_nodes.front(), hovering_connectors.front());
|
||||
} else {
|
||||
//SPTR_Node new_node = app.gm.addMidiNode(mouse_pos);
|
||||
SPTR_Node new_node = app.gm.copyNode(std::dynamic_pointer_cast<MidiNode>(connecting_nodes.front()), mouse_pos);
|
||||
SPTR_Node new_node = app.gm.copyNode(std::dynamic_pointer_cast<MidiNode>(connecting_nodes.front()), target_position);
|
||||
new_node->connecting = false;
|
||||
app.gm.addConnection(connecting_nodes.front(), new_node);
|
||||
}
|
||||
@@ -422,7 +443,7 @@ int main(){
|
||||
}
|
||||
}
|
||||
}
|
||||
if(hovering_nodes.empty()){
|
||||
if(!IsKeyDown(KEY_LEFT_SHIFT) && !IsKeyDown(KEY_LEFT_CONTROL) && !IsKeyDown(KEY_LEFT_ALT)){
|
||||
Vector2 mouseWorldPos = GetScreenToWorld2D(GetMousePosition(), camera);
|
||||
camera.offset = GetMousePosition();
|
||||
camera.target = mouseWorldPos;
|
||||
|
||||
Reference in New Issue
Block a user