global mouse moved to state and removed some GetMousePosition()s.
This commit is contained in:
+9
-15
@@ -5,7 +5,7 @@
|
||||
* 2024 Sebastian Kujas
|
||||
*
|
||||
*/
|
||||
#include "globals.h"
|
||||
#include "state.h"
|
||||
#include "datatypes.h"
|
||||
#include "graph-manager.h"
|
||||
#include "node.h"
|
||||
@@ -83,7 +83,7 @@ int main(){
|
||||
std::ifstream f("state.json");
|
||||
json graph = json::parse(f);
|
||||
|
||||
state->settings = graph.at("settings");
|
||||
// state->settings = graph.at("settings");
|
||||
|
||||
int highest_id = 0;
|
||||
std::shared_ptr<Node> hid;
|
||||
@@ -196,8 +196,9 @@ int main(){
|
||||
|
||||
Vec2Df mouse_delta = {GetMouseDelta().x, GetMouseDelta().y};
|
||||
Vec2Df delta = mouse_delta * (-1.0f/camera.zoom);
|
||||
|
||||
state->raw_mouse = mouse_pos;
|
||||
|
||||
state->screen_mouse = mouse_pos;
|
||||
state->raw_mouse = {GetMousePosition().x, GetMousePosition().y};
|
||||
state->mod_mouse = mouse_pos;
|
||||
|
||||
if(IsKeyDown(KEY_LEFT_CONTROL)) {
|
||||
@@ -513,22 +514,15 @@ int main(){
|
||||
/* break;*/
|
||||
/* }*/
|
||||
/*};*/
|
||||
if(mouse_right_down) {
|
||||
camera.target = Vector2Add(camera.target, delta);
|
||||
}
|
||||
|
||||
float wheel = GetMouseWheelMove();
|
||||
if(wheel != 0){
|
||||
if(!hovering_nodes.empty() && hovering_nodes.front()->getNodeType() == NodeType::MIDINODE) {
|
||||
VEC_SPTR_Node modify_nodes;
|
||||
std::copy_if(selected_nodes.begin(), selected_nodes.end(), std::back_inserter(modify_nodes), [](SPTR_Node n){ return n->getNodeType() == NodeType::MIDINODE;});
|
||||
if(selected_nodes.empty()) std::copy_if(hovering_nodes.begin(), hovering_nodes.end(), std::back_inserter(modify_nodes), [modify_nodes](SPTR_Node n){ return n->getNodeType() == NodeType::MIDINODE && !std::ranges::contains(modify_nodes, n);});
|
||||
|
||||
for(auto n : modify_nodes){
|
||||
std::shared_ptr<MidiNode> midiNode = std::dynamic_pointer_cast<MidiNode>(n);
|
||||
}
|
||||
}
|
||||
if(!IsKeyDown(KEY_LEFT_SHIFT) && !IsKeyDown(KEY_LEFT_CONTROL) && !IsKeyDown(KEY_LEFT_ALT)){
|
||||
Vector2 mouseWorldPos = GetScreenToWorld2D(GetMousePosition(), camera);
|
||||
camera.offset = GetMousePosition();
|
||||
camera.target = mouseWorldPos;
|
||||
camera.target = mouse_pos;
|
||||
float scaleFactor = 1.0f + (0.25f*fabsf(wheel));
|
||||
if (wheel < 0) scaleFactor = 1.0f/scaleFactor;
|
||||
camera.zoom = Clamp(camera.zoom*scaleFactor, 0.125f, 64.0f);
|
||||
|
||||
Reference in New Issue
Block a user