From e5e71c1702425ce02facd0d8a6b9831a3044064a Mon Sep 17 00:00:00 2001 From: RedstonewolfX <108761527+RedstonewolfX@users.noreply.github.com> Date: Fri, 23 Aug 2024 19:51:01 -0400 Subject: [PATCH] [Enhancement] Make the scrollbar cursor size more natural in the starter select UI (#3627) * Improve scroll bar Remaking these changes on the beta branch since you're supposed to do it for the PR checklist * Fix potential divide by zero error Thank you to KimJeongSun for bringing this up Co-authored-by: Leo Kim <47556641+KimJeongSun@users.noreply.github.com> * Fix parenthases order Co-authored-by: Leo Kim <47556641+KimJeongSun@users.noreply.github.com> --------- Co-authored-by: Leo Kim <47556641+KimJeongSun@users.noreply.github.com> --- src/ui/scroll-bar.ts | 4 ++-- src/ui/starter-select-ui-handler.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ui/scroll-bar.ts b/src/ui/scroll-bar.ts index 02282edb4cd..e756393ae1a 100644 --- a/src/ui/scroll-bar.ts +++ b/src/ui/scroll-bar.ts @@ -29,8 +29,8 @@ export class ScrollBar extends Phaser.GameObjects.Container { setPages(pages: number): void { this.pages = pages; - this.handleBody.height = (this.bg.displayHeight - 1 - this.handleBottom.displayHeight) / this.pages; + this.handleBody.height = (this.bg.displayHeight - 1 - this.handleBottom.displayHeight) * 9 / this.pages; - this.setVisible(this.pages > 1); + this.setVisible(this.pages > 9); } } diff --git a/src/ui/starter-select-ui-handler.ts b/src/ui/starter-select-ui-handler.ts index fe6c39cc6f1..97064cd9061 100644 --- a/src/ui/starter-select-ui-handler.ts +++ b/src/ui/starter-select-ui-handler.ts @@ -2386,7 +2386,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { } }); - this.starterSelectScrollBar.setPages(Math.ceil((this.filteredStarterContainers.length - 81) / 9) + 1); + this.starterSelectScrollBar.setPages(Math.max(Math.ceil(this.filteredStarterContainers.length / 9), 1)); this.starterSelectScrollBar.setPage(0); // sort