50 lines
1.4 KiB
Kotlin
50 lines
1.4 KiB
Kotlin
package net.shadowfacts.phycon.client.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.TabViewController
|
|
import net.shadowfacts.cacao.viewcontroller.ViewController
|
|
import net.shadowfacts.kiwidsl.dsl
|
|
import net.shadowfacts.phycon.block.miner.MinerBlockEntity
|
|
import net.shadowfacts.phycon.networking.C2SConfigureDevice
|
|
|
|
/**
|
|
* @author shadowfacts
|
|
*/
|
|
class MinerViewController(
|
|
val device: MinerBlockEntity,
|
|
): ViewController() {
|
|
|
|
override fun viewDidLoad() {
|
|
super.viewDidLoad()
|
|
|
|
val label = Label(TranslatableText("gui.phycon.console.miner.mode")).apply {
|
|
textColor = Color.TEXT
|
|
}
|
|
view.addSubview(label)
|
|
|
|
val mode = EnumButton(device.minerMode, MinerBlockEntity.MinerMode::friendlyName)
|
|
mode.handler = {
|
|
device.minerMode = it.value
|
|
MinecraftClient.getInstance().player!!.networkHandler.sendPacket(C2SConfigureDevice(device))
|
|
|
|
(parent as TabViewController<TabViewController.SimpleTab>).visibleTabsChanged()
|
|
}
|
|
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)
|
|
}
|
|
}
|
|
|
|
}
|