worked on encoder

This commit is contained in:
DarkGuardsman 2013-11-29 23:20:02 -05:00
parent 3ec2c9e60e
commit 20a03233af
14 changed files with 316 additions and 205 deletions

View file

@ -8,7 +8,7 @@ import universalelectricity.core.vector.Vector2;
/** Flow chart style program. Each command in the program needs to have a stored location so it can
* be saved and loaded with its correct connections. Though the location only need to be a simple
* Column and row based system.
*
*
* @author DarkGuardsman */
public interface IProgram extends Cloneable
{
@ -25,17 +25,17 @@ public interface IProgram extends Cloneable
public ITask getNextTask();
/** Gets a task at the given x y location in the program */
public ITask getTaskAt(Vector2 vector2);
public ITask getTaskAt(int col, int row);
/** Returns the entire program as a map as grid locations and tasks. */
public HashMap<Vector2, ITask> getTaskMap();
/** Sets the task at the point overriding what was there. If the task is null remove it and shift
* everything up one */
public void setTaskAt(Vector2 vector2, ITask task);
public void setTaskAt(int col, int row, ITask task);
/** Inserts a task at the point. If a task is already there everything should shift down 1 */
public void insertTask(Vector2 vector2, ITask task);
public void insertTask(int col, int row, ITask task);
/** Return this program to its starting conditions */
public void reset();

View file

@ -21,10 +21,12 @@ public interface ITask extends Cloneable
public void setProgram(IProgram program);
/** Location in the program */
public Vector2 getPosition();
public int getRow();
public int getCol();
/** Sets the tasks position in the program */
public void setPosition(Vector2 pos);
public void setPosition(int col, int row);
/** Method name or rather command name this will be called. Uses both to ID this command, and do
* basic command structuring. */
@ -68,6 +70,13 @@ public interface ITask extends Cloneable
* the TaskRegistry */
public ITask clone();
/** Texture to be used make sure to use a reference as creating a new one each call with memory
* leak the game */
public ResourceLocation getTextureSheet();
/** Location of the texture in the sheet */
public Vector2 getTextureUV();
/** Used mainly for display purposes in the encoder */
public static enum TaskType
{

View file

@ -36,13 +36,13 @@ public class Program implements IProgram
if (entry.getValue() != null)
{
entry.getValue().setProgram(this);
if (entry.getValue().getPosition().intX() > w)
if (entry.getValue().getCol() > w)
{
w = entry.getValue().getPosition().intX();
w = entry.getValue().getCol();
}
if (entry.getValue().getPosition().intY() > h)
if (entry.getValue().getRow() > h)
{
h = entry.getValue().getPosition().intY();
h = entry.getValue().getRow();
}
}
else
@ -76,20 +76,16 @@ public class Program implements IProgram
{
if (!started)
{
this.currentTask = this.getTaskAt(currentPos);
this.currentTask = this.getTaskAt(currentPos.intX(), currentPos.intY());
this.currentPos.add(new Vector2(1, 0));
}
return this.currentTask;
}
@Override
public ITask getTaskAt(Vector2 vector2)
public ITask getTaskAt(int col, int row)
{
if (vector2 != null)
{
return this.tasks.get(new Vector2(vector2.intX(), vector2.intY()));
}
return null;
return this.tasks.get(new Vector2(col, row));
}
@Override
@ -99,76 +95,71 @@ public class Program implements IProgram
}
@Override
public void setTaskAt(Vector2 vector2, ITask task)
public void setTaskAt(int col, int row, ITask task)
{
if (vector2 != null)
if (task != null)
{
if (task != null)
task.setPosition(col, row);
if (task.getRow() > this.width)
{
task.setPosition(vector2);
if (task.getPosition().x > this.width)
{
this.width = (int) task.getPosition().x;
}
if (task.getPosition().y > this.hight)
{
this.hight = (int) task.getPosition().y;
}
this.tasks.put(new Vector2(vector2.intX(), vector2.intY()), task);
this.width = task.getRow();
}
else if (this.tasks.containsKey(vector2))
if (task.getCol() > this.hight)
{
this.tasks.remove(vector2);
if (vector2.intY() == this.hight && !this.isThereATaskInRow(this.hight))
{
this.hight--;
}
else if (!this.isThereATaskInRow(vector2.intY()))
{
this.moveAll(vector2.intY(), true);
}
this.hight = task.getCol();
}
this.tasks.put(new Vector2(col, row), task);
}
else if (this.tasks.containsKey(new Vector2(col, row)))
{
this.tasks.remove(new Vector2(col, row));
if (col == this.hight && !this.isThereATaskInRow(this.hight))
{
this.hight--;
}
else if (!this.isThereATaskInRow(col))
{
this.moveAll(col, true);
}
}
}
public boolean isThereATaskInRow(int row)
{
Vector2 vec = new Vector2(0, row);
Vector2 slide = new Vector2(1, 0);
int colume = 0;
for (int x = 0; x <= this.width; x++)
{
if (this.getTaskAt(vec) != null)
if (this.getTaskAt(colume, row) != null)
{
return true;
}
vec.add(slide);
colume++;
}
return false;
}
public boolean isThereATaskInColume(int colume)
{
Vector2 vec = new Vector2(colume, 0);
Vector2 slide = new Vector2(0, 1);
int row = 0;
for (int y = 0; y <= this.width; y++)
{
if (this.getTaskAt(vec) != null)
if (this.getTaskAt(row, colume) != null)
{
return true;
}
vec.add(slide);
row++;
}
return false;
}
/** Move all tasks at the row and in the direction given.
*
*
* @param row - row number or Y value of the position from the task
* @param up - true will move all the tasks up one, false will move all the tasks down one */
public void moveAll(int row, boolean up)
{
List<ITask> moveList = new ArrayList<ITask>();
final Vector2 moveDown = up ? new Vector2(-1, 0) : new Vector2(1, 0);
final int move = up ? -1 : 1;
Vector2 targetPos;
ITask tagetTask;
/* Gather all task and remove them so they can be re-added wither there new positions */
@ -177,7 +168,7 @@ public class Program implements IProgram
for (int y = row; y <= this.hight; y++)
{
targetPos = new Vector2(x, y);
tagetTask = this.getTaskAt(targetPos);
tagetTask = this.getTaskAt(x, y);
if (tagetTask != null)
{
//Add the task to the move list
@ -190,24 +181,23 @@ public class Program implements IProgram
/* Update all the task locations */
for (ITask moveTask : moveList)
{
moveTask.setPosition(moveTask.getPosition().add(moveDown));
this.setTaskAt(moveTask.getPosition(), moveTask);
this.setTaskAt(moveTask.getCol(), moveTask.getRow() + move, moveTask);
}
//TODO send to the client the updates map and key to unlock the delete button
}
@Override
public void insertTask(Vector2 vector2, ITask task)
public void insertTask(int col, int row, ITask task)
{
if (vector2 != null && task != null)
if (task != null)
{
if (this.getTaskAt(vector2) != null)
if (this.getTaskAt(col, row) != null)
{
this.moveAll(vector2.intY(), false);
this.moveAll(row, false);
}
else
{
this.setTaskAt(vector2, task);
this.setTaskAt(col, row, task);
}
}
}
@ -220,7 +210,7 @@ public class Program implements IProgram
NBTTagCompound tag = this.currentTask.save(new NBTTagCompound());
this.currentTask = TaskRegistry.getCommand(this.currentTask.getMethodName()).clone();
this.currentTask.load(tag);
this.setTaskAt(this.currentTask.getPosition(), this.currentTask);
this.setTaskAt(this.currentTask.getCol(), this.currentTask.getRow(), this.currentTask);
this.currentTask = null;
}
this.currentPos = new Vector2(0, 0);
@ -256,9 +246,9 @@ public class Program implements IProgram
NBTTagList taskList = new NBTTagList();
for (Entry<Vector2, ITask> entry : this.tasks.entrySet())
{
entry.getValue().setPosition(entry.getKey());
entry.getValue().setPosition(entry.getKey().intX(), entry.getKey().intY());
NBTTagCompound task = entry.getValue().save(new NBTTagCompound());
if (entry.getKey().equals(this.currentTask.getPosition()))
if (entry.getKey().equals(new Vector2(this.currentTask.getCol(), this.currentTask.getRow())))
{
task.setBoolean("currentTask", true);
entry.getValue().saveProgress(task);
@ -294,21 +284,21 @@ public class Program implements IProgram
if (task != null)
{
task.load(tag);
task.setPosition(new Vector2(nbt.getInteger("positionX"), nbt.getInteger("positionY")));
this.tasks.put(task.getPosition(), task);
task.setPosition(nbt.getInteger("positionX"), nbt.getInteger("positionY"));
this.tasks.put(new Vector2(task.getCol(), task.getRow()), task);
if (tag.getBoolean("currentTask"))
{
this.currentTask = task;
task.loadProgress(tag);
this.currentPos = task.getPosition();
this.currentPos = new Vector2(task.getCol(), task.getRow());
}
if (task.getPosition().x > this.width)
if (task.getCol() > this.width)
{
this.width = (int) task.getPosition().x;
this.width = task.getCol();
}
if (task.getPosition().y > this.hight)
if (task.getRow() > this.hight)
{
this.hight = (int) task.getPosition().y;
this.hight = task.getRow();
}
}
}

View file

@ -6,6 +6,7 @@ import java.util.List;
import java.util.Map.Entry;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import universalelectricity.core.vector.Vector2;
import dark.api.al.coding.IMemorySlot;
import dark.api.al.coding.IProgram;
@ -25,7 +26,8 @@ public abstract class TaskBase implements ITask, IMemorySlot
protected TaskType taskType;
protected Vector2 pos;
protected int col;
protected int row;
/** The parameters this command */
protected HashMap<String, Object> aruguments = new HashMap<String, Object>();
@ -75,15 +77,22 @@ public abstract class TaskBase implements ITask, IMemorySlot
}
@Override
public Vector2 getPosition()
public int getCol()
{
return pos;
return this.col;
}
@Override
public void setPosition(Vector2 pos)
public int getRow()
{
this.pos = pos;
return this.row;
}
@Override
public void setPosition(int col, int row)
{
this.col = col;
this.row = row;
}
@Override
@ -136,7 +145,8 @@ public abstract class TaskBase implements ITask, IMemorySlot
@Override
public TaskBase load(NBTTagCompound nbt)
{
this.pos = new Vector2(nbt.getDouble("xx"), nbt.getDouble("yy"));
this.col = nbt.getInteger("col");
this.row = nbt.getInteger("row");
if (this.getEncoderParms() != null)
{
this.aruguments = new HashMap();
@ -156,11 +166,9 @@ public abstract class TaskBase implements ITask, IMemorySlot
@Override
public NBTTagCompound save(NBTTagCompound nbt)
{
if (this.pos != null)
{
nbt.setDouble("xx", pos.x);
nbt.setDouble("yy", pos.y);
}
nbt.setInteger("col", this.col);
nbt.setInteger("row", this.row);
NBTTagCompound parms = new NBTTagCompound();
for (Entry<String, Object> entry : this.aruguments.entrySet())
{
@ -195,4 +203,18 @@ public abstract class TaskBase implements ITask, IMemorySlot
return "COMMAND[" + super.toString() + "]:" + this.methodName;
}
@Override
public ResourceLocation getTextureSheet()
{
// TODO Auto-generated method stub
return null;
}
@Override
public Vector2 getTextureUV()
{
// TODO Auto-generated method stub
return null;
}
}

View file

@ -6,7 +6,9 @@ import net.minecraft.block.Block;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import universalelectricity.core.vector.Vector2;
import universalelectricity.core.vector.Vector3;
import com.builtbroken.common.Pair;
@ -18,7 +20,7 @@ import dark.assembly.armbot.TaskBaseProcess;
import dark.core.helpers.ItemWorldHelper;
/** Used by arms to break a specific block in a position.
*
*
* @author Calclavia */
public class TaskBreak extends TaskBaseArmbot
{
@ -88,4 +90,6 @@ public class TaskBreak extends TaskBaseArmbot
return nbt;
}
}

View file

@ -40,12 +40,12 @@ public class TaskGOTO extends TaskBase implements IRedirectTask
super.refresh();
if (task == null && taskPos != null)
{
this.task = this.program.getTaskAt(taskPos);
this.task = this.program.getTaskAt(taskPos.intX(), taskPos.intY());
}
this.exits.clear();
if (this.task != null)
{
this.exits.add(this.task.getPosition());
this.exits.add(new Vector2(this.task.getCol(), this.task.getRow()));
}
}
@ -92,8 +92,8 @@ public class TaskGOTO extends TaskBase implements IRedirectTask
super.saveProgress(nbt);
if (this.task != null)
{
nbt.setDouble("entryX", this.task.getPosition().x);
nbt.setDouble("entryY", this.task.getPosition().y);
nbt.setDouble("entryX", this.task.getCol());
nbt.setDouble("entryY", this.task.getRow());
}
return nbt;
}

View file

@ -16,7 +16,6 @@ public class TaskIF extends TaskBaseLogic
protected ITask exitTruePoint = null;
protected ITask exitFalsePoint = null;
protected List<Vector2> exits = new ArrayList<Vector2>();
protected Vector2 exitA, exitB;
protected boolean isTrue = false;
public TaskIF()
@ -34,14 +33,6 @@ public class TaskIF extends TaskBaseLogic
}
public TaskIF(Vector2 exitA, Vector2 exitB)
{
this();
this.exitA = exitA;
this.exitB = exitB;
}
@Override
public void refresh()
{
@ -50,23 +41,14 @@ public class TaskIF extends TaskBaseLogic
{
this.isTrue = this.getArg("check").equals(this.getArg("compare"));
}
if (exitTruePoint == null && exitA != null)
if (exitTruePoint == null)
{
exitTruePoint = this.program.getTaskAt(exitA);
exitTruePoint = this.program.getTaskAt(this.getCol() + 1, this.getRow());
}
if (exitFalsePoint == null && exitB != null)
if (exitFalsePoint == null)
{
exitFalsePoint = this.program.getTaskAt(exitB);
}
this.exits.clear();
if (this.exitFalsePoint != null)
{
this.exits.add(this.exitFalsePoint.getPosition());
}
if (this.exitTruePoint != null)
{
this.exits.add(this.exitTruePoint.getPosition());
exitFalsePoint = this.program.getTaskAt(this.getCol(), this.getRow() + 1);
;
}
}
@ -105,32 +87,6 @@ public class TaskIF extends TaskBaseLogic
}
}
@Override
public TaskIF load(NBTTagCompound nbt)
{
super.loadProgress(nbt);
this.exitFalsePoint = this.program.getTaskAt(new Vector2(nbt.getDouble("exitFalseX"), (nbt.getDouble("exitFalseY"))));
this.exitTruePoint = this.program.getTaskAt(new Vector2(nbt.getDouble("exitTrueX"), (nbt.getDouble("exitTrueY"))));
return this;
}
@Override
public NBTTagCompound save(NBTTagCompound nbt)
{
super.saveProgress(nbt);
if (this.exitFalsePoint != null)
{
nbt.setDouble("exitFalseX", this.exitFalsePoint.getPosition().x);
nbt.setDouble("exitFalseY", this.exitFalsePoint.getPosition().y);
}
if (this.exitTruePoint != null)
{
nbt.setDouble("exitTrueX", this.exitTruePoint.getPosition().x);
nbt.setDouble("exitTrueY", this.exitTruePoint.getPosition().y);
}
return nbt;
}
@Override
public boolean canUseTask(IProgrammableMachine device)
{

View file

@ -0,0 +1,28 @@
package dark.assembly.client.gui;
/** Used to reference icons in the gui coder sheet
*
* @author DarkGuardsman */
public enum EnumTaskIcon
{
VERT_LINE(0, 0),
HORT_LINE(20, 0),
ARROW_UP(40, 0),
ARROW_RIGHT(60, 0),
ARROW_DOWN(80, 0),
ARROW_LEFT(100, 0),
VERT_LINE_DOT(120, 0),
HORT_LINE_DOT(140, 0),
LEFT_UP_BEND(160, 0),
LEFT_DOWN_BEND(180, 0),
RIGHT_UP_BEND(200, 0),
RIGHT_DOWN_BEND(220, 0);
int uu, vv;
int sizeX = 20, sizeY = 20;
private EnumTaskIcon(int uu, int vv)
{
}
}

View file

@ -13,7 +13,7 @@ public class GuiEncoderBase extends GuiMachineContainer
//
public GuiEncoderBase(InventoryPlayer player, TileEntityMachine tileEntity, Container container)
{
super(AssemblyLine.MOD_ID, container, player, tileEntity);
super(AssemblyLine.instance, container, player, tileEntity);
this.guiID = CommonProxy.GUI_ENCODER;
this.guiID2 = CommonProxy.GUI_ENCODER_CODE;
this.guiID3 = CommonProxy.GUI_ENCODER_HELP;

View file

@ -2,10 +2,6 @@ package dark.assembly.client.gui;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.client.FMLClientHandler;
import dark.assembly.AssemblyLine;
import dark.assembly.machine.encoder.TileEntityEncoder;
@ -20,21 +16,39 @@ public class GuiEncoderCoder extends GuiEncoderBase
}
@Override
protected void drawGuiContainerBackgroundLayer(float var1, int x, int y)
public void initGui()
{
if (taskListGui == null)
super.initGui();
this.getTaskListElement(true);
}
protected GuiTaskList getTaskListElement(boolean renew)
{
if (taskListGui == null || renew)
{
taskListGui = new GuiTaskList((this.width - this.xSize) / 2 + 25, (this.height - this.ySize) / 2 + 30);
taskListGui = new GuiTaskList(this.tileEntity, this.containerWidth + 25, this.containerHeight + 15);
}
super.drawGuiContainerBackgroundLayer(var1, x, y);
FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE_CODE_BACK);
return this.taskListGui;
}
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
protected GuiTaskList getTaskListElement()
{
return this.getTaskListElement(false);
}
int containerWidth = (this.width - this.xSize) / 2;
int containerHeight = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(containerWidth, containerHeight, 0, 0, this.xSize, this.ySize);
taskListGui.drawConsole();
@Override
protected void drawGuiContainerBackgroundLayer(float f, int i, int j)
{
super.drawGuiContainerBackgroundLayer(f, i, j);
getTaskListElement().drawConsole(this.mc);
}
@Override
protected void drawGuiContainerForegroundLayer(int x, int y)
{
super.drawGuiContainerForegroundLayer(x, y);
taskListGui.drawGuiContainerForegroundLayer(this.mc, x, y);
}
@Override

