Upload files to "src/openonyx/render/group_w"
This commit is contained in:
1 parent
2f68dddd12
commit
d8ebaf1a02
5 files changed
+689
No files matched your search
@@ -0,0 +1,346 @@
|
||||
package openonyx.render.group_w;
|
||||
|
||||
import java.util.Random;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import openonyx.core.OnyxClient;
|
||||
import openonyx.features.hud.CustomGui;
|
||||
import openonyx.render.group_e.FontFamily;
|
||||
import openonyx.render.group_e.FontFamilyMode;
|
||||
import openonyx.render.group_e.FontStyle;
|
||||
import openonyx.render.group_e.GlyphFont;
|
||||
import openonyx.render.group_e.GlyphFontData;
|
||||
import openonyx.render.group_e.TargetHudTextSettingsWeightMode;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public final class FontRendererHook {
|
||||
private static final Random RANDOM = new Random();
|
||||
private static final float M = 1.0F;
|
||||
private static TargetHudTextSettingsWeightMode targetHudTextSettingsWeightMode;
|
||||
private static final int j = 16579836;
|
||||
private static float m;
|
||||
private static FontStyle fontStyle;
|
||||
private static final float l = 0.2F;
|
||||
private static FontStyle fontStyle2;
|
||||
private static final float d = 7.0F;
|
||||
private static final float i = 7.0F;
|
||||
private static boolean f;
|
||||
private static final String H = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
private static boolean e;
|
||||
|
||||
private static float L(FontRenderer fontRenderer, char c, float f, float g, int i, boolean bl) {
|
||||
String string = String.valueOf(c);
|
||||
e = true;
|
||||
|
||||
try {
|
||||
fontRenderer.drawString(string, fx, g, ix, false);
|
||||
return fontRenderer.getCharWidth(c) + (bl ? fontRenderer.offsetBold : 0.0F);
|
||||
} finally {
|
||||
e = false;
|
||||
GlStateManager.enableTexture2D();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean L(char c) {
|
||||
char dx = c;
|
||||
|
||||
try {
|
||||
return dx == 167 || dx == ' ' || L(false).L().d(dx);
|
||||
} catch (Throwable throwable) {
|
||||
f = true;
|
||||
OnyxClient.LOGGER.warn("Custom GUI font stood down to the bitmap font after a failure", throwable);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static float L(char c) {
|
||||
char dx = c;
|
||||
FontStyle fontStylex;
|
||||
return dx == 167 ? -1.0F : (fontStylex = L(false)).L().D(dx) * fontStylex.L() + L();
|
||||
}
|
||||
|
||||
private static void L(FontRenderer fontRenderer, String string, float f, float g, int i, boolean bl) {
|
||||
FontRenderer fontRenderer1 = fontRenderer;
|
||||
if (!string.isEmpty()) {
|
||||
FontStyle fontStylex;
|
||||
GlyphFont glyphFont = (fontStylex = L(false)).L();
|
||||
GlyphFont glyphFont1 = L(true).L();
|
||||
|
||||
int jx;
|
||||
for (int p = jx = 0; p < string.length(); p = jx) {
|
||||
glyphFont.d(string.charAt(jx));
|
||||
glyphFont1.d(string.charAt(jx++));
|
||||
}
|
||||
|
||||
if (glyphFont.L() != -1) {
|
||||
float mx = fontStylex.L();
|
||||
ix = ix;
|
||||
GlStateManager.enableTexture2D();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
|
||||
fx = fx;
|
||||
int lx = ix;
|
||||
boolean bl1 = false;
|
||||
boolean bl2 = false;
|
||||
boolean bl3 = false;
|
||||
boolean bl4 = false;
|
||||
boolean bl5 = false;
|
||||
|
||||
int k;
|
||||
for (int o = k = 0; o < string.length(); o = ++k) {
|
||||
char c;
|
||||
if ((c = string.charAt(k)) == 167 && k < string.length() - 1) {
|
||||
char ex = Character.toLowerCase(string.charAt(++k));
|
||||
if ("0123456789abcdef".indexOf(ex) >= 0) {
|
||||
bl5 = false;
|
||||
bl4 = false;
|
||||
bl3 = false;
|
||||
bl2 = false;
|
||||
bl1 = false;
|
||||
int n = fontRenderer1.getColorCode(ex);
|
||||
lx = ix & 0xFF000000 | (bl ? (n & 16579836) >> 2 : n) & 16777215;
|
||||
} else {
|
||||
switch (ex) {
|
||||
case 'k':
|
||||
while (false) {
|
||||
}
|
||||
|
||||
bl3 = true;
|
||||
break;
|
||||
case 'l':
|
||||
bl1 = true;
|
||||
break;
|
||||
case 'm':
|
||||
bl5 = true;
|
||||
break;
|
||||
case 'n':
|
||||
bl4 = true;
|
||||
break;
|
||||
case 'o':
|
||||
bl2 = true;
|
||||
case 'p':
|
||||
case 'q':
|
||||
default:
|
||||
break;
|
||||
case 'r':
|
||||
bl5 = false;
|
||||
bl4 = false;
|
||||
bl3 = false;
|
||||
bl2 = false;
|
||||
bl1 = false;
|
||||
lx = ix;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
char dx = bl3 ? L(c) : c;
|
||||
if (!L(dx)) {
|
||||
fx += L(fontRenderer1, dx, fx, g, lx, bl1) + L();
|
||||
} else {
|
||||
GlyphFont glyphFont2 = bl1 ? glyphFont1 : glyphFont;
|
||||
float h = glyphFont.D(c) * mx + L() + (bl1 ? L(fontRenderer1) : 0.0F);
|
||||
L(glyphFont2, dx, fx, g, mx, lx, bl2);
|
||||
if (bl5) {
|
||||
L(fx, g + 3.8500001F, h, lx);
|
||||
}
|
||||
|
||||
if (bl4) {
|
||||
L(fx, g + 7.0F + 1.0F, h, lx);
|
||||
}
|
||||
|
||||
fx += h;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GlStateManager.resetColor();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static int d(FontRenderer fontRenderer, String string, float f, float g, int i, boolean bl) {
|
||||
if (string == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((ix & -67108864) == 0) {
|
||||
ix |= -16777216;
|
||||
}
|
||||
|
||||
if (bl) {
|
||||
L(fontRenderer, string, fx + 1.0F, g + 1.0F, L(ix), true);
|
||||
}
|
||||
|
||||
L(fontRenderer, string, fx, g, ix, false);
|
||||
return (int)(fx + L(fontRenderer, string));
|
||||
}
|
||||
|
||||
private static float L(FontRenderer fontRenderer, char c) {
|
||||
e = true;
|
||||
|
||||
try {
|
||||
return fontRenderer.getCharWidth(c);
|
||||
} finally {
|
||||
e = false;
|
||||
}
|
||||
}
|
||||
|
||||
private static char L(char c) {
|
||||
return c == ' ' ? c : "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".charAt(RANDOM.nextInt("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".length()));
|
||||
}
|
||||
|
||||
private static TargetHudTextSettingsWeightMode L(TargetHudTextSettingsWeightMode targetHudTextSettingsWeightMode) {
|
||||
switch (targetHudTextSettingsWeightModex) {
|
||||
case REGULAR:
|
||||
while (false) {
|
||||
}
|
||||
|
||||
return TargetHudTextSettingsWeightMode.SEMI_BOLD;
|
||||
case MEDIUM:
|
||||
return TargetHudTextSettingsWeightMode.BOLD;
|
||||
default:
|
||||
return TargetHudTextSettingsWeightMode.BOLD;
|
||||
}
|
||||
}
|
||||
|
||||
private static FontStyle L(boolean bl) {
|
||||
boolean bl1 = bl;
|
||||
CustomGui customGui;
|
||||
float fx = (customGui = CustomGuiState.L()) == null ? 1.0F : customGui.customGuiPart5.size.getFloat();
|
||||
TargetHudTextSettingsWeightMode targetHudTextSettingsWeightModex = customGui == null
|
||||
? TargetHudTextSettingsWeightMode.REGULAR
|
||||
: customGui.customGuiPart5.weight.getValue().getTargetHudTextSettingsWeightMode();
|
||||
if (fontStyle2 == null || fx != m || targetHudTextSettingsWeightModex != targetHudTextSettingsWeightMode) {
|
||||
fontStyle2 = L(targetHudTextSettingsWeightModex, fx);
|
||||
fontStyle = L(L(targetHudTextSettingsWeightModex), fx);
|
||||
m = fx;
|
||||
targetHudTextSettingsWeightMode = targetHudTextSettingsWeightModex;
|
||||
}
|
||||
|
||||
return bl1 ? fontStyle : fontStyle2;
|
||||
}
|
||||
|
||||
private static float L() {
|
||||
CustomGui customGui;
|
||||
return (customGui = CustomGuiState.L()) == null ? 0.0F : customGui.customGuiPart5.letterSpacing.getFloat();
|
||||
}
|
||||
|
||||
public static int L(FontRenderer fontRenderer, String string, float f, float g, int i, boolean bl) {
|
||||
FontRenderer fontRenderer1 = fontRenderer;
|
||||
|
||||
try {
|
||||
return d(fontRenderer1, string, fx, g, ix, bl);
|
||||
} catch (Throwable throwable) {
|
||||
f = true;
|
||||
e = false;
|
||||
OnyxClient.LOGGER.warn("Custom GUI font stood down to the bitmap font after a failure", throwable);
|
||||
return fontRenderer1.drawString(string, fx, g, ix, bl);
|
||||
}
|
||||
}
|
||||
|
||||
private FontRendererHook() {
|
||||
}
|
||||
|
||||
public static void L() {
|
||||
fontStyle2 = null;
|
||||
fontStyle = null;
|
||||
f = false;
|
||||
}
|
||||
|
||||
public static int L(FontRenderer fontRenderer, String string) {
|
||||
FontRenderer fontRenderer1 = fontRenderer;
|
||||
if (string != null && !string.isEmpty()) {
|
||||
float fx = 0.0F;
|
||||
boolean bl = false;
|
||||
|
||||
int ix;
|
||||
for (int jx = ix = 0; jx < string.length(); jx = ++ix) {
|
||||
char c;
|
||||
if ((c = string.charAt(ix)) == 167 && ix < string.length() - 1) {
|
||||
char dx;
|
||||
if ((dx = Character.toLowerCase(string.charAt(++ix))) == 'l') {
|
||||
bl = true;
|
||||
} else if (dx == 'r' || "0123456789abcdef".indexOf(dx) >= 0) {
|
||||
bl = false;
|
||||
}
|
||||
} else {
|
||||
fx += L(c) ? L(c) : L(fontRenderer1, c) + L();
|
||||
if (bl) {
|
||||
fx += fontRenderer1.offsetBold;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Math.round(fx);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private static void L(float f, float g, float h, int i) {
|
||||
GlStateManager.disableTexture2D();
|
||||
GL11.glColor4f((ix >> 16 & 0xFF) / 255.0F, (ix >> 8 & 0xFF) / 255.0F, (ix & 0xFF) / 255.0F, (ix >>> 24) / 255.0F);
|
||||
GL11.glBegin(7);
|
||||
GL11.glVertex2f(fx, g);
|
||||
GL11.glVertex2f(fx, g + 1.0F);
|
||||
GL11.glVertex2f(fx + h, g + 1.0F);
|
||||
GL11.glVertex2f(fx + h, g);
|
||||
GL11.glEnd();
|
||||
GlStateManager.enableTexture2D();
|
||||
}
|
||||
|
||||
private static int L(int i) {
|
||||
return ix & 0xFF000000 | (ix & 16579836) >> 2;
|
||||
}
|
||||
|
||||
public static boolean d() {
|
||||
CustomGui customGui;
|
||||
return !f && !e && CustomGuiState.l() ? (customGui = CustomGuiState.L()) != null && customGui.isEnabled() && customGui.customGuiPart5.isEnabled() : false;
|
||||
}
|
||||
|
||||
private static float L(FontRenderer fontRenderer) {
|
||||
return fontRenderer.offsetBold;
|
||||
}
|
||||
|
||||
private static void L(GlyphFont glyphFont, char c, float f, float g, float h, int i, boolean bl) {
|
||||
GlyphFontData glyphFontData;
|
||||
if (!(glyphFontData = glyphFont.d(c)).L()) {
|
||||
int jx;
|
||||
if ((jx = glyphFont.L()) != -1) {
|
||||
GlStateManager.bindTexture(jx);
|
||||
GL11.glColor4f((ix >> 16 & 0xFF) / 255.0F, (ix >> 8 & 0xFF) / 255.0F, (ix & 0xFF) / 255.0F, (ix >>> 24) / 255.0F);
|
||||
fx += glyphFontData.bearingX() * h;
|
||||
float lx = g + 7.0F + glyphFontData.bearingY() * h;
|
||||
float n = fx + glyphFontData.width() * h;
|
||||
h = lx + glyphFontData.height() * h;
|
||||
float k = bl ? (g + 7.0F - lx) * 0.2F : 0.0F;
|
||||
float mx = bl ? (g + 7.0F - h) * 0.2F : 0.0F;
|
||||
GL11.glBegin(7);
|
||||
GL11.glTexCoord2f(glyphFontData.u0(), glyphFontData.v0());
|
||||
GL11.glVertex2f(fx + k, lx);
|
||||
GL11.glTexCoord2f(glyphFontData.u0(), glyphFontData.v1());
|
||||
GL11.glVertex2f(fx + mx, h);
|
||||
GL11.glTexCoord2f(glyphFontData.u1(), glyphFontData.v1());
|
||||
GL11.glVertex2f(n + mx, h);
|
||||
GL11.glTexCoord2f(glyphFontData.u1(), glyphFontData.v0());
|
||||
GL11.glVertex2f(n + k, lx);
|
||||
GL11.glEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean L() {
|
||||
CustomGui customGui;
|
||||
return (customGui = CustomGuiState.L()) == null || customGui.customGuiPart5.shadow.isEnabled();
|
||||
}
|
||||
|
||||
private static FontStyle L(TargetHudTextSettingsWeightMode targetHudTextSettingsWeightMode, float f) {
|
||||
TargetHudTextSettingsWeightMode targetHudTextSettingsWeightMode1 = targetHudTextSettingsWeightModex;
|
||||
FontFamilyMode fontFamilyMode = FontFamilyMode.PT24;
|
||||
float g;
|
||||
float h = (g = FontFamily.L(FontFamilyMode.PT24, targetHudTextSettingsWeightMode1).d() / fontFamilyMode.L()) > 0.0F ? 7.0F / g : fontFamilyMode.L();
|
||||
return new FontStyle(fontFamilyMode, targetHudTextSettingsWeightMode1, h * fx, 9.0F);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user