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
|
package net.tylermurphy.Minecraft.UI;
import net.tylermurphy.Minecraft.Render.Data.Mesh;
import org.joml.Vector3f;
import net.tylermurphy.Minecraft.UI.Text.TextMaster;
import net.tylermurphy.Minecraft.UI.Text.TextMeshData;
public class UIText extends UIComponent{
private String textString;
private final float fontSize;
private final Vector3f colour = new Vector3f(255f, 255f, 255f);
private final float lineMaxSize;
private int numberOfLines;
private double maxX;
private final UIFont font;
private final boolean centerText;
private boolean stretchBackdrop = false;
private Mesh mesh;
public UIText(String text, float fontSize, UIFont font, float maxLineLength ,boolean centered) {
this.textString = text;
this.fontSize = fontSize;
this.font = font;
this.lineMaxSize = maxLineLength;
this.centerText = centered;
TextMeshData data = font.loadText(this);
this.mesh = new Mesh(data.getVertexPositions().length).store(data.getVertexPositions(), 2).store(data.getTextureCoords(), 2).finish();
TextMaster.loadText(this);
}
public void remove() {
TextMaster.removeText(this);
}
public UIFont getFont() {
return font;
}
public void setColour(float r, float g, float b) {
colour.set(r, g, b);
}
public Vector3f getColour() {
return colour;
}
public int getNumberOfLines() {
return numberOfLines;
}
public int getMesh() {
return mesh.getID();
}
public int getVertexCount() {
return mesh.getVertexCount();
}
public float getFontSize() {
return fontSize;
}
public void setNumberOfLines(int number) {
this.numberOfLines = number;
}
public boolean isCentered() {
return centerText;
}
public float getMaxLineSize() {
return lineMaxSize;
}
public String getTextString() {
return textString;
}
public void setText(String textString) {
this.textString = textString;
mesh.delete();
TextMeshData data = font.loadText(this);
this.mesh = new Mesh(data.getVertexPositions().length).store(data.getVertexPositions(), 2).store(data.getTextureCoords(), 2).finish();
}
public void setMaxX(double maxX) {
this.maxX = maxX;
}
public double getMaxX() {
return maxX;
}
public void setStretchBackdrop(boolean stretchBackdrop) {
this.stretchBackdrop = stretchBackdrop;
}
public boolean getStretchBackdrop() {
return this.stretchBackdrop;
}
}
|