use of me.jellysquid.mods.sodium.client.gui.options.OptionImpact in project reeses-sodium-options by FlashyReese.
the class OptionPageScrollFrame method renderOptionTooltip.
private void renderOptionTooltip(MatrixStack matrixStack, int mouseX, int mouseY, ControlElement<?> element) {
if (this.lastTime + 500 > System.currentTimeMillis())
return;
Dim2i dim = element.getDimensions();
int textPadding = 3;
int boxPadding = 3;
int boxWidth = dim.width();
// Offset based on mouse position, width and height of content and width and height of the window
int boxY = dim.getLimitY();
int boxX = dim.x();
Option<?> option = element.getOption();
List<OrderedText> tooltip = new ArrayList<>(MinecraftClient.getInstance().textRenderer.wrapLines(option.getTooltip(), boxWidth - (textPadding * 2)));
OptionImpact impact = option.getImpact();
if (impact != null) {
tooltip.add(Language.getInstance().reorder(new TranslatableText("sodium.options.performance_impact_string", impact.getLocalizedName()).formatted(Formatting.GRAY)));
}
int boxHeight = (tooltip.size() * 12) + boxPadding;
int boxYLimit = boxY + boxHeight;
int boxYCutoff = this.dim.getLimitY();
// If the box is going to be cutoff on the Y-axis, move it back up the difference
if (boxYLimit > boxYCutoff) {
boxY -= boxHeight + dim.height();
}
if (boxY < 0) {
boxY = dim.getLimitY();
}
this.drawRect(boxX, boxY, boxX + boxWidth, boxY + boxHeight, 0xE0000000);
this.drawRectOutline(boxX, boxY, boxX + boxWidth, boxY + boxHeight, 0xFF94E4D3);
for (int i = 0; i < tooltip.size(); i++) {
MinecraftClient.getInstance().textRenderer.draw(matrixStack, tooltip.get(i), boxX + textPadding, boxY + textPadding + (i * 12), 0xFFFFFFFF);
}
}
Aggregations