package sl.steeldood.bit.client.theme.impl.notheme;

import org.lwjgl.input.Mouse;
import sl.steeldood.bit.client.gui.Component;
import sl.steeldood.bit.client.gui.TessRenderUtil;
import sl.steeldood.bit.client.gui.components.ButtonComponent;
import sl.steeldood.bit.client.theme.IThemeComponent;
import sl.steeldood.bit.client.utils.render.ColorBuilder;
import sl.steeldood.bit.client.utils.math.VectorUtil;
import sl.steeldood.bit.client.utils.module.Wrapper;
import sl.steeldood.bit.client.utils.render.ColorUtil;

/**
 * @author steeldood Created: 24. 06. 2017 at 16:15
 */
public class NoThemeButtonComponent implements IThemeComponent {

    @Override
    public void render(float mouseX, float mouseY, boolean mouseOver, VectorUtil position, VectorUtil size, Object... payload) {
        String title = (String) payload[0];
        int alpha = (int) payload[1];
        boolean color = (boolean) payload[2];
        boolean centered = (boolean) payload[3];

        if (mouseOver)
            TessRenderUtil.drawRect(position.getX() + (centered ? 15 + 18 - 1 : 6), position.getY() + 3.5f,
                    (float) (position.getX() + (centered ? 15 + 18 : 6) + Wrapper.getStringWidth(title) / 2
                            + 3),
                    position.getY() + size.getY() + 1,
                    new ColorBuilder(20, 20, 20, 145).build_hex());

        TessRenderUtil.drawBorderedRect(position.getX() + (centered ? 15 + 18 : 6) - 1, position.getY() + 3.5f,
                (float) (position.getX() + (centered ? 15 + 18 : 6) + Wrapper.getStringWidth(title) / 2
                        + 3),
                position.getY() + size.getY() + 1, Mouse.isButtonDown(0) && mouseOver ? 0.8f : 0.6f,
                new ColorBuilder(20, 20, 20, 145).build_hex(), new ColorBuilder(255, 255, 255, alpha).build_hex());


        Wrapper.drawStringWithShadow_scaled(title, (int) (position.getX() + (centered ? 15 + 18 : 6) + 1),
                (int) (position.getY() + 6), color ? ColorUtil.getClientColor() : -1, 0.5);
    }

    @Override
    public Class<? extends Component> getComponentClass() {
        return ButtonComponent.class;
    }

}