From ecf6295b4ab0643f80f7925de9bf820fd08bff59 Mon Sep 17 00:00:00 2001 From: Kazooo100 <106842463+Kazooo100@users.noreply.github.com> Date: Sun, 14 Jul 2024 15:57:11 -0400 Subject: [PATCH] Allow main menu gamebar scroll to loop (#14841) --- builtin/fstk/buttonbar.lua | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/builtin/fstk/buttonbar.lua b/builtin/fstk/buttonbar.lua index c7da41280..59b7a586f 100644 --- a/builtin/fstk/buttonbar.lua +++ b/builtin/fstk/buttonbar.lua @@ -102,14 +102,24 @@ local function buttonbar_formspec(self) end local function buttonbar_buttonhandler(self, fields) - if fields[self.btn_prev_name] and self.cur_page > 1 then - self.cur_page = self.cur_page - 1 - return true + if fields[self.btn_prev_name] then + if self.cur_page > 1 then + self.cur_page = self.cur_page - 1 + return true + elseif self.cur_page == 1 then + self.cur_page = self.num_pages + return true + end end - if fields[self.btn_next_name] and self.cur_page < self.num_pages then - self.cur_page = self.cur_page + 1 - return true + if fields[self.btn_next_name] then + if self.cur_page < self.num_pages then + self.cur_page = self.cur_page + 1 + return true + elseif self.cur_page == self.num_pages then + self.cur_page = 1 + return true + end end for _, btn in ipairs(self.buttons) do