Created a prefab for Debug Frame GUI and added a few interfaces to go with it
This commit is contained in:
parent
884cd97296
commit
7468a38b8a
5 changed files with 160 additions and 0 deletions
92
src/main/scala/resonantinduction/core/debug/FrameDebug.java
Normal file
92
src/main/scala/resonantinduction/core/debug/FrameDebug.java
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
package resonantinduction.core.debug;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.awt.Frame;
|
||||||
|
import java.awt.Panel;
|
||||||
|
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import resonant.api.grid.INode;
|
||||||
|
|
||||||
|
@SuppressWarnings("serial")
|
||||||
|
public class FrameDebug extends Frame
|
||||||
|
{
|
||||||
|
/** Linked tile */
|
||||||
|
TileEntity tile = null;
|
||||||
|
/** Linked node */
|
||||||
|
INode node = null;
|
||||||
|
/** Are we debugging a node */
|
||||||
|
boolean debugNode = false;
|
||||||
|
|
||||||
|
public FrameDebug(TileEntity tile)
|
||||||
|
{
|
||||||
|
this();
|
||||||
|
this.tile = tile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FrameDebug(INode node)
|
||||||
|
{
|
||||||
|
this();
|
||||||
|
this.node = node;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected FrameDebug()
|
||||||
|
{
|
||||||
|
buildGUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Called to build the base of the GUI */
|
||||||
|
protected void buildGUI()
|
||||||
|
{
|
||||||
|
UpdatePanel topPanel = new UpdatePanel();
|
||||||
|
UpdatePanel botPanel = new UpdatePanel();
|
||||||
|
UpdatePanel leftPanel = new UpdatePanel();
|
||||||
|
UpdatePanel rightPanel = new UpdatePanel();
|
||||||
|
|
||||||
|
buildTop(topPanel);
|
||||||
|
buildBottom(botPanel);
|
||||||
|
buildLeft(leftPanel);
|
||||||
|
buildRight(rightPanel);
|
||||||
|
|
||||||
|
this.add(topPanel, BorderLayout.NORTH);
|
||||||
|
this.add(botPanel, BorderLayout.SOUTH);
|
||||||
|
this.add(rightPanel, BorderLayout.EAST);
|
||||||
|
this.add(leftPanel, BorderLayout.WEST);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Top are of the Frame */
|
||||||
|
public void buildTop(Panel panel)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Bottom are of the Frame */
|
||||||
|
public void buildBottom(Panel panel)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Left are of the Frame */
|
||||||
|
public void buildLeft(Panel panel)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Right are of the Frame */
|
||||||
|
public void buildRight(Panel panel)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Called each tick by the host of this GUI */
|
||||||
|
public void update()
|
||||||
|
{
|
||||||
|
for(Component component : getComponents())
|
||||||
|
{
|
||||||
|
if(component instanceof IUpdate)
|
||||||
|
{
|
||||||
|
((IUpdate)component).update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
9
src/main/scala/resonantinduction/core/debug/IDebug.java
Normal file
9
src/main/scala/resonantinduction/core/debug/IDebug.java
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
package resonantinduction.core.debug;
|
||||||
|
|
||||||
|
/** Used to pass info to the debug GUI
|
||||||
|
*
|
||||||
|
* @author Darkguardsman */
|
||||||
|
public interface IDebug
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
9
src/main/scala/resonantinduction/core/debug/IUpdate.java
Normal file
9
src/main/scala/resonantinduction/core/debug/IUpdate.java
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
package resonantinduction.core.debug;
|
||||||
|
|
||||||
|
/** Used by objects can update each tick
|
||||||
|
*
|
||||||
|
* @author Darkguardsman */
|
||||||
|
public interface IUpdate
|
||||||
|
{
|
||||||
|
public void update();
|
||||||
|
}
|
20
src/main/scala/resonantinduction/core/debug/UpdatePanel.java
Normal file
20
src/main/scala/resonantinduction/core/debug/UpdatePanel.java
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
package resonantinduction.core.debug;
|
||||||
|
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.awt.Panel;
|
||||||
|
|
||||||
|
@SuppressWarnings("serial")
|
||||||
|
public class UpdatePanel extends Panel implements IUpdate
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void update()
|
||||||
|
{
|
||||||
|
for(Component component : getComponents())
|
||||||
|
{
|
||||||
|
if(component instanceof IUpdate)
|
||||||
|
{
|
||||||
|
((IUpdate)component).update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
package resonantinduction.core.debug;
|
||||||
|
|
||||||
|
import java.awt.Label;
|
||||||
|
|
||||||
|
/** Simple label with an update method
|
||||||
|
*
|
||||||
|
* @author Darkguardsman */
|
||||||
|
@SuppressWarnings("serial")
|
||||||
|
public class UpdatedLabel extends Label implements IUpdate
|
||||||
|
{
|
||||||
|
String start_string = "I Am a Label";
|
||||||
|
|
||||||
|
public UpdatedLabel(String start)
|
||||||
|
{
|
||||||
|
super(start);
|
||||||
|
this.start_string = start;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update()
|
||||||
|
{
|
||||||
|
this.setText(buildLabel());
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Recreates then returns the label's string value */
|
||||||
|
public String buildLabel()
|
||||||
|
{
|
||||||
|
return start_string;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue