Search in sources :

Example 1 with StyleColor

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());
    }
}
Also used : TruthError(pl.asie.charset.module.tablet.format.api.TruthError) StyleColor(pl.asie.charset.module.tablet.format.words.StyleColor) WordText(pl.asie.charset.module.tablet.format.words.WordText)

Example 2 with StyleColor

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();
    }
}
Also used : IStyle(pl.asie.charset.module.tablet.format.api.IStyle) StyleScale(pl.asie.charset.module.tablet.format.words.StyleScale) StyleFormat(pl.asie.charset.module.tablet.format.words.StyleFormat) StyleColor(pl.asie.charset.module.tablet.format.words.StyleColor)

Aggregations

StyleColor (pl.asie.charset.module.tablet.format.words.StyleColor)2 IStyle (pl.asie.charset.module.tablet.format.api.IStyle)1 TruthError (pl.asie.charset.module.tablet.format.api.TruthError)1 StyleFormat (pl.asie.charset.module.tablet.format.words.StyleFormat)1 StyleScale (pl.asie.charset.module.tablet.format.words.StyleScale)1 WordText (pl.asie.charset.module.tablet.format.words.WordText)1