/
ControlSuper.cpp
executable file
·110 lines (90 loc) · 2.16 KB
/
ControlSuper.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#include "ControlSuper.h"
#include "TouchControls.h"
using namespace touchcontrols;
ControlSuper::ControlSuper(int type_, std::string t, RectF pos)
{
controlPos = pos;
controlPos.left /= ScaleX;
controlPos.right /= ScaleX;
controlPos.top /= ScaleY;
controlPos.bottom /= ScaleY;
type = type_;
tag = t;
enabled = true;
hidden = false;
editable = true;
allowPassThrough = true;
color = COLOUR_NONE; // 0 means use default
}
bool ControlSuper::gamepadInput(bool down, GamePadKey key)
{
// By default controls do no handle a gamepad
return false;
}
ControlSuper::~ControlSuper()
{
}
bool ControlSuper::UI_drawGL(bool UIActive)
{
return drawGL(UIActive);
}
void ControlSuper::setEnabled(bool v)
{
enabled = v;
}
void ControlSuper::setHidden(bool v)
{
hidden = v;
}
bool ControlSuper::isEnabled()
{
return enabled;
}
bool ControlSuper::isHidden()
{
return hidden;
}
void ControlSuper::setAllowPassThrough(bool v)
{
allowPassThrough = v;
}
bool ControlSuper::isAllowPassThrough()
{
return allowPassThrough;
}
void ControlSuper::setEditable(bool v)
{
editable = v;
}
bool ControlSuper::isEditable()
{
return editable;
}
void ControlSuper::scaleSize(float x, float y)
{
controlPos.scale(x, y);
}
void ControlSuper::positionTranslate(float dx, float dy)
{
controlPos.offset(dx, dy);
}
void ControlSuper::saveXML(TiXmlElement &root)
{
root.SetAttribute("enabled", enabled);
root.SetAttribute("hidden", hidden);
root.SetDoubleAttribute("left", controlPos.left);
root.SetDoubleAttribute("right", controlPos.right);
root.SetDoubleAttribute("top", controlPos.top);
root.SetDoubleAttribute("bottom", controlPos.bottom);
root.SetAttribute("color", color);
}
void ControlSuper::loadXML(TiXmlElement &root)
{
root.QueryBoolAttribute("enabled", &enabled);
root.QueryBoolAttribute("hidden", &hidden);
root.QueryFloatAttribute("left", &controlPos.left);
root.QueryFloatAttribute("right", &controlPos.right);
root.QueryFloatAttribute("top", &controlPos.top);
root.QueryFloatAttribute("bottom", &controlPos.bottom);
root.QueryUnsignedAttribute("color", &color);
}