Search in sources :

Example 21 with ITextProperties

use of net.minecraft.util.text.ITextProperties in project AstralSorcery by HellFirePvP.

the class ScreenJournalOverlayPerkStatistics method drawPageText.

private void drawPageText(MatrixStack renderStack, int mouseX, int mouseY) {
    if (nameStrWidth == -1 || valueStrWidth == -1 || suffixStrWidth == -1) {
        buildDisplayWidth();
    }
    Map<Rectangle, PerkStatistic> valueStrMap = Maps.newHashMap();
    int offsetY = guiTop + 40;
    int offsetX = guiLeft + guiWidth / 2 - DEFAULT_WIDTH / 2;
    int line = 0;
    for (PerkStatistic stat : statistics) {
        ITextProperties statName = new TranslationTextComponent(stat.getUnlocPerkTypeName());
        List<IReorderingProcessor> statistics = font.trimStringToWidth(statName, MathHelper.floor(HEADER_WIDTH / 1.5F));
        for (int i = 0; i < statistics.size(); i++) {
            IReorderingProcessor statistic = statistics.get(i);
            int drawX = offsetX;
            if (i > 0) {
                drawX += 10;
            }
            renderStack.push();
            renderStack.translate(drawX, offsetY + ((line + i) * 10), this.getGuiZLevel());
            RenderingDrawUtils.renderStringAt(statistic, renderStack, font, 0xEE333333, false);
            renderStack.pop();
        }
        renderStack.push();
        renderStack.translate(offsetX + nameStrWidth, offsetY + (line * 10), this.getGuiZLevel());
        RenderingDrawUtils.renderStringAt(new StringTextComponent(stat.getPerkValue()), renderStack, font, 0xEE333333, false);
        renderStack.pop();
        int strLength = font.getStringWidth(stat.getPerkValue());
        Rectangle rctValue = new Rectangle(offsetX + nameStrWidth, offsetY + (line * 10), strLength, 8);
        valueStrMap.put(rctValue, stat);
        line += statistics.size();
        if (!stat.getSuffix().isEmpty()) {
            renderStack.push();
            renderStack.translate(offsetX + 25, offsetY + (line * 10), this.getGuiZLevel());
            RenderingDrawUtils.renderStringAt(new StringTextComponent(stat.getSuffix()), renderStack, font, 0xEE333333, false);
            renderStack.pop();
            line++;
        }
    }
    for (Rectangle rct : valueStrMap.keySet()) {
        if (rct.contains(mouseX, mouseY)) {
            PerkStatistic stat = valueStrMap.get(rct);
            drawCalculationDescription(renderStack, rct.x + rct.width + 2, rct.y + 15, stat);
        }
    }
}
Also used : IReorderingProcessor(net.minecraft.util.IReorderingProcessor) PerkStatistic(hellfirepvp.astralsorcery.common.perk.reader.PerkStatistic) ITextProperties(net.minecraft.util.text.ITextProperties) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) StringTextComponent(net.minecraft.util.text.StringTextComponent)

Example 22 with ITextProperties

use of net.minecraft.util.text.ITextProperties in project AstralSorcery by HellFirePvP.

the class ScreenJournalOverlayPerkStatistics method buildDisplayWidth.

private void buildDisplayWidth() {
    nameStrWidth = -1;
    valueStrWidth = -1;
    suffixStrWidth = -1;
    for (PerkStatistic stat : this.statistics) {
        ITextProperties typeName = new TranslationTextComponent(stat.getUnlocPerkTypeName());
        int nameWidth = Math.min(font.getStringPropertyWidth(typeName), ((int) (HEADER_WIDTH / 1.5F)));
        int valueWidth = font.getStringWidth(stat.getPerkValue());
        int suffixWidth = font.getStringWidth(stat.getSuffix());
        if (nameWidth > nameStrWidth) {
            nameStrWidth = nameWidth;
        }
        if (valueWidth > valueStrWidth) {
            valueStrWidth = valueWidth;
        }
        if (suffixWidth > suffixStrWidth) {
            suffixStrWidth = suffixWidth;
        }
    }
    nameStrWidth += 6;
    valueStrWidth += 6;
    suffixStrWidth += 6;
}
Also used : PerkStatistic(hellfirepvp.astralsorcery.common.perk.reader.PerkStatistic) ITextProperties(net.minecraft.util.text.ITextProperties) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent)

