aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-07-15 16:04:10 +0200
committerLinnea Gräf <nea@nea.moe>2024-07-15 16:04:10 +0200
commite96bef23200e4767269271388a5c88f6d4e6457e (patch)
tree69a8a9e1cc7c4cabc984ecb28c920e45f1abc493 /src/main/kotlin
parenta74ec310bb9f37f98033e03f3cb2cdff7f404f89 (diff)
downloadfirmament-e96bef23200e4767269271388a5c88f6d4e6457e.tar.gz
firmament-e96bef23200e4767269271388a5c88f6d4e6457e.tar.bz2
firmament-e96bef23200e4767269271388a5c88f6d4e6457e.zip
Add always open storage overlay option
Diffstat (limited to 'src/main/kotlin')
-rw-r--r--src/main/kotlin/moe/nea/firmament/features/inventory/storageoverlay/StorageOverlay.kt6
-rw-r--r--src/main/kotlin/moe/nea/firmament/features/inventory/storageoverlay/StorageOverlayScreen.kt15
-rw-r--r--src/main/kotlin/moe/nea/firmament/features/inventory/storageoverlay/StorageOverviewScreen.kt4
3 files changed, 7 insertions, 18 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 777cbe9..c1ac993 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
@@ -14,7 +14,6 @@ import net.minecraft.client.gui.screen.ingame.HandledScreen
import net.minecraft.entity.player.PlayerInventory
import net.minecraft.item.Items
import net.minecraft.network.packet.c2s.play.CloseHandledScreenC2SPacket
-import net.minecraft.text.Text
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.ScreenChangeEvent
import moe.nea.firmament.events.SlotClickEvent
@@ -34,7 +33,8 @@ object StorageOverlay : FirmamentFeature {
get() = "storage-overlay"
object TConfig : ManagedConfig(identifier) {
- val rows by integer("rows", 1, 5) { 3 }
+ val alwaysReplace by toggle("always-replace") { true }
+ val columns by integer("rows", 1, 10) { 3 }
val scrollSpeed by integer("scroll-speed", 1, 50) { 10 }
val inverseScroll by toggle("inverse-scroll") { false }
val padding by integer("padding", 1, 20) { 5 }
@@ -105,7 +105,7 @@ object StorageOverlay : FirmamentFeature {
screen.customGui = StorageOverlayCustom(
currentHandler ?: return,
screen,
- storageOverlayScreen ?: return)
+ storageOverlayScreen ?: (if (TConfig.alwaysReplace) StorageOverlayScreen() else return))
}
fun rememberContent(handler: StorageBackingHandle?) {
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 ac89f8c..c371eb4 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
@@ -33,22 +33,11 @@ class StorageOverlayScreen : Screen(Text.literal("")) {
val MAIN_INVENTORY_Y = 9
val SCROLL_BAR_WIDTH = 8
val SCROLL_BAR_HEIGHT = 16
-
- @Subscribe
- fun onCommand(event: CommandEvent.SubCommand) {
- event.subcommand("teststorage") {
- executes {
- ScreenUtil.setScreenLater(StorageOverlayScreen())
- MC.sendCommand("ec")
- 0
- }
- }
- }
}
var isExiting: Boolean = false
var scroll: Float = 0F
- var pageWidthCount = StorageOverlay.TConfig.rows
+ var pageWidthCount = StorageOverlay.TConfig.columns
inner class Measurements {
val innerScrollPanelWidth = PAGE_WIDTH * pageWidthCount + (pageWidthCount - 1) * PADDING
@@ -66,7 +55,7 @@ class StorageOverlayScreen : Screen(Text.literal("")) {
var lastRenderedInnerHeight = 0
override fun init() {
super.init()
- pageWidthCount = StorageOverlay.TConfig.rows
+ pageWidthCount = StorageOverlay.TConfig.columns
.coerceAtMost((width - PADDING) / (PAGE_WIDTH + PADDING))
.coerceAtLeast(1)
measurements = Measurements()
diff --git a/src/main/kotlin/moe/nea/firmament/features/inventory/storageoverlay/StorageOverviewScreen.kt b/src/main/kotlin/moe/nea/firmament/features/inventory/storageoverlay/StorageOverviewScreen.kt
index dc2bd48..fb77ff2 100644
--- a/src/main/kotlin/moe/nea/firmament/features/inventory/storageoverlay/StorageOverviewScreen.kt
+++ b/src/main/kotlin/moe/nea/firmament/features/inventory/storageoverlay/StorageOverviewScreen.kt
@@ -51,7 +51,7 @@ class StorageOverviewScreen() : Screen(Text.empty()) {
var currentMaxHeight = StorageOverlay.config.margin - StorageOverlay.config.padding - scroll
var totalHeight = -currentMaxHeight
content.storageInventories.onEachIndexed { index, (key, value) ->
- val pageX = (index % StorageOverlay.config.rows)
+ val pageX = (index % StorageOverlay.config.columns)
if (pageX == 0) {
currentMaxHeight += StorageOverlay.config.padding
offsetY += currentMaxHeight
@@ -59,7 +59,7 @@ class StorageOverviewScreen() : Screen(Text.empty()) {
currentMaxHeight = 0
}
val xPosition =
- width / 2 - (StorageOverlay.config.rows * (pageWidth + StorageOverlay.config.padding) - StorageOverlay.config.padding) / 2 + pageX * (pageWidth + StorageOverlay.config.padding)
+ width / 2 - (StorageOverlay.config.columns * (pageWidth + StorageOverlay.config.padding) - StorageOverlay.config.padding) / 2 + pageX * (pageWidth + StorageOverlay.config.padding)
onEach(Pair(key, value), xPosition, offsetY)
val height = getStorePageHeight(value)
currentMaxHeight = max(currentMaxHeight, height)