mirror of
https://github.com/tobspr/shapez.io.git
synced 2024-10-27 20:34:29 +00:00
Refactor dialog buttons
This commit is contained in:
parent
76fb637606
commit
b1fce1b115
@ -365,23 +365,18 @@ export class DialogWithForm extends Dialog {
|
||||
* @param {Application} param0.app
|
||||
* @param {string} param0.title
|
||||
* @param {string} param0.desc
|
||||
* @param {string=} param0.confirmButton
|
||||
* @param {array=} param0.buttons
|
||||
* @param {string=} param0.confirmButtonId
|
||||
* @param {string=} param0.extraButton
|
||||
* @param {Array<FormElement>} param0.formElements
|
||||
*/
|
||||
constructor({ app, title, desc, formElements, confirmButton = "ok:good", extraButton = null }) {
|
||||
constructor({ app, title, desc, formElements, buttons = ["cancel", "ok:good"], confirmButtonId = "ok" }) {
|
||||
let html = "";
|
||||
html += desc + "<br>";
|
||||
for (let i = 0; i < formElements.length; ++i) {
|
||||
html += formElements[i].getHtml();
|
||||
}
|
||||
|
||||
let buttons = null;
|
||||
if (extraButton) {
|
||||
buttons = [extraButton, "cancel", confirmButton];
|
||||
} else {
|
||||
buttons = ["cancel", confirmButton];
|
||||
}
|
||||
super({
|
||||
app,
|
||||
title: title,
|
||||
@ -390,10 +385,10 @@ export class DialogWithForm extends Dialog {
|
||||
type: "info",
|
||||
closeButton: true,
|
||||
});
|
||||
this.confirmButtonId = confirmButton.split(":")[0];
|
||||
this.confirmButtonId = confirmButtonId;
|
||||
this.formElements = formElements;
|
||||
|
||||
this.enterHandler = "ok";
|
||||
this.enterHandler = confirmButtonId;
|
||||
}
|
||||
|
||||
internalButtonHandler(id, ...payload) {
|
||||
|
@ -303,7 +303,7 @@ export class HUDWaypoints extends BaseHUDPart {
|
||||
title: T.dialogs.editMarker.title,
|
||||
desc: T.dialogs.editMarker.desc,
|
||||
formElements: [markerNameInput],
|
||||
extraButton: "delete:bad",
|
||||
buttons: ["delete:bad", "cancel", "ok:good"],
|
||||
});
|
||||
this.root.hud.parts.dialogs.internalShowDialog(dialog);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user