static id fixed
This commit is contained in:
+4
-3
@@ -9,9 +9,9 @@ namespace VISEQ::GRAPH {
|
|||||||
class GraphItem{
|
class GraphItem{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GraphItem() {newId();}
|
GraphItem() {newId(-1);}
|
||||||
GraphItem(const GraphItem& G) {
|
GraphItem(const GraphItem& G) {
|
||||||
newId();
|
newId(-1);
|
||||||
graphItemType = G.graphItemType;
|
graphItemType = G.graphItemType;
|
||||||
neighbors = G.neighbors;
|
neighbors = G.neighbors;
|
||||||
}
|
}
|
||||||
@@ -20,8 +20,9 @@ namespace VISEQ::GRAPH {
|
|||||||
|
|
||||||
int id = 0;
|
int id = 0;
|
||||||
|
|
||||||
void newId(){
|
void newId(int start){
|
||||||
static int _id;
|
static int _id;
|
||||||
|
if(start > -1) _id = start;
|
||||||
id = _id;
|
id = _id;
|
||||||
_id++;
|
_id++;
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-4
@@ -9,6 +9,7 @@
|
|||||||
#include "graph-manager.h"
|
#include "graph-manager.h"
|
||||||
#include "node.h"
|
#include "node.h"
|
||||||
#include "vmath.h"
|
#include "vmath.h"
|
||||||
|
#include <alsa/hwdep.h>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#define RAYGUI_IMPLEMENTATION
|
#define RAYGUI_IMPLEMENTATION
|
||||||
@@ -29,8 +30,6 @@
|
|||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "state-io.h"
|
|
||||||
|
|
||||||
using json = nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
VISEQ::APP::AppState app;
|
VISEQ::APP::AppState app;
|
||||||
@@ -85,16 +84,25 @@ int main(){
|
|||||||
|
|
||||||
app.settings = graph.at("settings");
|
app.settings = graph.at("settings");
|
||||||
|
|
||||||
// app.gm = graph["graphmanager"].get<VISEQ::GRAPH::GraphManager>();
|
|
||||||
int highest_id = 0;
|
int highest_id = 0;
|
||||||
std::shared_ptr<Node> hid;
|
std::shared_ptr<Node> hid;
|
||||||
for(auto n : graph.at("graphmanager").at("nodes")){
|
for(auto n : graph.at("graphmanager").at("nodes")){
|
||||||
std::shared_ptr<MidiNode> mn = n;
|
std::shared_ptr<MidiNode> mn = n;
|
||||||
app.gm.nodes.push_back(mn);
|
|
||||||
if(mn->id > highest_id) {
|
if(mn->id > highest_id) {
|
||||||
highest_id = mn->id;
|
highest_id = mn->id;
|
||||||
hid = mn;
|
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;
|
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")){
|
for(auto s : graph.at("signalmanager").at("signals")){
|
||||||
int start_id = s.at("start").get<int>();
|
int start_id = s.at("start").get<int>();
|
||||||
int next_id = s.at("next").get<int>();
|
int next_id = s.at("next").get<int>();
|
||||||
|
|||||||
@@ -96,6 +96,17 @@ namespace VISEQ::APP::UI{
|
|||||||
DrawFPS(20, settings->height - 30);
|
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){
|
void drawPerNodeConfig(Camera2D *camera){
|
||||||
for(auto& n : gm->nodes | std::views::filter([](std::shared_ptr<Node> n){ return n->config; })){
|
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);
|
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){
|
void draw(Vec2Df *mouse_pos, Camera2D *camera){
|
||||||
drawSideBar();
|
drawSideBar();
|
||||||
|
drawPropertiesBar();
|
||||||
drawPerNodeConfig(camera);
|
drawPerNodeConfig(camera);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user