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
@@ -19,43 +19,38 @@ import mekanism.common.tile.prefab.TileEntityElectricMachine;
|
||||
import mekanism.common.util.LangUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
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 GuiElectricMachine extends GuiMekanism {
|
||||
public class GuiElectricMachine extends GuiMekanismTile<TileEntityElectricMachine> {
|
||||
|
||||
public TileEntityElectricMachine tileEntity;
|
||||
|
||||
public GuiElectricMachine(InventoryPlayer inventory, TileEntityElectricMachine tentity) {
|
||||
super(tentity, new ContainerElectricMachine(inventory, tentity));
|
||||
tileEntity = tentity;
|
||||
|
||||
guiElements.add(new GuiRedstoneControl(this, tileEntity, tileEntity.guiLocation));
|
||||
guiElements.add(new GuiUpgradeTab(this, tileEntity, tileEntity.guiLocation));
|
||||
guiElements.add(new GuiSecurityTab(this, tileEntity, tileEntity.guiLocation));
|
||||
guiElements.add(new GuiSideConfigurationTab(this, tileEntity, tileEntity.guiLocation));
|
||||
guiElements.add(new GuiTransporterConfigTab(this, 34, tileEntity, tileEntity.guiLocation));
|
||||
guiElements.add(new GuiPowerBar(this, tileEntity, tileEntity.guiLocation, 164, 15));
|
||||
guiElements.add(new GuiEnergyInfo(() ->
|
||||
{
|
||||
public GuiElectricMachine(InventoryPlayer inventory, TileEntityElectricMachine tile) {
|
||||
super(tile, new ContainerElectricMachine(inventory, tile));
|
||||
ResourceLocation resource = tileEntity.guiLocation;
|
||||
addGuiElement(new GuiRedstoneControl(this, tileEntity, resource));
|
||||
addGuiElement(new GuiUpgradeTab(this, tileEntity, resource));
|
||||
addGuiElement(new GuiSecurityTab(this, tileEntity, resource));
|
||||
addGuiElement(new GuiSideConfigurationTab(this, tileEntity, resource));
|
||||
addGuiElement(new GuiTransporterConfigTab(this, 34, tileEntity, resource));
|
||||
addGuiElement(new GuiPowerBar(this, tileEntity, resource, 164, 15));
|
||||
addGuiElement(new GuiEnergyInfo(() -> {
|
||||
String multiplier = MekanismUtils.getEnergyDisplay(tileEntity.energyPerTick);
|
||||
return Arrays.asList(LangUtils.localize("gui.using") + ": " + multiplier + "/t",
|
||||
LangUtils.localize("gui.needed") + ": " + MekanismUtils
|
||||
.getEnergyDisplay(tileEntity.getMaxEnergy() - tileEntity.getEnergy()));
|
||||
}, this, tileEntity.guiLocation));
|
||||
|
||||
guiElements.add(new GuiSlot(SlotType.INPUT, this, tileEntity.guiLocation, 55, 16));
|
||||
guiElements.add(new GuiSlot(SlotType.POWER, this, tileEntity.guiLocation, 55, 52).with(SlotOverlay.POWER));
|
||||
guiElements.add(new GuiSlot(SlotType.OUTPUT_LARGE, this, tileEntity.guiLocation, 111, 30));
|
||||
|
||||
guiElements.add(new GuiProgress(new IProgressInfoHandler() {
|
||||
}, this, resource));
|
||||
addGuiElement(new GuiSlot(SlotType.INPUT, this, resource, 55, 16));
|
||||
addGuiElement(new GuiSlot(SlotType.POWER, this, resource, 55, 52).with(SlotOverlay.POWER));
|
||||
addGuiElement(new GuiSlot(SlotType.OUTPUT_LARGE, this, resource, 111, 30));
|
||||
addGuiElement(new GuiProgress(new IProgressInfoHandler() {
|
||||
@Override
|
||||
public double getProgress() {
|
||||
return tileEntity.getScaledProgress();
|
||||
}
|
||||
}, getProgressType(), this, tileEntity.guiLocation, 77, 37));
|
||||
}, getProgressType(), this, resource, 77, 37));
|
||||
}
|
||||
|
||||
public ProgressBar getProgressType() {
|
||||
@@ -68,18 +63,21 @@ public class GuiElectricMachine extends GuiMekanism {
|
||||
.drawString(tileEntity.getName(), (xSize / 2) - (fontRenderer.getStringWidth(tileEntity.getName()) / 2),
|
||||
6, 0x404040);
|
||||
fontRenderer.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040);
|
||||
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) {
|
||||
mc.renderEngine.bindTexture(tileEntity.guiLocation);
|
||||
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);
|
||||
|
||||
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ResourceLocation getGuiLocation() {
|
||||
return tileEntity.guiLocation;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user