Toyed with debug frame adding location data and setup debug GUI content

This commit is contained in:
Robert S 2014-06-12 09:27:24 -04:00
parent b3feb7c104
commit 6af3bb2d50
2 changed files with 181 additions and 8 deletions

View file

@ -3,19 +3,24 @@ package resonantinduction.core.debug;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Component; import java.awt.Component;
import java.awt.Frame; import java.awt.Frame;
import java.awt.GridLayout;
import java.awt.Label;
import java.awt.Panel; import java.awt.Panel;
import java.awt.event.WindowAdapter; import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent; import java.awt.event.WindowEvent;
import resonantinduction.mechanical.energy.grid.MechanicalNodeFrame;
import universalelectricity.api.vector.IVectorWorld;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
/** @author Darkguardsman */ /** @author Darkguardsman */
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class FrameDebug extends Frame public class FrameDebug extends Frame implements IVectorWorld
{ {
/** Linked tile */ /** Linked tile */
TileEntity tile = null; TileEntity tile = null;
boolean debugNode = false; boolean debugNode = false;
protected long tick = 0; protected long tick = 0;
@ -25,7 +30,6 @@ public class FrameDebug extends Frame
this.tile = tile; this.tile = tile;
} }
protected FrameDebug() protected FrameDebug()
{ {
buildGUI(); buildGUI();
@ -66,24 +70,111 @@ public class FrameDebug extends Frame
/** Top are of the Frame */ /** Top are of the Frame */
public void buildTop(Panel panel) public void buildTop(Panel panel)
{ {
panel.setLayout(new GridLayout(1, 2, 0, 0));
UpdatedLabel tickLabel = new UpdatedLabel("Tile: ")
{
@Override
public String buildLabel()
{
return super.buildLabel() + tile;
}
};
panel.add(tickLabel);
} }
/** Bottom are of the Frame */ /** Bottom are of the Frame */
public void buildBottom(Panel panel) public void buildBottom(Panel panel)
{ {
panel.setLayout(new GridLayout(1, 4, 0, 0));
UpdatedLabel tickLabel = new UpdatedLabel("Tick: ")
{
@Override
public String buildLabel()
{
return super.buildLabel() + tick;
}
};
panel.add(tickLabel);
UpdatedLabel xLabel = new UpdatedLabel("X: ")
{
@Override
public String buildLabel()
{
return super.buildLabel() + x();
}
};
panel.add(xLabel);
UpdatedLabel yLabel = new UpdatedLabel("Y: ")
{
@Override
public String buildLabel()
{
return super.buildLabel() + y();
}
};
panel.add(yLabel);
UpdatedLabel zLabel = new UpdatedLabel("Z: ")
{
@Override
public String buildLabel()
{
return super.buildLabel() + z();
}
};
panel.add(zLabel);
} }
/** Left are of the Frame */ /** Left are of the Frame */
public void buildLeft(Panel panel) public void buildRight(Panel panel)
{ {
panel.setLayout(new GridLayout(1, 2, 0, 0));
UpdatedLabel tickLabel = new UpdatedLabel("Valid: ")
{
@Override
public String buildLabel()
{
return super.buildLabel() + (tile != null ? tile.isInvalid() : "null");
}
};
panel.add(tickLabel);
} }
/** Right are of the Frame */ /** Right are of the Frame */
public void buildRight(Panel panel) public void buildLeft(Panel panel)
{ {
panel.setLayout(new GridLayout(4, 1, 0, 0));
UpdatedLabel block_label = new UpdatedLabel("BLOCK: ")
{
@Override
public String buildLabel()
{
return super.buildLabel() + (tile != null ? tile.getBlockType() : "null");
}
};
panel.add(block_label);
UpdatedLabel meta_label = new UpdatedLabel("META: ")
{
@Override
public String buildLabel()
{
return super.buildLabel() + (tile != null && tile.getBlockType() != null ? tile.getBlockType().blockID : "-");
}
};
panel.add(meta_label);
UpdatedLabel id_label = new UpdatedLabel("ID: ")
{
@Override
public String buildLabel()
{
return super.buildLabel() + (tile != null && tile.getBlockType() != null ? tile.getBlockType().blockID : "-");
}
};
panel.add(id_label);
} }
@ -103,7 +194,7 @@ public class FrameDebug extends Frame
((IUpdate) component).update(); ((IUpdate) component).update();
} }
} }
} }
/** Shows the frame */ /** Shows the frame */
public void showDebugFrame() public void showDebugFrame()
@ -118,4 +209,28 @@ public class FrameDebug extends Frame
{ {
dispose(); dispose();
} }
@Override
public double z()
{
return tile != null ? tile.zCoord : 0;
}
@Override
public double x()
{
return tile != null ? tile.xCoord : 0;
}
@Override
public double y()
{
return tile != null ? tile.yCoord : 0;
}
@Override
public World world()
{
return tile != null ? tile.getWorldObj() : null;
}
} }

View file

@ -1,6 +1,8 @@
package resonantinduction.core.debug; package resonantinduction.core.debug;
import codechicken.multipart.TMultiPart;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import resonant.api.grid.INode; import resonant.api.grid.INode;
import resonant.api.grid.INodeProvider; import resonant.api.grid.INodeProvider;
@ -48,4 +50,60 @@ public class FrameNodeDebug extends FrameDebug
} }
return node; return node;
} }
@Override
public double z()
{
if (nodeProvider instanceof TileEntity)
{
return ((TileEntity) nodeProvider).zCoord;
}
else if (nodeProvider instanceof TMultiPart)
{
return ((TMultiPart) nodeProvider).z();
}
return super.z();
}
@Override
public double x()
{
if (nodeProvider instanceof TileEntity)
{
return ((TileEntity) nodeProvider).xCoord;
}
else if (nodeProvider instanceof TMultiPart)
{
return ((TMultiPart) nodeProvider).x();
}
return super.x();
}
@Override
public double y()
{
if (nodeProvider instanceof TileEntity)
{
return ((TileEntity) nodeProvider).yCoord;
}
else if (nodeProvider instanceof TMultiPart)
{
return ((TMultiPart) nodeProvider).y();
}
return super.y();
}
@Override
public World world()
{
if (nodeProvider instanceof TileEntity)
{
return ((TileEntity) nodeProvider).getWorldObj();
}
else if (nodeProvider instanceof TMultiPart)
{
return ((TMultiPart) nodeProvider).world();
}
return super.world();
}
} }