2025-03-11 00:23:54 +01:00
|
|
|
package game.gui;
|
|
|
|
|
2025-03-11 10:26:48 +01:00
|
|
|
import game.gui.element.ActButton;
|
2025-03-16 17:45:08 +01:00
|
|
|
import game.gui.element.ActButton.Mode;
|
2025-03-11 10:26:48 +01:00
|
|
|
import game.gui.element.Label;
|
2025-03-20 11:32:45 +01:00
|
|
|
import game.gui.element.TransparentBox;
|
2025-03-11 00:23:54 +01:00
|
|
|
|
|
|
|
public class GuiConfirm extends Gui implements ActButton.Callback {
|
|
|
|
public static interface Callback {
|
|
|
|
void confirm(boolean confirmed);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected Callback callback;
|
|
|
|
protected String messageLine1;
|
|
|
|
private String messageLine2;
|
|
|
|
protected String confirmButtonText;
|
|
|
|
protected 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, 500, 24, this.messageLine1, true));
|
2025-03-20 11:32:45 +01:00
|
|
|
this.add(new TransparentBox(0, 80, 500, 300, this.messageLine2));
|
2025-03-11 00:23:54 +01:00
|
|
|
this.confirmBtn = this.add(new ActButton(48, 500, 200, 24, (ActButton.Callback)this, this.confirmButtonText));
|
|
|
|
this.cancelBtn = this.add(new ActButton(252, 500, 200, 24, (ActButton.Callback)this, this.cancelButtonText));
|
|
|
|
this.shift();
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getTitle() {
|
|
|
|
return "Aktion bestätigen";
|
|
|
|
}
|
|
|
|
|
|
|
|
public void use(ActButton btn, Mode mode) {
|
|
|
|
this.callback.confirm(btn == this.confirmBtn);
|
|
|
|
}
|
|
|
|
}
|