Added Current/Max Power to Network Tool.

Added Current/Max Power to Spatial IO Port.
Added Required/Efficiency to Spatial IO Port.
Added Power Unit Button / Setting.
Fixed bug with Meteorite and Spatial IO.
Removed Random Logging in Spatial IO.
This commit is contained in:
AlgorithmX2
2014-03-05 23:45:14 -06:00
parent 040e948d8e
commit adb03c45c6
13 changed files with 262 additions and 62 deletions
+36
View File
@@ -1,6 +1,7 @@
package appeng.client.gui;
import java.io.IOException;
import java.text.DecimalFormat;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;
@@ -23,6 +24,7 @@ import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import appeng.api.config.PowerUnits;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.gui.widgets.GuiScrollbar;
import appeng.client.gui.widgets.ITooltip;
@@ -39,6 +41,7 @@ import appeng.container.slot.SlotFake;
import appeng.container.slot.SlotInaccessable;
import appeng.container.slot.SlotOutput;
import appeng.container.slot.SlotRestrictedInput;
import appeng.core.AEConfig;
import appeng.core.AELog;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketInventoryAction;
@@ -51,6 +54,39 @@ public abstract class AEBaseGui extends GuiContainer
protected List<InternalSlotME> meSlots = new LinkedList<InternalSlotME>();
protected GuiScrollbar myScrollBar = null;
protected String formatPowerLong(long n, boolean isRate)
{
double p = ((double) n) / 100;
PowerUnits displayUnits = AEConfig.instance.selectedPowerUnit();
p = PowerUnits.AE.convertTo( displayUnits, p );
int offset = 0;
String Lvl = "";
String preFixes[] = new String[] { "k", "M", "G", "T", "P", "T", "P", "E", "Z", "Y" };
String unitName = displayUnits.name();
if ( displayUnits == PowerUnits.WA )
unitName = "J";
if ( displayUnits == PowerUnits.KJ )
{
Lvl = preFixes[offset];
unitName = "J";
offset++;
}
while (p > 1000 && offset < preFixes.length)
{
p /= 1000;
Lvl = preFixes[offset];
offset++;
}
DecimalFormat df = new DecimalFormat( "#.##" );
return df.format( p ) + " " + Lvl + unitName + (isRate ? "/t" : "");
}
public AEBaseGui(Container container) {
super( container );
}
@@ -2,23 +2,28 @@ package appeng.client.gui.implementations;
import java.util.List;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import appeng.api.config.Settings;
import appeng.api.config.SortDir;
import appeng.api.config.SortOrder;
import appeng.api.implementations.guiobjects.INetworkTool;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiScrollbar;
import appeng.client.gui.widgets.ISortSource;
import appeng.client.me.ItemRepo;
import appeng.client.me.SlotME;
import appeng.container.implementations.ContainerNetworkStatus;
import appeng.core.AEConfig;
import appeng.core.localization.GuiText;
import appeng.util.Platform;
@@ -26,18 +31,42 @@ public class GuiNetworkStatus extends AEBaseGui implements ISortSource
{
ItemRepo repo;
GuiImgButton units;
int rows = 4;
public GuiNetworkStatus(InventoryPlayer inventoryPlayer, INetworkTool te) {
super( new ContainerNetworkStatus( inventoryPlayer, te ) );
this.ySize = 125;
this.ySize = 153;
this.xSize = 195;
myScrollBar = new GuiScrollbar();
repo = new ItemRepo( myScrollBar, this );
repo.rowSize = 5;
}
@Override
protected void actionPerformed(GuiButton btn)
{
super.actionPerformed( btn );
boolean backwards = Mouse.isButtonDown( 1 );
if ( btn == units )
{
AEConfig.instance.nextPowerUnit( backwards );
units.set( AEConfig.instance.selectedPowerUnit() );
}
}
@Override
public void initGui()
{
super.initGui();
units = new GuiImgButton( this.guiLeft - 18, guiTop + 8, Settings.POWER_UNITS, AEConfig.instance.selectedPowerUnit() );
buttonList.add( units );
}
public void postUpdate(List<IAEItemStack> list)
{
repo.clear();
@@ -110,8 +139,11 @@ public class GuiNetworkStatus extends AEBaseGui implements ISortSource
fontRendererObj.drawString( GuiText.NetworkDetails.getLocal(), 8, 6, 4210752 );
fontRendererObj.drawString( GuiText.PowerInputRate.getLocal() + ": " + formatPowerLong( ns.avgAddition ), 8, 16, 4210752 );
fontRendererObj.drawString( GuiText.PowerUsageRate.getLocal() + ": " + formatPowerLong( ns.powerUsage ), 8, 26, 4210752 );
fontRendererObj.drawString( GuiText.StoredPower.getLocal() + ": " + formatPowerLong( ns.currentPower, false ), 13, 16, 4210752 );
fontRendererObj.drawString( GuiText.MaxPower.getLocal() + ": " + formatPowerLong( ns.maxPower, false ), 13, 26, 4210752 );
fontRendererObj.drawString( GuiText.PowerInputRate.getLocal() + ": " + formatPowerLong( ns.avgAddition, true ), 13, 143 - 10, 4210752 );
fontRendererObj.drawString( GuiText.PowerUsageRate.getLocal() + ": " + formatPowerLong( ns.powerUsage, true ), 13, 143 - 20, 4210752 );
int sectionLength = 30;
@@ -152,7 +184,7 @@ public class GuiNetworkStatus extends AEBaseGui implements ISortSource
ToolTip = ToolTip + ("\n" + GuiText.Installed.getLocal() + ": " + (refStack.getStackSize()));
if ( refStack.getCountRequestable() > 0 )
ToolTip = ToolTip + ("\n" + GuiText.EnergyDrain.getLocal() + ": " + formatPowerLong( refStack.getCountRequestable() ));
ToolTip = ToolTip + ("\n" + GuiText.EnergyDrain.getLocal() + ": " + formatPowerLong( refStack.getCountRequestable(), true ));
toolPosX = x * sectionLength + xo + sectionLength - 8;
toolPosY = y * 18 + yo;
@@ -180,12 +212,6 @@ public class GuiNetworkStatus extends AEBaseGui implements ISortSource
}
private String formatPowerLong(long n)
{
double p = ((double) n) / 100;
return Double.toString( p ) + " ae/t";
}
// @Override - NEI
public List<String> handleItemTooltip(ItemStack stack, int mousex, int mousey, List<String> currenttip)
{
@@ -241,7 +267,7 @@ public class GuiNetworkStatus extends AEBaseGui implements ISortSource
currenttip.remove( 1 );
currenttip.add( GuiText.Installed.getLocal() + ": " + (myStack.getStackSize()) );
currenttip.add( GuiText.EnergyDrain.getLocal() + ": " + formatPowerLong( myStack.getCountRequestable() ) );
currenttip.add( GuiText.EnergyDrain.getLocal() + ": " + formatPowerLong( myStack.getCountRequestable(), true ) );
drawTooltip( x, y, 0, join( currenttip, "\n" ) );
}
@@ -1,17 +1,51 @@
package appeng.client.gui.implementations;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import org.lwjgl.input.Mouse;
import appeng.api.config.Settings;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.container.implementations.ContainerSpatialIOPort;
import appeng.core.AEConfig;
import appeng.core.localization.GuiText;
import appeng.tile.spatial.TileSpatialIOPort;
public class GuiSpatialIOPort extends AEBaseGui
{
ContainerSpatialIOPort csiop;
GuiImgButton units;
public GuiSpatialIOPort(InventoryPlayer inventoryPlayer, TileSpatialIOPort te) {
super( new ContainerSpatialIOPort( inventoryPlayer, te ) );
this.ySize = 199;
csiop = (ContainerSpatialIOPort) inventorySlots;
}
@Override
protected void actionPerformed(GuiButton btn)
{
super.actionPerformed( btn );
boolean backwards = Mouse.isButtonDown( 1 );
if ( btn == units )
{
AEConfig.instance.nextPowerUnit( backwards );
units.set( AEConfig.instance.selectedPowerUnit() );
}
}
@Override
public void initGui()
{
super.initGui();
units = new GuiImgButton( this.guiLeft - 18, guiTop + 8, Settings.POWER_UNITS, AEConfig.instance.selectedPowerUnit() );
buttonList.add( units );
}
@Override
@@ -24,6 +58,11 @@ public class GuiSpatialIOPort extends AEBaseGui
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
fontRendererObj.drawString( GuiText.StoredPower.getLocal() + ": " + formatPowerLong( csiop.currentPower, false ), 13, 21, 4210752 );
fontRendererObj.drawString( GuiText.MaxPower.getLocal() + ": " + formatPowerLong( csiop.maxPower, false ), 13, 31, 4210752 );
fontRendererObj.drawString( GuiText.RequiredPower.getLocal() + ": " + formatPowerLong( csiop.reqPower, false ), 13, 78, 4210752 );
fontRendererObj.drawString( GuiText.Efficiency.getLocal() + ": " + (((float) csiop.eff) / 100) + "%", 13, 88, 4210752 );
fontRendererObj.drawString( GuiText.SpatialIOPort.getLocal(), 8, 6, 4210752 );
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96, 4210752 );
}
+1
View File
@@ -113,6 +113,7 @@ public class GuiImgButton extends GuiButton implements ITooltip
registerApp( 16 * 10 + 2, Settings.POWER_UNITS, PowerUnits.MJ, ButtonToolTips.PowerUnits, PowerUnits.MJ.unlocalizedName );
registerApp( 16 * 10 + 3, Settings.POWER_UNITS, PowerUnits.KJ, ButtonToolTips.PowerUnits, PowerUnits.KJ.unlocalizedName );
registerApp( 16 * 10 + 4, Settings.POWER_UNITS, PowerUnits.WA, ButtonToolTips.PowerUnits, PowerUnits.WA.unlocalizedName );
registerApp( 16 * 10 + 5, Settings.POWER_UNITS, PowerUnits.RF, ButtonToolTips.PowerUnits, PowerUnits.RF.unlocalizedName );
registerApp( 3, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE, ButtonToolTips.RedstoneMode, ButtonToolTips.AlwaysActive );
registerApp( 0, Settings.REDSTONE_CONTROLLED, RedstoneMode.LOW_SIGNAL, ButtonToolTips.RedstoneMode, ButtonToolTips.ActiveWithoutSignal );