Started work on the new upgrade system, as well as the new GUI

This commit is contained in:
Aidan C. Brady 2014-07-21 14:57:31 -04:00
parent 0416e2e904
commit d16483f4b1
21 changed files with 259 additions and 108 deletions

View file

@ -31,7 +31,7 @@ public class GuiAdvancedElectricMachine extends GuiMekanism
tileEntity = tentity;
guiElements.add(new GuiRedstoneControl(this, tileEntity, tileEntity.guiLocation));
guiElements.add(new GuiUpgradeManagement(this, tileEntity, tileEntity.guiLocation));
guiElements.add(new GuiUpgradeTab(this, tileEntity, tileEntity.guiLocation));
guiElements.add(new GuiConfigurationTab(this, tileEntity, tileEntity.guiLocation));
guiElements.add(new GuiPowerBar(this, tileEntity, tileEntity.guiLocation, 164, 15));
guiElements.add(new GuiEnergyInfo(new IInfoHandler() {

View file

@ -29,7 +29,7 @@ public class GuiChanceMachine extends GuiMekanism
tileEntity = tentity;
guiElements.add(new GuiRedstoneControl(this, tileEntity, tileEntity.guiLocation));
guiElements.add(new GuiUpgradeManagement(this, tileEntity, tileEntity.guiLocation));
guiElements.add(new GuiUpgradeTab(this, tileEntity, tileEntity.guiLocation));
guiElements.add(new GuiConfigurationTab(this, tileEntity, tileEntity.guiLocation));
guiElements.add(new GuiPowerBar(this, tileEntity, tileEntity.guiLocation, 164, 15));
guiElements.add(new GuiEnergyInfo(new IInfoHandler() {

View file

@ -52,7 +52,7 @@ public class GuiChemicalCrystallizer extends GuiMekanism
tileEntity = tentity;
guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalCrystallizer.png")));
guiElements.add(new GuiUpgradeManagement(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalCrystallizer.png")));
guiElements.add(new GuiUpgradeTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalCrystallizer.png")));
guiElements.add(new GuiPowerBar(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalCrystallizer.png"), 160, 23));
guiElements.add(new GuiConfigurationTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalCrystallizer.png")));
guiElements.add(new GuiEnergyInfo(new IInfoHandler() {

View file

@ -32,7 +32,7 @@ public class GuiChemicalDissolutionChamber extends GuiMekanism
tileEntity = tentity;
guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalDissolutionChamber.png")));
guiElements.add(new GuiUpgradeManagement(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalDissolutionChamber.png")));
guiElements.add(new GuiUpgradeTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalDissolutionChamber.png")));
guiElements.add(new GuiEnergyInfo(new IInfoHandler() {
@Override
public List<String> getInfo()

View file

@ -32,7 +32,7 @@ public class GuiChemicalOxidizer extends GuiMekanism
tileEntity = tentity;
guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalOxidizer.png")));
guiElements.add(new GuiUpgradeManagement(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalOxidizer.png")));
guiElements.add(new GuiUpgradeTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalOxidizer.png")));
guiElements.add(new GuiEnergyInfo(new IInfoHandler() {
@Override
public List<String> getInfo()

View file

@ -46,7 +46,7 @@ public class GuiDigitalMiner extends GuiMekanism
tileEntity = tentity;
guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiDigitalMiner.png")));
guiElements.add(new GuiUpgradeManagement(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiDigitalMiner.png")));
guiElements.add(new GuiUpgradeTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiDigitalMiner.png")));
guiElements.add(new GuiPowerBar(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiDigitalMiner.png"), 163, 23));
guiElements.add(new GuiEnergyInfo(new IInfoHandler() {
@Override

View file

@ -29,7 +29,7 @@ public class GuiElectricMachine extends GuiMekanism
tileEntity = tentity;
guiElements.add(new GuiRedstoneControl(this, tileEntity, tileEntity.guiLocation));
guiElements.add(new GuiUpgradeManagement(this, tileEntity, tileEntity.guiLocation));
guiElements.add(new GuiUpgradeTab(this, tileEntity, tileEntity.guiLocation));
guiElements.add(new GuiConfigurationTab(this, tileEntity, tileEntity.guiLocation));
guiElements.add(new GuiPowerBar(this, tileEntity, tileEntity.guiLocation, 164, 15));
guiElements.add(new GuiEnergyInfo(new IInfoHandler() {

View file

@ -31,7 +31,7 @@ public class GuiFactory extends GuiMekanism
ySize += 11;
guiElements.add(new GuiRedstoneControl(this, tileEntity, tileEntity.tier.guiLocation));
guiElements.add(new GuiUpgradeManagement(this, tileEntity, tileEntity.tier.guiLocation));
guiElements.add(new GuiUpgradeTab(this, tileEntity, tileEntity.tier.guiLocation));
guiElements.add(new GuiRecipeType(this, tileEntity, tileEntity.tier.guiLocation));
guiElements.add(new GuiConfigurationTab(this, tileEntity, tileEntity.tier.guiLocation));
guiElements.add(new GuiSortingTab(this, tileEntity, tileEntity.tier.guiLocation));

View file

@ -35,7 +35,7 @@ public class GuiMetallurgicInfuser extends GuiMekanism
tileEntity = tentity;
guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiMetallurgicInfuser.png")));
guiElements.add(new GuiUpgradeManagement(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiMetallurgicInfuser.png")));
guiElements.add(new GuiUpgradeTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiMetallurgicInfuser.png")));
guiElements.add(new GuiConfigurationTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiMetallurgicInfuser.png")));
guiElements.add(new GuiPowerBar(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiMetallurgicInfuser.png"), 164, 15));
guiElements.add(new GuiEnergyInfo(new IInfoHandler() {

View file

@ -31,7 +31,7 @@ public class GuiPRC extends GuiMekanism
guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png")));
guiElements.add(new GuiConfigurationTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png")));
guiElements.add(new GuiUpgradeManagement(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png")));
guiElements.add(new GuiUpgradeTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png")));
guiElements.add(new GuiFluidGauge(new IFluidInfoHandler() {
@Override
public FluidTank getTank()

View file

@ -1,101 +1,18 @@
package mekanism.client.gui;
import codechicken.lib.vec.Rectangle4i;
import mekanism.api.Coord4D;
import mekanism.client.sound.SoundHandler;
import mekanism.common.IUpgradeTile;
import mekanism.common.Mekanism;
import mekanism.common.network.PacketRemoveUpgrade.RemoveUpgradeMessage;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import mekanism.common.inventory.container.ContainerUpgradeManagement;
import net.minecraft.entity.player.InventoryPlayer;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class GuiUpgradeManagement extends GuiElement
@SideOnly(Side.CLIENT)
public class GuiUpgradeManagement extends GuiMekanism
{
TileEntity tileEntity;
public GuiUpgradeManagement(IGuiWrapper gui, TileEntity tile, ResourceLocation def)
{
super(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiUpgradeManagement.png"), gui, def);
tileEntity = tile;
}
public IUpgradeTile tileEntity;
@Override
public Rectangle4i getBounds(int guiWidth, int guiHeight)
public GuiUpgradeManagement(InventoryPlayer inventory, IUpgradeTile tileEntity)
{
return new Rectangle4i(guiWidth + 176, guiHeight + 6, 26, 63);
}
@Override
public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight)
{
mc.renderEngine.bindTexture(RESOURCE);
guiObj.drawTexturedRect(guiWidth + 176, guiHeight + 6, 0, 0, 26, 63);
IUpgradeTile upgradeTile = (IUpgradeTile)tileEntity;
int displayInt = upgradeTile.getComponent().getScaledUpgradeProgress(14);
guiObj.drawTexturedRect(guiWidth + 180, guiHeight + 30, 26, 0, 10, displayInt);
mc.renderEngine.bindTexture(defaultLocation);
}
@Override
public void renderForeground(int xAxis, int yAxis)
{
mc.renderEngine.bindTexture(RESOURCE);
IUpgradeTile upgradeTile = (IUpgradeTile)tileEntity;
if(getFontRenderer() != null)
{
getFontRenderer().drawString("S:" + (upgradeTile.getSpeedMultiplier()+1) + "x", 179, 47, 0x404040);
getFontRenderer().drawString("E:" + (upgradeTile.getEnergyMultiplier()+1) + "x", 179, 57, 0x404040);
}
if(xAxis >= 179 && xAxis <= 198 && yAxis >= 47 && yAxis <= 54)
{
displayTooltip(MekanismUtils.localize("gui.removeSpeedUpgrade"), xAxis, yAxis);
}
if(xAxis >= 179 && xAxis <= 198 && yAxis >= 57 && yAxis <= 64)
{
displayTooltip(MekanismUtils.localize("gui.removeEnergyUpgrade"), xAxis, yAxis);
}
mc.renderEngine.bindTexture(defaultLocation);
}
@Override
public void preMouseClicked(int xAxis, int yAxis, int button)
{
if(xAxis >= 180 && xAxis <= 196 && yAxis >= 11 && yAxis <= 27)
{
offsetX(26);
}
}
@Override
public void mouseClicked(int xAxis, int yAxis, int button)
{
if(xAxis >= 179 && xAxis <= 198 && yAxis >= 47 && yAxis <= 54)
{
SoundHandler.playSound("gui.button.press");
Mekanism.packetHandler.sendToServer(new RemoveUpgradeMessage(Coord4D.get(tileEntity), (byte)0));
}
if(xAxis >= 179 && xAxis <= 198 && yAxis >= 57 && yAxis <= 64)
{
SoundHandler.playSound("gui.button.press");
Mekanism.packetHandler.sendToServer(new RemoveUpgradeMessage(Coord4D.get(tileEntity), (byte)1));
}
if(xAxis >= 180 && xAxis <= 196 && yAxis >= 11 && yAxis <= 27)
{
offsetX(-26);
}
super(new ContainerUpgradeManagement(inventory, tileEntity));
}
}

View file

@ -0,0 +1,101 @@
package mekanism.client.gui;
import codechicken.lib.vec.Rectangle4i;
import mekanism.api.Coord4D;
import mekanism.client.sound.SoundHandler;
import mekanism.common.IUpgradeTile;
import mekanism.common.Mekanism;
import mekanism.common.network.PacketRemoveUpgrade.RemoveUpgradeMessage;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
public class GuiUpgradeTab extends GuiElement
{
TileEntity tileEntity;
public GuiUpgradeTab(IGuiWrapper gui, TileEntity tile, ResourceLocation def)
{
super(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiUpgradeManagement.png"), gui, def);
tileEntity = tile;
}
@Override
public Rectangle4i getBounds(int guiWidth, int guiHeight)
{
return new Rectangle4i(guiWidth + 176, guiHeight + 6, 26, 63);
}
@Override
public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight)
{
mc.renderEngine.bindTexture(RESOURCE);
guiObj.drawTexturedRect(guiWidth + 176, guiHeight + 6, 0, 0, 26, 63);
IUpgradeTile upgradeTile = (IUpgradeTile)tileEntity;
int displayInt = upgradeTile.getComponent().getScaledUpgradeProgress(14);
guiObj.drawTexturedRect(guiWidth + 180, guiHeight + 30, 26, 0, 10, displayInt);
mc.renderEngine.bindTexture(defaultLocation);
}
@Override
public void renderForeground(int xAxis, int yAxis)
{
mc.renderEngine.bindTexture(RESOURCE);
IUpgradeTile upgradeTile = (IUpgradeTile)tileEntity;
if(getFontRenderer() != null)
{
getFontRenderer().drawString("S:" + (upgradeTile.getSpeedMultiplier()+1) + "x", 179, 47, 0x404040);
getFontRenderer().drawString("E:" + (upgradeTile.getEnergyMultiplier()+1) + "x", 179, 57, 0x404040);
}
if(xAxis >= 179 && xAxis <= 198 && yAxis >= 47 && yAxis <= 54)
{
displayTooltip(MekanismUtils.localize("gui.removeSpeedUpgrade"), xAxis, yAxis);
}
if(xAxis >= 179 && xAxis <= 198 && yAxis >= 57 && yAxis <= 64)
{
displayTooltip(MekanismUtils.localize("gui.removeEnergyUpgrade"), xAxis, yAxis);
}
mc.renderEngine.bindTexture(defaultLocation);
}
@Override
public void preMouseClicked(int xAxis, int yAxis, int button)
{
if(xAxis >= 180 && xAxis <= 196 && yAxis >= 11 && yAxis <= 27)
{
offsetX(26);
}
}
@Override
public void mouseClicked(int xAxis, int yAxis, int button)
{
if(xAxis >= 179 && xAxis <= 198 && yAxis >= 47 && yAxis <= 54)
{
SoundHandler.playSound("gui.button.press");
Mekanism.packetHandler.sendToServer(new RemoveUpgradeMessage(Coord4D.get(tileEntity), (byte)0));
}
if(xAxis >= 179 && xAxis <= 198 && yAxis >= 57 && yAxis <= 64)
{
SoundHandler.playSound("gui.button.press");
Mekanism.packetHandler.sendToServer(new RemoveUpgradeMessage(Coord4D.get(tileEntity), (byte)1));
}
if(xAxis >= 180 && xAxis <= 196 && yAxis >= 11 && yAxis <= 27)
{
offsetX(-26);
}
}
}

View file

@ -30,10 +30,12 @@ public final class MinerVisualRenderer
GL11.glPushMatrix();
GL11.glTranslated(getX(miner.xCoord), getY(miner.yCoord), getZ(miner.zCoord));
MekanismRenderer.blendOn();
MekanismRenderer.glowOn();
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.8F);
mc.getTextureManager().bindTexture(MekanismRenderer.getBlocksTexture());
getList(new MinerRenderData(miner)).render();
MekanismRenderer.glowOff();
MekanismRenderer.blendOff();
GL11.glPopMatrix();
}

View file

@ -0,0 +1,26 @@
package mekanism.common;
import mekanism.common.util.MekanismUtils;
public enum Upgrade
{
SPEED("speed"),
ENERGY("energy");
private String name;
private Upgrade(String s)
{
name = s;
}
public String getName()
{
return MekanismUtils.localize("upgrade." + name);
}
public String getDescription()
{
return MekanismUtils.localize("upgrade." + name + ".desc");
}
}

View file

@ -30,15 +30,15 @@ public class ContainerAdvancedElectricMachine extends Container
int slotX;
for(slotX = 0; slotX < 3; ++slotX)
for(slotX = 0; slotX < 3; slotX++)
{
for(int slotY = 0; slotY < 9; ++slotY)
for(int slotY = 0; slotY < 9; slotY++)
{
addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18));
}
}
for(slotX = 0; slotX < 9; ++slotX)
for(slotX = 0; slotX < 9; slotX++)
{
addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142));
}

View file

@ -17,15 +17,15 @@ public class ContainerFilter extends Container
int slotX;
for(slotX = 0; slotX < 3; ++slotX)
for(slotX = 0; slotX < 3; slotX++)
{
for(int slotY = 0; slotY < 9; ++slotY)
for(int slotY = 0; slotY < 9; slotY++)
{
addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18));
}
}
for(slotX = 0; slotX < 9; ++slotX)
for(slotX = 0; slotX < 9; slotX++)
{
addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142));
}

View file

@ -0,0 +1,105 @@
package mekanism.common.inventory.container;
import mekanism.common.IUpgradeTile;
import mekanism.common.inventory.slot.SlotMachineUpgrade;
import mekanism.common.tile.TileEntityContainerBlock;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ContainerUpgradeManagement extends Container
{
private IUpgradeTile tileEntity;
public ContainerUpgradeManagement(InventoryPlayer inventory, IUpgradeTile tile)
{
tileEntity = tile;
addSlotToContainer(new SlotMachineUpgrade((TileEntityContainerBlock)tile, 3, 180, 11));
int slotX;
for(slotX = 0; slotX < 3; slotX++)
{
for(int slotY = 0; slotY < 9; slotY++)
{
addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18));
}
}
for(slotX = 0; slotX < 9; slotX++)
{
addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142));
}
((TileEntityContainerBlock)tileEntity).open(inventory.player);
((TileEntityContainerBlock)tileEntity).openInventory();
}
@Override
public void onContainerClosed(EntityPlayer entityplayer)
{
super.onContainerClosed(entityplayer);
((TileEntityContainerBlock)tileEntity).close(entityplayer);
((TileEntityContainerBlock)tileEntity).closeInventory();
}
@Override
public boolean canInteractWith(EntityPlayer entityplayer)
{
return ((TileEntityContainerBlock)tileEntity).isUseableByPlayer(entityplayer);
}
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slotID)
{
ItemStack stack = null;
Slot currentSlot = (Slot)inventorySlots.get(slotID);
if(currentSlot != null && currentSlot.getHasStack())
{
ItemStack slotStack = currentSlot.getStack();
stack = slotStack.copy();
if(slotID >= 0 && slotID <= 26)
{
if(!mergeItemStack(slotStack, 27, inventorySlots.size(), false))
{
return null;
}
}
else if(slotID > 26)
{
if(!mergeItemStack(slotStack, 0, 26, false))
{
return null;
}
}
else {
if(!mergeItemStack(slotStack, 0, inventorySlots.size(), true))
{
return null;
}
}
if(slotStack.stackSize == 0)
{
currentSlot.putStack((ItemStack)null);
}
else {
currentSlot.onSlotChanged();
}
if(slotStack.stackSize == stack.stackSize)
{
return null;
}
currentSlot.onPickupFromSlot(player, slotStack);
}
return stack;
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.7 KiB

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB