From 2ab9d7b98b4d45f08f81be7e655727f49d7bbbd1 Mon Sep 17 00:00:00 2001 From: DarkGuardsman Date: Wed, 20 Nov 2013 10:35:13 -0500 Subject: [PATCH] worked on click events for bot tasks --- .../assembly/client/gui/GuiEncoderCoder.java | 15 +++++++-- src/dark/assembly/client/gui/GuiTaskList.java | 33 ++++++++++++++++--- 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/src/dark/assembly/client/gui/GuiEncoderCoder.java b/src/dark/assembly/client/gui/GuiEncoderCoder.java index 03ff648c5..65e54561e 100644 --- a/src/dark/assembly/client/gui/GuiEncoderCoder.java +++ b/src/dark/assembly/client/gui/GuiEncoderCoder.java @@ -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); + } } } diff --git a/src/dark/assembly/client/gui/GuiTaskList.java b/src/dark/assembly/client/gui/GuiTaskList.java index 2e589d2c8..bc2b1acf8 100644 --- a/src/dark/assembly/client/gui/GuiTaskList.java +++ b/src/dark/assembly/client/gui/GuiTaskList.java @@ -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()); + } + } + } + } }