Skip to content

Commit 297bfbd

Browse files
committed
Clean up when firstPaint is set to false
1 parent 2880ec5 commit 297bfbd

File tree

4 files changed

+4
-9
lines changed

4 files changed

+4
-9
lines changed

next/src/main/kotlin/org/incendo/interfaces/next/view/AbstractInterfaceView.kt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,6 @@ public abstract class AbstractInterfaceView<I : InterfacesInventory, P : Pane>(
6161
// Add listeners to all triggers and update its transforms
6262
for ((trigger, transforms) in triggers.asMap()) {
6363
trigger.addListener(this) {
64-
// If the first paint has not completed we do not perform any updates
65-
if (firstPaint) return@addListener
66-
6764
// Apply the transforms for the new ones
6865
applyTransforms(transforms)
6966
}
@@ -90,7 +87,6 @@ public abstract class AbstractInterfaceView<I : InterfacesInventory, P : Pane>(
9087
if (firstPaint || this !is ChestInterfaceView) {
9188
firstPaint = true
9289
setup()
93-
firstPaint = false
9490
} else {
9591
renderAndOpen()
9692
}
@@ -251,7 +247,7 @@ public abstract class AbstractInterfaceView<I : InterfacesInventory, P : Pane>(
251247
protected open suspend fun renderToInventory(callback: (Boolean) -> Unit) {
252248
// If a new inventory is required we create one
253249
// and mark that the current one is not to be used!
254-
val createdInventory = if (firstPaint || requiresNewInventory()) {
250+
val createdInventory = if (requiresNewInventory()) {
255251
currentInventory = createInventory()
256252
true
257253
} else {
@@ -273,6 +269,7 @@ public abstract class AbstractInterfaceView<I : InterfacesInventory, P : Pane>(
273269
if ((openIfClosed && !isOpen) || createdInventory) {
274270
openInventory()
275271
openIfClosed = false
272+
firstPaint = false
276273
}
277274
}
278275
}

next/src/main/kotlin/org/incendo/interfaces/next/view/ChestInterfaceView.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class ChestInterfaceView internal constructor(
3737

3838
override fun requiresPlayerUpdate(): Boolean = false
3939

40-
override fun requiresNewInventory(): Boolean = titleState.hasChanged
40+
override fun requiresNewInventory(): Boolean = super.requiresNewInventory() || titleState.hasChanged
4141

4242
override fun getInventory(): Inventory = currentInventory.chestInventory
4343

next/src/main/kotlin/org/incendo/interfaces/next/view/CombinedInterfaceView.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class CombinedInterfaceView internal constructor(
3838

3939
override fun requiresPlayerUpdate(): Boolean = false
4040

41-
override fun requiresNewInventory(): Boolean = titleState.hasChanged
41+
override fun requiresNewInventory(): Boolean = super.requiresNewInventory() || titleState.hasChanged
4242

4343
override fun getInventory(): Inventory = currentInventory.chestInventory
4444

next/src/main/kotlin/org/incendo/interfaces/next/view/PlayerInterfaceView.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ public class PlayerInterfaceView internal constructor(
2323
error("PlayerInventoryView's cannot have a title")
2424
}
2525

26-
override fun requiresNewInventory(): Boolean = false
27-
2826
override fun createInventory(): PlayerInterfacesInventory = PlayerInterfacesInventory(player)
2927

3028
override fun openInventory() {

0 commit comments

Comments
 (0)