<commit_before><commit_msg>Add scalable checkbox button<commit_after>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 positionFactor = 1 / scale;
			
			final float xStart = (x + 24) * positionFactor;
			final float yStart = (y + ((int) (height - 8 * scale)) / 2) * positionFactor;
			
			matrixStack.push();
			matrixStack.scale(scale, scale, 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;
	}
}
{'fraction_non_alphanumeric': 0.09785804283914322, 'fraction_numerical': 0.005459890802183957, 'mean_word_length': 5.139175257731959, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2407818', 'n_tokens_mistral': 800, 'n_tokens_neox': 733, 'n_words': 221}