Skip to content

Commit dc1596d

Browse files
committed
Redraw UI titles on re-open
1 parent a7964f2 commit dc1596d

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

interfaces/src/main/kotlin/com/noxcrew/interfaces/interfaces/InterfaceProperties.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ public open class InterfaceProperties<P : Pane> {
8181
/** The exception handler to use for this interface. */
8282
public var exceptionHandler: InterfacesExceptionHandler = StandardInterfacesExceptionHandler()
8383

84+
/** Whether to redraw the title when re-opening a menu, defaults to true for legacy compatibility. */
85+
public var redrawTitleOnReopen: Boolean = true
86+
8487
/** Adds a new close handler [closeHandler] that triggers whenever the inventory is closed for any of the given [reasons]. */
8588
public fun addCloseHandler(reasons: Collection<InventoryCloseEvent.Reason> = DEFAULT_REASONS, closeHandler: CloseHandler) {
8689
reasons.forEach {

interfaces/src/main/kotlin/com/noxcrew/interfaces/view/AbstractInterfaceView.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ public abstract class AbstractInterfaceView<I : InterfacesInventory, T : Interfa
8484
/** Whether the view is being painted for the first time. */
8585
protected var firstPaint: Boolean = true
8686

87+
/** Whether the view should be painted to a fresh inventory. */
88+
protected var drawToFreshInventory: Boolean = true
89+
8790
/** Whether a click is being processed. */
8891
public var isProcessingClick: Boolean = false
8992

@@ -278,6 +281,11 @@ public abstract class AbstractInterfaceView<I : InterfacesInventory, T : Interfa
278281
openIfClosed.set(true)
279282
shouldBeOpened.set(true)
280283

284+
// If we want to redraw the title we use a new inventory always
285+
if (backing.builder.redrawTitleOnReopen) {
286+
drawToFreshInventory = true
287+
}
288+
281289
// Either draw the entire interface or just re-render it
282290
if (firstPaint) {
283291
redrawComplete()
@@ -671,7 +679,7 @@ public abstract class AbstractInterfaceView<I : InterfacesInventory, T : Interfa
671679
drawPaneToInventory(drawNormalInventory = false, drawPlayerInventory = true)
672680
}
673681

674-
protected open fun requiresNewInventory(): Boolean = firstPaint
682+
protected open fun requiresNewInventory(): Boolean = drawToFreshInventory
675683

676684
protected open fun requiresPlayerUpdate(): Boolean = false
677685

@@ -730,6 +738,7 @@ public abstract class AbstractInterfaceView<I : InterfacesInventory, T : Interfa
730738
}
731739
openIfClosed.set(false)
732740
firstPaint = false
741+
drawToFreshInventory = false
733742
}
734743
}
735744

0 commit comments

Comments
 (0)