76 lines
2.3 KiB
Java
76 lines
2.3 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*/
|
|
package net.minecraft.client.gui.components;
|
|
|
|
import net.minecraft.client.gui.Font;
|
|
import net.minecraft.client.gui.GuiGraphics;
|
|
import net.minecraft.client.gui.components.AbstractTextAreaWidget;
|
|
import net.minecraft.client.gui.components.MultiLineTextWidget;
|
|
import net.minecraft.client.gui.narration.NarratedElementType;
|
|
import net.minecraft.client.gui.narration.NarrationElementOutput;
|
|
import net.minecraft.network.chat.Component;
|
|
|
|
public class FittingMultiLineTextWidget
|
|
extends AbstractTextAreaWidget {
|
|
private final Font font;
|
|
private final MultiLineTextWidget multilineWidget;
|
|
|
|
public FittingMultiLineTextWidget(int x, int y, int width, int height, Component message, Font font) {
|
|
super(x, y, width, height, message);
|
|
this.font = font;
|
|
this.multilineWidget = new MultiLineTextWidget(message, font).setMaxWidth(this.getWidth() - this.totalInnerPadding());
|
|
}
|
|
|
|
@Override
|
|
public void setWidth(int width) {
|
|
super.setWidth(width);
|
|
this.multilineWidget.setMaxWidth(this.getWidth() - this.totalInnerPadding());
|
|
}
|
|
|
|
@Override
|
|
protected int getInnerHeight() {
|
|
return this.multilineWidget.getHeight();
|
|
}
|
|
|
|
public void minimizeHeight() {
|
|
if (!this.showingScrollBar()) {
|
|
this.setHeight(this.getInnerHeight() + this.totalInnerPadding());
|
|
}
|
|
}
|
|
|
|
@Override
|
|
protected double scrollRate() {
|
|
return this.font.lineHeight;
|
|
}
|
|
|
|
@Override
|
|
protected void renderBackground(GuiGraphics graphics) {
|
|
super.renderBackground(graphics);
|
|
}
|
|
|
|
public boolean showingScrollBar() {
|
|
return super.scrollbarVisible();
|
|
}
|
|
|
|
@Override
|
|
protected void renderContents(GuiGraphics graphics, int mouseX, int mouseY, float a) {
|
|
graphics.pose().pushMatrix();
|
|
graphics.pose().translate((float)this.getInnerLeft(), (float)this.getInnerTop());
|
|
this.multilineWidget.render(graphics, mouseX, mouseY, a);
|
|
graphics.pose().popMatrix();
|
|
}
|
|
|
|
@Override
|
|
protected void updateWidgetNarration(NarrationElementOutput output) {
|
|
output.add(NarratedElementType.TITLE, this.getMessage());
|
|
}
|
|
|
|
@Override
|
|
public void setMessage(Component message) {
|
|
super.setMessage(message);
|
|
this.multilineWidget.setMessage(message);
|
|
}
|
|
}
|
|
|