Holo sign text coloring
This commit is contained in:
parent
a72f2aabb2
commit
005c8b0396
@ -155,6 +155,8 @@ private fun misc(provider: MatteryLanguageProvider) {
|
|||||||
gui("exopack.change_color2", "Remove color")
|
gui("exopack.change_color2", "Remove color")
|
||||||
gui("exopack.go_curios", "Open Curios inventory")
|
gui("exopack.go_curios", "Open Curios inventory")
|
||||||
|
|
||||||
|
gui("change_color", "Customize color")
|
||||||
|
|
||||||
gui("exopack.probe1", "This little device feels unnatural to touch, it is almost certainly resilient to any possible attempt to break it open.")
|
gui("exopack.probe1", "This little device feels unnatural to touch, it is almost certainly resilient to any possible attempt to break it open.")
|
||||||
gui("exopack.probe2", "There is fingerprint reader built into one of sides which gently glow when touched.")
|
gui("exopack.probe2", "There is fingerprint reader built into one of sides which gently glow when touched.")
|
||||||
gui("exopack.probe3", "It seems this box will unlock once you strongly press fingerprint reader, and you feel what's inside will affect you without any way back!")
|
gui("exopack.probe3", "It seems this box will unlock once you strongly press fingerprint reader, and you feel what's inside will affect you without any way back!")
|
||||||
|
@ -163,6 +163,8 @@ private fun misc(provider: MatteryLanguageProvider) {
|
|||||||
gui("exopack.change_color2", "Убрать окраску")
|
gui("exopack.change_color2", "Убрать окраску")
|
||||||
gui("exopack.go_curios", "Открыть инвентарь Curios")
|
gui("exopack.go_curios", "Открыть инвентарь Curios")
|
||||||
|
|
||||||
|
gui("change_color", "Изменить цвет")
|
||||||
|
|
||||||
gui("exopack.probe1", "Данное маленькое устройство необычно на ощупь, а так же неприступно для любых попыток вскрыть.")
|
gui("exopack.probe1", "Данное маленькое устройство необычно на ощупь, а так же неприступно для любых попыток вскрыть.")
|
||||||
gui("exopack.probe2", "На одной из сторон данного устройства находится сканер отпечатка, который тускло загорается при касании.")
|
gui("exopack.probe2", "На одной из сторон данного устройства находится сканер отпечатка, который тускло загорается при касании.")
|
||||||
gui("exopack.probe3", "Вероятно, устройство откроется если достаточно сильно нажать на сканер отпечатка, и вы чувствуете, что последствия будут необратимы!")
|
gui("exopack.probe3", "Вероятно, устройство откроется если достаточно сильно нажать на сканер отпечатка, и вы чувствуете, что последствия будут необратимы!")
|
||||||
|
@ -25,12 +25,22 @@ class HoloSignBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryB
|
|||||||
access.write(value)
|
access.write(value)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
var textRed by synchronizer.float(1f).property
|
||||||
|
var textGreen by synchronizer.float(1f).property
|
||||||
|
var textBlue by synchronizer.float(85f / 255f).property
|
||||||
|
var textAlpha by synchronizer.float(1f).property
|
||||||
|
|
||||||
var isLocked = false
|
var isLocked = false
|
||||||
|
|
||||||
init {
|
init {
|
||||||
savetables.string(::signText)
|
savetables.string(::signText)
|
||||||
savetablesLevel.bool(::isLocked)
|
savetablesLevel.bool(::isLocked)
|
||||||
savetables.stateful(::redstoneControl)
|
savetables.stateful(::redstoneControl)
|
||||||
|
|
||||||
|
savetables.float(::textRed)
|
||||||
|
savetables.float(::textGreen)
|
||||||
|
savetables.float(::textBlue)
|
||||||
|
savetables.float(::textAlpha)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun createMenu(p_39954_: Int, p_39955_: Inventory, p_39956_: Player): AbstractContainerMenu {
|
override fun createMenu(p_39954_: Int, p_39955_: Inventory, p_39956_: Player): AbstractContainerMenu {
|
||||||
|
@ -38,7 +38,7 @@ class HoloSignRenderer(private val context: BlockEntityRendererProvider.Context)
|
|||||||
var y = -totalHeight / 2f
|
var y = -totalHeight / 2f
|
||||||
|
|
||||||
for (line in lines) {
|
for (line in lines) {
|
||||||
font.draw(poseStack = poseStack, buffer = sorse, text = line, gravity = RenderGravity.TOP_CENTER, y = y, color = RGBAColor.YELLOW)
|
font.draw(poseStack = poseStack, buffer = sorse, text = line, gravity = RenderGravity.TOP_CENTER, y = y, color = RGBAColor(tile.textRed, tile.textGreen, tile.textBlue, tile.textAlpha))
|
||||||
y += font.lineHeight + 2f
|
y += font.lineHeight + 2f
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,15 +2,21 @@ package ru.dbotthepony.mc.otm.client.screen.decorative
|
|||||||
|
|
||||||
import net.minecraft.network.chat.Component
|
import net.minecraft.network.chat.Component
|
||||||
import net.minecraft.world.entity.player.Inventory
|
import net.minecraft.world.entity.player.Inventory
|
||||||
|
import net.minecraft.world.item.ItemStack
|
||||||
|
import ru.dbotthepony.mc.otm.client.render.ItemStackIcon
|
||||||
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
|
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
|
||||||
|
import ru.dbotthepony.mc.otm.client.screen.panels.ColorPickerPanel
|
||||||
import ru.dbotthepony.mc.otm.client.screen.panels.Dock
|
import ru.dbotthepony.mc.otm.client.screen.panels.Dock
|
||||||
import ru.dbotthepony.mc.otm.client.screen.panels.DockProperty
|
import ru.dbotthepony.mc.otm.client.screen.panels.DockProperty
|
||||||
import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel
|
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.panels.button.CheckBoxLabelInputPanel
|
||||||
|
import ru.dbotthepony.mc.otm.client.screen.panels.button.LargeRectangleButtonPanel
|
||||||
import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls
|
import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls
|
||||||
import ru.dbotthepony.mc.otm.client.screen.panels.input.NetworkedStringInputPanel
|
import ru.dbotthepony.mc.otm.client.screen.panels.input.NetworkedStringInputPanel
|
||||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||||
|
import ru.dbotthepony.mc.otm.core.math.RGBAColor
|
||||||
import ru.dbotthepony.mc.otm.menu.decorative.HoloSignMenu
|
import ru.dbotthepony.mc.otm.menu.decorative.HoloSignMenu
|
||||||
|
import ru.dbotthepony.mc.otm.registry.MItems
|
||||||
|
|
||||||
class HoloSignScreen(menu: HoloSignMenu, inventory: Inventory, title: Component) : MatteryScreen<HoloSignMenu>(menu, title) {
|
class HoloSignScreen(menu: HoloSignMenu, inventory: Inventory, title: Component) : MatteryScreen<HoloSignMenu>(menu, title) {
|
||||||
override fun makeMainFrame(): FramePanel<MatteryScreen<*>> {
|
override fun makeMainFrame(): FramePanel<MatteryScreen<*>> {
|
||||||
@ -28,7 +34,26 @@ class HoloSignScreen(menu: HoloSignMenu, inventory: Inventory, title: Component)
|
|||||||
lock.dockMargin = DockProperty(2f, 2f, 2f, 2f)
|
lock.dockMargin = DockProperty(2f, 2f, 2f, 2f)
|
||||||
lock.tooltips.add(TranslatableComponent("otm.gui.lock_holo_screen.tip"))
|
lock.tooltips.add(TranslatableComponent("otm.gui.lock_holo_screen.tip"))
|
||||||
|
|
||||||
makeDeviceControls(this, frame, redstoneConfig = menu.redstone)
|
val controls = makeDeviceControls(this, frame, redstoneConfig = menu.redstone)
|
||||||
|
|
||||||
|
controls.addButton(object : LargeRectangleButtonPanel<HoloSignScreen>(this@HoloSignScreen, frame, onPress = {
|
||||||
|
frame.blockingWindow = ColorPickerPanel.frame(
|
||||||
|
this@HoloSignScreen,
|
||||||
|
callback = {
|
||||||
|
menu.textRed.accept(it.red)
|
||||||
|
menu.textGreen.accept(it.green)
|
||||||
|
menu.textBlue.accept(it.blue)
|
||||||
|
menu.textAlpha.accept(it.alpha)
|
||||||
|
},
|
||||||
|
color = RGBAColor(menu.textRed.value, menu.textGreen.value, menu.textBlue.value, menu.textAlpha.value),
|
||||||
|
isDisabled = { !menu.textRed.and(menu.textGreen).and(menu.textBlue).and(menu.textAlpha).test(minecraft?.player) },
|
||||||
|
title = TranslatableComponent("otm.gui.change_color"))
|
||||||
|
}) {
|
||||||
|
init {
|
||||||
|
tooltips.add(TranslatableComponent("otm.gui.change_color"))
|
||||||
|
icon = ItemStackIcon(ItemStack(MItems.PAINTER)).fixed()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
return frame
|
return frame
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
|||||||
import ru.dbotthepony.mc.otm.core.math.HSVColor
|
import ru.dbotthepony.mc.otm.core.math.HSVColor
|
||||||
import ru.dbotthepony.mc.otm.core.math.RGBAColor
|
import ru.dbotthepony.mc.otm.core.math.RGBAColor
|
||||||
import java.util.function.Consumer
|
import java.util.function.Consumer
|
||||||
|
import java.util.function.Supplier
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
open class ColorBoxPanel<out S : Screen>(
|
open class ColorBoxPanel<out S : Screen>(
|
||||||
@ -31,6 +32,7 @@ open class ColorBoxPanel<out S : Screen>(
|
|||||||
width: Float = 64f,
|
width: Float = 64f,
|
||||||
height: Float = 64f,
|
height: Float = 64f,
|
||||||
protected val callback: Consumer<HSVColor>? = null,
|
protected val callback: Consumer<HSVColor>? = null,
|
||||||
|
val isDisabled: Supplier<Boolean> = Supplier { false },
|
||||||
) : EditablePanel<S>(screen, parent, x, y, width, height) {
|
) : EditablePanel<S>(screen, parent, x, y, width, height) {
|
||||||
var backgroundColor = RGBAColor.RED
|
var backgroundColor = RGBAColor.RED
|
||||||
private set
|
private set
|
||||||
@ -66,7 +68,7 @@ open class ColorBoxPanel<out S : Screen>(
|
|||||||
|
|
||||||
override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean {
|
override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean {
|
||||||
if (button == InputConstants.MOUSE_BUTTON_LEFT) {
|
if (button == InputConstants.MOUSE_BUTTON_LEFT) {
|
||||||
if (!isPressed) {
|
if (!isPressed && !isDisabled.get()) {
|
||||||
isPressed = true
|
isPressed = true
|
||||||
grabMouseInput = true
|
grabMouseInput = true
|
||||||
|
|
||||||
@ -81,7 +83,7 @@ open class ColorBoxPanel<out S : Screen>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun mouseDraggedInner(x: Double, y: Double, button: Int, xDelta: Double, yDelta: Double): Boolean {
|
override fun mouseDraggedInner(x: Double, y: Double, button: Int, xDelta: Double, yDelta: Double): Boolean {
|
||||||
if (isPressed && button == InputConstants.MOUSE_BUTTON_LEFT) {
|
if (isPressed && button == InputConstants.MOUSE_BUTTON_LEFT && !isDisabled.get()) {
|
||||||
pickColor(x, y)
|
pickColor(x, y)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -135,11 +137,13 @@ abstract class AbstractColorWangPanel<out S : Screen>(
|
|||||||
width: Float = 40f,
|
width: Float = 40f,
|
||||||
height: Float = 10f,
|
height: Float = 10f,
|
||||||
protected val callback: Consumer<RGBAColor>? = null,
|
protected val callback: Consumer<RGBAColor>? = null,
|
||||||
|
val isDisabled: Supplier<Boolean> = Supplier { false },
|
||||||
) : EditablePanel<S>(screen, parent, x, y, width, height) {
|
) : EditablePanel<S>(screen, parent, x, y, width, height) {
|
||||||
abstract val leftColor: RGBAColor
|
abstract val leftColor: RGBAColor
|
||||||
abstract val rightColor: RGBAColor
|
abstract val rightColor: RGBAColor
|
||||||
abstract val wangPosition: Float
|
abstract val wangPosition: Float
|
||||||
abstract fun setColor(color: Either<RGBAColor, HSVColor>)
|
abstract fun setColor(color: Either<RGBAColor, HSVColor>)
|
||||||
|
|
||||||
protected abstract fun onWangInput(newPosition: Float)
|
protected abstract fun onWangInput(newPosition: Float)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
@ -155,7 +159,7 @@ abstract class AbstractColorWangPanel<out S : Screen>(
|
|||||||
|
|
||||||
override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean {
|
override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean {
|
||||||
if (button == InputConstants.MOUSE_BUTTON_LEFT) {
|
if (button == InputConstants.MOUSE_BUTTON_LEFT) {
|
||||||
if (!isPressed) {
|
if (!isPressed && !isDisabled.get()) {
|
||||||
isPressed = true
|
isPressed = true
|
||||||
grabMouseInput = true
|
grabMouseInput = true
|
||||||
|
|
||||||
@ -170,7 +174,7 @@ abstract class AbstractColorWangPanel<out S : Screen>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun mouseDraggedInner(x: Double, y: Double, button: Int, xDelta: Double, yDelta: Double): Boolean {
|
override fun mouseDraggedInner(x: Double, y: Double, button: Int, xDelta: Double, yDelta: Double): Boolean {
|
||||||
if (isPressed && button == InputConstants.MOUSE_BUTTON_LEFT) {
|
if (isPressed && button == InputConstants.MOUSE_BUTTON_LEFT && !isDisabled.get()) {
|
||||||
updateColor(x)
|
updateColor(x)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -216,7 +220,8 @@ open class RedColorWangPanel<out S : Screen>(
|
|||||||
width: Float = 40f,
|
width: Float = 40f,
|
||||||
height: Float = 10f,
|
height: Float = 10f,
|
||||||
callback: Consumer<RGBAColor>? = null,
|
callback: Consumer<RGBAColor>? = null,
|
||||||
) : AbstractColorWangPanel<S>(screen, parent, x, y, width, height, callback) {
|
isDisabled: Supplier<Boolean> = Supplier { false },
|
||||||
|
) : AbstractColorWangPanel<S>(screen, parent, x, y, width, height, callback, isDisabled) {
|
||||||
override var leftColor: RGBAColor = RGBAColor.BLACK
|
override var leftColor: RGBAColor = RGBAColor.BLACK
|
||||||
protected set
|
protected set
|
||||||
override var rightColor: RGBAColor = RGBAColor.RED
|
override var rightColor: RGBAColor = RGBAColor.RED
|
||||||
@ -247,7 +252,8 @@ open class GreenColorWangPanel<out S : Screen>(
|
|||||||
width: Float = 40f,
|
width: Float = 40f,
|
||||||
height: Float = 10f,
|
height: Float = 10f,
|
||||||
callback: Consumer<RGBAColor>? = null,
|
callback: Consumer<RGBAColor>? = null,
|
||||||
) : AbstractColorWangPanel<S>(screen, parent, x, y, width, height, callback) {
|
isDisabled: Supplier<Boolean> = Supplier { false },
|
||||||
|
) : AbstractColorWangPanel<S>(screen, parent, x, y, width, height, callback, isDisabled) {
|
||||||
override var leftColor: RGBAColor = RGBAColor.BLACK
|
override var leftColor: RGBAColor = RGBAColor.BLACK
|
||||||
protected set
|
protected set
|
||||||
override var rightColor: RGBAColor = RGBAColor.GREEN
|
override var rightColor: RGBAColor = RGBAColor.GREEN
|
||||||
@ -278,7 +284,8 @@ open class BlueColorWangPanel<out S : Screen>(
|
|||||||
width: Float = 40f,
|
width: Float = 40f,
|
||||||
height: Float = 10f,
|
height: Float = 10f,
|
||||||
callback: Consumer<RGBAColor>? = null,
|
callback: Consumer<RGBAColor>? = null,
|
||||||
) : AbstractColorWangPanel<S>(screen, parent, x, y, width, height, callback) {
|
isDisabled: Supplier<Boolean> = Supplier { false },
|
||||||
|
) : AbstractColorWangPanel<S>(screen, parent, x, y, width, height, callback, isDisabled) {
|
||||||
override var leftColor: RGBAColor = RGBAColor.BLACK
|
override var leftColor: RGBAColor = RGBAColor.BLACK
|
||||||
protected set
|
protected set
|
||||||
override var rightColor: RGBAColor = RGBAColor.BLUE
|
override var rightColor: RGBAColor = RGBAColor.BLUE
|
||||||
@ -309,7 +316,8 @@ open class HueWangPanel<out S : Screen>(
|
|||||||
width: Float = 40f,
|
width: Float = 40f,
|
||||||
height: Float = 10f,
|
height: Float = 10f,
|
||||||
protected val hueCallback: FloatConsumer? = null,
|
protected val hueCallback: FloatConsumer? = null,
|
||||||
) : AbstractColorWangPanel<S>(screen, parent, x, y, width, height) {
|
isDisabled: Supplier<Boolean> = Supplier { false },
|
||||||
|
) : AbstractColorWangPanel<S>(screen, parent, x, y, width, height, null, isDisabled) {
|
||||||
override val leftColor: RGBAColor get() = RGBAColor.WHITE
|
override val leftColor: RGBAColor get() = RGBAColor.WHITE
|
||||||
override val rightColor: RGBAColor get() = RGBAColor.WHITE
|
override val rightColor: RGBAColor get() = RGBAColor.WHITE
|
||||||
override var wangPosition: Float = 1f
|
override var wangPosition: Float = 1f
|
||||||
@ -351,7 +359,8 @@ open class SaturationWangPanel<out S : Screen>(
|
|||||||
width: Float = 40f,
|
width: Float = 40f,
|
||||||
height: Float = 10f,
|
height: Float = 10f,
|
||||||
protected val saturationCallback: FloatConsumer? = null,
|
protected val saturationCallback: FloatConsumer? = null,
|
||||||
) : AbstractColorWangPanel<S>(screen, parent, x, y, width, height) {
|
isDisabled: Supplier<Boolean> = Supplier { false },
|
||||||
|
) : AbstractColorWangPanel<S>(screen, parent, x, y, width, height, null, isDisabled) {
|
||||||
override var leftColor: RGBAColor = RGBAColor.WHITE
|
override var leftColor: RGBAColor = RGBAColor.WHITE
|
||||||
protected set
|
protected set
|
||||||
override var rightColor: RGBAColor = RGBAColor.WHITE
|
override var rightColor: RGBAColor = RGBAColor.WHITE
|
||||||
@ -396,7 +405,8 @@ open class ValueWangPanel<out S : Screen>(
|
|||||||
width: Float = 40f,
|
width: Float = 40f,
|
||||||
height: Float = 10f,
|
height: Float = 10f,
|
||||||
protected val valueCallback: FloatConsumer? = null,
|
protected val valueCallback: FloatConsumer? = null,
|
||||||
) : AbstractColorWangPanel<S>(screen, parent, x, y, width, height) {
|
isDisabled: Supplier<Boolean> = Supplier { false }
|
||||||
|
) : AbstractColorWangPanel<S>(screen, parent, x, y, width, height, null, isDisabled) {
|
||||||
override var leftColor: RGBAColor = RGBAColor.BLACK
|
override var leftColor: RGBAColor = RGBAColor.BLACK
|
||||||
protected set
|
protected set
|
||||||
override var rightColor: RGBAColor = RGBAColor.WHITE
|
override var rightColor: RGBAColor = RGBAColor.WHITE
|
||||||
@ -440,7 +450,8 @@ open class ColorPalettePanel<out S : Screen>(
|
|||||||
y: Float = 0f,
|
y: Float = 0f,
|
||||||
width: Float = 64f,
|
width: Float = 64f,
|
||||||
height: Float = 64f,
|
height: Float = 64f,
|
||||||
protected val callback: Consumer<RGBAColor>? = null
|
protected val callback: Consumer<RGBAColor>? = null,
|
||||||
|
val isDisabled: Supplier<Boolean> = Supplier { false }
|
||||||
) : EditablePanel<S>(screen, parent, x, y, width, height) {
|
) : EditablePanel<S>(screen, parent, x, y, width, height) {
|
||||||
open fun onColorChoose(color: RGBAColor) {
|
open fun onColorChoose(color: RGBAColor) {
|
||||||
callback?.accept(color)
|
callback?.accept(color)
|
||||||
@ -452,6 +463,10 @@ open class ColorPalettePanel<out S : Screen>(
|
|||||||
tooltips.add(TextComponent(color.toHexStringRGB()))
|
tooltips.add(TextComponent(color.toHexStringRGB()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override var isDisabled: Boolean
|
||||||
|
get() = this@ColorPalettePanel.isDisabled.get()
|
||||||
|
set(value) {}
|
||||||
|
|
||||||
override fun onClick(mouseButton: Int) {
|
override fun onClick(mouseButton: Int) {
|
||||||
onColorChoose(color)
|
onColorChoose(color)
|
||||||
}
|
}
|
||||||
@ -499,7 +514,8 @@ open class ColorPickerPanel<out S : Screen>(
|
|||||||
y: Float = 0f,
|
y: Float = 0f,
|
||||||
width: Float = 164f,
|
width: Float = 164f,
|
||||||
height: Float = 118f,
|
height: Float = 118f,
|
||||||
var callback: Consumer<RGBAColor>? = null
|
var callback: Consumer<RGBAColor>? = null,
|
||||||
|
val isDisabled: Supplier<Boolean> = Supplier { false },
|
||||||
) : EditablePanel<S>(screen, parent, x, y, width, height) {
|
) : EditablePanel<S>(screen, parent, x, y, width, height) {
|
||||||
open fun onColorChanged(color: RGBAColor) {
|
open fun onColorChanged(color: RGBAColor) {
|
||||||
callback?.accept(color)
|
callback?.accept(color)
|
||||||
@ -523,49 +539,53 @@ open class ColorPickerPanel<out S : Screen>(
|
|||||||
|
|
||||||
protected open fun onPaletteChoose(color: RGBAColor) {
|
protected open fun onPaletteChoose(color: RGBAColor) {
|
||||||
setColor(Either.left(color))
|
setColor(Either.left(color))
|
||||||
onColorChanged(color)
|
if (!isDisabled.get()) onColorChanged(color)
|
||||||
}
|
}
|
||||||
|
|
||||||
protected open fun onColorBoxChoose(color: HSVColor) {
|
protected open fun onColorBoxChoose(color: HSVColor) {
|
||||||
setColor(Either.right(color))
|
setColor(Either.right(color))
|
||||||
onColorChanged(color.toRGBA())
|
if (!isDisabled.get()) onColorChanged(color.toRGBA())
|
||||||
}
|
}
|
||||||
|
|
||||||
protected open fun onWangChoose(color: RGBAColor) {
|
protected open fun onWangChoose(color: RGBAColor) {
|
||||||
setColor(Either.left(color))
|
setColor(Either.left(color))
|
||||||
onColorChanged(color)
|
if (!isDisabled.get()) onColorChanged(color)
|
||||||
}
|
}
|
||||||
|
|
||||||
protected open fun onHueChoose(hue: Float) {
|
protected open fun onHueChoose(hue: Float) {
|
||||||
val current = currentColor.map({ it.toHSV() }, { it })
|
val current = currentColor.map({ it.toHSV() }, { it })
|
||||||
val new = current.copy(hue = hue)
|
val new = current.copy(hue = hue)
|
||||||
setColor(Either.right(new))
|
setColor(Either.right(new))
|
||||||
onColorChanged(new.toRGBA())
|
if (!isDisabled.get()) onColorChanged(new.toRGBA())
|
||||||
}
|
}
|
||||||
|
|
||||||
protected open fun onSaturationChoose(saturation: Float) {
|
protected open fun onSaturationChoose(saturation: Float) {
|
||||||
val current = currentColor.map({ it.toHSV() }, { it })
|
val current = currentColor.map({ it.toHSV() }, { it })
|
||||||
val new = current.copy(saturation = saturation)
|
val new = current.copy(saturation = saturation)
|
||||||
setColor(Either.right(new))
|
setColor(Either.right(new))
|
||||||
onColorChanged(new.toRGBA())
|
if (!isDisabled.get()) onColorChanged(new.toRGBA())
|
||||||
}
|
}
|
||||||
|
|
||||||
protected open fun onValueChoose(value: Float) {
|
protected open fun onValueChoose(value: Float) {
|
||||||
val current = currentColor.map({ it.toHSV() }, { it })
|
val current = currentColor.map({ it.toHSV() }, { it })
|
||||||
val new = current.copy(value = value)
|
val new = current.copy(value = value)
|
||||||
setColor(Either.right(new))
|
setColor(Either.right(new))
|
||||||
onColorChanged(new.toRGBA())
|
if (!isDisabled.get()) onColorChanged(new.toRGBA())
|
||||||
}
|
}
|
||||||
|
|
||||||
val topStrip = EditablePanel(screen, this, 0f, 0f, width = width, height = 70f)
|
val topStrip = EditablePanel(screen, this, 0f, 0f, width = width, height = 70f)
|
||||||
val middleStrip = EditablePanel(screen, this)
|
val middleStrip = EditablePanel(screen, this)
|
||||||
val palette = ColorPalettePanel(screen, this, callback = { onPaletteChoose(it) })
|
val palette = ColorPalettePanel(screen, this, callback = { onPaletteChoose(it) }, isDisabled = isDisabled)
|
||||||
|
|
||||||
val hexInput = object : TextInputPanel<S>(screen, middleStrip, width = 50f) {
|
val hexInput = object : TextInputPanel<S>(screen, middleStrip, width = 50f) {
|
||||||
init {
|
init {
|
||||||
dock = Dock.RIGHT
|
dock = Dock.RIGHT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override var isActive: Boolean
|
||||||
|
get() = !isDisabled.get()
|
||||||
|
set(value) {}
|
||||||
|
|
||||||
override fun onFocusChanged() {
|
override fun onFocusChanged() {
|
||||||
if (!isFocusedThis) {
|
if (!isFocusedThis) {
|
||||||
val newColor = RGBAColor.fromHexStringRGB(text)
|
val newColor = RGBAColor.fromHexStringRGB(text)
|
||||||
@ -574,7 +594,7 @@ open class ColorPickerPanel<out S : Screen>(
|
|||||||
text = currentColor.map({ it }, { it.toRGBA() }).toHexStringRGB()
|
text = currentColor.map({ it }, { it.toRGBA() }).toHexStringRGB()
|
||||||
} else {
|
} else {
|
||||||
setColor(Either.left(newColor))
|
setColor(Either.left(newColor))
|
||||||
onColorChanged(newColor)
|
if (!isDisabled.get()) onColorChanged(newColor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -596,7 +616,7 @@ open class ColorPickerPanel<out S : Screen>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val box = ColorBoxPanel(screen, topStrip, 0f, 0f, width = 70f, height = 70f, callback = { onColorBoxChoose(it) })
|
val box = ColorBoxPanel(screen, topStrip, 0f, 0f, width = 70f, height = 70f, callback = { onColorBoxChoose(it) }, isDisabled = isDisabled)
|
||||||
val wangCanvas = EditablePanel(screen, topStrip, width = 80f)
|
val wangCanvas = EditablePanel(screen, topStrip, width = 80f)
|
||||||
|
|
||||||
inner class WangLine(label: String, val wang: AbstractColorWangPanel<S>, val text: (color: Either<RGBAColor, HSVColor>) -> Component?) {
|
inner class WangLine(label: String, val wang: AbstractColorWangPanel<S>, val text: (color: Either<RGBAColor, HSVColor>) -> Component?) {
|
||||||
@ -637,13 +657,13 @@ open class ColorPickerPanel<out S : Screen>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val red = WangLine("red", RedColorWangPanel(screen, wangCanvas, callback = { onWangChoose(it) })) { TextComponent((it.map({ it }, { it.toRGBA() }).red * 255f).roundToInt().toString()) }
|
val red = WangLine("red", RedColorWangPanel(screen, wangCanvas, callback = { onWangChoose(it) }, isDisabled = isDisabled)) { TextComponent((it.map({ it }, { it.toRGBA() }).red * 255f).roundToInt().toString()) }
|
||||||
val green = WangLine("green", GreenColorWangPanel(screen, wangCanvas, callback = { onWangChoose(it) })) { TextComponent((it.map({ it }, { it.toRGBA() }).green * 255f).roundToInt().toString()) }
|
val green = WangLine("green", GreenColorWangPanel(screen, wangCanvas, callback = { onWangChoose(it) }, isDisabled = isDisabled)) { TextComponent((it.map({ it }, { it.toRGBA() }).green * 255f).roundToInt().toString()) }
|
||||||
val blue = WangLine("blue", BlueColorWangPanel(screen, wangCanvas, callback = { onWangChoose(it) })) { TextComponent((it.map({ it }, { it.toRGBA() }).blue * 255f).roundToInt().toString()) }
|
val blue = WangLine("blue", BlueColorWangPanel(screen, wangCanvas, callback = { onWangChoose(it) }, isDisabled = isDisabled)) { TextComponent((it.map({ it }, { it.toRGBA() }).blue * 255f).roundToInt().toString()) }
|
||||||
|
|
||||||
val hue = WangLine("hue", HueWangPanel(screen, wangCanvas, hueCallback = { onHueChoose(it) })) { it.map({ if (it.canRepresentHue()) it.toHSV() else null }, { it })?.let { TextComponent(it.hue.roundToInt().toString()) } }
|
val hue = WangLine("hue", HueWangPanel(screen, wangCanvas, hueCallback = { onHueChoose(it) }, isDisabled = isDisabled)) { it.map({ if (it.canRepresentHue()) it.toHSV() else null }, { it })?.let { TextComponent(it.hue.roundToInt().toString()) } }
|
||||||
val saturation = WangLine("saturation", SaturationWangPanel(screen, wangCanvas, saturationCallback = { onSaturationChoose(it) })) { it.map({ if (it.canRepresentHue()) it.toHSV() else null }, { it })?.let { TextComponent((it.saturation * 100f).roundToInt().toString() + "%") } }
|
val saturation = WangLine("saturation", SaturationWangPanel(screen, wangCanvas, saturationCallback = { onSaturationChoose(it) }, isDisabled = isDisabled)) { it.map({ if (it.canRepresentHue()) it.toHSV() else null }, { it })?.let { TextComponent((it.saturation * 100f).roundToInt().toString() + "%") } }
|
||||||
val value = WangLine("value", ValueWangPanel(screen, wangCanvas, valueCallback = { onValueChoose(it) })) { it.map({ if (it.canRepresentHue()) it.toHSV() else null }, { it })?.let { TextComponent((it.value * 100f).roundToInt().toString() + "%") } }
|
val value = WangLine("value", ValueWangPanel(screen, wangCanvas, valueCallback = { onValueChoose(it) }, isDisabled = isDisabled)) { it.map({ if (it.canRepresentHue()) it.toHSV() else null }, { it })?.let { TextComponent((it.value * 100f).roundToInt().toString() + "%") } }
|
||||||
|
|
||||||
val wangs = listOf(red, green, blue, hue, saturation, value)
|
val wangs = listOf(red, green, blue, hue, saturation, value)
|
||||||
|
|
||||||
@ -728,9 +748,9 @@ open class ColorPickerPanel<out S : Screen>(
|
|||||||
RGBAColor.rgb(0xEE82EEL), // Violet
|
RGBAColor.rgb(0xEE82EEL), // Violet
|
||||||
)
|
)
|
||||||
|
|
||||||
fun <S : MatteryScreen<*>> frame(screen: S, callback: Consumer<RGBAColor>, color: RGBAColor = RGBAColor.RED, title: Component? = TranslatableComponent("otm.gui.color_picker")): FramePanel<S> {
|
fun <S : MatteryScreen<*>> frame(screen: S, callback: Consumer<RGBAColor>, color: RGBAColor = RGBAColor.RED, title: Component? = TranslatableComponent("otm.gui.color_picker"), isDisabled: Supplier<Boolean> = Supplier { false }): FramePanel<S> {
|
||||||
return FramePanel.padded(screen, 164f, 118f, title).also {
|
return FramePanel.padded(screen, 164f, 118f, title).also {
|
||||||
ColorPickerPanel(screen, it, 0f, 0f, callback = callback).also {
|
ColorPickerPanel(screen, it, 0f, 0f, callback = callback, isDisabled = isDisabled).also {
|
||||||
it.dock = Dock.FILL
|
it.dock = Dock.FILL
|
||||||
it.setColor(Either.left(color))
|
it.setColor(Either.left(color))
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,7 @@ import ru.dbotthepony.mc.otm.core.util.BigDecimalValueCodec
|
|||||||
import ru.dbotthepony.mc.otm.core.util.BinaryStringCodec
|
import ru.dbotthepony.mc.otm.core.util.BinaryStringCodec
|
||||||
import ru.dbotthepony.mc.otm.core.util.BooleanValueCodec
|
import ru.dbotthepony.mc.otm.core.util.BooleanValueCodec
|
||||||
import ru.dbotthepony.mc.otm.core.util.CollectionStreamCodec
|
import ru.dbotthepony.mc.otm.core.util.CollectionStreamCodec
|
||||||
|
import ru.dbotthepony.mc.otm.core.util.FloatValueCodec
|
||||||
import ru.dbotthepony.mc.otm.core.util.IStreamCodec
|
import ru.dbotthepony.mc.otm.core.util.IStreamCodec
|
||||||
import ru.dbotthepony.mc.otm.core.util.ItemStackValueCodec
|
import ru.dbotthepony.mc.otm.core.util.ItemStackValueCodec
|
||||||
import ru.dbotthepony.mc.otm.core.util.ItemValueCodec
|
import ru.dbotthepony.mc.otm.core.util.ItemValueCodec
|
||||||
@ -189,6 +190,7 @@ abstract class MatteryMenu(
|
|||||||
fun itemStackInput(allowSpectators: Boolean = false, handler: (ItemStack) -> Unit) = PlayerInput(ItemStackValueCodec, allowSpectators, handler)
|
fun itemStackInput(allowSpectators: Boolean = false, handler: (ItemStack) -> Unit) = PlayerInput(ItemStackValueCodec, allowSpectators, handler)
|
||||||
fun nullableItemInput(allowSpectators: Boolean = false, handler: (Item?) -> Unit) = PlayerInput(ItemValueCodec.nullable, allowSpectators, handler)
|
fun nullableItemInput(allowSpectators: Boolean = false, handler: (Item?) -> Unit) = PlayerInput(ItemValueCodec.nullable, allowSpectators, handler)
|
||||||
fun stringInput(allowSpectators: Boolean = false, handler: (String) -> Unit) = PlayerInput(BinaryStringCodec, allowSpectators, handler)
|
fun stringInput(allowSpectators: Boolean = false, handler: (String) -> Unit) = PlayerInput(BinaryStringCodec, allowSpectators, handler)
|
||||||
|
fun floatInput(allowSpectators: Boolean = false, handler: (Float) -> Unit) = PlayerInput(FloatValueCodec, allowSpectators, handler)
|
||||||
fun intInput(allowSpectators: Boolean = false, handler: (Int) -> Unit) = PlayerInput(VarIntValueCodec, allowSpectators, handler)
|
fun intInput(allowSpectators: Boolean = false, handler: (Int) -> Unit) = PlayerInput(VarIntValueCodec, allowSpectators, handler)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -7,10 +7,11 @@ import ru.dbotthepony.mc.otm.block.entity.decorative.HoloSignBlockEntity
|
|||||||
import ru.dbotthepony.mc.otm.menu.MatteryMenu
|
import ru.dbotthepony.mc.otm.menu.MatteryMenu
|
||||||
import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback
|
import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback
|
||||||
import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback
|
import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback
|
||||||
|
import ru.dbotthepony.mc.otm.menu.input.FloatInputWithFeedback
|
||||||
import ru.dbotthepony.mc.otm.menu.input.StringInputWithFeedback
|
import ru.dbotthepony.mc.otm.menu.input.StringInputWithFeedback
|
||||||
import ru.dbotthepony.mc.otm.registry.MMenus
|
import ru.dbotthepony.mc.otm.registry.MMenus
|
||||||
|
|
||||||
class HoloSignMenu @JvmOverloads constructor(
|
class HoloSignMenu(
|
||||||
containerId: Int,
|
containerId: Int,
|
||||||
inventory: Inventory,
|
inventory: Inventory,
|
||||||
tile: HoloSignBlockEntity? = null
|
tile: HoloSignBlockEntity? = null
|
||||||
@ -19,13 +20,27 @@ class HoloSignMenu @JvmOverloads constructor(
|
|||||||
val locked = BooleanInputWithFeedback(this)
|
val locked = BooleanInputWithFeedback(this)
|
||||||
val redstone = EnumInputWithFeedback(this, RedstoneSetting::class.java)
|
val redstone = EnumInputWithFeedback(this, RedstoneSetting::class.java)
|
||||||
|
|
||||||
|
val textRed = FloatInputWithFeedback(this)
|
||||||
|
val textGreen = FloatInputWithFeedback(this)
|
||||||
|
val textBlue = FloatInputWithFeedback(this)
|
||||||
|
val textAlpha = FloatInputWithFeedback(this)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
text.filter { it.isCreative || !locked.value }
|
text.filter { it.isCreative || !locked.value }
|
||||||
redstone.filter { it.isCreative || !locked.value }
|
redstone.filter { it.isCreative || !locked.value }
|
||||||
locked.filter { it.isCreative }
|
locked.filter { it.isCreative }
|
||||||
|
|
||||||
|
textRed.filter { it.isCreative || !locked.value }
|
||||||
|
textGreen.filter { it.isCreative || !locked.value }
|
||||||
|
textBlue.filter { it.isCreative || !locked.value }
|
||||||
|
textAlpha.filter { it.isCreative || !locked.value }
|
||||||
|
|
||||||
if (tile != null) {
|
if (tile != null) {
|
||||||
text.withConsumer { if (tile.isLocked) tile.signText = it else tile.signText = HoloSignBlockEntity.truncate(it) }.withSupplier(tile::signText)
|
text.withConsumer { if (tile.isLocked) tile.signText = it else tile.signText = HoloSignBlockEntity.truncate(it) }.withSupplier(tile::signText)
|
||||||
|
textRed.withConsumer { tile.textRed = it.coerceIn(0f, 1f) }.withSupplier(tile::textRed)
|
||||||
|
textGreen.withConsumer { tile.textGreen = it.coerceIn(0f, 1f) }.withSupplier(tile::textGreen)
|
||||||
|
textBlue.withConsumer { tile.textBlue = it.coerceIn(0f, 1f) }.withSupplier(tile::textBlue)
|
||||||
|
textAlpha.withConsumer { tile.textAlpha = it.coerceIn(0f, 1f) }.withSupplier(tile::textAlpha)
|
||||||
locked.with(tile::isLocked)
|
locked.with(tile::isLocked)
|
||||||
redstone.with(tile.redstoneControl::redstoneSetting)
|
redstone.with(tile.redstoneControl::redstoneSetting)
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,18 @@
|
|||||||
|
package ru.dbotthepony.mc.otm.menu.input
|
||||||
|
|
||||||
|
import ru.dbotthepony.mc.otm.core.GetterSetter
|
||||||
|
import ru.dbotthepony.mc.otm.menu.MatteryMenu
|
||||||
|
import kotlin.reflect.KMutableProperty0
|
||||||
|
|
||||||
|
class FloatInputWithFeedback(menu: MatteryMenu) : AbstractPlayerInputWithFeedback<Float>() {
|
||||||
|
override val input = menu.floatInput { consumer?.invoke(it) }
|
||||||
|
override val field = menu.mSynchronizer.computedFloat { supplier?.invoke() ?: 0f }
|
||||||
|
|
||||||
|
constructor(menu: MatteryMenu, state: KMutableProperty0<Float>) : this(menu) {
|
||||||
|
with(state)
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(menu: MatteryMenu, state: GetterSetter<Float>) : this(menu) {
|
||||||
|
with(state)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user