Got tool tips and edit gui working
Still a long ways to go but its start to look like something.
This commit is contained in:
parent
cdbc6b1313
commit
cdaf97f480
12 changed files with 98 additions and 92 deletions
|
@ -77,6 +77,9 @@ public interface ITask extends Cloneable
|
|||
/** Location of the texture in the sheet */
|
||||
public Vector2 getTextureUV();
|
||||
|
||||
/** Passes in a list so that the task can add to the tool tip render */
|
||||
public void getToolTips(List<String> list);
|
||||
|
||||
/** Used mainly for display purposes in the encoder */
|
||||
public static enum TaskType
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package dark.api.al.coding.args;
|
||||
|
||||
/** Used to store arguments in a way that can be easier to read, limit, and understand
|
||||
*
|
||||
*
|
||||
* @author DarkGuardsman */
|
||||
public class ArgumentData
|
||||
{
|
||||
|
@ -15,7 +15,7 @@ public class ArgumentData
|
|||
}
|
||||
|
||||
/** Sets the value
|
||||
*
|
||||
*
|
||||
* @return true if the value was accepted */
|
||||
public boolean setData(Object object)
|
||||
{
|
||||
|
@ -49,4 +49,10 @@ public class ArgumentData
|
|||
//Null is invalide since the object is used to understand data types. Without data the encoder can't use the value and will remove it
|
||||
return storedValue != null;
|
||||
}
|
||||
|
||||
/** Used by things like a gui to give a warning such as limits of data this can accept */
|
||||
public String warning()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package dark.api.al.coding.args;
|
||||
|
||||
import universalelectricity.core.electricity.ElectricityDisplay;
|
||||
|
||||
/** Used to create argument data for the encoder. Should only be used if the value needs to be
|
||||
* clearly limited inside the encoder display.
|
||||
*
|
||||
*
|
||||
* @author DarkGuardsman */
|
||||
public class ArgumentDoubleData extends ArgumentData
|
||||
{
|
||||
|
@ -20,4 +22,10 @@ public class ArgumentDoubleData extends ArgumentData
|
|||
{
|
||||
return super.isValid() && object instanceof Double && ((Double) object) >= min && ((Double) object) <= max;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String warning()
|
||||
{
|
||||
return "" + ElectricityDisplay.roundDecimals(min, 2) + " - " + ElectricityDisplay.roundDecimals(max, 2);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package dark.api.al.coding.args;
|
||||
|
||||
import universalelectricity.core.electricity.ElectricityDisplay;
|
||||
|
||||
/** Used to create argument data for the encoder. Should only be used if the value needs to be
|
||||
* clearly limited inside the encoder display.
|
||||
*
|
||||
*
|
||||
* @author DarkGuardsman */
|
||||
public class ArgumentFloatData extends ArgumentData
|
||||
{
|
||||
|
@ -20,4 +22,10 @@ public class ArgumentFloatData extends ArgumentData
|
|||
{
|
||||
return super.isValid() && object instanceof Float && ((Float) object) >= min && ((Float) object) <= max;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String warning()
|
||||
{
|
||||
return "" + ElectricityDisplay.roundDecimals(min, 2) + " - " + ElectricityDisplay.roundDecimals(max, 2);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package dark.api.al.coding.args;
|
||||
|
||||
import universalelectricity.core.electricity.ElectricityDisplay;
|
||||
|
||||
/** Used to create argument data for the encoder. Should only be used if the value needs to be
|
||||
* clearly limited inside the encoder display.
|
||||
*
|
||||
*
|
||||
* @author DarkGuardsman */
|
||||
public class ArgumentIntData extends ArgumentData
|
||||
{
|
||||
|
@ -20,4 +22,10 @@ public class ArgumentIntData extends ArgumentData
|
|||
{
|
||||
return super.isValid() && object instanceof Integer && ((Integer) object) >= min && ((Integer) object) <= max;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String warning()
|
||||
{
|
||||
return "" + min + " - " + max;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -237,4 +237,9 @@ public abstract class TaskBase implements ITask, IMemorySlot
|
|||
return this.UV;
|
||||
}
|
||||
|
||||
public void getToolTips(List<String> list)
|
||||
{
|
||||
list.add(this.getMethodName());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package dark.assembly.armbot.command;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import com.builtbroken.common.science.units.UnitHelper;
|
||||
|
@ -85,4 +87,11 @@ public class TaskIdle extends TaskBaseProcess
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getToolTips(List<String> list)
|
||||
{
|
||||
super.getToolTips(list);
|
||||
list.add(" Wait: " + this.totalIdleTime);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package dark.assembly.armbot.command;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import universalelectricity.core.vector.Vector2;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
|
@ -84,4 +86,12 @@ public class TaskRotateBy extends TaskBaseArmbot
|
|||
{
|
||||
return new TaskRotateBy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getToolTips(List<String> list)
|
||||
{
|
||||
super.getToolTips(list);
|
||||
list.add(" Yaw: " + this.targetRotationYaw);
|
||||
list.add(" Pitch: " + this.targetRotationPitch);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package dark.assembly.armbot.command;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import universalelectricity.core.vector.Vector2;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
|
@ -90,4 +92,12 @@ public class TaskRotateTo extends TaskBaseArmbot
|
|||
{
|
||||
return new TaskRotateTo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getToolTips(List<String> list)
|
||||
{
|
||||
super.getToolTips(list);
|
||||
list.add(" Yaw: " + this.targetRotationYaw);
|
||||
list.add(" Pitch: " + this.targetRotationPitch);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package dark.assembly.armbot.command;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
@ -121,4 +123,11 @@ public class TaskUse extends TaskBaseArmbot
|
|||
{
|
||||
return new TaskUse();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getToolTips(List<String> list)
|
||||
{
|
||||
super.getToolTips(list);
|
||||
list.add(" Repeat: " + this.times);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ public class GuiEditTask extends GuiBase
|
|||
{
|
||||
super.initGui();
|
||||
this.drawButtons();
|
||||
Keyboard.enableRepeatEvents(true);
|
||||
}
|
||||
|
||||
public void drawButtons()
|
||||
|
@ -61,12 +62,13 @@ public class GuiEditTask extends GuiBase
|
|||
|
||||
if (eArgs != null && !eArgs.isEmpty())
|
||||
{
|
||||
int i = 0;
|
||||
this.argTextBoxes = new GuiTextField[eArgs.size()];
|
||||
for (ArgumentData arg : eArgs)
|
||||
for (int i = 0; i < this.argTextBoxes.length; i++)
|
||||
{
|
||||
this.argTextBoxes[i] = new GuiTextField(this.fontRenderer, width + 12, height + 165, 135, 11);
|
||||
ArgumentData arg = eArgs.get(i);
|
||||
this.argTextBoxes[i] = new GuiTextField(this.fontRenderer, (this.width - this.guiSize.intX()) / 2 + 60, (this.height - this.guiSize.intY()) / 2 + 64 + (i * this.ySpacing), 30, 10);
|
||||
this.argTextBoxes[i].setMaxStringLength(30);
|
||||
this.argTextBoxes[i].setVisible(true);
|
||||
if (args.containsKey(arg.getName()))
|
||||
{
|
||||
this.argTextBoxes[i].setText("" + args.get(arg.getName()));
|
||||
|
@ -75,10 +77,9 @@ public class GuiEditTask extends GuiBase
|
|||
{
|
||||
this.argTextBoxes[i].setText("" + arg.getData());
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
Keyboard.enableRepeatEvents(true);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -176,12 +177,15 @@ public class GuiEditTask extends GuiBase
|
|||
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());
|
||||
for (int i = 0; i < this.argTextBoxes.length; i++)
|
||||
if (this.argTextBoxes != null)
|
||||
{
|
||||
GuiTextField box = this.argTextBoxes[i];
|
||||
if (box != null)
|
||||
for (int i = 0; i < this.argTextBoxes.length; i++)
|
||||
{
|
||||
box.drawTextBox();
|
||||
GuiTextField box = this.argTextBoxes[i];
|
||||
if (box != null)
|
||||
{
|
||||
box.drawTextBox();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -203,6 +207,7 @@ public class GuiEditTask extends GuiBase
|
|||
{
|
||||
i++;
|
||||
this.fontRenderer.drawString(arg.getName() + ":", (int) ((this.guiSize.intX() / 2) - 70), 45 + (i * this.ySpacing), 4210752);
|
||||
this.fontRenderer.drawString(arg.warning(), (int) ((this.guiSize.intX() / 2) + 11), 45 + (i * this.ySpacing), 4210752);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -2,13 +2,10 @@ 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;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import dark.api.al.coding.IProgram;
|
||||
|
@ -116,7 +113,7 @@ public class GuiTaskList extends Gui implements IScroll
|
|||
{
|
||||
task = new TaskStart();
|
||||
}
|
||||
if (actualRow == this.program.getSize().intY() + 1 && colume == 0)
|
||||
if (actualRow == this.program.getSize().intY() + 1 && colume + this.scrollX - 1 == -1)
|
||||
{
|
||||
task = new TaskEnd();
|
||||
}
|
||||
|
@ -139,11 +136,10 @@ public class GuiTaskList extends Gui implements IScroll
|
|||
protected void drawGuiContainerForegroundLayer(Minecraft mc, int cx, int cy)
|
||||
{
|
||||
ITask task = this.getTaskAt(cx, cy);
|
||||
if (task != null)
|
||||
if (task != null && coder != null)
|
||||
{
|
||||
this.drawTooltip(mc, xPos - cy, yPos - cx + 10, "Task At: " + task.getMethodName());
|
||||
coder.drawTooltip(cx - coder.getGuiLeft(), cy - coder.getGuiTop() + 10, task.getMethodName());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void mousePressed(int cx, int cy)
|
||||
|
@ -151,7 +147,6 @@ public class GuiTaskList extends Gui implements IScroll
|
|||
ITask task = this.getTaskAt(cx, cy);
|
||||
if (task != null)
|
||||
{
|
||||
System.out.println("Task: " + task.getMethodName());
|
||||
FMLCommonHandler.instance().showGuiScreen(new GuiEditTask(this.coder, task));
|
||||
}
|
||||
}
|
||||
|
@ -169,74 +164,4 @@ public class GuiTaskList extends Gui implements IScroll
|
|||
}
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue