2018-05-13 18:43:49 +02:00
|
|
|
package com.minelittlepony.gui;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
import com.mumfrey.liteloader.modconfig.ConfigPanel;
|
|
|
|
import com.mumfrey.liteloader.modconfig.ConfigPanelHost;
|
|
|
|
|
|
|
|
import net.minecraft.client.Minecraft;
|
|
|
|
import net.minecraft.client.gui.GuiButton;
|
2018-07-27 14:27:32 +02:00
|
|
|
|
2018-05-13 18:43:49 +02:00
|
|
|
|
|
|
|
/**
|
2018-07-27 14:27:32 +02:00
|
|
|
* A GuiScreen that doubles as a liteloader panel. What is this madness!?
|
2018-05-13 18:43:49 +02:00
|
|
|
*/
|
2018-07-27 14:27:32 +02:00
|
|
|
public abstract class SettingsPanel extends GameGui implements ConfigPanel {
|
|
|
|
|
|
|
|
private boolean isInPanel = false;
|
2018-05-13 18:43:49 +02:00
|
|
|
|
|
|
|
private int contentHeight;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getPanelTitle() {
|
2018-07-27 14:27:32 +02:00
|
|
|
return translate(getTitle());
|
2018-05-13 18:43:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getContentHeight() {
|
|
|
|
return contentHeight + 40;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected <T extends GuiButton> T addButton(T button) {
|
|
|
|
if (button.y > contentHeight) {
|
|
|
|
contentHeight = button.y;
|
|
|
|
}
|
|
|
|
return super.addButton(button);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onPanelShown(ConfigPanelHost host) {
|
|
|
|
mc = Minecraft.getMinecraft();
|
|
|
|
width = host.getWidth();
|
2018-05-15 16:24:47 +02:00
|
|
|
buttonList.clear();
|
2018-05-13 18:43:49 +02:00
|
|
|
initGui();
|
2018-07-27 14:27:32 +02:00
|
|
|
isInPanel = true;
|
2018-05-13 18:43:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onPanelResize(ConfigPanelHost host) {
|
|
|
|
width = host.getWidth();
|
2018-05-15 16:24:47 +02:00
|
|
|
buttonList.clear();
|
2018-05-13 18:43:49 +02:00
|
|
|
initGui();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onPanelHidden() {
|
2018-07-27 14:27:32 +02:00
|
|
|
isInPanel = false;
|
2018-05-13 18:43:49 +02:00
|
|
|
onGuiClosed();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onTick(ConfigPanelHost host) {
|
|
|
|
updateScreen();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void drawPanel(ConfigPanelHost host, int mouseX, int mouseY, float partialTicks) {
|
|
|
|
drawScreen(mouseX, mouseY, partialTicks);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void mousePressed(ConfigPanelHost host, int mouseX, int mouseY, int mouseButton) {
|
|
|
|
try {
|
|
|
|
mouseClicked(mouseX, mouseY, mouseButton);
|
|
|
|
} catch (IOException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void mouseReleased(ConfigPanelHost host, int mouseX, int mouseY, int mouseButton) {
|
|
|
|
mouseReleased(mouseX, mouseY, mouseButton);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void mouseMoved(ConfigPanelHost host, int mouseX, int mouseY) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void keyPressed(ConfigPanelHost host, char keyChar, int keyCode) {
|
|
|
|
try {
|
|
|
|
keyTyped(keyChar, keyCode);
|
|
|
|
} catch (IOException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void drawWorldBackground(int tint) {
|
2018-07-27 14:27:32 +02:00
|
|
|
if (!isInPanel) {
|
|
|
|
super.drawWorldBackground(tint);
|
|
|
|
}
|
2018-05-13 18:43:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
protected boolean mustScroll() {
|
2018-07-27 14:27:32 +02:00
|
|
|
return isInPanel;
|
2018-05-13 18:43:49 +02:00
|
|
|
}
|
|
|
|
|
2018-07-27 14:27:32 +02:00
|
|
|
protected abstract String getTitle();
|
2018-05-13 18:43:49 +02:00
|
|
|
}
|