Example 23 with ITextProperties

use of net.minecraft.util.text.ITextProperties in project AstralSorcery by HellFirePvP.

the class ScreenJournalOverlayPerkStatistics method drawCalculationDescription.

private void drawCalculationDescription(MatrixStack renderStack, int x, int y, PerkStatistic stat) {
    PerkAttributeType type = stat.getType();
    PerkAttributeReader reader = type.getReader();
    if (reader == null) {
        return;
    }
    PlayerEntity player = Minecraft.getInstance().player;
    PerkAttributeMap attrMap = PerkAttributeHelper.getOrCreateMap(player, LogicalSide.CLIENT);
    List<ITextProperties> information = Lists.newArrayList();
    information.add(new TranslationTextComponent("perk.reader.astralsorcery.description.head", PerkAttributeReader.formatDecimal(reader.getDefaultValue(attrMap, player, LogicalSide.CLIENT))));
    information.add(new TranslationTextComponent("perk.reader.astralsorcery.description.addition", PerkAttributeReader.formatDecimal(reader.getModifierValueForMode(attrMap, player, LogicalSide.CLIENT, ModifierType.ADDITION) - 1)));
    information.add(new TranslationTextComponent("perk.reader.astralsorcery.description.increase", PerkAttributeReader.formatDecimal(reader.getModifierValueForMode(attrMap, player, LogicalSide.CLIENT, ModifierType.ADDED_MULTIPLY))));
    information.add(new TranslationTextComponent("perk.reader.astralsorcery.description.moreless", PerkAttributeReader.formatDecimal(reader.getModifierValueForMode(attrMap, player, LogicalSide.CLIENT, ModifierType.STACKING_MULTIPLY))));
    if (!stat.getSuffix().isEmpty() || !stat.getPostProcessInfo().isEmpty()) {
        information.add(StringTextComponent.EMPTY);
    }
    if (!stat.getSuffix().isEmpty()) {
        information.add(new StringTextComponent(stat.getSuffix()));
    }
    if (!stat.getPostProcessInfo().isEmpty()) {
        information.add(new StringTextComponent(stat.getPostProcessInfo()));
    }
    RenderingDrawUtils.renderBlueTooltipComponents(renderStack, x, y, this.getGuiZLevel(), information, this.font, false);
}
Also used : VanillaPerkAttributeType(hellfirepvp.astralsorcery.common.perk.type.vanilla.VanillaPerkAttributeType) PerkAttributeType(hellfirepvp.astralsorcery.common.perk.type.PerkAttributeType) PerkAttributeReader(hellfirepvp.astralsorcery.common.perk.reader.PerkAttributeReader) ITextProperties(net.minecraft.util.text.ITextProperties) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) StringTextComponent(net.minecraft.util.text.StringTextComponent) PlayerEntity(net.minecraft.entity.player.PlayerEntity) PerkAttributeMap(hellfirepvp.astralsorcery.common.perk.PerkAttributeMap)

Example 24 with ITextProperties

use of net.minecraft.util.text.ITextProperties in project AstralSorcery by HellFirePvP.

the class ScreenJournalConstellationDetail method drawPagePhaseInformation.

