1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2026-02-16 21:09:22 +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.closeRequested = new Signal();
this.buttonSignals = {}; this.buttonSignals = {};
this.enterHandler = null;
this.escapeHandler = null;
for (let i = 0; i < buttons.length; ++i) { for (let i = 0; i < buttons.length; ++i) {
if (G_IS_DEV && globalConfig.debug.disableTimedButtons) { if (G_IS_DEV && globalConfig.debug.disableTimedButtons) {
@ -58,6 +60,14 @@ export class Dialog {
const buttonId = this.buttonIds[i].split(":")[0]; const buttonId = this.buttonIds[i].split(":")[0];
this.buttonSignals[buttonId] = new Signal(); 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 = []; this.timeouts = [];
@ -66,9 +76,6 @@ export class Dialog {
this.inputReciever = new InputReceiver("dialog-" + this.title); this.inputReciever = new InputReceiver("dialog-" + this.title);
this.inputReciever.keydown.add(this.handleKeydown, this); this.inputReciever.keydown.add(this.handleKeydown, this);
this.enterHandler = null;
this.escapeHandler = null;
} }
/** /**

View File

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

View File

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