File tree Expand file tree Collapse file tree 5 files changed +86
-32
lines changed
build-src/src/main/kotlin
modern/templates/java/io/github/notenoughupdates/moulconfig/test
main/kotlin/moe/nea/shale
test/kotlin/moe/nea/shale/test Expand file tree Collapse file tree 5 files changed +86
-32
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,8 @@ dependencies {
1818 shadowInclude(Dependencies .LIB_NINE_PATCH )
1919 compileOnly(Dependencies .JB_ANNOTATIONS )
2020 compileOnly(Dependencies .JSPECIFY )
21+ " implementation" (project(" :shale" ))
22+ shadowInclude(project(" :shale" ))
2123}
2224
2325val shadowJar by tasks.named(" shadowJar" , ShadowJar ::class ) {
Original file line number Diff line number Diff line change @@ -10,6 +10,8 @@ import io.github.notenoughupdates.moulconfig.platform.MoulConfigPlatform
1010import io.github.notenoughupdates.moulconfig.platform.MoulConfigScreenComponent
1111import io.github.notenoughupdates.moulconfig.xml.Bind
1212import io.github.notenoughupdates.moulconfig.xml.XMLUniverse
13+ import moe.nea.shale.render.minecraft.ShaleComponent
14+ import moe.nea.shale.util.ExampleTrees
1315import net.fabricmc.api.ModInitializer
1416import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.literal
1517import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback
@@ -35,6 +37,13 @@ class FabricMain : ModInitializer {
3537 }
3638 0
3739 })
40+ a.register(literal(" shaleuitest" ).executes {
41+ MinecraftClient .getInstance().send {
42+ val tree = ExampleTrees .boxes
43+ ShaleComponent (tree).openScreen()
44+ }
45+ 0
46+ })
3847 a.register(literal(" moulconfigxml" ).executes {
3948 MinecraftClient .getInstance().send {
4049 val xmlUniverse =
Original file line number Diff line number Diff line change 1+ package moe.nea.shale.render.minecraft
2+
3+ import io.github.notenoughupdates.moulconfig.common.IMinecraft
4+ import io.github.notenoughupdates.moulconfig.gui.GuiComponent
5+ import io.github.notenoughupdates.moulconfig.gui.GuiImmediateContext
6+ import moe.nea.shale.layout.RootElement
7+ import moe.nea.shale.layout.Size
8+ import moe.nea.shale.layout.Sizing
9+
10+ class ShaleComponent (val tree : RootElement ) : GuiComponent() {
11+ override fun getWidth (): Int {
12+ return 0
13+ }
14+
15+ override fun getHeight (): Int {
16+ return 0
17+ }
18+
19+ override fun render (context : GuiImmediateContext ) {
20+ tree.sizing = Sizing .Fixed (Size (context.width, context.height))
21+ val context = MinecraftGraphicsContext (context.renderContext)
22+ tree.relayout(context)
23+ tree.render(context)
24+ }
25+
26+ fun openScreen () {
27+ IMinecraft .instance.openWrappedScreen(this )
28+ }
29+ }
Original file line number Diff line number Diff line change 1+ package moe.nea.shale.util
2+
3+ import moe.nea.shale.dsl.box
4+ import moe.nea.shale.dsl.buildShaleLayout
5+ import moe.nea.shale.dsl.text
6+ import java.awt.Color
7+
8+ object ExampleTrees {
9+ val boxes = buildShaleLayout {
10+ box {
11+ ltr()
12+ padding(10 )
13+ childGap(10 )
14+ grow()
15+ box {
16+ ttb()
17+ background(Color .RED )
18+ box {
19+ background(Color .BLUE )
20+ text(" Goodbye, World!" ) {
21+ color(Color .WHITE )
22+ }
23+ }
24+ grow()
25+ }
26+ box {
27+ background(Color .GREEN )
28+ grow()
29+ }
30+ box {
31+ background(Color .CYAN )
32+ fixed(200 , 100 )
33+ }
34+ box {
35+ background(Color .DARK_GRAY )
36+ padding(10 )
37+ text(" Hello, World!" ) {
38+ color(Color .WHITE )
39+ }
40+ }
41+ }
42+ }
43+
44+ }
Original file line number Diff line number Diff line change 11package moe.nea.shale.test
22
3- import moe.nea.shale.dsl.box
4- import moe.nea.shale.dsl.buildShaleLayout
5- import moe.nea.shale.dsl.text
63import moe.nea.shale.layout.Size
74import moe.nea.shale.layout.Sizing
85import moe.nea.shale.render.awt.AwtGraphicsContext
6+ import moe.nea.shale.util.ExampleTrees
97import java.awt.BorderLayout
10- import java.awt.Color
118import java.awt.Dimension
129import java.awt.Graphics
1310import javax.swing.JFrame
1411import javax.swing.JPanel
1512import javax.swing.SwingUtilities
1613
1714class TestGui : JPanel () {
18- val tree = buildShaleLayout {
19- box {
20- ltr()
21- padding(10 )
22- childGap(10 )
23- grow()
24- box {
25- background(Color .RED )
26- grow()
27- }
28- box {
29- background(Color .GREEN )
30- grow()
31- }
32- box {
33- background(Color .CYAN )
34- fixed(200 , 100 )
35- }
36- box {
37- background(Color .DARK_GRAY )
38- padding(10 )
39- text(" Hello, World!" ) {
40- color(Color .WHITE )
41- }
42- }
43- }
44- }
45-
15+ val tree = ExampleTrees .boxes
4616 override fun paintComponent (g : Graphics ? ) {
4717 super .paintComponent(g)
4818 tree.sizing = Sizing .Fixed (Size .coerced(width, height))
You can’t perform that action at this time.
0 commit comments