package info.u_team.u_team_core.gui.elements;

import com.mojang.blaze3d.matrix.MatrixStack;

import info.u_team.u_team_core.api.gui.*;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.util.text.ITextComponent;

public class ScalableCheckboxButton extends CheckboxButton implements IScaleable, IScaleProvider {
	
	protected float scale;
	
	public ScalableCheckboxButton(int x, int y, int width, int height, ITextComponent text, boolean checked, boolean drawText, float scale) {
		this(x, y, width, height, text, checked, drawText, scale, EMTPY_PRESSABLE);
	}
	
	public ScalableCheckboxButton(int x, int y, int width, int height, ITextComponent text, boolean checked, boolean drawText, float scale, IPressable pessable) {
		this(x, y, width, height, text, checked, drawText, scale, pessable, EMPTY_TOOLTIP);
	}
	
	public ScalableCheckboxButton(int x, int y, int width, int height, ITextComponent text, boolean checked, boolean drawText, float scale, ITooltip tooltip) {
		this(x, y, width, height, text, checked, drawText, scale, EMTPY_PRESSABLE, tooltip);
	}
	
	public ScalableCheckboxButton(int x, int y, int width, int height, ITextComponent text, boolean checked, boolean drawText, float scale, IPressable pessable, ITooltip tooltip) {
		super(x, y, width, height, text, checked, drawText, pessable, tooltip);
		this.scale = scale;
	}
	
	@Override
	public float getScale() {
		return scale;
	}
	
	@Override
	public void setScale(float scale) {
		this.scale = scale;
	}
	
	@Override
	public void renderForeground(MatrixStack matrixStack, Minecraft minecraft, int mouseX, int mouseY, float partialTicks) {
		if (drawText) {
			final FontRenderer fontRenderer = minecraft.fontRenderer;
			
			final float currentScale = getCurrentScale(matrixStack, mouseX, mouseY, partialTicks);
			
			final float positionFactor = 1 / currentScale;
			
			final float xStart = (x + 24) * positionFactor;
			final float yStart = (y + ((int) (height - 8 * currentScale)) / 2) * positionFactor;
			
			matrixStack.push();
			matrixStack.scale(currentScale, currentScale, 0);
			fontRenderer.func_243246_a(matrixStack, getCurrentText(), xStart, yStart, getCurrentTextColor(matrixStack, mouseX, mouseY, partialTicks).getColorARGB());
			matrixStack.pop();
		}
	}
	
	@Override
	public float getCurrentScale(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
		return scale;
	}
}

@@ -245,30 +245,17 @@
 il.text.
-ITextComponent
+*
 ;%0A%0Apubli
@@ -1723,24 +1723,124 @@
 nderer;%0A%09%09%09%0A
+%09%09%09final ITextComponent message = getCurrentText();%0A%09%09%09if (message != StringTextComponent.EMPTY) %7B%0A%09
 %09%09%09final flo
@@ -1916,25 +1916,27 @@
 lTicks);%0A%09%09%09
-%0A
+%09%0A%09
 %09%09%09final flo
@@ -1972,25 +1972,27 @@
 ntScale;%0A%09%09%09
-%0A
+%09%0A%09
 %09%09%09final flo
@@ -2004,38 +2004,11 @@
 tart
- = (x + 24) * positionFactor
 ;%0A
+%09
 %09%09%09f
@@ -2094,17 +2094,310 @@
 tor;%0A%09%09%09
+%09
 %0A
+%09%09%09%09if (leftSideText) %7B%0A%09%09%09%09%09xStart = (x - (fontRenderer.getStringPropertyWidth(message) + 4)) * positionFactor;%0A%09%09%09%09%7D else %7B%0A%09%09%09%09%09xStart = (x + width + 4) * positionFactor;%0A%09%09%09%09%7D%0A%09%09%09%09%0A%09%09%09%09final int color = getCurrentTextColor(matrixStack, mouseX, mouseY, partialTicks).getColorARGB();%0A%09%09%09%09%0A%09
 %09%09%09matri
@@ -2411,16 +2411,17 @@
 push();%0A
+%09
 %09%09%09matri
@@ -2465,16 +2465,45 @@
 le, 0);%0A
+%09%09%09%09%0A%09%09%09%09if (dropShadow) %7B%0A%09%09
 %09%09%09fontR
@@ -2575,88 +2575,128 @@
 rt, 
-getCurrentTextColor(matrixStack, mouseX, mouseY, partialTicks).getColorARGB());%0A
+color);%0A%09%09%09%09%7D else %7B%0A%09%09%09%09%09fontRenderer.func_243248_b(matrixStack, getCurrentText(), xStart, yStart, color);%0A%09%09%09%09%7D%0A%09%09%09%09%0A%09
 %09%09%09m
@@ -2713,16 +2713,21 @@
 .pop();%0A
+%09%09%09%7D%0A
 %09%09%7D%0A%09%7D%0A%09

Update scalable text button