Added alot of work on the PDA still {WIP}
This commit is contained in:
parent
d41f7470b9
commit
f58fbfe0e8
14 changed files with 836 additions and 106 deletions
|
@ -1,5 +0,0 @@
|
|||
package techreborn.api;
|
||||
|
||||
public interface IpdaItem {
|
||||
//TODO
|
||||
}
|
|
@ -5,7 +5,8 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||
import net.minecraft.world.World;
|
||||
import techreborn.client.container.*;
|
||||
import techreborn.client.gui.*;
|
||||
import techreborn.pda.GuiPda;
|
||||
import techreborn.pda.GuiManual;
|
||||
import techreborn.pda.pages.BasePage;
|
||||
import techreborn.tiles.*;
|
||||
import techreborn.tiles.idsu.TileIDSU;
|
||||
import techreborn.tiles.lesu.TileLesu;
|
||||
|
@ -205,7 +206,7 @@ public class GuiHandler implements IGuiHandler {
|
|||
return new GuiChemicalReactor(player,
|
||||
(TileChemicalReactor) world.getTileEntity(x, y, z));
|
||||
} else if (ID == pdaID) {
|
||||
return new GuiPda(player, new ContainerPda(player));
|
||||
return new GuiManual();
|
||||
} else if (ID == destructoPackID) {
|
||||
return new GuiDestructoPack(new ContainerDestructoPack(player));
|
||||
} else if (ID == lesuID) {
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
package techreborn.pda;
|
||||
|
||||
import cpw.mods.fml.client.config.GuiButtonExt;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class GuiButtonCustomTexture extends GuiButtonExt {
|
||||
|
||||
public int textureU;
|
||||
public int textureV;
|
||||
public ResourceLocation texture;
|
||||
|
||||
public GuiButtonCustomTexture(int id, int xPos, int yPos, int u, int v,
|
||||
int width, int height, ResourceLocation loc) {
|
||||
super(id, xPos, yPos, width, height, "_");
|
||||
textureU = u;
|
||||
textureV = v;
|
||||
texture = loc;
|
||||
}
|
||||
|
||||
public void drawButton(Minecraft mc, int mouseX, int mouseY) {
|
||||
if (this.visible) {
|
||||
boolean flag = mouseX >= this.xPosition && mouseY >= this.yPosition
|
||||
&& mouseX < this.xPosition + this.width
|
||||
&& mouseY < this.yPosition + this.height;
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
mc.getTextureManager().bindTexture(texture);
|
||||
int u = textureU;
|
||||
int v = textureV;
|
||||
|
||||
if (flag) {
|
||||
u += width;
|
||||
}
|
||||
|
||||
this.drawTexturedModalRect(this.xPosition, this.yPosition, u, v,
|
||||
width, height);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
172
src/main/java/techreborn/pda/GuiManual.java
Normal file
172
src/main/java/techreborn/pda/GuiManual.java
Normal file
|
@ -0,0 +1,172 @@
|
|||
package techreborn.pda;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.init.ModItems;
|
||||
import techreborn.pda.pages.CraftingInfoPage;
|
||||
import techreborn.pda.pages.IndexPage;
|
||||
import techreborn.pda.pages.TitledPage;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiManual extends GuiScreen{
|
||||
|
||||
protected final PageCollection root;
|
||||
protected int pageIndex = 0;
|
||||
protected int xSize = 0;
|
||||
protected int ySize = 0;
|
||||
public Container inventorySlots;
|
||||
protected int guiLeft;
|
||||
protected int guiTop;
|
||||
|
||||
public GuiManual() {
|
||||
this.xSize = 256;
|
||||
this.ySize = 202;
|
||||
root = createRoot();
|
||||
}
|
||||
|
||||
protected PageCollection createRoot() {
|
||||
pageIndex = 0;
|
||||
final PageCollection pageCollection = new PageCollection();
|
||||
pageCollection.addPage(new IndexPage("INDEX", pageCollection));
|
||||
|
||||
pageCollection.addPage(new CraftingInfoPage("BLOCK_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.Aesu), ""));
|
||||
pageCollection.addPage(new CraftingInfoPage("BLOCK_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.AlloyFurnace), ""));
|
||||
pageCollection.addPage(new CraftingInfoPage("BLOCK_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.AlloySmelter), ""));
|
||||
pageCollection.addPage(new CraftingInfoPage("BLOCK_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.AssemblyMachine), ""));
|
||||
pageCollection.addPage(new CraftingInfoPage("BLOCK_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.BlastFurnace), ""));
|
||||
pageCollection.addPage(new CraftingInfoPage("BLOCK_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.centrifuge), ""));
|
||||
pageCollection.addPage(new CraftingInfoPage("BLOCK_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.chargeBench), ""));
|
||||
pageCollection.addPage(new CraftingInfoPage("BLOCK_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.ChemicalReactor), ""));
|
||||
pageCollection.addPage(new CraftingInfoPage("BLOCK_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.ChunkLoader), ""));
|
||||
pageCollection.addPage(new CraftingInfoPage("BLOCK_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.ComputerCube), ""));
|
||||
pageCollection.addPage(new CraftingInfoPage("BLOCK_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.DieselGenerator), ""));
|
||||
pageCollection.addPage(new CraftingInfoPage("BLOCK_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.digitalChest), ""));
|
||||
pageCollection.addPage(new CraftingInfoPage("BLOCK_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.Distillationtower), ""));
|
||||
pageCollection.addPage(new CraftingInfoPage("BLOCK_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.Dragoneggenergysiphoner), ""));
|
||||
pageCollection.addPage(new CraftingInfoPage("BLOCK_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.ElectricCraftingTable), ""));
|
||||
pageCollection.addPage(new CraftingInfoPage("BLOCK_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.farm), ""));
|
||||
pageCollection.addPage(new CraftingInfoPage("BLOCK_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.FusionCoil), ""));
|
||||
pageCollection.addPage(new CraftingInfoPage("BLOCK_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.FusionControlComputer), ""));
|
||||
pageCollection.addPage(new CraftingInfoPage("BLOCK_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.Gasturbine), ""));
|
||||
pageCollection.addPage(new CraftingInfoPage("BLOCK_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.Grinder), ""));
|
||||
pageCollection.addPage(new CraftingInfoPage("BLOCK_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.heatGenerator), ""));
|
||||
pageCollection.addPage(new CraftingInfoPage("BLOCK_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.HighAdvancedMachineBlock), ""));
|
||||
pageCollection.addPage(new CraftingInfoPage("BLOCK_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.Idsu), ""));
|
||||
pageCollection.addPage(new CraftingInfoPage("BLOCK_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.ImplosionCompressor), ""));
|
||||
pageCollection.addPage(new CraftingInfoPage("BLOCK_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.IndustrialElectrolyzer), ""));
|
||||
pageCollection.addPage(new CraftingInfoPage("BLOCK_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.lathe), ""));
|
||||
pageCollection.addPage(new CraftingInfoPage("BLOCK_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.Lesu), ""));
|
||||
pageCollection.addPage(new CraftingInfoPage("BLOCK_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.LesuStorage), ""));
|
||||
pageCollection.addPage(new CraftingInfoPage("BLOCK_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.LightningRod), ""));
|
||||
pageCollection.addPage(new CraftingInfoPage("BLOCK_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.machineframe), ""));
|
||||
pageCollection.addPage(new CraftingInfoPage("BLOCK_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.MagicalAbsorber), ""));
|
||||
pageCollection.addPage(new CraftingInfoPage("BLOCK_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.Magicenergeyconverter), ""));
|
||||
pageCollection.addPage(new CraftingInfoPage("BLOCK_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.MatterFabricator), ""));
|
||||
pageCollection.addPage(new CraftingInfoPage("BLOCK_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.Metalshelf), ""));
|
||||
pageCollection.addPage(new CraftingInfoPage("BLOCK_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.PlasmaGenerator), ""));
|
||||
pageCollection.addPage(new CraftingInfoPage("BLOCK_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.platecuttingmachine), ""));
|
||||
pageCollection.addPage(new CraftingInfoPage("BLOCK_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.quantumChest), ""));
|
||||
pageCollection.addPage(new CraftingInfoPage("BLOCK_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.quantumTank), ""));
|
||||
pageCollection.addPage(new CraftingInfoPage("BLOCK_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.RollingMachine), ""));
|
||||
pageCollection.addPage(new CraftingInfoPage("BLOCK_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.Semifluidgenerator), ""));
|
||||
pageCollection.addPage(new CraftingInfoPage("BLOCK_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.thermalGenerator), ""));
|
||||
pageCollection.addPage(new CraftingInfoPage("BLOCK_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.VacuumFreezer), ""));
|
||||
pageCollection.addPage(new CraftingInfoPage("BLOCK_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.Woodenshelf), ""));
|
||||
|
||||
pageCollection.addPage(new CraftingInfoPage("ITEM_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModItems.lapotronicOrb), ""));
|
||||
//TODO add the rest of the items
|
||||
//TODO add scroll bar
|
||||
|
||||
return pageCollection;
|
||||
}
|
||||
|
||||
private int getNextPageIndex(){
|
||||
int i = pageIndex;
|
||||
pageIndex++;
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float par3) {
|
||||
drawGuiBackgroundLayer(par3, mouseX, mouseY);
|
||||
super.drawScreen(mouseX, mouseY, par3);
|
||||
|
||||
prepareRenderState();
|
||||
GL11.glPushMatrix();
|
||||
|
||||
root.drawScreen(this.mc, this.guiLeft, this.guiTop, mouseX - this.guiLeft, mouseY - this.guiTop);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
restoreRenderState();
|
||||
}
|
||||
|
||||
protected void prepareRenderState() {
|
||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
protected void restoreRenderState() {
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
}
|
||||
|
||||
protected void drawGuiBackgroundLayer(float p_146976_1_, int mouseX, int mouseY) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(this.guiLeft, this.guiTop, 0);
|
||||
root.renderBackgroundLayer(this.mc, 0, 0, mouseX - this.guiLeft, mouseY - this.guiTop);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWorldAndResolution(Minecraft minecraft, int x, int y) {
|
||||
super.setWorldAndResolution(minecraft, x, y);
|
||||
root.setWorldAndResolution(minecraft, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(GuiButton button) {
|
||||
root.actionPerformed(button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseMovedOrUp(int par1, int par2, int par3){
|
||||
root.mouseMovedOrUp(par1, par2, par3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int par1, int par2, int par3){
|
||||
root.mouseClicked(par1, par2, par3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleInput() {
|
||||
super.handleInput();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
this.guiLeft = (this.width - this.xSize) / 2;
|
||||
this.guiTop = (this.height - this.ySize) / 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesGuiPauseGame() {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
package techreborn.pda;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import techreborn.client.container.ContainerPda;
|
||||
import techreborn.cofhLib.gui.GuiBase;
|
||||
import techreborn.cofhLib.gui.GuiColor;
|
||||
import techreborn.cofhLib.gui.element.ElementSlider;
|
||||
|
||||
public class GuiPda extends GuiBase {
|
||||
|
||||
public final int guiHeight = 256;
|
||||
public final int guiWidth = 256;
|
||||
private int guiLeft, guiTop;
|
||||
private ElementSlider slider;
|
||||
|
||||
private static final ResourceLocation pdaGuipages = new ResourceLocation("techreborn:" + "textures/gui/pda.png");
|
||||
|
||||
public GuiPda(EntityPlayer player, ContainerPda container) {
|
||||
super(container);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
this.guiLeft = this.width / 2 - this.guiWidth / 2;
|
||||
this.guiTop = this.height / 2 - this.guiHeight / 2;
|
||||
//TODO fix
|
||||
slider = new ElementSlider(this, "scrollBar", 239, 36, 12, 201, 187, 0) {
|
||||
@Override
|
||||
protected void dragSlider(int x, int y) {
|
||||
if (y > _value) {
|
||||
setValue(_value + 1);
|
||||
} else {
|
||||
setValue(_value - 1);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
slider.backgroundColor = new GuiColor(0, 0, 0, 0).getColor();
|
||||
slider.borderColor = new GuiColor(0, 0, 0, 0).getColor();
|
||||
slider.setSliderSize(12, 15);
|
||||
addElement(slider);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||
mc.getTextureManager().bindTexture(pdaGuipages);
|
||||
drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, this.guiWidth, this.guiHeight);
|
||||
// super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesGuiPauseGame() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
85
src/main/java/techreborn/pda/PageCollection.java
Normal file
85
src/main/java/techreborn/pda/PageCollection.java
Normal file
|
@ -0,0 +1,85 @@
|
|||
package techreborn.pda;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import techreborn.pda.pages.BasePage;
|
||||
|
||||
public class PageCollection extends Gui{
|
||||
|
||||
public final List<BasePage> pages = Lists.newArrayList();
|
||||
private String ACTIVE_PAGE = "INDEX";
|
||||
protected int x;
|
||||
protected int y;
|
||||
|
||||
public PageCollection() {
|
||||
this.x = 0;
|
||||
this.y = 0;
|
||||
}
|
||||
|
||||
public void addPage(BasePage page) {
|
||||
pages.add(page);
|
||||
}
|
||||
|
||||
public BasePage getPageByName(String name){
|
||||
for (BasePage component : pages) {
|
||||
if (component.getReferenceName().equals(ACTIVE_PAGE)) {
|
||||
return component;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public BasePage getActivePage(){
|
||||
for (BasePage component : pages) {
|
||||
if (component.getReferenceName().equals(ACTIVE_PAGE)) {
|
||||
return component;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public final void drawScreen(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
|
||||
if (getActivePage() == null) return;
|
||||
getActivePage().drawScreen(minecraft, offsetX, offsetY, mouseX, mouseY);
|
||||
}
|
||||
|
||||
|
||||
public final void renderBackgroundLayer(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
|
||||
if (getActivePage() == null) return;
|
||||
getActivePage().renderBackgroundLayer(minecraft, offsetX, offsetY, mouseX, mouseY);
|
||||
}
|
||||
|
||||
public void changeActivePage(String newPage){
|
||||
ACTIVE_PAGE = newPage;
|
||||
if (getActivePage() == null) return;
|
||||
getActivePage().setWorldAndResolution(Minecraft.getMinecraft(), x, y);
|
||||
}
|
||||
|
||||
public void setWorldAndResolution(Minecraft minecraft, int x, int y) {
|
||||
if (getActivePage() == null) return;
|
||||
getActivePage().setWorldAndResolution(minecraft, x, y);
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
protected void actionPerformed(GuiButton button) {
|
||||
if (getActivePage() == null) return;
|
||||
getActivePage().actionPerformed(button);
|
||||
}
|
||||
|
||||
protected void mouseMovedOrUp(int par1, int par2, int par3){
|
||||
if (getActivePage() == null) return;
|
||||
getActivePage().mouseMovedOrUp(par1, par2, par3);
|
||||
}
|
||||
|
||||
protected void mouseClicked(int par1, int par2, int par3){
|
||||
if (getActivePage() == null) return;
|
||||
getActivePage().mouseClicked(par1, par2, par3);
|
||||
}
|
||||
|
||||
}
|
102
src/main/java/techreborn/pda/pages/BasePage.java
Normal file
102
src/main/java/techreborn/pda/pages/BasePage.java
Normal file
|
@ -0,0 +1,102 @@
|
|||
package techreborn.pda.pages;
|
||||
|
||||
import java.awt.Button;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import techreborn.client.container.ContainerPda;
|
||||
import techreborn.cofhLib.gui.GuiBase;
|
||||
import techreborn.cofhLib.gui.GuiColor;
|
||||
import techreborn.cofhLib.gui.element.ElementSlider;
|
||||
import techreborn.pda.PageCollection;
|
||||
|
||||
public class BasePage extends GuiScreen {
|
||||
|
||||
//Name used to reference the page
|
||||
private String REFERENCE_NAME;
|
||||
//Name Displayed in the index page
|
||||
public String INDEX_NAME;
|
||||
public boolean hasIndexButton = false;
|
||||
public static final ResourceLocation PAGE_TEXTURE = new ResourceLocation("techreborn:textures/gui/pda.png");
|
||||
private final int xSize = 256;
|
||||
private final int ySize = 202;
|
||||
protected PageCollection collection;
|
||||
|
||||
public BasePage(){}
|
||||
|
||||
public BasePage(String referenceName, PageCollection collection) {
|
||||
this.REFERENCE_NAME = referenceName;
|
||||
this.mc = Minecraft.getMinecraft();
|
||||
this.collection = collection;
|
||||
initGui();
|
||||
}
|
||||
|
||||
public BasePage(String referenceName, boolean showInMenue, PageCollection collection) {
|
||||
this(referenceName, collection);
|
||||
this.hasIndexButton = showInMenue;
|
||||
}
|
||||
|
||||
public int getXMin(){
|
||||
return (this.width - xSize) / 2;
|
||||
}
|
||||
|
||||
public int getYMin(){
|
||||
return (this.height - ySize) / 2;
|
||||
}
|
||||
|
||||
public void setXMin(int x){
|
||||
this.width = x;
|
||||
}
|
||||
|
||||
public void setYMin(int y){
|
||||
this.height = y;
|
||||
}
|
||||
|
||||
//Unlocalized Index Page Name
|
||||
public BasePage setIndexName(String unlocalizedName){
|
||||
this.INDEX_NAME = ttl(unlocalizedName);
|
||||
return this;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void initGui() {
|
||||
buttonList.clear();
|
||||
buttonList.add(new GuiButton(0, getXMin()+88, getYMin()+181, 80, 16, ttl("techreborn.pda.backbutton")));
|
||||
}
|
||||
|
||||
public void setReferenceName(String name){
|
||||
REFERENCE_NAME = name;}
|
||||
|
||||
public String getReferenceName(){ return REFERENCE_NAME;}
|
||||
|
||||
public void renderBackgroundLayer(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY){
|
||||
minecraft.renderEngine.bindTexture(PAGE_TEXTURE);
|
||||
drawTexturedModalRect(offsetX, offsetY, 0, 0, xSize, ySize);
|
||||
}
|
||||
|
||||
public void renderOverlayComponents(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY){
|
||||
|
||||
}
|
||||
|
||||
public void drawScreen(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
|
||||
super.drawScreen(mouseX+offsetX, mouseY+offsetY, 0);
|
||||
renderOverlayComponents(minecraft, offsetX, offsetY, mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(GuiButton button) {
|
||||
if (button.id == 0)collection.changeActivePage("INDEX");
|
||||
}
|
||||
@Override
|
||||
public void mouseMovedOrUp(int par1, int par2, int par3){super.mouseMovedOrUp(par1, par2, par3);}
|
||||
@Override
|
||||
public void mouseClicked(int par1, int par2, int par3){super.mouseClicked(par1, par2, par3);}
|
||||
|
||||
//Translate To Local
|
||||
public String ttl(String unlocalizedName){return StatCollector.translateToLocal(unlocalizedName);}
|
||||
}
|
284
src/main/java/techreborn/pda/pages/CraftingInfoPage.java
Normal file
284
src/main/java/techreborn/pda/pages/CraftingInfoPage.java
Normal file
|
@ -0,0 +1,284 @@
|
|||
package techreborn.pda.pages;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.item.crafting.ShapedRecipes;
|
||||
import net.minecraft.item.crafting.ShapelessRecipes;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
import net.minecraftforge.oredict.ShapelessOreRecipe;
|
||||
import techreborn.client.GuiUtil;
|
||||
import techreborn.pda.PageCollection;
|
||||
import techreborn.util.LogHelper;
|
||||
|
||||
public class CraftingInfoPage extends TitledPage{
|
||||
protected static RenderItem itemRenderer = new RenderItem();
|
||||
public ItemStack result;
|
||||
private boolean isSmelting = false;
|
||||
private ItemStack[] recipe = new ItemStack[9];
|
||||
private boolean hasRecipe = false;
|
||||
private String rawDescription;
|
||||
private List<String> formattedDescription;
|
||||
private float descriptionScale = 0.66f;
|
||||
|
||||
public CraftingInfoPage(String name, PageCollection collection, ItemStack itemStack, String unlocalizedDescription) {
|
||||
super(name, true, collection, itemStack.getUnlocalizedName()+".name", 0000000);
|
||||
this.result = itemStack;
|
||||
this.recipe = getFirstRecipeForItem(itemStack);
|
||||
for (ItemStack stack : recipe) if (stack != null) hasRecipe = true;
|
||||
if (unlocalizedDescription == "") rawDescription = ttl(itemStack.getUnlocalizedName()+".description");
|
||||
else rawDescription = ttl(unlocalizedDescription);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderBackgroundLayer(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
|
||||
super.renderBackgroundLayer(minecraft, offsetX, offsetY, mouseX, mouseY);
|
||||
GL11.glPushMatrix();
|
||||
if (isSmelting){
|
||||
drawTexturedModalRect(offsetX + 87, offsetY + 15, 116, 202, 82, 54);
|
||||
}else {
|
||||
if (hasRecipe) {
|
||||
drawTexturedModalRect(offsetX + 70, offsetY + 15, 0, 202, 116, 54);
|
||||
}
|
||||
else {
|
||||
drawTexturedModalRect(offsetX + 119, offsetY + 17, 0, 202, 18, 18);
|
||||
drawString(fontRendererObj, "No Crafting Recipe", offsetX + 145, offsetY + 17, 0000000);
|
||||
}
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
|
||||
}
|
||||
|
||||
public void drawScreen(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
|
||||
super.drawScreen(minecraft, offsetX, offsetY, mouseX, mouseY);
|
||||
int relativeMouseX = mouseX + offsetX;
|
||||
int relativeMouseY = mouseY + offsetY;
|
||||
int gridOffsetX = isSmelting ? 88 : 71;
|
||||
int gridOffsetY = 16;
|
||||
int itemBoxSize = 18;
|
||||
addDescription(minecraft, offsetX, offsetY);
|
||||
|
||||
ItemStack tooltip = null;
|
||||
int i = 0;
|
||||
for (ItemStack input : recipe) {
|
||||
if (input != null) {
|
||||
int row = (i % 3);
|
||||
int column = i / 3;
|
||||
int itemX = offsetX + gridOffsetX + (row * itemBoxSize);
|
||||
int itemY = offsetY + gridOffsetY + (column * itemBoxSize);
|
||||
drawItemStack(input, itemX, itemY, "");
|
||||
if (relativeMouseX > itemX - 2 && relativeMouseX < itemX - 2 + itemBoxSize &&
|
||||
relativeMouseY > itemY - 2 && relativeMouseY < itemY - 2 + itemBoxSize) {
|
||||
tooltip = input;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
int itemX = offsetX + (isSmelting ? 148 : 165);
|
||||
int itemY = offsetY + 34;
|
||||
if (!hasRecipe){
|
||||
itemX = offsetX+120;
|
||||
itemY = offsetY+18;
|
||||
}
|
||||
|
||||
drawItemStack(result, itemX, itemY, "");
|
||||
if (relativeMouseX > itemX - 2 && relativeMouseX < itemX - 2 + itemBoxSize &&
|
||||
relativeMouseY > itemY - 2 && relativeMouseY < itemY - 2 + itemBoxSize) {
|
||||
tooltip = result;
|
||||
}
|
||||
if (tooltip != null) {
|
||||
drawItemStackTooltip(tooltip, relativeMouseX, relativeMouseY);
|
||||
}
|
||||
}
|
||||
|
||||
public void addDescription(Minecraft minecraft, int offsetX, int offsetY){
|
||||
GL11.glPushMatrix();
|
||||
if (hasRecipe) GL11.glTranslated(offsetX+5, offsetY+75, 1);
|
||||
else GL11.glTranslated(offsetX+5, offsetY+40, 1);
|
||||
GL11.glScalef(descriptionScale, descriptionScale, descriptionScale);
|
||||
int offset = 0;
|
||||
for (String s : getFormattedText(fontRendererObj)) {
|
||||
if (s == null) break;
|
||||
if (s.contains("\\%") && s.substring(0,2).equals("\\%")){
|
||||
s = s.substring(2);
|
||||
offset += fontRendererObj.FONT_HEIGHT/2;
|
||||
}
|
||||
fontRendererObj.drawString(s, 0, offset, 0x000000);
|
||||
offset += fontRendererObj.FONT_HEIGHT;
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<String> getFormattedText(FontRenderer fr) {
|
||||
if (formattedDescription == null) {
|
||||
formattedDescription = new ArrayList<String>();
|
||||
|
||||
if (Strings.isNullOrEmpty(rawDescription)) {
|
||||
formattedDescription = ImmutableList.of();
|
||||
return formattedDescription;
|
||||
}
|
||||
if (!rawDescription.contains("\\n")) {
|
||||
formattedDescription = ImmutableList.copyOf(fr.listFormattedStringToWidth(rawDescription, 370));
|
||||
return formattedDescription;
|
||||
}
|
||||
|
||||
List<String> segments = new ArrayList(); //Each separate string that is separated by a \n
|
||||
String raw = rawDescription;
|
||||
|
||||
|
||||
int escape = 0;
|
||||
while (raw.contains("\\n")) {
|
||||
segments.add(raw.substring(0, raw.indexOf("\\n")));
|
||||
raw = raw.substring(raw.indexOf("\\n") + 2);
|
||||
if (!raw.contains("\\n")) segments.add(raw);
|
||||
|
||||
escape++;
|
||||
if (escape > 100) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (String s : segments)
|
||||
formattedDescription.addAll(ImmutableList.copyOf(fr.listFormattedStringToWidth(s, 370)));
|
||||
}
|
||||
return formattedDescription;
|
||||
}
|
||||
|
||||
protected void drawItemStackTooltip(ItemStack stack, int x, int y) {
|
||||
final Minecraft mc = Minecraft.getMinecraft();
|
||||
FontRenderer font = Objects.firstNonNull(stack.getItem().getFontRenderer(stack), mc.fontRenderer);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<String> list = stack.getTooltip(mc.thePlayer, mc.gameSettings.advancedItemTooltips);
|
||||
|
||||
List<String> colored = Lists.newArrayListWithCapacity(list.size());
|
||||
colored.add(stack.getRarity().rarityColor + list.get(0));
|
||||
for (String line : list)
|
||||
colored.add(EnumChatFormatting.GRAY + line);
|
||||
|
||||
if (colored.size() >= 2) colored.remove(1);
|
||||
drawHoveringText(colored, x, y, font);
|
||||
}
|
||||
|
||||
private void drawItemStack(ItemStack par1ItemStack, int par2, int par3, String par4Str) {
|
||||
GL11.glTranslatef(0.0F, 0.0F, 32.0F);
|
||||
this.zLevel = 200.0F;
|
||||
itemRenderer.zLevel = 200.0F;
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
GL11.glColor3f(1f, 1f, 1f);
|
||||
GL11.glEnable(GL11.GL_NORMALIZE);
|
||||
FontRenderer font = null;
|
||||
if (par1ItemStack != null) font = par1ItemStack.getItem().getFontRenderer(par1ItemStack);
|
||||
if (font == null) font = Minecraft.getMinecraft().fontRenderer;
|
||||
itemRenderer.renderItemAndEffectIntoGUI(font, Minecraft.getMinecraft().getTextureManager(), par1ItemStack, par2, par3);
|
||||
itemRenderer.renderItemOverlayIntoGUI(font, Minecraft.getMinecraft().getTextureManager(), par1ItemStack, par2, par3, par4Str);
|
||||
this.zLevel = 0.0F;
|
||||
itemRenderer.zLevel = 0.0F;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private ItemStack[] getFirstRecipeForItem(ItemStack resultingItem) {
|
||||
ItemStack[] recipeItems = new ItemStack[9];
|
||||
for (IRecipe recipe : (List<IRecipe>) CraftingManager.getInstance().getRecipeList()) {
|
||||
if (recipe == null) continue;
|
||||
|
||||
ItemStack result = recipe.getRecipeOutput();
|
||||
if (result == null || !result.isItemEqual(resultingItem)) continue;
|
||||
|
||||
Object[] input = getRecipeInput(recipe);
|
||||
if (input == null) continue;
|
||||
|
||||
for (int i = 0; i < input.length; i++)
|
||||
recipeItems[i] = convertToStack(input[i]);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
Iterator iterator = FurnaceRecipes.smelting().getSmeltingList().entrySet().iterator();
|
||||
Map.Entry entry;
|
||||
|
||||
while (iterator.hasNext()){
|
||||
entry = (Map.Entry)iterator.next();
|
||||
if (entry.getKey() instanceof ItemStack && ((ItemStack)entry.getValue()).isItemEqual(result)){
|
||||
isSmelting = true;
|
||||
recipeItems[0] = (ItemStack)entry.getKey();
|
||||
}
|
||||
}
|
||||
|
||||
return recipeItems;
|
||||
}
|
||||
|
||||
protected ItemStack convertToStack(Object obj) {
|
||||
ItemStack entry = null;
|
||||
if (obj instanceof ItemStack) {
|
||||
entry = (ItemStack)obj;
|
||||
} else if (obj instanceof List) {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<ItemStack> list = (List<ItemStack>)obj;
|
||||
if (list.size() > 0) entry = list.get(0);
|
||||
}
|
||||
|
||||
if (entry == null) return null;
|
||||
entry = entry.copy();
|
||||
if (entry.getItemDamage() == OreDictionary.WILDCARD_VALUE) entry.setItemDamage(0);
|
||||
return entry;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Object[] getRecipeInput(IRecipe recipe) {
|
||||
if (recipe instanceof ShapelessOreRecipe) return ((ShapelessOreRecipe)recipe).getInput().toArray();
|
||||
else if (recipe instanceof ShapedOreRecipe) return getShapedOreRecipe((ShapedOreRecipe)recipe);
|
||||
else if (recipe instanceof ShapedRecipes) return ((ShapedRecipes)recipe).recipeItems;
|
||||
else if (recipe instanceof ShapelessRecipes) return ((ShapelessRecipes)recipe).recipeItems.toArray(new ItemStack[0]);
|
||||
return null;
|
||||
}
|
||||
|
||||
private Object[] getShapedOreRecipe(ShapedOreRecipe recipe) {
|
||||
try {
|
||||
Field field = ShapedOreRecipe.class.getDeclaredField("width");
|
||||
if (field != null) {
|
||||
field.setAccessible(true);
|
||||
int width = field.getInt(recipe);
|
||||
Object[] input = recipe.getInput();
|
||||
Object[] grid = new Object[9];
|
||||
for (int i = 0, offset = 0, y = 0; y < 3; y++) {
|
||||
for (int x = 0; x < 3; x++, i++) {
|
||||
if (x < width && offset < input.length) {
|
||||
grid[i] = input[offset];
|
||||
offset++;
|
||||
} else {
|
||||
grid[i] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return grid;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
58
src/main/java/techreborn/pda/pages/IndexPage.java
Normal file
58
src/main/java/techreborn/pda/pages/IndexPage.java
Normal file
|
@ -0,0 +1,58 @@
|
|||
package techreborn.pda.pages;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import techreborn.pda.PageCollection;
|
||||
import techreborn.pda.util.GuiButtonAHeight;
|
||||
import techreborn.pda.util.GuiButtonTextOnly;
|
||||
|
||||
public class IndexPage extends TitledPage{
|
||||
|
||||
public IndexPage(String name, PageCollection collection) {
|
||||
super(name, false, collection, "techreborn.pda.index", 518915);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void initGui() {
|
||||
buttonList.clear();
|
||||
int row = 0;
|
||||
int collum = 0;
|
||||
for (BasePage page : collection.pages){
|
||||
if (page.hasIndexButton){
|
||||
String indexName = page.INDEX_NAME;
|
||||
if (indexName==null && page instanceof CraftingInfoPage) indexName = ttl(((CraftingInfoPage)page).result.getUnlocalizedName()+".name");
|
||||
else if (indexName==null) indexName = page.getReferenceName();
|
||||
int colour = 0000000;
|
||||
|
||||
buttonList.add(new GuiButtonTextOnly(999, getXMin()+5+collum*81, getYMin()+20+(row*7), 82, 7, indexName, page.getReferenceName(), colour));
|
||||
row++;
|
||||
if (row > 21){
|
||||
row = 0;
|
||||
collum++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(GuiButton button) {
|
||||
if (button instanceof GuiButtonTextOnly)
|
||||
collection.changeActivePage(((GuiButtonTextOnly)button).LINKED_PAGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderBackgroundLayer(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
|
||||
super.renderBackgroundLayer(minecraft, offsetX, offsetY, mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
|
||||
super.drawScreen(minecraft, offsetX, offsetY, mouseX, mouseY);
|
||||
for (int k = 0; k < this.buttonList.size(); ++k){
|
||||
if (buttonList.get(k) instanceof GuiButtonTextOnly && ((GuiButtonTextOnly) buttonList.get(k)).getIsHovering()) {
|
||||
((GuiButtonTextOnly) this.buttonList.get(k)).drawButton(this.mc, mouseX + offsetX, mouseY + offsetY);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
22
src/main/java/techreborn/pda/pages/TitledPage.java
Normal file
22
src/main/java/techreborn/pda/pages/TitledPage.java
Normal file
|
@ -0,0 +1,22 @@
|
|||
package techreborn.pda.pages;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import techreborn.pda.PageCollection;
|
||||
|
||||
public class TitledPage extends BasePage{
|
||||
private String title;
|
||||
public boolean drawTitle = true;
|
||||
private int colour;
|
||||
|
||||
public TitledPage(String name, boolean showInMenue, PageCollection collection, String unlocalizedTitle, int colour) {
|
||||
super(name, showInMenue, collection);
|
||||
this.title = unlocalizedTitle;
|
||||
this.colour = colour;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderOverlayComponents(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
|
||||
if (title == null) title = INDEX_NAME;
|
||||
if (drawTitle)drawCenteredString(minecraft.fontRenderer, ttl(title), offsetX + 128, offsetY + 5, colour);
|
||||
}
|
||||
}
|
50
src/main/java/techreborn/pda/util/GuiButtonAHeight.java
Normal file
50
src/main/java/techreborn/pda/util/GuiButtonAHeight.java
Normal file
|
@ -0,0 +1,50 @@
|
|||
package techreborn.pda.util;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
|
||||
public class GuiButtonAHeight extends GuiButton{
|
||||
|
||||
public GuiButtonAHeight(int id, int xPos, int yPos, int width, int hight, String displayString) {
|
||||
super(id, xPos, yPos, width, hight, displayString);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft minecraft, int mouseX, int mouseY) {
|
||||
if (this.visible){
|
||||
FontRenderer fontrenderer = minecraft.fontRenderer;
|
||||
minecraft.getTextureManager().bindTexture(buttonTextures);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.field_146123_n = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
|
||||
int k = this.getHoverState(this.field_146123_n);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
this.drawTexturedModalRect(this.xPosition, this.yPosition, 0, 46 + k * 20, this.width / 2, this.height);
|
||||
this.drawTexturedModalRect(this.xPosition + this.width / 2, this.yPosition, 200 - this.width / 2, 46 + k * 20, this.width / 2, this.height);
|
||||
|
||||
if (this.height < 20){
|
||||
this.drawTexturedModalRect(xPosition, yPosition+3, 0, (46 + k * 20)+20-height+3, width / 2, height-3);
|
||||
this.drawTexturedModalRect(xPosition + width / 2, yPosition+3, 200 - width / 2, (46 + k * 20)+20-height+3, width / 2, height-3);
|
||||
}
|
||||
|
||||
this.mouseDragged(minecraft, mouseX, mouseY);
|
||||
int l = 14737632;
|
||||
|
||||
if (packedFGColour != 0){
|
||||
l = packedFGColour;
|
||||
}
|
||||
else if (!this.enabled){
|
||||
l = 10526880;
|
||||
}
|
||||
else if (this.field_146123_n){
|
||||
l = 16777120;
|
||||
}
|
||||
this.drawCenteredString(fontrenderer, this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, l);
|
||||
}
|
||||
}
|
||||
}
|
60
src/main/java/techreborn/pda/util/GuiButtonTextOnly.java
Normal file
60
src/main/java/techreborn/pda/util/GuiButtonTextOnly.java
Normal file
|
@ -0,0 +1,60 @@
|
|||
package techreborn.pda.util;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
public class GuiButtonTextOnly extends GuiButton{
|
||||
public String LINKED_PAGE;
|
||||
public int textColour;
|
||||
|
||||
public GuiButtonTextOnly(int id, int xPos, int yPos, int width, int hight, String displayString, String linkedPage, int colour) {
|
||||
super(id, xPos, yPos, width, hight, displayString);
|
||||
this.LINKED_PAGE = linkedPage;
|
||||
this.textColour = colour;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft minecraft, int mouseX, int mouseY) {
|
||||
if (this.visible){
|
||||
FontRenderer fontrenderer = minecraft.fontRenderer;
|
||||
minecraft.getTextureManager().bindTexture(buttonTextures);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.field_146123_n = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
this.mouseDragged(minecraft, mouseX, mouseY);
|
||||
|
||||
String trimmedDisplayString = displayString;
|
||||
if (fontrenderer.getStringWidth(displayString) > width+30 && !this.field_146123_n){
|
||||
int energencyBreak = 0;
|
||||
while (fontrenderer.getStringWidth(trimmedDisplayString)*0.7 > width-5){
|
||||
trimmedDisplayString = trimmedDisplayString.substring(0, trimmedDisplayString.length()-1);
|
||||
energencyBreak++;
|
||||
if (energencyBreak > 100) break;
|
||||
}
|
||||
trimmedDisplayString+="...";
|
||||
}
|
||||
|
||||
if (this.field_146123_n){
|
||||
trimmedDisplayString = EnumChatFormatting.BOLD+""+EnumChatFormatting.ITALIC+trimmedDisplayString;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glColor4f(0f, 0f, 0f, 1f);
|
||||
drawTexturedModalRect(xPosition+(int)(xPosition*0.01), yPosition+(int)(yPosition*0.01), 0, 46, (int)(fontrenderer.getStringWidth(trimmedDisplayString)*0.72)+2, 8);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScalef(0.7F, 0.7F, 1);
|
||||
fontrenderer.drawString(trimmedDisplayString, (int)(xPosition*1.45), (int)((yPosition + (height - 8) / 2)*1.45), textColour);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getIsHovering(){return field_146123_n;}
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 3.1 KiB |
BIN
src/main/resources/assets/techreborn/textures/gui/pda1.png
Normal file
BIN
src/main/resources/assets/techreborn/textures/gui/pda1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.7 KiB |
Loading…
Add table
Reference in a new issue