Skip to content

Commit

Permalink
Cleanup GUIs all around:
Browse files Browse the repository at this point in the history
- Fix lighting errors throughout
- Add item highlights
- Fix buttons being cut off and uncentered
- Add a background to the headers on the recipe GUI
- Change the color of the header text on the recipe GUI
  • Loading branch information
tterrag1098 authored and mezz committed Nov 24, 2015
1 parent 9746cdf commit 6147a96
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 19 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ JustEnoughItems.iws
out/
.idea
build/*
/bin/
Empty file modified gradlew
100644 → 100755
Empty file.
11 changes: 10 additions & 1 deletion src/main/java/mezz/jei/gui/GuiItemStack.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.item.ItemStack;

import org.lwjgl.opengl.GL11;

import mezz.jei.util.Log;
import mezz.jei.util.StackUtil;

Expand Down Expand Up @@ -54,8 +57,14 @@ public void drawHovered(@Nonnull Minecraft minecraft, int mouseX, int mouseY) {
}
draw(minecraft, false);
try {
minecraft.currentScreen.renderToolTip(itemStack, mouseX, mouseY);
GlStateManager.disableDepth();
this.zLevel = 0;
RenderHelper.disableStandardItemLighting();
GL11.glEnable(GL11.GL_BLEND);
drawRect(xPosition, yPosition, xPosition + width, yPosition + width, 0x7FFFFFFF);
this.zLevel = 0;
minecraft.currentScreen.renderToolTip(itemStack, mouseX, mouseY);
GlStateManager.enableDepth();
} catch (RuntimeException e) {
Log.error("Exception when rendering tooltip on {}.\n{}", itemStack, e);
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/mezz/jei/gui/GuiWidget.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
import java.util.Collections;
import java.util.List;

import net.minecraft.client.gui.Gui;

import mezz.jei.util.CycleTimer;

public abstract class GuiWidget<T> implements IGuiWidget<T> {
public abstract class GuiWidget<T> extends Gui implements IGuiWidget<T> {
protected final int xPosition;
protected final int yPosition;
protected final int width;
Expand Down
9 changes: 7 additions & 2 deletions src/main/java/mezz/jei/gui/ItemListOverlay.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;

import net.minecraftforge.fml.client.config.GuiButtonExt;

import org.lwjgl.input.Keyboard;

import mezz.jei.ItemFilter;
Expand Down Expand Up @@ -80,8 +83,8 @@ public void initGui(@Nonnull GuiContainer guiContainer) {

int leftEdge = this.guiLeft + this.xSize + borderPadding;

nextButton = new GuiButton(0, rightEdge - nextButtonWidth, 0, nextButtonWidth, buttonHeight, next);
backButton = new GuiButton(1, leftEdge, 0, backButtonWidth, buttonHeight, back);
nextButton = new GuiButtonExt(0, rightEdge - nextButtonWidth, 0, nextButtonWidth, buttonHeight, next);
backButton = new GuiButtonExt(1, leftEdge, 0, backButtonWidth, buttonHeight, back);

searchField = new GuiTextField(0, fontRenderer, leftEdge, this.height - searchHeight - (2 * borderPadding), rightEdge - leftEdge, searchHeight);
searchField.setMaxStringLength(maxSearchLength);
Expand Down Expand Up @@ -174,6 +177,8 @@ public void drawScreen(@Nonnull Minecraft minecraft, int mouseX, int mouseY) {
return;
}

GlStateManager.disableLighting();

minecraft.fontRendererObj.drawString(pageNumDisplayString, pageNumDisplayX, pageNumDisplayY, Color.white.getRGB(), true);
searchField.drawTextBox();

Expand Down
33 changes: 20 additions & 13 deletions src/main/java/mezz/jei/gui/RecipesGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import net.minecraft.util.ResourceLocation;

import net.minecraftforge.fml.client.FMLClientHandler;
import net.minecraftforge.fml.client.config.GuiButtonExt;

import org.lwjgl.opengl.GL11;

Expand All @@ -36,13 +37,14 @@ private enum Mode {
INPUT, OUTPUT
}

private static final int borderPadding = 6;
private static final int textPadding = 2;
private static final int borderPadding = 8;
private static final int textPadding = 5;

private int titleHeight;
private int headerHeight;
private int buttonWidth;

/* Whether this GUI is displaying input or output recipes */
/* Whether this GUI is dispzzlaying input or output recipes */
private Mode mode;

