Screens
Pages over the song list are made of copies of its own parts, so they look and move like the game. local ui = phigrospp.ui first.
ConfirmTile
| Field | Type | |
|---|---|---|
icon? | Unity | a Sprite |
label | string | |
colour? | Colour | |
tap? | fun() | |
on? | fun(): boolean | lit while it returns true |
note? | fun(): string |
ConfirmOptions
| Field | Type | |
|---|---|---|
title | string | |
message? | string | |
yes? | string|false | false leaves only no |
no? | string|false | false leaves only yes |
danger? | boolean | makes yes red |
grid? | { cells: (string|ConfirmTile)[], columns: integer, height: number } | aligned columns, one is centered |
input? | string | a text box's placeholder: its text is returned second |
progress? | fun(): number, string | a bar from 0 to 1 and its message, redrawn |
ChooseTile
| Field | Type | |
|---|---|---|
icon | Icon | |
label | string | |
colour? | Colour | |
value | any |
PageList
| Field | Type | |
|---|---|---|
count | integer | |
row | fun(row: Unity, i: integer) | sets a SongListItem |
selected? | fun(row: Unity, i: integer) | sets the middle one's songName, artist, level and levelText |
select? | fun(i: integer) | runs when it changes |
Page
A page sliding over the song list.
Page:part(name)
A copy of a song list part where it is: topbar, shadows, background (the list's dimming), info (record panel), cover, selected, up, down, back, play.
local page = phigrospp.ui.page() page:part("topbar") local cover = page:part("cover").transform
| Parameter | Type | |
|---|---|---|
name | "topbar"|"shadows"|"background"|"info"|"cover"|"selected"|"up"|"down"|"back"|"play" |
Returns GameObject
Page:back()
The back button closes the page.
local page = phigrospp.ui.page() page:back() -- the back arrow slides it out
Page:play(fn)
The play button runs fn.
local play = page:play(function() toast("Play!") end) -- the copy of the play button play:SetActive(false)
| Parameter | Type | |
|---|---|---|
fn | fun() |
Returns GameObject
Page:list(options)
The song list's list.
page:list({ count = #replays, row = function(row, i) row.songName.text, row.difficulty.text = replays[i].date, "" end, selected = function(row, i) row.songName.text = replays[i].date end, select = function(i) shown = replays[i] end, })
| Parameter | Type | |
|---|---|---|
options | PageList |
Page:close()
Slides back.
page:play(function() page:close() phigrospp.play(id, "IN") end)
View
A screen of its own over the menus, like the rooms. The song list under it takes no touch meanwhile. Its pieces are placed in units from its bottom left.
| Field | Type | |
|---|---|---|
height | number | 1080 |
width | number | |
left | number | where the columns start |
top | number | the middle of the top bar |
View.show(screen)
Slides a panel in, another one's out.
local view = phigrospp.ui.view("my-mod") view.show("list")
| Parameter | Type | |
|---|---|---|
screen | string |
View.hide()
Slides it out.
view.part("all", "", function(root) view.back(root, view.hide) end)
View.shown()
The panel showing.
print(view.shown()) --> list
Returns string?
View.part(name, key, draw)
Draws a part again only when its key changed.
view.show("scores") view.part("all", #scores, function(root) -- drawn again only when #scores changes view.text(root, { view.left, view.top }, 44, ("%d scores"):format(#scores)) end)
| Parameter | Type | |
|---|---|---|
name | string | |
key | any | |
draw | fun(root: Unity) |
View.text(parent, pos, size, text, colour?, alignment?, pivot?, box?)
A text from the middle of its left side.
local title = view.text(root, { view.left, view.top }, 44, "Scores") view.text(root, { view.width - view.left, view.top }, 30, "11.3288", ui.colours.dim, 5, { 1, 0.5 }) -- MiddleRight view.text(row, { 300, 66 }, 34, "A very long song name", ui.colours.white, 3, nil, 400) -- cut at 400 with ... local after = title.preferredWidth + 20 -- a UnityEngine.UI.Text
| Parameter | Type | |
|---|---|---|
parent | Unity | |
pos | Vector | |
size | number | |
text | string | |
colour? | Colour | |
alignment? | integer | a TextAnchor, MiddleLeft when left out |
pivot? | Vector | |
box? | number | a width: what goes past it is cut and ends with "..." |
Returns Text
View.icon(parent, pos, size, icon, colour?)
One of ui.icon's icons.
view.icon(root, { 60, 60 }, 48, "trophy", ui.colours.gold)
| Parameter | Type | |
|---|---|---|
parent | Unity | |
pos | Vector | |
size | number | |
icon | Icon | |
colour? | Colour |
Returns Image
View.plate(parent, pos, size, colour, fontSize, label, ink?)
A slanted bar with a centred text.
view.plate(row, { 300, 44 }, { 116, 34 }, ui.colours.IN, 22, "IN 15.8")
| Parameter | Type | |
|---|---|---|
parent | Unity | |
pos | Vector | |
size | Vector | |
colour | Colour | |
fontSize | number | |
label | string | |
ink? | Colour |
Returns LeanPolygon
View.action(parent, pos, width, label, fn?, lit?)
A button, lit in a colour when given one. Without fn it's only a label.
view.action(root, { 1500, 120 }, 300, "Start", function() toast("Go") end, ui.colours.green) view.action(root, { 1500, 30 }, 300, "Waiting") -- only a label
| Parameter | Type | |
|---|---|---|
parent | Unity | |
pos | Vector | |
width | number | |
label | string | |
fn? | fun()|false | |
lit? | Colour|false |
Returns LeanPolygon
View.back(root, fn)
The back arrow.
view.part("all", "", function(root) view.back(root, view.hide) end)
| Parameter | Type | |
|---|---|---|
root | Unity | |
fn | fun() |
View.tappable(shape, fn)
Makes anything a button.
local box = ui.rect(parent, "my-tap", { 0, 0 }, { 200, 80 }, { 0, 0, 0, 0 }) view.tappable(box, function() toast("Tapped") end)
| Parameter | Type | |
|---|---|---|
shape | Unity | |
fn | fun() |
View.checkbox(parent, pos, label, checked, fn)
A checkbox ending at pos.
view.checkbox(root, { 1800, 120 }, "Spectators", allowed, function() allowed = not allowed end)
| Parameter | Type | |
|---|---|---|
parent | Unity | |
pos | Vector | |
label | string | |
checked | boolean | |
fn | fun() |
View.titles(root, titles, own, pick)
The top bar's titles for screens that go together: pick(title) runs when another one's is tapped.
local shown = "Rooms" view.titles(root, { "Rooms", "Friends" }, shown, function(title) shown = title draw() end)
| Parameter | Type | |
|---|---|---|
root | Unity | |
titles | string[] | |
own | string | |
pick | fun(title: string) |
Panel
A screen sliding in over a canvas and its shade.
| Field | Type | |
|---|---|---|
transform | Unity | to fill |
close | fun() | slides it out, then closed() runs |
ui.colours
{ white: Colour, dim: Colour, faint: Colour, dark: Colour, gold: Colour, green: Colour, red: Colour, EZ: Colour, HD: Colour, IN: Colour, AT: Colour }
What they're drawn in, and a level's plate.
ui.icon(name)
A Lucide icon (lucide.dev) as a white Sprite tinted by its Image: one of the names listed, or another icon's svg.
local star = ui.icon("star") image.sprite, image.color = star, ui.colours.gold
| Parameter | Type | |
|---|---|---|
name | Icon |
Returns Sprite
ui.clone(button, offset, fn)
A copy of a game button moved by an offset, running fn instead.
local copy = ui.clone(original, { -150, 0 }, function() toast("Mine") end)
| Parameter | Type | |
|---|---|---|
button | Unity | |
offset | Vector | |
fn | fun() |
Returns GameObject
ui.sideButton(play, slot, sprite, fn)
A copy of a play button slot slots left of it, showing a sprite.
local selector = CS.UnityEngine.Object.FindObjectOfType(CS.SongSelectorControl) local bot = ui.sideButton(selector.startButton, 2, ui.icon("eye"), function() toast("Autoplay") end) bot:SetActive(false) -- a GameObject
| Parameter | Type | |
|---|---|---|
play | Unity | |
slot | integer | |
sprite | Unity | |
fn | fun() |
Returns GameObject
ui.switch(label, lit, fn)
A switch like the song list's Mirror one, after it and those already there: lit while lit says so, fn runs on a tap.
local practice = setting("Practice", false) on("scene", function(name) if name == "SongSelector" then ui.switch("Practice", practice, function() practice(not practice()) end) end end)
| Parameter | Type | |
|---|---|---|
label | string | |
lit | fun(): boolean | |
fn | fun() |
ui.shortcut(icon, fn)
A tab left of the chapter screen's settings and of those already there, showing an icon: asked for at each "ChapterSelector" scene.
on("scene", function(name) if name == "ChapterSelector" then ui.shortcut("users", open) end end)
| Parameter | Type | |
|---|---|---|
icon | Icon | |
fn | fun() |
ui.page()
Slides the song list out to the left and an empty page in.
local page = ui.page() page:part("topbar") page:part("background") page:back()
Returns Page
ui.confirm(options)
The game's popup, from a button's function or a coroutine: waits for the choice and returns true for yes.
if ui.confirm({ title = "Delete replay", message = "...", yes = "Delete", danger = true }) then end
| Parameter | Type | |
|---|---|---|
options | ConfirmOptions |
Returns boolean (yes)
Returns string? (text)
ui.close(...)
Closes the open popup, its confirm returning what's given.
button("Ask", function() after(5, function() ui.close(false) end) -- no answer in 5 seconds is a no if ui.confirm({ title = "Still there?" }) then toast("Yes") end end)
| Parameter | Type | |
|---|---|---|
... | any |
ui.choose(title, choices)
A popup of tiles to pick one of, called like confirm: returns the value of the one tapped, nothing when the player backs out.
local value = ui.choose("ggmolly#0042", { { icon = "eye", label = "Watch", colour = ui.colours.green, value = "watch" } })
| Parameter | Type | |
|---|---|---|
title | string | |
choices | ChooseTile[] |
Returns any
ui.bar(parent, name, pos, size, colour)
A bar slanted like the game's, from its top left corner.
local bar = ui.bar(parent, "my-bar", { 0, 96 }, { 600, 96 }, ui.colours.faint) view.text(bar.transform, { 40, 48 }, 34, "In the bar")
| Parameter | Type | |
|---|---|---|
parent | Unity | |
name | string | |
pos | Vector | |
size | Vector | |
colour | Colour |
Returns LeanPolygon
ui.cover(parent, name, pos, size, id, level?)
A song's illustration cut to fill such a bar, what's put in it is cut to its shape too. It's the level's own when the level has one. A few songs have one per level: given a level, it's that level's.
ui.cover(row, "my-cover", { 0, 96 }, { 170, 96 }, "Glaciaxion.SunsetRay.0", "IN")
| Parameter | Type | |
|---|---|---|
parent | Unity | |
name | string | |
pos | Vector | |
size | Vector | |
id | string | the song's id |
level? | Difficulty |
Returns LeanPolygon
ui.panel(canvas, name, closed?, shade?)
A screen sliding in over a canvas and its shade.
local canvas = ui.screen("my-mod", 50) local panel = ui.panel(canvas, "my-panel", function() print("gone") end) ui.rect(panel.transform, "my-box", { 100, 100 }, { 400, 300 }, ui.colours.dark) after(3, panel.close)
| Parameter | Type | |
|---|---|---|
canvas | Unity | |
name | string | |
closed? | function | |
shade? | number | how dark it is (0.85), for a screen whose texts go over what's under |
Returns Panel
ui.place(parent, name, kind, pos, size, pivot?)
A component on a new object under parent, placed from its bottom left corner: what ui.rect and ui.text make theirs with.
local raw = ui.place(parent, "my-picture", CS.UnityEngine.UI.RawImage, { 0, 0 }, { 400, 400 })
| Parameter | Type | |
|---|---|---|
parent | Unity | |
name | string | |
kind | Unity | a component's class |
pos | Vector | |
size | Vector | |
pivot? | Vector | { 0, 0.5 } when left out |
Returns Unity (component)
ui.rect(parent, name, pos, size, colour, pivot?)
A plain Image in a colour, placed like ui.place.
local box = ui.rect(parent, "my-box", { 100, 100 }, { 400, 300 }, ui.colours.dark) box.sprite = image("logo.png")
| Parameter | Type | |
|---|---|---|
parent | Unity | |
name | string | |
pos | Vector | |
size | Vector | |
colour | Colour | |
pivot? | Vector |
Returns Image (image)
ui.text(parent, name, font, pos, size, fontSize, alignment, pivot?)
A Text in white, placed like ui.place, its text overflowing its box. alignment is a TextAnchor.
local label = ui.text(parent, "my-label", font, { 40, 40 }, { 0, 0 }, 32, 3) -- MiddleLeft label.text = "Hello"
| Parameter | Type | |
|---|---|---|
parent | Unity | |
name | string | |
font | Unity | |
pos | Vector | |
size | Vector | |
fontSize | number | |
alignment | integer | |
pivot? | Vector |
Returns Text (text)
ui.screen(name, order)
A canvas over everything in any scene, 1080 units high like the game's menus and width wide, whose buttons take taps.
local canvas, width = ui.screen("my-mod", 50) print(width) --> 1617.98 on a 3200x2136 screen ui.rect(canvas, "my-corner", { width - 120, 1080 - 120 }, { 100, 100 }, ui.colours.red)
| Parameter | Type | |
|---|---|---|
name | string | |
order | integer |
Returns RectTransform (canvas)
Returns number (width)
ui.view(name)
A screen of its own over the menus.
local view = ui.view("my-mod") button("Open", function() view.show("main") view.part("all", "", function(root) view.back(root, view.hide) view.text(root, { view.left, view.top }, 44, "My mod") end) end)
| Parameter | Type | |
|---|---|---|
name | string |
Returns View
ui.toasted(x, y)
Whether a point of the screen (pixels) is on a toast, for what reads the touches itself.
for _, touch in ipairs(touches()) do if not ui.toasted(touch.x, touch.y) then press(touch) end end
| Parameter | Type | |
|---|---|---|
x | number | |
y | number |
Returns boolean
ui.avatar(parent, name, pos, size, key)
A player's avatar in a square, from the game's key of it.
ui.avatar(row, "my-avatar", { 40, 48 }, 64, appearance().avatar)
| Parameter | Type | |
|---|---|---|
parent | Unity | |
name | string | |
pos | Vector | |
size | number | |
key | string |
Returns Image
ui.list(parent, name, pos, size, width?)
A list scrolling like the game's: bars width wide go in list.rows at { -y * slope, -y }, list.content.sizeDelta's y is their height. Without a width it's upright: what's put in rows scrolls straight up and down, with a thin bar on its right.
local list = ui.list(root, "my-list", { 200, 30 }, { 1200, 900 }, 1000) local slope = CS.SettingItemsManager.InverseSlope for i, name in ipairs(names) do local y = (i - 1) * 108 view.plate(list.rows, { -y * slope, -y }, { list.width, 96 }, ui.colours.faint, 34, name) end list.content.sizeDelta = { 0, #names * 108 }
| Parameter | Type | |
|---|---|---|
parent | Unity | |
name | string | |
pos | Vector | |
size | Vector | |
width? | number |
Returns { transform: Unity, content: Unity, rows: Unity, width: number? }
ui.video(parent, name, pos, size, url, poster?, pivot?)
A RawImage looping a video of a url or a file without sound, showing poster (a Texture) until it plays.
ui.video(parent, "my-clip", { 0, 0 }, { 640, 360 }, "https://phigros.tools/catalog/clip.mp4")
| Parameter | Type | |
|---|---|---|
parent | Unity | |
name | string | |
pos | Vector | |
size | Vector | |
url | string | |
poster? | Unity | |
pivot? | Vector |
Returns RawImage
ui.fit(rawImage, texture)
Shows a texture, the image shrinking to its shape.
local shown = ui.place(parent, "my-picture", CS.UnityEngine.UI.RawImage, { 0, 0 }, { 400, 400 }) ui.fit(shown, phigrospp.texture(phigrospp.read(phigrospp.dir() .. "art.png")))
| Parameter | Type | |
|---|---|---|
rawImage | Unity | |
texture | Unity |
ui.checkbox(parent, name, font, pos, size, label, checked, fn)
A checkbox.
ui.checkbox(parent, "my-check", font, { 600, 40 }, 32, "Mirror", mirrored, function() mirrored = not mirrored end)
| Parameter | Type | |
|---|---|---|
parent | Unity | |
name | string | |
font | Unity | |
pos | Vector | |
size | number | |
label | string | |
checked | boolean | |
fn | fun() |