OSDN Git Service

原子記号と番号書いてー
[chemicraft/chemicraft.git] / common / chemicraft / gui / GuiChemicalCombinationTable.java
1 package chemicraft.gui;
2
3 import java.util.Arrays;
4
5 import net.minecraft.src.EntityPlayer;
6 import net.minecraft.src.GuiButton;
7 import net.minecraft.src.GuiContainer;
8 import net.minecraft.src.GuiTextField;
9 import net.minecraft.src.IInventory;
10 import net.minecraft.src.ItemStack;
11 import chemicraft.ChemiCraft;
12 import chemicraft.container.ContainerChemicalCombinationTable;
13 import chemicraft.tileentity.TileEntityChemicalCombinationTable;
14 import chemicraft.util.Auxiliary.ArrayAuxiliary;
15 import chemicraft.util.ComparatorItemStack;
16 import cpw.mods.fml.common.network.PacketDispatcher;
17
18 public class GuiChemicalCombinationTable extends GuiContainer {
19
20         private GuiTextField atomList;
21
22         private TileEntityChemicalCombinationTable tileentity;
23
24         public GuiChemicalCombinationTable(EntityPlayer par1EntityPlayer, TileEntityChemicalCombinationTable par2) {
25                 super(new ContainerChemicalCombinationTable(par1EntityPlayer, par2));
26                 this.tileentity = par2;
27         }
28
29         @Override
30         public void initGui(){
31                 super.initGui();
32                 this.atomList = new GuiTextField(this.fontRenderer, 92, 7, 80, 15);
33                 this.atomList.setFocused(false);
34                 this.atomList.setMaxStringLength(10);
35                 this.controlList.add(new GuiButton(0, this.guiLeft + 132 - 41, this.guiTop + 63, 40, 20, "Add"));
36                 this.controlList.add(new GuiButton(1, this.guiLeft + 132, this.guiTop + 63, 40, 20, "Eject"));
37         }
38
39         @Override
40         protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) {
41                 this.mc.renderEngine.bindTexture(this.mc.renderEngine.getTexture(ChemiCraft.instance.guiChemicalCombinationTexture));
42                 this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize);
43         }
44
45         @Override
46         protected void actionPerformed(GuiButton par1GuiButton) {
47                 if(par1GuiButton.id == 0){
48                         this.field_00001(this.tileentity);
49                         PacketDispatcher.sendPacketToServer(this.tileentity.getDescriptionPacket());
50                 }else if(par1GuiButton.id == 1){
51
52                 }
53                 return;
54         }
55
56         protected void field_00001(TileEntityChemicalCombinationTable par1){
57                 IInventory inv = par1.getInvMaterial();
58                 ItemStack[] stacks = new ItemStack[inv.getSizeInventory()];
59                 for(int i = 0;i < stacks.length;i++){
60                         if(inv.getStackInSlot(i) != null){
61                                 stacks[i] = inv.getStackInSlot(i);
62                         }
63                 }
64                 Arrays.sort(stacks, new ComparatorItemStack());
65                 stacks = ChemiCraft.instance.arrayAuxiliary.deleteNull(stacks);
66
67                 for(int i = 0;i < stacks.length;i++){
68                 }
69         }
70
71         @Override
72         protected void drawGuiContainerForegroundLayer() {
73                 this.atomList.drawTextBox();
74         }
75
76 }