/* The ItemStack that is the focus of this GUI */
Expand Down Expand Up @@ -97,19 +99,20 @@ public void initGui(@Nonnull Minecraft minecraft) {
this.titleHeight = fontRendererObj.FONT_HEIGHT + borderPadding;
this.headerHeight = titleHeight + fontRendererObj.FONT_HEIGHT + textPadding;

int buttonWidth = 13;
int buttonHeight = fontRendererObj.FONT_HEIGHT + textPadding;
buttonWidth = 13;

int buttonHeight = fontRendererObj.FONT_HEIGHT + 3;

int rightButtonX = guiLeft + xSize - borderPadding - buttonWidth;
int leftButtonX = guiLeft + borderPadding;

int recipeClassButtonTop = guiTop + borderPadding - 3;
nextRecipeCategory = new GuiButton(2, rightButtonX, recipeClassButtonTop, buttonWidth, buttonHeight, ">");
previousRecipeCategory = new GuiButton(3, leftButtonX, recipeClassButtonTop, buttonWidth, buttonHeight, "<");
int recipeClassButtonTop = guiTop + borderPadding - 2;
nextRecipeCategory = new GuiButtonExt(2, rightButtonX, recipeClassButtonTop, buttonWidth, buttonHeight, ">");
previousRecipeCategory = new GuiButtonExt(3, leftButtonX, recipeClassButtonTop, buttonWidth, buttonHeight, "<");

int pageButtonTop = guiTop + titleHeight;
nextPage = new GuiButton(4, rightButtonX, pageButtonTop, buttonWidth, buttonHeight, ">");
previousPage = new GuiButton(5, leftButtonX, pageButtonTop, buttonWidth, buttonHeight, "<");
int pageButtonTop = guiTop + titleHeight + 3;
nextPage = new GuiButtonExt(4, rightButtonX, pageButtonTop, buttonWidth, buttonHeight, ">");
previousPage = new GuiButtonExt(5, leftButtonX, pageButtonTop, buttonWidth, buttonHeight, "<");

addButtons();

Expand Down Expand Up @@ -343,10 +346,14 @@ public void draw(int mouseX, int mouseY) {
GL11.glPushMatrix();
{
GL11.glTranslatef(guiLeft, guiTop, 0.0F);

drawRect(borderPadding + buttonWidth, borderPadding - 2, xSize - borderPadding - buttonWidth, borderPadding + 10, 0x30000000);
drawRect(borderPadding + buttonWidth, titleHeight + textPadding - 2, xSize - borderPadding - buttonWidth, titleHeight + textPadding + 10, 0x30000000);

GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

StringUtil.drawCenteredString(fontRendererObj, title, xSize, borderPadding, Color.black.getRGB());
StringUtil.drawCenteredString(fontRendererObj, pageString, xSize, titleHeight + textPadding, Color.black.getRGB());
StringUtil.drawCenteredString(fontRendererObj, title, xSize, borderPadding, Color.WHITE.getRGB(), true);
StringUtil.drawCenteredString(fontRendererObj, pageString, xSize, titleHeight + textPadding, Color.WHITE.getRGB(), true);
}
GL11.glPopMatrix();

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/mezz/jei/util/StringUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

public class StringUtil {

public static void drawCenteredString(FontRenderer fontRenderer, String string, int guiWidth, int yPos, int color) {
fontRenderer.drawString(string, (guiWidth - fontRenderer.getStringWidth(string)) / 2, yPos, color);
public static void drawCenteredString(FontRenderer fontRenderer, String string, int guiWidth, int yPos, int color, boolean shadow) {
fontRenderer.drawString(string, (guiWidth - fontRenderer.getStringWidth(string)) / 2, yPos, color, shadow);
}

}

0 comments on commit 6147a96

Please sign in to comment.