-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScene.pde
71 lines (61 loc) · 2.04 KB
/
Scene.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
public class Scene implements Showable{
private TextBox[] text_boxes;
private Button[] buttons;
public Scene(TextBox[] new_text_boxes) {
assert(new_text_boxes != null);
text_boxes = new_text_boxes;
buttons = new Button[0];
}
public Scene(TextBox[] new_text_boxes, Button[] new_buttons) {
this(new_text_boxes);
assert(new_buttons != null);
buttons = new_buttons;
}
public Scene(TextBox[][] new_text_boxes) {
assert(new_text_boxes != null);
ArrayList<TextBox> boxes = new ArrayList<TextBox>();
for (int i = 0; i < new_text_boxes.length; i++) {
for(int j = 0; j < new_text_boxes[i].length; j++) {
if (new_text_boxes[i][j] instanceof TextBox) {
boxes.add(new_text_boxes[i][j]);
}
}
}
text_boxes = boxes.toArray(new TextBox[boxes.size()]);
buttons = new Button[0];
}
public Scene(TextBox[][] new_text_boxes, Button[] new_buttons) {
this(new_text_boxes);
assert(new_buttons != null);
buttons = new Button[0];
}
public TextBox[] get_text_boxes() {
return text_boxes;
}
public Button[] get_buttons() {
return buttons;
}
public void show(float leading_scalar, float horizontal_scalar, float vertical_scalar) {
float min_size = find_minimum_font_size_in_group(get_text_boxes(), leading_scalar, horizontal_scalar, vertical_scalar);
for (TextBox box : get_text_boxes()) {
box.show(min_size, leading_scalar, horizontal_scalar, vertical_scalar);
}
}
@Override
public void show() {
float leading_scalar = 5f / 3;
float horizontal_scalar = 2f / 3;
float vertical_scalar = 1f;
float min_size = find_minimum_font_size_in_group(get_text_boxes(), leading_scalar, horizontal_scalar, vertical_scalar);
for (TextBox box : get_text_boxes()) {
box.show(min_size, leading_scalar, horizontal_scalar, vertical_scalar);
}
}
@Override
public void cleanup() {
for (int i = 0; i < get_buttons().length; i++) {
get_buttons()[i].cleanup();
}
cleanup_scenes.add(this);
}
}