-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProfileScreen.pde
190 lines (166 loc) · 6.2 KB
/
ProfileScreen.pde
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
//this class is used for displaying the users profile
class ProfileScreen {
//declare a variable to store a reference to the class that called it
private RedPanda context;
//create image arrays to store the button images
private PImage[] close = new PImage[3];
//create a Gp5 group for this screen
private Group profileGroup;
//create array to store the buttons
private Button []buttons;
//create array to store the textlabels
private Textlabel [] textlabels;
//Boolean start for timer
//Timer int for timer seconds count
boolean start = false;
int timer;
//constructor set the context to the class that called it
public ProfileScreen(RedPanda c) {
this.context = c;
}
//this function loads the assets used by the class
void loadImages() {
//load images for UI
this.close[0] = loadImage("images/close.png");
this.close[1] =loadImage("images/closeover.png");
this.close[2] = this.close[0];
}
//create the programmes screen UI
public void create() {
start = false;
cp5.setAutoDraw(false);
//create a group for this screen
profileGroup = cp5.addGroup("profileGroup")
.setPosition(700, 65)
.setSize(260, 400)
.setBackgroundColor(color(62, 151, 139))
.hideBar()
;
//initialise the button array
//initialist the textlabels array
buttons = new Button[1];
textlabels = new Textlabel[7];
//create a profile close button, set its image, group and posistion
buttons[0] = cp5.addButton("profileClose")
.setPosition(220, -20)
.setImages(close)
.updateSize()
.setGroup(profileGroup)
;
//create an name textlabel, set its image, group and posistion
textlabels[0] = cp5.addTextlabel("name")
.setText("Name : \n" + user.getLast_name() + ", " + user.getFirst_name())
.setPosition(10, 10)
.setColorValue(0xffffffff)
.setFont(createFont("Arial", 18))
.setGroup(profileGroup)
;
//create an age textlabel, set its image, group and posistion
textlabels[1] = cp5.addTextlabel("age")
.setText("\nDOB : \n" + user.getDob())
.setPosition(10, 35)
.setColorValue(0xffffffff)
.setFont(createFont("Arial", 18))
.setGroup(profileGroup)
;
//create a gender textlabel, set its image, group and posistion
textlabels[2] = cp5.addTextlabel("gender")
.setText("\nGender : \n" + user.getSex() )
.setPosition(10, 80)
.setColorValue(0xffffffff)
.setFont(createFont("Arial", 18))
.setGroup(profileGroup)
;
//create an height textlabel, set its image, group and posistion
textlabels[3] = cp5.addTextlabel("height")
.setText("\nHeight : \n" + user.getHeight() + "cm")
.setPosition(10, 125)
.setColorValue(0xffffffff)
.setFont(createFont("Arial", 18))
.setGroup(profileGroup)
;
//create an weight textlabel, set its image, group and posistion
textlabels[4] = cp5.addTextlabel("weight")
.setText("\nWeight : \n" + user.getWeight() + "kg")
.setPosition(10, 175)
.setColorValue(0xffffffff)
.setFont(createFont("Arial", 18))
.setGroup(profileGroup)
;
//create an injury textlabel, set its image, group and posistion
textlabels[5] = cp5.addTextlabel("injury")
.setText("\nInjury type : \n" + user.getInjury_type())
.setPosition(10, 225)
.setColorValue(0xffffffff)
.setFont(createFont("Arial", 18))
.setGroup(profileGroup)
;
//create a program textlabel, set its image, group and posistion
textlabels[6] = cp5.addTextlabel("programmeDesc")
.setText("\nProgramme \n: Shoulder Stretching")
.setPosition(10, 280)
.setColorValue(0xffffffff)
.setFont(createFont("Arial", 18))
.setGroup(profileGroup)
;
}
//CheckBtn called from main file, sending in the converted 3d perspective
//positioning of the left and right hand into a flat plane
void checkBtn(PVector convertedLeftJoint, PVector convertedRightJoint ) {
//set PVectors to vectors sent in
PVector leftHand = convertedLeftJoint;
PVector rightHand = convertedRightJoint;
//If left hand x position is within the boundaries of the close profile button
//Start is set to false initially, once left hand x is within these boundaries start will be set to true
//the timer will be set and loaderOn() is called, which changes the hand image to a loader gif
if (leftHand.x > (910/2.5) && leftHand.x < (970/2.5) && leftHand.y > (20/2.5) && leftHand.y < (80/2.5))
{
if (start == false) {
println("Close Profile Called");
start = true;
timer = millis();
loaderOn();
}
if (checkTimer()) {
makeProfileClose();
}
}
//If left hand position goes outside the boundaries of the button set start to false again
//Turn off loading gif image, replace for hand image.
else {
start = false;
loaderOff();
}
}
//checkTimer will only return true if passed time is greater than the total time set.
public boolean checkTimer() {
int totalTime = 5000;
boolean checkInt = false;
if (start) {
int passedTime = millis() - timer;
if (passedTime > totalTime) {
checkInt = true;
}
else {
checkInt = false;
}
}
return checkInt;
}
//this function draws the cp5 object UI elements as well as the demo exercise gifs
void drawUI() {
cp5.draw();
}
//this function is called to remove the buttons, group UI elements and to stop the demo gifs
void destroy() {
for ( int i = 0 ; i < buttons.length ; i++ ) {//loop through all the button and
buttons[i].remove(); //remove them
buttons[i] = null;
}
for ( int i = 0 ; i < textlabels.length ; i++ ) { //loop through all the button and
textlabels[i].remove(); //remove them
textlabels[i] = null;
}
cp5.getGroup("profileGroup").remove(); //remove the UI group from the cp5 object for this screen
}
}