Skip to content

Commit 1e34428

Browse files
committed
Get some work done on the fullscreen locker too
1 parent 6b9a6bc commit 1e34428

File tree

2 files changed

+98
-10
lines changed

2 files changed

+98
-10
lines changed

src/main/kotlin/org/polyfrost/polyplus/client/gui/FullscreenLockerUI.kt

Lines changed: 89 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,109 @@ import net.minecraft.client.gui.GuiScreen
44
import org.polyfrost.oneconfig.api.ui.v1.OCPolyUIBuilder
55
import org.polyfrost.oneconfig.api.ui.v1.UIManager
66
import org.polyfrost.polyplus.PolyPlusConstants
7+
import org.polyfrost.polyui.animate.SetAnimation
8+
import org.polyfrost.polyui.component.Drawable
9+
import org.polyfrost.polyui.component.extensions.disable
10+
import org.polyfrost.polyui.component.extensions.named
11+
import org.polyfrost.polyui.component.extensions.onChange
12+
import org.polyfrost.polyui.component.extensions.onClick
13+
import org.polyfrost.polyui.component.extensions.onRightClick
14+
import org.polyfrost.polyui.component.extensions.setFont
15+
import org.polyfrost.polyui.component.extensions.withBorder
16+
import org.polyfrost.polyui.component.impl.Block
17+
import org.polyfrost.polyui.component.impl.Group
18+
import org.polyfrost.polyui.component.impl.Image
19+
import org.polyfrost.polyui.component.impl.Text
20+
import org.polyfrost.polyui.component.impl.TextInput
21+
import org.polyfrost.polyui.unit.Align
22+
import org.polyfrost.polyui.unit.Vec2
23+
import org.polyfrost.polyui.utils.image
24+
import kotlin.reflect.KMutableProperty0
725

826
object FullscreenLockerUI {
9-
private val INTENDED_WIDTH = 1920f
10-
private val INTENDED_HEIGHT = 1080f
27+
private const val DESIGNED_WIDTH = 1920f
28+
private const val DESIGNED_HEIGHT = 1080f
29+
30+
private var backArrow: Drawable? = null
31+
private var forwardArrow: Drawable? = null
1132

1233
fun create(): GuiScreen {
1334
val uiManager = UIManager.INSTANCE
1435
val builder = OCPolyUIBuilder.create()
1536
.blurs()
16-
.atResolution(INTENDED_WIDTH, INTENDED_HEIGHT)
37+
.atResolution(DESIGNED_WIDTH, DESIGNED_HEIGHT)
1738
.renderer(uiManager.renderer)
1839
.translatorDelegate("assets/${PolyPlusConstants.ID}")
1940

2041
val polyUI = builder.make(
42+
Group(
43+
// Header
44+
Group(
45+
// Left
46+
Group(
47+
// TODO: Implement navigation history
48+
Image("assets/oneconfig/ico/left-arrow.svg".image()).disable().onClick {
49+
// val prev = previous.removeLastOrNull() ?: return@onClick false
50+
// if (previous.isEmpty()) prevArrow?.disable()
51+
// val current = current
52+
// openPage(prev, SetAnimation.SlideRight, addToPrev = false, clearNext = false)
53+
// next.add(current ?: return@onClick false)
54+
// nextArrow?.disable(false)
55+
false
56+
}.named("Back").bindTo(::backArrow),
57+
Image("assets/oneconfig/ico/right-arrow.svg".image()).disable().onClick {
58+
// val nextDrawable = next.removeLastOrNull() ?: return@onClick false
59+
// if (next.isEmpty()) nextArrow?.disable()
60+
// openPage(nextDrawable, clearNext = false)
61+
false
62+
}.named("Forward").bindTo(::forwardArrow),
63+
Text("polyplus.locker.title", fontSize = 24f).setFont { semiBold }.named("Title"),
64+
alignment = Align(pad = Vec2(16f, 8f), wrap = Align.Wrap.NEVER),
65+
).named("Controls"),
66+
67+
// Right
68+
Block(
69+
Image("assets/oneconfig/ico/search.svg".image()).named("SearchIcon"),
70+
TextInput(
71+
placeholder = "polyplus.search.placeholder",
72+
visibleSize = Vec2(256f, 32f)
73+
).onChange { text: String ->
74+
// TODO: Filter cosmetics list based on search input
75+
false
76+
}.named("SearchInput")
77+
).onRightClick {
78+
(this[1] as TextInput).text = ""
79+
}.withBorder(1f) { page.border5 }.named("SearchField")
80+
),
81+
82+
// Content
83+
Group(
84+
// Cosmetic list
85+
Group(),
86+
87+
// Sidebar
88+
Group(
89+
// Purchasing options
90+
Group(
91+
92+
),
93+
94+
// Player preview
95+
Group()
96+
),
97+
),
98+
99+
size = Vec2(1499f, 1080f),
100+
),
21101
)
22102

23-
val screen = uiManager.createPolyUIScreen(polyUI, INTENDED_WIDTH, INTENDED_HEIGHT, false, true) { }
103+
val screen = uiManager.createPolyUIScreen(polyUI, DESIGNED_WIDTH, DESIGNED_HEIGHT, false, true) { }
24104
polyUI.window = uiManager.createWindow()
25105
return screen
26106
}
107+
108+
private fun Drawable.bindTo(ref: KMutableProperty0<Drawable?>): Drawable {
109+
ref.set(this)
110+
return this
111+
}
27112
}

src/main/kotlin/org/polyfrost/polyplus/client/gui/LockerUI.kt

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import org.polyfrost.polyui.component.extensions.onClick
1010
import org.polyfrost.polyui.component.extensions.padded
1111
import org.polyfrost.polyui.component.impl.Button
1212
import org.polyfrost.polyui.component.impl.Group
13+
import org.polyfrost.polyui.unit.Align
1314
import org.polyfrost.polyui.unit.Vec2
1415
import org.polyfrost.polyui.utils.image
1516

@@ -25,7 +26,7 @@ private fun LockerPage(): Drawable {
2526
return Group(
2627
// Cosmetics List
2728
Group(
28-
size = Vec2(610f, 614f),
29+
visibleSize = Vec2(610f, 614f),
2930
),
3031

3132
// Right sidebar
@@ -36,25 +37,27 @@ private fun LockerPage(): Drawable {
3637
text = "Cart",
3738
radii = floatArrayOf(6f),
3839
padding = Vec2(42.75f, 5.5f),
39-
size = Vec2(136f, 32f)
40+
size = Vec2(146f, 32f)
4041
),
4142
Button(
4243
text = "Checkout items",
4344
radii = floatArrayOf(6f),
4445
padding = Vec2(75.5f, 5.5f),
4546
size = Vec2(306f, 32f)
4647
),
47-
size = Vec2(465f, 32f)
48+
size = Vec2(465f, 32f),
49+
alignment = Align(padBetween = Vec2(13f, 0f))
4850
),
4951

5052
// Player preview
5153
Group(
52-
size = Vec2(465f, 558f)
54+
visibleSize = Vec2(465f, 558f)
5355
).padded(0f, 12f, 0f, 0f),
5456

55-
size = Vec2(465f, 602f)
57+
visibleSize = Vec2(465f, 602f)
5658
).padded(13f, 0f, 0f, 0f),
5759

58-
size = Vec2(1088f, 614f)
60+
visibleSize = Vec2(1088f, 614f),
61+
alignment = Align(padBetween = Vec2(13f, 0f), wrap = Align.Wrap.NEVER)
5962
).named("Locker")
6063
}

0 commit comments

Comments
 (0)