Skip to content

Commit 6c59fb5

Browse files
committed
Add an additional field to better determine if a parent view is valid
1 parent f7fbd7c commit 6c59fb5

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

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

+3
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ public abstract class AbstractInterfaceView<I : InterfacesInventory, P : Pane>(
7575
override val shouldStillBeOpened: Boolean
7676
get() = shouldBeOpened.get()
7777

78+
override val isTreeOpened: Boolean
79+
get() = shouldStillBeOpened || children.keys.any { it.shouldStillBeOpened }
80+
7881
/** Creates a new inventory GUI. */
7982
public abstract fun createInventory(): I
8083

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

+9-3
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,18 @@ public interface InterfaceView {
1818
/**
1919
* Tracks whether this menu should be opened or not. This does not actually represent
2020
* whether the menu is open currently, it represents whether the code wants it to be
21-
* open. This does not get set to false if the menu is closed by the player, it gets
22-
* set to false if the code calls close() which is a manual request to make sure this
23-
* menu doesn't do anything anymore!
21+
* open. This gets set to `false` whenever the close handlers are called.
22+
*
23+
* This should be `false` whenever the menu is not on-screen.
2424
*/
2525
public val shouldStillBeOpened: Boolean
2626

27+
/**
28+
* Whether this view or any of its children are still opened. This can be used to verify whether
29+
* a parent view is still valid based on whether any of its children are open.
30+
*/
31+
public val isTreeOpened: Boolean
32+
2733
/** Opens up this view. */
2834
public suspend fun open()
2935

0 commit comments

Comments
 (0)