use of pl.asie.charset.module.tablet.format.api.IStyle in project Charset by CharsetMC.
the class WordPrinterMCURL method draw.
@Override
public void draw(IPrintingContextMinecraft context, WordText word, int x, int y, boolean isHovering) {
StringBuilder s = new StringBuilder(word.getText());
int color = 0xFF3333CC;
float scale = 1.0f;
for (IStyle style : context.getStyleList()) {
if (style instanceof StyleFormat) {
s.insert(0, ((StyleFormat) style).getMcPrefix());
} else if (style instanceof StyleColor) {
color = 0xFF000000 | ((StyleColor) style).color;
} else if (style instanceof StyleScale) {
scale *= ((StyleScale) style).scale;
}
}
s.insert(0, TextFormatting.UNDERLINE);
if (scale == 1.0f) {
context.getFontRenderer().drawString(s.toString(), x, y, color);
} else {
GlStateManager.pushMatrix();
GlStateManager.translate(x, y, 0);
GlStateManager.scale(scale, scale, scale);
context.getFontRenderer().drawString(s.toString(), 0, 0, color);
GlStateManager.popMatrix();
}
}
use of pl.asie.charset.module.tablet.format.api.IStyle in project Charset by CharsetMC.
the class WordPrinterMCText method getWidth.
@Override
public int getWidth(IPrintingContextMinecraft context, WordText word) {
StringBuilder s = new StringBuilder(word.getText());
float scale = 1.0f;
for (IStyle style : context.getStyleList()) {
if (style instanceof StyleFormat) {
s.insert(0, ((StyleFormat) style).getMcPrefix());
} else if (style instanceof StyleScale) {
scale *= ((StyleScale) style).scale;
}
}
return (int) Math.ceil(context.getFontRenderer().getStringWidth(s.toString()) * scale);
}
use of pl.asie.charset.module.tablet.format.api.IStyle in project Charset by CharsetMC.
the class WordPrinterMCText method draw.
@Override
public void draw(IPrintingContextMinecraft context, WordText word, int x, int y, boolean isHovering) {
StringBuilder s = new StringBuilder(word.getText());
float scale = 1.0f;
int color = 0xFF000000;
for (IStyle style : context.getStyleList()) {
if (style instanceof StyleFormat) {
s.insert(0, ((StyleFormat) style).getMcPrefix());
} else if (style instanceof StyleColor) {
color = 0xFF000000 | ((StyleColor) style).color;
} else if (style instanceof StyleScale) {
scale *= ((StyleScale) style).scale;
}
}
if (scale == 1.0f) {
context.getFontRenderer().drawString(s.toString(), x, y, color);
} else {
GlStateManager.pushMatrix();
GlStateManager.translate(x, y, 0);
GlStateManager.scale(scale, scale, scale);
context.getFontRenderer().drawString(s.toString(), 0, 0, color);
GlStateManager.popMatrix();
}
}
Aggregations