static id fixed

This commit is contained in:
Sebastian
2024-11-05 00:51:25 +01:00
parent dc7eae1931
commit 4a346350f4
3 changed files with 31 additions and 8 deletions
+4 -3
View File
@@ -9,9 +9,9 @@ namespace VISEQ::GRAPH {
class GraphItem{
public:
GraphItem() {newId();}
GraphItem() {newId(-1);}
GraphItem(const GraphItem& G) {
newId();
newId(-1);
graphItemType = G.graphItemType;
neighbors = G.neighbors;
}
@@ -20,8 +20,9 @@ namespace VISEQ::GRAPH {
int id = 0;
void newId(){
void newId(int start){
static int _id;
if(start > -1) _id = start;
id = _id;
_id++;
}
+14 -4
View File
@@ -9,6 +9,7 @@
#include "graph-manager.h"
#include "node.h"
#include "vmath.h"
#include <alsa/hwdep.h>
#include <filesystem>
#include <fstream>
#define RAYGUI_IMPLEMENTATION
@@ -29,8 +30,6 @@
#include <iterator>
#include <memory>
#include "state-io.h"
using json = nlohmann::json;
VISEQ::APP::AppState app;
@@ -85,16 +84,25 @@ 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;
}
}
for(auto e : graph.at("graphmanager").at("edges")){
if(e.at("id") > highest_id){
highest_id = e.at("id");
}
}
for(auto n : graph.at("graphmanager").at("nodes")){
std::shared_ptr<MidiNode> mn = n;
app.gm.nodes.push_back(mn);
std::cout << std::format("adding node {}", mn->id) << std::endl;
}
@@ -112,6 +120,8 @@ int main(){
}
app.gm.edges.back()->newId(highest_id); // reset static id counter in base class
for(auto s : graph.at("signalmanager").at("signals")){
int start_id = s.at("start").get<int>();
int next_id = s.at("next").get<int>();
+12
View File
@@ -96,6 +96,17 @@ namespace VISEQ::APP::UI{
DrawFPS(20, settings->height - 30);
}
void drawPropertiesBar(){
float left = settings->width - 280.f;
GuiPanel((Rectangle){left,-30,280,(float)settings->height + 31}, "");
const int s_controls = 25;
}
void drawPerNodeConfig(Camera2D *camera){
for(auto& n : gm->nodes | std::views::filter([](std::shared_ptr<Node> n){ return n->config; })){
Vector2 np = GetWorldToScreen2D((Vector2){n->position.x, n->position.y}, *camera);
@@ -188,6 +199,7 @@ namespace VISEQ::APP::UI{
void draw(Vec2Df *mouse_pos, Camera2D *camera){
drawSideBar();
drawPropertiesBar();
drawPerNodeConfig(camera);
}