node deletion with connection deletion and signal redistribution implemented

This commit is contained in:
Sebastian
2024-10-26 02:14:41 +02:00
parent 658bc118ef
commit c25d5b2a1a
10 changed files with 167 additions and 84 deletions
+7 -6
View File
@@ -53,7 +53,7 @@ class AppUI{
for(auto &midis : sm->midi.midi_out_ports){
if(midis.enabled){
for(auto &n : nm->nodes){
n.setMidiPort(midis.number, true);
n.second.setMidiPort(midis.number, true);
}
}
}
@@ -62,8 +62,8 @@ class AppUI{
int s_signal = s_midi + 90 + i*20;
GuiLabel((Rectangle){20, (float)s_signal, 240, 20}, "SIGNALS");
if(GuiButton((Rectangle){20, (float)s_signal + 35, 240, 20}, "ADD RANDOM SIGNAL")){
int ni = rand() % nm->nodes.size();
sm->addSignalAtNode(&nm->nodes[ni]);
int ni = nm->getRandomNode();
sm->addSignalAtNode(ni);
}
int signal_configs = 0;
@@ -81,7 +81,8 @@ class AppUI{
int s_nodes = s_signal + 60 + signal_configs*20;
GuiLabel((Rectangle){20, (float)s_nodes + 30, 240, 20}, "NODES");
if(GuiButton((Rectangle){20, (float)s_nodes + 60, 240, 20}, "ADD RANDOM NODE")){
nm->nodes.emplace_back(200.0f, 200.0f, 15.0f);
nm->addNode(200.0f, 200.0f);
// nm->nodes.emplace_back(200.0f, 200.0f, 15.0f);
}
DrawFPS(20, settings->height - 30);
@@ -89,7 +90,7 @@ class AppUI{
}
void drawPerNodeConfig(Camera2D *camera){
for(auto& n : nm->nodes | std::ranges::views::filter([](Node n){ return n.config; })){
for(auto& n : nm->nodes | std::ranges::views::values | std::views::filter([](Node n){ return n.config; })){
Vector2 np = GetWorldToScreen2D((Vector2){n.position.x, n.position.y}, *camera);
n.config = !GuiWindowBox((Rectangle){np.x + 10, np.y + 10, 240, 440}, "config");
@@ -100,7 +101,7 @@ class AppUI{
GuiLabel((Rectangle){np.x + 20, np.y + 65, 220, 20}, "SIGNALS");
if(GuiButton((Rectangle){np.x + 20, np.y + 90, 220, 20}, "ADD SIGNAL")){
sm->addSignalAtNode(&n);
sm->addSignalAtNode(n.id);
}
int y_midi = 120;