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);
}
}
}
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;
}
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);
}
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();
}
}
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);
}
}
Aggregations