diff options
author | isXander <xandersmith2008@gmail.com> | 2023-08-12 14:51:55 +0100 |
---|---|---|
committer | isXander <xandersmith2008@gmail.com> | 2023-08-12 14:51:55 +0100 |
commit | 0aa7b3ebb1d0554ef26a3824ad47d65a6b9cc9ee (patch) | |
tree | c13c66e1cc408094ce922e194723ee5fe1aa4e30 /common/src/main | |
parent | af472c8304c9e1864b5c2a1ab8472533fe8f5950 (diff) | |
download | YetAnotherConfigLib-0aa7b3ebb1d0554ef26a3824ad47d65a6b9cc9ee.tar.gz YetAnotherConfigLib-0aa7b3ebb1d0554ef26a3824ad47d65a6b9cc9ee.tar.bz2 YetAnotherConfigLib-0aa7b3ebb1d0554ef26a3824ad47d65a6b9cc9ee.zip |
Restore current tab on screen resize (close #69)
Diffstat (limited to 'common/src/main')
-rw-r--r-- | common/src/main/java/dev/isxander/yacl3/gui/YACLScreen.java | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/common/src/main/java/dev/isxander/yacl3/gui/YACLScreen.java b/common/src/main/java/dev/isxander/yacl3/gui/YACLScreen.java index 5d40a07..b363ada 100644 --- a/common/src/main/java/dev/isxander/yacl3/gui/YACLScreen.java +++ b/common/src/main/java/dev/isxander/yacl3/gui/YACLScreen.java @@ -41,7 +41,6 @@ public class YACLScreen extends Screen { public final TabManager tabManager = new TabManager(this::addRenderableWidget, this::removeWidget); public TabNavigationBar tabNavigationBar; - public Tab[] tabs; public ScreenRectangle tabArea; public Component saveButtonMessage, saveButtonTooltipMessage; @@ -55,6 +54,12 @@ public class YACLScreen extends Screen { @Override protected void init() { + int currentTab = tabNavigationBar != null + ? tabNavigationBar.tabs.indexOf(tabManager.getCurrentTab()) + : 0; + if (currentTab == -1) + currentTab = 0; + tabNavigationBar = new ScrollableNavigationBar(this.width, tabManager, config.categories() .stream() .map(category -> { @@ -62,7 +67,7 @@ public class YACLScreen extends Screen { return new PlaceholderTab(placeholder); return new CategoryTab(category); }).toList()); - tabNavigationBar.selectTab(0, false); + tabNavigationBar.selectTab(currentTab, false); tabNavigationBar.arrangeElements(); ScreenRectangle navBarArea = tabNavigationBar.getRectangle(); tabArea = new ScreenRectangle(0, navBarArea.height() - 1, this.width, this.height - navBarArea.height() + 1); |