Split checkbox panels file
This commit is contained in:
parent
b2181819ca
commit
b6b7ea6a77
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
@ -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)
|
||||
}
|
@ -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)
|
||||
}
|
@ -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<out S : Screen> @JvmOverloads constructor(
|
||||
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)
|
||||
}
|
Loading…
Reference in New Issue
Block a user