package com.irtimaled.bbor.client.gui;
+import com.irtimaled.bbor.Versions;
import com.irtimaled.bbor.client.interop.ClientInterop;
-import net.minecraft.client.gui.IGuiEventListener;
+import net.minecraft.client.gui.Element;
import net.minecraft.client.gui.screen.Screen;
-import net.minecraft.client.resources.I18n;
-import net.minecraft.util.text.StringTextComponent;
+import net.minecraft.client.resource.language.I18n;
+import net.minecraft.client.util.math.MatrixStack;
+import net.minecraft.text.LiteralText;
+
+import java.util.List;
public abstract class ListScreen extends Screen {
private final Screen lastScreen;
+ private static final String version = Versions.build;
private AbstractButton doneButton;
private ControlList controlList;
private SearchField searchField;
ListScreen(Screen lastScreen) {
- super(new StringTextComponent("Bounding Box Outline Reloaded"));
+ super(new LiteralText("Bounding Box Outline Reloaded"));
this.lastScreen = lastScreen;
}
@Override
protected void init() {
this.controlList = this.buildList(48, this.height - 28);
- this.searchField = new SearchField(this.font, this.width / 2 - 100, 22, 200, 20, this.controlList);
- this.doneButton = new AbstractButton(this.width / 2 - 100, this.height - 24, 200, I18n.format("gui.done")) {
+ this.searchField = new SearchField(this.textRenderer, this.width / 2 - 100, 22, 200, 20, this.controlList);
+ this.doneButton = new AbstractButton(this.width / 2 - 100, this.height - 24, 200, I18n.translate("gui.done")) {
@Override
public void onPressed() {
onDoneClicked();
}
};
- this.children.add(this.searchField);
- this.children.add(this.controlList);
- this.children.add(this.doneButton);
+ this.addDrawableChild(this.searchField);
+ ((List<Element>)this.children()).add(controlList);
+ this.addDrawableChild(this.doneButton);
}
protected abstract ControlList buildList(int top, int bottom);
@Override
- public void render(int mouseX, int mouseY, float unknown) {
- render(mouseX, mouseY);
+ public void render(MatrixStack matrixStack, int mouseX, int mouseY, float unknown) {
+ render(matrixStack, mouseX, mouseY);
}
- protected void render(int mouseX, int mouseY) {
- this.controlList.render(mouseX, mouseY);
+ protected void render(MatrixStack matrixStack, int mouseX, int mouseY) {
+ this.controlList.render(matrixStack, mouseX, mouseY);
+
+ this.drawCenteredText(matrixStack, this.textRenderer, this.title.asString(), this.width / 2, 8, 16777215);
+ this.searchField.render(matrixStack, mouseX, mouseY);
+ this.doneButton.render(matrixStack, mouseX, mouseY);
- this.drawCenteredString(this.font, this.title.getUnformattedComponentText(), this.width / 2, 8, 16777215);
- this.searchField.render(mouseX, mouseY);
- this.doneButton.render(mouseX, mouseY);
+ int left = this.width - this.textRenderer.getWidth(version) - 2;
+ int top = this.height - 10;
+ this.drawStringWithShadow(matrixStack, this.textRenderer, version, left, top, -10658467);
}
@Override
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
- for (IGuiEventListener control : this.children()) {
+ for (Element control : this.children()) {
if (control.mouseClicked(mouseX, mouseY, button)) {
- IGuiEventListener focused = getFocused();
+ Element focused = getFocused();
if (focused instanceof IFocusableControl && focused != control) {
((IFocusableControl) focused).clearFocus();
}