diff --git a/src/main/java/techreborn/client/gui/GuiIDSU.java b/src/main/java/techreborn/client/gui/GuiIDSU.java index f39a61d4c..9af65ddd9 100644 --- a/src/main/java/techreborn/client/gui/GuiIDSU.java +++ b/src/main/java/techreborn/client/gui/GuiIDSU.java @@ -6,10 +6,12 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; import net.minecraft.world.World; import techreborn.client.container.ContainerIDSU; +import techreborn.client.gui.componets.TabIDConfig; import techreborn.cofhLib.gui.GuiBase; import techreborn.cofhLib.gui.element.ElementListBox; import techreborn.cofhLib.gui.element.ElementTextField; import techreborn.cofhLib.gui.element.ElementTextFieldLimited; +import techreborn.cofhLib.gui.element.listbox.IListBoxElement; import techreborn.cofhLib.gui.element.listbox.ListBoxElementText; import techreborn.packets.PacketHandler; import techreborn.packets.PacketIdsu; @@ -18,6 +20,9 @@ import techreborn.tiles.idsu.IDSUManager; import techreborn.tiles.idsu.TileIDSU; import techreborn.util.LogHelper; +import java.util.LinkedList; +import java.util.List; + public class GuiIDSU extends GuiBase { @@ -25,12 +30,13 @@ public class GuiIDSU extends GuiBase { ContainerIDSU containerIDSU; - ElementListBox listBox; + public static ElementListBox listBox = new ElementListBox(null, 10, 28, 80, 60); ElementTextFieldLimited idFeild; ElementTextField nameFeild; + public GuiIDSU(EntityPlayer player, TileIDSU tileIDSU) { @@ -58,25 +64,8 @@ public class GuiIDSU extends GuiBase { this.buttonList.add(new GuiButton(3, k + 96, l + 8 + (22*3), 18, 20, "--")); this.buttonList.add(new GuiButton(4, k + 40, l + 10, 10, 10, "+")); - listBox = new ElementListBox(this, 10, 28, 80, 60); + listBox.gui = this; - if(idsu.getWorldObj() != null){ - - for(World world : ClientSideIDSUManager.CLIENT.worldData.keySet()){ - // System.out.println(world.n + ":" + idsu.getWorldObj().getProviderName()); - //if(world.getProviderName().equals(idsu.getWorldObj().getProviderName())){ - IDSUManager.IDSUWorldSaveData saveData = ClientSideIDSUManager.CLIENT.getWorldDataFormWorld(world); - for(Integer id : saveData.idsuValues.keySet()){ - IDSUManager.IDSUValueSaveData valueSaveData = saveData.idsuValues.get(id); - if(valueSaveData.name != ""){ - listBox.add(new ListBoxElementText(valueSaveData.name + " - " + id)); - } else { - listBox.add(new ListBoxElementText(id.toString())); - } - } - // } - } - } // listBox.borderColor = new GuiColor(120, 120, 120, 0).getColor(); // listBox.backgroundColor = new GuiColor(0, 0, 0, 32).getColor(); addElement(listBox); @@ -90,6 +79,8 @@ public class GuiIDSU extends GuiBase { addElement(nameFeild); +// tabs.add(new TabIDConfig(this)); + } diff --git a/src/main/java/techreborn/client/gui/componets/TabIDConfig.java b/src/main/java/techreborn/client/gui/componets/TabIDConfig.java new file mode 100644 index 000000000..de221a8ac --- /dev/null +++ b/src/main/java/techreborn/client/gui/componets/TabIDConfig.java @@ -0,0 +1,13 @@ +package techreborn.client.gui.componets; + +import techreborn.cofhLib.gui.GuiBase; +import techreborn.cofhLib.gui.element.TabBase; + +/** + * Created by mark on 18/06/15. + */ +public class TabIDConfig extends TabBase { + public TabIDConfig(GuiBase gui) { + super(gui); + } +} diff --git a/src/main/java/techreborn/cofhLib/gui/GuiProps.java b/src/main/java/techreborn/cofhLib/gui/GuiProps.java index d112be35d..f1d335569 100755 --- a/src/main/java/techreborn/cofhLib/gui/GuiProps.java +++ b/src/main/java/techreborn/cofhLib/gui/GuiProps.java @@ -1,12 +1,15 @@ package techreborn.cofhLib.gui; -import com.pahimar.ee3.reference.Textures; +import techreborn.lib.ModInfo; public class GuiProps { + + public static final String RESOURCE_PREFIX = ModInfo.MOD_ID + ":"; + /* GUI */ - public static final String PATH_GFX = Textures.RESOURCE_PREFIX + "textures/"; + public static final String PATH_GFX = RESOURCE_PREFIX + "textures/"; public static final String PATH_ARMOR = PATH_GFX + "armor/"; public static final String PATH_GUI = PATH_GFX + "gui/"; public static final String PATH_RENDER = PATH_GFX + "blocks/"; diff --git a/src/main/java/techreborn/cofhLib/gui/element/ElementBase.java b/src/main/java/techreborn/cofhLib/gui/element/ElementBase.java index e1ee9ea37..d3e1fef9e 100755 --- a/src/main/java/techreborn/cofhLib/gui/element/ElementBase.java +++ b/src/main/java/techreborn/cofhLib/gui/element/ElementBase.java @@ -16,7 +16,7 @@ import java.util.List; public abstract class ElementBase { - protected GuiBase gui; + public GuiBase gui; protected ResourceLocation texture; protected int posX; diff --git a/src/main/java/techreborn/cofhLib/gui/element/ElementListBox.java b/src/main/java/techreborn/cofhLib/gui/element/ElementListBox.java index 6d309cd0b..4d8c3d0f2 100755 --- a/src/main/java/techreborn/cofhLib/gui/element/ElementListBox.java +++ b/src/main/java/techreborn/cofhLib/gui/element/ElementListBox.java @@ -23,7 +23,7 @@ public class ElementListBox extends ElementBase { private final int _marginRight = 2; private final int _marginBottom = 2; - private final List _elements = new LinkedList(); + public List _elements = new LinkedList(); private int _firstIndexDisplayed; private int _selectedIndex; diff --git a/src/main/java/techreborn/packets/PacketSendIDSUManager.java b/src/main/java/techreborn/packets/PacketSendIDSUManager.java index c3f42cec6..f620a546f 100644 --- a/src/main/java/techreborn/packets/PacketSendIDSUManager.java +++ b/src/main/java/techreborn/packets/PacketSendIDSUManager.java @@ -3,7 +3,11 @@ package techreborn.packets; import io.netty.buffer.ByteBuf; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.network.PacketBuffer; +import net.minecraft.world.World; +import techreborn.client.gui.GuiIDSU; +import techreborn.cofhLib.gui.element.listbox.ListBoxElementText; import techreborn.tiles.idsu.ClientSideIDSUManager; +import techreborn.tiles.idsu.IDSUManager; import java.io.IOException; @@ -36,5 +40,23 @@ public class PacketSendIDSUManager extends SimplePacket { @Override public void execute() { ClientSideIDSUManager.CLIENT.loadFromString(json, player.worldObj); + + if(player.worldObj != null){ + GuiIDSU.listBox._elements.clear(); + for(World world : ClientSideIDSUManager.CLIENT.worldData.keySet()){ + // System.out.println(world.n + ":" + idsu.getWorldObj().getProviderName()); + //if(world.getProviderName().equals(idsu.getWorldObj().getProviderName())){ + IDSUManager.IDSUWorldSaveData saveData = ClientSideIDSUManager.CLIENT.getWorldDataFormWorld(world); + for(Integer id : saveData.idsuValues.keySet()){ + IDSUManager.IDSUValueSaveData valueSaveData = saveData.idsuValues.get(id); + if(!valueSaveData.name.isEmpty()){ + GuiIDSU.listBox._elements.add(new ListBoxElementText(valueSaveData.name + " - " + id)); + } else { + GuiIDSU.listBox._elements.add(new ListBoxElementText(id.toString())); + } + } + // } + } + } } }