Added scrolledLines set functionality

This commit is contained in:
bluefireoly
2020-10-21 22:21:27 +02:00
parent c9993593a7
commit b25adb42d4

View File

@@ -47,6 +47,12 @@ class InventoryGUISpaceCompound<T : ForInventory, E>(
} }
internal var scrolledLines: Int = 0 internal var scrolledLines: Int = 0
set(value) {
if (((value - 1) * invType.dimensions.width) < content.size) {
field = value
onChange()
}
}
private var contentSort: () -> Unit = { } private var contentSort: () -> Unit = { }
@@ -76,6 +82,10 @@ class InventoryGUISpaceCompound<T : ForInventory, E>(
realInternalSlots.sort() realInternalSlots.sort()
} }
internal fun onChange() {
registeredGUIs.forEach { it.reloadCurrentPage() }
}
internal fun registerGUI(gui: InventoryGUI<*>) { internal fun registerGUI(gui: InventoryGUI<*>) {
registeredGUIs += gui registeredGUIs += gui
} }
@@ -108,7 +118,7 @@ class InventoryGUISpaceCompound<T : ForInventory, E>(
fun addContent(elements: Collection<E>) { fun addContent(elements: Collection<E>) {
content += elements content += elements
contentSort.invoke() contentSort.invoke()
registeredGUIs.forEach { it.reloadCurrentPage() } onChange()
} }
} }