1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2026-02-12 10:59:23 +00:00

Implemented /kb_enter and /kb_escape on Dialogs

Added this to default values for "showInfo" method
Added this to "Delete" & "Cut" confirmation dialogs
This commit is contained in:
Andifaind 2020-06-17 18:36:46 -03:00
parent d6c1cb15f6
commit 23bc7ca9e7
3 changed files with 14 additions and 7 deletions

View File

@ -50,6 +50,8 @@ export class Dialog {
this.closeRequested = new Signal();
this.buttonSignals = {};
this.enterHandler = null;
this.escapeHandler = null;
for (let i = 0; i < buttons.length; ++i) {
if (G_IS_DEV && globalConfig.debug.disableTimedButtons) {
@ -58,6 +60,14 @@ export class Dialog {
const buttonId = this.buttonIds[i].split(":")[0];
this.buttonSignals[buttonId] = new Signal();
if (this.buttonIds[i].indexOf("/kb_enter") >= 0) {
this.enterHandler = buttonId;
this.buttonIds[i] = this.buttonIds[i].replace("/kb_enter", "");
}
if (this.buttonIds[i].indexOf("/kb_escape") >= 0) {
this.escapeHandler = buttonId;
this.buttonIds[i] = this.buttonIds[i].replace("/kb_escape", "");
}
}
this.timeouts = [];
@ -66,9 +76,6 @@ export class Dialog {
this.inputReciever = new InputReceiver("dialog-" + this.title);
this.inputReciever.keydown.add(this.handleKeydown, this);
this.enterHandler = null;
this.escapeHandler = null;
}
/**
@ -297,7 +304,7 @@ export class DialogOptionChooser extends Dialog {
<div class='option ${value === options.active ? "active" : ""} ${
iconPrefix ? "hasIcon" : ""
}' data-optionvalue='${value}'>
${iconHtml}
${iconHtml}
<span class='title'>${text}</span>
${descHtml}
</div>

View File

@ -91,7 +91,7 @@ export class HUDMassSelector extends BaseHUDPart {
"<count>",
"" + formatBigNumberFull(this.selectedUids.size)
),
["cancel:good", "ok:bad"]
["cancel:good/kb_escape", "ok:bad/kb_enter"]
);
ok.add(() => this.doDelete());
} else {
@ -141,7 +141,7 @@ export class HUDMassSelector extends BaseHUDPart {
"<count>",
"" + formatBigNumberFull(this.selectedUids.size)
),
["cancel:good", "ok:bad"]
["cancel:good/kb_escape", "ok:bad/kb_enter"]
);
ok.add(() => this.doCut());
} else {

View File

@ -53,7 +53,7 @@ export class HUDModalDialogs extends BaseHUDPart {
* @param {string} text
* @param {Array<string>} buttons
*/
showInfo(title, text, buttons = ["ok:good"]) {
showInfo(title, text, buttons = ["ok:good/kb_enter/kb_escape"]) {
const dialog = new Dialog({
app: this.app,
title: title,