tcr/java/src/game/gui/element/Fill.java

58 lines
1.2 KiB
Java
Raw Normal View History

2025-03-11 14:09:49 +01:00
package game.gui.element;
2025-03-19 21:54:09 +01:00
import game.renderer.Drawing;
import game.renderer.Drawing.Vec2i;
2025-03-11 14:09:49 +01:00
public class Fill extends Element {
private final boolean left;
private final boolean top;
public Fill(int x, int y, int w, int h, String text, boolean top, boolean left) {
super(x, y, w, h, null);
this.top = top;
this.left = left;
this.setText(text);
}
public Fill(int x, int y, int w, int h, String text, boolean left) {
this(x, y, w, h, text, false, left);
}
public Fill(int x, int y, int w, int h, String text) {
this(x, y, w, h, text, false, false);
}
public Fill(int x, int y, int w, int h, boolean top, boolean left) {
this(x, y, w, h, "", top, left);
}
public Fill(int x, int y, int w, int h, boolean left) {
this(x, y, w, h, "", false, left);
}
public Fill(int x, int y, int w, int h) {
this(x, y, w, h, "", false, false);
}
public boolean canHover() {
return false;
}
2025-03-19 21:54:09 +01:00
// protected boolean isTextCenteredX() {
// return !this.left;
// }
//
// protected boolean isTextCenteredY() {
// return !this.top;
// }
2025-03-11 14:09:49 +01:00
2025-03-19 21:54:09 +01:00
public void updateText() {
Vec2i size = Drawing.getSize(this.text);
if(!this.left)
this.text_x = (this.size_x - size.xpos) / 2;
if(!this.top)
this.text_y = (this.size_y - size.ypos) / 2;
2025-03-11 14:09:49 +01:00
}
}