Split checkbox panels file

This commit is contained in:
DBotThePony 2022-10-21 22:46:35 +07:00
parent b2181819ca
commit b6b7ea6a77
Signed by: DBot
GPG Key ID: DCC23B5715498507
8 changed files with 85 additions and 55 deletions

View File

@ -6,6 +6,7 @@ import net.minecraft.world.entity.player.Inventory
import net.minecraft.world.item.ItemStack import net.minecraft.world.item.ItemStack
import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.TranslatableComponent
import ru.dbotthepony.mc.otm.client.screen.panels.* 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.client.screen.widget.PowerGaugePanel
import ru.dbotthepony.mc.otm.core.maxScrollDivision import ru.dbotthepony.mc.otm.core.maxScrollDivision
import ru.dbotthepony.mc.otm.item.PortableCondensationDriveItem import ru.dbotthepony.mc.otm.item.PortableCondensationDriveItem

View File

@ -4,6 +4,7 @@ import net.minecraft.network.chat.Component
import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Inventory
import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.TranslatableComponent
import ru.dbotthepony.mc.otm.client.screen.panels.* 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.client.screen.widget.WidePowerGaugePanel
import ru.dbotthepony.mc.otm.menu.StorageBusMenu import ru.dbotthepony.mc.otm.menu.StorageBusMenu

View File

@ -4,6 +4,7 @@ import net.minecraft.network.chat.Component
import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Inventory
import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.TranslatableComponent
import ru.dbotthepony.mc.otm.client.screen.panels.* 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.client.screen.widget.WidePowerGaugePanel
import ru.dbotthepony.mc.otm.menu.StorageExporterMenu import ru.dbotthepony.mc.otm.menu.StorageExporterMenu

View File

@ -4,6 +4,7 @@ import net.minecraft.network.chat.Component
import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Inventory
import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.TranslatableComponent
import ru.dbotthepony.mc.otm.client.screen.panels.* 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.client.screen.widget.WidePowerGaugePanel
import ru.dbotthepony.mc.otm.menu.StorageImporterMenu import ru.dbotthepony.mc.otm.menu.StorageImporterMenu

View File

@ -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<out S : Screen> @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<S>(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)
}
}

View File

@ -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<out S : Screen> @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<S>(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)
}

View File

@ -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<out S : Screen> @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<S>(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)
}

View File

@ -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.platform.InputConstants
import com.mojang.blaze3d.vertex.PoseStack import com.mojang.blaze3d.vertex.PoseStack
import net.minecraft.client.gui.screens.Screen 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.playGuiClickSound
import ru.dbotthepony.mc.otm.client.render.AbstractSkinElement import ru.dbotthepony.mc.otm.client.render.AbstractSkinElement
import ru.dbotthepony.mc.otm.client.render.WidgetLocation import ru.dbotthepony.mc.otm.client.render.WidgetLocation
import ru.dbotthepony.mc.otm.client.render.subGrid 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.client.screen.panels.EditablePanel
import ru.dbotthepony.mc.otm.menu.widget.BooleanPlayerInputWidget
open class CheckBoxPanel<out S : Screen> @JvmOverloads constructor( open class CheckBoxPanel<out S : Screen> @JvmOverloads constructor(
screen: S, screen: S,
@ -108,52 +105,3 @@ open class CheckBoxPanel<out S : Screen> @JvmOverloads constructor(
} }
} }
open class CheckBoxInputPanel<out S : Screen> @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<S>(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<out S : Screen> @JvmOverloads constructor(
screen: S,
parent: EditablePanel<*>?,
text: Component,
x: Float = 0f,
y: Float = 0f,
width: Float = REGULAR_DIMENSIONS + 120f,
height: Float = REGULAR_DIMENSIONS
) : EditablePanel<S>(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<out S : Screen> @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<S>(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)
}