-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgamepanelcontrol.cpp
More file actions
82 lines (66 loc) · 1.57 KB
/
gamepanelcontrol.cpp
File metadata and controls
82 lines (66 loc) · 1.57 KB
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
80
81
82
#include "gamepanelcontrol.h"
#include "gamepanel.h"
GamePanelControl::GamePanelControl(QObject *parent) : QObject(parent)
{
}
void GamePanelControl::addPanel(GamePanel *panel)
{
panels.append(panel);
}
void GamePanelControl::activatePanel(GamePanel *panel, bool activate)
{
bool block = panel->isBlocking();
QList<GamePanel*> &list = block ? activeBlockingPanels : activeNonBlockingPanels;
if (activate)
{
if (activePanels.contains(panel))
return;
if (list.isEmpty() && block)
emit blocked();
list.append(panel);
activePanels.append(panel);
}
else
{
if (!activePanels.contains(panel))
return;
list.removeAll(panel);
activePanels.removeAll(panel);
if (!block && list.isEmpty())
emit unblocked();
}
}
void GamePanelControl::paint(QPainter &p)
{
for (int i = 0; i < activePanels.count(); i++)
{
GamePanel *panel = activePanels.at(i);
panel->paint(p);
}
}
bool GamePanelControl::mouseMove(QPoint pos, int buttons)
{
bool hover = false;
for (int i = 0; i < activePanels.count(); i++)
{
GamePanel *panel = activePanels.at(i);
if (hover)
{
panel->setHover(false);
continue;
}
if (panel->mouseMove(pos, buttons))
hover = true;
}
return hover;
}
bool GamePanelControl::mouseClick(QPoint pos, int buttons)
{
for (int i = 0; i < activePanels.count(); i++)
{
GamePanel *panel = activePanels.at(i);
if (panel->mouseClick(pos, buttons))
return true;
}
return false;
}