Work on new Portable Teleporter GUI - going to basically be a clone of the regular teleporter GUI without an inventory view

This commit is contained in:
Aidan C. Brady 2015-03-12 11:18:12 -05:00
parent d16a6f06ee
commit 9043e12938
6 changed files with 136 additions and 175 deletions

View file

@ -16,7 +16,6 @@ import mekanism.client.gui.GuiChemicalInjectionChamber;
import mekanism.client.gui.GuiChemicalOxidizer;
import mekanism.client.gui.GuiChemicalWasher;
import mekanism.client.gui.GuiCombiner;
import mekanism.client.gui.GuiSideConfiguration;
import mekanism.client.gui.GuiCredits;
import mekanism.client.gui.GuiCrusher;
import mekanism.client.gui.GuiDictionary;
@ -42,7 +41,6 @@ import mekanism.client.gui.GuiPRC;
import mekanism.client.gui.GuiPasswordEnter;
import mekanism.client.gui.GuiPasswordModify;
import mekanism.client.gui.GuiPortableTank;
import mekanism.client.gui.GuiPortableTeleporter;
import mekanism.client.gui.GuiPrecisionSawmill;
import mekanism.client.gui.GuiPurificationChamber;
import mekanism.client.gui.GuiRobitCrafting;
@ -53,6 +51,7 @@ import mekanism.client.gui.GuiRobitSmelting;
import mekanism.client.gui.GuiRotaryCondensentrator;
import mekanism.client.gui.GuiSeismicReader;
import mekanism.client.gui.GuiSeismicVibrator;
import mekanism.client.gui.GuiSideConfiguration;
import mekanism.client.gui.GuiSolarEvaporationController;
import mekanism.client.gui.GuiSolarNeutronActivator;
import mekanism.client.gui.GuiTeleporter;
@ -419,7 +418,7 @@ public class ClientProxy extends CommonProxy
if(itemStack != null && itemStack.getItem() instanceof ItemPortableTeleporter)
{
return new GuiPortableTeleporter(player, itemStack);
return new GuiTeleporter(player, itemStack);
}
case 15:
return new GuiPurificationChamber(player.inventory, (TileEntityAdvancedElectricMachine)tileEntity);

View file

