package dev.crucifixbeta.mod.modules.impl.render;

import dev.crucifixbeta.api.utils.render.Render2DUtil;
import dev.crucifixbeta.mod.modules.Module;
import dev.crucifixbeta.mod.modules.settings.impl.ColorSetting;
import dev.crucifixbeta.mod.modules.settings.impl.SliderSetting;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.util.math.MatrixStack;

@Environment(EnvType.CLIENT)
public class Crosshair extends Module {
   public static Crosshair INSTANCE;
   public final SliderSetting length = this.add(new SliderSetting("Length", 1.4, 0.0, 20.0, 0.1));
   public final SliderSetting thickness = this.add(new SliderSetting("Thickness", 0.8, 0.0, 20.0, 0.1));
   public final SliderSetting interval = this.add(new SliderSetting("Interval", 1.0, 0.0, 20.0, 0.1));
   private final ColorSetting color = this.add(new ColorSetting("Color"));

   public Crosshair() {
      super("Crosshair", Module.Category.Render);
      this.setChinese("\u51c6\u661f");
      INSTANCE = this;
   }

   public void draw(DrawContext context) {
      MatrixStack var2 = context.getMatrices();
      float var3 = (float)mc.getWindow().getScaledWidth() / 2.0F;
      float var4 = (float)mc.getWindow().getScaledHeight() / 2.0F;
      Render2DUtil.drawRect(
         var2,
         var3 - this.thickness.getValueFloat() / 2.0F,
         var4 - this.length.getValueFloat() - this.interval.getValueFloat(),
         this.thickness.getValueFloat(),
         this.length.getValueFloat(),
         this.color.getValue()
      );
      Render2DUtil.drawRect(
         var2,
         var3 - this.thickness.getValueFloat() / 2.0F,
         var4 + this.interval.getValueFloat(),
         this.thickness.getValueFloat(),
         this.length.getValueFloat(),
         this.color.getValue()
      );
      Render2DUtil.drawRect(
         var2,
         var3 + this.interval.getValueFloat(),
         var4 - this.thickness.getValueFloat() / 2.0F,
         this.length.getValueFloat(),
         this.thickness.getValueFloat(),
         this.color.getValue()
      );
      Render2DUtil.drawRect(
         var2,
         var3 - this.interval.getValueFloat() - this.length.getValueFloat(),
         var4 - this.thickness.getValueFloat() / 2.0F,
         this.length.getValueFloat(),
         this.thickness.getValueFloat(),
         this.color.getValue()
      );
   }
}
