Moving the handling of progress to GuiProgressBar

Adds an interface providing data for GuiProgressBar
Changed all containers simulating progress to implement the interface
This commit is contained in:
yueh
2014-09-28 20:36:58 +02:00
parent 640d888d13
commit 21a7d815ae
10 changed files with 142 additions and 44 deletions
@@ -26,7 +26,8 @@ public class GuiCondenser extends AEBaseGui
GuiProgressBar pb;
GuiImgButton mode;
public GuiCondenser(InventoryPlayer inventoryPlayer, TileCondenser te) {
public GuiCondenser(InventoryPlayer inventoryPlayer, TileCondenser te)
{
super( new ContainerCondenser( inventoryPlayer, te ) );
cvc = (ContainerCondenser) inventorySlots;
this.ySize = 197;
@@ -57,8 +58,7 @@ public class GuiCondenser extends AEBaseGui
{
super.initGui();
pb = new GuiProgressBar( "guis/condenser.png", 120 + guiLeft, 25 + guiTop, 178, 25, 6, 18, Direction.VERTICAL );
pb.TitleName = GuiText.StoredEnergy.getLocal();
pb = new GuiProgressBar( cvc, "guis/condenser.png", 120 + guiLeft, 25 + guiTop, 178, 25, 6, 18, Direction.VERTICAL, GuiText.StoredEnergy.getLocal() );
mode = new GuiImgButton( 128 + guiLeft, 52 + guiTop, Settings.CONDENSER_OUTPUT, cvc.output );
@@ -83,8 +83,6 @@ public class GuiCondenser extends AEBaseGui
mode.set( cvc.output );
mode.FillVar = "" + cvc.output.requiredPower;
pb.max = (int) cvc.requiredEnergy;
pb.current = (int) cvc.storedPower;
}
}
@@ -15,7 +15,8 @@ public class GuiInscriber extends AEBaseGui
ContainerInscriber cvc;
GuiProgressBar pb;
public GuiInscriber(InventoryPlayer inventoryPlayer, TileInscriber te) {
public GuiInscriber(InventoryPlayer inventoryPlayer, TileInscriber te)
{
super( new ContainerInscriber( inventoryPlayer, te ) );
cvc = (ContainerInscriber) inventorySlots;
this.ySize = 176;
@@ -27,7 +28,7 @@ public class GuiInscriber extends AEBaseGui
{
super.initGui();
pb = new GuiProgressBar( "guis/inscriber.png", 135, 39, 135, 177, 6, 18, Direction.VERTICAL );
pb = new GuiProgressBar( cvc, "guis/inscriber.png", 135, 39, 135, 177, 6, 18, Direction.VERTICAL );
this.buttonList.add( pb );
}
@@ -49,9 +50,7 @@ public class GuiInscriber extends AEBaseGui
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
pb.max = cvc.maxProcessingTime;
pb.current = cvc.processingTime;
pb.FullMsg = (pb.current * 100 / pb.max) + "%";
pb.setFullMsg( cvc.getCurrentProgress() * 100 / cvc.getMaxProgress() + "%" );
fontRendererObj.drawString( getGuiDisplayName( GuiText.Inscriber.getLocal() ), 8, 6, 4210752 );
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
@@ -21,7 +21,7 @@ public class GuiMAC extends GuiUpgradeable
{
super.initGui();
pb = new GuiProgressBar( "guis/mac.png", 139, 36, 148, 201, 6, 18, Direction.VERTICAL );
pb = new GuiProgressBar( container, "guis/mac.png", 139, 36, 148, 201, 6, 18, Direction.VERTICAL );
this.buttonList.add( pb );
}
@@ -36,10 +36,7 @@ public class GuiMAC extends GuiUpgradeable
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
pb.max = 100;
pb.current = container.craftProgress;
pb.FullMsg = pb.current + "%";
pb.setFullMsg( container.getCurrentProgress() + "%" );
super.drawFG( offsetX, offsetY, mouseX, mouseY );
}
@@ -56,7 +53,8 @@ public class GuiMAC extends GuiUpgradeable
return "guis/mac.png";
}
public GuiMAC(InventoryPlayer inventoryPlayer, TileMolecularAssembler te) {
public GuiMAC(InventoryPlayer inventoryPlayer, TileMolecularAssembler te)
{
super( new ContainerMAC( inventoryPlayer, te ) );
this.ySize = 197;
this.container = (ContainerMAC) this.inventorySlots;
@@ -17,7 +17,8 @@ public class GuiVibrationChamber extends AEBaseGui
ContainerVibrationChamber cvc;
GuiProgressBar pb;
public GuiVibrationChamber(InventoryPlayer inventoryPlayer, TileVibrationChamber te) {
public GuiVibrationChamber(InventoryPlayer inventoryPlayer, TileVibrationChamber te)
{
super( new ContainerVibrationChamber( inventoryPlayer, te ) );
cvc = (ContainerVibrationChamber) inventorySlots;
this.ySize = 166;
@@ -28,7 +29,7 @@ public class GuiVibrationChamber extends AEBaseGui
{
super.initGui();
pb = new GuiProgressBar( "guis/vibchamber.png", 99, 36, 176, 14, 6, 18, Direction.VERTICAL );
pb = new GuiProgressBar( cvc, "guis/vibchamber.png", 99, 36, 176, 14, 6, 18, Direction.VERTICAL );
this.buttonList.add( pb );
}
@@ -50,13 +51,11 @@ public class GuiVibrationChamber extends AEBaseGui
int k = 25;
int l = -15;
pb.max = 200;
pb.current = cvc.burnProgress > 0 ? cvc.burnSpeed : 0;
pb.FullMsg = (cvc.aePerTick * pb.current / 100) + " ae/t";
pb.setFullMsg( cvc.aePerTick * cvc.getCurrentProgress() / 100 + " ae/t" );
if ( cvc.burnProgress > 0 )
if ( cvc.getCurrentProgress() > 0 )
{
int i1 = cvc.burnProgress;
int i1 = cvc.getCurrentProgress();
bindTexture( "guis/vibchamber.png" );
GL11.glColor3f( 1, 1, 1 );
this.drawTexturedModalRect( k + 56, l + 36 + 12 - i1, 176, 12 - i1, 14, i1 + 2 );
@@ -3,6 +3,7 @@ package appeng.client.gui.widgets;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.util.ResourceLocation;
import appeng.container.interfaces.IProgressProvider;
import appeng.core.localization.GuiText;
public class GuiProgressBar extends GuiButton implements ITooltip
@@ -13,29 +14,33 @@ public class GuiProgressBar extends GuiButton implements ITooltip
HORIZONTAL, VERTICAL
}
private IProgressProvider source;
private ResourceLocation texture;
private int fill_u;
private int fill_v;
private Direction layout;
public String FullMsg;
private String fullMsg;
private final String titleName;
public String TitleName;
public int current;
public int max;
public GuiProgressBar(IProgressProvider source, String texture, int posX, int posY, int u, int y, int _width, int _height, Direction dir)
{
this( source, texture, posX, posY, u, y, _width, _height, dir, null );
}
public GuiProgressBar(String string, int posX, int posY, int u, int y, int _width, int _height, Direction dir) {
public GuiProgressBar(IProgressProvider source, String texture, int posX, int posY, int u, int y, int _width, int _height, Direction dir, String title)
{
super( posX, posY, _width, "" );
this.source = source;
this.xPosition = posX;
this.yPosition = posY;
texture = new ResourceLocation( "appliedenergistics2", "textures/" + string );
this.texture = new ResourceLocation( "appliedenergistics2", "textures/" + texture );
width = _width;
height = _height;
fill_u = u;
fill_v = y;
current = 0;
max = 100;
layout = dir;
titleName = title;
}
@Override
@@ -44,6 +49,8 @@ public class GuiProgressBar extends GuiButton implements ITooltip
if ( this.visible )
{
par1Minecraft.getTextureManager().bindTexture( texture );
int max = source.getMaxProgress();
int current = source.getCurrentProgress();
if ( layout == Direction.VERTICAL )
{
@@ -60,13 +67,18 @@ public class GuiProgressBar extends GuiButton implements ITooltip
}
}
public void setFullMsg(String msg)
{
this.fullMsg = msg;
}
@Override
public String getMsg()
{
if ( FullMsg != null )
return FullMsg;
if ( fullMsg != null )
return fullMsg;
return (TitleName != null ? TitleName : "") + "\n" + current + " " + GuiText.Of.getLocal() + " " + max;
return (titleName != null ? titleName : "") + "\n" + source.getCurrentProgress() + " " + GuiText.Of.getLocal() + " " + source.getMaxProgress();
}
@Override