This commit is contained in:
2026-07-05 21:14:50 +02:00
parent eaeb467db9
commit 999b51ce66
8 changed files with 251 additions and 129 deletions
@@ -0,0 +1,42 @@
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();
}
}