This repository was archived by the owner on Sep 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathInputHandler.cpp
81 lines (66 loc) · 1.44 KB
/
InputHandler.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include "InputHandler.h"
#include <sstream>
#include <utility>
using namespace sf;
using namespace std;
void InputHandler::init(ScreenManagerRemoteControl* smrc,
vector<shared_ptr<Button>> buttons,
View* pointerToUIView, Screen* parentScreen)
{
_smrc = smrc;
_buttons = std::move(buttons);
_pointerToUIPanelView = pointerToUIView;
_parentScreen = parentScreen;
}
void InputHandler::handleInput(RenderWindow& window, Event& event)
{
if (event.type == Event::KeyPressed)
{
handleKeyPressed(event, window);
}
if (event.type == Event::KeyReleased)
{
handleKeyReleased(event, window);
}
if (event.type == Event::MouseButtonReleased)
{
auto i = _buttons.begin();
const auto end = _buttons.end();
for(i; i!= end; ++i)
{
const Vector2f position = window.mapPixelToCoords(
Mouse::getPosition(),
(*getPointerToUIView()));
if ((*i)->collider.contains(position));
{
handleLeftClick((*i)->text, window);
break;
}
}
}
handleGamepad();
}
void InputHandler::handleGamepad()
{
return;
}
void InputHandler::handleKeyPressed(Event& event, RenderWindow& window)
{
return;
}
void InputHandler::handleLeftClick(string& buttonInteractedWith, RenderWindow& window)
{
return;
}
View* InputHandler::getPointerToUIView() const
{
return _pointerToUIPanelView;
}
ScreenManagerRemoteControl* InputHandler::getPointerToSMRC() const
{
return _smrc;
}
Screen* InputHandler::getParentScreen() const
{
return _parentScreen;
}