Reformatted some GUI

This commit is contained in:
Calclavia 2012-11-03 11:56:51 +08:00
parent cefb0245bd
commit bd78faab1f
5 changed files with 118 additions and 109 deletions

View file

@ -3,19 +3,15 @@ package assemblyline.ai;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.src.TileEntity;
import cpw.mods.fml.common.FMLLog;
import universalelectricity.prefab.TileEntityAdvanced;
public class TileEntityAI extends TileEntityAdvanced
public class TaskManager
{
private final List<Task> tasks = new ArrayList<Task>();
public void updateEntity()
public void onUpdate()
{
super.updateEntity();
/**
* Loop through each task and do them.
*/
@ -43,9 +39,9 @@ public class TileEntityAI extends TileEntityAdvanced
}
}
public void addTask(Task task)
public void addTask(TileEntity tileEntity, Task task)
{
task.setTileEntity(this);
task.setTileEntity(tileEntity);
task.onTaskStart();
tasks.add(task);
}

View file

@ -15,33 +15,40 @@ import cpw.mods.fml.common.asm.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiAutoCrafting extends GuiContainer
{
public GuiAutoCrafting(InventoryPlayer par1InventoryPlayer, World par2World, int par3, int par4, int par5)
{
super(new ContainerWorkbench(par1InventoryPlayer, par2World, par3, par4, par5));
//TODO on opening if the user is not the owner they can see the crafting recipes but if
//the machine is locked they can't do anything with it
//Also the need to add a locking button can only be activate by the owner
}
public GuiAutoCrafting(InventoryPlayer par1InventoryPlayer, World par2World, int par3, int par4, int par5)
{
super(new ContainerWorkbench(par1InventoryPlayer, par2World, par3, par4, par5));
// TODO on opening if the user is not the
// owner they can see the crafting recipes
// but if
// the machine is locked they can't do
// anything with it
// Also the need to add a locking button
// can only be activate by the owner
}
/**
* Draw the foreground layer for the GuiContainer (everything in front of the items)
*/
protected void drawGuiContainerForegroundLayer()
{
this.fontRenderer.drawString(StatCollector.translateToLocal("AutoCrafter"), 28, 6, 4210752);
this.fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
}
/**
* Draw the foreground layer for the
* GuiContainer (everything in front of the
* items)
*/
protected void drawGuiContainerForegroundLayer()
{
this.fontRenderer.drawString(StatCollector.translateToLocal("AutoCrafter"), 28, 6, 4210752);
this.fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
}
/**
* Draw the background layer for the GuiContainer (everything behind the items)
*/
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
{
int var4 = this.mc.renderEngine.getTexture(AssemblyLine.TEXTURE_PATH+"gui_crafting.png");
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.renderEngine.bindTexture(var4);
int var5 = (this.width - this.xSize) / 2;
int var6 = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(var5, var6, 0, 0, this.xSize, this.ySize);
}
/**
* Draw the background layer for the
* GuiContainer (everything behind the items)
*/
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
{
int var4 = this.mc.renderEngine.getTexture(AssemblyLine.TEXTURE_PATH + "gui_crafting.png");
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.renderEngine.bindTexture(var4);
int var5 = (this.width - this.xSize) / 2;
int var6 = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(var5, var6, 0, 0, this.xSize, this.ySize);
}
}

View file

@ -7,40 +7,44 @@ import org.lwjgl.opengl.GL11;
import cpw.mods.fml.common.Side;
import cpw.mods.fml.common.asm.SideOnly;
/**
* Copied from GSM lib and modified for this mod only
* Copied from GSM lib and modified for this mod
* only
*
* @author Rseifert
*
*
*/
@SideOnly(Side.CLIENT)
public class GuiButtonImage extends GuiButton
{
private int type = 0;
public GuiButtonImage(int par1, int par2, int par3,int type)
{
super(par1, par2, par3, 12, 12, "");
this.type = type;
}
/**
* Draws this button to the screen.
*/
@Override
public void drawButton(Minecraft par1Minecraft, int width, int hight)
{
if (this.drawButton)
{
GL11.glBindTexture(GL11.GL_TEXTURE_2D, par1Minecraft.renderEngine.getTexture("/assemblyline/textures/gui@.png"));
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
boolean var4 = width >= this.xPosition && hight >= this.yPosition && width < this.xPosition + this.width && hight < this.yPosition + this.height;
int var5 = 106;
int var6 = 0;
if (var4)
{
var5 += this.height;
}
public GuiButtonImage(int par1, int par2, int par3, int type)
{
super(par1, par2, par3, 12, 12, "");
this.type = type;
}
this.drawTexturedModalRect(this.xPosition, this.yPosition, var6, var5, this.width, this.height);
}
}
/**
* Draws this button to the screen.
*/
@Override
public void drawButton(Minecraft par1Minecraft, int width, int hight)
{
if (this.drawButton)
{
GL11.glBindTexture(GL11.GL_TEXTURE_2D, par1Minecraft.renderEngine.getTexture("/assemblyline/textures/gui@.png"));
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
boolean var4 = width >= this.xPosition && hight >= this.yPosition && width < this.xPosition + this.width && hight < this.yPosition + this.height;
int var5 = 106;
int var6 = 0;
if (var4)
{
var5 += this.height;
}
this.drawTexturedModalRect(this.xPosition, this.yPosition, var6, var5, this.width, this.height);
}
}
}

View file

