From 583b9dc2082ab34f24d2b3141f6100b1bea039a1 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 7 Nov 2024 13:11:15 +0700 Subject: [PATCH] "Draw building guide" checkbox --- .../mc/otm/datagen/lang/English.kt | 1 + .../mc/otm/datagen/lang/Russian.kt | 1 + .../mc/otm/client/render/WidgetLocation.kt | 1 + .../blockentity/BlackHoleGeneratorRenderer.kt | 6 +++--- .../screen/panels/button/CheckBoxPanel.kt | 16 ++++++++-------- .../screen/tech/BlackHoleGeneratorScreen.kt | 19 ++++++++----------- .../multiblock/ShapedMultiblockBuilder.kt | 12 ++++++------ 7 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index d9514b613..343421c3c 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -853,6 +853,7 @@ private fun androidFeatures(provider: MatteryLanguageProvider) { private fun gui(provider: MatteryLanguageProvider) { with(provider.english) { + gui("draw_multiblock_guide", "Draw building guide") gui("ago", "%s ago") gui("time.short.5s", "5s") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index 6bcbe1a0a..91b373a4b 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -857,6 +857,7 @@ private fun androidFeatures(provider: MatteryLanguageProvider) { private fun gui(provider: MatteryLanguageProvider) { with(provider.russian) { + gui("draw_multiblock_guide", "Отображать помощника постройки") gui("ago", "%s тому назад") gui("time.short.5s", "5с") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt index de5df4aeb..3377e5dcf 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt @@ -16,6 +16,7 @@ object WidgetLocation { val PATTERN_PANEL_TABS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/pattern_panel_tabs.png"), 60f, 23f) val CHECKBOX = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/checkbox.png"), 30f, 60f) + val RADIO = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/radio.png"), 30f, 60f) val PROGRESS_ARROWS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/progress_arrows.png"), 22f, 31f) val HORIZONTAL_GAUGES = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/horizontal_gauges.png"), 96f, 108f) val VERTICAL_GAUGES = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/vertical_gauges.png"), 90f, 48f) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BlackHoleGeneratorRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BlackHoleGeneratorRenderer.kt index 250ec9077..34cd93f94 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BlackHoleGeneratorRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BlackHoleGeneratorRenderer.kt @@ -17,8 +17,8 @@ class BlackHoleGeneratorRenderer(private val context: BlockEntityRendererProvide packedLight: Int, packedOverlay: Int ) { - //if (!tile.drawBuildingGuide) return - val multiblock = tile.multiblock ?: return - multiblock.render(poseStack, DynamicBufferSource.WORLD, tile.blockPos) + if (tile.drawBuildingGuide) { + tile.multiblock?.render(poseStack, DynamicBufferSource.WORLD, tile.blockPos) + } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxPanel.kt index 8d4cbbc13..694d24aa3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxPanel.kt @@ -16,14 +16,14 @@ open class CheckBoxPanel( height: Float = REGULAR_DIMENSIONS, open val isChecked: Delegate = Delegate.Box(false) ) : AbstractButtonPanel(screen, parent, x, y, width, height) { - open val IDLE_UNCHECKED: AbstractMatterySprite = Companion.IDLE_UNCHECKED - open val IDLE_CHECKED: AbstractMatterySprite = Companion.IDLE_CHECKED - open val HOVERED_UNCHECKED: AbstractMatterySprite = Companion.HOVERED_UNCHECKED - open val HOVERED_CHECKED: AbstractMatterySprite = Companion.HOVERED_CHECKED - open val PRESSED_UNCHECKED: AbstractMatterySprite = Companion.PRESSED_UNCHECKED - open val PRESSED_CHECKED: AbstractMatterySprite = Companion.PRESSED_CHECKED - open val DISABLED_UNCHECKED: AbstractMatterySprite = Companion.DISABLED_UNCHECKED - open val DISABLED_CHECKED: AbstractMatterySprite = Companion.DISABLED_CHECKED + open val IDLE_UNCHECKED: AbstractMatterySprite get() = Companion.IDLE_UNCHECKED + open val IDLE_CHECKED: AbstractMatterySprite get() = Companion.IDLE_CHECKED + open val HOVERED_UNCHECKED: AbstractMatterySprite get() = Companion.HOVERED_UNCHECKED + open val HOVERED_CHECKED: AbstractMatterySprite get() = Companion.HOVERED_CHECKED + open val PRESSED_UNCHECKED: AbstractMatterySprite get() = Companion.PRESSED_UNCHECKED + open val PRESSED_CHECKED: AbstractMatterySprite get() = Companion.PRESSED_CHECKED + open val DISABLED_UNCHECKED: AbstractMatterySprite get() = Companion.DISABLED_UNCHECKED + open val DISABLED_CHECKED: AbstractMatterySprite get() = Companion.DISABLED_CHECKED protected fun renderCheckboxBackground(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { if (isDisabled) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/BlackHoleGeneratorScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/BlackHoleGeneratorScreen.kt index 04fad457e..92f2328cc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/BlackHoleGeneratorScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/BlackHoleGeneratorScreen.kt @@ -2,36 +2,33 @@ package ru.dbotthepony.mc.otm.client.screen.tech import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory -import ru.dbotthepony.mc.otm.client.render.RenderGravity import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.Dock -import ru.dbotthepony.mc.otm.client.screen.panels.DockResizeMode import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.CheckBoxLabelInputPanel import ru.dbotthepony.mc.otm.client.screen.widget.ProfiledMatterGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.ProfiledPowerGaugePanel -import ru.dbotthepony.mc.otm.client.screen.widget.TallHorizontalProfiledPowerGaugePanel -import ru.dbotthepony.mc.otm.client.screen.widget.WideProfiledPowerGaugePanel +import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.menu.tech.BlackHoleGeneratorMenu -import ru.dbotthepony.mc.otm.menu.tech.CobblerMenu class BlackHoleGeneratorScreen(menu: BlackHoleGeneratorMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { override fun makeMainFrame(): FramePanel> { val frame = FramePanel.padded(this, 200f, 60f, title) - val left = EditablePanel(this, frame) - val energy = ProfiledPowerGaugePanel(this, frame, menu.energy) val matter = ProfiledMatterGaugePanel(this, frame, menu.matter) - left.width = energy.width + matter.width + 1f - energy.parent = left - matter.parent = left matter.dockLeft = 1f - left.dock = Dock.LEFT energy.dock = Dock.LEFT matter.dock = Dock.LEFT + matter.dockRight = 4f + + val drawGuide = CheckBoxLabelInputPanel(this, frame, menu.drawBuildingGuide, TranslatableComponent("otm.gui.draw_multiblock_guide")) + drawGuide.dock = Dock.TOP + drawGuide.dockBottom = 2f + return frame } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/multiblock/ShapedMultiblockBuilder.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/multiblock/ShapedMultiblockBuilder.kt index ad2d0c77d..91868056d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/multiblock/ShapedMultiblockBuilder.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/multiblock/ShapedMultiblockBuilder.kt @@ -218,42 +218,42 @@ class ShapedMultiblockBuilder { } /** - * Creates new node relative to this node at [diff], which behaves as if being [Or] node + * Creates new node relative to this node at [diff], which behaves by default as [Strategy.OR_EITHER] */ fun relative(diff: Vec3i): Node { return node(pos + diff) } /** - * Creates new node relative to this node at [dir] side, which behaves as if being [Or] node + * Creates new node relative to this node at [dir] side, which behaves by default as [Strategy.OR_EITHER] */ fun relative(dir: Direction): Node { return relative(dir.normal) } /** - * Creates new node relative to this node at [dir] side, which behaves as if being [Or] node + * Creates new node relative to this node at [dir] side, which behaves by default as [Strategy.OR_EITHER] */ fun relative(dir: RelativeSide): Node { return relative(dir.default) } /** - * Creates new node relative to this node at [diff], and configures it in-place using provided [configurator] expression, which behaves as if being [Or] node + * Creates new node relative to this node at [diff], and configures it in-place using provided [configurator] expression, which behaves by default as [Strategy.OR_EITHER] */ fun relative(diff: Vec3i, configurator: Node.() -> Unit): Node { return node(pos + diff).also(configurator) } /** - * Creates new node relative to this node at [dir] side, and configures it in-place using provided [configurator] expression, which behaves as if being [Or] node + * Creates new node relative to this node at [dir] side, and configures it in-place using provided [configurator] expression, which behaves by default as [Strategy.OR_EITHER] */ fun relative(dir: Direction, configurator: Node.() -> Unit): Node { return relative(dir.normal).also(configurator) } /** - * Creates new node relative to this node at [dir] side, and configures it in-place using provided [configurator] expression, which behaves as if being [Or] node + * Creates new node relative to this node at [dir] side, and configures it in-place using provided [configurator] expression, which behaves by default as [Strategy.OR_EITHER] */ fun relative(dir: RelativeSide, configurator: Node.() -> Unit): Node { return relative(dir.default).also(configurator)