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 e768e895e..e1c0e931a 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 @@ -6,6 +6,7 @@ import net.minecraft.world.entity.player.Inventory import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.screen.panels.* +import ru.dbotthepony.mc.otm.client.screen.panels.buttons.CheckBoxLabelInputPanel import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel import ru.dbotthepony.mc.otm.core.maxScrollDivision import ru.dbotthepony.mc.otm.item.PortableCondensationDriveItem @@ -116,4 +117,4 @@ class DriveViewerScreen(menu: DriveViewerMenu, inventory: Inventory, title: Comp const val GRID_WIDTH = 9 const val GRID_HEIGHT = 5 } -} \ No newline at end of file +} 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 5425256a0..e2546153b 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 @@ -4,6 +4,7 @@ import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.screen.panels.* +import ru.dbotthepony.mc.otm.client.screen.panels.buttons.CheckBoxLabelInputPanel import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel import ru.dbotthepony.mc.otm.menu.StorageBusMenu 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 3ffded024..ff6276da6 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 @@ -4,6 +4,7 @@ import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.screen.panels.* +import ru.dbotthepony.mc.otm.client.screen.panels.buttons.CheckBoxLabelInputPanel import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel import ru.dbotthepony.mc.otm.menu.StorageExporterMenu 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 eccb87be7..5da4971ac 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 @@ -4,6 +4,7 @@ import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.screen.panels.* +import ru.dbotthepony.mc.otm.client.screen.panels.buttons.CheckBoxLabelInputPanel import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel import ru.dbotthepony.mc.otm.menu.StorageImporterMenu diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxInputPanel.kt new file mode 100644 index 000000000..a5bfd55fa --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxInputPanel.kt @@ -0,0 +1,28 @@ +package ru.dbotthepony.mc.otm.client.screen.panels.buttons + +import net.minecraft.client.gui.screens.Screen +import ru.dbotthepony.mc.otm.client.minecraft +import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel +import ru.dbotthepony.mc.otm.menu.widget.BooleanPlayerInputWidget + +open class CheckBoxInputPanel @JvmOverloads constructor( + screen: S, + parent: EditablePanel<*>?, + val widget: BooleanPlayerInputWidget, + x: Float = 0f, + y: Float = 0f, + width: Float = REGULAR_DIMENSIONS + 120f, + height: Float = REGULAR_DIMENSIONS +) : CheckBoxPanel(screen, parent, x, y, width, height) { + override var checked: Boolean + get() = widget.value + set(value) {} + + override var isDisabled: Boolean + get() = !widget.ignoreSpectators || minecraft.player?.isSpectator == true + set(value) {} + + override fun onClick() { + widget.userInput(!checked, minecraft.player) + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxLabelInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxLabelInputPanel.kt new file mode 100644 index 000000000..d42d56c43 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxLabelInputPanel.kt @@ -0,0 +1,30 @@ +package ru.dbotthepony.mc.otm.client.screen.panels.buttons + +import net.minecraft.client.gui.screens.Screen +import net.minecraft.network.chat.Component +import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel +import ru.dbotthepony.mc.otm.client.screen.panels.Label +import ru.dbotthepony.mc.otm.menu.widget.BooleanPlayerInputWidget + +open class CheckBoxLabelInputPanel @JvmOverloads constructor( + screen: S, + parent: EditablePanel<*>?, + widget: BooleanPlayerInputWidget, + text: Component, + x: Float = 0f, + y: Float = 0f, + width: Float = CheckBoxPanel.REGULAR_DIMENSIONS + 120f, + height: Float = CheckBoxPanel.REGULAR_DIMENSIONS +) : EditablePanel(screen, parent, x, y, width, height) { + val widget get() = checkbox.widget + val checkbox = CheckBoxInputPanel( + screen, + this, + widget, + 0f, + 0f, + CheckBoxPanel.REGULAR_DIMENSIONS, + CheckBoxPanel.REGULAR_DIMENSIONS + ) + val label = Label(screen, this, CheckBoxPanel.REGULAR_DIMENSIONS + 4f, 4f, text = text) +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxLabelPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxLabelPanel.kt new file mode 100644 index 000000000..4d24b4ac8 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxLabelPanel.kt @@ -0,0 +1,20 @@ +package ru.dbotthepony.mc.otm.client.screen.panels.buttons + +import net.minecraft.client.gui.screens.Screen +import net.minecraft.network.chat.Component +import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel +import ru.dbotthepony.mc.otm.client.screen.panels.Label + +open class CheckBoxLabelPanel @JvmOverloads constructor( + screen: S, + parent: EditablePanel<*>?, + text: Component, + x: Float = 0f, + y: Float = 0f, + width: Float = CheckBoxPanel.REGULAR_DIMENSIONS + 120f, + height: Float = CheckBoxPanel.REGULAR_DIMENSIONS +) : EditablePanel(screen, parent, x, y, width, height) { + val checkbox = + CheckBoxPanel(screen, this, 0f, 0f, CheckBoxPanel.REGULAR_DIMENSIONS, CheckBoxPanel.REGULAR_DIMENSIONS) + val label = Label(screen, this, CheckBoxPanel.REGULAR_DIMENSIONS + 4f, 4f, text = text) +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/CheckBox.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxPanel.kt similarity index 60% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/CheckBox.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxPanel.kt index 0cdf82698..084ee8479 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/CheckBox.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxPanel.kt @@ -1,16 +1,13 @@ -package ru.dbotthepony.mc.otm.client.screen.panels +package ru.dbotthepony.mc.otm.client.screen.panels.buttons import com.mojang.blaze3d.platform.InputConstants import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.gui.screens.Screen -import net.minecraft.network.chat.Component -import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.playGuiClickSound import ru.dbotthepony.mc.otm.client.render.AbstractSkinElement import ru.dbotthepony.mc.otm.client.render.WidgetLocation import ru.dbotthepony.mc.otm.client.render.subGrid -import ru.dbotthepony.mc.otm.client.screen.panels.CheckBoxPanel.Companion.REGULAR_DIMENSIONS -import ru.dbotthepony.mc.otm.menu.widget.BooleanPlayerInputWidget +import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel open class CheckBoxPanel @JvmOverloads constructor( screen: S, @@ -108,52 +105,3 @@ open class CheckBoxPanel @JvmOverloads constructor( } } -open class CheckBoxInputPanel @JvmOverloads constructor( - screen: S, - parent: EditablePanel<*>?, - val widget: BooleanPlayerInputWidget, - x: Float = 0f, - y: Float = 0f, - width: Float = REGULAR_DIMENSIONS + 120f, - height: Float = REGULAR_DIMENSIONS -) : CheckBoxPanel(screen, parent, x, y, width, height) { - override var checked: Boolean - get() = widget.value - set(value) {} - - override var isDisabled: Boolean - get() = !widget.ignoreSpectators || minecraft.player?.isSpectator == true - set(value) {} - - override fun onClick() { - widget.userInput(!checked, minecraft.player) - } -} - -open class CheckBoxLabelPanel @JvmOverloads constructor( - screen: S, - parent: EditablePanel<*>?, - text: Component, - x: Float = 0f, - y: Float = 0f, - width: Float = REGULAR_DIMENSIONS + 120f, - height: Float = REGULAR_DIMENSIONS -) : EditablePanel(screen, parent, x, y, width, height) { - val checkbox = CheckBoxPanel(screen, this, 0f, 0f, REGULAR_DIMENSIONS, REGULAR_DIMENSIONS) - val label = Label(screen, this, REGULAR_DIMENSIONS + 4f, 4f, text = text) -} - -open class CheckBoxLabelInputPanel @JvmOverloads constructor( - screen: S, - parent: EditablePanel<*>?, - widget: BooleanPlayerInputWidget, - text: Component, - x: Float = 0f, - y: Float = 0f, - width: Float = REGULAR_DIMENSIONS + 120f, - height: Float = REGULAR_DIMENSIONS -) : EditablePanel(screen, parent, x, y, width, height) { - val widget get() = checkbox.widget - val checkbox = CheckBoxInputPanel(screen, this, widget, 0f, 0f, REGULAR_DIMENSIONS, REGULAR_DIMENSIONS) - val label = Label(screen, this, REGULAR_DIMENSIONS + 4f, 4f, text = text) -}