/
ys_LeftMenu.pde
77 lines (59 loc) · 1.65 KB
/
ys_LeftMenu.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
//
//
// LeftMenu is for turning pages. It's located at the left most side of the screen
//
class ys_LeftMenu {
float x, y;
float w; // width
float h;
ys_Button[] leftButton;
int num; // number of buttons
ys_LeftMenu(float _w, int n, float btn_h, String[][] strs) {
// width, number, height, names
x = LEFT_BAR_DEFAULT_WIDTH;
y = 0;
w = _w;
h = Height;
num = n;
leftButton = new ys_Button[num];
for (int i=0;i<num;i++) {
leftButton[i] = new ys_Button(x, y + h * 0.5 - num/2.0*(btn_h+3*scale) + i * (btn_h+3*scale), w, btn_h, strs[i]);
}
}
void render() {
pushStyle();
fill(POP_UP_COLOR); // need change
noStroke();
rectMode(CORNER);
rect(x, y, w, h);
popStyle();
for (int i=0;i<num;i++) {
leftButton[i].render(false, 18); // align(center)
}
}
void update(float posx, float posy) {
if (posx>x && posx<x+w && posy>y && posy<y+h) {
for (int i=0;i<num;i++) {
float yy = y + h*0.5 - num/2.0*leftButton[i].getHeight() + i*leftButton[i].getHeight();
if (posy > yy && posy < yy + leftButton[i].getHeight()) {
if (i<3) {
currentPage = i;
}
else if (i == 3) {
if (LA == 1) LA = 0;
else if (LA == 0) LA = 1;
}
else if (i == 4) { // help
ui.getHelpWindow().switchDisplay();
ui.getCreditWindow().setNotDisplay();
} // on -> off, off -> on
else if (i == 5) { // credit
ui.getCreditWindow().switchDisplay();
ui.getHelpWindow().setNotDisplay();
}
break;
}
}
}
}
}