package wtf.opal.client.screen.click.dropdown.panel.property;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.gui.DrawContext;
import wtf.opal.client.feature.module.property.Property;
import wtf.opal.client.renderer.NVGRenderer;
import wtf.opal.client.screen.click.OpalPanelComponent;
import wtf.opal.utility.render.ColorUtility;

@Environment(EnvType.CLIENT)
public abstract class PropertyPanel<T extends Property<?>> extends OpalPanelComponent {
   private final T property;
   protected static final int DEFAULT_HEIGHT = 17;
   protected boolean lastProperty;

   public PropertyPanel(T property) {
      this.property = (T)property;
      this.setHeight(17.0F);
   }

   @Override
   public void render(DrawContext context, int mouseX, int mouseY, float delta) {
      if (this.lastProperty) {
         NVGRenderer.roundedRectVarying(
            this.x, this.y, this.width, this.height, 0.0F, 0.0F, 5.0F, 5.0F, ColorUtility.scaleOpacity(ColorUtility.getPanelBackgroundColor(), 0.25F)
         );
      } else {
         NVGRenderer.rect(this.x, this.y, this.width, this.height, ColorUtility.scaleOpacity(ColorUtility.getPanelBackgroundColor(), 0.25F));
      }
   }

   public T getProperty() {
      return this.property;
   }

   public boolean isHidden() {
      return this.property.isHidden();
   }
}
