Work on GUI, things are starting to work
This commit is contained in:
parent
76b93bec65
commit
dc611eb0b2
2 changed files with 76 additions and 5 deletions
|
@ -1,5 +1,9 @@
|
||||||
package mekanism.client.gui;
|
package mekanism.client.gui;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import mekanism.api.Coord4D;
|
||||||
import mekanism.api.EnumColor;
|
import mekanism.api.EnumColor;
|
||||||
import mekanism.client.gui.element.GuiPowerBar;
|
import mekanism.client.gui.element.GuiPowerBar;
|
||||||
import mekanism.client.gui.element.GuiScrollList;
|
import mekanism.client.gui.element.GuiScrollList;
|
||||||
|
@ -7,7 +11,10 @@ import mekanism.client.gui.element.GuiSlot;
|
||||||
import mekanism.client.gui.element.GuiSlot.SlotOverlay;
|
import mekanism.client.gui.element.GuiSlot.SlotOverlay;
|
||||||
import mekanism.client.gui.element.GuiSlot.SlotType;
|
import mekanism.client.gui.element.GuiSlot.SlotType;
|
||||||
import mekanism.client.sound.SoundHandler;
|
import mekanism.client.sound.SoundHandler;
|
||||||
|
import mekanism.common.Mekanism;
|
||||||
|
import mekanism.common.frequency.Frequency;
|
||||||
import mekanism.common.inventory.container.ContainerTeleporter;
|
import mekanism.common.inventory.container.ContainerTeleporter;
|
||||||
|
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||||
import mekanism.common.tile.TileEntityTeleporter;
|
import mekanism.common.tile.TileEntityTeleporter;
|
||||||
import mekanism.common.util.MekanismUtils;
|
import mekanism.common.util.MekanismUtils;
|
||||||
import mekanism.common.util.MekanismUtils.ResourceType;
|
import mekanism.common.util.MekanismUtils.ResourceType;
|
||||||
|
@ -88,6 +95,15 @@ public class GuiTeleporter extends GuiMekanism
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ArrayList data = new ArrayList();
|
||||||
|
data.add(0);
|
||||||
|
data.add(text);
|
||||||
|
data.add(!privateMode);
|
||||||
|
|
||||||
|
Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data));
|
||||||
|
|
||||||
|
frequencyField.setText("");
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSecurity()
|
public String getSecurity()
|
||||||
|
@ -97,6 +113,11 @@ public class GuiTeleporter extends GuiMekanism
|
||||||
|
|
||||||
public void updateButtons()
|
public void updateButtons()
|
||||||
{
|
{
|
||||||
|
if(tileEntity.owner == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(privateMode)
|
if(privateMode)
|
||||||
{
|
{
|
||||||
publicButton.enabled = true;
|
publicButton.enabled = true;
|
||||||
|
@ -108,10 +129,25 @@ public class GuiTeleporter extends GuiMekanism
|
||||||
}
|
}
|
||||||
|
|
||||||
if(scrollList.hasSelection())
|
if(scrollList.hasSelection())
|
||||||
|
{
|
||||||
|
Frequency freq = privateMode ? tileEntity.privateCache.get(scrollList.selected) : tileEntity.publicCache.get(scrollList.selected);
|
||||||
|
|
||||||
|
if(tileEntity.frequency == null || !tileEntity.frequency.equals(freq))
|
||||||
{
|
{
|
||||||
setButton.enabled = true;
|
setButton.enabled = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
setButton.enabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(tileEntity.owner.equals(freq.owner))
|
||||||
|
{
|
||||||
deleteButton.enabled = true;
|
deleteButton.enabled = true;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
deleteButton.enabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
setButton.enabled = false;
|
setButton.enabled = false;
|
||||||
deleteButton.enabled = false;
|
deleteButton.enabled = false;
|
||||||
|
@ -125,6 +161,24 @@ public class GuiTeleporter extends GuiMekanism
|
||||||
|
|
||||||
updateButtons();
|
updateButtons();
|
||||||
|
|
||||||
|
List<String> text = new ArrayList<String>();
|
||||||
|
|
||||||
|
if(privateMode)
|
||||||
|
{
|
||||||
|
for(Frequency freq : tileEntity.privateCache)
|
||||||
|
{
|
||||||
|
text.add(freq.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
for(Frequency freq : tileEntity.publicCache)
|
||||||
|
{
|
||||||
|
text.add(freq.name + " (" + freq.owner + ")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
scrollList.setText(text);
|
||||||
|
|
||||||
frequencyField.updateCursorCounter();
|
frequencyField.updateCursorCounter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,6 +199,7 @@ public class GuiTeleporter extends GuiMekanism
|
||||||
if(xAxis >= 137 && xAxis <= 148 && yAxis >= 103 && yAxis <= 114)
|
if(xAxis >= 137 && xAxis <= 148 && yAxis >= 103 && yAxis <= 114)
|
||||||
{
|
{
|
||||||
setFrequency();
|
setFrequency();
|
||||||
|
frequencyField.setText("");
|
||||||
SoundHandler.playSound("gui.button.press");
|
SoundHandler.playSound("gui.button.press");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -189,11 +244,25 @@ public class GuiTeleporter extends GuiMekanism
|
||||||
}
|
}
|
||||||
else if(guibutton.id == 2)
|
else if(guibutton.id == 2)
|
||||||
{
|
{
|
||||||
|
setFrequency();
|
||||||
}
|
}
|
||||||
else if(guibutton.id == 3)
|
else if(guibutton.id == 3)
|
||||||
{
|
{
|
||||||
|
int selection = scrollList.getSelection();
|
||||||
|
|
||||||
|
if(selection != -1)
|
||||||
|
{
|
||||||
|
Frequency freq = privateMode ? tileEntity.privateCache.get(selection) : tileEntity.publicCache.get(selection);
|
||||||
|
|
||||||
|
ArrayList data = new ArrayList();
|
||||||
|
data.add(1);
|
||||||
|
data.add(freq.name);
|
||||||
|
data.add(freq.publicFreq);
|
||||||
|
|
||||||
|
Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data));
|
||||||
|
|
||||||
|
scrollList.selected = -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateButtons();
|
updateButtons();
|
||||||
|
@ -206,7 +275,7 @@ public class GuiTeleporter extends GuiMekanism
|
||||||
int yAxis = (mouseY-(height-ySize)/2);
|
int yAxis = (mouseY-(height-ySize)/2);
|
||||||
|
|
||||||
fontRendererObj.drawString(tileEntity.getInventoryName(), (xSize/2)-(fontRendererObj.getStringWidth(tileEntity.getInventoryName())/2), 4, 0x404040);
|
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(MekanismUtils.localize("gui.owner") + ": " + (tileEntity.owner != null ? tileEntity.owner : MekanismUtils.localize("gui.none")), 8, (ySize-96)+4, 0x404040);
|
||||||
|
|
||||||
fontRendererObj.drawString(MekanismUtils.localize("gui.freq") + ":", 32, 81, 0x404040);
|
fontRendererObj.drawString(MekanismUtils.localize("gui.freq") + ":", 32, 81, 0x404040);
|
||||||
fontRendererObj.drawString(MekanismUtils.localize("gui.security") + ":", 32, 91, 0x404040);
|
fontRendererObj.drawString(MekanismUtils.localize("gui.security") + ":", 32, 91, 0x404040);
|
||||||
|
|
|
@ -146,11 +146,13 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
||||||
Frequency freq = new Frequency(name, owner).setPublic(publicFreq);
|
Frequency freq = new Frequency(name, owner).setPublic(publicFreq);
|
||||||
freq.activeCoords.add(Coord4D.get(this));
|
freq.activeCoords.add(Coord4D.get(this));
|
||||||
manager.addFrequency(freq);
|
manager.addFrequency(freq);
|
||||||
|
|
||||||
|
frequency = freq;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FrequencyManager getManager(Frequency freq)
|
public FrequencyManager getManager(Frequency freq)
|
||||||
{
|
{
|
||||||
if(owner == null)
|
if(owner == null || freq == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue