102 lines
2.2 KiB
Plaintext
102 lines
2.2 KiB
Plaintext
Node nodes[] = new Node[1000];
|
|
Link links[] = new Link[6000];
|
|
|
|
int textSize = 14;
|
|
boolean darkMode = true;
|
|
|
|
void setup() {
|
|
size(800, 600);
|
|
surface.setResizable(true);
|
|
//frame.setResizable(true);
|
|
|
|
textSize(textSize);
|
|
|
|
initButtons();
|
|
|
|
/**
|
|
* When saving, a copy of the save-file is stored locally which is opened when starting the program
|
|
*/
|
|
try {
|
|
loadCSV(dataPath("save.csv"));
|
|
}
|
|
catch(Exception e) {
|
|
println("No File found, starting blank");
|
|
}
|
|
}
|
|
|
|
void draw() {
|
|
background(darkMode? 0 : 255);
|
|
|
|
/**
|
|
* Update and display links
|
|
*/
|
|
for (int i = 0; i < linkCount; i++) {
|
|
if (links[i].active) {
|
|
links[i].update();
|
|
links[i].display();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Update and display nodes
|
|
*/
|
|
for (int i = 0; i < nodeCount; i++) {
|
|
if (!nodes[i].deleted) {
|
|
nodes[i].update();
|
|
nodes[i].display();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Update and display ui, hide via exporting-flag for easy image-saving
|
|
* Not all buttons always show, that's why this isn't in a loop
|
|
*/
|
|
if (!exporting) {
|
|
textSize(14);
|
|
rectMode(CORNER);
|
|
textAlign(CORNER);
|
|
buttons[0].display();
|
|
if (i_selectedNode != -1) buttons[1].display();
|
|
if (menuOpen) {
|
|
buttons[2].display();
|
|
buttons[3].display();
|
|
buttons[4].display();
|
|
buttons[5].display();
|
|
buttons[6].display();
|
|
}
|
|
buttons[7].display();
|
|
rectMode(CENTER);
|
|
textAlign(CENTER);
|
|
textSize(textSize);
|
|
} else {
|
|
save(savePNGpath);
|
|
exporting = false;
|
|
}
|
|
|
|
/**
|
|
* Pull "wire" out of in/outlet before creating a link (see mouseReleased in ui)
|
|
*/
|
|
if (dragLink) {
|
|
stroke(darkMode? 255:0);
|
|
strokeWeight(2);
|
|
if (dragOriginLet == -1) {
|
|
line(nodes[dragOriginId].inletCenter.x, nodes[dragOriginId].inletCenter.y, mouseX, mouseY);
|
|
} else if (dragOriginLet == 1) {
|
|
line(nodes[dragOriginId].outletCenter.x, nodes[dragOriginId].outletCenter.y, mouseX, mouseY);
|
|
}
|
|
}
|
|
}
|
|
|
|
void deleteAll() {
|
|
for (int i = 0; i < nodeCount; i++) {
|
|
//nodes[i].deleted = true;
|
|
i_selectedNode = i;
|
|
deleteSelectedNode();
|
|
}
|
|
nodeCount = 0;
|
|
for (int i = 0; i < linkCount; i++) {
|
|
links[i].active = false;
|
|
}
|
|
linkCount = 0;
|
|
}
|