worked on click events for bot tasks

This commit is contained in:
DarkGuardsman 2013-11-20 10:35:13 -05:00
parent d91af32cd2
commit 2ab9d7b98b
2 changed files with 42 additions and 6 deletions

View file

@ -1,5 +1,6 @@
package dark.assembly.client.gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
@ -25,7 +26,7 @@ public class GuiEncoderCoder extends GuiEncoderBase
{
if (taskListGui == null)
{
taskListGui = new GuiTaskList();
taskListGui = new GuiTaskList((this.width - this.guiSize.intX()) / 2 + 25, (this.height - this.guiSize.intY()) / 2 + 30);
}
super.drawBackgroundLayer(x, y, var1);
FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE_CODE_BACK);
@ -35,7 +36,17 @@ public class GuiEncoderCoder extends GuiEncoderBase
int containerWidth = (this.width - this.guiSize.intX()) / 2;
int containerHeight = (this.height - this.guiSize.intY()) / 2;
this.drawTexturedModalRect(containerWidth, containerHeight, 0, 0, this.guiSize.intX(), this.guiSize.intY());
taskListGui.drawConsole(this.mc, (this.width - this.guiSize.intX()) / 2 + 15, (this.height - this.guiSize.intY()) / 2 + 20);
taskListGui.drawConsole();
}
@Override
protected void mouseClicked(int par1, int par2, int par3)
{
super.mouseClicked(par1, par2, par3);
if (par3 == 0)
{
this.taskListGui.mousePressed(par1, par2);
}
}
}

View file

@ -39,8 +39,13 @@ public class GuiTaskList extends Gui implements IScroll
/** The string displayed on this control. */
public String displayString;
public GuiTaskList()
int x, y;
public GuiTaskList(int x, int y)
{
this.x = x;
this.y = 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)));
@ -98,7 +103,7 @@ public class GuiTaskList extends Gui implements IScroll
return this.scroll;
}
public void drawConsole(Minecraft minecraft, int x, int y)
public void drawConsole()
{
//Draw icons for task
FMLClientHandler.instance().getClient().renderEngine.bindTexture(ITask.TaskType.TEXTURE);
@ -121,15 +126,35 @@ public class GuiTaskList extends Gui implements IScroll
}
if (task != null && (!(task instanceof IRedirectTask) || task instanceof IRedirectTask && ((IRedirectTask) task).render()))
{
this.drawTexturedModalRect(x + 10 + (20 * j), y + 10 + (20 * i), 20 * task.getType().vv, 20 * task.getType().uu, 20, 20);
this.drawTexturedModalRect(x + (20 * j), y + (20 * i), 20 * task.getType().vv, 20 * task.getType().uu, 20, 20);
}
else
{
this.drawTexturedModalRect(x + 10 + (20 * j), y + 10 + (20 * i), 0, 40, 20, 20);
this.drawTexturedModalRect(x + (20 * j), y + (20 * i), 0, 40, 20, 20);
}
}
}
}
}
public void mousePressed(int cx, int cz)
{
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))
{
int row = (cz / 20)-4;
int col = (cx / 20)-7;
System.out.println("Player clicked at " + row + "r " + col + "c ");
if (this.program != null)
{
ITask task = this.program.getTaskAt(new Vector2(col, row));
if (task != null)
{
//TODO open editing options
System.out.println("Player tried to edit task - " + task.getMethodName());
}
}
}
}
}