Added Energy Cells Charge levels to Waila
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package appeng.client.gui;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
@@ -24,7 +23,6 @@ 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;
|
||||
@@ -42,7 +40,6 @@ 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.AppEng;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
@@ -59,39 +56,6 @@ 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 );
|
||||
}
|
||||
|
||||
@@ -138,11 +138,11 @@ public class GuiNetworkStatus extends AEBaseGui implements ISortSource
|
||||
|
||||
fontRendererObj.drawString( GuiText.NetworkDetails.getLocal(), 8, 6, 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.StoredPower.getLocal() + ": " + Platform.formatPowerLong( ns.currentPower, false ), 13, 16, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.MaxPower.getLocal() + ": " + Platform.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 );
|
||||
fontRendererObj.drawString( GuiText.PowerInputRate.getLocal() + ": " + Platform.formatPowerLong( ns.avgAddition, true ), 13, 143 - 10, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.PowerUsageRate.getLocal() + ": " + Platform.formatPowerLong( ns.powerUsage, true ), 13, 143 - 20, 4210752 );
|
||||
|
||||
int sectionLength = 30;
|
||||
|
||||
@@ -183,7 +183,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(), true ));
|
||||
ToolTip = ToolTip + ("\n" + GuiText.EnergyDrain.getLocal() + ": " + Platform.formatPowerLong( refStack.getCountRequestable(), true ));
|
||||
|
||||
toolPosX = x * sectionLength + xo + sectionLength - 8;
|
||||
toolPosY = y * 18 + yo;
|
||||
@@ -266,7 +266,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(), true ) );
|
||||
currenttip.add( GuiText.EnergyDrain.getLocal() + ": " + Platform.formatPowerLong( myStack.getCountRequestable(), true ) );
|
||||
|
||||
drawTooltip( x, y, 0, join( currenttip, "\n" ) );
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import appeng.container.implementations.ContainerSpatialIOPort;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.tile.spatial.TileSpatialIOPort;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class GuiSpatialIOPort extends AEBaseGui
|
||||
{
|
||||
@@ -58,9 +59,9 @@ 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.StoredPower.getLocal() + ": " + Platform.formatPowerLong( csiop.currentPower, false ), 13, 21, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.MaxPower.getLocal() + ": " + Platform.formatPowerLong( csiop.maxPower, false ), 13, 31, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.RequiredPower.getLocal() + ": " + Platform.formatPowerLong( csiop.reqPower, false ), 13, 78, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.Efficiency.getLocal() + ": " + (((float) csiop.eff) / 100) + "%", 13, 88, 4210752 );
|
||||
|
||||
fontRendererObj.drawString( getGuiDisplayName( GuiText.SpatialIOPort.getLocal() ), 8, 6, 4210752 );
|
||||
|
||||
@@ -8,6 +8,7 @@ import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.api.IWailaRegistrar;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
@@ -25,6 +26,8 @@ import appeng.core.AppEng;
|
||||
import appeng.core.localization.WailaText;
|
||||
import appeng.integration.BaseModule;
|
||||
import appeng.tile.misc.TileCharger;
|
||||
import appeng.tile.networking.TileEnergyCell;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.common.event.FMLInterModComms;
|
||||
|
||||
public class Waila extends BaseModule implements IWailaDataProvider
|
||||
@@ -90,6 +93,18 @@ public class Waila extends BaseModule implements IWailaDataProvider
|
||||
}
|
||||
}
|
||||
|
||||
if ( ThingOfInterest instanceof TileEnergyCell )
|
||||
{
|
||||
NBTTagCompound c = accessor.getNBTData();
|
||||
if ( c != null )
|
||||
{
|
||||
TileEnergyCell tec = (TileEnergyCell) ThingOfInterest;
|
||||
long power = (long) (100 * c.getDouble( "internalCurrentPower" ));
|
||||
currenttip.add( WailaText.Contains + ": " + Platform.formatPowerLong( power, false ) + " / "
|
||||
+ Platform.formatPowerLong( (long) (100 * tec.getAEMaxPower()), false ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ThingOfInterest instanceof IPartStorageMonitor )
|
||||
{
|
||||
IPartStorageMonitor psm = (IPartStorageMonitor) ThingOfInterest;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package appeng.util;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumSet;
|
||||
@@ -52,6 +53,7 @@ import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.PowerMultiplier;
|
||||
import appeng.api.config.PowerUnits;
|
||||
import appeng.api.config.SearchBoxMode;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.config.SortOrder;
|
||||
@@ -78,6 +80,7 @@ import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.storage.data.IAETagCompound;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.api.util.AEItemDefinition;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
@@ -127,6 +130,46 @@ public class Platform
|
||||
return rdnSrc.nextFloat();
|
||||
}
|
||||
|
||||
/**
|
||||
* This displays the value for encoded longs ( double *100 )
|
||||
*
|
||||
* @param n
|
||||
* @param isRate
|
||||
* @return
|
||||
*/
|
||||
public static 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 static ForgeDirection crossProduct(ForgeDirection forward, ForgeDirection up)
|
||||
{
|
||||
int west_x = forward.offsetY * up.offsetZ - forward.offsetZ * up.offsetY;
|
||||
|
||||
Reference in New Issue
Block a user