pick 97420a31d The big reformat of 2020
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
|
||||
package appeng.fluids.client.gui;
|
||||
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
import appeng.client.gui.implementations.GuiUpgradeable;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
@@ -12,64 +14,52 @@ import appeng.fluids.client.gui.widgets.GuiFluidSlot;
|
||||
import appeng.fluids.client.gui.widgets.GuiOptionalFluidSlot;
|
||||
import appeng.fluids.container.ContainerFluidFormationPlane;
|
||||
import appeng.fluids.util.IAEFluidTank;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
public class GuiFluidFormationPlane extends GuiUpgradeable<ContainerFluidFormationPlane> {
|
||||
public GuiFluidFormationPlane(ContainerFluidFormationPlane container, PlayerInventory playerInventory,
|
||||
ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.ySize = 251;
|
||||
}
|
||||
|
||||
public class GuiFluidFormationPlane extends GuiUpgradeable<ContainerFluidFormationPlane>
|
||||
{
|
||||
public GuiFluidFormationPlane(ContainerFluidFormationPlane container, PlayerInventory playerInventory, ITextComponent title)
|
||||
{
|
||||
super(container, playerInventory, title);
|
||||
this.ySize = 251;
|
||||
}
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
final int xo = 8;
|
||||
final int yo = 23 + 6;
|
||||
|
||||
final int xo = 8;
|
||||
final int yo = 23 + 6;
|
||||
final IAEFluidTank config = container.getFluidConfigInventory();
|
||||
|
||||
final IAEFluidTank config = container.getFluidConfigInventory();
|
||||
for (int y = 0; y < 7; y++) {
|
||||
for (int x = 0; x < 9; x++) {
|
||||
final int idx = y * 9 + x;
|
||||
if (y < 2) {
|
||||
this.guiSlots.add(new GuiFluidSlot(config, idx, idx, xo + x * 18, yo + y * 18));
|
||||
} else {
|
||||
this.guiSlots.add(new GuiOptionalFluidSlot(config, container, idx, idx, y - 2, xo, yo, x, y));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for( int y = 0; y < 7; y++ )
|
||||
{
|
||||
for( int x = 0; x < 9; x++ )
|
||||
{
|
||||
final int idx = y * 9 + x;
|
||||
if( y < 2 )
|
||||
{
|
||||
this.guiSlots.add( new GuiFluidSlot( config, idx, idx, xo + x * 18, yo + y * 18 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.guiSlots.add( new GuiOptionalFluidSlot( config, container, idx, idx, y - 2, xo, yo, x, y ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void addButtons() {
|
||||
this.addButton(new GuiTabButton(this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(),
|
||||
this.itemRenderer, btn -> openPriorityGui()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addButtons()
|
||||
{
|
||||
this.addButton( new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRenderer, btn -> openPriorityGui() ) );
|
||||
}
|
||||
private void openPriorityGui() {
|
||||
NetworkHandler.instance().sendToServer(new PacketSwitchGuis(ContainerPriority.TYPE));
|
||||
}
|
||||
|
||||
private void openPriorityGui() {
|
||||
NetworkHandler.instance().sendToServer( new PacketSwitchGuis( ContainerPriority.TYPE ) );
|
||||
}
|
||||
@Override
|
||||
protected String getBackground() {
|
||||
return "guis/storagebus.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBackground()
|
||||
{
|
||||
return "guis/storagebus.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected GuiText getName()
|
||||
{
|
||||
return GuiText.FluidFormationPlane;
|
||||
}
|
||||
@Override
|
||||
protected GuiText getName() {
|
||||
return GuiText.FluidFormationPlane;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
package appeng.fluids.client.gui;
|
||||
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
import appeng.client.gui.implementations.GuiUpgradeable;
|
||||
import appeng.core.localization.GuiText;
|
||||
@@ -26,47 +28,40 @@ import appeng.fluids.client.gui.widgets.GuiOptionalFluidSlot;
|
||||
import appeng.fluids.container.ContainerFluidIO;
|
||||
import appeng.fluids.parts.PartFluidImportBus;
|
||||
import appeng.fluids.util.IAEFluidTank;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
|
||||
/**
|
||||
* @author BrockWS
|
||||
* @version rv5 - 1/05/2018
|
||||
* @since rv5 1/05/2018
|
||||
*/
|
||||
public class GuiFluidIO extends GuiUpgradeable<ContainerFluidIO>
|
||||
{
|
||||
public class GuiFluidIO extends GuiUpgradeable<ContainerFluidIO> {
|
||||
|
||||
public GuiFluidIO(ContainerFluidIO container, PlayerInventory playerInventory, ITextComponent title)
|
||||
{
|
||||
super(container, playerInventory, title);
|
||||
}
|
||||
public GuiFluidIO(ContainerFluidIO container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
|
||||
final IAEFluidTank inv = this.container.getFluidConfigInventory();
|
||||
final int y = 40;
|
||||
final int x = 80;
|
||||
final IAEFluidTank inv = this.container.getFluidConfigInventory();
|
||||
final int y = 40;
|
||||
final int x = 80;
|
||||
|
||||
this.guiSlots.add( new GuiFluidSlot( inv, 0, 0, x, y ) );
|
||||
this.guiSlots.add( new GuiOptionalFluidSlot( inv, container, 1, 1, 1, x, y, -1, 0 ) );
|
||||
this.guiSlots.add( new GuiOptionalFluidSlot( inv, container, 2, 2, 1, x, y, 1, 0 ) );
|
||||
this.guiSlots.add( new GuiOptionalFluidSlot( inv, container, 3, 3, 1, x, y, 0, -1 ) );
|
||||
this.guiSlots.add( new GuiOptionalFluidSlot( inv, container, 4, 4, 1, x, y, 0, 1 ) );
|
||||
this.guiSlots.add(new GuiFluidSlot(inv, 0, 0, x, y));
|
||||
this.guiSlots.add(new GuiOptionalFluidSlot(inv, container, 1, 1, 1, x, y, -1, 0));
|
||||
this.guiSlots.add(new GuiOptionalFluidSlot(inv, container, 2, 2, 1, x, y, 1, 0));
|
||||
this.guiSlots.add(new GuiOptionalFluidSlot(inv, container, 3, 3, 1, x, y, 0, -1));
|
||||
this.guiSlots.add(new GuiOptionalFluidSlot(inv, container, 4, 4, 1, x, y, 0, 1));
|
||||
|
||||
this.guiSlots.add( new GuiOptionalFluidSlot( inv, container, 5, 5, 2, x, y, -1, -1 ) );
|
||||
this.guiSlots.add( new GuiOptionalFluidSlot( inv, container, 6, 6, 2, x, y, 1, -1 ) );
|
||||
this.guiSlots.add( new GuiOptionalFluidSlot( inv, container, 7, 7, 2, x, y, -1, 1 ) );
|
||||
this.guiSlots.add( new GuiOptionalFluidSlot( inv, container, 8, 8, 2, x, y, 1, 1 ) );
|
||||
}
|
||||
this.guiSlots.add(new GuiOptionalFluidSlot(inv, container, 5, 5, 2, x, y, -1, -1));
|
||||
this.guiSlots.add(new GuiOptionalFluidSlot(inv, container, 6, 6, 2, x, y, 1, -1));
|
||||
this.guiSlots.add(new GuiOptionalFluidSlot(inv, container, 7, 7, 2, x, y, -1, 1));
|
||||
this.guiSlots.add(new GuiOptionalFluidSlot(inv, container, 8, 8, 2, x, y, 1, 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected GuiText getName()
|
||||
{
|
||||
return this.bc instanceof PartFluidImportBus ? GuiText.ImportBusFluids : GuiText.ExportBusFluids;
|
||||
}
|
||||
@Override
|
||||
protected GuiText getName() {
|
||||
return this.bc instanceof PartFluidImportBus ? GuiText.ImportBusFluids : GuiText.ExportBusFluids;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,9 @@
|
||||
|
||||
package appeng.fluids.client.gui;
|
||||
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
import appeng.client.gui.implementations.GuiUpgradeable;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
@@ -30,65 +33,55 @@ import appeng.fluids.client.gui.widgets.GuiFluidTank;
|
||||
import appeng.fluids.container.ContainerFluidInterface;
|
||||
import appeng.fluids.helper.DualityFluidInterface;
|
||||
import appeng.fluids.util.IAEFluidTank;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
public class GuiFluidInterface extends GuiUpgradeable<ContainerFluidInterface>
|
||||
{
|
||||
public GuiFluidInterface(ContainerFluidInterface container, PlayerInventory playerInventory, ITextComponent title)
|
||||
{
|
||||
super(container, playerInventory, title);
|
||||
this.ySize = 231;
|
||||
}
|
||||
public class GuiFluidInterface extends GuiUpgradeable<ContainerFluidInterface> {
|
||||
public GuiFluidInterface(ContainerFluidInterface container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.ySize = 231;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
|
||||
final IAEFluidTank configFluids = this.container.getFluidConfigInventory();
|
||||
final IAEFluidTank fluidTank = this.container.getTanks();
|
||||
final IAEFluidTank configFluids = this.container.getFluidConfigInventory();
|
||||
final IAEFluidTank fluidTank = this.container.getTanks();
|
||||
|
||||
for( int i = 0; i < DualityFluidInterface.NUMBER_OF_TANKS; ++i )
|
||||
{
|
||||
final GuiFluidTank guiTank = new GuiFluidTank( fluidTank, i, this.getGuiLeft() + 35 + 18 * i, this
|
||||
.getGuiTop() + 53, 16, 68 );
|
||||
this.addButton( guiTank );
|
||||
this.guiSlots.add( new GuiFluidSlot( configFluids, i, i, 35 + 18 * i, 35 ) );
|
||||
}
|
||||
for (int i = 0; i < DualityFluidInterface.NUMBER_OF_TANKS; ++i) {
|
||||
final GuiFluidTank guiTank = new GuiFluidTank(fluidTank, i, this.getGuiLeft() + 35 + 18 * i,
|
||||
this.getGuiTop() + 53, 16, 68);
|
||||
this.addButton(guiTank);
|
||||
this.guiSlots.add(new GuiFluidSlot(configFluids, i, i, 35 + 18 * i, 35));
|
||||
}
|
||||
|
||||
this.addButton( new GuiTabButton( this.getGuiLeft() + 154, this.getGuiTop(), 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRenderer, btn -> openPriorityGui() ) );
|
||||
}
|
||||
this.addButton(new GuiTabButton(this.getGuiLeft() + 154, this.getGuiTop(), 2 + 4 * 16,
|
||||
GuiText.Priority.getLocal(), this.itemRenderer, btn -> openPriorityGui()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addButtons()
|
||||
{
|
||||
}
|
||||
@Override
|
||||
protected void addButtons() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG( int offsetX, int offsetY, int mouseX, int mouseY )
|
||||
{
|
||||
this.font.drawString( this.getGuiDisplayName( GuiText.FluidInterface.getLocal() ), 8, 6, 4210752 );
|
||||
this.font.drawString( GuiText.Config.getLocal(), 35, 6 + 11 + 7, 4210752 );
|
||||
this.font.drawString( GuiText.StoredFluids.getLocal(), 35, 6 + 112 + 7, 4210752 );
|
||||
this.font.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
|
||||
}
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
|
||||
this.font.drawString(this.getGuiDisplayName(GuiText.FluidInterface.getLocal()), 8, 6, 4210752);
|
||||
this.font.drawString(GuiText.Config.getLocal(), 35, 6 + 11 + 7, 4210752);
|
||||
this.font.drawString(GuiText.StoredFluids.getLocal(), 35, 6 + 112 + 7, 4210752);
|
||||
this.font.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
this.bindTexture( "guis/interfacefluid.png" );
|
||||
GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize, 0 /* FIXME ZINDEX */ );
|
||||
}
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY, float partialTicks) {
|
||||
this.bindTexture("guis/interfacefluid.png");
|
||||
GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize, 0 /* FIXME ZINDEX */ );
|
||||
}
|
||||
|
||||
private void openPriorityGui() {
|
||||
NetworkHandler.instance().sendToServer( new PacketSwitchGuis( ContainerPriority.TYPE ) );
|
||||
}
|
||||
private void openPriorityGui() {
|
||||
NetworkHandler.instance().sendToServer(new PacketSwitchGuis(ContainerPriority.TYPE));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean drawUpgrades()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
protected boolean drawUpgrades() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,204 +1,180 @@
|
||||
|
||||
package appeng.fluids.client.gui;
|
||||
|
||||
|
||||
|
||||
import appeng.client.gui.widgets.GuiServerSettingToggleButton;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.util.InputMappings;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
import appeng.api.config.RedstoneMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.client.gui.implementations.GuiUpgradeable;
|
||||
import appeng.client.gui.widgets.GuiNumberBox;
|
||||
import appeng.client.gui.widgets.GuiServerSettingToggleButton;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.fluids.client.gui.widgets.GuiFluidSlot;
|
||||
import appeng.fluids.container.ContainerFluidLevelEmitter;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
public class GuiFluidLevelEmitter extends GuiUpgradeable<ContainerFluidLevelEmitter> {
|
||||
private GuiNumberBox level;
|
||||
|
||||
public class GuiFluidLevelEmitter extends GuiUpgradeable<ContainerFluidLevelEmitter>
|
||||
{
|
||||
private GuiNumberBox level;
|
||||
public GuiFluidLevelEmitter(ContainerFluidLevelEmitter container, PlayerInventory playerInventory,
|
||||
ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
}
|
||||
|
||||
public GuiFluidLevelEmitter(ContainerFluidLevelEmitter container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
}
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
this.level = new GuiNumberBox(this.font, this.guiLeft + 24, this.guiTop + 43, 79, this.font.FONT_HEIGHT,
|
||||
Long.class);
|
||||
this.level.setEnableBackgroundDrawing(false);
|
||||
this.level.setMaxStringLength(16);
|
||||
this.level.setTextColor(0xFFFFFF);
|
||||
this.level.setVisible(true);
|
||||
this.level.changeFocus(true);
|
||||
container.setTextField(this.level);
|
||||
|
||||
this.level = new GuiNumberBox( this.font, this.guiLeft + 24, this.guiTop + 43, 79, this.font.FONT_HEIGHT, Long.class );
|
||||
this.level.setEnableBackgroundDrawing( false );
|
||||
this.level.setMaxStringLength( 16 );
|
||||
this.level.setTextColor( 0xFFFFFF );
|
||||
this.level.setVisible( true );
|
||||
this.level.changeFocus( true );
|
||||
container.setTextField( this.level );
|
||||
final int y = 40;
|
||||
final int x = 80 + 44;
|
||||
this.guiSlots.add(new GuiFluidSlot(this.container.getFluidConfigInventory(), 0, 0, x, y));
|
||||
}
|
||||
|
||||
final int y = 40;
|
||||
final int x = 80 + 44;
|
||||
this.guiSlots.add( new GuiFluidSlot( this.container.getFluidConfigInventory(), 0, 0, x, y ) );
|
||||
}
|
||||
@Override
|
||||
protected void addButtons() {
|
||||
this.redstoneMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 28,
|
||||
Settings.REDSTONE_EMITTER, RedstoneMode.LOW_SIGNAL);
|
||||
|
||||
@Override
|
||||
protected void addButtons()
|
||||
{
|
||||
this.redstoneMode = new GuiServerSettingToggleButton<>( this.guiLeft - 18, this.guiTop + 28, Settings.REDSTONE_EMITTER, RedstoneMode.LOW_SIGNAL );
|
||||
final int a = AEConfig.instance().levelByMillyBuckets(0);
|
||||
final int b = AEConfig.instance().levelByMillyBuckets(1);
|
||||
final int c = AEConfig.instance().levelByMillyBuckets(2);
|
||||
final int d = AEConfig.instance().levelByMillyBuckets(3);
|
||||
|
||||
final int a = AEConfig.instance().levelByMillyBuckets( 0 );
|
||||
final int b = AEConfig.instance().levelByMillyBuckets( 1 );
|
||||
final int c = AEConfig.instance().levelByMillyBuckets( 2 );
|
||||
final int d = AEConfig.instance().levelByMillyBuckets( 3 );
|
||||
this.addButton(new Button(this.guiLeft + 20, this.guiTop + 17, 22, 20, "+" + a, btn -> addQty(a)));
|
||||
this.addButton(new Button(this.guiLeft + 48, this.guiTop + 17, 28, 20, "+" + b, btn -> addQty(b)));
|
||||
this.addButton(new Button(this.guiLeft + 82, this.guiTop + 17, 32, 20, "+" + c, btn -> addQty(c)));
|
||||
this.addButton(new Button(this.guiLeft + 120, this.guiTop + 17, 38, 20, "+" + d, btn -> addQty(d)));
|
||||
|
||||
this.addButton( new Button(this.guiLeft + 20, this.guiTop + 17, 22, 20, "+" + a, btn -> addQty(a) ) );
|
||||
this.addButton( new Button(this.guiLeft + 48, this.guiTop + 17, 28, 20, "+" + b, btn -> addQty(b) ) );
|
||||
this.addButton( new Button(this.guiLeft + 82, this.guiTop + 17, 32, 20, "+" + c, btn -> addQty(c) ) );
|
||||
this.addButton( new Button(this.guiLeft + 120, this.guiTop + 17, 38, 20, "+" + d, btn -> addQty(d) ) );
|
||||
this.addButton(new Button(this.guiLeft + 20, this.guiTop + 59, 22, 20, "-" + a, btn -> addQty(-a)));
|
||||
this.addButton(new Button(this.guiLeft + 48, this.guiTop + 59, 28, 20, "-" + b, btn -> addQty(-b)));
|
||||
this.addButton(new Button(this.guiLeft + 82, this.guiTop + 59, 32, 20, "-" + c, btn -> addQty(-c)));
|
||||
this.addButton(new Button(this.guiLeft + 120, this.guiTop + 59, 38, 20, "-" + d, btn -> addQty(-d)));
|
||||
|
||||
this.addButton( new Button(this.guiLeft + 20, this.guiTop + 59, 22, 20, "-" + a, btn -> addQty(-a) ) );
|
||||
this.addButton( new Button(this.guiLeft + 48, this.guiTop + 59, 28, 20, "-" + b, btn -> addQty(-b) ) );
|
||||
this.addButton( new Button(this.guiLeft + 82, this.guiTop + 59, 32, 20, "-" + c, btn -> addQty(-c) ) );
|
||||
this.addButton( new Button(this.guiLeft + 120, this.guiTop + 59, 38, 20, "-" + d, btn -> addQty(-d) ) );
|
||||
this.addButton(this.redstoneMode);
|
||||
}
|
||||
|
||||
this.addButton( this.redstoneMode );
|
||||
}
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
|
||||
super.drawBG(offsetX, offsetY, mouseX, mouseY, partialTicks);
|
||||
this.level.render(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks)
|
||||
{
|
||||
super.drawBG( offsetX, offsetY, mouseX, mouseY, partialTicks);
|
||||
this.level.render(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
@Override
|
||||
protected boolean drawUpgrades() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean drawUpgrades()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
protected String getBackground() {
|
||||
return "guis/lvlemitter.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBackground()
|
||||
{
|
||||
return "guis/lvlemitter.png";
|
||||
}
|
||||
@Override
|
||||
protected GuiText getName() {
|
||||
return GuiText.FluidLevelEmitter;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected GuiText getName()
|
||||
{
|
||||
return GuiText.FluidLevelEmitter;
|
||||
}
|
||||
@Override
|
||||
protected void handleButtonVisibility() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleButtonVisibility()
|
||||
{
|
||||
}
|
||||
private void addQty(final long i) {
|
||||
try {
|
||||
String Out = this.level.getText();
|
||||
|
||||
private void addQty( final long i )
|
||||
{
|
||||
try
|
||||
{
|
||||
String Out = this.level.getText();
|
||||
boolean Fixed = false;
|
||||
while (Out.startsWith("0") && Out.length() > 1) {
|
||||
Out = Out.substring(1);
|
||||
Fixed = true;
|
||||
}
|
||||
|
||||
boolean Fixed = false;
|
||||
while( Out.startsWith( "0" ) && Out.length() > 1 )
|
||||
{
|
||||
Out = Out.substring( 1 );
|
||||
Fixed = true;
|
||||
}
|
||||
if (Fixed) {
|
||||
this.level.setText(Out);
|
||||
}
|
||||
|
||||
if( Fixed )
|
||||
{
|
||||
this.level.setText( Out );
|
||||
}
|
||||
if (Out.isEmpty()) {
|
||||
Out = "0";
|
||||
}
|
||||
|
||||
if( Out.isEmpty() )
|
||||
{
|
||||
Out = "0";
|
||||
}
|
||||
long result = Long.parseLong(Out);
|
||||
result += i;
|
||||
if (result < 0) {
|
||||
result = 0;
|
||||
}
|
||||
|
||||
long result = Long.parseLong( Out );
|
||||
result += i;
|
||||
if( result < 0 )
|
||||
{
|
||||
result = 0;
|
||||
}
|
||||
this.level.setText(Out = Long.toString(result));
|
||||
|
||||
this.level.setText( Out = Long.toString( result ) );
|
||||
NetworkHandler.instance().sendToServer(new PacketValueConfig("FluidLevelEmitter.Value", Out));
|
||||
} catch (final NumberFormatException e) {
|
||||
// nope..
|
||||
this.level.setText("0");
|
||||
}
|
||||
}
|
||||
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "FluidLevelEmitter.Value", Out ) );
|
||||
}
|
||||
catch( final NumberFormatException e )
|
||||
{
|
||||
// nope..
|
||||
this.level.setText( "0" );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean charTyped(char character, int keyCode) {
|
||||
if (level.charTyped(character, keyCode)) {
|
||||
String Out = this.level.getText();
|
||||
|
||||
@Override
|
||||
public boolean charTyped(char character, int keyCode) {
|
||||
if (level.charTyped(character, keyCode)) {
|
||||
String Out = this.level.getText();
|
||||
boolean Fixed = false;
|
||||
while (Out.startsWith("0") && Out.length() > 1) {
|
||||
Out = Out.substring(1);
|
||||
Fixed = true;
|
||||
}
|
||||
|
||||
boolean Fixed = false;
|
||||
while( Out.startsWith( "0" ) && Out.length() > 1 )
|
||||
{
|
||||
Out = Out.substring( 1 );
|
||||
Fixed = true;
|
||||
}
|
||||
if (Fixed) {
|
||||
this.level.setText(Out);
|
||||
}
|
||||
|
||||
if( Fixed )
|
||||
{
|
||||
this.level.setText( Out );
|
||||
}
|
||||
if (Out.isEmpty()) {
|
||||
Out = "0";
|
||||
}
|
||||
|
||||
if( Out.isEmpty() )
|
||||
{
|
||||
Out = "0";
|
||||
}
|
||||
NetworkHandler.instance().sendToServer(new PacketValueConfig("FluidLevelEmitter.Value", Out));
|
||||
return true;
|
||||
}
|
||||
return super.charTyped(character, keyCode);
|
||||
}
|
||||
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "FluidLevelEmitter.Value", Out ) );
|
||||
return true;
|
||||
}
|
||||
return super.charTyped(character, keyCode);
|
||||
}
|
||||
@Override
|
||||
public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_) {
|
||||
if (!this.checkHotbarKeys(InputMappings.getInputByCode(keyCode, scanCode))) {
|
||||
if ((keyCode == 211 || keyCode == 205 || keyCode == 203 || keyCode == 14)
|
||||
&& this.level.keyPressed(keyCode, scanCode, p_keyPressed_3_)) {
|
||||
String Out = this.level.getText();
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_)
|
||||
{
|
||||
if( !this.checkHotbarKeys( InputMappings.getInputByCode(keyCode, scanCode) ) )
|
||||
{
|
||||
if( ( keyCode == 211 || keyCode == 205 || keyCode == 203 || keyCode == 14 ) && this.level.keyPressed( keyCode, scanCode, p_keyPressed_3_ ) )
|
||||
{
|
||||
String Out = this.level.getText();
|
||||
boolean Fixed = false;
|
||||
while (Out.startsWith("0") && Out.length() > 1) {
|
||||
Out = Out.substring(1);
|
||||
Fixed = true;
|
||||
}
|
||||
|
||||
boolean Fixed = false;
|
||||
while( Out.startsWith( "0" ) && Out.length() > 1 )
|
||||
{
|
||||
Out = Out.substring( 1 );
|
||||
Fixed = true;
|
||||
}
|
||||
if (Fixed) {
|
||||
this.level.setText(Out);
|
||||
}
|
||||
|
||||
if( Fixed )
|
||||
{
|
||||
this.level.setText( Out );
|
||||
}
|
||||
if (Out.isEmpty()) {
|
||||
Out = "0";
|
||||
}
|
||||
|
||||
if( Out.isEmpty() )
|
||||
{
|
||||
Out = "0";
|
||||
}
|
||||
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "FluidLevelEmitter.Value", Out ) );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return super.keyPressed(keyCode, scanCode, p_keyPressed_3_);
|
||||
}
|
||||
NetworkHandler.instance().sendToServer(new PacketValueConfig("FluidLevelEmitter.Value", Out));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return super.keyPressed(keyCode, scanCode, p_keyPressed_3_);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,150 +1,138 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2018, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.fluids.client.gui;
|
||||
|
||||
|
||||
import appeng.client.gui.widgets.GuiActionButton;
|
||||
import appeng.client.gui.widgets.GuiServerSettingToggleButton;
|
||||
import appeng.container.implementations.ContainerPriority;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.ActionItems;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.StorageFilter;
|
||||
import appeng.client.gui.implementations.GuiUpgradeable;
|
||||
import appeng.client.gui.widgets.GuiSettingToggleButton;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.core.localization.GuiText;
|
||||
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.fluids.client.gui.widgets.GuiFluidSlot;
|
||||
import appeng.fluids.client.gui.widgets.GuiOptionalFluidSlot;
|
||||
import appeng.fluids.container.ContainerFluidStorageBus;
|
||||
import appeng.fluids.util.IAEFluidTank;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
|
||||
/**
|
||||
* @author BrockWS
|
||||
* @version rv6 - 22/05/2018
|
||||
* @since rv6 22/05/2018
|
||||
*/
|
||||
public class GuiFluidStorageBus extends GuiUpgradeable<ContainerFluidStorageBus>
|
||||
{
|
||||
private GuiSettingToggleButton<AccessRestriction> rwMode;
|
||||
private GuiSettingToggleButton<StorageFilter> storageFilter;
|
||||
|
||||
public GuiFluidStorageBus(ContainerFluidStorageBus container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.ySize = 251;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
|
||||
final int xo = 8;
|
||||
final int yo = 23 + 6;
|
||||
|
||||
final IAEFluidTank config = this.container.getFluidConfigInventory();
|
||||
|
||||
for( int y = 0; y < 7; y++ )
|
||||
{
|
||||
for( int x = 0; x < 9; x++ )
|
||||
{
|
||||
final int idx = y * 9 + x;
|
||||
if( y < 2 )
|
||||
{
|
||||
this.guiSlots.add( new GuiFluidSlot( config, idx, idx, xo + x * 18, yo + y * 18 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.guiSlots.add( new GuiOptionalFluidSlot( config, container, idx, idx, y - 2, xo, yo, x, y ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addButtons()
|
||||
{
|
||||
addButton( new GuiActionButton( this.guiLeft - 18, this.guiTop + 8, ActionItems.CLOSE, btn -> clear() ) );
|
||||
addButton( new GuiActionButton( this.guiLeft - 18, this.guiTop + 28, ActionItems.WRENCH, btn -> partition() ) );
|
||||
this.rwMode = new GuiServerSettingToggleButton<>( this.guiLeft - 18, this.guiTop + 48, Settings.ACCESS, AccessRestriction.READ_WRITE );
|
||||
this.storageFilter = new GuiServerSettingToggleButton<>( this.guiLeft - 18, this.guiTop + 68, Settings.STORAGE_FILTER, StorageFilter.EXTRACTABLE_ONLY );
|
||||
this.fuzzyMode = new GuiServerSettingToggleButton<>( this.guiLeft - 18, this.guiTop + 88, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
|
||||
|
||||
addButton( this.addButton( new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRenderer, btn -> openPriorityGui() ) ) );
|
||||
|
||||
this.addButton( this.storageFilter );
|
||||
this.addButton( this.fuzzyMode );
|
||||
this.addButton( this.rwMode );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
{
|
||||
this.font.drawString( this.getGuiDisplayName( this.getName().getLocal() ), 8, 6, 4210752 );
|
||||
this.font.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
|
||||
|
||||
if( this.fuzzyMode != null )
|
||||
{
|
||||
this.fuzzyMode.set( this.cvb.getFuzzyMode() );
|
||||
}
|
||||
|
||||
if( this.storageFilter != null )
|
||||
{
|
||||
this.storageFilter.set( ( (ContainerFluidStorageBus) this.cvb ).getStorageFilter() );
|
||||
}
|
||||
|
||||
if( this.rwMode != null )
|
||||
{
|
||||
this.rwMode.set( ( (ContainerFluidStorageBus) this.cvb ).getReadWriteMode() );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBackground()
|
||||
{
|
||||
return "guis/storagebus.png";
|
||||
}
|
||||
|
||||
private void partition() {
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "StorageBus.Action", "Partition" ) );
|
||||
}
|
||||
|
||||
private void clear() {
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "StorageBus.Action", "Clear" ) );
|
||||
}
|
||||
|
||||
private void openPriorityGui() {
|
||||
NetworkHandler.instance().sendToServer( new PacketSwitchGuis( ContainerPriority.TYPE ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected GuiText getName()
|
||||
{
|
||||
return GuiText.StorageBusFluids;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2018, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.fluids.client.gui;
|
||||
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.ActionItems;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.StorageFilter;
|
||||
import appeng.client.gui.implementations.GuiUpgradeable;
|
||||
import appeng.client.gui.widgets.GuiActionButton;
|
||||
import appeng.client.gui.widgets.GuiServerSettingToggleButton;
|
||||
import appeng.client.gui.widgets.GuiSettingToggleButton;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.container.implementations.ContainerPriority;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.fluids.client.gui.widgets.GuiFluidSlot;
|
||||
import appeng.fluids.client.gui.widgets.GuiOptionalFluidSlot;
|
||||
import appeng.fluids.container.ContainerFluidStorageBus;
|
||||
import appeng.fluids.util.IAEFluidTank;
|
||||
|
||||
/**
|
||||
* @author BrockWS
|
||||
* @version rv6 - 22/05/2018
|
||||
* @since rv6 22/05/2018
|
||||
*/
|
||||
public class GuiFluidStorageBus extends GuiUpgradeable<ContainerFluidStorageBus> {
|
||||
private GuiSettingToggleButton<AccessRestriction> rwMode;
|
||||
private GuiSettingToggleButton<StorageFilter> storageFilter;
|
||||
|
||||
public GuiFluidStorageBus(ContainerFluidStorageBus container, PlayerInventory playerInventory,
|
||||
ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.ySize = 251;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
|
||||
final int xo = 8;
|
||||
final int yo = 23 + 6;
|
||||
|
||||
final IAEFluidTank config = this.container.getFluidConfigInventory();
|
||||
|
||||
for (int y = 0; y < 7; y++) {
|
||||
for (int x = 0; x < 9; x++) {
|
||||
final int idx = y * 9 + x;
|
||||
if (y < 2) {
|
||||
this.guiSlots.add(new GuiFluidSlot(config, idx, idx, xo + x * 18, yo + y * 18));
|
||||
} else {
|
||||
this.guiSlots.add(new GuiOptionalFluidSlot(config, container, idx, idx, y - 2, xo, yo, x, y));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addButtons() {
|
||||
addButton(new GuiActionButton(this.guiLeft - 18, this.guiTop + 8, ActionItems.CLOSE, btn -> clear()));
|
||||
addButton(new GuiActionButton(this.guiLeft - 18, this.guiTop + 28, ActionItems.WRENCH, btn -> partition()));
|
||||
this.rwMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 48, Settings.ACCESS,
|
||||
AccessRestriction.READ_WRITE);
|
||||
this.storageFilter = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 68,
|
||||
Settings.STORAGE_FILTER, StorageFilter.EXTRACTABLE_ONLY);
|
||||
this.fuzzyMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 88, Settings.FUZZY_MODE,
|
||||
FuzzyMode.IGNORE_ALL);
|
||||
|
||||
addButton(this.addButton(new GuiTabButton(this.guiLeft + 154, this.guiTop, 2 + 4 * 16,
|
||||
GuiText.Priority.getLocal(), this.itemRenderer, btn -> openPriorityGui())));
|
||||
|
||||
this.addButton(this.storageFilter);
|
||||
this.addButton(this.fuzzyMode);
|
||||
this.addButton(this.rwMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
this.font.drawString(this.getGuiDisplayName(this.getName().getLocal()), 8, 6, 4210752);
|
||||
this.font.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752);
|
||||
|
||||
if (this.fuzzyMode != null) {
|
||||
this.fuzzyMode.set(this.cvb.getFuzzyMode());
|
||||
}
|
||||
|
||||
if (this.storageFilter != null) {
|
||||
this.storageFilter.set(((ContainerFluidStorageBus) this.cvb).getStorageFilter());
|
||||
}
|
||||
|
||||
if (this.rwMode != null) {
|
||||
this.rwMode.set(((ContainerFluidStorageBus) this.cvb).getReadWriteMode());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBackground() {
|
||||
return "guis/storagebus.png";
|
||||
}
|
||||
|
||||
private void partition() {
|
||||
NetworkHandler.instance().sendToServer(new PacketValueConfig("StorageBus.Action", "Partition"));
|
||||
}
|
||||
|
||||
private void clear() {
|
||||
NetworkHandler.instance().sendToServer(new PacketValueConfig("StorageBus.Action", "Clear"));
|
||||
}
|
||||
|
||||
private void openPriorityGui() {
|
||||
NetworkHandler.instance().sendToServer(new PacketSwitchGuis(ContainerPriority.TYPE));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected GuiText getName() {
|
||||
return GuiText.StorageBusFluids;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,340 +1,312 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2018, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.fluids.client.gui;
|
||||
|
||||
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.SortDir;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.ViewItems;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.client.gui.AEBaseMEGui;
|
||||
import appeng.client.gui.widgets.GuiSettingToggleButton;
|
||||
import appeng.client.gui.widgets.GuiScrollbar;
|
||||
import appeng.client.gui.widgets.ISortSource;
|
||||
import appeng.client.gui.widgets.MEGuiTextField;
|
||||
import appeng.client.me.FluidRepo;
|
||||
import appeng.client.me.InternalFluidSlotME;
|
||||
import appeng.client.me.SlotFluidME;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketInventoryAction;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.fluids.container.ContainerFluidTerminal;
|
||||
import appeng.fluids.container.slots.IMEFluidSlot;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.client.util.InputMappings;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.ClickType;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
|
||||
/**
|
||||
* @author BrockWS
|
||||
* @version rv6 - 12/05/2018
|
||||
* @since rv6 12/05/2018
|
||||
*/
|
||||
public class GuiFluidTerminal extends AEBaseMEGui<ContainerFluidTerminal> implements ISortSource, IConfigManagerHost
|
||||
{
|
||||
private final List<SlotFluidME> meFluidSlots = new LinkedList<>();
|
||||
private final FluidRepo repo;
|
||||
private final IConfigManager configSrc;
|
||||
private final int offsetX = 9;
|
||||
private int rows = 6;
|
||||
private int perRow = 9;
|
||||
|
||||
private MEGuiTextField searchField;
|
||||
private GuiSettingToggleButton<SortOrder> sortByBox;
|
||||
private GuiSettingToggleButton<SortDir> sortDirBox;
|
||||
|
||||
public GuiFluidTerminal(ContainerFluidTerminal container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.xSize = 185;
|
||||
this.ySize = 222;
|
||||
final GuiScrollbar scrollbar = new GuiScrollbar();
|
||||
this.setScrollBar( scrollbar );
|
||||
this.repo = new FluidRepo( scrollbar, this );
|
||||
this.configSrc = container.getConfigManager();
|
||||
this.container.setGui( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
this.guiLeft = ( this.width - this.xSize ) / 2;
|
||||
this.guiTop = ( this.height - this.ySize ) / 2;
|
||||
|
||||
this.searchField = new MEGuiTextField( this.font, this.guiLeft + Math.max( 80, this.offsetX ), this.guiTop + 4, 90, 12 );
|
||||
this.searchField.setEnableBackgroundDrawing( false );
|
||||
this.searchField.setMaxStringLength( 25 );
|
||||
this.searchField.setTextColor( 0xFFFFFF );
|
||||
this.searchField.setSelectionColor( 0xFF99FF99 );
|
||||
this.searchField.setVisible( true );
|
||||
|
||||
int offset = this.guiTop;
|
||||
|
||||
this.sortByBox = this.addButton( new GuiSettingToggleButton<>( this.guiLeft - 18, offset, Settings.SORT_BY, getSortBy(), Platform::isSortOrderAvailable, this::toggleServerSetting ) );
|
||||
offset += 20;
|
||||
|
||||
this.sortDirBox = this.addButton( new GuiSettingToggleButton<>( this.guiLeft - 18, offset, Settings.SORT_DIRECTION, getSortDir(), this::toggleServerSetting ) );
|
||||
|
||||
for( int y = 0; y < this.rows; y++ )
|
||||
{
|
||||
for( int x = 0; x < this.perRow; x++ )
|
||||
{
|
||||
SlotFluidME slot = new SlotFluidME( new InternalFluidSlotME( this.repo, x + y * this.perRow, this.offsetX + x * 18, 18 + y * 18 ) );
|
||||
this.getMeFluidSlots().add( slot );
|
||||
this.container.inventorySlots.add( slot );
|
||||
}
|
||||
}
|
||||
this.setScrollBar();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG( int offsetX, int offsetY, int mouseX, int mouseY )
|
||||
{
|
||||
this.font.drawString( this.getGuiDisplayName( "Fluid Terminal" ), 8, 6, 4210752 );
|
||||
this.font.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
this.bindTexture( this.getBackground() );
|
||||
final int x_width = 197;
|
||||
GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, x_width, 18, getBlitOffset() );
|
||||
|
||||
for( int x = 0; x < 6; x++ )
|
||||
{
|
||||
GuiUtils.drawTexturedModalRect( offsetX, offsetY + 18 + x * 18, 0, 18, x_width, 18, getBlitOffset() );
|
||||
}
|
||||
|
||||
GuiUtils.drawTexturedModalRect( offsetX, offsetY + 16 + 6 * 18, 0, 106 - 18 - 18, x_width, 99 + 77, getBlitOffset() );
|
||||
|
||||
if( this.searchField != null )
|
||||
{
|
||||
this.searchField.render(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
this.repo.setPower( this.container.isPowered() );
|
||||
super.tick();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderHoveredToolTip( int mouseX, int mouseY )
|
||||
{
|
||||
final Slot slot = this.getSlot( mouseX, mouseY );
|
||||
|
||||
if( slot instanceof IMEFluidSlot && slot.isEnabled() )
|
||||
{
|
||||
final IMEFluidSlot fluidSlot = (IMEFluidSlot) slot;
|
||||
|
||||
if( fluidSlot.getAEFluidStack() != null && fluidSlot.shouldRenderAsFluid() )
|
||||
{
|
||||
final IAEFluidStack fluidStack = fluidSlot.getAEFluidStack();
|
||||
final String formattedAmount = NumberFormat.getNumberInstance( Locale.US ).format( fluidStack.getStackSize() / 1000.0 ) + " B";
|
||||
|
||||
final String modName = Platform.getModName( Platform.getModId( fluidStack ) );
|
||||
|
||||
final List<String> list = new ArrayList<>();
|
||||
|
||||
list.add( fluidStack.getFluidStack().getDisplayName().getFormattedText() );
|
||||
list.add( formattedAmount );
|
||||
list.add( modName );
|
||||
|
||||
this.renderTooltip( list, mouseX, mouseY );
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
super.renderHoveredToolTip( mouseX, mouseY );
|
||||
}
|
||||
|
||||
private <S extends Enum<S>> void toggleServerSetting(GuiSettingToggleButton<S> btn, boolean backwards) {
|
||||
S next = btn.getNextValue(backwards);
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( btn.getSetting().name(), next.name() ) );
|
||||
btn.set( next );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleMouseClick( Slot slot, int slotIdx, int mouseButton, ClickType clickType )
|
||||
{
|
||||
if( slot instanceof SlotFluidME )
|
||||
{
|
||||
final SlotFluidME meSlot = (SlotFluidME) slot;
|
||||
|
||||
if( clickType == ClickType.PICKUP )
|
||||
{
|
||||
// TODO: Allow more options
|
||||
if( mouseButton == 0 && meSlot.getHasStack() )
|
||||
{
|
||||
this.container.setTargetStack( meSlot.getAEFluidStack() );
|
||||
AELog.debug( "mouse0 GUI STACK SIZE %s", meSlot.getAEFluidStack().getStackSize() );
|
||||
NetworkHandler.instance().sendToServer( new PacketInventoryAction( InventoryAction.FILL_ITEM, slot.slotNumber, 0 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.container.setTargetStack( meSlot.getAEFluidStack() );
|
||||
if( meSlot.getAEFluidStack() != null )
|
||||
{
|
||||
AELog.debug( "mouse1 GUI STACK SIZE %s", meSlot.getAEFluidStack().getStackSize() );
|
||||
}
|
||||
NetworkHandler.instance().sendToServer( new PacketInventoryAction( InventoryAction.EMPTY_ITEM, slot.slotNumber, 0 ) );
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
super.handleMouseClick( slot, slotIdx, mouseButton, clickType );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean charTyped(char character, int keyCode) {
|
||||
if (character == ' ' && this.searchField.getText().isEmpty())
|
||||
{
|
||||
// Swallow spaces if the text field is still empty
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this.searchField.charTyped(character, keyCode)) {
|
||||
this.repo.setSearchString( this.searchField.getText() );
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.charTyped(character, keyCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_)
|
||||
{
|
||||
InputMappings.Input input = InputMappings.getInputByCode(keyCode, scanCode);
|
||||
if( !this.checkHotbarKeys(input) )
|
||||
{
|
||||
if( this.searchField.keyPressed( keyCode, scanCode, p_keyPressed_3_ ) )
|
||||
{
|
||||
this.repo.setSearchString( this.searchField.getText() );
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.keyPressed(keyCode, scanCode, p_keyPressed_3_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked( final double xCoord, final double yCoord, final int btn )
|
||||
{
|
||||
if (this.searchField.mouseClicked( xCoord, yCoord, btn )) {
|
||||
if (btn == 1 && this.searchField.isMouseOver(xCoord, yCoord)) {
|
||||
this.searchField.setText("");
|
||||
this.repo.setSearchString("");
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.mouseClicked( xCoord, yCoord, btn );
|
||||
}
|
||||
|
||||
public void postUpdate( final List<IAEFluidStack> list )
|
||||
{
|
||||
for( final IAEFluidStack is : list )
|
||||
{
|
||||
this.repo.postUpdate( is );
|
||||
}
|
||||
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
}
|
||||
|
||||
private void setScrollBar()
|
||||
{
|
||||
this.getScrollBar().setTop( 18 ).setLeft( 175 ).setHeight( this.rows * 18 - 2 );
|
||||
this.getScrollBar().setRange( 0, ( this.repo.size() + this.perRow - 1 ) / this.perRow - this.rows, Math.max( 1, this.rows / 6 ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortOrder getSortBy()
|
||||
{
|
||||
return (SortOrder) this.configSrc.getSetting( Settings.SORT_BY );
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortDir getSortDir()
|
||||
{
|
||||
return (SortDir) this.configSrc.getSetting( Settings.SORT_DIRECTION );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ViewItems getSortDisplay()
|
||||
{
|
||||
return (ViewItems) this.configSrc.getSetting( Settings.VIEW_MODE );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting(IConfigManager manager, Settings settingName, Enum<?> newValue )
|
||||
{
|
||||
if( this.sortByBox != null )
|
||||
{
|
||||
this.sortByBox.set( getSortBy() );
|
||||
}
|
||||
|
||||
if( this.sortDirBox != null )
|
||||
{
|
||||
this.sortDirBox.set( getSortDir() );
|
||||
}
|
||||
|
||||
this.repo.updateView();
|
||||
}
|
||||
|
||||
protected List<SlotFluidME> getMeFluidSlots()
|
||||
{
|
||||
return this.meFluidSlots;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isPowered()
|
||||
{
|
||||
return this.repo.hasPower();
|
||||
}
|
||||
|
||||
protected String getBackground()
|
||||
{
|
||||
return "guis/terminal.png";
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2018, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.fluids.client.gui;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import net.minecraft.client.util.InputMappings;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.ClickType;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.SortDir;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.ViewItems;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.client.gui.AEBaseMEGui;
|
||||
import appeng.client.gui.widgets.GuiScrollbar;
|
||||
import appeng.client.gui.widgets.GuiSettingToggleButton;
|
||||
import appeng.client.gui.widgets.ISortSource;
|
||||
import appeng.client.gui.widgets.MEGuiTextField;
|
||||
import appeng.client.me.FluidRepo;
|
||||
import appeng.client.me.InternalFluidSlotME;
|
||||
import appeng.client.me.SlotFluidME;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketInventoryAction;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.fluids.container.ContainerFluidTerminal;
|
||||
import appeng.fluids.container.slots.IMEFluidSlot;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
import appeng.util.Platform;
|
||||
|
||||
/**
|
||||
* @author BrockWS
|
||||
* @version rv6 - 12/05/2018
|
||||
* @since rv6 12/05/2018
|
||||
*/
|
||||
public class GuiFluidTerminal extends AEBaseMEGui<ContainerFluidTerminal> implements ISortSource, IConfigManagerHost {
|
||||
private final List<SlotFluidME> meFluidSlots = new LinkedList<>();
|
||||
private final FluidRepo repo;
|
||||
private final IConfigManager configSrc;
|
||||
private final int offsetX = 9;
|
||||
private int rows = 6;
|
||||
private int perRow = 9;
|
||||
|
||||
private MEGuiTextField searchField;
|
||||
private GuiSettingToggleButton<SortOrder> sortByBox;
|
||||
private GuiSettingToggleButton<SortDir> sortDirBox;
|
||||
|
||||
public GuiFluidTerminal(ContainerFluidTerminal container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.xSize = 185;
|
||||
this.ySize = 222;
|
||||
final GuiScrollbar scrollbar = new GuiScrollbar();
|
||||
this.setScrollBar(scrollbar);
|
||||
this.repo = new FluidRepo(scrollbar, this);
|
||||
this.configSrc = container.getConfigManager();
|
||||
this.container.setGui(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
this.guiLeft = (this.width - this.xSize) / 2;
|
||||
this.guiTop = (this.height - this.ySize) / 2;
|
||||
|
||||
this.searchField = new MEGuiTextField(this.font, this.guiLeft + Math.max(80, this.offsetX), this.guiTop + 4, 90,
|
||||
12);
|
||||
this.searchField.setEnableBackgroundDrawing(false);
|
||||
this.searchField.setMaxStringLength(25);
|
||||
this.searchField.setTextColor(0xFFFFFF);
|
||||
this.searchField.setSelectionColor(0xFF99FF99);
|
||||
this.searchField.setVisible(true);
|
||||
|
||||
int offset = this.guiTop;
|
||||
|
||||
this.sortByBox = this.addButton(new GuiSettingToggleButton<>(this.guiLeft - 18, offset, Settings.SORT_BY,
|
||||
getSortBy(), Platform::isSortOrderAvailable, this::toggleServerSetting));
|
||||
offset += 20;
|
||||
|
||||
this.sortDirBox = this.addButton(new GuiSettingToggleButton<>(this.guiLeft - 18, offset,
|
||||
Settings.SORT_DIRECTION, getSortDir(), this::toggleServerSetting));
|
||||
|
||||
for (int y = 0; y < this.rows; y++) {
|
||||
for (int x = 0; x < this.perRow; x++) {
|
||||
SlotFluidME slot = new SlotFluidME(
|
||||
new InternalFluidSlotME(this.repo, x + y * this.perRow, this.offsetX + x * 18, 18 + y * 18));
|
||||
this.getMeFluidSlots().add(slot);
|
||||
this.container.inventorySlots.add(slot);
|
||||
}
|
||||
}
|
||||
this.setScrollBar();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
|
||||
this.font.drawString(this.getGuiDisplayName("Fluid Terminal"), 8, 6, 4210752);
|
||||
this.font.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY, float partialTicks) {
|
||||
this.bindTexture(this.getBackground());
|
||||
final int x_width = 197;
|
||||
GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, x_width, 18, getBlitOffset());
|
||||
|
||||
for (int x = 0; x < 6; x++) {
|
||||
GuiUtils.drawTexturedModalRect(offsetX, offsetY + 18 + x * 18, 0, 18, x_width, 18, getBlitOffset());
|
||||
}
|
||||
|
||||
GuiUtils.drawTexturedModalRect(offsetX, offsetY + 16 + 6 * 18, 0, 106 - 18 - 18, x_width, 99 + 77,
|
||||
getBlitOffset());
|
||||
|
||||
if (this.searchField != null) {
|
||||
this.searchField.render(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
this.repo.setPower(this.container.isPowered());
|
||||
super.tick();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderHoveredToolTip(int mouseX, int mouseY) {
|
||||
final Slot slot = this.getSlot(mouseX, mouseY);
|
||||
|
||||
if (slot instanceof IMEFluidSlot && slot.isEnabled()) {
|
||||
final IMEFluidSlot fluidSlot = (IMEFluidSlot) slot;
|
||||
|
||||
if (fluidSlot.getAEFluidStack() != null && fluidSlot.shouldRenderAsFluid()) {
|
||||
final IAEFluidStack fluidStack = fluidSlot.getAEFluidStack();
|
||||
final String formattedAmount = NumberFormat.getNumberInstance(Locale.US)
|
||||
.format(fluidStack.getStackSize() / 1000.0) + " B";
|
||||
|
||||
final String modName = Platform.getModName(Platform.getModId(fluidStack));
|
||||
|
||||
final List<String> list = new ArrayList<>();
|
||||
|
||||
list.add(fluidStack.getFluidStack().getDisplayName().getFormattedText());
|
||||
list.add(formattedAmount);
|
||||
list.add(modName);
|
||||
|
||||
this.renderTooltip(list, mouseX, mouseY);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
super.renderHoveredToolTip(mouseX, mouseY);
|
||||
}
|
||||
|
||||
private <S extends Enum<S>> void toggleServerSetting(GuiSettingToggleButton<S> btn, boolean backwards) {
|
||||
S next = btn.getNextValue(backwards);
|
||||
NetworkHandler.instance().sendToServer(new PacketValueConfig(btn.getSetting().name(), next.name()));
|
||||
btn.set(next);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleMouseClick(Slot slot, int slotIdx, int mouseButton, ClickType clickType) {
|
||||
if (slot instanceof SlotFluidME) {
|
||||
final SlotFluidME meSlot = (SlotFluidME) slot;
|
||||
|
||||
if (clickType == ClickType.PICKUP) {
|
||||
// TODO: Allow more options
|
||||
if (mouseButton == 0 && meSlot.getHasStack()) {
|
||||
this.container.setTargetStack(meSlot.getAEFluidStack());
|
||||
AELog.debug("mouse0 GUI STACK SIZE %s", meSlot.getAEFluidStack().getStackSize());
|
||||
NetworkHandler.instance()
|
||||
.sendToServer(new PacketInventoryAction(InventoryAction.FILL_ITEM, slot.slotNumber, 0));
|
||||
} else {
|
||||
this.container.setTargetStack(meSlot.getAEFluidStack());
|
||||
if (meSlot.getAEFluidStack() != null) {
|
||||
AELog.debug("mouse1 GUI STACK SIZE %s", meSlot.getAEFluidStack().getStackSize());
|
||||
}
|
||||
NetworkHandler.instance()
|
||||
.sendToServer(new PacketInventoryAction(InventoryAction.EMPTY_ITEM, slot.slotNumber, 0));
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
super.handleMouseClick(slot, slotIdx, mouseButton, clickType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean charTyped(char character, int keyCode) {
|
||||
if (character == ' ' && this.searchField.getText().isEmpty()) {
|
||||
// Swallow spaces if the text field is still empty
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this.searchField.charTyped(character, keyCode)) {
|
||||
this.repo.setSearchString(this.searchField.getText());
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.charTyped(character, keyCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_) {
|
||||
InputMappings.Input input = InputMappings.getInputByCode(keyCode, scanCode);
|
||||
if (!this.checkHotbarKeys(input)) {
|
||||
if (this.searchField.keyPressed(keyCode, scanCode, p_keyPressed_3_)) {
|
||||
this.repo.setSearchString(this.searchField.getText());
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.keyPressed(keyCode, scanCode, p_keyPressed_3_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(final double xCoord, final double yCoord, final int btn) {
|
||||
if (this.searchField.mouseClicked(xCoord, yCoord, btn)) {
|
||||
if (btn == 1 && this.searchField.isMouseOver(xCoord, yCoord)) {
|
||||
this.searchField.setText("");
|
||||
this.repo.setSearchString("");
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.mouseClicked(xCoord, yCoord, btn);
|
||||
}
|
||||
|
||||
public void postUpdate(final List<IAEFluidStack> list) {
|
||||
for (final IAEFluidStack is : list) {
|
||||
this.repo.postUpdate(is);
|
||||
}
|
||||
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
}
|
||||
|
||||
private void setScrollBar() {
|
||||
this.getScrollBar().setTop(18).setLeft(175).setHeight(this.rows * 18 - 2);
|
||||
this.getScrollBar().setRange(0, (this.repo.size() + this.perRow - 1) / this.perRow - this.rows,
|
||||
Math.max(1, this.rows / 6));
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortOrder getSortBy() {
|
||||
return (SortOrder) this.configSrc.getSetting(Settings.SORT_BY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortDir getSortDir() {
|
||||
return (SortDir) this.configSrc.getSetting(Settings.SORT_DIRECTION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ViewItems getSortDisplay() {
|
||||
return (ViewItems) this.configSrc.getSetting(Settings.VIEW_MODE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting(IConfigManager manager, Settings settingName, Enum<?> newValue) {
|
||||
if (this.sortByBox != null) {
|
||||
this.sortByBox.set(getSortBy());
|
||||
}
|
||||
|
||||
if (this.sortDirBox != null) {
|
||||
this.sortDirBox.set(getSortDir());
|
||||
}
|
||||
|
||||
this.repo.updateView();
|
||||
}
|
||||
|
||||
protected List<SlotFluidME> getMeFluidSlots() {
|
||||
return this.meFluidSlots;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isPowered() {
|
||||
return this.repo.hasPower();
|
||||
}
|
||||
|
||||
protected String getBackground() {
|
||||
return "guis/terminal.png";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package appeng.fluids.client.gui.widgets;
|
||||
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
@@ -17,6 +16,7 @@ import net.minecraftforge.fluids.FluidAttributes;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.client.gui.widgets.GuiCustomSlot;
|
||||
@@ -24,92 +24,79 @@ import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketFluidSlot;
|
||||
import appeng.fluids.util.AEFluidStack;
|
||||
import appeng.fluids.util.IAEFluidTank;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
public class GuiFluidSlot extends GuiCustomSlot {
|
||||
private final IAEFluidTank fluids;
|
||||
private final int slot;
|
||||
|
||||
public class GuiFluidSlot extends GuiCustomSlot
|
||||
{
|
||||
private final IAEFluidTank fluids;
|
||||
private final int slot;
|
||||
public GuiFluidSlot(final IAEFluidTank fluids, final int slot, final int id, final int x, final int y) {
|
||||
super(id, x, y);
|
||||
this.fluids = fluids;
|
||||
this.slot = slot;
|
||||
}
|
||||
|
||||
public GuiFluidSlot( final IAEFluidTank fluids, final int slot, final int id, final int x, final int y )
|
||||
{
|
||||
super( id, x, y );
|
||||
this.fluids = fluids;
|
||||
this.slot = slot;
|
||||
}
|
||||
@Override
|
||||
public void drawContent(final Minecraft mc, final int mouseX, final int mouseY, final float partialTicks) {
|
||||
final IAEFluidStack fs = this.getFluidStack();
|
||||
if (fs != null) {
|
||||
RenderSystem.disableBlend();
|
||||
final Fluid fluid = fs.getFluid();
|
||||
final FluidAttributes attributes = fluid.getAttributes();
|
||||
mc.getTextureManager().bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE);
|
||||
final TextureAtlasSprite sprite = mc.getAtlasSpriteGetter(AtlasTexture.LOCATION_BLOCKS_TEXTURE)
|
||||
.apply(attributes.getStillTexture(fs.getFluidStack()));
|
||||
|
||||
@Override
|
||||
public void drawContent( final Minecraft mc, final int mouseX, final int mouseY, final float partialTicks )
|
||||
{
|
||||
final IAEFluidStack fs = this.getFluidStack();
|
||||
if( fs != null )
|
||||
{
|
||||
RenderSystem.disableBlend();
|
||||
final Fluid fluid = fs.getFluid();
|
||||
final FluidAttributes attributes = fluid.getAttributes();
|
||||
mc.getTextureManager().bindTexture( AtlasTexture.LOCATION_BLOCKS_TEXTURE );
|
||||
final TextureAtlasSprite sprite = mc.getAtlasSpriteGetter( AtlasTexture.LOCATION_BLOCKS_TEXTURE ).apply( attributes.getStillTexture(fs.getFluidStack()) );
|
||||
// Set color for dynamic fluids
|
||||
// Convert int color to RGB
|
||||
final float red = (attributes.getColor() >> 16 & 255) / 255.0F;
|
||||
final float green = (attributes.getColor() >> 8 & 255) / 255.0F;
|
||||
final float blue = (attributes.getColor() & 255) / 255.0F;
|
||||
RenderSystem.color3f(red, green, blue);
|
||||
|
||||
// Set color for dynamic fluids
|
||||
// Convert int color to RGB
|
||||
final float red = ( attributes.getColor() >> 16 & 255 ) / 255.0F;
|
||||
final float green = ( attributes.getColor() >> 8 & 255 ) / 255.0F;
|
||||
final float blue = ( attributes.getColor() & 255 ) / 255.0F;
|
||||
RenderSystem.color3f( red, green, blue );
|
||||
blit(xPos(), yPos(), this.getBlitOffset(), getWidth(), getHeight(), sprite);
|
||||
}
|
||||
}
|
||||
|
||||
blit(xPos(), yPos(), this.getBlitOffset(), getWidth(), getHeight(), sprite);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean canClick(final PlayerEntity player) {
|
||||
final ItemStack mouseStack = player.inventory.getItemStack();
|
||||
return mouseStack.isEmpty()
|
||||
|| mouseStack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY).isPresent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canClick( final PlayerEntity player )
|
||||
{
|
||||
final ItemStack mouseStack = player.inventory.getItemStack();
|
||||
return mouseStack.isEmpty() || mouseStack.getCapability( CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY ).isPresent();
|
||||
}
|
||||
@Override
|
||||
public void slotClicked(final ItemStack clickStack, int mouseButton) {
|
||||
if (clickStack.isEmpty() || mouseButton == 1) {
|
||||
this.setFluidStack(null);
|
||||
} else if (mouseButton == 0) {
|
||||
final LazyOptional<FluidStack> fluidOpt = FluidUtil.getFluidContained(clickStack);
|
||||
fluidOpt.ifPresent(fluid -> {
|
||||
this.setFluidStack(AEFluidStack.fromFluidStack(fluid));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void slotClicked( final ItemStack clickStack, int mouseButton )
|
||||
{
|
||||
if( clickStack.isEmpty() || mouseButton == 1 )
|
||||
{
|
||||
this.setFluidStack( null );
|
||||
}
|
||||
else if( mouseButton == 0 )
|
||||
{
|
||||
final LazyOptional<FluidStack> fluidOpt = FluidUtil.getFluidContained( clickStack );
|
||||
fluidOpt.ifPresent( fluid -> {
|
||||
this.setFluidStack( AEFluidStack.fromFluidStack( fluid ) );
|
||||
} );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public String getMessage() {
|
||||
final IAEFluidStack fluid = this.getFluidStack();
|
||||
if (fluid != null) {
|
||||
return I18n.format(fluid.getFluidStack().getTranslationKey());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage()
|
||||
{
|
||||
final IAEFluidStack fluid = this.getFluidStack();
|
||||
if( fluid != null )
|
||||
{
|
||||
return I18n.format( fluid.getFluidStack().getTranslationKey() );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
public IAEFluidStack getFluidStack() {
|
||||
return this.fluids.getFluidInSlot(this.slot);
|
||||
}
|
||||
|
||||
public IAEFluidStack getFluidStack()
|
||||
{
|
||||
return this.fluids.getFluidInSlot( this.slot );
|
||||
}
|
||||
|
||||
public void setFluidStack( final IAEFluidStack stack )
|
||||
{
|
||||
this.fluids.setFluidInSlot( this.slot, stack );
|
||||
NetworkHandler.instance().sendToServer( new PacketFluidSlot( Collections.singletonMap( this.getId(), this.getFluidStack() ) ) );
|
||||
}
|
||||
public void setFluidStack(final IAEFluidStack stack) {
|
||||
this.fluids.setFluidInSlot(this.slot, stack);
|
||||
NetworkHandler.instance()
|
||||
.sendToServer(new PacketFluidSlot(Collections.singletonMap(this.getId(), this.getFluidStack())));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,12 +18,8 @@
|
||||
|
||||
package appeng.fluids.client.gui.widgets;
|
||||
|
||||
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.client.gui.widgets.ITooltip;
|
||||
import appeng.fluids.util.IAEFluidTank;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.widget.Widget;
|
||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||
@@ -33,101 +29,96 @@ import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.fluids.FluidAttributes;
|
||||
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.client.gui.widgets.ITooltip;
|
||||
import appeng.fluids.util.IAEFluidTank;
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public class GuiFluidTank extends Widget implements ITooltip
|
||||
{
|
||||
private final IAEFluidTank tank;
|
||||
private final int slot;
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class GuiFluidTank extends Widget implements ITooltip {
|
||||
private final IAEFluidTank tank;
|
||||
private final int slot;
|
||||
|
||||
public GuiFluidTank(IAEFluidTank tank, int slot, int x, int y, int w, int h)
|
||||
{
|
||||
super( x, y, w, h, "" );
|
||||
this.tank = tank;
|
||||
this.slot = slot;
|
||||
}
|
||||
public GuiFluidTank(IAEFluidTank tank, int slot, int x, int y, int w, int h) {
|
||||
super(x, y, w, h, "");
|
||||
this.tank = tank;
|
||||
this.slot = slot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderButton(int mouseX, int mouseY, float partialTicks) {
|
||||
if( this.visible )
|
||||
{
|
||||
RenderSystem.disableBlend();
|
||||
@Override
|
||||
public void renderButton(int mouseX, int mouseY, float partialTicks) {
|
||||
if (this.visible) {
|
||||
RenderSystem.disableBlend();
|
||||
|
||||
fill( this.x, this.y, this.x + this.width, this.y + this.height, AEColor.GRAY.blackVariant | 0xFF000000 );
|
||||
fill(this.x, this.y, this.x + this.width, this.y + this.height, AEColor.GRAY.blackVariant | 0xFF000000);
|
||||
|
||||
final IAEFluidStack fluidStack = this.tank.getFluidInSlot( this.slot );
|
||||
if( fluidStack != null && fluidStack.getStackSize() > 0 )
|
||||
{
|
||||
Fluid fluid = fluidStack.getFluid();
|
||||
FluidAttributes attributes = fluid.getAttributes();
|
||||
final IAEFluidStack fluidStack = this.tank.getFluidInSlot(this.slot);
|
||||
if (fluidStack != null && fluidStack.getStackSize() > 0) {
|
||||
Fluid fluid = fluidStack.getFluid();
|
||||
FluidAttributes attributes = fluid.getAttributes();
|
||||
|
||||
float red = ( attributes.getColor() >> 16 & 255 ) / 255.0F;
|
||||
float green = ( attributes.getColor() >> 8 & 255 ) / 255.0F;
|
||||
float blue = ( attributes.getColor() & 255 ) / 255.0F;
|
||||
RenderSystem.color3f( red, green, blue );
|
||||
float red = (attributes.getColor() >> 16 & 255) / 255.0F;
|
||||
float green = (attributes.getColor() >> 8 & 255) / 255.0F;
|
||||
float blue = (attributes.getColor() & 255) / 255.0F;
|
||||
RenderSystem.color3f(red, green, blue);
|
||||
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
mc.getTextureManager().bindTexture( AtlasTexture.LOCATION_BLOCKS_TEXTURE );
|
||||
final TextureAtlasSprite sprite = mc.getAtlasSpriteGetter( AtlasTexture.LOCATION_BLOCKS_TEXTURE ).apply( attributes.getStillTexture(fluidStack.getFluidStack()) );
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
mc.getTextureManager().bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE);
|
||||
final TextureAtlasSprite sprite = mc.getAtlasSpriteGetter(AtlasTexture.LOCATION_BLOCKS_TEXTURE)
|
||||
.apply(attributes.getStillTexture(fluidStack.getFluidStack()));
|
||||
|
||||
final int scaledHeight = (int) ( this.height * ( (float) fluidStack.getStackSize() / this.tank.getTankCapacity(this.slot) ) );
|
||||
final int scaledHeight = (int) (this.height
|
||||
* ((float) fluidStack.getStackSize() / this.tank.getTankCapacity(this.slot)));
|
||||
|
||||
int iconHeightRemainder = scaledHeight % 16;
|
||||
if( iconHeightRemainder > 0 )
|
||||
{
|
||||
blit(this.x, this.y + this.height - iconHeightRemainder, getBlitOffset(), 16, iconHeightRemainder, sprite );
|
||||
}
|
||||
for( int i = 0; i < scaledHeight / 16; i++ )
|
||||
{
|
||||
blit( this.x, this.y + this.height - iconHeightRemainder - ( i + 1 ) * 16, getBlitOffset(), 16, 16, sprite );
|
||||
}
|
||||
}
|
||||
int iconHeightRemainder = scaledHeight % 16;
|
||||
if (iconHeightRemainder > 0) {
|
||||
blit(this.x, this.y + this.height - iconHeightRemainder, getBlitOffset(), 16, iconHeightRemainder,
|
||||
sprite);
|
||||
}
|
||||
for (int i = 0; i < scaledHeight / 16; i++) {
|
||||
blit(this.x, this.y + this.height - iconHeightRemainder - (i + 1) * 16, getBlitOffset(), 16, 16,
|
||||
sprite);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage()
|
||||
{
|
||||
final IAEFluidStack fluid = this.tank.getFluidInSlot( this.slot );
|
||||
if( fluid != null && fluid.getStackSize() > 0 )
|
||||
{
|
||||
String desc = fluid.getFluid().getAttributes().getDisplayName( fluid.getFluidStack() ).getFormattedText();
|
||||
String amountToText = fluid.getStackSize() + "mB";
|
||||
@Override
|
||||
public String getMessage() {
|
||||
final IAEFluidStack fluid = this.tank.getFluidInSlot(this.slot);
|
||||
if (fluid != null && fluid.getStackSize() > 0) {
|
||||
String desc = fluid.getFluid().getAttributes().getDisplayName(fluid.getFluidStack()).getFormattedText();
|
||||
String amountToText = fluid.getStackSize() + "mB";
|
||||
|
||||
return desc + "\n" + amountToText;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return desc + "\n" + amountToText;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int xPos()
|
||||
{
|
||||
return this.x - 2;
|
||||
}
|
||||
@Override
|
||||
public int xPos() {
|
||||
return this.x - 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int yPos()
|
||||
{
|
||||
return this.y - 2;
|
||||
}
|
||||
@Override
|
||||
public int yPos() {
|
||||
return this.y - 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth()
|
||||
{
|
||||
return this.width + 4;
|
||||
}
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return this.width + 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight()
|
||||
{
|
||||
return this.height + 4;
|
||||
}
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return this.height + 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,63 +1,54 @@
|
||||
|
||||
package appeng.fluids.client.gui.widgets;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.container.slot.IOptionalSlotHost;
|
||||
import appeng.fluids.util.IAEFluidTank;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
public class GuiOptionalFluidSlot extends GuiFluidSlot {
|
||||
private final IOptionalSlotHost containerBus;
|
||||
private final int groupNum;
|
||||
private final int srcX;
|
||||
private final int srcY;
|
||||
|
||||
public class GuiOptionalFluidSlot extends GuiFluidSlot
|
||||
{
|
||||
private final IOptionalSlotHost containerBus;
|
||||
private final int groupNum;
|
||||
private final int srcX;
|
||||
private final int srcY;
|
||||
public GuiOptionalFluidSlot(IAEFluidTank fluids, final IOptionalSlotHost containerBus, int slot, int id,
|
||||
int groupNum, int x, int y, int xoffs, int yoffs) {
|
||||
super(fluids, slot, id, x + xoffs * 18, y + yoffs * 18);
|
||||
this.containerBus = containerBus;
|
||||
this.groupNum = groupNum;
|
||||
this.srcX = x;
|
||||
this.srcY = y;
|
||||
}
|
||||
|
||||
public GuiOptionalFluidSlot( IAEFluidTank fluids, final IOptionalSlotHost containerBus, int slot, int id, int groupNum, int x, int y, int xoffs, int yoffs )
|
||||
{
|
||||
super( fluids, slot, id, x + xoffs * 18, y + yoffs * 18 );
|
||||
this.containerBus = containerBus;
|
||||
this.groupNum = groupNum;
|
||||
this.srcX = x;
|
||||
this.srcY = y;
|
||||
}
|
||||
@Override
|
||||
public boolean isSlotEnabled() {
|
||||
if (this.containerBus == null) {
|
||||
return false;
|
||||
}
|
||||
return this.containerBus.isSlotEnabled(this.groupNum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSlotEnabled()
|
||||
{
|
||||
if( this.containerBus == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return this.containerBus.isSlotEnabled( this.groupNum );
|
||||
}
|
||||
@Override
|
||||
public IAEFluidStack getFluidStack() {
|
||||
if (!this.isSlotEnabled() && super.getFluidStack() != null) {
|
||||
this.setFluidStack(null);
|
||||
}
|
||||
return super.getFluidStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEFluidStack getFluidStack()
|
||||
{
|
||||
if( !this.isSlotEnabled() && super.getFluidStack() != null )
|
||||
{
|
||||
this.setFluidStack( null );
|
||||
}
|
||||
return super.getFluidStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground( int guileft, int guitop, int currentZIndex )
|
||||
{
|
||||
RenderSystem.enableBlend();
|
||||
if( this.isSlotEnabled() )
|
||||
{
|
||||
RenderSystem.color4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderSystem.color4f( 1.0F, 1.0F, 1.0F, 0.4F );
|
||||
}
|
||||
GuiUtils.drawTexturedModalRect( guileft + this.xPos() - 1, guitop + this.yPos() - 1, this.srcX - 1, this.srcY - 1, this.getWidth() + 2,
|
||||
this.getHeight() + 2, currentZIndex );
|
||||
}
|
||||
@Override
|
||||
public void drawBackground(int guileft, int guitop, int currentZIndex) {
|
||||
RenderSystem.enableBlend();
|
||||
if (this.isSlotEnabled()) {
|
||||
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
} else {
|
||||
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 0.4F);
|
||||
}
|
||||
GuiUtils.drawTexturedModalRect(guileft + this.xPos() - 1, guitop + this.yPos() - 1, this.srcX - 1,
|
||||
this.srcY - 1, this.getWidth() + 2, this.getHeight() + 2, currentZIndex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,22 +18,21 @@
|
||||
|
||||
package appeng.fluids.client.render;
|
||||
|
||||
|
||||
import java.math.RoundingMode;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
|
||||
import appeng.client.render.StackSizeRenderer;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.client.render.StackSizeRenderer;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.util.ISlimReadableNumberConverter;
|
||||
import appeng.util.IWideReadableNumberConverter;
|
||||
import appeng.util.ReadableNumberConverter;
|
||||
|
||||
|
||||
/**
|
||||
* @author AlgorithmX2
|
||||
* @author thatsIch
|
||||
@@ -41,70 +40,59 @@ import appeng.util.ReadableNumberConverter;
|
||||
* @version rv6
|
||||
* @since rv6
|
||||
*/
|
||||
public class FluidStackSizeRenderer
|
||||
{
|
||||
public class FluidStackSizeRenderer {
|
||||
|
||||
private static final String[] NUMBER_FORMATS = new String[] { "#.000", "#.00", "#.0", "#" };
|
||||
private static final String[] NUMBER_FORMATS = new String[] { "#.000", "#.00", "#.0", "#" };
|
||||
|
||||
private static final ISlimReadableNumberConverter SLIM_CONVERTER = ReadableNumberConverter.INSTANCE;
|
||||
private static final IWideReadableNumberConverter WIDE_CONVERTER = ReadableNumberConverter.INSTANCE;
|
||||
private static final ISlimReadableNumberConverter SLIM_CONVERTER = ReadableNumberConverter.INSTANCE;
|
||||
private static final IWideReadableNumberConverter WIDE_CONVERTER = ReadableNumberConverter.INSTANCE;
|
||||
|
||||
public void renderStackSize( FontRenderer fontRenderer, IAEFluidStack aeStack, int xPos, int yPos )
|
||||
{
|
||||
if (aeStack != null && aeStack.getStackSize() > 0) {
|
||||
final String stackSize = this.getToBeRenderedStackSize(aeStack.getStackSize());
|
||||
StackSizeRenderer.renderSizeLabel(fontRenderer, xPos, yPos, stackSize);
|
||||
}
|
||||
}
|
||||
public void renderStackSize(FontRenderer fontRenderer, IAEFluidStack aeStack, int xPos, int yPos) {
|
||||
if (aeStack != null && aeStack.getStackSize() > 0) {
|
||||
final String stackSize = this.getToBeRenderedStackSize(aeStack.getStackSize());
|
||||
StackSizeRenderer.renderSizeLabel(fontRenderer, xPos, yPos, stackSize);
|
||||
}
|
||||
}
|
||||
|
||||
private String getToBeRenderedStackSize( final long originalSize )
|
||||
{
|
||||
// Handle any value below 100 (large font) or 1000 (small font) Buckets with a custom formatter,
|
||||
// otherwise pass it to the normal number converter
|
||||
if( originalSize < 1000 * 100 && AEConfig.instance().useTerminalUseLargeFont() )
|
||||
{
|
||||
return this.getSlimRenderedStacksize( originalSize );
|
||||
}
|
||||
else if( originalSize < 1000 * 1000 && !AEConfig.instance().useTerminalUseLargeFont() )
|
||||
{
|
||||
return this.getWideRenderedStacksize( originalSize );
|
||||
}
|
||||
private String getToBeRenderedStackSize(final long originalSize) {
|
||||
// Handle any value below 100 (large font) or 1000 (small font) Buckets with a
|
||||
// custom formatter,
|
||||
// otherwise pass it to the normal number converter
|
||||
if (originalSize < 1000 * 100 && AEConfig.instance().useTerminalUseLargeFont()) {
|
||||
return this.getSlimRenderedStacksize(originalSize);
|
||||
} else if (originalSize < 1000 * 1000 && !AEConfig.instance().useTerminalUseLargeFont()) {
|
||||
return this.getWideRenderedStacksize(originalSize);
|
||||
}
|
||||
|
||||
if( AEConfig.instance().useTerminalUseLargeFont() )
|
||||
{
|
||||
return SLIM_CONVERTER.toSlimReadableForm( originalSize / 1000 );
|
||||
}
|
||||
else
|
||||
{
|
||||
return WIDE_CONVERTER.toWideReadableForm( originalSize / 1000 );
|
||||
}
|
||||
}
|
||||
if (AEConfig.instance().useTerminalUseLargeFont()) {
|
||||
return SLIM_CONVERTER.toSlimReadableForm(originalSize / 1000);
|
||||
} else {
|
||||
return WIDE_CONVERTER.toWideReadableForm(originalSize / 1000);
|
||||
}
|
||||
}
|
||||
|
||||
private String getSlimRenderedStacksize( final long originalSize )
|
||||
{
|
||||
final int log = 1 + (int) Math.floor( Math.log10( originalSize ) ) / 2;
|
||||
private String getSlimRenderedStacksize(final long originalSize) {
|
||||
final int log = 1 + (int) Math.floor(Math.log10(originalSize)) / 2;
|
||||
|
||||
return this.getRenderedFluidStackSize( originalSize, log );
|
||||
}
|
||||
return this.getRenderedFluidStackSize(originalSize, log);
|
||||
}
|
||||
|
||||
private String getWideRenderedStacksize( final long originalSize )
|
||||
{
|
||||
final int log = (int) Math.floor( Math.log10( originalSize ) ) / 2;
|
||||
private String getWideRenderedStacksize(final long originalSize) {
|
||||
final int log = (int) Math.floor(Math.log10(originalSize)) / 2;
|
||||
|
||||
return this.getRenderedFluidStackSize( originalSize, log );
|
||||
}
|
||||
return this.getRenderedFluidStackSize(originalSize, log);
|
||||
}
|
||||
|
||||
private String getRenderedFluidStackSize( final long originalSize, final int log )
|
||||
{
|
||||
final int index = Math.max( 0, Math.min( 3, log ) );
|
||||
private String getRenderedFluidStackSize(final long originalSize, final int log) {
|
||||
final int index = Math.max(0, Math.min(3, log));
|
||||
|
||||
final DecimalFormatSymbols symbols = new DecimalFormatSymbols();
|
||||
symbols.setDecimalSeparator( '.' );
|
||||
final DecimalFormat format = new DecimalFormat( NUMBER_FORMATS[index] );
|
||||
format.setDecimalFormatSymbols( symbols );
|
||||
format.setRoundingMode( RoundingMode.DOWN );
|
||||
final DecimalFormatSymbols symbols = new DecimalFormatSymbols();
|
||||
symbols.setDecimalSeparator('.');
|
||||
final DecimalFormat format = new DecimalFormat(NUMBER_FORMATS[index]);
|
||||
format.setDecimalFormatSymbols(symbols);
|
||||
format.setRoundingMode(RoundingMode.DOWN);
|
||||
|
||||
return format.format( originalSize / 1000d );
|
||||
}
|
||||
return format.format(originalSize / 1000d);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user