package projectzombie.menu.gui;

import gl_engine.matrix.Matrix4;
import gl_engine.vec.Vec2d;
import gl_engine.vec.Vec3d;
import projectzombie.text.Text;

public class GUILabel implements GUIComponent
{
	private Vec2d pos = new Vec2d(0, 0);
	private Vec2d size = new Vec2d(0.5, 0.5);
	private String text = "";
	private GUIAlignment alignment = GUIAlignment.CENTRE;
	
	public void setText(String text) {
		this.text = text;
	}
	
	public void setPos(Vec2d pos) {
		this.pos = pos;
	}
	
	public void setSize(Vec2d size) {
		this.size = size;
	}
	
	public void setAlign(GUIAlignment alignment) {
		this.alignment = alignment;
	}

	@Override
	public void render(Matrix4 matrix, Vec2d mousePos, boolean canHover)
	{
		double off = 0;
		
		switch(alignment)
		{
		case LEFT:
			off = size.x * text.length();
			break;
		case CENTRE:
			off = size.x * text.length() / 2;
			break;
		default:
			break;
		}
		
		matrix = Matrix4.multiply(matrix, Matrix4.scale(new Vec3d(size, 1)));
		matrix = Matrix4.multiply(matrix, Matrix4.translate(pos.x - off, pos.y, 1));
		
		Text.render(text, matrix);
	}

	@Override
	public boolean checkMouseHover(Vec2d pos) {
		return false;
	}

	@Override
	public void onMouseClick(Vec2d pos) {
	}
	
	@Override
	public void onBack() {
	}
	
	@Override
	public void onActivate() {
	}
	
	@Override
	public void update(Vec2d mousePos) {
	}
	
	@Override
	public void onRightClick(Vec2d pos) {
	}
	
	@Override
	public void onScroll(Vec2d mousePos, double amount) {
	}

}
