From 0d406b1092ef10ad44cb8140749cf690a044751c Mon Sep 17 00:00:00 2001 From: Frederico Santos Date: Fri, 2 Aug 2024 19:20:17 +0100 Subject: [PATCH 1/3] hotfix cursor selection --- src/ui/menu-ui-handler.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/ui/menu-ui-handler.ts b/src/ui/menu-ui-handler.ts index 65637689d49..755267fcede 100644 --- a/src/ui/menu-ui-handler.ts +++ b/src/ui/menu-ui-handler.ts @@ -331,11 +331,15 @@ export default class MenuUiHandler extends MessageUiHandler { if (button === Button.ACTION) { let adjustedCursor = this.cursor; - for (const imo of this.excludedMenus().find(e => e.condition).options.sort()) { - if (adjustedCursor >= imo) { - adjustedCursor++; - } else { - break; + const excludedMenu = this.excludedMenus().find(e => e.condition); + if (excludedMenu !== null && excludedMenu.options.length > 0) { + const sortedOptions = excludedMenu.options.sort(); + for (const imo of sortedOptions) { + if (adjustedCursor >= imo) { + adjustedCursor++; + } else { + break; + } } } switch (adjustedCursor) { From 2f83e6e2e1f21bd1e8669330432899fb11a247d6 Mon Sep 17 00:00:00 2001 From: Frederico Santos Date: Fri, 2 Aug 2024 19:28:05 +0100 Subject: [PATCH 2/3] explicit check for options --- src/ui/menu-ui-handler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ui/menu-ui-handler.ts b/src/ui/menu-ui-handler.ts index 755267fcede..6d70bb27ae5 100644 --- a/src/ui/menu-ui-handler.ts +++ b/src/ui/menu-ui-handler.ts @@ -332,7 +332,7 @@ export default class MenuUiHandler extends MessageUiHandler { if (button === Button.ACTION) { let adjustedCursor = this.cursor; const excludedMenu = this.excludedMenus().find(e => e.condition); - if (excludedMenu !== null && excludedMenu.options.length > 0) { + if (excludedMenu !== null && excludedMenu.options !== undefined && excludedMenu.options.length > 0) { const sortedOptions = excludedMenu.options.sort(); for (const imo of sortedOptions) { if (adjustedCursor >= imo) { From 9f68ba867148f39bd8c707b6afe491ebdceab695 Mon Sep 17 00:00:00 2001 From: Frederico Santos Date: Fri, 2 Aug 2024 21:02:24 +0100 Subject: [PATCH 3/3] null or undefined? who knows. --- src/ui/menu-ui-handler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ui/menu-ui-handler.ts b/src/ui/menu-ui-handler.ts index 6d70bb27ae5..4710c575ce9 100644 --- a/src/ui/menu-ui-handler.ts +++ b/src/ui/menu-ui-handler.ts @@ -332,7 +332,7 @@ export default class MenuUiHandler extends MessageUiHandler { if (button === Button.ACTION) { let adjustedCursor = this.cursor; const excludedMenu = this.excludedMenus().find(e => e.condition); - if (excludedMenu !== null && excludedMenu.options !== undefined && excludedMenu.options.length > 0) { + if (excludedMenu !== undefined && excludedMenu.options !== undefined && excludedMenu.options.length > 0) { const sortedOptions = excludedMenu.options.sort(); for (const imo of sortedOptions) { if (adjustedCursor >= imo) {