use of pl.asie.charset.module.tablet.format.words.StyleColor in project Charset by CharsetMC.
the class CommandURLMissing method call.
@Override
public void call(ITypesetter typesetter, ITokenizer tokenizer) throws TruthError {
String content = tokenizer.getParameter("\\urlmissing missing parameter: content");
try {
typesetter.pushStyle(new StyleColor(0xFFCC3333), StyleFormat.ITALIC, StyleFormat.UNDERLINE);
typesetter.write(new WordText(content));
typesetter.popStyle(3);
} catch (Exception e) {
e.printStackTrace();
throw new TruthError(e.getMessage());
}
}
use of pl.asie.charset.module.tablet.format.words.StyleColor 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