aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/firmament/features
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/features')
-rw-r--r--src/main/kotlin/moe/nea/firmament/features/inventory/storageoverlay/StorageOverlay.kt18
-rw-r--r--src/main/kotlin/moe/nea/firmament/features/inventory/storageoverlay/StorageOverlayScreen.kt1
2 files changed, 19 insertions, 0 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/features/inventory/storageoverlay/StorageOverlay.kt b/src/main/kotlin/moe/nea/firmament/features/inventory/storageoverlay/StorageOverlay.kt
index cb8a8d8..b0ebea6 100644
--- a/src/main/kotlin/moe/nea/firmament/features/inventory/storageoverlay/StorageOverlay.kt
+++ b/src/main/kotlin/moe/nea/firmament/features/inventory/storageoverlay/StorageOverlay.kt
@@ -8,10 +8,12 @@ package moe.nea.firmament.features.inventory.storageoverlay
import java.util.*
import kotlinx.serialization.serializer
+import net.minecraft.client.gui.screen.Screen
import moe.nea.firmament.events.ScreenChangeEvent
import moe.nea.firmament.events.TickEvent
import moe.nea.firmament.features.FirmamentFeature
import moe.nea.firmament.gui.config.ManagedConfig
+import moe.nea.firmament.util.ScreenUtil.setScreenLater
import moe.nea.firmament.util.data.ProfileSpecificDataHolder
object StorageOverlay : FirmamentFeature {
@@ -33,9 +35,25 @@ object StorageOverlay : FirmamentFeature {
override val config: TConfig
get() = TConfig
+ var lastStorageOverlay: Screen? = null
+ var shouldReturnToStorageOverlayFrom: Screen? = null
+ var shouldReturnToStorageOverlay: Screen? = null
var currentHandler: StorageBackingHandle? = StorageBackingHandle.None
override fun onLoad() {
+ ScreenChangeEvent.subscribe {
+ if (lastStorageOverlay != null && it.new != null) {
+ shouldReturnToStorageOverlay = lastStorageOverlay
+ shouldReturnToStorageOverlayFrom = it.new
+ lastStorageOverlay = null
+ } else if (it.old === shouldReturnToStorageOverlayFrom) {
+ if (shouldReturnToStorageOverlay != null && it.new == null)
+ setScreenLater(shouldReturnToStorageOverlay)
+ shouldReturnToStorageOverlay = null
+ shouldReturnToStorageOverlayFrom = null
+ }
+ }
+
ScreenChangeEvent.subscribe { event ->
currentHandler = StorageBackingHandle.fromScreen(event.new)
if (event.old is StorageOverlayScreen && !event.old.isClosing) {
diff --git a/src/main/kotlin/moe/nea/firmament/features/inventory/storageoverlay/StorageOverlayScreen.kt b/src/main/kotlin/moe/nea/firmament/features/inventory/storageoverlay/StorageOverlayScreen.kt
index d00a3a1..e0cd3c8 100644
--- a/src/main/kotlin/moe/nea/firmament/features/inventory/storageoverlay/StorageOverlayScreen.kt
+++ b/src/main/kotlin/moe/nea/firmament/features/inventory/storageoverlay/StorageOverlayScreen.kt
@@ -91,6 +91,7 @@ class StorageOverlayScreen() : Screen(Text.empty()) {
val ry = mouseY - y
if (rx in (0.0..pageWidth.toDouble()) && ry in (0.0..getStorePageHeight(p).toDouble())) {
close()
+ StorageOverlay.lastStorageOverlay = this
k.navigateTo()
return true
}