package client.gui.element;

import client.gui.Font;
import client.renderer.Drawing;
import common.util.Util;

public class DisplayLabel extends MultiLabel {
	private final Font font;
	
	public DisplayLabel(int x, int y, int w, int lines, Font font, String text) {
		super(x, y, w, lines * font.getHeight() + 2, true);
		this.font = font;
		this.setText(text);
	}

	protected void drawBackground() {
		Drawing.drawRect(this.pos_x, this.pos_y, this.size_x, this.size_y, 0xff000000, this.gm.style.brdr_btm, this.gm.style.brdr_top);
	}
	
	protected void drawForeground(int x1, int y1, int x2, int y2) {
		Font.set(this.font);
		for(int z = 0; z < this.lines.length; z++) {
			Drawing.drawText(z == this.lines.length - 1 && Util.ftime() % 1.0f < 0.5f ? this.lines[z] + "_" : this.lines[z], x1, y1 + z * Font.HEIGHT, 0xff00ff00);
		}
		Font.unset();
	}
	
	public void updateText() {
		Font.set(this.font);
		super.updateText();
		Font.unset();
	}
	
	protected int getMarginX() {
		return 2;
	}
	
	protected int getMarginY() {
		return 1;
	}
}
