Files
TinkersConstruct/src/main/java/tconstruct/tools/gui/ToolForgeGui.java
T

123 lines
4.5 KiB
Java
Raw Normal View History

package tconstruct.tools.gui;
2014-09-09 18:30:15 +10:00
import cpw.mods.fml.relauncher.*;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
2013-12-01 20:41:33 +01:00
import net.minecraft.util.StatCollector;
2014-02-05 10:28:54 -05:00
import net.minecraft.world.World;
2014-09-09 18:30:15 +10:00
import tconstruct.library.client.*;
2014-06-04 21:44:48 -08:00
import tconstruct.tools.logic.ToolForgeLogic;
@SideOnly(Side.CLIENT)
public class ToolForgeGui extends ToolStationGui
{
int selectedButton;
public ToolForgeGui(InventoryPlayer inventoryplayer, ToolForgeLogic stationlogic, World world, int x, int y, int z)
{
super(inventoryplayer, stationlogic, world, x, y, z);
}
2014-02-17 00:31:43 -05:00
@Override
public void initGui ()
{
super.initGui();
2014-02-05 08:28:53 -05:00
this.buttonList.clear();
ToolGuiElement repair = TConstructClientRegistry.toolButtons.get(0);
2014-05-14 09:52:04 -05:00
GuiButtonTool repairButton = new GuiButtonTool(0, this.guiLeft, this.guiTop, repair.buttonIconX, repair.buttonIconY, repair.domain, repair.texture, repair); // Repair
2014-02-05 08:28:53 -05:00
repairButton.enabled = false;
this.buttonList.add(repairButton);
int offset = TConstructClientRegistry.tierTwoButtons.size();
for (int iter = 0; iter < TConstructClientRegistry.tierTwoButtons.size(); iter++)
{
ToolGuiElement element = TConstructClientRegistry.tierTwoButtons.get(iter);
2014-09-09 18:30:15 +10:00
GuiButtonTool button = new GuiButtonTool(iter + 1, this.guiLeft + 22 * ((iter + 1) % 5), this.guiTop + 22 * ((iter + 1) / 5), element.buttonIconX, element.buttonIconY, repair.domain, element.texture, element);
2014-02-05 08:28:53 -05:00
this.buttonList.add(button);
}
for (int iter = 1; iter < TConstructClientRegistry.toolButtons.size(); iter++)
{
ToolGuiElement element = TConstructClientRegistry.toolButtons.get(iter);
2014-09-09 18:30:15 +10:00
GuiButtonTool button = new GuiButtonTool(iter + offset, this.guiLeft + 22 * ((iter + offset) % 5), this.guiTop + 22 * ((iter + offset) / 5), element.buttonIconX, element.buttonIconY, repair.domain, element.texture, element);
2014-02-05 08:28:53 -05:00
this.buttonList.add(button);
}
}
2014-02-17 00:31:43 -05:00
@Override
protected void actionPerformed (GuiButton button)
{
GuiButtonTool b = (GuiButtonTool) button;
2014-02-05 08:28:53 -05:00
((GuiButton) this.buttonList.get(selectedButton)).enabled = true;
selectedButton = button.id;
button.enabled = false;
setSlotType(b.element.slotType);
iconX = b.element.iconsX;
iconY = b.element.iconsY;
title = "\u00A7n" + b.element.title;
2014-10-24 12:03:50 +02:00
body = StatCollector.translateToLocal(b.element.body);
if(body != null) {
int i;
// for some really weird reason replaceAll doesn't find "\\n", but indexOf does. We have to replace manually.
while((i = body.indexOf("\\n")) >= 0)
{
body = body.substring(0, i) + '\n' + body.substring(i+2);
}
}
}
@Override
void resetGui ()
{
2014-02-05 08:28:53 -05:00
this.text.setText("");
selectedButton = 0;
setSlotType(0);
iconX = new int[] { 0, 1, 2, 13 };
iconY = new int[] { 13, 13, 13, 13 };
2014-02-05 09:11:06 -05:00
title = "\u00A7n" + StatCollector.translateToLocal("gui.toolforge1");
2013-12-01 21:42:03 +00:00
body = StatCollector.translateToLocal("gui.toolforge2");
}
2014-02-17 00:31:43 -05:00
@Override
void setSlotType (int type)
{
switch (type)
{
case 0:
slotX = new int[] { 56, 38, 38, 14 }; // Repair
slotY = new int[] { 37, 28, 46, 37 };
break;
case 1:
slotX = new int[] { 56, 56, 56, 14 }; // Three parts
slotY = new int[] { 19, 55, 37, 37 };
break;
case 2:
slotX = new int[] { 56, 56, 14, 14 }; // Two parts
slotY = new int[] { 28, 46, 28, 46 };
break;
case 3:
slotX = new int[] { 38, 47, 56, 14 }; // Double head
slotY = new int[] { 28, 46, 28, 37 };
break;
case 4:
slotX = new int[] { 47, 38, 56, 47 }; // Four parts
slotY = new int[] { 19, 37, 37, 55 };
break;
case 5:
slotX = new int[] { 38, 47, 56, 47 }; // Four parts, double head
slotY = new int[] { 19, 55, 19, 37 };
break;
case 6:
slotX = new int[] { 38, 38, 20, 56 }; // Double head
slotY = new int[] { 28, 46, 28, 28 };
break;
case 7:
slotX = new int[] { 56, 56, 56, 14 }; // Three parts reverse
slotY = new int[] { 19, 37, 55, 37 };
break;
}
toolSlots.resetSlots(slotX, slotY);
}
}