package ttftcuts.physis.client.gui; import org.lwjgl.opengl.GL11; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.renderer.Tessellator; import net.minecraft.util.ResourceLocation; public class BookFontRenderer extends FontRenderer { private static ResourceLocation glyphSheet = new ResourceLocation("textures/font/ascii.png"); public BookFontRenderer() { super(Minecraft.getMinecraft().gameSettings, glyphSheet, Minecraft.getMinecraft().renderEngine, false); int basecolour = 150; int brightcolour = 60; for (int i = 0; i < 32; ++i) { // 170 base 85 bright int boost = (i >> 3 & 1) * brightcolour; int r = (i >> 2 & 1) * basecolour + boost; int g = (i >> 1 & 1) * basecolour + boost; int b = (i >> 0 & 1) * basecolour + boost; if (i == 6) { r = 210; g = 90; } if (Minecraft.getMinecraft().gameSettings.anaglyph) { int j1 = (r * 30 + g * 59 + b * 11) / 100; int k1 = (r * 30 + g * 70) / 100; int l1 = (r * 30 + b * 70) / 100; r = j1; g = k1; b = l1; } if (i >= 16) { r /= 4; g /= 4; b /= 4; } this.colorCode[i] = (r & 255) << 16 | (g & 255) << 8 | b & 255; } } protected float renderDefaultCharWithShadow(int glyph, boolean flip) { int k = this.textColor; GL11.glDisable(GL11.GL_ALPHA_TEST); float ox = 1f; float oy = 1f; this.posX += ox; GL11.glColor4f(0f,0f,0f, this.alpha * 0.07f); super.renderDefaultChar(glyph, flip); this.posY += oy; super.renderDefaultChar(glyph, flip); this.posY -= oy; this.posX -= ox; GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glColor4f((float)(k >> 16) / 255.0F, (float)(k >> 8 & 255) / 255.0F, (float)(k & 255) / 255.0F, this.alpha); return super.renderDefaultChar(glyph, flip); } protected float renderUnicodeCharWithShadow(char glyph, boolean flip) { return super.renderUnicodeChar(glyph, flip); } protected float renderCharAtPosWithShadow(int p_78278_1_, char p_78278_2_, boolean p_78278_3_) { return p_78278_2_ == 32 ? 4.0F : ("\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000".indexOf(p_78278_2_) != -1 && !this.unicodeFlag ? this.renderDefaultCharWithShadow(p_78278_1_, p_78278_3_) : this.renderUnicodeCharWithShadow(p_78278_2_, p_78278_3_)); } @Override protected void renderStringAtPos(String p_78255_1_, boolean p_78255_2_) { for (int i = 0; i < p_78255_1_.length(); ++i) { char c0 = p_78255_1_.charAt(i); int j; int k; if (c0 == 167 && i + 1 < p_78255_1_.length()) { j = "0123456789abcdefklmnor".indexOf(p_78255_1_.toLowerCase().charAt(i + 1)); if (j < 16) { this.randomStyle = false; this.boldStyle = false; this.strikethroughStyle = false; this.underlineStyle = false; this.italicStyle = false; if (j < 0 || j > 15) { j = 15; } if (p_78255_2_) { j += 16; } k = this.colorCode[j]; this.textColor = k; GL11.glColor4f((float)(k >> 16) / 255.0F, (float)(k >> 8 & 255) / 255.0F, (float)(k & 255) / 255.0F, this.alpha); } else if (j == 16) { this.randomStyle = true; } else if (j == 17) { this.boldStyle = true; } else if (j == 18) { this.strikethroughStyle = true; } else if (j == 19) { this.underlineStyle = true; } else if (j == 20) { this.italicStyle = true; } else if (j == 21) { this.randomStyle = false; this.boldStyle = false; this.strikethroughStyle = false; this.underlineStyle = false; this.italicStyle = false; GL11.glColor4f(this.red, this.blue, this.green, this.alpha); } ++i; } else { j = "\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000".indexOf(c0); if (this.randomStyle && j != -1) { do { k = this.fontRandom.nextInt(this.charWidth.length); } while (this.charWidth[j] != this.charWidth[k]); j = k; } float f1 = this.unicodeFlag ? 0.5F : 1.0F; boolean flag1 = (c0 == 0 || j == -1 || this.unicodeFlag) && p_78255_2_; if (flag1) { this.posX -= f1; this.posY -= f1; } float f = this.boldStyle ? 0 : this.renderCharAtPosWithShadow(j, c0, this.italicStyle); if (flag1) { this.posX += f1; this.posY += f1; } if (this.boldStyle) { this.posX += f1; if (flag1) { this.posX -= f1; this.posY -= f1; } this.renderCharAtPosWithShadow(j, c0, this.italicStyle); this.posX -= f1; if (flag1) { this.posX += f1; this.posY += f1; } f = this.renderCharAtPos(j, c0, this.italicStyle) + 1; } Tessellator tessellator; if (this.strikethroughStyle) { tessellator = Tessellator.instance; GL11.glDisable(GL11.GL_TEXTURE_2D); tessellator.startDrawingQuads(); tessellator.addVertex((double)this.posX, (double)(this.posY + (float)(this.FONT_HEIGHT / 2)), 0.0D); tessellator.addVertex((double)(this.posX + f), (double)(this.posY + (float)(this.FONT_HEIGHT / 2)), 0.0D); tessellator.addVertex((double)(this.posX + f), (double)(this.posY + (float)(this.FONT_HEIGHT / 2) - 1.0F), 0.0D); tessellator.addVertex((double)this.posX, (double)(this.posY + (float)(this.FONT_HEIGHT / 2) - 1.0F), 0.0D); tessellator.draw(); GL11.glEnable(GL11.GL_TEXTURE_2D); } if (this.underlineStyle) { tessellator = Tessellator.instance; GL11.glDisable(GL11.GL_TEXTURE_2D); tessellator.startDrawingQuads(); int l = this.underlineStyle ? -1 : 0; tessellator.addVertex((double)(this.posX + (float)l), (double)(this.posY + (float)this.FONT_HEIGHT), 0.0D); tessellator.addVertex((double)(this.posX + f), (double)(this.posY + (float)this.FONT_HEIGHT), 0.0D); tessellator.addVertex((double)(this.posX + f), (double)(this.posY + (float)this.FONT_HEIGHT - 1.0F), 0.0D); tessellator.addVertex((double)(this.posX + (float)l), (double)(this.posY + (float)this.FONT_HEIGHT - 1.0F), 0.0D); tessellator.draw(); GL11.glEnable(GL11.GL_TEXTURE_2D); } this.posX += (float)((int)f); } } } }