aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-01-18 20:46:11 +0100
committerLinnea Gräf <nea@nea.moe>2024-01-18 20:46:11 +0100
commite93dd76b0ff0dc52a0455023486d385730aed0fc (patch)
tree806c8a84e940583942ebc15f733286582e3e68cc
parentcc8e54b5944e38857e1781853d0c526884853312 (diff)
downloadfirmament-e93dd76b0ff0dc52a0455023486d385730aed0fc.tar.gz
firmament-e93dd76b0ff0dc52a0455023486d385730aed0fc.tar.bz2
firmament-e93dd76b0ff0dc52a0455023486d385730aed0fc.zip
Return to storage overlay after viewing a page
-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
}