2021-09-19 15:44:31 +03:00
|
|
|
//
|
|
|
|
// Created by Иван Ильин on 19.09.2021.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef SHOOTER_MOUSE_H
|
|
|
|
#define SHOOTER_MOUSE_H
|
|
|
|
|
2021-10-03 08:38:10 +03:00
|
|
|
#include <memory>
|
2021-10-28 16:58:02 +03:00
|
|
|
#include <utility>
|
2021-10-31 11:39:08 +03:00
|
|
|
|
2021-10-28 16:58:02 +03:00
|
|
|
#include "Screen.h"
|
2021-10-12 17:12:47 +03:00
|
|
|
#include "Vec2D.h"
|
2021-09-19 15:44:31 +03:00
|
|
|
|
2021-10-12 20:18:56 +03:00
|
|
|
class Mouse final {
|
2021-09-19 15:44:31 +03:00
|
|
|
private:
|
2021-10-28 16:58:02 +03:00
|
|
|
const std::shared_ptr<Screen> _screen;
|
2021-09-19 15:44:31 +03:00
|
|
|
|
|
|
|
std::map<sf::Mouse::Button, double> _tappedButtons;
|
2021-10-31 19:01:06 +03:00
|
|
|
|
2021-09-19 15:44:31 +03:00
|
|
|
public:
|
2021-10-28 16:58:02 +03:00
|
|
|
explicit Mouse(std::shared_ptr<Screen> screen) : _screen(std::move(screen)) {};
|
2021-09-19 15:44:31 +03:00
|
|
|
|
2021-10-31 11:39:08 +03:00
|
|
|
// returns true if this _button is _pressed
|
|
|
|
static bool isButtonPressed(sf::Mouse::Button button);
|
|
|
|
|
|
|
|
// returns true if this _button is tapped and 1/5 sec passed (_button bouncing problem solved)
|
|
|
|
bool isButtonTapped(sf::Mouse::Button button);
|
2021-09-19 15:44:31 +03:00
|
|
|
|
2021-10-12 17:12:47 +03:00
|
|
|
[[nodiscard]] Vec2D getMousePosition() const;
|
2021-10-31 11:39:08 +03:00
|
|
|
|
2021-10-12 17:12:47 +03:00
|
|
|
[[nodiscard]] Vec2D getMouseDisplacement() const;
|
2021-10-31 11:39:08 +03:00
|
|
|
|
2021-09-19 15:44:31 +03:00
|
|
|
void setMouseInCenter() const;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif //SHOOTER_MOUSE_H
|