private void drawPagePhaseInformation(MatrixStack renderStack) {
    if (this.activePhases == null) {
        this.testActivePhases();
        if (this.activePhases == null) {
            return;
        }
    }
    List<MoonPhase> phases = this.activePhases;
    if (phases.isEmpty()) {
        ITextProperties none = new TranslationTextComponent("astralsorcery.journal.constellation.unknown");
        float scale = 1.8F;
        float length = font.getStringPropertyWidth(none) * scale;
        float offsetLeft = guiLeft + 296 - length / 2;
        int offsetTop = guiTop + 199;
        renderStack.push();
        renderStack.translate(offsetLeft + 10, offsetTop, getGuiZLevel());
        renderStack.scale(scale, scale, scale);
        RenderingDrawUtils.renderStringAt(none, renderStack, font, 0xCCDDDDDD, true);
        renderStack.pop();
    } else {
        boolean known = ResearchHelper.getClientProgress().hasConstellationDiscovered(this.constellation);
        int size = 19;
        int offsetX = 95 + (width / 2) - (MoonPhase.values().length * (size + 2)) / 2;
        int offsetY = 199 + guiTop;
        RenderSystem.enableBlend();
        RenderSystem.defaultBlendFunc();
        MoonPhase[] mPhases = MoonPhase.values();
        for (int i = 0; i < mPhases.length; i++) {
            MoonPhase phase = mPhases[i];
            int index = i;
            float brightness;
            phase.getTexture().bindTexture();
            if (known && this.activePhases.contains(phase)) {
                Blending.PREALPHA.apply();
                brightness = 1F;
            } else {
                RenderSystem.defaultBlendFunc();
                brightness = 0.7F;
            }
            RenderingUtils.draw(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR_TEX, buf -> {
                RenderingGuiUtils.rect(buf, renderStack, offsetX + (index * (size + 2)), offsetY, this.getGuiZLevel(), size, size).color(brightness, brightness, brightness, brightness).draw();
            });
        }
        RenderSystem.defaultBlendFunc();
        RenderSystem.disableBlend();
    }
}
Also used : MoonPhase(hellfirepvp.astralsorcery.common.base.MoonPhase) ITextProperties(net.minecraft.util.text.ITextProperties) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent)

Example 25 with ITextProperties

use of net.minecraft.util.text.ITextProperties in project AstralSorcery by HellFirePvP.

the class ScreenJournalConstellationDetail method buildEnchText.

private void buildEnchText() {
    if (ResearchHelper.getClientProgress().getTierReached().isThisLaterOrEqual(ProgressionTier.CONSTELLATION_CRAFT)) {
        ITextComponent txtEnchantments = this.constellation.getConstellationEnchantmentDescription();
        ITextProperties headTxt = new TranslationTextComponent("astralsorcery.journal.constellation.enchantments");
        locTextRefraction.add(localize(headTxt));
        locTextRefraction.add(IReorderingProcessor.field_242232_a);
        List<IReorderingProcessor> lines = new LinkedList<>();
        for (String segment : txtEnchantments.getString().split("<NL>")) {
            lines.addAll(font.trimStringToWidth(new StringTextComponent(segment), JournalPage.DEFAULT_WIDTH));
            lines.add(IReorderingProcessor.field_242232_a);
        }
        locTextRefraction.addAll(lines);
        locTextRefraction.add(IReorderingProcessor.field_242232_a);
    }
}
Also used : IReorderingProcessor(net.minecraft.util.IReorderingProcessor) ITextProperties(net.minecraft.util.text.ITextProperties) ITextComponent(net.minecraft.util.text.ITextComponent) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) StringTextComponent(net.minecraft.util.text.StringTextComponent) LinkedList(java.util.LinkedList)

Aggregations

ITextProperties (net.minecraft.util.text.ITextProperties)36 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)19 StringTextComponent (net.minecraft.util.text.StringTextComponent)13 ArrayList (java.util.ArrayList)9 FontRenderer (net.minecraft.client.gui.FontRenderer)7 IReorderingProcessor (net.minecraft.util.IReorderingProcessor)7 List (java.util.List)6 Matrix4f (net.minecraft.util.math.vector.Matrix4f)6 IRenderTypeBuffer (net.minecraft.client.renderer.IRenderTypeBuffer)4 ITextComponent (net.minecraft.util.text.ITextComponent)4 ItemStack (net.minecraft.item.ItemStack)3 RenderTooltipEvent (net.minecraftforge.client.event.RenderTooltipEvent)3 MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)2 MoonPhase (hellfirepvp.astralsorcery.common.base.MoonPhase)2 IWeakConstellation (hellfirepvp.astralsorcery.common.constellation.IWeakConstellation)2 PerkStatistic (hellfirepvp.astralsorcery.common.perk.reader.PerkStatistic)2 LinkedList (java.util.LinkedList)2 Minecraft (net.minecraft.client.Minecraft)2 Lists (com.google.common.collect.Lists)1 LivingData (com.lying.variousoddities.capabilities.LivingData)1