diff --git a/src/test/kotlin/com/neptuneclient/voidui/tests/MainMenu.kt b/src/test/kotlin/com/neptuneclient/voidui/tests/MainMenu.kt new file mode 100644 index 0000000..24c13b6 --- /dev/null +++ b/src/test/kotlin/com/neptuneclient/voidui/tests/MainMenu.kt @@ -0,0 +1,102 @@ +package com.neptuneclient.voidui.tests + +import com.neptuneclient.voidui.VoidUI +import com.neptuneclient.voidui.event.MouseClickedEvent +import com.neptuneclient.voidui.framework.Screen +import com.neptuneclient.voidui.framework.Size +import com.neptuneclient.voidui.framework.Widget +import com.neptuneclient.voidui.objects.CornerRadius +import com.neptuneclient.voidui.objects.EdgeInsets +import com.neptuneclient.voidui.utils.image +import com.neptuneclient.voidui.widgets.* +import java.awt.Color + +class MainMenu(voidUI: VoidUI) : Screen(voidUI) { + + private var counter by stateOf(0) + + init { + registerEventAction(MouseClickedEvent::class) { + counter++ + } + } + + override fun build(): Widget { + return Stack( + children = arrayOf( + Image( + src = image("images/main_menu.png"), + fit = ImageFit.COVER + ), + Container( + width = width.toFloat(), + height = height.toFloat(), + color = Color(0, 0, 0, 100), + child = Padding( + padding = EdgeInsets.all(10f), + child = Column( + children = arrayOf( + AccountSwitcher(), + Center( + Container( + cornerRadius = CornerRadius.all(10f), + color = Color(10, 12, 20), + padding = EdgeInsets.all(20f), + child = Column( + gap = 20f, + children = arrayOf( + Button("Hello"), + Button("World"), + Text("Counter $counter") + ) + ) + ) + ), + Row( + children = arrayOf( + Text("Minecraft 1.8.9") + ) + ) + ) + ) + ) + ) + ) + ) + } + +} + +fun AccountSwitcher(): Widget { + return Container( + width = 250f, + cornerRadius = CornerRadius.all(10f), + color = Color(10, 12, 20), + padding = EdgeInsets.all(20f), + + child = Row( + gap = 10f, + children = arrayOf( + Image( + src = image("images/head.png"), + imageSize = Size(16f, 16f), + cornerRadius = CornerRadius.all(5f) + ), + Text("marc_daddy") + ) + ) + ) +} + +fun Button(text: String): Widget { + return Container( + width = 250f, + height = 40f, + cornerRadius = CornerRadius.all(10f), + color = Color(100, 70, 200), + + child = Center( + Text(text) + ) + ) +} \ No newline at end of file diff --git a/src/test/kotlin/com/neptuneclient/voidui/tests/ScreenTest.kt b/src/test/kotlin/com/neptuneclient/voidui/tests/ScreenTest.kt index c88840a..ab93dab 100644 --- a/src/test/kotlin/com/neptuneclient/voidui/tests/ScreenTest.kt +++ b/src/test/kotlin/com/neptuneclient/voidui/tests/ScreenTest.kt @@ -103,7 +103,7 @@ private val template = Template { slot -> val voidUI = VoidUI(TestRenderer(), TestTheme(), Settings(centeredScreen = false, useShaders = true), /*template*/) fun main() { - val screen = TestScreen(voidUI) + val screen = MainMenu(voidUI) screen.init() if (voidUI.renderer is TestRenderer) { diff --git a/src/test/resources/images/head.png b/src/test/resources/images/head.png new file mode 100644 index 0000000..71f6c83 Binary files /dev/null and b/src/test/resources/images/head.png differ diff --git a/src/test/resources/images/main_menu.png b/src/test/resources/images/main_menu.png new file mode 100644 index 0000000..6a0d172 Binary files /dev/null and b/src/test/resources/images/main_menu.png differ