47 lines
1.3 KiB
Kotlin
47 lines
1.3 KiB
Kotlin
|
package net.shadowfacts.phycon.screen.console
|
||
|
|
||
|
import net.minecraft.client.MinecraftClient
|
||
|
import net.minecraft.text.TranslatableText
|
||
|
import net.shadowfacts.cacao.util.Color
|
||
|
import net.shadowfacts.cacao.view.Label
|
||
|
import net.shadowfacts.cacao.view.button.EnumButton
|
||
|
import net.shadowfacts.cacao.viewcontroller.ViewController
|
||
|
import net.shadowfacts.kiwidsl.dsl
|
||
|
import net.shadowfacts.phycon.block.redstone_emitter.RedstoneEmitterBlockEntity
|
||
|
import net.shadowfacts.phycon.networking.C2SConfigureDevice
|
||
|
|
||
|
/**
|
||
|
* @author shadowfacts
|
||
|
*/
|
||
|
class RedstoneEmitterViewController(
|
||
|
val device: RedstoneEmitterBlockEntity,
|
||
|
): ViewController() {
|
||
|
|
||
|
override fun viewDidLoad() {
|
||
|
super.viewDidLoad()
|
||
|
|
||
|
val label = Label(TranslatableText("gui.phycon.console.emitter.mode")).apply {
|
||
|
textColor = Color.TEXT
|
||
|
}
|
||
|
view.addSubview(label)
|
||
|
|
||
|
val mode = EnumButton(device.mode, RedstoneEmitterBlockEntity.Mode::friendlyName)
|
||
|
mode.handler = {
|
||
|
device.mode = it.value
|
||
|
MinecraftClient.getInstance().player!!.networkHandler.sendPacket(C2SConfigureDevice(device))
|
||
|
}
|
||
|
view.addSubview(mode)
|
||
|
|
||
|
view.solver.dsl {
|
||
|
mode.widthAnchor equalTo 100
|
||
|
mode.heightAnchor equalTo 20
|
||
|
mode.topAnchor equalTo view.topAnchor
|
||
|
mode.rightAnchor equalTo view.rightAnchor
|
||
|
|
||
|
label.centerYAnchor equalTo mode.centerYAnchor
|
||
|
label.rightAnchor equalTo (mode.leftAnchor - 4)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|