From 367292e545f5a15e9dc68d60e5f4fe6835eecce1 Mon Sep 17 00:00:00 2001 From: Stephen Enders Date: Mon, 18 Jan 2021 16:26:18 -0500 Subject: Lock mouse click --- ur.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ur.cpp b/ur.cpp index eef3adb..d1f87ed 100644 --- a/ur.cpp +++ b/ur.cpp @@ -13,6 +13,8 @@ const sf::Color SEMI_TRANSPARENT = sf::Color(0xff, 0x0, 0xff, 255); GameState state = GameState::WAITING; GameState prev_state = GameState::WAITING; +bool mouse_left_locked = false; + inline void change_state(GameState next) { @@ -177,7 +179,9 @@ main() window.close(); } - if (sf::Mouse::isButtonPressed(sf::Mouse::Button::Left)) { + if (sf::Mouse::isButtonPressed(sf::Mouse::Button::Left) && + !mouse_left_locked) { + mouse_left_locked = true; // check rolling button click window.setView(view); auto mPos = window.mapPixelToCoords(sf::Mouse::getPosition(window)); @@ -211,6 +215,8 @@ main() } } window.setView(window.getDefaultView()); // reset back to main view + } else if (!sf::Mouse::isButtonPressed(sf::Mouse::Button::Left)) { + mouse_left_locked = false; } } -- cgit v1.2.3-54-g00ecf