package client.gui.element;

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

public class MultiLabel extends Fill {
	protected String[] lines;
	
	public MultiLabel(int x, int y, int w, int h, String text, boolean top) {
		super(x, y, w, h, text, top, true);
	}
	
	public MultiLabel(int x, int y, int w, int h, String text) {
		super(x, y, w, h, text, false, true);
	}
	
	protected MultiLabel(int x, int y, int w, int h, boolean top) {
		super(x, y, w, h, top, true);
	}
	
	public void setText(String str) {
		super.setText(str);
		this.lines = str.split("\n", -1);
	}

	protected void drawBackground() {
	}
	
	protected void drawForeground(int x1, int y1, int x2, int y2) {
		int color = this.enabled ? this.gm.style.text_label : Util.mulColor(this.gm.style.text_label, 0.5f);
		for(int z = 0; z < this.lines.length; z++) {
			Drawing.drawTextCentered(this.lines[z], x1 + x2 / 2, y1 + this.text_y + z * Font.HEIGHT, color);
		}
	}
	
	protected int getMarginX() {
		return 0;
	}
	
	protected int getMarginY() {
		return 0;
	}
}
