2016-11-10 19:50:01 +01:00
|
|
|
/*
|
|
|
|
* This file ("GuiBooklet.java") is part of the Actually Additions mod for Minecraft.
|
|
|
|
* It is created and owned by Ellpeck and distributed
|
|
|
|
* under the Actually Additions License to be found at
|
|
|
|
* http://ellpeck.de/actaddlicense
|
|
|
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
|
|
*
|
|
|
|
* © 2015-2016 Ellpeck
|
|
|
|
*/
|
|
|
|
|
|
|
|
package de.ellpeck.actuallyadditions.mod.booklet.gui;
|
|
|
|
|
2016-11-10 21:07:15 +01:00
|
|
|
import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase;
|
2016-11-10 19:50:01 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
2016-11-10 21:07:15 +01:00
|
|
|
import net.minecraft.client.gui.GuiButton;
|
2016-11-10 19:50:01 +01:00
|
|
|
import net.minecraft.client.gui.GuiScreen;
|
|
|
|
import net.minecraft.util.ResourceLocation;
|
|
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
|
|
|
import org.lwjgl.input.Keyboard;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
2016-11-10 23:37:40 +01:00
|
|
|
public abstract class GuiBooklet extends GuiBookletBase{
|
2016-11-10 19:50:01 +01:00
|
|
|
|
|
|
|
public static final int BUTTONS_PER_PAGE = 12;
|
|
|
|
public static final ResourceLocation RES_LOC_GUI = AssetUtil.getBookletGuiLocation("guiBooklet");
|
|
|
|
public static final ResourceLocation RES_LOC_GADGETS = AssetUtil.getBookletGuiLocation("guiBookletGadgets");
|
|
|
|
|
2016-11-10 23:37:40 +01:00
|
|
|
public GuiScreen previousScreen;
|
2016-11-10 21:07:15 +01:00
|
|
|
protected GuiBookletBase parentPage;
|
2016-11-10 19:50:01 +01:00
|
|
|
|
|
|
|
protected int xSize;
|
|
|
|
protected int ySize;
|
|
|
|
protected int guiLeft;
|
|
|
|
protected int guiTop;
|
|
|
|
|
2016-11-10 21:07:15 +01:00
|
|
|
public GuiBooklet(GuiScreen previousScreen, GuiBookletBase parentPage){
|
|
|
|
this.previousScreen = previousScreen;
|
|
|
|
this.parentPage = parentPage;
|
2016-11-10 19:50:01 +01:00
|
|
|
|
|
|
|
this.xSize = 281;
|
|
|
|
this.ySize = 180;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void initGui(){
|
|
|
|
super.initGui();
|
|
|
|
|
|
|
|
this.guiLeft = (this.width-this.xSize)/2;
|
|
|
|
this.guiTop = (this.height-this.ySize)/2;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void drawScreen(int mouseX, int mouseY, float partialTicks){
|
|
|
|
this.mc.getTextureManager().bindTexture(RES_LOC_GUI);
|
|
|
|
drawModalRectWithCustomSizedTexture(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize, 512, 512);
|
|
|
|
|
|
|
|
super.drawScreen(mouseX, mouseY, partialTicks);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean doesGuiPauseGame(){
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void keyTyped(char typedChar, int keyCode) throws IOException{
|
2016-11-10 21:07:15 +01:00
|
|
|
if(this.previousScreen != null && keyCode == Keyboard.KEY_ESCAPE){
|
|
|
|
this.mc.displayGuiScreen(this.previousScreen);
|
2016-11-10 19:50:01 +01:00
|
|
|
}
|
|
|
|
else{
|
|
|
|
super.keyTyped(typedChar, keyCode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void renderScaledAsciiString(String text, int x, int y, int color, boolean shadow, float scale){
|
|
|
|
StringUtil.renderScaledAsciiString(this.fontRendererObj, text, x, y, color, shadow, scale);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void renderSplitScaledAsciiString(String text, int x, int y, int color, boolean shadow, float scale, int length){
|
|
|
|
StringUtil.renderSplitScaledAsciiString(this.fontRendererObj, text, x, y, color, shadow, scale, length);
|
|
|
|
}
|
2016-11-10 21:07:15 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public List<GuiButton> getButtonList(){
|
|
|
|
return this.buttonList;
|
|
|
|
}
|
2016-11-10 22:06:58 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getGuiLeft(){
|
|
|
|
return this.guiLeft;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getGuiTop(){
|
|
|
|
return this.guiTop;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getSizeX(){
|
|
|
|
return this.xSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getSizeY(){
|
|
|
|
return this.ySize;
|
|
|
|
}
|
2016-11-10 19:50:01 +01:00
|
|
|
}
|