View file

@ -33,6 +33,6 @@ public class GuiEncoderInventory extends GuiEncoderBase
int containerWidth = (this.width - this.xSize) / 2;
int containerHeight = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(containerWidth, containerHeight, 0, 0, this.xSize, this.ySize);
this.drawTexturedModalRect(containerWidth, containerHeight-10, 0, 0, this.xSize, this.ySize);
}
}

View file

@ -1,8 +1,12 @@
package dark.assembly.client.gui;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.tileentity.TileEntity;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import universalelectricity.core.vector.Vector2;
import cpw.mods.fml.client.FMLClientHandler;
@ -18,56 +22,56 @@ import dark.assembly.armbot.command.TaskStart;
import dark.core.interfaces.IScroll;
/** Not a gui itself but a component used to display task as a box inside of a gui
*
*
* @author DarkGuardsman */
public class GuiTaskList extends Gui implements IScroll
{
protected IProgram program;
protected int scroll = 0;
private final float scale = 0.52f;
private int color = 14737632;
protected TileEntity entity;
/** The string displayed on this control. */
public String displayString;
int x, y;
int xPos, yPos;
int countX = 6, countY = 7;
public GuiTaskList(int x, int y)
public GuiTaskList(TileEntity entity, int x, int y)
{
this.x = x;
this.y = y;
this.xPos = x;
this.yPos = y;
program = new Program();
program.setTaskAt(new Vector2(0, 0), new TaskGive());
program.setTaskAt(new Vector2(0, 1), new TaskIF(new Vector2(0, 2), new Vector2(1, 1)));
program.setTaskAt(new Vector2(0, 2), new TaskGive());
program.setTaskAt(new Vector2(0, 3), new TaskGive());
program.setTaskAt(new Vector2(0, 4), new TaskGive());
program.setTaskAt(new Vector2(0, 5), new TaskGive());
program.setTaskAt(new Vector2(0, 6), new TaskGive());
program.setTaskAt(new Vector2(0, 7), new TaskGive());
program.setTaskAt(new Vector2(0, 8), new TaskGive());
program.setTaskAt(new Vector2(0, 9), new TaskGive());
program.setTaskAt(0, 0, new TaskGive());
program.setTaskAt(0, 1, new TaskIF());
program.setTaskAt(0, 2, new TaskGive());
program.setTaskAt(0, 3, new TaskGive());
program.setTaskAt(0, 4, new TaskGive());
program.setTaskAt(0, 5, new TaskGive());
program.setTaskAt(0, 6, new TaskGive());
program.setTaskAt(0, 7, new TaskGive());
program.setTaskAt(0, 8, new TaskGive());
program.setTaskAt(0, 9, new TaskGive());
program.setTaskAt(new Vector2(1, 1), new TaskGive());
program.setTaskAt(new Vector2(1, 2), new TaskIF(new Vector2(1, 3), new Vector2(2, 2)));
program.setTaskAt(new Vector2(1, 3), new TaskGive());
program.setTaskAt(new Vector2(1, 4), new TaskGive());
program.setTaskAt(new Vector2(1, 5), new TaskGive());
program.setTaskAt(1, 1, new TaskGive());
program.setTaskAt(1, 2, new TaskIF());
program.setTaskAt(1, 3, new TaskGive());
program.setTaskAt(1, 4, new TaskGive());
program.setTaskAt(1, 5, new TaskGive());
TaskGOTO ifEixt = new TaskGOTO();
ifEixt.setExitPoint(0, new Vector2(0, 6));
program.setTaskAt(new Vector2(1, 6), ifEixt);
program.setTaskAt(1, 6, ifEixt);
program.setTaskAt(new Vector2(2, 2), new TaskGive());
program.setTaskAt(new Vector2(2, 3), new TaskGive());
program.setTaskAt(new Vector2(2, 4), new TaskGive());
program.setTaskAt(new Vector2(2, 5), new TaskGive());
program.setTaskAt(new Vector2(2, 6), new TaskGive());
program.setTaskAt(new Vector2(2, 7), new TaskGive());
program.setTaskAt(2, 2, new TaskGive());
program.setTaskAt(2, 3, new TaskGive());
program.setTaskAt(2, 4, new TaskGive());
program.setTaskAt(2, 5, new TaskGive());
program.setTaskAt(2, 6, new TaskGive());
program.setTaskAt(2, 7, new TaskGive());
TaskGOTO ifEixt2 = new TaskGOTO();
ifEixt2.setExitPoint(0, new Vector2(1, 8));
program.setTaskAt(new Vector2(2, 8), ifEixt2);
program.setTaskAt(2, 8, ifEixt2);
program.init(null);
}
@ -95,34 +99,35 @@ public class GuiTaskList extends Gui implements IScroll
return this.scroll;
}
public void drawConsole()
public void drawConsole(Minecraft mc)
{
//Draw icons for task
FMLClientHandler.instance().getClient().renderEngine.bindTexture(ITask.TaskType.TEXTURE);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
for (int j = 0; j < 6; j++)
for (int colume = 0; colume < countX; colume++)
{
for (int i = 0; i < 7; i++)
for (int row = 0; row < countY; row++)
{
int currentLine = i + this.scroll - 1;
if (currentLine <= this.program.getSize().intY() + 1 && currentLine >= -1)
int actualRow = row + this.scroll - 1;
if (actualRow <= this.program.getSize().intY() + 1 && actualRow >= -1)
{
ITask task = this.program.getTaskAt(new Vector2(j, currentLine));
if (currentLine == -1 && j == 0)
ITask task = this.program.getTaskAt(colume, actualRow);
if (actualRow == -1 && colume == 0)
{
task = new TaskStart();
}
if (currentLine == this.program.getSize().intY() + 1 && j == 0)
if (actualRow == this.program.getSize().intY() + 1 && colume == 0)
{
task = new TaskEnd();
}
if (task != null && (!(task instanceof IRedirectTask) || task instanceof IRedirectTask && ((IRedirectTask) task).render()))
{
this.drawTexturedModalRect(x + (20 * j), y + (20 * i), 20 * task.getType().vv, 20 * task.getType().uu, 20, 20);
FMLClientHandler.instance().getClient().renderEngine.bindTexture(task.getTextureSheet());
this.drawTexturedModalRect(xPos + (20 * colume), yPos + (20 * row), task.getTextureUV().intX(), task.getTextureUV().intY(), 20, 20);
}
else
{
this.drawTexturedModalRect(x + (20 * j), y + (20 * i), 0, 40, 20, 20);
this.drawTexturedModalRect(xPos + (20 * colume), yPos + (20 * row), 0, 40, 20, 20);
}
}
}
@ -130,23 +135,106 @@ public class GuiTaskList extends Gui implements IScroll
}
}
public void mousePressed(int cx, int cz)
protected void drawGuiContainerForegroundLayer(Minecraft mc, int cx, int cy)
{
System.out.println("Player clicked at " + cx + "x " + cz + "z ");
if (cx >= this.x && cz >= this.y && cx < (this.x + (20 * 7) + 10) && cz < (this.y + (20 * 6) + 10))
ITask task = this.getTaskAt(cx, cy);
if (task != null)
{
int row = (cz / 20) - 4;
int col = (cx / 20) - 7;
System.out.println("Player clicked at " + row + "r " + col + "c ");
this.drawTooltip(mc, xPos - cy, yPos - cx + 10, "Task At: " + task.getMethodName());
}
}
public void mousePressed(int cx, int cy)
{
System.out.println("Player clicked at " + cx + "x " + cy + "y ");
ITask task = this.getTaskAt(cx, cy);
if (task != null)
{
System.out.println("Task is at " + task.getRow() + "r " + task.getCol() + "c " + task.getMethodName());
}
}
public ITask getTaskAt(int cx, int cz)
{
if (cx >= this.xPos && cz >= this.yPos && cx < this.xPos + (this.countX * 20) + 20 && cz < this.yPos + (this.countX * 20) + 20)
{
int row = (cx - this.xPos) / 20;
int col = (cz - this.yPos) / 20;
if (this.program != null)
{
ITask task = this.program.getTaskAt(new Vector2(col, row));
if (task != null)
return this.program.getTaskAt(col, row);
}
}
return null;
}
public void drawTooltip(Minecraft mc, int x, int y, String... toolTips)
{
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
RenderHelper.disableStandardItemLighting();
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_DEPTH_TEST);
if (toolTips != null)
{
int var5 = 0;
int var6;
int var7;
for (var6 = 0; var6 < toolTips.length; ++var6)
{
var7 = mc.fontRenderer.getStringWidth(toolTips[var6]);
if (var7 > var5)
{
//TODO open editing options
System.out.println("Player tried to edit task - " + task.getMethodName());
var5 = var7;
}
}
var6 = x + 12;
var7 = y - 12;
int var9 = 8;
if (toolTips.length > 1)
{
var9 += 2 + (toolTips.length - 1) * 10;
}
if (y + var7 + var9 + 6 > 20)
{
var7 = 20 - var9 - y - 6;
}
this.zLevel = 300.0F;
int var10 = -267386864;
this.drawGradientRect(var6 - 3, var7 - 4, var6 + var5 + 3, var7 - 3, var10, var10);
this.drawGradientRect(var6 - 3, var7 + var9 + 3, var6 + var5 + 3, var7 + var9 + 4, var10, var10);
this.drawGradientRect(var6 - 3, var7 - 3, var6 + var5 + 3, var7 + var9 + 3, var10, var10);
this.drawGradientRect(var6 - 4, var7 - 3, var6 - 3, var7 + var9 + 3, var10, var10);
this.drawGradientRect(var6 + var5 + 3, var7 - 3, var6 + var5 + 4, var7 + var9 + 3, var10, var10);
int var11 = 1347420415;
int var12 = (var11 & 16711422) >> 1 | var11 & -16777216;
this.drawGradientRect(var6 - 3, var7 - 3 + 1, var6 - 3 + 1, var7 + var9 + 3 - 1, var11, var12);
this.drawGradientRect(var6 + var5 + 2, var7 - 3 + 1, var6 + var5 + 3, var7 + var9 + 3 - 1, var11, var12);
this.drawGradientRect(var6 - 3, var7 - 3, var6 + var5 + 3, var7 - 3 + 1, var11, var11);
this.drawGradientRect(var6 - 3, var7 + var9 + 2, var6 + var5 + 3, var7 + var9 + 3, var12, var12);
for (int var13 = 0; var13 < toolTips.length; ++var13)
{
String var14 = "\u00a77" + toolTips[var13];
mc.fontRenderer.drawStringWithShadow(var14, var6, var7, -1);
if (var13 == 0)
{
var7 += 2;
}
var7 += 10;
}
this.zLevel = 0.0F;
}
}
}

