Skip to content

Commit

Permalink
Add a background hover color for the section list
Browse files Browse the repository at this point in the history
  • Loading branch information
bonii-xx committed Apr 27, 2016
1 parent e829fac commit 7c6f34d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class AppearanceData implements IDataItem {
public int coverColor = 0x8B4631;
public int arrowColor = 0xFFFFD3;
public int arrowColorHover = 0xFF541C;
public int hoverColor = 0x77EE541C;
public int lockedSectionColor = 0x000000;
public float scale = 0.5F;
public String title = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.VertexBuffer;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
Expand Down Expand Up @@ -215,6 +216,7 @@ public static String[] cropStringBySize(String s, String modifiers, int width, i
//BEGIN METHODS FROM GUI
private static void drawHoveringText(String[] textLines, int x, int y, FontRenderer font) {
GuiUtils.drawHoveringText(ImmutableList.copyOf(textLines), x, y, GuiBook.PAGE_WIDTH, GuiBook.PAGE_HEIGHT, GuiBook.PAGE_WIDTH, font);
RenderHelper.disableStandardItemLighting();
}

public static void drawScaledString(FontRenderer font, String text, float x, float y, int color, boolean dropShadow, float scale) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ public void draw(int mouseX, int mouseY, float partialTicks, FontRenderer fontRe
boolean hover = isHovered(mouseX, mouseY);

if(section.icon != null) {
int iconX = x + WIDTH / 2 - IMG_SIZE / 2;
int iconY = y + HEIGHT / 2 - IMG_SIZE / 2;
if(hover) {
drawRect(iconX, iconY, iconX + IMG_SIZE, iconY + IMG_SIZE, parent.book.appearance.hoverColor);
}
if(unlocked) {
GlStateManager.color(1F, 1F, 1F, hover ? 1F : 0.5F);
} else {
Expand All @@ -46,11 +51,11 @@ public void draw(int mouseX, int mouseY, float partialTicks, FontRenderer fontRe
if(section.icon.location != null) {
renderEngine.bindTexture(section.icon.location);

drawScaledCustomSizeModalRect(x + WIDTH / 2 - IMG_SIZE / 2, y + HEIGHT / 2 - IMG_SIZE / 2, section.icon.u, section.icon.v, section.icon.uw, section.icon.vh, IMG_SIZE, IMG_SIZE, section.icon.texWidth, section.icon.texHeight);
drawScaledCustomSizeModalRect(iconX, iconY, section.icon.u, section.icon.v, section.icon.uw, section.icon.vh, IMG_SIZE, IMG_SIZE, section.icon.texWidth, section.icon.texHeight);
}
} else {
GlStateManager.pushMatrix();
GlStateManager.translate(x + WIDTH / 2 - IMG_SIZE / 2, y + HEIGHT / 2 - IMG_SIZE / 2, 0);
GlStateManager.translate(iconX, iconY, 0);
GlStateManager.scale(2F, 2F, 1F);
RenderHelper.enableGUIStandardItemLighting();
mc.getRenderItem().renderItemAndEffectIntoGUI(section.icon.item.getItems()[0], 0, 0);
Expand All @@ -60,9 +65,12 @@ public void draw(int mouseX, int mouseY, float partialTicks, FontRenderer fontRe
}

if(section.parent.appearance.drawSectionListText) {
int textW = fontRenderer.getStringWidth(section.getTitle());
int textX = x + WIDTH / 2 - textW / 2;
int textY = y + HEIGHT - fontRenderer.FONT_HEIGHT/2;
fontRenderer.drawString(section.getTitle(),
x + WIDTH / 2 - fontRenderer.getStringWidth(section.getTitle()) / 2,
y + HEIGHT - fontRenderer.FONT_HEIGHT/2,
textX,
textY,
hover ? 0xFF000000 : 0x7F000000);
}
}
Expand All @@ -85,7 +93,7 @@ public void drawOverlay(int mouseX, int mouseY, float partialTicks, FontRenderer
}
}
}
drawHoveringText(text, mouseX, mouseY, Minecraft.getMinecraft().fontRendererObj);
drawHoveringText(text, mouseX, mouseY, fontRenderer);
}
}

Expand Down

0 comments on commit 7c6f34d

Please sign in to comment.