From f63a87298d3268ae3d01c8ee036925af58b85888 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 1 Sep 2022 14:38:57 +0700 Subject: [PATCH] Battery slot background icon --- .../mc/otm/client/render/Widgets18.kt | 1 + .../otm/client/screen/AndroidStationScreen.kt | 9 +++++-- .../mc/otm/client/screen/BatteryBankScreen.kt | 5 ++-- .../client/screen/ChemicalGeneratorScreen.kt | 2 +- .../mc/otm/client/screen/DriveRackScreen.kt | 3 ++- .../mc/otm/client/screen/DriveViewerScreen.kt | 2 +- .../otm/client/screen/MatterBottlerScreen.kt | 3 ++- .../client/screen/MatterDecomposerScreen.kt | 3 ++- .../otm/client/screen/MatterRecyclerScreen.kt | 3 ++- .../client/screen/MatterReplicatorScreen.kt | 3 ++- .../otm/client/screen/MatterScannerScreen.kt | 3 ++- .../mc/otm/client/screen/PlatePressScreen.kt | 3 ++- .../mc/otm/client/screen/StorageBusScreen.kt | 7 ++---- .../client/screen/StorageExporterScreen.kt | 7 ++---- .../client/screen/StorageImporterScreen.kt | 7 ++---- .../screen/StoragePowerSupplierScreen.kt | 2 +- .../client/screen/panels/AbstractSlotPanel.kt | 15 +++++++----- .../otm/client/screen/panels/EditablePanel.kt | 6 +++-- .../mc/otm/client/screen/panels/SlotPanel.kt | 23 +++++++++++++++--- .../textures/gui/widgets_18.png | Bin 1298 -> 1390 bytes .../textures/gui/widgets_18.xcf | 4 +-- 21 files changed, 68 insertions(+), 43 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt index a630c4ddd..569b98db1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt @@ -13,4 +13,5 @@ object Widgets18 { val C = GRID.next() val CROSS = GRID.next() val FORWARD_SLASH = GRID.next() + val BATTERY_SLOT_BACKGROUND = GRID.next() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/AndroidStationScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/AndroidStationScreen.kt index b92dcf8f7..63b6057bf 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/AndroidStationScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/AndroidStationScreen.kt @@ -470,6 +470,7 @@ class AndroidStationScreen constructor(p_97741_: AndroidStationMenu, p_97742_: I val canvas = object : DraggableCanvasPanel(this@AndroidStationScreen, null) { private val random = Random() private var scroller: PreviewScrollers = PreviewScrollers.values().let { it[random.nextInt(it.size)] } + private var firstTick = false override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { drawColor = RGBAColor.BLACK @@ -488,7 +489,11 @@ class AndroidStationScreen constructor(p_97741_: AndroidStationMenu, p_97742_: I override fun tick() { super.tick() - if (isPreview) { + if (isPreview && !layoutInvalidated) { + if (firstTick) { + scroller.init.invoke(this, random) + } + val status = scroller.scroll.invoke(this, random) if (!status) { @@ -606,7 +611,7 @@ class AndroidStationScreen constructor(p_97741_: AndroidStationMenu, p_97742_: I it.dock = Dock.TOP } - SlotPanel(this, stripLeft, menu.batterySlot).also { + BatterySlotPanel(this, stripLeft, menu.batterySlot).also { it.dock = Dock.TOP it.dockTop = 6f } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/BatteryBankScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/BatteryBankScreen.kt index 6ea0a912f..1e8f8a445 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/BatteryBankScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/BatteryBankScreen.kt @@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.client.screen import net.minecraft.network.chat.Component import ru.dbotthepony.mc.otm.menu.BatteryBankMenu import net.minecraft.world.entity.player.Inventory +import ru.dbotthepony.mc.otm.client.screen.panels.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.panels.SlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel @@ -17,10 +18,10 @@ class BatteryBankScreen(menu: BatteryBankMenu, p_97742_: Inventory, p_97743_: Co WidePowerGaugePanel(this, frame, menu.powerLevel, LEFT_MARGIN, GAUGE_TOP_WITHOUT_SLOT) for (i in 0 .. 5) - SlotPanel(this, frame, menu.storageSlots[i], 44f + 18 * i, 32f) + BatterySlotPanel(this, frame, menu.storageSlots[i], 44f + 18 * i, 32f) for (i in 6 .. 11) - SlotPanel(this, frame, menu.storageSlots[i], 44f + 18 * (i - 6), 32f + 18f) + BatterySlotPanel(this, frame, menu.storageSlots[i], 44f + 18 * (i - 6), 32f + 18f) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ChemicalGeneratorScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ChemicalGeneratorScreen.kt index a07cda9fc..0f6a6ffe3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ChemicalGeneratorScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ChemicalGeneratorScreen.kt @@ -14,7 +14,7 @@ class ChemicalGeneratorScreen(menu: ChemicalGeneratorMenu, inventory: Inventory, val frame = super.makeMainFrame()!! WidePowerGaugePanel(this, frame, menu.energy, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) - SlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) + BatterySlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) val self = this val progress = object : ProgressGaugePanel(self, frame, menu.progress, 78f, PROGRESS_ARROW_TOP) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/DriveRackScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/DriveRackScreen.kt index b36a6a69c..73fd9059c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/DriveRackScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/DriveRackScreen.kt @@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.client.screen import net.minecraft.network.chat.Component import ru.dbotthepony.mc.otm.menu.DriveRackMenu import net.minecraft.world.entity.player.Inventory +import ru.dbotthepony.mc.otm.client.screen.panels.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.panels.SlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel @@ -15,7 +16,7 @@ class DriveRackScreen(menu: DriveRackMenu, inventory: Inventory, title: Componen val frame = super.makeMainFrame()!! WidePowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) - SlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) + BatterySlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) SlotPanel(this, frame, menu.storageSlots[0], 71f, 32f) SlotPanel(this, frame, menu.storageSlots[1], 71f + 18f, 32f) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/DriveViewerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/DriveViewerScreen.kt index 04be72afa..6700bd60a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/DriveViewerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/DriveViewerScreen.kt @@ -46,7 +46,7 @@ class DriveViewerScreen(menu: DriveViewerMenu, inventory: Inventory, title: Comp } views.add(PowerGaugePanel(this, frame, menu.powerWidget, 8f, 16f)) - views.add(SlotPanel(this, frame, menu.batterySlot, 8f, 67f)) + views.add(BatterySlotPanel(this, frame, menu.batterySlot, 8f, 67f)) views.add(SlotPanel(this, frame, menu.driveSlot, 8f, 85f)) val grid = GridPanel(this, frame, 28f, 16f, GRID_WIDTH * 18f, GRID_HEIGHT * 18f, GRID_WIDTH, GRID_HEIGHT) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterBottlerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterBottlerScreen.kt index 15a02016b..045caa514 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterBottlerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterBottlerScreen.kt @@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.client.screen import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.TranslatableComponent +import ru.dbotthepony.mc.otm.client.screen.panels.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.ButtonPanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.panels.SlotPanel @@ -22,7 +23,7 @@ class MatterBottlerScreen(menu: MatterBottlerMenu, inventory: Inventory, title: val p = PowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) MatterGaugePanel(this, frame, menu.matterWidget, LEFT_MARGIN + p.width, GAUGE_TOP_WITH_SLOT) - SlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) + BatterySlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) for (i in 0 .. 2) { SlotPanel(this, frame, menu.storageSlots[i], 31f + i * 18, PROGRESS_SLOT_TOP) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterDecomposerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterDecomposerScreen.kt index 04fd54225..ed562772f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterDecomposerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterDecomposerScreen.kt @@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.client.screen import net.minecraft.network.chat.Component import ru.dbotthepony.mc.otm.menu.MatterDecomposerMenu import net.minecraft.world.entity.player.Inventory +import ru.dbotthepony.mc.otm.client.screen.panels.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.panels.SlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel @@ -18,7 +19,7 @@ class MatterDecomposerScreen(p_97741_: MatterDecomposerMenu, p_97742_: Inventory val m = PowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) MatterGaugePanel(this, frame, menu.matterWidget, LEFT_MARGIN + m.width, GAUGE_TOP_WITH_SLOT) - SlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) + BatterySlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) SlotPanel(this, frame, menu.input, 56f, PROGRESS_SLOT_TOP) ProgressGaugePanel(this, frame, menu.progressWidget, 78f, PROGRESS_ARROW_TOP) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterRecyclerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterRecyclerScreen.kt index cd9956e7c..8379ddc47 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterRecyclerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterRecyclerScreen.kt @@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.client.screen import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory +import ru.dbotthepony.mc.otm.client.screen.panels.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.panels.SlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel @@ -16,7 +17,7 @@ class MatterRecyclerScreen(menu: MatterRecyclerMenu, inventory: Inventory, title val m = PowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) MatterGaugePanel(this, frame, menu.matter, LEFT_MARGIN + m.width, GAUGE_TOP_WITH_SLOT) - SlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) + BatterySlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) ProgressGaugePanel(this, frame, menu.progress, 63f, PROGRESS_ARROW_TOP).flop = true SlotPanel(this, frame, menu.input, 93f, PROGRESS_SLOT_TOP) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterReplicatorScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterReplicatorScreen.kt index a2937b928..cd9ba2e7e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterReplicatorScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterReplicatorScreen.kt @@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.client.screen import net.minecraft.network.chat.Component import ru.dbotthepony.mc.otm.menu.MatterReplicatorMenu import net.minecraft.world.entity.player.Inventory +import ru.dbotthepony.mc.otm.client.screen.panels.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.panels.SlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel @@ -17,7 +18,7 @@ class MatterReplicatorScreen(p_97741_: MatterReplicatorMenu, p_97742_: Inventory val m = PowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) MatterGaugePanel(this, frame, menu.matter, LEFT_MARGIN + m.width, GAUGE_TOP_WITH_SLOT) - SlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) + BatterySlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) ProgressGaugePanel(this, frame, menu.progress, 54f, PROGRESS_ARROW_TOP) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterScannerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterScannerScreen.kt index 82d3097a4..dc4cf2085 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterScannerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterScannerScreen.kt @@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.client.screen import net.minecraft.network.chat.Component import ru.dbotthepony.mc.otm.menu.MatterScannerMenu import net.minecraft.world.entity.player.Inventory +import ru.dbotthepony.mc.otm.client.screen.panels.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.panels.SlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.PatternGaugePanel @@ -17,7 +18,7 @@ class MatterScannerScreen(p_97741_: MatterScannerMenu, p_97742_: Inventory, p_97 val m = PowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) PatternGaugePanel(this, frame, menu.patterns, LEFT_MARGIN + m.width, GAUGE_TOP_WITH_SLOT) - SlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) + BatterySlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) ProgressGaugePanel(this, frame, menu.progress, 63f, PROGRESS_ARROW_TOP).flop = true SlotPanel(this, frame, menu.input, 93f, PROGRESS_SLOT_TOP) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/PlatePressScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/PlatePressScreen.kt index 1ba015646..746235eac 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/PlatePressScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/PlatePressScreen.kt @@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.client.screen import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory +import ru.dbotthepony.mc.otm.client.screen.panels.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.panels.SlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel @@ -15,7 +16,7 @@ class PlatePressScreen(menu: PlatePressMenu, inventory: Inventory, title: Compon val frame = super.makeMainFrame()!! WidePowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) - SlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) + BatterySlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) SlotPanel(this, frame, menu.inputSlot, 56f, PROGRESS_SLOT_TOP) ProgressGaugePanel(this, frame, menu.progressGauge, 78f, PROGRESS_ARROW_TOP) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StorageBusScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StorageBusScreen.kt index 845d3d43a..342a0dfea 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StorageBusScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StorageBusScreen.kt @@ -3,10 +3,7 @@ package ru.dbotthepony.mc.otm.client.screen import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.TranslatableComponent -import ru.dbotthepony.mc.otm.client.screen.panels.CheckBoxLabelInputPanel -import ru.dbotthepony.mc.otm.client.screen.panels.FilterSlotPanel -import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel -import ru.dbotthepony.mc.otm.client.screen.panels.SlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel @@ -18,7 +15,7 @@ class StorageBusScreen(menu: StorageBusMenu, inventory: Inventory, title: Compon val frame = super.makeMainFrame()!! WidePowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) - SlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) + BatterySlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) for (row in 0 .. 2) { for (column in 0 .. 5) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StorageExporterScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StorageExporterScreen.kt index fc5b57dd1..7ea5b4169 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StorageExporterScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StorageExporterScreen.kt @@ -3,10 +3,7 @@ package ru.dbotthepony.mc.otm.client.screen import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.TranslatableComponent -import ru.dbotthepony.mc.otm.client.screen.panels.CheckBoxLabelInputPanel -import ru.dbotthepony.mc.otm.client.screen.panels.FilterSlotPanel -import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel -import ru.dbotthepony.mc.otm.client.screen.panels.SlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel @@ -18,7 +15,7 @@ class StorageExporterScreen(menu: StorageExporterMenu, inventory: Inventory, tit val frame = super.makeMainFrame()!! WidePowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) - SlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) + BatterySlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) for (row in 0 .. 2) { for (column in 0 .. 5) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StorageImporterScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StorageImporterScreen.kt index 997156713..d6aff0902 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StorageImporterScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StorageImporterScreen.kt @@ -3,10 +3,7 @@ package ru.dbotthepony.mc.otm.client.screen import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.TranslatableComponent -import ru.dbotthepony.mc.otm.client.screen.panels.CheckBoxLabelInputPanel -import ru.dbotthepony.mc.otm.client.screen.panels.FilterSlotPanel -import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel -import ru.dbotthepony.mc.otm.client.screen.panels.SlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel @@ -18,7 +15,7 @@ class StorageImporterScreen(menu: StorageImporterMenu, inventory: Inventory, tit val frame = super.makeMainFrame()!! WidePowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) - SlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) + BatterySlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) for (row in 0 .. 2) { for (column in 0 .. 5) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StoragePowerSupplierScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StoragePowerSupplierScreen.kt index 057811411..7e0f0d90e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StoragePowerSupplierScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StoragePowerSupplierScreen.kt @@ -16,7 +16,7 @@ class StoragePowerSupplierScreen(menu: StoragePowerSupplierMenu, inventory: Inve val frame = super.makeMainFrame()!! WidePowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) - SlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) + BatterySlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) object : Label(this@StoragePowerSupplierScreen, frame, 28f, 17f, width = 140f) { override fun tick() { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/AbstractSlotPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/AbstractSlotPanel.kt index cc02c0fbd..b9b59d0b7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/AbstractSlotPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/AbstractSlotPanel.kt @@ -8,10 +8,7 @@ import net.minecraft.world.item.ItemStack import net.minecraftforge.client.extensions.common.IClientItemExtensions import org.lwjgl.opengl.GL11 import ru.dbotthepony.mc.otm.client.minecraft -import ru.dbotthepony.mc.otm.client.render.WidgetLocation -import ru.dbotthepony.mc.otm.client.render.drawColor -import ru.dbotthepony.mc.otm.client.render.drawRect -import ru.dbotthepony.mc.otm.client.render.drawTexturedRectAuto +import ru.dbotthepony.mc.otm.client.render.* import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.core.RGBAColor @@ -21,7 +18,8 @@ abstract class AbstractSlotPanel @JvmOverloads constructor( x: Float = 0f, y: Float = 0f, width: Float = SIZE, - height: Float = SIZE + height: Float = SIZE, + open val noItemIcon: SkinElement? = null ) : EditablePanel( screen, parent, x, y, width, height ) { @@ -86,7 +84,12 @@ abstract class AbstractSlotPanel @JvmOverloads constructor( override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { renderSlotBackground(stack, mouseX, mouseY, partialTick) - renderRegular(stack, getItemStack()) + val itemStack = getItemStack() + renderRegular(stack, itemStack) + + if (itemStack.isEmpty) { + noItemIcon?.render(stack, width = width, height = height) + } } override fun innerRenderTooltips(stack: PoseStack, mouse_x: Float, mouse_y: Float, flag: Float): Boolean { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EditablePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EditablePanel.kt index 2f7dd1f97..878558b68 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EditablePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EditablePanel.kt @@ -124,8 +124,10 @@ open class EditablePanel @JvmOverloads constructor( protected val children = ArrayList() val childrenView: List = Collections.unmodifiableList(children) - private var layoutInvalidated = true - private var boundsInvalidated = true + var layoutInvalidated = true + private set + var boundsInvalidated = true + private set protected var visibleAsChildren: Boolean = true private set diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/SlotPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/SlotPanel.kt index 9d605e8e1..787144bf6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/SlotPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/SlotPanel.kt @@ -9,6 +9,8 @@ import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.inventory.Slot import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.client.minecraft +import ru.dbotthepony.mc.otm.client.render.SkinElement +import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.render.drawRect import ru.dbotthepony.mc.otm.client.render.setDrawColor import ru.dbotthepony.mc.otm.client.screen.MatteryScreen @@ -20,9 +22,10 @@ open class SlotPanel( val slot: T, x: Float = 0f, y: Float = 0f, - width: Float = 18f, - height: Float = 18f -) : AbstractSlotPanel(screen, parent, x, y, width, height) { + width: Float = AbstractSlotPanel.SIZE, + height: Float = AbstractSlotPanel.SIZE, + noItemIcon: SkinElement? = null +) : AbstractSlotPanel(screen, parent, x, y, width, height, noItemIcon) { override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean { screen.returnSlot = slot return true @@ -91,6 +94,8 @@ open class SlotPanel( val texture = minecraft.getTextureAtlas(icon.first).apply(icon.second) RenderSystem.setShaderTexture(0, texture.atlas().location()) GuiComponent.blit(stack, 1, 1, 0, 16, 16, texture) + } else { + noItemIcon?.render(stack, width = width, height = height) } } @@ -105,4 +110,14 @@ open class SlotPanel( // no op, screen does it for us (completely) return false } -} \ No newline at end of file +} + +fun BatterySlotPanel( + screen: MatteryScreen<*>, + parent: EditablePanel?, + slot: T, + x: Float = 0f, + y: Float = 0f, + width: Float = AbstractSlotPanel.SIZE, + height: Float = AbstractSlotPanel.SIZE, +) = SlotPanel(screen, parent, slot, x, y, width, height, Widgets18.BATTERY_SLOT_BACKGROUND) diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets_18.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets_18.png index 7cbc2444df4367296564829fcda078bbe92d8f9b..a454bd484fa9c6c2fd258decb2b6086d15d259ad 100644 GIT binary patch delta 679 zcmV;Y0$BZ$3hoN9x&eRx0RI60puMM)00009a7bBm000XU000XU0RWnu7ytkO2XskI zMF-{y0S6@8l27=Yp9syD#|VyL=xLM&bp+%jVIf|$Bh z9S}@hhP%{~gYXZ>#u#`WDH2J^2_pFAJH#{zA>^S4dEU!1y-9zPBniN%eGego<#O3+ zk^O!jLI`2CT6J1yx7!u*c&iw`yZrwhesA<+zwc4&@T35R5W;jijauM*K7aXqyPeoqt$x9|NQlf7ogXjo~{qtd#0-_ z%ktv7<;%~Q>~8)1wzsJ%LPN*rayllL)3Nosu~QTAzPStH4$w4BlX7&5uN5DkydAq0 zilO6Ew%Kg*n190rG|Kptqtj(#C0JCjcF1ZLwv9Wdx>zgy-wX$>s{h8HsWIfddn@;z47U5@_FPIY>d$;e=YW8 z#V+xw`_sBVyPJRpQQqQIg`n#JpJiEI{%AW*)m@Ig4MR_lbM*i^j3j z#;xm=qv3zyR2_|HoUAyR&2tlu0F5$2O<{S)bk@gh>Eruj@1Le<40*ER<#bFYvw2>3 zZjU$#(9Az43X%%2x&eOx00000`9r&Z00009a7bBm000XU000XU0RWnu7ytkO2XskI zMF-{x9|Zv{8Oy$-00y7uNRJl&lV2A>u(rlt(swrzWCx?Sqr=C<#)oqA4VAtZbdKn235FD&{7 z?OLZ}eIX=#5I_aPrwyGY6+;?QecL%z%#!MOLlX5I}`KADJ?R85`Ior(o|` z2?-yD{0NSD$5d4n)1Tb%LHMw;3g})yEd9(TCwv|;1$%$T&`5umyI4{9sDM6NI>i|Z zf~5n#U0XDDjZs=f4Q=P1!?UZ$d!aFRosjTR0ex)_dhh(!c1SSEKKm-UEFyIfC)~aq=RbZR| O0000