46 lines
1.3 KiB
Java
46 lines
1.3 KiB
Java
![]() |
package game.gui;
|
||
|
|
||
|
import game.ActButton;
|
||
|
import game.ActButton.Mode;
|
||
|
import game.Gui;
|
||
|
import game.Label;
|
||
|
import game.Textbox;
|
||
|
|
||
|
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));
|
||
|
this.add(new Textbox(0, 80, 500, 300, this.messageLine2));
|
||
|
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);
|
||
|
}
|
||
|
}
|