42 lines
1.3 KiB
Java
42 lines
1.3 KiB
Java
package de.fullrisk.citrusDev.UIHelper;
|
|
|
|
import io.wispforest.owo.ui.component.LabelComponent;
|
|
import io.wispforest.owo.ui.core.AnimatableProperty;
|
|
import io.wispforest.owo.ui.core.OwoUIGraphics;
|
|
import net.minecraft.network.chat.Component;
|
|
|
|
public class ScalableLabel extends LabelComponent {
|
|
|
|
protected final AnimatableProperty<ScaleValue> scale = AnimatableProperty.of(new ScaleValue(0f));
|
|
|
|
public ScalableLabel(Component text) {
|
|
super(text);
|
|
}
|
|
|
|
public AnimatableProperty<ScaleValue> scale() {
|
|
return this.scale;
|
|
}
|
|
|
|
@Override
|
|
public void update(float delta, int mouseX, int mouseY) {
|
|
super.update(delta, mouseX, mouseY);
|
|
this.scale.update(delta);
|
|
}
|
|
|
|
@Override
|
|
public void draw(OwoUIGraphics graphics, int mouseX, int mouseY, float partialTicks, float delta) {
|
|
float s = this.scale.get().value();
|
|
|
|
float centerX = this.x() + this.width() / 2f;
|
|
float centerY = this.y() + this.height() / 2f;
|
|
|
|
graphics.pose().pushMatrix();
|
|
graphics.pose().translate(centerX, centerY);
|
|
graphics.pose().scale(s, s);
|
|
graphics.pose().translate(-centerX, -centerY);
|
|
|
|
super.draw(graphics, mouseX, mouseY, partialTicks, delta);
|
|
|
|
graphics.pose().popMatrix();
|
|
}
|
|
} |