package im.expensive.ui.display.impl;
import com.mojang.blaze3d.matrix.MatrixStack;
import im.expensive.Expensive;
import im.expensive.events.EventDisplay;
import im.expensive.ui.display.ElementRenderer;
import im.expensive.ui.styles.Style;
import im.expensive.utils.render.ColorUtils;
import im.expensive.utils.render.DisplayUtils;
import im.expensive.utils.render.KawaseBlur;
import im.expensive.utils.render.font.Fonts;
import im.expensive.utils.text.GradientUtil;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
import lombok.experimental.FieldDefaults;
import net.minecraft.client.Minecraft;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.ITextComponent;
import java.text.SimpleDateFormat;
import java.util.Date;
@FieldDefaults(level = AccessLevel.PRIVATE)
@RequiredArgsConstructor
public class WatermarkRenderer implements ElementRenderer {
final Minecraft mc = Minecraft.getInstance();
final ResourceLocation logo = new ResourceLocation("expensive/images/hud/logo.png");
final ResourceLocation user = new ResourceLocation("expensive/images/hud/user.png");
//final ResourceLocation timeIcon = new ResourceLocation("expensive/images/hud/time.png");
final ResourceLocation fpsIcon = new ResourceLocation("expensive/images/hud/graph.png");
@Override
public void render(EventDisplay eventDisplay) {
MatrixStack ms = eventDisplay.getMatrixStack();
float posX = 5;
float posY = 4;
float padding = 5;
float fontSize = 7.0f;
float iconSize = 10;
float posX1 = 65;
float posY1 = 4;
final ITextComponent text = GradientUtil.gradient("Alpha");
Style style = Expensive.getInstance().getStyleManager().getCurrentStyle();
drawStyledRect(posX * 1.6f, posY, iconSize + padding * 7.0f, iconSize + padding * 0.8f, 2);
DisplayUtils.drawImage(logo, posX * 1.0f + padding, posY * 0.07f + padding, iconSize, iconSize, ColorUtils.getColor(0));
DisplayUtils.drawRectVerticalW(posX + 16.5f, posY + 2, 1.9f, 10.0f, 3, ColorUtils.rgba(69, 69, 69, (int) (255 * 0.75f)));
Fonts.sfbold.drawCenteredText(ms, text, posX + 31.5f, posY + 3.80f, fontSize);
final ITextComponent timeText = GradientUtil.white("deddelal");
float timeTextWidth = Fonts.sfbold.getWidth(timeText, fontSize);
float userPosX = posX1;
drawStyledRect(userPosX * 0.95f, posY1, iconSize + padding * 9.3f + timeTextWidth, iconSize + padding * 0.8f, 2);
DisplayUtils.drawImage(user, userPosX * 0.90f + padding, posY1 * 0.07f + padding, iconSize, iconSize, ColorUtils.getColor(0));
DisplayUtils.drawRectVerticalW(posX + 70.0f, posY + 2, 1.9, 10.0f, 3, ColorUtils.rgba(69, 69, 69, (int) (255 * 0.75f)));
Fonts.sfbold.drawText(ms, timeText, userPosX * 0.97f + iconSize + padding * 1, posY1 * 0.17f + iconSize / 2 + 1.5f, fontSize, 255);
int fps = mc.getDebugFPS();
ITextComponent fpsText = GradientUtil.white(String.valueOf(fps));
float fpsTextWidth = Fonts.sfbold.getWidth(fpsText, fontSize);
float fpsPosX = posX + iconSize + padding * 3;
if (fps >= 100 && fps <= 999) {
posX1 += 5;
}
DisplayUtils.drawImage(fpsIcon, fpsPosX * 3.81f + padding, posY * 0.07f + padding, iconSize, iconSize, ColorUtils.getColor(0));
DisplayUtils.drawRectVerticalW(posX + 112.0f, posY + 2, 1.9, 10.0f, 3, ColorUtils.rgba(69, 69, 69, (int) (255 * 0.75f)));
Fonts.sfbold.drawText(ms, fpsText, fpsPosX * 3.85f + iconSize + padding * 1.5f, posY * 0.17f + iconSize / 2 + 1.5f, fontSize, 255);
}
private void drawStyledRect(float x, float y, float width, float height, float radius) {
// DisplayUtils.drawRoundedRect(x - 0.5f, y - 0.5f, width + 1, height + 1, radius + 0.5f, ColorUtils.getColor(0)); // outline
DisplayUtils.drawRoundedRect(x, y, width, height, radius, ColorUtils.rgba(12, 12, 12, 225));
}
}