package client.gui;

import client.gui.element.ActButton;
import client.gui.element.ButtonCallback;
import client.gui.element.Label;
import client.gui.element.MultiLabel;
import client.gui.element.PressType;

public class GuiConfirm extends Gui implements ButtonCallback {
	public static interface Callback {
		void confirm(boolean confirmed);
	}
	
	private final Callback callback;
	private final String messageLine1;
	private final String messageLine2;
	private final String confirmButtonText;
	private final String cancelButtonText;
	
	private ActButton confirmBtn;
	private ActButton cancelBtn;

	public GuiConfirm(Callback callback, String msg1, String msg2, String msgConfirm, String msgCancel) {
		this.callback = callback;
		this.messageLine1 = msg1;
		this.messageLine2 = msg2;
		this.confirmButtonText = msgConfirm;
		this.cancelButtonText = msgCancel;
	}

	public void init(int width, int height) {
		this.add(new Label(0, 0, 700, 0, this.messageLine1));
		this.add(new MultiLabel(0, 40, 700, 300, this.messageLine2, true));
		this.confirmBtn = this.add(new ActButton(100, 400, 245, 0, this, this.confirmButtonText));
		this.cancelBtn = this.add(new ActButton(355, 400, 245, 0, this, this.cancelButtonText));
		this.shift();
	}
	
	public String getTitle() {
		return "Aktion bestätigen";
	}

	public void use(ActButton btn, PressType mode) {
		this.callback.confirm(btn == this.confirmBtn);
	}
}
