Removed test program from gui

well removed it from the gui but added it to the tile in the same exact
format. Mainly just to test that the gui can pull the program from the
tile. Once this test is done though the program will need to be moved to
server side. That way packet testing can begin. After that its on to
actual editing.
This commit is contained in:
DarkGuardsman 2013-11-30 03:44:36 -05:00
parent cdaf97f480
commit a3009a72a7
3 changed files with 61 additions and 36 deletions

View file

@ -98,14 +98,24 @@ public class GuiEncoderCoder extends GuiEncoderBase
{
this.mc.thePlayer.closeScreen();
}
else if (keycode == 200) // PAGE UP (no constant)
else if (keycode == Keyboard.KEY_UP) // PAGE UP (no constant)
{
this.getTaskListElement().scroll(-1);
}
else if (keycode == 208) // PAGE DOWN (no constant)
else if (keycode == Keyboard.KEY_DOWN) // PAGE DOWN (no constant)
{
this.getTaskListElement().scroll(1);
}
else if (keycode == Keyboard.KEY_LEFT) // PAGE LEFT (no constant)
{
if (this.getTaskListElement().scrollX > -5)
this.getTaskListElement().scrollSide(-1);
}
else if (keycode == Keyboard.KEY_RIGHT) // PAGE RIGHT (no constant)
{
if (this.getTaskListElement().scrollX < ((TileEntityEncoder) tileEntity).getProgram().getSize().intX())
this.getTaskListElement().scrollSide(1);
}
}
protected GuiTaskList getTaskListElement()

View file

@ -11,15 +11,9 @@ import cpw.mods.fml.common.FMLCommonHandler;
import dark.api.al.coding.IProgram;
import dark.api.al.coding.IRedirectTask;
import dark.api.al.coding.ITask;
import dark.assembly.armbot.Program;
import dark.assembly.armbot.command.TaskDrop;
import dark.assembly.armbot.command.TaskEnd;
import dark.assembly.armbot.command.TaskGOTO;
import dark.assembly.armbot.command.TaskGive;
import dark.assembly.armbot.command.TaskGrabItem;
import dark.assembly.armbot.command.TaskIF;
import dark.assembly.armbot.command.TaskRotateTo;
import dark.assembly.armbot.command.TaskStart;
import dark.assembly.machine.encoder.TileEntityEncoder;
import dark.core.interfaces.IScroll;
/** Not a gui itself but a component used to display task as a box inside of a gui
@ -27,7 +21,6 @@ import dark.core.interfaces.IScroll;
* @author DarkGuardsman */
public class GuiTaskList extends Gui implements IScroll
{
protected IProgram program;
protected int scrollY = 0, scrollX;
protected TileEntity entity;
@ -45,20 +38,9 @@ public class GuiTaskList extends Gui implements IScroll
this.yPos = y;
this.coder = coder;
program = new Program();
program.setTaskAt(0, 0, new TaskRotateTo());
program.setTaskAt(0, 1, new TaskDrop());
program.setTaskAt(0, 2, new TaskRotateTo());
program.setTaskAt(0, 3, new TaskGrabItem());
program.setTaskAt(0, 4, new TaskIF());
program.setTaskAt(0, 5, new TaskRotateTo());
program.setTaskAt(0, 6, new TaskGive());
program.setTaskAt(1, 4, new TaskRotateTo());
program.setTaskAt(1, 5, new TaskGive());
program.setTaskAt(1, 6, new TaskGOTO(0, 6));
if (program.getSize().intX() < (this.countX / 2))
if (entity instanceof TileEntityEncoder && ((TileEntityEncoder) entity).getProgram() != null)
{
if (((TileEntityEncoder) entity).getProgram().getSize().intX() < (this.countX / 2))
{
this.scrollX = -2;
}
@ -66,12 +48,17 @@ public class GuiTaskList extends Gui implements IScroll
{
this.scrollX = 0;
}
}
}
public void setProgram(IProgram program)
public IProgram getProgram()
{
this.program = program;
if (entity instanceof TileEntityEncoder)
{
return ((TileEntityEncoder) entity).getProgram();
}
return null;
}
@Override
@ -106,14 +93,14 @@ public class GuiTaskList extends Gui implements IScroll
for (int row = 0; row < countY; row++)
{
int actualRow = row + this.scrollY - 1;
if (actualRow <= this.program.getSize().intY() + 1 && actualRow >= -1)
if (actualRow <= this.getProgram().getSize().intY() + 1 && actualRow >= -1)
{
ITask task = this.program.getTaskAt(actualCol, actualRow);
ITask task = this.getProgram().getTaskAt(actualCol, actualRow);
if (actualRow == -1 && colume + this.scrollX - 1 == -1)
{
task = new TaskStart();
}
if (actualRow == this.program.getSize().intY() + 1 && colume + this.scrollX - 1 == -1)
if (actualRow == this.getProgram().getSize().intY() + 1 && colume + this.scrollX - 1 == -1)
{
task = new TaskEnd();
}
@ -157,9 +144,9 @@ public class GuiTaskList extends Gui implements IScroll
{
int col = ((cx - this.xPos) / 20) + this.scrollX;
int row = ((cz - this.yPos) / 20) + this.scrollY;
if (this.program != null)
if (this.getProgram() != null)
{
return this.program.getTaskAt(col, row - 1);
return this.getProgram().getTaskAt(col, row - 1);
}
}
return null;

View file

@ -17,6 +17,12 @@ import dark.api.al.coding.IProcessTask;
import dark.api.al.coding.IProgram;
import dark.api.al.coding.TaskRegistry;
import dark.assembly.armbot.Program;
import dark.assembly.armbot.command.TaskDrop;
import dark.assembly.armbot.command.TaskGOTO;
import dark.assembly.armbot.command.TaskGive;
import dark.assembly.armbot.command.TaskGrabItem;
import dark.assembly.armbot.command.TaskIF;
import dark.assembly.armbot.command.TaskRotateTo;
import dark.core.common.DarkMain;
import dark.core.network.PacketHandler;
import dark.core.prefab.machine.TileEntityMachine;
@ -28,6 +34,23 @@ public class TileEntityEncoder extends TileEntityMachine implements ISidedInvent
public static final String PROGRAM_ID = "program", PROGRAM_CHANGE = "programChange", REMOVE_TASK = "removeTask";
protected IProgram program;
public TileEntityEncoder()
{
super();
program = new Program();
program.setTaskAt(0, 0, new TaskRotateTo());
program.setTaskAt(0, 1, new TaskDrop());
program.setTaskAt(0, 2, new TaskRotateTo());
program.setTaskAt(0, 3, new TaskGrabItem());
program.setTaskAt(0, 4, new TaskIF());
program.setTaskAt(0, 5, new TaskRotateTo());
program.setTaskAt(0, 6, new TaskGive());
program.setTaskAt(1, 4, new TaskRotateTo());
program.setTaskAt(1, 5, new TaskGive());
program.setTaskAt(1, 6, new TaskGOTO(0, 6));
}
@Override
public void onInventoryChanged()
{
@ -180,4 +203,9 @@ public class TileEntityEncoder extends TileEntityMachine implements ISidedInvent
//TODO ?
return false;
}
public IProgram getProgram()
{
return this.program;
}
}