@ -12,98 +12,100 @@ import assemblyline.AssemblyLine;
import assemblyline.machines.ContainerSorter;
import assemblyline.machines.TileEntitySorter;
public class GuiSorter extends GuiContainer {
public class GuiSorter extends GuiContainer
{
private TileEntitySorter tileEntity;
private int containerWidth;
private int containerHeight;
public GuiSorter(InventoryPlayer par1InventoryPlayer,
TileEntitySorter tileEntity) {
public GuiSorter(InventoryPlayer par1InventoryPlayer, TileEntitySorter tileEntity)
{
super(new ContainerSorter(par1InventoryPlayer, tileEntity));
this.tileEntity = tileEntity;
}
public void initGui() {
public void initGui()
{
super.initGui();
Keyboard.enableRepeatEvents(true);
this.controlList.clear();
int wid = (this.width - this.xSize) / 2;
int hig = (this.height - this.ySize) / 2;
this.controlList.add(new GuiButton(0, wid + 112, hig + 32, 44,19, "Toggle"));
for(int i = 1; i < this.tileEntity.guiButtons.length; i++)
this.controlList.add(new GuiButton(0, wid + 112, hig + 32, 44, 19, "Toggle"));
for (int i = 1; i < this.tileEntity.guiButtons.length; i++)
{
this.controlList.add(new GuiButtonImage(i, wid + 17 + i*18, hig + 17, 0));
this.controlList.add(new GuiButtonImage(i, wid + 17 + i * 18, hig + 17, 0));
}
}
public void updateScreen() {
public void updateScreen()
{
super.updateScreen();
}
/**
* Fired when a control is clicked. This is the equivalent of
* ActionListener.actionPerformed(ActionEvent e).
* Fired when a control is clicked. This is
* the equivalent of
* ActionListener.actionPerformed(ActionEvent
* e).
*/
protected void actionPerformed(GuiButton button)
protected void actionPerformed(GuiButton button)
{
if(button.id < 5)
if (button.id < 5)
{
this.tileEntity.changeOnOff(button.id);
}
super.actionPerformed(button);
}
protected void keyTyped(char par1, int par2) {
protected void keyTyped(char par1, int par2)
{
super.keyTyped(par1, par2);
}
protected void mouseClicked(int par1, int par2, int par3) {
protected void mouseClicked(int par1, int par2, int par3)
{
super.mouseClicked(par1, par2, par3);
}
public void onGuiClosed() {
public void onGuiClosed()
{
super.onGuiClosed();
}
/**
* Draw the foreground layer for the GuiContainer (everything in front of
* the items)
*/
@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
this.fontRenderer.drawString(this.tileEntity.getInvName(), 55, 6, 4210752);
this.fontRenderer.drawString(
"Voltage: " + (int) this.tileEntity.getVoltage(), 95, 60,
4210752);
this.fontRenderer.drawString(
StatCollector.translateToLocal("container.inventory"), 8,
this.ySize - 96 + 2, 4210752);
}
/**
* Draw the background layer for the GuiContainer (everything behind the
* Draw the foreground layer for the
* GuiContainer (everything in front of the
* items)
*/
@Override
protected void drawGuiContainerBackgroundLayer(float par1, int par2,
int par3) {
int var4 = this.mc.renderEngine.getTexture(AssemblyLine.TEXTURE_PATH
+ "gui_ejector.png");
protected void drawGuiContainerForegroundLayer(int par1, int par2)
{
this.fontRenderer.drawString(this.tileEntity.getInvName(), 55, 6, 4210752);
this.fontRenderer.drawString("Voltage: " + (int) this.tileEntity.getVoltage(), 95, 60, 4210752);
this.fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
}
/**
* Draw the background layer for the
* GuiContainer (everything behind the items)
*/
@Override
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
{
int var4 = this.mc.renderEngine.getTexture(AssemblyLine.TEXTURE_PATH + "gui_ejector.png");
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.renderEngine.bindTexture(var4);
containerWidth = (this.width - this.xSize) / 2;
containerHeight = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(containerWidth, containerHeight, 0, 0,
this.xSize, this.ySize);
//GUI button changes
for(int i = 1; i < this.tileEntity.guiButtons.length; i++)
this.drawTexturedModalRect(containerWidth, containerHeight, 0, 0, this.xSize, this.ySize);
// GUI button changes
for (int i = 1; i < this.tileEntity.guiButtons.length; i++)
{
this.drawTexturedModalRect(containerWidth+17+i*18, containerHeight+17, 176, +(tileEntity.guiButtons[i] ? 12 : 0), 12, 12);
this.drawTexturedModalRect(containerWidth + 17 + i * 18, containerHeight + 17, 176, +(tileEntity.guiButtons[i] ? 12 : 0), 12, 12);
}
this.fontRenderer.drawString(
"Reject: "+(tileEntity.guiButtons[0] ? "Inv" : "Other"), containerWidth + 108,
containerHeight +22, 4210752);
this.fontRenderer.drawString("Reject: " + (tileEntity.guiButtons[0] ? "Inv" : "Other"), containerWidth + 108, containerHeight + 22, 4210752);
}
}

View file

@ -21,7 +21,7 @@ public class RenderManipulator extends TileEntitySpecialRenderer
GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
GL11.glRotatef(180f, 0f, 0f, 1f);
if(tileEntity.isOutput)
if (tileEntity.isOutput)
{
this.bindTextureByName(AssemblyLine.TEXTURE_PATH + "manipulator1.png");
}
@ -29,7 +29,7 @@ public class RenderManipulator extends TileEntitySpecialRenderer
{
this.bindTextureByName(AssemblyLine.TEXTURE_PATH + "manipulator2.png");
}
if (face == 2)
{
GL11.glRotatef(0f, 0f, 1f, 0f);