package speiger.src.coreengine.rendering.gui.font;

import speiger.src.coreengine.assets.AssetLocation;

public record FontStyle(AssetLocation font, int style, float size) {
	public static final FontStyle DEFAULT = new FontStyle(AssetLocation.of("default"), 0, 16F);
	public static final int REGULAR = 0;
	public static final int BOLD = 1;
	public static final int ITALIC = 2;
	public static final int BOLD_ITCALIC = 3;
	
	public FontStyle {
		if(style < 0 || style > 3) throw new IllegalArgumentException("Style can only be between 0-3. Style found: "+style);
	}
	
	public FontStyle(AssetLocation font, float size) {
		this(font, REGULAR, size);
	}
	
	public FontStyle(AssetLocation font, boolean bold, boolean italic, float size) {
		this(font, (bold ? BOLD : 0) | (italic ? ITALIC : 0), size);
	}
	
	public FontStyle with(AssetLocation font, int style, float size) {
		return new FontStyle(font, style, size);
	}
	
	public FontStyle with(AssetLocation font, float size) {
		return new FontStyle(font, style, size);
	}
	
	public FontStyle with(AssetLocation font) {
		return new FontStyle(font, style, size);
	}
	
	public FontStyle with(float size) {
		return new FontStyle(font, style, size);
	}
	
	public FontStyle with(int style) {
		return new FontStyle(font, style, size);
	}
	
	public FontStyle withBold(boolean bold) {
		return new FontStyle(font, bold ? (style | BOLD) : (style & ~BOLD), size);
	}
	
	public FontStyle withItalic(boolean italic) {
		return new FontStyle(font, italic ? (style | ITALIC) : (style & ~ITALIC), size);
	}
	
	public boolean bold() {
		return (style() & BOLD) != 0;
	}
	
	public boolean italic() {
		return (style() & ITALIC) != 0;
	}
}