@ -1,137 +0,0 @@
package mekanism.client.gui;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import mekanism.client.sound.SoundHandler;
import mekanism.common.Mekanism;
import mekanism.common.item.ItemPortableTeleporter;
import mekanism.common.network.PacketDigitUpdate.DigitUpdateMessage;
import mekanism.common.network.PacketPortableTeleport.PortableTeleportMessage;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import org.lwjgl.opengl.GL11;
@SideOnly(Side.CLIENT)
public class GuiPortableTeleporter extends GuiScreen
{
public EntityPlayer entityPlayer;
public ItemStack itemStack;
public int xSize = 176;
public int ySize = 166;
public GuiPortableTeleporter(EntityPlayer player, ItemStack itemstack)
{
entityPlayer = player;
itemStack = itemstack;
}
@Override
public void initGui()
{
buttonList.clear();
buttonList.add(new GuiButton(0, 173, 105, 80, 20, MekanismUtils.localize("gui.teleport")));
}
@Override
public void drawScreen(int mouseX, int mouseY, float partialTick)
{
if(mc.thePlayer.getCurrentEquippedItem() != null && mc.thePlayer.getCurrentEquippedItem().getItem() instanceof ItemPortableTeleporter)
{
itemStack = mc.thePlayer.getCurrentEquippedItem();
}
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiPortableTeleporter.png"));
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
int guiWidth = (width-xSize)/2;
int guiHeight = (height-ySize)/2;
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
int displayInt;
displayInt = getYAxisForNumber(((ItemPortableTeleporter)itemStack.getItem()).getDigit(itemStack, 0));
drawTexturedModalRect(guiWidth+23, guiHeight+44, 176, displayInt, 13, 13);
displayInt = getYAxisForNumber(((ItemPortableTeleporter)itemStack.getItem()).getDigit(itemStack, 1));
drawTexturedModalRect(guiWidth+62, guiHeight+44, 176, displayInt, 13, 13);
displayInt = getYAxisForNumber(((ItemPortableTeleporter)itemStack.getItem()).getDigit(itemStack, 2));
drawTexturedModalRect(guiWidth+101, guiHeight+44, 176, displayInt, 13, 13);
displayInt = getYAxisForNumber(((ItemPortableTeleporter)itemStack.getItem()).getDigit(itemStack, 3));
drawTexturedModalRect(guiWidth+140, guiHeight+44, 176, displayInt, 13, 13);
ItemPortableTeleporter item = (ItemPortableTeleporter)itemStack.getItem();
((GuiButton)buttonList.get(0)).xPosition = guiWidth+48;
((GuiButton)buttonList.get(0)).yPosition = guiHeight+68;
fontRendererObj.drawString(MekanismUtils.localize("gui.portableTeleporter"), guiWidth+39, guiHeight+6, 0x404040);
fontRendererObj.drawString(item.getStatusAsString(item.getStatus(itemStack)), guiWidth+53, guiHeight+19, 0x00CD00);
super.drawScreen(mouseX, mouseY, partialTick);
}
@Override
protected void actionPerformed(GuiButton guibutton)
{
if(guibutton.id == 0)
{
Mekanism.packetHandler.sendToServer(new PortableTeleportMessage());
mc.setIngameFocus();
}
}
@Override
protected void mouseClicked(int mouseX, int mouseY, int button)
{
super.mouseClicked(mouseX, mouseY, button);
int xAxis = (mouseX-(width-xSize)/2);
int yAxis = (mouseY-(height-ySize)/2);
handleButtonClick(xAxis, yAxis, button, 0, 23, 37, 44, 58);
handleButtonClick(xAxis, yAxis, button, 1, 62, 76, 44, 58);
handleButtonClick(xAxis, yAxis, button, 2, 101, 115, 44, 58);
handleButtonClick(xAxis, yAxis, button, 3, 140, 154, 44, 58);
}
private void handleButtonClick(int xAxis, int yAxis, int mouseButton, int clickedButtonIndex, int xmin, int xmax, int ymin, int ymax)
{
if(xAxis > xmin && xAxis < xmax && yAxis > ymin && yAxis < ymax)
{
int currentDigit = ((ItemPortableTeleporter)itemStack.getItem()).getDigit(itemStack, clickedButtonIndex);
int updatedDigit = getUpdatedNumber(currentDigit, mouseButton);
Mekanism.packetHandler.sendToServer(new DigitUpdateMessage(clickedButtonIndex, updatedDigit));
((ItemPortableTeleporter)itemStack.getItem()).setDigit(itemStack, clickedButtonIndex, updatedDigit);
SoundHandler.playSound("gui.button.press");
}
}
public int getUpdatedNumber(int i, int mouseButton)
{
if(mouseButton == 1) //right click
{
return (i-1+10)%10; //add 10 to ensure postive result
}
else
{
return (i+1)%10;
}
}
public int getYAxisForNumber(int i)
{
return i*13;
}
@Override
public boolean doesGuiPauseGame()
{
return false;
}
}

View file

