Add always open storage overlay option
This commit is contained in:
@@ -14,7 +14,6 @@ import net.minecraft.client.gui.screen.ingame.HandledScreen
|
|||||||
import net.minecraft.entity.player.PlayerInventory
|
import net.minecraft.entity.player.PlayerInventory
|
||||||
import net.minecraft.item.Items
|
import net.minecraft.item.Items
|
||||||
import net.minecraft.network.packet.c2s.play.CloseHandledScreenC2SPacket
|
import net.minecraft.network.packet.c2s.play.CloseHandledScreenC2SPacket
|
||||||
import net.minecraft.text.Text
|
|
||||||
import moe.nea.firmament.annotations.Subscribe
|
import moe.nea.firmament.annotations.Subscribe
|
||||||
import moe.nea.firmament.events.ScreenChangeEvent
|
import moe.nea.firmament.events.ScreenChangeEvent
|
||||||
import moe.nea.firmament.events.SlotClickEvent
|
import moe.nea.firmament.events.SlotClickEvent
|
||||||
@@ -34,7 +33,8 @@ object StorageOverlay : FirmamentFeature {
|
|||||||
get() = "storage-overlay"
|
get() = "storage-overlay"
|
||||||
|
|
||||||
object TConfig : ManagedConfig(identifier) {
|
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 scrollSpeed by integer("scroll-speed", 1, 50) { 10 }
|
||||||
val inverseScroll by toggle("inverse-scroll") { false }
|
val inverseScroll by toggle("inverse-scroll") { false }
|
||||||
val padding by integer("padding", 1, 20) { 5 }
|
val padding by integer("padding", 1, 20) { 5 }
|
||||||
@@ -105,7 +105,7 @@ object StorageOverlay : FirmamentFeature {
|
|||||||
screen.customGui = StorageOverlayCustom(
|
screen.customGui = StorageOverlayCustom(
|
||||||
currentHandler ?: return,
|
currentHandler ?: return,
|
||||||
screen,
|
screen,
|
||||||
storageOverlayScreen ?: return)
|
storageOverlayScreen ?: (if (TConfig.alwaysReplace) StorageOverlayScreen() else return))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun rememberContent(handler: StorageBackingHandle?) {
|
fun rememberContent(handler: StorageBackingHandle?) {
|
||||||
|
|||||||
@@ -33,22 +33,11 @@ class StorageOverlayScreen : Screen(Text.literal("")) {
|
|||||||
val MAIN_INVENTORY_Y = 9
|
val MAIN_INVENTORY_Y = 9
|
||||||
val SCROLL_BAR_WIDTH = 8
|
val SCROLL_BAR_WIDTH = 8
|
||||||
val SCROLL_BAR_HEIGHT = 16
|
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 isExiting: Boolean = false
|
||||||
var scroll: Float = 0F
|
var scroll: Float = 0F
|
||||||
var pageWidthCount = StorageOverlay.TConfig.rows
|
var pageWidthCount = StorageOverlay.TConfig.columns
|
||||||
|
|
||||||
inner class Measurements {
|
inner class Measurements {
|
||||||
val innerScrollPanelWidth = PAGE_WIDTH * pageWidthCount + (pageWidthCount - 1) * PADDING
|
val innerScrollPanelWidth = PAGE_WIDTH * pageWidthCount + (pageWidthCount - 1) * PADDING
|
||||||
@@ -66,7 +55,7 @@ class StorageOverlayScreen : Screen(Text.literal("")) {
|
|||||||
var lastRenderedInnerHeight = 0
|
var lastRenderedInnerHeight = 0
|
||||||
override fun init() {
|
override fun init() {
|
||||||
super.init()
|
super.init()
|
||||||
pageWidthCount = StorageOverlay.TConfig.rows
|
pageWidthCount = StorageOverlay.TConfig.columns
|
||||||
.coerceAtMost((width - PADDING) / (PAGE_WIDTH + PADDING))
|
.coerceAtMost((width - PADDING) / (PAGE_WIDTH + PADDING))
|
||||||
.coerceAtLeast(1)
|
.coerceAtLeast(1)
|
||||||
measurements = Measurements()
|
measurements = Measurements()
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ class StorageOverviewScreen() : Screen(Text.empty()) {
|
|||||||
var currentMaxHeight = StorageOverlay.config.margin - StorageOverlay.config.padding - scroll
|
var currentMaxHeight = StorageOverlay.config.margin - StorageOverlay.config.padding - scroll
|
||||||
var totalHeight = -currentMaxHeight
|
var totalHeight = -currentMaxHeight
|
||||||
content.storageInventories.onEachIndexed { index, (key, value) ->
|
content.storageInventories.onEachIndexed { index, (key, value) ->
|
||||||
val pageX = (index % StorageOverlay.config.rows)
|
val pageX = (index % StorageOverlay.config.columns)
|
||||||
if (pageX == 0) {
|
if (pageX == 0) {
|
||||||
currentMaxHeight += StorageOverlay.config.padding
|
currentMaxHeight += StorageOverlay.config.padding
|
||||||
offsetY += currentMaxHeight
|
offsetY += currentMaxHeight
|
||||||
@@ -59,7 +59,7 @@ class StorageOverviewScreen() : Screen(Text.empty()) {
|
|||||||
currentMaxHeight = 0
|
currentMaxHeight = 0
|
||||||
}
|
}
|
||||||
val xPosition =
|
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)
|
onEach(Pair(key, value), xPosition, offsetY)
|
||||||
val height = getStorePageHeight(value)
|
val height = getStorePageHeight(value)
|
||||||
currentMaxHeight = max(currentMaxHeight, height)
|
currentMaxHeight = max(currentMaxHeight, height)
|
||||||
|
|||||||
@@ -126,7 +126,8 @@
|
|||||||
"firmament.config.save-cursor-position.tolerance": "Tolerance",
|
"firmament.config.save-cursor-position.tolerance": "Tolerance",
|
||||||
"firmament.config.save-cursor-position": "Save Cursor Position",
|
"firmament.config.save-cursor-position": "Save Cursor Position",
|
||||||
"firmament.config.storage-overlay": "Storage Overlay",
|
"firmament.config.storage-overlay": "Storage Overlay",
|
||||||
"firmament.config.storage-overlay.rows": "Rows",
|
"firmament.config.storage-overlay.rows": "Columns",
|
||||||
|
"firmament.config.storage-overlay.always-replace": "Always Open Overlay",
|
||||||
"firmament.config.storage-overlay.padding": "Padding",
|
"firmament.config.storage-overlay.padding": "Padding",
|
||||||
"firmament.config.storage-overlay.scroll-speed": "Scroll Speed",
|
"firmament.config.storage-overlay.scroll-speed": "Scroll Speed",
|
||||||
"firmament.config.storage-overlay.inverse-scroll": "Invert Scroll",
|
"firmament.config.storage-overlay.inverse-scroll": "Invert Scroll",
|
||||||
|
|||||||
Reference in New Issue
Block a user