more refactoring and breaking things
This commit is contained in:
+4
-63
@@ -5,7 +5,6 @@
|
||||
#include "raylib.h"
|
||||
#include "vmath.h"
|
||||
#include <memory>
|
||||
#include <queue>
|
||||
|
||||
#define STATE state->istate
|
||||
#define SETTINGS state->settings
|
||||
@@ -88,70 +87,12 @@ namespace VISEQ::APP{
|
||||
|
||||
Color mode_color = settings.mode_colors[0];
|
||||
|
||||
void pushEvent(InteractionEvent e){
|
||||
event_queue.push_back(e);
|
||||
}
|
||||
|
||||
InteractionEvent pullEvent(){
|
||||
if(!event_queue.empty()){
|
||||
InteractionEvent e = event_queue.front();
|
||||
event_queue.pop_front();
|
||||
return e;
|
||||
}
|
||||
return {nullptr, Interaction::NONE};
|
||||
}
|
||||
|
||||
void update(Camera2D camera){
|
||||
|
||||
if(istate != old_istate) std::cout << state_string[istate] << std::endl;
|
||||
|
||||
mouse_delta = {GetMouseDelta().x, GetMouseDelta().y};
|
||||
|
||||
settings.speed = (settings.grid * 16.0f) * (settings.bpm / 120.f);
|
||||
|
||||
Vector2 mp = GetScreenToWorld2D(GetMousePosition(), camera);
|
||||
Vec2Df mouse_pos = {(float)mp.x, (float)mp.y};
|
||||
|
||||
mouse_left.down = IsMouseButtonDown(MOUSE_BUTTON_LEFT);
|
||||
mouse_left.clicked = IsMouseButtonPressed(MOUSE_BUTTON_LEFT);
|
||||
mouse_left.released = IsMouseButtonReleased(MOUSE_BUTTON_LEFT);
|
||||
|
||||
mouse_right.down = IsMouseButtonDown(MOUSE_BUTTON_RIGHT);
|
||||
mouse_right.clicked = IsMouseButtonPressed(MOUSE_BUTTON_RIGHT);
|
||||
mouse_right.released = IsMouseButtonReleased(MOUSE_BUTTON_RIGHT);
|
||||
|
||||
keys_down.ctrl = IsKeyDown(KEY_LEFT_CONTROL) || IsKeyDown(KEY_RIGHT_CONTROL);
|
||||
keys_down.shift = IsKeyDown(KEY_LEFT_SHIFT) || IsKeyDown(KEY_RIGHT_SHIFT);
|
||||
keys_down.alt = IsKeyDown(KEY_LEFT_ALT) || IsKeyDown(KEY_RIGHT_ALT);
|
||||
|
||||
keys_pressed.ctrl = IsKeyPressed(KEY_LEFT_CONTROL) || IsKeyPressed(KEY_RIGHT_CONTROL);
|
||||
keys_pressed.shift = IsKeyPressed(KEY_LEFT_SHIFT) || IsKeyPressed(KEY_RIGHT_SHIFT);
|
||||
keys_pressed.alt = IsKeyPressed(KEY_LEFT_ALT) || IsKeyPressed(KEY_RIGHT_ALT);
|
||||
|
||||
keys_released.ctrl = IsKeyReleased(KEY_LEFT_CONTROL) || IsKeyReleased(KEY_RIGHT_CONTROL);
|
||||
keys_released.shift = IsKeyReleased(KEY_LEFT_SHIFT) || IsKeyReleased(KEY_RIGHT_SHIFT);
|
||||
keys_released.alt = IsKeyReleased(KEY_LEFT_ALT) || IsKeyReleased(KEY_RIGHT_ALT);
|
||||
|
||||
screen_mouse = {round(mouse_pos.x), round(mouse_pos.y)};
|
||||
raw_mouse = {GetMousePosition().x, GetMousePosition().y};
|
||||
mod_mouse = {round(mouse_pos.x), round(mouse_pos.y)};
|
||||
|
||||
mode_color = settings.mode_colors[node_mode];
|
||||
|
||||
if(keys_down.ctrl) {
|
||||
mod_mouse.x = round(mouse_pos.x / settings.grid) * settings.grid;
|
||||
mod_mouse.y = round(mouse_pos.y / settings.grid) * settings.grid;
|
||||
}
|
||||
old_istate = istate;
|
||||
}
|
||||
void pushEvent(InteractionEvent e);
|
||||
InteractionEvent pullEvent();
|
||||
void update(Camera2D camera);
|
||||
|
||||
inline static std::shared_ptr<State> instance;
|
||||
static std::shared_ptr<State> get() {
|
||||
if(!instance){
|
||||
instance.reset(new State());
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
inline static std::shared_ptr<State> get();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user