mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-28 07:55:41 +00:00
Update buildscript & spotlessApply (#78)
* Update buildscript & spotlessApply * Add mapping version
This commit is contained in:
1 parent
f272840987
commit
cf41b89ae4
851 files changed
+95348
-92599
No files matched your search
@@ -1,16 +1,5 @@
|
||||
package crazypants.enderio.machine.gui;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.enderio.core.api.common.util.IProgressTile;
|
||||
import com.enderio.core.client.gui.button.IconButton;
|
||||
import com.enderio.core.client.gui.widget.GuiToolTip;
|
||||
@@ -18,7 +7,6 @@ import com.enderio.core.client.render.RenderUtil;
|
||||
import com.enderio.core.common.util.BlockCoord;
|
||||
import com.enderio.core.common.util.Util;
|
||||
import com.enderio.core.common.vecmath.Vector4f;
|
||||
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.gui.GuiContainerBaseEIO;
|
||||
import crazypants.enderio.gui.IconEIO;
|
||||
@@ -27,187 +15,196 @@ import crazypants.enderio.gui.RedstoneModeButton;
|
||||
import crazypants.enderio.machine.AbstractMachineEntity;
|
||||
import crazypants.enderio.machine.IoMode;
|
||||
import crazypants.enderio.machine.SlotDefinition;
|
||||
import java.awt.Rectangle;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public abstract class GuiMachineBase<T extends AbstractMachineEntity> extends GuiContainerBaseEIO {
|
||||
|
||||
public static final Vector4f PUSH_COLOR = new Vector4f(0.8f, 0.4f, 0.1f, 0.5f);
|
||||
public static final Vector4f PULL_COLOR = new Vector4f(0.1f, 0.4f, 0.8f, 0.5f);
|
||||
public static final Vector4f PUSH_COLOR = new Vector4f(0.8f, 0.4f, 0.1f, 0.5f);
|
||||
public static final Vector4f PULL_COLOR = new Vector4f(0.1f, 0.4f, 0.8f, 0.5f);
|
||||
|
||||
public static final int BUTTON_SIZE = 16;
|
||||
private static final int CONFIG_ID = 8962349;
|
||||
private static final int RECIPE_ID = CONFIG_ID + 1;
|
||||
public static final int BUTTON_SIZE = 16;
|
||||
private static final int CONFIG_ID = 8962349;
|
||||
private static final int RECIPE_ID = CONFIG_ID + 1;
|
||||
|
||||
private final T tileEntity;
|
||||
private final T tileEntity;
|
||||
|
||||
protected RedstoneModeButton redstoneButton;
|
||||
protected RedstoneModeButton redstoneButton;
|
||||
|
||||
private final GuiOverlayIoConfig configOverlay;
|
||||
private final GuiOverlayIoConfig configOverlay;
|
||||
|
||||
protected final GuiButtonIoConfig configB;
|
||||
|
||||
protected IconButton recipeButton;
|
||||
protected final GuiButtonIoConfig configB;
|
||||
|
||||
protected List<GuiToolTip> progressTooltips;
|
||||
protected int lastProgressTooltipValue = -1;
|
||||
protected IconButton recipeButton;
|
||||
|
||||
protected GuiMachineBase(T machine, Container par1Container, String... guiTexture) {
|
||||
super(par1Container, guiTexture);
|
||||
tileEntity = machine;
|
||||
|
||||
xSize = getXSize();
|
||||
ySize = getYSize();
|
||||
int x = getXSize() - 5 - BUTTON_SIZE;
|
||||
int y = 5;
|
||||
redstoneButton = new RedstoneModeButton(this, -1, x, y, tileEntity, new BlockCoord(tileEntity));
|
||||
protected List<GuiToolTip> progressTooltips;
|
||||
protected int lastProgressTooltipValue = -1;
|
||||
|
||||
configOverlay = new GuiOverlayIoConfig(machine);
|
||||
addOverlay(configOverlay);
|
||||
protected GuiMachineBase(T machine, Container par1Container, String... guiTexture) {
|
||||
super(par1Container, guiTexture);
|
||||
tileEntity = machine;
|
||||
|
||||
y += 19;
|
||||
configB = new GuiButtonIoConfig(this, CONFIG_ID, x, y, machine, configOverlay);
|
||||
xSize = getXSize();
|
||||
ySize = getYSize();
|
||||
int x = getXSize() - 5 - BUTTON_SIZE;
|
||||
int y = 5;
|
||||
redstoneButton = new RedstoneModeButton(this, -1, x, y, tileEntity, new BlockCoord(tileEntity));
|
||||
|
||||
y += 19;
|
||||
recipeButton = new IconButton(this, RECIPE_ID, x, y, IconEIO.RECIPE);
|
||||
recipeButton.visible = false;
|
||||
recipeButton.setIconMargin(1, 1);
|
||||
}
|
||||
configOverlay = new GuiOverlayIoConfig(machine);
|
||||
addOverlay(configOverlay);
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
redstoneButton.onGuiInit();
|
||||
configB.onGuiInit();
|
||||
recipeButton.onGuiInit();
|
||||
}
|
||||
y += 19;
|
||||
configB = new GuiButtonIoConfig(this, CONFIG_ID, x, y, machine, configOverlay);
|
||||
|
||||
protected boolean showRecipeButton() {
|
||||
return EnderIO.proxy.isNeiInstalled();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
|
||||
super.drawGuiContainerBackgroundLayer(par1, par2, par3);
|
||||
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
for (int i = 0; i < buttonList.size(); ++i) {
|
||||
GuiButton guibutton = (GuiButton) buttonList.get(i);
|
||||
guibutton.drawButton(mc, 0, 0);
|
||||
y += 19;
|
||||
recipeButton = new IconButton(this, RECIPE_ID, x, y, IconEIO.RECIPE);
|
||||
recipeButton.visible = false;
|
||||
recipeButton.setIconMargin(1, 1);
|
||||
}
|
||||
|
||||
if(showRecipeButton()) {
|
||||
recipeButton.visible = true;
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
redstoneButton.onGuiInit();
|
||||
configB.onGuiInit();
|
||||
recipeButton.onGuiInit();
|
||||
}
|
||||
|
||||
super.drawGuiContainerBackgroundLayer(par1, par2, par3);
|
||||
|
||||
renderSlotHighlights();
|
||||
}
|
||||
|
||||
public void renderSlotHighlights() {
|
||||
SelectedFace sel = configOverlay.getSelection();
|
||||
if(sel != null) {
|
||||
IoMode mode = sel.config.getIoMode(sel.face);
|
||||
if(mode != null) {
|
||||
renderSlotHighlights(mode);
|
||||
}
|
||||
protected boolean showRecipeButton() {
|
||||
return EnderIO.proxy.isNeiInstalled();
|
||||
}
|
||||
}
|
||||
|
||||
public void renderSlotHighlights(IoMode mode) {
|
||||
SlotDefinition slotDef = tileEntity.getSlotDefinition();
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
|
||||
super.drawGuiContainerBackgroundLayer(par1, par2, par3);
|
||||
|
||||
for (Slot invSlot : (List<Slot>) inventorySlots.inventorySlots) {
|
||||
if (invSlot.inventory == tileEntity) {
|
||||
if ((mode == IoMode.PULL || mode == IoMode.PUSH_PULL) && slotDef.isInputSlot(invSlot.getSlotIndex())) {
|
||||
renderSlotHighlight(invSlot, PULL_COLOR);
|
||||
} else if ((mode == IoMode.PUSH || mode == IoMode.PUSH_PULL) && slotDef.isOutputSlot(invSlot.getSlotIndex())) {
|
||||
renderSlotHighlight(invSlot, PUSH_COLOR);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
for (int i = 0; i < buttonList.size(); ++i) {
|
||||
GuiButton guibutton = (GuiButton) buttonList.get(i);
|
||||
guibutton.drawButton(mc, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void renderSlotHighlight(int slot, Vector4f col) {
|
||||
Slot invSlot = (Slot) inventorySlots.inventorySlots.get(slot);
|
||||
renderSlotHighlight(col, invSlot.xDisplayPosition, invSlot.yDisplayPosition, 16, 16);
|
||||
}
|
||||
if (showRecipeButton()) {
|
||||
recipeButton.visible = true;
|
||||
}
|
||||
|
||||
protected void renderSlotHighlight(Slot invSlot, Vector4f col) {
|
||||
renderSlotHighlight(col, invSlot.xDisplayPosition, invSlot.yDisplayPosition, 16, 16);
|
||||
}
|
||||
super.drawGuiContainerBackgroundLayer(par1, par2, par3);
|
||||
|
||||
protected void renderSlotHighlight(Vector4f col, int x, int y, int width, int height) {
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
RenderUtil.renderQuad2D(getGuiLeft() + x, getGuiTop() + y, 0, width, height, col);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
}
|
||||
|
||||
protected boolean isConfigOverlayEnabled() {
|
||||
return configOverlay.isVisible();
|
||||
}
|
||||
|
||||
protected T getTileEntity() {
|
||||
return tileEntity;
|
||||
}
|
||||
|
||||
protected void addProgressTooltip(int x, int y, int w, int h) {
|
||||
if(progressTooltips == null) {
|
||||
progressTooltips = new ArrayList<GuiToolTip>();
|
||||
renderSlotHighlights();
|
||||
}
|
||||
|
||||
GuiToolTip tt = new GuiToolTip(new Rectangle(x, y, w, h), (String[])null);
|
||||
progressTooltips.add(tt);
|
||||
addToolTip(tt);
|
||||
}
|
||||
|
||||
protected final void updateProgressTooltips(int scaledProgress, float progress) {
|
||||
if(lastProgressTooltipValue == scaledProgress || progressTooltips == null) {
|
||||
return;
|
||||
}
|
||||
lastProgressTooltipValue = scaledProgress;
|
||||
|
||||
if(scaledProgress < 0) {
|
||||
for(GuiToolTip tt : progressTooltips) {
|
||||
tt.setVisible(false);
|
||||
}
|
||||
return;
|
||||
public void renderSlotHighlights() {
|
||||
SelectedFace sel = configOverlay.getSelection();
|
||||
if (sel != null) {
|
||||
IoMode mode = sel.config.getIoMode(sel.face);
|
||||
if (mode != null) {
|
||||
renderSlotHighlights(mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String msg = formatProgressTooltip(scaledProgress, progress);
|
||||
String[] tooltip = msg.split("\\|");
|
||||
for(GuiToolTip tt : progressTooltips) {
|
||||
tt.setToolTipText(tooltip);
|
||||
tt.setVisible(true);
|
||||
public void renderSlotHighlights(IoMode mode) {
|
||||
SlotDefinition slotDef = tileEntity.getSlotDefinition();
|
||||
|
||||
for (Slot invSlot : (List<Slot>) inventorySlots.inventorySlots) {
|
||||
if (invSlot.inventory == tileEntity) {
|
||||
if ((mode == IoMode.PULL || mode == IoMode.PUSH_PULL) && slotDef.isInputSlot(invSlot.getSlotIndex())) {
|
||||
renderSlotHighlight(invSlot, PULL_COLOR);
|
||||
} else if ((mode == IoMode.PUSH || mode == IoMode.PUSH_PULL)
|
||||
&& slotDef.isOutputSlot(invSlot.getSlotIndex())) {
|
||||
renderSlotHighlight(invSlot, PUSH_COLOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected String formatProgressTooltip(int scaledProgress, float progress) {
|
||||
return MessageFormat.format(EnderIO.lang.localize("gui.progress"), scaledProgress);
|
||||
}
|
||||
protected void renderSlotHighlight(int slot, Vector4f col) {
|
||||
Slot invSlot = (Slot) inventorySlots.inventorySlots.get(slot);
|
||||
renderSlotHighlight(col, invSlot.xDisplayPosition, invSlot.yDisplayPosition, 16, 16);
|
||||
}
|
||||
|
||||
protected int scaleProgressForTooltip(float progress) {
|
||||
return (int) (progress * 100);
|
||||
}
|
||||
protected void renderSlotHighlight(Slot invSlot, Vector4f col) {
|
||||
renderSlotHighlight(col, invSlot.xDisplayPosition, invSlot.yDisplayPosition, 16, 16);
|
||||
}
|
||||
|
||||
protected boolean shouldRenderProgress() {
|
||||
if(tileEntity instanceof IProgressTile) {
|
||||
float progress = ((IProgressTile) tileEntity).getProgress();
|
||||
if(progress > 0 && progress < 1) {
|
||||
updateProgressTooltips(scaleProgressForTooltip(progress), progress);
|
||||
return true;
|
||||
} else {
|
||||
updateProgressTooltips(-1, -1);
|
||||
protected void renderSlotHighlight(Vector4f col, int x, int y, int width, int height) {
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
RenderUtil.renderQuad2D(getGuiLeft() + x, getGuiTop() + y, 0, width, height, col);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
}
|
||||
|
||||
protected boolean isConfigOverlayEnabled() {
|
||||
return configOverlay.isVisible();
|
||||
}
|
||||
|
||||
protected T getTileEntity() {
|
||||
return tileEntity;
|
||||
}
|
||||
|
||||
protected void addProgressTooltip(int x, int y, int w, int h) {
|
||||
if (progressTooltips == null) {
|
||||
progressTooltips = new ArrayList<GuiToolTip>();
|
||||
}
|
||||
|
||||
GuiToolTip tt = new GuiToolTip(new Rectangle(x, y, w, h), (String[]) null);
|
||||
progressTooltips.add(tt);
|
||||
addToolTip(tt);
|
||||
}
|
||||
|
||||
protected final void updateProgressTooltips(int scaledProgress, float progress) {
|
||||
if (lastProgressTooltipValue == scaledProgress || progressTooltips == null) {
|
||||
return;
|
||||
}
|
||||
lastProgressTooltipValue = scaledProgress;
|
||||
|
||||
if (scaledProgress < 0) {
|
||||
for (GuiToolTip tt : progressTooltips) {
|
||||
tt.setVisible(false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
String msg = formatProgressTooltip(scaledProgress, progress);
|
||||
String[] tooltip = msg.split("\\|");
|
||||
for (GuiToolTip tt : progressTooltips) {
|
||||
tt.setToolTipText(tooltip);
|
||||
tt.setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
protected String formatProgressTooltip(int scaledProgress, float progress) {
|
||||
return MessageFormat.format(EnderIO.lang.localize("gui.progress"), scaledProgress);
|
||||
}
|
||||
|
||||
protected int scaleProgressForTooltip(float progress) {
|
||||
return (int) (progress * 100);
|
||||
}
|
||||
|
||||
protected boolean shouldRenderProgress() {
|
||||
if (tileEntity instanceof IProgressTile) {
|
||||
float progress = ((IProgressTile) tileEntity).getProgress();
|
||||
if (progress > 0 && progress < 1) {
|
||||
updateProgressTooltips(scaleProgressForTooltip(progress), progress);
|
||||
return true;
|
||||
} else {
|
||||
updateProgressTooltips(-1, -1);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected int getProgressScaled(int scale) {
|
||||
if(getTileEntity() instanceof IProgressTile) {
|
||||
return Util.getProgressScaled(scale, (IProgressTile) getTileEntity());
|
||||
protected int getProgressScaled(int scale) {
|
||||
if (getTileEntity() instanceof IProgressTile) {
|
||||
return Util.getProgressScaled(scale, (IProgressTile) getTileEntity());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user