Skip to content

Commit

Permalink
Change the tooltip rendering in books over to forge tooltip rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
bonii-xx committed Apr 27, 2016
1 parent 1c67011 commit 7c9f790
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.IProgressMeter;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.resources.I18n;
import net.minecraft.item.ItemStack;
Expand Down Expand Up @@ -184,6 +185,7 @@ else if(mc.gameSettings.guiScale == 2) {

if(page == -1) {
render.bindTexture(TEX_BOOKFRONT);
RenderHelper.disableStandardItemLighting();

GlStateManager.color(coverR, coverG, coverB);
drawModalRectWithCustomSizedTexture(width / 2 - PAGE_WIDTH_UNSCALED / 2, height / 2 - PAGE_HEIGHT_UNSCALED / 2, 0, 0, PAGE_WIDTH_UNSCALED, PAGE_HEIGHT_UNSCALED, TEX_SIZE, TEX_SIZE);
Expand Down Expand Up @@ -211,6 +213,7 @@ else if(mc.gameSettings.guiScale == 2) {
}
} else {
render.bindTexture(TEX_BOOK);
RenderHelper.disableStandardItemLighting();

GlStateManager.color(coverR, coverG, coverB);
drawModalRectWithCustomSizedTexture(width / 2 - PAGE_WIDTH_UNSCALED, height / 2 - PAGE_HEIGHT_UNSCALED / 2, 0, 0, PAGE_WIDTH_UNSCALED * 2, PAGE_HEIGHT_UNSCALED, TEX_SIZE, TEX_SIZE);
Expand Down Expand Up @@ -256,6 +259,7 @@ else if(mc.gameSettings.guiScale == 2) {
render.bindTexture(TEX_BOOK);
// Set color back to white
GlStateManager.color(1F, 1F, 1F, 1F);
RenderHelper.disableStandardItemLighting();

if((page < book.getFullPageCount(statFile) - 1 || book.getPageCount(statFile) % 2 != 0) && page < book
.getFullPageCount(statFile)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package slimeknights.mantle.client.gui.book;

import com.google.common.collect.ImmutableList;

import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.VertexBuffer;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.translation.I18n;
import net.minecraftforge.fml.client.config.GuiUtils;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

Expand Down Expand Up @@ -211,60 +214,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) {
if(textLines.length > 0) {
GlStateManager.disableDepth();
int i = 0;

for(String s : textLines) {
int j = font.getStringWidth(s);

if(j > i) {
i = j;
}
}

int l1 = x + 12;
int i2 = y - 12;
int k = 8;

if(textLines.length > 1) {
k += 2 + (textLines.length - 1) * 10;
}

if(l1 + i > GuiBook.PAGE_WIDTH) {
l1 -= 28 + i;
}

if(i2 + k + 6 > GuiBook.PAGE_HEIGHT) {
i2 = GuiBook.PAGE_HEIGHT - k - 6;
}

int l = -267386864;
drawGradientRect(l1 - 3, i2 - 4, l1 + i + 3, i2 - 3, l, l);
drawGradientRect(l1 - 3, i2 + k + 3, l1 + i + 3, i2 + k + 4, l, l);
drawGradientRect(l1 - 3, i2 - 3, l1 + i + 3, i2 + k + 3, l, l);
drawGradientRect(l1 - 4, i2 - 3, l1 - 3, i2 + k + 3, l, l);
drawGradientRect(l1 + i + 3, i2 - 3, l1 + i + 4, i2 + k + 3, l, l);
int i1 = 1347420415;
int j1 = (i1 & 16711422) >> 1 | i1 & -16777216;
drawGradientRect(l1 - 3, i2 - 3 + 1, l1 - 3 + 1, i2 + k + 3 - 1, i1, j1);
drawGradientRect(l1 + i + 2, i2 - 3 + 1, l1 + i + 3, i2 + k + 3 - 1, i1, j1);
drawGradientRect(l1 - 3, i2 - 3, l1 + i + 3, i2 - 3 + 1, i1, i1);
drawGradientRect(l1 - 3, i2 + k + 2, l1 + i + 3, i2 + k + 3, j1, j1);

for(int k1 = 0; k1 < textLines.length; ++k1) {
String s1 = textLines[k1];
font.drawStringWithShadow(s1, (float) l1, (float) i2, -1);

if(k1 == 0) {
i2 += 2;
}

i2 += 10;
}

GlStateManager.enableDepth();
}
GuiUtils.drawHoveringText(ImmutableList.copyOf(textLines), x, y, GuiBook.PAGE_WIDTH, GuiBook.PAGE_HEIGHT, GuiBook.PAGE_WIDTH, font);
}

public static void drawScaledString(FontRenderer font, String text, float x, float y, int color, boolean dropShadow, float scale) {
Expand Down

0 comments on commit 7c9f790

Please sign in to comment.