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
@@ -11,33 +11,29 @@ 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.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiInductionMatrix extends GuiMekanism {
|
||||
public class GuiInductionMatrix extends GuiMekanismTile<TileEntityInductionCasing> {
|
||||
|
||||
public TileEntityInductionCasing tileEntity;
|
||||
|
||||
public GuiInductionMatrix(InventoryPlayer inventory, TileEntityInductionCasing tentity) {
|
||||
super(tentity, new ContainerInductionMatrix(inventory, tentity));
|
||||
tileEntity = tentity;
|
||||
guiElements.add(new GuiMatrixTab(this, tileEntity, MatrixTab.STAT, 6,
|
||||
MekanismUtils.getResource(ResourceType.GUI, "GuiInductionMatrix.png")));
|
||||
guiElements.add(new GuiEnergyInfo(() -> Arrays.asList(
|
||||
public GuiInductionMatrix(InventoryPlayer inventory, TileEntityInductionCasing tile) {
|
||||
super(tile, new ContainerInductionMatrix(inventory, tile));
|
||||
ResourceLocation resource = getGuiLocation();
|
||||
addGuiElement(new GuiMatrixTab(this, tileEntity, MatrixTab.STAT, 6, resource));
|
||||
addGuiElement(new GuiEnergyInfo(() -> Arrays.asList(
|
||||
LangUtils.localize("gui.storing") + ": " + MekanismUtils
|
||||
.getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()),
|
||||
LangUtils.localize("gui.input") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.structure.lastInput)
|
||||
+ "/t", LangUtils.localize("gui.output") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.structure.lastOutput)
|
||||
+ "/t"), this, MekanismUtils.getResource(ResourceType.GUI, "GuiInductionMatrix.png")));
|
||||
+ "/t",
|
||||
LangUtils.localize("gui.output") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.structure.lastOutput)
|
||||
+ "/t"), this, resource));
|
||||
}
|
||||
|
||||
@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);
|
||||
@@ -48,31 +44,34 @@ public class GuiInductionMatrix extends GuiMekanism {
|
||||
fontRenderer.drawString(LangUtils.localize("gui.output") + ":", 53, 44, 0x00CD00);
|
||||
fontRenderer
|
||||
.drawString(MekanismUtils.getEnergyDisplay(tileEntity.structure.lastOutput) + "/t", 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(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), 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, "GuiInductionMatrix.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.getScaledEnergyLevel(58) > 0) {
|
||||
displayGauge(7, 14, tileEntity.getScaledEnergyLevel(58), 0);
|
||||
displayGauge(23, 14, tileEntity.getScaledEnergyLevel(58), 1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ResourceLocation getGuiLocation() {
|
||||
return MekanismUtils.getResource(ResourceType.GUI, "GuiInductionMatrix.png");
|
||||
}
|
||||
|
||||
public void displayGauge(int xPos, int yPos, int scale, int side /*0-left, 1-right*/) {
|
||||
int guiWidth = (width - xSize) / 2;
|
||||
int guiHeight = (height - ySize) / 2;
|
||||
@@ -100,7 +99,7 @@ public class GuiInductionMatrix extends GuiMekanism {
|
||||
}
|
||||
}
|
||||
|
||||
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiInductionMatrix.png"));
|
||||
mc.renderEngine.bindTexture(getGuiLocation());
|
||||
drawTexturedModalRect(guiWidth + xPos, guiHeight + yPos, 176, side == 0 ? 0 : 54, 16, 54);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user