1 package com.irtimaled.bbor.client.gui;
3 import com.irtimaled.bbor.client.interop.ClientInterop;
4 import net.minecraft.client.gui.screen.Screen;
5 import net.minecraft.client.resources.I18n;
6 import net.minecraft.util.text.StringTextComponent;
8 public abstract class ListScreen extends Screen {
9 private final Screen lastScreen;
11 private AbstractButton doneButton;
12 private ControlList controlList;
13 private SearchField searchField;
15 ListScreen(Screen lastScreen) {
16 super(new StringTextComponent("Bounding Box Outline Reloaded"));
17 this.lastScreen = lastScreen;
24 protected void onDoneClicked() {
25 ClientInterop.displayScreen(lastScreen);
29 protected void init() {
30 this.controlList = new ControlList(this.width, this.height, 48, this.height - 28);
31 this.searchField = new SearchField(this.font, this.width / 2 - 100, 22, 200, 20, this.controlList);
32 this.doneButton = new AbstractButton(this.width / 2 - 100, this.height - 24, 200, I18n.format("gui.done")) {
34 public void onPressed() {
39 this.children.add(this.doneButton);
40 this.children.add(this.controlList);
41 this.children.add(this.searchField);
45 protected abstract void setup();
48 public void render(int mouseX, int mouseY, float unknown) {
49 render(mouseX, mouseY);
52 protected void render(int mouseX, int mouseY) {
53 this.controlList.render(mouseX, mouseY);
55 this.drawCenteredString(this.font, this.title.getUnformattedComponentText(), this.width / 2, 8, 16777215);
56 this.searchField.render(mouseX, mouseY);
57 this.doneButton.render(mouseX, mouseY);
62 this.searchField.tick();
66 public boolean keyPressed(int key, int scanCode, int modifiers) {
67 return super.keyPressed(key, scanCode, modifiers) || this.searchField.keyPressed(key, scanCode, modifiers);
71 public boolean charTyped(char character, int modifiers) {
72 return this.searchField.charTyped(character, modifiers);
76 public boolean mouseScrolled(double mouseX, double mouseY, double scrollAmount) {
77 return this.controlList.mouseScrolled(mouseX, mouseY, scrollAmount);
81 public void removed() {
82 this.controlList.close();
85 ControlList getControlList() {
86 return this.controlList;
89 AbstractButton getDoneButton() {