Config property for displaying different energy units

This commit is contained in:
Aidan Brady 2014-01-11 11:49:27 -05:00
parent a3012b05fb
commit 70d3140296
6 changed files with 48 additions and 2 deletions

View file

@ -66,6 +66,7 @@ import mekanism.common.CommonProxy;
import mekanism.common.IElectricChest;
import mekanism.common.IInvConfiguration;
import mekanism.common.Mekanism;
import mekanism.common.EnergyDisplay.EnergyType;
import mekanism.common.block.BlockMachine.MachineType;
import mekanism.common.entity.EntityBalloon;
import mekanism.common.entity.EntityObsidianTNT;
@ -141,6 +142,29 @@ public class ClientProxy extends CommonProxy
MekanismClient.fancyUniversalCableRender = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "FancyUniversalCableRender", true).getBoolean(true);
MekanismClient.holidays = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "Holidays", true).getBoolean(true);
MekanismClient.baseSoundVolume = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "SoundVolume", 1D).getDouble(1D);
String s = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "EnergyType", "J").getString();
if(s != null)
{
if(s.trim().equalsIgnoreCase("j") || s.trim().equalsIgnoreCase("joules"))
{
Mekanism.activeType = EnergyType.J;
}
else if(s.trim().equalsIgnoreCase("rf") || s.trim().equalsIgnoreCase("te") || s.trim().equalsIgnoreCase("thermal expansion"))
{
Mekanism.activeType = EnergyType.RF;
}
else if(s.trim().equalsIgnoreCase("eu") || s.trim().equalsIgnoreCase("ic2"))
{
Mekanism.activeType = EnergyType.EU;
}
else if(s.trim().equalsIgnoreCase("mj") || s.trim().equalsIgnoreCase("bc") || s.trim().equalsIgnoreCase("buildcraft"))
{
Mekanism.activeType = EnergyType.MJ;
}
}
Mekanism.configuration.save();
}

View file

@ -32,7 +32,7 @@ public class GuiEnergyCube extends GuiMekanism
int xAxis = (mouseX - (width - xSize) / 2);
int yAxis = (mouseY - (height - ySize) / 2);
String capacityInfo = MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()) + "/" + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy());
String capacityInfo = MekanismUtils.getEnergyDisplay(tileEntity.getEnergy());
String outputInfo = MekanismUtils.localize("gui.out") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t";
fontRenderer.drawString(tileEntity.getInvName(), 43, 6, 0x404040);

View file

@ -190,4 +190,12 @@ public class EnergyDisplay
{
return roundDecimals(d, 2);
}
public static enum EnergyType
{
J,
RF,
EU,
MJ
}
}

View file

@ -25,6 +25,7 @@ import mekanism.api.transmitters.DynamicNetwork.ClientTickUpdate;
import mekanism.api.transmitters.DynamicNetwork.NetworkClientRequest;
import mekanism.api.transmitters.TransmitterNetworkRegistry;
import mekanism.client.ClientTickHandler;
import mekanism.common.EnergyDisplay.EnergyType;
import mekanism.common.EnergyNetwork.EnergyTransferEvent;
import mekanism.common.FluidNetwork.FluidTransferEvent;
import mekanism.common.IFactory.RecipeType;
@ -275,6 +276,7 @@ public class Mekanism
public static int VOICE_PORT = 36123;
public static int maxUpgradeMultiplier = 10;
public static double ENERGY_PER_REDSTONE = 10000;
public static EnergyType activeType = EnergyType.J;
public static double TO_IC2;
public static double TO_BC;

View file

@ -1129,7 +1129,19 @@ public final class MekanismUtils
*/
public static String getEnergyDisplay(double energy)
{
return EnergyDisplay.getDisplayShort(energy, ElectricUnit.JOULES);
switch(Mekanism.activeType)
{
case J:
return EnergyDisplay.getDisplayShort(energy, ElectricUnit.JOULES);
case RF:
return Math.round(energy*Mekanism.TO_TE) + " RF";
case EU:
return Math.round(energy*Mekanism.TO_IC2) + " EU";
case MJ:
return (Math.round((energy*Mekanism.TO_BC)*100)/100) + " MJ";
}
return "error";
}
/**

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB