mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-26 14:52:58 +00:00
Gui cleanup (#74)
* Update dependencies for dev environment to have latest versions * Fix depreated method usage for JEI * Add Deprecated annotation to methods overriding a deprecated method * Fix various Deprecated method calls * Slightly clean up gui code based on IntelliJ inspections * Remove some unused variables/calculations from the gui code * Remove some unused variables/calculations from the generator gui code * Create a bit of hierarchy for Gui's that keep track of TileEntities * Cleanup Gui Element having majority of variables as public * Cleanup some duplicate math * Store tile entity type in a less duplicated manner * Cleanup Gui ResourceLocation handling. Makes it easier to read the code * Switch adding to a method * Switch remaining GUI variables to private/protected * Partially cleanup Gui Filter code * Cleanup some of the Chemical Gui Code * Fix missing a few files in last commit * Improve handling of Tile Entities in GUIs
This commit is contained in:
1 parent
56831edb3e
commit
cd5fe2040b
151 files changed
+3057
-4549
No files matched your search
@@ -10,28 +10,22 @@ import mekanism.common.util.LangUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.MekanismUtils.ResourceType;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiDynamicTank extends GuiMekanism {
|
||||
public class GuiDynamicTank extends GuiMekanismTile<TileEntityDynamicTank> {
|
||||
|
||||
public TileEntityDynamicTank tileEntity;
|
||||
|
||||
public GuiDynamicTank(InventoryPlayer inventory, TileEntityDynamicTank tentity) {
|
||||
super(tentity, new ContainerDynamicTank(inventory, tentity));
|
||||
tileEntity = tentity;
|
||||
guiElements.add(new GuiContainerEditMode(this, tileEntity,
|
||||
MekanismUtils.getResource(ResourceType.GUI, "GuiDynamicTank.png")));
|
||||
public GuiDynamicTank(InventoryPlayer inventory, TileEntityDynamicTank tile) {
|
||||
super(tile, new ContainerDynamicTank(inventory, tile));
|
||||
addGuiElement(new GuiContainerEditMode(this, tileEntity, getGuiLocation()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
int xAxis = (mouseX - (width - xSize) / 2);
|
||||
int yAxis = (mouseY - (height - ySize) / 2);
|
||||
|
||||
fontRenderer
|
||||
.drawString(tileEntity.getName(), (xSize / 2) - (fontRenderer.getStringWidth(tileEntity.getName()) / 2),
|
||||
6, 0x404040);
|
||||
@@ -42,37 +36,39 @@ public class GuiDynamicTank extends GuiMekanism {
|
||||
renderScaledText(
|
||||
tileEntity.structure.fluidStored != null ? LangUtils.localizeFluidStack(tileEntity.structure.fluidStored)
|
||||
+ ":" : LangUtils.localize("gui.noFluid"), 53, 44, 0x00CD00, 74);
|
||||
|
||||
if (tileEntity.structure.fluidStored != null) {
|
||||
fontRenderer.drawString(tileEntity.structure.fluidStored.amount + "mB", 53, 53, 0x00CD00);
|
||||
}
|
||||
|
||||
int xAxis = (mouseX - (width - xSize) / 2);
|
||||
int yAxis = (mouseY - (height - ySize) / 2);
|
||||
if (xAxis >= 7 && xAxis <= 39 && yAxis >= 14 && yAxis <= 72) {
|
||||
drawHoveringText(tileEntity.structure.fluidStored != null ?
|
||||
LangUtils.localizeFluidStack(tileEntity.structure.fluidStored) + ": "
|
||||
+ tileEntity.structure.fluidStored.amount + "mB" : LangUtils.localize("gui.empty"), xAxis,
|
||||
yAxis);
|
||||
}
|
||||
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) {
|
||||
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
|
||||
|
||||
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiDynamicTank.png"));
|
||||
mc.renderEngine.bindTexture(getGuiLocation());
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
int guiWidth = (width - xSize) / 2;
|
||||
int guiHeight = (height - ySize) / 2;
|
||||
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
|
||||
|
||||
if (tileEntity.getScaledFluidLevel(58) > 0) {
|
||||
displayGauge(7, 14, tileEntity.getScaledFluidLevel(58), tileEntity.structure.fluidStored, 0);
|
||||
displayGauge(23, 14, tileEntity.getScaledFluidLevel(58), tileEntity.structure.fluidStored, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ResourceLocation getGuiLocation() {
|
||||
return MekanismUtils.getResource(ResourceType.GUI, "GuiDynamicTank.png");
|
||||
}
|
||||
|
||||
public void displayGauge(int xPos, int yPos, int scale, FluidStack fluid, int side /*0-left, 1-right*/) {
|
||||
if (fluid == null) {
|
||||
return;
|
||||
@@ -104,7 +100,7 @@ public class GuiDynamicTank extends GuiMekanism {
|
||||
}
|
||||
}
|
||||
|
||||
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiDynamicTank.png"));
|
||||
mc.renderEngine.bindTexture(getGuiLocation());
|
||||
drawTexturedModalRect(guiWidth + xPos, guiHeight + yPos, 176, side == 0 ? 0 : 54, 16, 54);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user