@ -6,6 +6,7 @@ import java.util.List;
import mekanism.api.Coord4D;
import mekanism.api.EnumColor;
import mekanism.client.gui.element.GuiPowerBar;
import mekanism.client.gui.element.GuiPowerBar.IPowerInfoHandler;
import mekanism.client.gui.element.GuiScrollList;
import mekanism.client.gui.element.GuiSlot;
import mekanism.client.gui.element.GuiSlot.SlotOverlay;
@ -13,14 +14,19 @@ import mekanism.client.gui.element.GuiSlot.SlotType;
import mekanism.client.sound.SoundHandler;
import mekanism.common.Mekanism;
import mekanism.common.frequency.Frequency;
import mekanism.common.inventory.container.ContainerNull;
import mekanism.common.inventory.container.ContainerTeleporter;
import mekanism.common.item.ItemPortableTeleporter;
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
import mekanism.common.tile.TileEntityTeleporter;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
@ -33,7 +39,12 @@ public class GuiTeleporter extends GuiMekanism
{
public static int MAX_LENGTH = 16;
public ResourceLocation resource;
public TileEntityTeleporter tileEntity;
public ItemStack itemStack;
public EntityPlayer entityPlayer;
public GuiButton publicButton;
public GuiButton privateButton;
@ -51,14 +62,52 @@ public class GuiTeleporter extends GuiMekanism
{
super(tentity, new ContainerTeleporter(inventory, tentity));
tileEntity = tentity;
resource = MekanismUtils.getResource(ResourceType.GUI, "GuiTeleporter.png");
guiElements.add(new GuiPowerBar(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiTeleporter.png"), 158, 26));
guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTeleporter.png"), 152, 6).with(SlotOverlay.POWER));
guiElements.add(scrollList = new GuiScrollList(this, MekanismUtils.getResource(ResourceType.GUI, "GuiTeleporter.png"), 28, 37, 120, 4));
guiElements.add(new GuiPowerBar(this, new IPowerInfoHandler() {
@Override
public String getTooltip()
{
return MekanismUtils.getEnergyDisplay(getEnergy());
}
@Override
public double getLevel()
{
return getEnergy()/getMaxEnergy();
}
}, resource, 158, 26));
guiElements.add(new GuiSlot(SlotType.NORMAL, this, resource, 152, 6).with(SlotOverlay.POWER));
guiElements.add(scrollList = new GuiScrollList(this, resource, 28, 37, 120, 4));
ySize+=64;
}
public GuiTeleporter(EntityPlayer player, ItemStack stack)
{
super(new ContainerNull());
itemStack = stack;
entityPlayer = player;
resource = MekanismUtils.getResource(ResourceType.GUI, "GuiPortableTeleporter.png");
guiElements.add(new GuiPowerBar(this, new IPowerInfoHandler() {
@Override
public String getTooltip()
{
return MekanismUtils.getEnergyDisplay(getEnergy());
}
@Override
public double getLevel()
{
return getEnergy()/getMaxEnergy();
}
}, resource, 158, 26));
guiElements.add(scrollList = new GuiScrollList(this, resource, 28, 37, 120, 4));
ySize = 147;
}
@Override
public void initGui()
{
@ -109,7 +158,7 @@ public class GuiTeleporter extends GuiMekanism
public void updateButtons()
{
if(tileEntity.owner == null)
if(getOwner() == null)
{
return;
}
@ -146,7 +195,7 @@ public class GuiTeleporter extends GuiMekanism
{
Frequency freq = privateMode ? tileEntity.privateCache.get(scrollList.selected) : tileEntity.publicCache.get(scrollList.selected);
if(tileEntity.frequency == null || !tileEntity.frequency.equals(freq))
if(getFrequency() == null || !getFrequency().equals(freq))
{
setButton.enabled = true;
}
@ -154,7 +203,7 @@ public class GuiTeleporter extends GuiMekanism
setButton.enabled = false;
}
if(tileEntity.owner.equals(freq.owner))
if(getOwner().equals(freq.owner))
{
deleteButton.enabled = true;
}
@ -277,26 +326,26 @@ public class GuiTeleporter extends GuiMekanism
int xAxis = (mouseX-(width-xSize)/2);
int yAxis = (mouseY-(height-ySize)/2);
fontRendererObj.drawString(tileEntity.getInventoryName(), (xSize/2)-(fontRendererObj.getStringWidth(tileEntity.getInventoryName())/2), 4, 0x404040);
fontRendererObj.drawString(MekanismUtils.localize("gui.owner") + ": " + (tileEntity.owner != null ? tileEntity.owner : MekanismUtils.localize("gui.none")), 8, (ySize-96)+4, 0x404040);
fontRendererObj.drawString(getInventoryName(), (xSize/2)-(fontRendererObj.getStringWidth(getInventoryName())/2), 4, 0x404040);
fontRendererObj.drawString(MekanismUtils.localize("gui.owner") + ": " + (getOwner() != null ? getOwner() : MekanismUtils.localize("gui.none")), 8, (ySize-96)+4, 0x404040);
fontRendererObj.drawString(MekanismUtils.localize("gui.freq") + ":", 32, 81, 0x404040);
fontRendererObj.drawString(MekanismUtils.localize("gui.security") + ":", 32, 91, 0x404040);
fontRendererObj.drawString(" " + (tileEntity.frequency != null ? tileEntity.frequency.name : EnumColor.DARK_RED + MekanismUtils.localize("gui.none")), 32 + fontRendererObj.getStringWidth(MekanismUtils.localize("gui.freq") + ":"), 81, 0x797979);
fontRendererObj.drawString(" " + (tileEntity.frequency != null ? getSecurity(tileEntity.frequency) : EnumColor.DARK_RED + MekanismUtils.localize("gui.none")), 32 + fontRendererObj.getStringWidth(MekanismUtils.localize("gui.security") + ":"), 91, 0x797979);
fontRendererObj.drawString(" " + (getFrequency() != null ? getFrequency().name : EnumColor.DARK_RED + MekanismUtils.localize("gui.none")), 32 + fontRendererObj.getStringWidth(MekanismUtils.localize("gui.freq") + ":"), 81, 0x797979);
fontRendererObj.drawString(" " + (getFrequency() != null ? getSecurity(getFrequency()) : EnumColor.DARK_RED + MekanismUtils.localize("gui.none")), 32 + fontRendererObj.getStringWidth(MekanismUtils.localize("gui.security") + ":"), 91, 0x797979);
String str = MekanismUtils.localize("gui.set") + ":";
renderScaledText(str, 27, 104, 0x404040, 20);
if(xAxis >= 6 && xAxis <= 24 && yAxis >= 6 && yAxis <= 24)
{
if(tileEntity.frequency == null)
if(getFrequency() == null)
{
drawCreativeTabHoveringText(EnumColor.DARK_RED + MekanismUtils.localize("gui.teleporter.noFreq"), xAxis, yAxis);
}
else {
drawCreativeTabHoveringText(tileEntity.getStatusDisplay(), xAxis, yAxis);
drawCreativeTabHoveringText(getStatusDisplay(), xAxis, yAxis);
}
}
@ -306,7 +355,7 @@ public class GuiTeleporter extends GuiMekanism
@Override
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY)
{
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiTeleporter.png"));
mc.renderEngine.bindTexture(resource);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
int guiWidth = (width-xSize)/2;
int guiHeight = (height-ySize)/2;
@ -323,8 +372,8 @@ public class GuiTeleporter extends GuiMekanism
drawTexturedModalRect(guiWidth + 137, guiHeight + 103, xSize, 11, 11, 11);
}
int y = tileEntity.frequency == null ? 94 : (tileEntity.status == 2 ? 22 : (tileEntity.status == 3 ? 40 :
(tileEntity.status == 4 ? 58 : 76)));
int y = getFrequency() == null ? 94 : (getStatus() == 2 ? 22 : (getStatus() == 3 ? 40 :
(getStatus() == 4 ? 58 : 76)));
drawTexturedModalRect(guiWidth + 6, guiHeight + 6, 176, y, 18, 18);
@ -332,4 +381,61 @@ public class GuiTeleporter extends GuiMekanism
frequencyField.drawTextBox();
}
public String getStatusDisplay()
{
switch(getStatus())
{
case 1:
return EnumColor.DARK_GREEN + MekanismUtils.localize("gui.teleporter.ready");
case 2:
return EnumColor.DARK_RED + MekanismUtils.localize("gui.teleporter.noFrame");
case 3:
return EnumColor.DARK_RED + MekanismUtils.localize("gui.teleporter.noLink");
case 4:
return EnumColor.DARK_RED + MekanismUtils.localize("gui.teleporter.needsEnergy");
}
return EnumColor.DARK_RED + MekanismUtils.localize("gui.teleporter.noLink");
}
private String getOwner()
{
return tileEntity != null ? tileEntity.owner : entityPlayer.getCommandSenderName();
}
private byte getStatus()
{
return tileEntity.status;
}
private Frequency getFrequency()
{
return tileEntity.frequency;
}
private String getInventoryName()
{
return tileEntity != null ? tileEntity.getInventoryName() : itemStack.getDisplayName();
}
private double getEnergy()
{
if(itemStack != null)
{
return ((ItemPortableTeleporter)itemStack.getItem()).getEnergy(itemStack);
}
return tileEntity.getEnergy();
}
private double getMaxEnergy()
{
if(itemStack != null)
{
return ((ItemPortableTeleporter)itemStack.getItem()).getMaxEnergy(itemStack);
}
return tileEntity.getMaxEnergy();
}
}

View file

@ -16,19 +16,29 @@ public class ContainerNull extends Container
tileEntity.open(player);
tileEntity.openInventory();
}
public ContainerNull() {}
@Override
public void onContainerClosed(EntityPlayer entityplayer)
{
super.onContainerClosed(entityplayer);
tileEntity.close(entityplayer);
tileEntity.closeInventory();
if(tileEntity != null)
{
tileEntity.close(entityplayer);
tileEntity.closeInventory();
}
}
@Override
public boolean canInteractWith(EntityPlayer entityplayer)
{
return tileEntity.isUseableByPlayer(entityplayer);
if(tileEntity != null)
{
return tileEntity.isUseableByPlayer(entityplayer);
}
return true;
}
}

View file

@ -187,23 +187,6 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
}
}
public String getStatusDisplay()
{
switch(status)
{
case 1:
return EnumColor.DARK_GREEN + MekanismUtils.localize("gui.teleporter.ready");
case 2:
return EnumColor.DARK_RED + MekanismUtils.localize("gui.teleporter.noFrame");
case 3:
return EnumColor.DARK_RED + MekanismUtils.localize("gui.teleporter.noLink");
case 4:
return EnumColor.DARK_RED + MekanismUtils.localize("gui.teleporter.needsEnergy");
}
return EnumColor.DARK_RED + MekanismUtils.localize("gui.teleporter.noLink");
}
@Override
public void onChunkUnload()
{

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB