phigros.tools

Settings

Settings are rows of the Phigros++ settings tab, or of a tab of the mod's own, saved for it (Settings). Each function takes the tab's name and a function saying whether the row shows as its last arguments.

setting(label, default, options?, tab?, shown?) setting(label, default, tab?, shown?)

A toggle, a slider or a choice, saved. Returns its getter, which sets it when given a value (as if the player had).

local enabled = setting("Show the thing", true)                 -- a toggle in the Phigros++ tab
local other = setting("Other thing", false, "My mod")           -- or in a tab of its own
local size = setting("Size", 1.0, { 0.5, 2 })                   -- a slider, whole numbers when the default is one
local offset = setting("Offset", 0, { -100, 100, step = 5, unit = "ms", hint = "*Shown under it" })
                                                                -- with a step: - and + buttons, the value on the right
local style = setting("Style", "osu", { "osu", "classic" })     -- a choice, tapping it picks the next one
if enabled() then end
enabled(false)
ParameterType
labelstring
defaultT
options?table{ min, max, step =, unit =, hint = } for a slider, the values for a choice
tab?string
shown?fun(): boolean

Returns fun(value?: T): T

button(label, fn, tab?, shown?, danger?)

A button running a function. A label can be a function, the button follows what it returns. danger makes the label red, for what can't be undone.

button("Say hello", function() toast("Hello") end)
local taps = 0
button(function() return ("Tapped %d times"):format(taps) end, function() taps = taps + 1 end, "My mod")
button("Forget my records", forget, "My mod", nil, true) -- red, for what can't be undone
ParameterType
labelstring|fun(): string
fnfun()
tab?string
shown?fun(): boolean
danger?boolean

A label with the game's arrow button, as on its Misc page.

link("Open the docs", function() CS.UnityEngine.Application.OpenURL("https://docs.phigros.tools") end)
ParameterType
labelstring|fun(): string
fnfun()
tab?string
shown?fun(): boolean

progress(fn, tab?, shown?)

A bar filled from 0 to 1, redrawn every frame: fn returns how far along it is and a text for its middle, or { left =, center =, right = }.

progress(function()
  local done = now() % 5 / 5
  return done, ("Downloading, %d%%"):format(math.floor(done * 100))
end, "My mod")
progress(function() return 0.25, { left = "song.zip", right = "10 / 40 MB" } end, "My mod")
ParameterType
fnfun(): number, (string|table)?
tab?string
shown?fun(): boolean

row(height, draw, tab?, shown?)

An empty row height high that draw fills each time the settings are built, for a preview: area is its RectTransform, as wide as the tab's rows.

row(190, function(area)
  phigrospp.ui.cover(area, "my-preview", { 40, 170 }, { 300, 150 }, "Glaciaxion.SunsetRay.0")
end, "My mod")
ParameterType
heightnumber
drawfun(area: Unity)
tab?string
shown?fun(): boolean

tab(name, shown?, draw?)

A tab shown only while shown returns true. The tab "Profile" puts rows on the game's Profile page. Given draw, the tab draws its page itself each time the settings are built: view is a RectTransform as high as the list, centred on screen, and font the game's.

local debug = setting("Debug", false)
tab("Debug tools", function() return debug() end) -- the tab shows while Debug is on
button("Dump the scene", function() print(scene()) end, "Debug tools")
setting("Show my RKS", true, "Profile")             -- a row on the game's Profile page
ParameterType
namestring
shown?fun(): boolean
draw?fun(view: Unity, font: Unity)