Skip to content

Commit

Permalink
played around a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
Hobbyshop committed May 22, 2024
1 parent ba05e95 commit 5551bb3
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 1 deletion.
102 changes: 102 additions & 0 deletions src/test/kotlin/com/neptuneclient/voidui/tests/MainMenu.kt
Original file line number Diff line number Diff line change
@@ -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)
)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Binary file added src/test/resources/images/head.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/test/resources/images/main_menu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5551bb3

Please sign in to comment.