Batbox gui overhaul
This commit is contained in:
parent
53a3869092
commit
d385e6eaf4
7 changed files with 74 additions and 85 deletions
|
@ -76,6 +76,10 @@ public class GuiBase extends GuiContainer {
|
|||
drawString(string, (xSize / 2 - mc.fontRendererObj.getStringWidth(string) / 2), y, colour);
|
||||
}
|
||||
|
||||
protected void drawCentredString(String string, int y, int colour, int modifier) {
|
||||
drawString(string, (xSize / 2 - (mc.fontRendererObj.getStringWidth(string)) / 2) + modifier, y, colour);
|
||||
}
|
||||
|
||||
protected void drawString(String string, int x, int y, int colour) {
|
||||
mc.fontRendererObj.drawString(string, x, y, colour);
|
||||
GlStateManager.color(1, 1, 1, 1);
|
||||
|
|
|
@ -1,27 +1,19 @@
|
|||
package techreborn.client.gui;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
|
||||
import reborncore.common.powerSystem.PowerSystem;
|
||||
|
||||
import techreborn.client.container.builder.ContainerBuilder;
|
||||
import techreborn.client.gui.widget.GuiButtonPowerBar;
|
||||
import techreborn.tiles.storage.TileBatBox;
|
||||
|
||||
public class GuiBatbox extends GuiContainer {
|
||||
public class GuiBatbox extends GuiBase {
|
||||
|
||||
public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/batbox.png");
|
||||
TileBatBox tile;
|
||||
|
||||
TileBatBox generator;
|
||||
|
||||
public GuiBatbox(final EntityPlayer player, final TileBatBox generator) {
|
||||
super(new ContainerBuilder().player(player.inventory).inventory(8, 84).hotbar(8, 142).addInventory()
|
||||
.tile(generator).energySlot(0, 80, 17).energySlot(1, 80, 53).syncEnergyValue().addInventory().create());
|
||||
this.xSize = 176;
|
||||
this.ySize = 167;
|
||||
this.generator = generator;
|
||||
public GuiBatbox(final EntityPlayer player, final TileBatBox tile) {
|
||||
super(player, tile, new ContainerBuilder().player(player.inventory).inventory().hotbar().addInventory().tile(tile).energySlot(0, 62, 45).energySlot(1, 98, 45).syncEnergyValue().addInventory().create());
|
||||
this.tile = tile;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -32,38 +24,20 @@ public class GuiBatbox extends GuiContainer {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(final float p_146976_1_, final int p_146976_2_, final int p_146976_3_) {
|
||||
this.mc.getTextureManager().bindTexture(GuiBatbox.texture);
|
||||
final int k = (this.width - this.xSize) / 2;
|
||||
final int l = (this.height - this.ySize) / 2;
|
||||
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
|
||||
protected void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) {
|
||||
super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY);
|
||||
|
||||
int j = 0;
|
||||
|
||||
j = this.generator.getEnergyScaled(24);
|
||||
if (j > 0) {
|
||||
this.drawTexturedModalRect(k + 109, l + 21 + 12, 176, 0, j + 1, 16);
|
||||
}
|
||||
//
|
||||
// if (containerGenerator.burnTime != 0)
|
||||
// {
|
||||
// j = containerGenerator.getScaledBurnTime(13);
|
||||
// this.drawTexturedModalRect(k + 80, l + 38 + 12 - j, 176, 30 - j, 14,
|
||||
// j + 1);
|
||||
// }
|
||||
this.buttonList.clear();
|
||||
drawSlotBackground(62, 45);
|
||||
drawSlotBackground(98, 45);
|
||||
this.buttonList.add(new GuiButtonPowerBar(0, guiLeft + 82, guiTop + 29));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) {
|
||||
final String name = I18n.translateToLocal("tile.techreborn.batbox.name");
|
||||
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6,
|
||||
4210752);
|
||||
|
||||
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), 8,
|
||||
this.ySize - 96 + 2, 4210752);
|
||||
this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(this.generator.getMaxPower()), 25, this.ySize - 140,
|
||||
4210752);
|
||||
this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(this.generator.getEnergy()), 25,
|
||||
this.ySize - 150, 4210752);
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
builder.drawMultiEnergyBar(this, 81, 28, (int) tile.getEnergy(), (int) tile.getMaxPower(), mouseX - guiLeft, mouseY - guiTop);
|
||||
GlStateManager.scale(0.6, 0.6, 5);
|
||||
drawCentredString(PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) (tile.getEnergy())) + "/" + PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) (tile.getMaxPower())) + " " + PowerSystem.getDisplayPower().abbreviation, 35, 0, 58);
|
||||
GlStateManager.scale(1, 1, 1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,56 +1,34 @@
|
|||
package techreborn.client.gui;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
import reborncore.common.util.ItemUtils;
|
||||
|
||||
import techreborn.client.container.builder.ContainerBuilder;
|
||||
import techreborn.tiles.TileQuantumChest;
|
||||
|
||||
public class GuiQuantumChest extends GuiContainer {
|
||||
|
||||
private static final ResourceLocation texture = new ResourceLocation("techreborn",
|
||||
"textures/gui/thermal_generator.png");
|
||||
public class GuiQuantumChest extends GuiBase {
|
||||
|
||||
TileQuantumChest tile;
|
||||
|
||||
public GuiQuantumChest(final EntityPlayer player, final TileQuantumChest tile) {
|
||||
super(new ContainerBuilder().player(player.inventory).inventory(8, 64).hotbar(8, 152).addInventory().tile(tile)
|
||||
.slot(0, 80, 17).outputSlot(1, 80, 53).fakeSlot(2, 59, 42).addInventory().create());
|
||||
this.xSize = 176;
|
||||
this.ySize = 167;
|
||||
super(player, tile, new ContainerBuilder().player(player.inventory).inventory().hotbar().addInventory().tile(tile).slot(0, 80, 24).outputSlot(1, 80, 64).addInventory().create());
|
||||
this.tile = tile;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(texture);
|
||||
int k = (this.width - this.xSize) / 2;
|
||||
int l = (this.height - this.ySize) / 2;
|
||||
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
|
||||
protected void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) {
|
||||
super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY);
|
||||
|
||||
drawSlotBackground(80, 24);
|
||||
drawSlotBackground(80, 64);
|
||||
}
|
||||
|
||||
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) {
|
||||
String name = I18n.translateToLocal("tile.techreborn.quantumChest.name");
|
||||
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6,
|
||||
4210752);
|
||||
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), 8,
|
||||
this.ySize - 96 + 2, 4210752);
|
||||
this.fontRendererObj.drawString("Amount", 10, 20, 16448255);
|
||||
|
||||
int count = 0;
|
||||
if (tile.storedItem != ItemStack.EMPTY || !tile.getStackInSlot(1).isEmpty()) {
|
||||
|
||||
count = tile.storedItem.getCount();
|
||||
if (tile.getStackInSlot(1) != ItemStack.EMPTY && (tile.storedItem.isEmpty()
|
||||
|| ItemUtils.isItemEqual(tile.getStackInSlot(1), tile.getStackInSlot(2), true, true)))
|
||||
count += tile.getStackInSlot(1).getCount();
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
if (tile.storedItem != ItemStack.EMPTY && tile.getStackInSlot(1) != null) {
|
||||
builder.drawBigBlueBar(this, 31, 43, tile.storedItem.getCount() + tile.getStackInSlot(1).getCount(), tile.maxCapacity, mouseX - guiLeft, mouseY - guiTop, "Stored");
|
||||
}
|
||||
if (tile.storedItem == ItemStack.EMPTY && tile.getStackInSlot(1) != null) {
|
||||
builder.drawBigBlueBar(this, 31, 43, tile.getStackInSlot(1).getCount(), tile.maxCapacity, mouseX - guiLeft, mouseY - guiTop, "Stored");
|
||||
}
|
||||
this.fontRendererObj.drawString(count + "", 10, 30, 16448255);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,9 +44,7 @@ public class TRBuilder extends GuiBuilder {
|
|||
List<String> list = new ArrayList<>();
|
||||
TextFormatting powerColour = TextFormatting.GOLD;
|
||||
list.add(powerColour + PowerSystem.getLocaliszedPowerFormattedNoSuffix(energyStored) + "/" + PowerSystem.getLocaliszedPowerFormattedNoSuffix(maxEnergyStored) + " " + PowerSystem.getDisplayPower().abbreviation);
|
||||
if (gui.isShiftKeyDown()) {
|
||||
list.add(getPercentageColour(percentage) + "" + percentage + "%" + TextFormatting.GRAY + " Charged");
|
||||
}
|
||||
list.add(getPercentageColour(percentage) + "" + percentage + "%" + TextFormatting.GRAY + " Charged");
|
||||
net.minecraftforge.fml.client.config.GuiUtils.drawHoveringText(list, mouseX, mouseY, gui.width, gui.height, -1, gui.mc.fontRendererObj);
|
||||
GlStateManager.disableLighting();
|
||||
GlStateManager.color(1, 1, 1, 1);
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
package techreborn.client.gui.widget;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import reborncore.common.powerSystem.PowerSystem;
|
||||
|
||||
/**
|
||||
* Created by Prospector
|
||||
*/
|
||||
public class GuiButtonPowerBar extends GuiButton {
|
||||
public GuiButtonPowerBar(int buttonId, int x, int y) {
|
||||
super(buttonId, x, y, 12, 48, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mousePressed(Minecraft mc, int mouseX, int mouseY) {
|
||||
if (this.enabled && this.visible && mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height) {
|
||||
PowerSystem.bumpPowerConfig();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButtonForegroundLayer(int mouseX, int mouseY) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft mc, int mouseX, int mouseY) {
|
||||
|
||||
}
|
||||
}
|
|
@ -33,6 +33,8 @@ public class ProbeProvider implements IProbeInfoProvider {
|
|||
|
||||
@Override
|
||||
public void addProbeInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data) {
|
||||
euStyle = new ProgressStyle().backgroundColor(0xFF8B8B8B).borderColor(0xFF373737).alternateFilledColor(PowerSystem.getDisplayPower().altColour).filledColor(PowerSystem.getDisplayPower().colour);
|
||||
euStyle.suffix(" " + PowerSystem.getDisplayPower().abbreviation);
|
||||
TileEntity tile = world.getTileEntity(data.getPos());
|
||||
if (tile instanceof IListInfoProvider) {
|
||||
List<String> strs = new ArrayList<>();
|
||||
|
|
|
@ -3,6 +3,6 @@ package techreborn.tiles;
|
|||
public class TileDigitalChest extends TileTechStorageBase {
|
||||
|
||||
public TileDigitalChest() {
|
||||
super("TileDigitalChest", Short.MAX_VALUE);
|
||||
super("TileDigitalChest", 32768);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue