2021-02-28 02:48:40 +00:00
|
|
|
package net.shadowfacts.phycon.screen.console
|
|
|
|
|
|
|
|
import net.minecraft.text.TranslatableText
|
|
|
|
import net.minecraft.util.Identifier
|
|
|
|
import net.shadowfacts.cacao.CacaoScreen
|
|
|
|
import net.shadowfacts.cacao.geometry.Size
|
|
|
|
import net.shadowfacts.cacao.util.Color
|
|
|
|
import net.shadowfacts.cacao.util.texture.Texture
|
|
|
|
import net.shadowfacts.cacao.view.Label
|
|
|
|
import net.shadowfacts.cacao.view.TextureView
|
|
|
|
import net.shadowfacts.cacao.viewcontroller.TabViewController
|
|
|
|
import net.shadowfacts.cacao.viewcontroller.ViewController
|
|
|
|
import net.shadowfacts.cacao.window.Window
|
|
|
|
import net.shadowfacts.kiwidsl.dsl
|
|
|
|
import net.shadowfacts.phycon.network.DeviceBlockEntity
|
|
|
|
import net.shadowfacts.phycon.network.block.redstone.RedstoneControllerBlockEntity
|
|
|
|
import net.shadowfacts.phycon.network.component.ActivationController
|
|
|
|
import org.lwjgl.glfw.GLFW
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author shadowfacts
|
|
|
|
*/
|
|
|
|
class DeviceConsoleScreen(
|
|
|
|
val device: DeviceBlockEntity,
|
|
|
|
): CacaoScreen(TranslatableText("item.phycon.console")) {
|
|
|
|
|
2021-02-28 17:19:09 +00:00
|
|
|
private val tabController: TabViewController<TabViewController.SimpleTab>
|
2021-02-28 02:48:40 +00:00
|
|
|
|
|
|
|
init {
|
|
|
|
val tabs = mutableListOf(
|
2021-02-28 17:19:09 +00:00
|
|
|
TabViewController.SimpleTab(
|
2021-02-28 02:48:40 +00:00
|
|
|
Label("IP").apply { textColor = Color.TEXT },
|
|
|
|
TranslatableText("gui.phycon.console.details"),
|
|
|
|
DeviceDetailsViewController(device)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
if (device is ActivationController.ActivatableDevice) {
|
2021-02-28 17:19:09 +00:00
|
|
|
tabs.add(TabViewController.SimpleTab(
|
2021-02-28 02:48:40 +00:00
|
|
|
TextureView(Texture(Identifier("textures/item/ender_pearl.png"), 0, 0, 16, 16)).apply {
|
|
|
|
intrinsicContentSize = Size(16.0, 16.0)
|
|
|
|
},
|
|
|
|
TranslatableText("gui.phycon.console.remote"),
|
|
|
|
ActivatableDeviceViewController(device)
|
|
|
|
))
|
|
|
|
}
|
|
|
|
if (device is RedstoneControllerBlockEntity) {
|
2021-02-28 17:19:09 +00:00
|
|
|
tabs.add(TabViewController.SimpleTab(
|
2021-02-28 02:48:40 +00:00
|
|
|
TextureView(Texture(Identifier("textures/block/redstone_torch.png"), 0, 0, 16, 16)).apply {
|
|
|
|
intrinsicContentSize = Size(16.0, 16.0)
|
|
|
|
},
|
|
|
|
TranslatableText("block.phycon.redstone_controller"),
|
|
|
|
RedstoneControllerViewController(device)
|
|
|
|
))
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
tabController = TabViewController(tabs)
|
|
|
|
|
|
|
|
val root = object: ViewController() {
|
|
|
|
override fun viewDidLoad() {
|
|
|
|
super.viewDidLoad()
|
|
|
|
embedChild(tabController, pinEdges = false)
|
|
|
|
view.solver.dsl {
|
|
|
|
tabController.view.centerXAnchor equalTo view.centerXAnchor
|
|
|
|
tabController.view.centerYAnchor equalTo view.centerYAnchor
|
|
|
|
tabController.tabVCContainer.widthAnchor equalTo 200
|
|
|
|
tabController.tabVCContainer.heightAnchor equalTo 150
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
addWindow(Window(root))
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun isPauseScreen() = false
|
|
|
|
|
|
|
|
override fun keyPressed(keyCode: Int, scanCode: Int, modifiers: Int): Boolean {
|
|
|
|
if (keyCode == GLFW.GLFW_KEY_E) {
|
|
|
|
onClose()
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
return super.keyPressed(keyCode, scanCode, modifiers)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|