From b10fee71c90a242e1a9c6ef916e9d3df150e8d78 Mon Sep 17 00:00:00 2001 From: Elliot Thomas Date: Thu, 4 Aug 2022 21:27:28 +0100 Subject: [PATCH] Limit scroll offset in getter resolves #37 --- changelogs/1.3.1-beta+fabric-1.19.md | 6 ++++++ gradle.properties | 6 +++--- .../enchantmenu/client/gui/screen/EnchantMenuScreen.kt | 1 + 3 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 changelogs/1.3.1-beta+fabric-1.19.md diff --git a/changelogs/1.3.1-beta+fabric-1.19.md b/changelogs/1.3.1-beta+fabric-1.19.md new file mode 100644 index 0000000..9f70df9 --- /dev/null +++ b/changelogs/1.3.1-beta+fabric-1.19.md @@ -0,0 +1,6 @@ +Now with fixed scroll! + +**Changed**: +- Scroll offset is now capped to max scroll offset + +**Full Changelog**: https://github.com/eth0net/enchant-menu/compare/v1.3.0+fabric-1.19...v1.3.1-beta+fabric-1.19 diff --git a/gradle.properties b/gradle.properties index d6f974b..5695dbc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -19,6 +19,6 @@ completeConfigVersionId=zaC01d1T # Mod Properties mavenGroup=com.github.eth0net modId=enchant-menu -modVersion=1.3.0+fabric-1.19 -modVersionName=1.3.0 Fabric 1.19 -modVersionType=release +modVersion=1.3.1-beta+fabric-1.19 +modVersionName=1.3.1 Beta Fabric 1.19 +modVersionType=beta diff --git a/src/main/kotlin/com/github/eth0net/enchantmenu/client/gui/screen/EnchantMenuScreen.kt b/src/main/kotlin/com/github/eth0net/enchantmenu/client/gui/screen/EnchantMenuScreen.kt index 7adedd9..572dc62 100644 --- a/src/main/kotlin/com/github/eth0net/enchantmenu/client/gui/screen/EnchantMenuScreen.kt +++ b/src/main/kotlin/com/github/eth0net/enchantmenu/client/gui/screen/EnchantMenuScreen.kt @@ -40,6 +40,7 @@ class EnchantMenuScreen(handler: EnchantMenuScreenHandler, playerInventory: Play private val canScroll get() = handler.enchantments.size > maxRows private val maxScrollOffset get() = if (canScroll) handler.enchantments.size - maxRows else 0 private var scrollOffset = 0 + get() = if (field > maxScrollOffset) maxScrollOffset else field set(value) { field = if (value <= 0) { 0