View file

@ -29,12 +29,12 @@ public class ContainerEncoder extends Container
{
for (int slot = 0; slot < 9; ++slot)
{
this.addSlotToContainer(new Slot(inventoryPlayer, slot + row * 9 + 9, 8 + slot * 18, 97 + row * 18));
this.addSlotToContainer(new Slot(inventoryPlayer, slot + row * 9 + 9, 8 + slot * 18, 97 + row * 8));
}
}
for (row = 0; row < 9; ++row)
{
this.addSlotToContainer(new Slot(inventoryPlayer, row, 8 + row * 18, 155));
this.addSlotToContainer(new Slot(inventoryPlayer, row, 8 + row * 18, 145));
}
}

View file

@ -118,16 +118,16 @@ public class TileEntityEncoder extends TileEntityMachine implements ISidedInvent
{
IProcessTask task = TaskRegistry.getCommand(dis.readUTF());
task.setPosition(new Vector2(dis.readInt(), dis.readInt()));
task.setPosition(dis.readInt(), dis.readInt());
task.load(PacketManager.readNBTTagCompound(dis));
this.program.setTaskAt(task.getPosition(), task);
this.program.setTaskAt(task.getCol(), task.getRow(), task);
this.sendGUIPacket();
return true;
}
else if (id.equalsIgnoreCase(TileEntityEncoder.REMOVE_TASK))
{
this.program.setTaskAt(new Vector2(dis.readInt(), dis.readInt()), null);
this.program.setTaskAt(dis.readInt(), dis.readInt(), null);
this.sendGUIPacket();
return true;
}
@ -170,7 +170,7 @@ public class TileEntityEncoder extends TileEntityMachine implements ISidedInvent
{
if (task != null)
{
PacketDispatcher.sendPacketToServer(PacketHandler.instance().getTilePacket(DarkMain.CHANNEL, this, task.getPosition().intX(), task.getPosition().intY(), task.save(new NBTTagCompound())));
PacketDispatcher.sendPacketToServer(PacketHandler.instance().getTilePacket(DarkMain.CHANNEL, this, task.getCol(), task.getRow(), task.save(new NBTTagCompound())));
}
}