blob: 40b84b8117b56fb2ede6c3405281aa3a91083ee2 (
plain)
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
|
package me.shedaniel.rei.gui.widget;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.Element;
import java.awt.*;
import java.util.Collections;
import java.util.List;
public class LabelWidget extends HighlightableWidget {
public int x;
public int y;
public String text;
public LabelWidget(int x, int y, String text) {
this.x = x;
this.y = y;
this.text = text;
}
@Override
public Rectangle getBounds() {
int width = font.getStringWidth(text);
return new Rectangle(x - width / 2 - 1, y - 5, width + 2, 14);
}
@Override
public List<? extends Element> children() {
return Collections.emptyList();
}
@Override
public void render(int mouseX, int mouseY, float delta) {
drawCenteredString(font, text, x, y, -1);
}
}
|