mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-28 07:36:01 +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
@@ -25,6 +25,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
@@ -32,19 +33,15 @@ import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiTransporterConfig extends GuiMekanism {
|
||||
public class GuiTransporterConfig extends GuiMekanismTile<TileEntityContainerBlock> {
|
||||
|
||||
public Map<Integer, GuiPos> slotPosMap = new HashMap<>();
|
||||
|
||||
public ISideConfiguration configurable;
|
||||
private Map<Integer, GuiPos> slotPosMap = new HashMap<>();
|
||||
private ISideConfiguration configurable;
|
||||
|
||||
public GuiTransporterConfig(EntityPlayer player, ISideConfiguration tile) {
|
||||
super((TileEntityContainerBlock) tile, new ContainerNull(player, (TileEntityContainerBlock) tile));
|
||||
|
||||
ySize = 95;
|
||||
|
||||
configurable = tile;
|
||||
|
||||
slotPosMap.put(0, new GuiPos(54, 64));
|
||||
slotPosMap.put(1, new GuiPos(54, 34));
|
||||
slotPosMap.put(2, new GuiPos(54, 49));
|
||||
@@ -56,44 +53,33 @@ public class GuiTransporterConfig extends GuiMekanism {
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) {
|
||||
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
|
||||
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiTransporterConfig.png"));
|
||||
|
||||
mc.renderEngine.bindTexture(getGuiLocation());
|
||||
int guiWidth = (width - xSize) / 2;
|
||||
int guiHeight = (height - ySize) / 2;
|
||||
|
||||
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
|
||||
|
||||
int xAxis = (mouseX - (width - xSize) / 2);
|
||||
int yAxis = (mouseY - (height - ySize) / 2);
|
||||
|
||||
if (xAxis >= 6 && xAxis <= 20 && yAxis >= 6 && yAxis <= 20) {
|
||||
drawTexturedModalRect(guiWidth + 6, guiHeight + 6, 176 + 14, 0, 14, 14);
|
||||
} else {
|
||||
drawTexturedModalRect(guiWidth + 6, guiHeight + 6, 176 + 14, 14, 14, 14);
|
||||
}
|
||||
|
||||
if (xAxis >= 156 && xAxis <= 170 && yAxis >= 6 && yAxis <= 20) {
|
||||
drawTexturedModalRect(guiWidth + 156, guiHeight + 6, 176 + 28, 0, 14, 14);
|
||||
} else {
|
||||
drawTexturedModalRect(guiWidth + 156, guiHeight + 6, 176 + 28, 14, 14, 14);
|
||||
}
|
||||
|
||||
for (int i = 0; i < slotPosMap.size(); i++) {
|
||||
MekanismRenderer.resetColor();
|
||||
|
||||
int x = slotPosMap.get(i).xPos;
|
||||
int y = slotPosMap.get(i).yPos;
|
||||
|
||||
EnumColor color = configurable.getEjector().getInputColor(EnumFacing.byIndex(i));
|
||||
|
||||
if (configurable.getConfig().getOutput(TransmissionType.ITEM, EnumFacing.byIndex(i))
|
||||
!= TileComponentConfig.EMPTY) {
|
||||
if (color != null) {
|
||||
MekanismRenderer.color(color);
|
||||
}
|
||||
|
||||
if (xAxis >= x && xAxis <= x + 14 && yAxis >= y && yAxis <= y + 14) {
|
||||
drawTexturedModalRect(guiWidth + x, guiHeight + y, 176, 0, 14, 14);
|
||||
} else {
|
||||
@@ -103,44 +89,35 @@ public class GuiTransporterConfig extends GuiMekanism {
|
||||
drawTexturedModalRect(guiWidth + x, guiHeight + y, 176, 28, 14, 14);
|
||||
}
|
||||
}
|
||||
|
||||
MekanismRenderer.resetColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
int xAxis = (mouseX - (width - xSize) / 2);
|
||||
int yAxis = (mouseY - (height - ySize) / 2);
|
||||
|
||||
String text = LangUtils.localize("gui.configuration.transporter");
|
||||
fontRenderer.drawString(text, (xSize / 2) - (fontRenderer.getStringWidth(text) / 2), 5, 0x404040);
|
||||
text = LangUtils.localize("gui.strictInput") + " (" + LangUtils
|
||||
.transOnOff(configurable.getEjector().hasStrictInput()) + ")";
|
||||
renderScaledText(text, 53, 17, 0x00CD00, 70);
|
||||
|
||||
fontRenderer.drawString(LangUtils.localize("gui.input"), 48, 81, 0x787878);
|
||||
fontRenderer.drawString(LangUtils.localize("gui.output"), 114, 68, 0x787878);
|
||||
|
||||
if (configurable.getEjector().getOutputColor() != null) {
|
||||
GlStateManager.pushMatrix();
|
||||
GL11.glColor4f(1, 1, 1, 1);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
|
||||
mc.getTextureManager().bindTexture(MekanismRenderer.getBlocksTexture());
|
||||
drawTexturedRectFromIcon(122, 49, MekanismRenderer.getColorIcon(configurable.getEjector().getOutputColor()),
|
||||
16, 16);
|
||||
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
||||
int xAxis = (mouseX - (width - xSize) / 2);
|
||||
int yAxis = (mouseY - (height - ySize) / 2);
|
||||
for (int i = 0; i < slotPosMap.size(); i++) {
|
||||
int x = slotPosMap.get(i).xPos;
|
||||
int y = slotPosMap.get(i).yPos;
|
||||
|
||||
EnumColor color = configurable.getEjector().getInputColor(EnumFacing.byIndex(i));
|
||||
|
||||
if (configurable.getConfig().getOutput(TransmissionType.ITEM, EnumFacing.byIndex(i))
|
||||
!= TileComponentConfig.EMPTY) {
|
||||
if (xAxis >= x && xAxis <= x + 14 && yAxis >= y && yAxis <= y + 14) {
|
||||
@@ -149,7 +126,6 @@ public class GuiTransporterConfig extends GuiMekanism {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (xAxis >= 122 && xAxis <= 138 && yAxis >= 49 && yAxis <= 65) {
|
||||
if (configurable.getEjector().getOutputColor() != null) {
|
||||
drawHoveringText(configurable.getEjector().getOutputColor().getColoredName(), xAxis, yAxis);
|
||||
@@ -157,51 +133,41 @@ public class GuiTransporterConfig extends GuiMekanism {
|
||||
drawHoveringText(LangUtils.localize("gui.none"), xAxis, yAxis);
|
||||
}
|
||||
}
|
||||
|
||||
if (xAxis >= 156 && xAxis <= 170 && yAxis >= 6 && yAxis <= 20) {
|
||||
drawHoveringText(LangUtils.localize("gui.configuration.strictInput"), xAxis, yAxis);
|
||||
}
|
||||
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int mouseX, int mouseY, int button) throws IOException {
|
||||
super.mouseClicked(mouseX, mouseY, button);
|
||||
|
||||
int xAxis = (mouseX - (width - xSize) / 2);
|
||||
int yAxis = (mouseY - (height - ySize) / 2);
|
||||
|
||||
TileEntity tile = (TileEntity) configurable;
|
||||
|
||||
if (button == 0) {
|
||||
if (xAxis >= 6 && xAxis <= 20 && yAxis >= 6 && yAxis <= 20) {
|
||||
int guiId = Mekanism.proxy.getGuiId(tile.getBlockType(), tile.getBlockMetadata());
|
||||
SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK);
|
||||
Mekanism.packetHandler.sendToServer(new SimpleGuiMessage(Coord4D.get(tile), 0, guiId));
|
||||
}
|
||||
|
||||
if (xAxis >= 156 && xAxis <= 170 && yAxis >= 6 && yAxis <= 20) {
|
||||
SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK);
|
||||
Mekanism.packetHandler.sendToServer(
|
||||
new ConfigurationUpdateMessage(ConfigurationPacket.STRICT_INPUT, Coord4D.get(tile), 0, 0, null));
|
||||
}
|
||||
}
|
||||
|
||||
if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && button == 0) {
|
||||
button = 2;
|
||||
}
|
||||
|
||||
if (xAxis >= 122 && xAxis <= 138 && yAxis >= 49 && yAxis <= 65) {
|
||||
SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK);
|
||||
Mekanism.packetHandler.sendToServer(
|
||||
new ConfigurationUpdateMessage(ConfigurationPacket.EJECT_COLOR, Coord4D.get(tile), button, 0, null));
|
||||
}
|
||||
|
||||
for (int i = 0; i < slotPosMap.size(); i++) {
|
||||
int x = slotPosMap.get(i).xPos;
|
||||
int y = slotPosMap.get(i).yPos;
|
||||
|
||||
if (xAxis >= x && xAxis <= x + 14 && yAxis >= y && yAxis <= y + 14) {
|
||||
SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK);
|
||||
Mekanism.packetHandler.sendToServer(
|
||||
@@ -210,4 +176,9 @@ public class GuiTransporterConfig extends GuiMekanism {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ResourceLocation getGuiLocation() {
|
||||
return MekanismUtils.getResource(ResourceType.GUI, "GuiTransporterConfig.png");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user