From 8f1c326e6a42b37c465583ca3ba617b29057c82b Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Fri, 29 Jan 2021 21:54:34 +0100 Subject: [PATCH] fix: reset view on page change --- birb/modules/menusystem/menus/flowbox.lua | 4 ++++ birb/modules/menusystem/menus/grid.lua | 5 +++++ birb/modules/menusystem/menus/hlistbox.lua | 4 ++++ birb/modules/menusystem/menus/listbox.lua | 4 ++++ birb/modules/menusystem/menus/parent.lua | 2 ++ birb/modules/menusystem/menus/views/view1D.lua | 5 +++++ 6 files changed, 24 insertions(+) diff --git a/birb/modules/menusystem/menus/flowbox.lua b/birb/modules/menusystem/menus/flowbox.lua index 7991af9..5fcde9b 100644 --- a/birb/modules/menusystem/menus/flowbox.lua +++ b/birb/modules/menusystem/menus/flowbox.lua @@ -45,6 +45,10 @@ function FlowBox:setRealSize() self.h = self.view.lineNumber * self.widgetSize.h end +function FlowBox:resetView() + self.view:reset() +end + -- UPDATE FUNCTIONS -- Update the menu and its view diff --git a/birb/modules/menusystem/menus/grid.lua b/birb/modules/menusystem/menus/grid.lua index 6f985e4..7ba675f 100644 --- a/birb/modules/menusystem/menus/grid.lua +++ b/birb/modules/menusystem/menus/grid.lua @@ -137,6 +137,11 @@ function GridBox:update(dt) self.view.firstSlot = 1 end +function GridBox:resetView() + self.view:reset() +end + + -- KEYS FUNCTIONS -- Handle the keyboard/manette functions diff --git a/birb/modules/menusystem/menus/hlistbox.lua b/birb/modules/menusystem/menus/hlistbox.lua index c8f0394..c8a853f 100644 --- a/birb/modules/menusystem/menus/hlistbox.lua +++ b/birb/modules/menusystem/menus/hlistbox.lua @@ -50,6 +50,10 @@ function HListBox:update(dt) self.view:updateFirstSlot(self.widget:getSelected()) end +function HListBox:resetView() + self.view:reset() +end + -- KEYBOARD FUNCTIONS -- Handle key check. diff --git a/birb/modules/menusystem/menus/listbox.lua b/birb/modules/menusystem/menus/listbox.lua index d1a3c6d..828ade8 100644 --- a/birb/modules/menusystem/menus/listbox.lua +++ b/birb/modules/menusystem/menus/listbox.lua @@ -50,6 +50,10 @@ function ListBox:update(dt) self.view:updateFirstSlot(self.widget:getSelected()) end +function ListBox:resetView() + self.view:reset() +end + -- KEYBOARD FUNCTIONS -- Handle input from keyboard/controllers. diff --git a/birb/modules/menusystem/menus/parent.lua b/birb/modules/menusystem/menus/parent.lua index 9713fb8..57ea23c 100644 --- a/birb/modules/menusystem/menus/parent.lua +++ b/birb/modules/menusystem/menus/parent.lua @@ -109,10 +109,12 @@ end function Menu:switch(pageName) self.widget:switch(pageName) + self:resetView() end function Menu:back() self.widget:back() + self:resetView() end -- ACTION FUNCTIONS diff --git a/birb/modules/menusystem/menus/views/view1D.lua b/birb/modules/menusystem/menus/views/view1D.lua index 686dc1e..563c602 100644 --- a/birb/modules/menusystem/menus/views/view1D.lua +++ b/birb/modules/menusystem/menus/views/view1D.lua @@ -29,6 +29,11 @@ function View1D:new(slotNumber) self.firstSlot = 1 end +function View1D:reset() + self.firstSlot = 1 + print("reset") +end + function View1D:updateFirstSlot(widgetID) self.firstSlot = math.max(1, widgetID - (self.slotNumber - 1), math.min(widgetID, self.firstSlot)) end