simple signal config added. bpm config and grid.
This commit is contained in:
+33
-7
@@ -21,6 +21,7 @@
|
||||
#include <format>
|
||||
#include <raylib.h>
|
||||
#include <raymath.h>
|
||||
#include <string>
|
||||
|
||||
#define RAYGUI_IMPLEMENTATION
|
||||
#include "raygui/raygui.h"
|
||||
@@ -121,6 +122,8 @@ int main(){
|
||||
|
||||
while(!WindowShouldClose()){
|
||||
|
||||
app.grid = round(((app.fps / (app.bpm / 60.0f)) * app.speed) / 4.0f); // from quarter notes to 16th notes = div by 4
|
||||
|
||||
Vector2 mp = GetScreenToWorld2D(GetMousePosition(), camera);
|
||||
Vec2D<float> mouse_pos = {(float)mp.x, (float)mp.y};
|
||||
Vec2D<float> cam_pos = {camera.offset.x, camera.offset.y};
|
||||
@@ -245,14 +248,22 @@ int main(){
|
||||
// Main Config Window
|
||||
GuiWindowBox((Rectangle){0,0,280,(float)app.height}, "config");
|
||||
{
|
||||
GuiLabel((Rectangle){20, 55, 240, 20}, "MIDI OUT");
|
||||
const int s_bpm = 55;
|
||||
GuiLabel((Rectangle){20, (float)s_bpm, 120, 20}, "TIMING");
|
||||
GuiLabel((Rectangle){200, (float)s_bpm, 40, 20}, std::format("{}",app.bpm).c_str());
|
||||
float _bpm = (float)app.bpm;
|
||||
GuiSlider((Rectangle){20, (float)s_bpm + 25, 240, 20}, "", "", &_bpm, 1, 300);
|
||||
app.bpm = _bpm;
|
||||
|
||||
int s_midi = 100;
|
||||
GuiLabel((Rectangle){20, (float)s_midi, 240, 20}, "MIDI OUT");
|
||||
int i = 0;
|
||||
for(auto& mo : midi.midi_out_ports){
|
||||
GuiCheckBox((Rectangle){20, 80 + i*20.0f, 20, 20}, mo.port.port_name.c_str(), &mo.enabled);
|
||||
GuiCheckBox((Rectangle){20, (float)s_midi + 25 + i*20.0f, 20, 20}, mo.port.port_name.c_str(), &mo.enabled);
|
||||
i++;
|
||||
}
|
||||
|
||||
if(GuiButton((Rectangle){20, 100 + i*20.0f, 240, 20}, "ENABLE FOR ALL")) {
|
||||
if(GuiButton((Rectangle){20, (float)s_midi + 45 + i*20.0f, 240, 20}, "ENABLE FOR ALL")) {
|
||||
for(auto &midis : midi.midi_out_ports){
|
||||
if(midis.enabled){
|
||||
for(auto &n : nodes){
|
||||
@@ -262,16 +273,31 @@ int main(){
|
||||
}
|
||||
}
|
||||
|
||||
GuiLabel((Rectangle){20, 135 + i*20.0f, 240, 20}, "SIGNALS");
|
||||
if(GuiButton((Rectangle){20, 160 + i*20.0f, 240, 20}, "ADD RANDOM SIGNAL")){
|
||||
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() % nodes.size();
|
||||
sm.addSignalAtNode(&nodes[ni]);
|
||||
}
|
||||
|
||||
GuiLabel((Rectangle){20, 185 + i*20.0f, 240, 20}, "NODES");
|
||||
if(GuiButton((Rectangle){20, 215 + i*20.0f, 240, 20}, "ADD RANDOM NODE")){
|
||||
int signal_configs = 0;
|
||||
for(auto &s : sm.signals){
|
||||
if(GuiButton((Rectangle){20,(float)s_signal+70 + signal_configs*20, 20, 20},"X")) sm.removeSignal(signal_configs);
|
||||
DrawCircle(55, s_signal+80 + signal_configs*20, 6.0F, s.color);
|
||||
float s_speed = round(s.speed*10.0f)/10.0f;
|
||||
float signal_bpm = (app.bpm / app.speed) * s_speed;
|
||||
GuiSlider((Rectangle){70, (float)s_signal+70 + signal_configs*20, 160, 20}, "", std::format("{:.1f}",signal_bpm).c_str(), &s_speed, 0.1, 24);
|
||||
s.speed = s_speed;
|
||||
signal_configs++;
|
||||
}
|
||||
|
||||
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")){
|
||||
nodes.emplace_back(Node((float)(rand() % app.width*0.5 + app.width*0.25), (float)(rand() % app.height*0.5 + app.height*0.25), 15.0f));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Per Node Config Windows
|
||||
|
||||
@@ -32,12 +32,14 @@ class SignalManager{
|
||||
}
|
||||
|
||||
void addSignalAtNode(Node *node){
|
||||
signals.emplace(signals.end(), Signal(node->position.x+1, node->position.y+1, 5.0f, app->speed)); // position + 1 or else it does not render. why? no idea!
|
||||
Color c = {(unsigned char)(232 - (rand() % 120)), (unsigned char)(125 + (int)(rand() % 120)), 62, 255};
|
||||
signals.emplace(signals.end(), Signal(node->position.x+1, node->position.y+1, 5.0f, app->speed, c)); // position + 1 or else it does not render. why? no idea!
|
||||
signals.back().next = node;
|
||||
signals.back().last = node;
|
||||
}
|
||||
|
||||
void removeSignal(Signal *signal){
|
||||
void removeSignal(int n){
|
||||
signals.erase(signals.begin() + n);
|
||||
}
|
||||
|
||||
void updateSignals(){
|
||||
|
||||
+4
-2
@@ -10,7 +10,7 @@ class Signal : public Movable{
|
||||
public:
|
||||
|
||||
Signal();
|
||||
Signal(float x, float y, float r, float s) : Movable(Vec2D<float>(x, y), Vec2D<float>(0,0), s), radius(r) {}
|
||||
Signal(float x, float y, float r, float s, Color color) : Movable(Vec2D<float>(x, y), Vec2D<float>(0,0), s), radius(r), color(color) {}
|
||||
|
||||
int id = 0;
|
||||
|
||||
@@ -23,6 +23,8 @@ class Signal : public Movable{
|
||||
|
||||
float radius;
|
||||
|
||||
Color color;
|
||||
|
||||
void update(int fps){
|
||||
|
||||
}
|
||||
@@ -31,7 +33,7 @@ class Signal : public Movable{
|
||||
|
||||
position += direction.norm() * speed;
|
||||
|
||||
DrawCircle(position.x, position.y, radius, (Color){232, 125, 62, 255});
|
||||
DrawCircle(position.x, position.y, radius, color);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user