added lua api for usc for code completion and static analisys

This commit is contained in:
Hersi 2021-11-18 00:32:24 +01:00
parent bef6a917c1
commit a9b582ed6f
17 changed files with 1373 additions and 0 deletions

View File

@ -0,0 +1,60 @@
-- bg 'background' table
-- Draws the background shader and invokes `gfx.ForceRender`
DrawShader = function() end
-- Gets the clear state value, `0` for fail state, `1` for clear state
---@return integer
GetClearTransition = function() end
-- Retrieves the path to the background folder
GetPath = function() end
-- Gets the pixel coordinates for a point just above the end of the track
---@return number x
---@return number y
GetScreenCenter = function() end
-- Gets tilt values, `< 0` for clockwise, `> 0` for counter-clockwise
---@return number laserTilt # Tilt induced by lasers
---@return number spinTilt # Tilt induced by spinEvents
GetTilt = function() end
-- Gets timing data of the chart
---@return number bartime # Value that goes from `0` to `1` over the duration of each beat
---@return number offsync # Value that goes from `0` to `1` over the duration `BPM * multiplier`
---@return number time # Current time in the chart
GetTiming = function() end
-- Loads a texture which will be available in the fragment shader under the given `shaderName`
---@param shaderName string
---@param fileName string
LoadTexture = function(shaderName, fileName) end
-- Set a float value to a uniform variable in the shader
---@param uniformName string
---@param val number
SetParamf = function(uniformName, val) end
-- Set an integer value to a uniform variable in the shader
---@param uniformName string
---@param val integer
SetParami = function(uniformName, val) end
-- Sets the speed multiplier for the `offsync` timer returned by `GetTiming`
---@param speed number
SetSpeedMulti = function(speed) end
---@class background
background = {
DrawShader = DrawShader,
GetClearTransition = GetClearTransition,
GetPath = GetPath,
GetScreenCenter = GetScreenCenter,
GetTilt = GetTilt,
GetTiming = GetTiming,
LoadTexture = LoadTexture,
SetParamf = SetParamf,
SetParami = SetParami,
SetSpeedMulti = SetSpeedMulti,
};

View File

@ -0,0 +1,32 @@
-- chalwheel `chalwheel` table
---@class Challenge
---@field bestScore integer # Best score for the challenge
---@field charts Chart[] # Array of charts for the challenge
---@field grade string # Best grade achieved for the challenge
---@field id integer # Challenge id, unique static identifier
---@field missing_chart boolean # `true` if a chart is missing
---@field requirement_text string # Challenge requirements, separated by newline character `"\n"`
---@field title string # Challenge title
---@field topBadge integer -- `0 = Never Played`, `1 = Played`, `2 = Cleared`, `3 = Hard Cleared`, `4 = Full Chain`, `5 = Perfect Chain`
Challenge = {};
---@class Chart
---@field artist string # Chart artist
---@field bpm number # Chart BPm
---@field difficulty integer # Difficulty index
---@field effector string # Chart effector
---@field id integer # Chart id, unique static identifier
---@field illustrator string # Chart jacket illustrator
---@field jacketPath string -- Full filepath to the jacket image on the disk
---@field level integer # Chart level
---@field title string # Chart title
Chart = {};
---@class chalwheel
---@field allChallenges Challenge[] # Array of all available challenges
---@field challenges Challenge[] # Array of challenges with the current filters/sorting applied
---@field searchInputActive boolean # Search status
---@field searchStatus string # Current challenge database status
---@field searchText string # Search input text
chalwheel = {};

View File

@ -0,0 +1,28 @@
-- downloadscreen `dlScreen` table
-- Download the selected song
---@param uri string # Encoded URI
---@param header table
---@param id string # Song ID
---@param cb function # Archive callback
DownloadArchive = function(uri, header, id, cb) end
-- Exit the download screen
Exit = function() end
-- Gets the path to the song folder
GetSongsPath = function() end
-- Play the chart preview
---@param uri string # Encoded URI
---@param header table
---@param id string # Song ID
PlayPreview = function(uri, header, id) end
---@class dlScreen
dlScreen = {
DownloadArchive = DownloadArchive,
Exit = Exit,
GetSongsPath = GetSongsPath,
PlayPreview = PlayPreview,
};

View File

@ -0,0 +1,6 @@
-- filterwheel `filters` table
---@class filters
---@field folder string[] # Array of song folders and collections
---@field level string[] # Array of song levels
filters = {};

View File

@ -0,0 +1,60 @@
-- fg 'foreground' table
-- Draws the foreground shader and invokes `gfx.ForceRender`
DrawShader = function() end
-- Gets the clear state value, `0` for fail state, `1` for clear state
---@return integer
GetClearTransition = function() end
-- Retrieves the path to the background folder
GetPath = function() end
-- Gets the pixel coordinates for a point just above the end of the track
---@return number x
---@return number y
GetScreenCenter = function() end
-- Gets tilt values, `< 0` for clockwise, `> 0` for counter-clockwise
---@return number laserTilt # Tilt induced by lasers
---@return number spinTilt # Tilt induced by spinEvents
GetTilt = function() end
-- Gets timing data of the chart
---@return number bartime # Value that goes from `0` to `1` over the duration of each beat
---@return number offsync # Value that goes from `0` to `1` over the duration `BPM * multiplier`
---@return number time # Current time in the chart
GetTiming = function() end
-- Loads a texture which will be available in the fragment shader under the given `shaderName`
---@param shaderName string
---@param fileName string
LoadTexture = function(shaderName, fileName) end
-- Set a float value to a uniform variable in the shader
---@param uniformName string
---@param val number
SetParamf = function(uniformName, val) end
-- Set an integer value to a uniform variable in the shader
---@param uniformName string
---@param val integer
SetParami = function(uniformName, val) end
-- Sets the speed multiplier for the `offsync` timer returned by `GetTiming`
---@param speed number
SetSpeedMulti = function(speed) end
---@class foreground
foreground = {
DrawShader = DrawShader,
GetClearTransition = GetClearTransition,
GetPath = GetPath,
GetScreenCenter = GetScreenCenter,
GetTilt = GetTilt,
GetTiming = GetTiming,
LoadTexture = LoadTexture,
SetParamf = SetParamf,
SetParami = SetParami,
SetSpeedMulti = SetSpeedMulti,
};

96
docs/lua_api/game.lua Normal file
View File

@ -0,0 +1,96 @@
-- Global `game` table
-- Gets the state of the specified button
---@param button integer # options are under the `game` table prefixed with `BUTTON`
---@return boolean # `true` if it is being pressed
GetButton = function(button) end
-- Gets the absolute rotation of the specified knob
---@param knob integer # `0 = left`, `1 = right`
---@return number angle # in radians, `0.0` to `2*pi`
GetKnob = function(knob) end
-- Gets the color of the specified laser
---@param laser integer # `0 = left`, `1 = right`
---@return integer r, integer g, integer b
GetLaserColor = function(laser) end
-- Gets the mouse's position on the game window in pixel coordinates
---@return number, number
GetMousePos = function() end
-- Gets the game window's resolution in pixels
---@return number, number
GetResolution = function() end
-- Gets the name of the current skin
---@return string
GetSkin = function() end
-- Gets the value of the skin setting with the specified key
---@param key string
---@return any
GetSkinSetting = function(key) end
-- Checks whether the named sample is currently playing
---@param name string # name of the loaded sample
---@return boolean|nil # `nil` if the sample is not loaded
IsSamplePlaying = function(name) end
-- Loads an audio sample from the `audio` directory of the current skin folder
---@param name string # `.wav` extension assumed if not provided
LoadSkinSample = function(name) end
-- Logs a message to the game's log file
---@param message string
---@param severity integer # options are under the `game` table prefixed with `LOGGER`
Log = function(message, severity) end
-- Plays a loaded sample
---@param name string # name of the loaded sample
---@param loop? boolean
PlaySample = function(name, loop) end
-- Sets the value of the skin setting with the specified key
---@param key string
---@param value any # type must match the type of the defined skin setting
SetSkinSetting = function(key, value) end
-- Stops a playing sample
---@param name string # name of the loaded sample
StopSample = function(name) end
-- Checks if an update is available
---@return string url, string version # `nil` if there is no update available
UpdateAvailable = function() end
game = {
LOGGER_INFO = 1,
LOGGER_NORMAL = 2,
LOGGER_WARNING = 3,
LOGGER_ERROR = 4,
BUTTON_BTA = 0,
BUTTON_BTB = 1,
BUTTON_BTC = 2,
BUTTON_BTD = 3,
BUTTON_FXL = 4,
BUTTON_FXR = 5,
BUTTON_STA = 6,
BUTTON_BCK = 11,
GetButton = GetButton,
GetKnob = GetKnob,
GetLaserColor = GetLaserColor,
GetMousePos = GetMousePos,
GetResolution = GetResolution,
GetSkin = GetSkin,
GetSkinSetting = GetSkinSetting,
IsSamplePlaying = IsSamplePlaying,
LoadSkinSample = LoadSkinSample,
Log = Log,
PlaySample = PlaySample,
SetSkinSetting = SetSkinSetting,
StopSample = StopSample,
UpdateAvailable = UpdateAvailable,
};

57
docs/lua_api/gameplay.lua Normal file
View File

@ -0,0 +1,57 @@
-- gameplay `gameplay` table
---@class CritLine
---@field cursors LaserCursor[] #
---@field line Line # Line from the left corner of the track to the right corner
---@field rotation number # The rotation of the crit line, in radians
---@field x integer # Screen x-coordinate of the center of the crit line
---@field y integer # Screen y-coordinate of the center of the crit line
CritLine = {};
---@class LaserCursor
---@field alpha number # Alpha channel value, `0.0` to `1.0`
---@field pos number # The x-position relative to the center of the crit line
---@field skew number # The x-skew of the cursor
LaserCursor = {};
---@class Gauge
---@field type integer # `0` = Effective, `1` = Excessive, `2` = Permissive, `3` = Blastive
---@field value number # Current gauge percentage, `0.0` to `1.0`
Gauge = {};
---@class Line
---@field x1 number # Starting x-coordinate
---@field y1 number # Starting y-coordinate
---@field x2 number # Ending x-coordinate
---@field y2 number # Ending y-coordinate
Line = {};
---@class ScoreReplay
---@field currentScore integer # Current score of the replay
---@field maxScore integer # Ending score of the replay
ScoreReplay = {};
---@class gameplay
---@field artist string # Chart artist
---@field bpm number # Chart BPM
---@field comboState integer # `0` = Normal, `1` = UC, `2` = PUC
---@field critLine CritLine # Table of crit line information
---@field demoMode boolean # Whether the game is in demo mode
---@field difficulty integer # Difficulty index
---@field gauge Gauge # Table of gauge information
---@field hiddenCutoff number # Hidden cutoff value, `0.0` to `1.0`
---@field hiddenFade number # Hidden fade value, `0.0` to `1.0`
---@field hispeed number # Current hispeed
---@field hitWindow HitWindow # Table of hit window information
---@field jacketPath string # Full filepath to the jacket image on the disk
---@field laserActive boolean[] # Array of laser active states, `1` = left, `2` = right
---@field level integer # Chart level
---@field noteHeld boolean[] # Array of button hold states, in order from 1 to 6: `BTA`, `BTB`, `BTC`, `BTD`, `FXL`, `FXR`
---@field practice_setup boolean|nil # `true` = practice setup, `false` = practicing, `nil` = not in practice mode
---@field progress number # Chart progress, `0.0` to `1.0`
---@field scoreReplays ScoreReplay[] # Array of previous scores for the chart
---@field suddenCutoff number # Sudden cutoff value, `0.0` to `1.0`
---@field suddenFade number # Sudden fade value, `0.0` to `1.0`
---@field title string # Chart title
---@field user_id nil|string # Only for multiplayer
gameplay = {};

View File

@ -0,0 +1,23 @@
-- gamesettingsdialog `SettingsDiag` table
---@class SettingsDiagSetting
---@field max? number # Maximum setting value, only available if setting `type` is `int` or `float`
---@field min? number # Minimum setting value, only available if setting `type` is `int` or `float`
---@field name string # Setting ane
---@field options? string[] # Array of setting value names, only available if setting `type` is `enum`
---@field type string # Type of the setting value: `button`, `enum`, `float`, `int`, or `toggle`
---@field value? number|boolean # Value of the setting, not available if setting `type` is `button`
SettingsDiagSetting = {};
---@class SettingsDiagTab
---@field name string # Tab name
---@field settings SettingsDiagSetting[] # Array of settings in the tab
SettingsDiagTab = {};
---@class SettingsDiag
---@field currentSetting integer # Current setting index for `SettigsDiag[currentTab].settings`
---@field currentTab integer # Current tab index for `SettingsDiag.tabs`
---@field posX number # X-Position relative to the entire screen, from `0.0` to `1.0`
---@field posY number # Y-Position relative to the entire screen, from `0.0` to `1.0`
---@field tabs SettingsDiagTab[]
SettingsDiag = {};

598
docs/lua_api/gfx.lua Normal file
View File

@ -0,0 +1,598 @@
-- Global `gfx` table
-- Creates a new circle arc shaped sub-path
---@param cx number # center x-coordinate
---@param cy number # center y-coordinate
---@param r number # radius
---@param a0 number # starting angle, in radians
---@param a1 number # ending angle, in radians
---@param dir integer # 1 = counter-clockwise, 2 = clockwise
Arc = function(cx, cy, r, a0, a1, dir) end
-- Adds an arc segment at the corner defined by the previous point and two specified points
---@param x1 number
---@param y1 number
---@param x2 number
---@param y2 number
---@param radius number
ArcTo = function(x1, y1, x2, y2, radius) end
-- Clears currently defined paths to begin drawing a new "shape"
BeginPath = function() end
-- Adds a cubic bezier segment from the previous point to the specified point
-- Uses the two control points `(c1x, c1y)` and `(c2x, c2y)`
---@param c1x number
---@param c1y number
---@param c2x number
---@param c2y number
---@param x number
---@param y number
BezierTo = function(c1x, c1y, c2x, c2y, x, y) end
-- Creates a box gradient that can be used by `FillPaint` or `StrokePaint`
---@param x number
---@param y number
---@param w number
---@param h number
---@param r number # radius
---@param f number # feather amount
BoxGradient = function(x, y, w, h, r, f) end
-- Creates a new circle shaped sub-path
---@param cx number
---@param cy number
---@param r number
Circle = function(cx, cy, r) end
-- Closes the current sub-path with a line segment
ClosePath = function() end
-- Loads an image from the specified filename
---@param filename string
---@param flags? integer # options are under the `gfx` table prefixed with `IMAGE`
CreateImage = function(filename, flags) end
-- Creates a cached text that can be drawn by `DrawLabel`
---@param text string
---@param size integer
---@param monospace boolean
CreateLabel = function(text, size, monospace) end
-- Creates a new `ShadedMesh` object
---@param materialName string
---@param path? string # Optional path to the material, loads from the current skin's `shaders` folder otherwise
-- `<materialName>.fs` and `<materialName>.vs` must exist at either location
---@return ShadedMesh
CreateShadedMesh = function(materialName, path) end
-- Loads an image from `skins/<skin>/textures/<path>`
---@param path string
---@param flags? integer
CreateSkinImage = function(path, flags) end
-- Draws the loaded gauge
-- The game loads the gauge itself, using the textures in `skins/<skin>/textures/gauges/`
---@param rate number # current gauge percentage
---@param x number
---@param y number
---@param w number
---@param h number
---@param deltaTime number
DrawGauge = function(rate, x, y, w, h, deltaTime) end
-- Draws a created label, resized if `maxWidth > 0`
-- Labels are always be drawn on top of other drawn elements
---@param label any # label created by `CreateLabel`
---@param x number
---@param y number
---@param maxWidth? number
DrawLabel = function(label, x, y, maxWidth) end
-- Creates a new ellipse shaped sub-path
---@param cx number
---@param cy number
---@param rx number
---@param ry number
Ellipse = function(cx, cy, rx, ry) end
-- Draws a string at the specified location, but will always be drawn on top of other drawn elements
---@param text string
---@param x number
---@param y number
FastText = function(text, x, y) end
-- Gets the width and height of a given fast text
---@param text string
---@return number w, number h
FastTextSize = function(text) end
-- Fills the current path with the current fill style
Fill = function() end
-- Sets the current fill to a solid color
---@param r integer
---@param g integer
---@param b integer
---@param a? integer # default 255
FillColor = function(r, g, b, a) end
-- Sets the current fill to a paint
---@param paint any # pattern created by `ImagePattern` or gradient created by `BoxGradient`, `LinearGradient`, or `RadialGradient`
FillPaint = function(paint) end
-- Sets the font face for the current text style
---@param font string
FontFace = function(font) end
-- Sets the font size of the current text style
---@param size number
FontSize = function(size) end
-- Forces the current render queue to be processed
-- This causes "fast" elements such as `FastRect`, `FastText` or `labels` to be drawn/processed immediately rather than at the end of the render queue
ForceRender = function() end
-- Gets the shared texture ID generated by `gfx.LoadSharedTexture` under the given `name`
---@param name string
---@return integer ID # Used the same as images generated by `gfx.CreateImage`
GetSharedTexture = function(name) end
-- Sets the global alpha value for all drawings
-- Elements that have their alpha set will be adjusted relative to the global value
---@param alpha number
GlobalAlpha = function(alpha) end
-- Sets the composite operation with custom pixel arithmetic
-- Options are under the `gfx` table prefixed with `BLEND`
---@param srcFactor integer
---@param desFactor integer
GlobalCompositeBlendFunc = function(srcFactor, desFactor) end
-- Sets the composite operation with custom pixel arithmetic for RGB and alpha components separately
-- Options are under the `gfx` table prefixed with `BLEND`
---@param srcRGB integer
---@param desRGB integer
---@param srcAlpha integer
---@param desAlpha integer
GlobalCompositeBlendFuncSeparate = function(srcRGB, desRGB, srcAlpha, desAlpha) end
-- Sets the composite operation
-- Options are under the `gfx` table prefixed with `BLEND_OP`
---@param op integer
GlobalCompositeOperation = function(op) end
-- Sets the inner and outer colors for a gradient
-- `ri, gi, bi, ai` inner color
-- `ro, go, bo, ao` outer color
---@param ri integer
---@param gi integer
---@param bi integer
---@param ai integer
---@param ro integer
---@param go integer
---@param bo integer
---@param ao integer
GradientColors = function(ri, gi, bi, ai, ro, bo, go, ao) end
-- Creates an image pattern that can be used by `FillPaint` or `StrokePaint`
-- `(sx, sy)` is the top-left location of the pattern
-- `(ix, iy)` is the size of one image
---@param sx number
---@param sy number
---@param ix number
---@param iy number
---@param angle number # in radians
---@param image any # image created by `CreateImage` or `CreateSkinImage`
---@param alpha number # `0.0` to `1.0`
ImagePattern = function(sx, sy, ix, iy, angle, image, alpha) end
-- Draws an image in the specified rect; stretches the image to fit
---@param x number
---@param y number
---@param w number
---@param h number
---@param image any # image created by `CreateImage` or `CreateSkinImage`, or an animation loaded with `LoadSkinAnimation`
---@param alpha number # `0.0` to `1.0`
---@param angle number # in radians
ImageRect = function(x, y, w, h, image, alpha, angle) end
-- Gets the width and height of a given image
---@param image any # image created by `CreateImage` or `CreateSkinImage`
---@return number w, number h
ImageSize = function(image) end
-- Intersects the current scissor rectangle with the specified rectangle
---@param x number
---@param y number
---@param w number
---@param h number
IntersectScissor = function(x, y, w, h) end
-- Gets the width and height of a given label
---@param label any # label created by `CreateLabel`
---@return number w, number h
LabelSize = function(label) end
-- Creates a linear gradient that can be used by `FillPaint` or `StrokePaint`
-- `(sx, sy)` -> `(ex, ey)` starting to ending coordinates
---@param sx number
---@param sy number
---@param ex number
---@param ey number
LinearGradient = function(sx, sy, ex, ey) end
-- Sets how the end of the line is drawn
-- Options are under the `gfx` table prefixed with `LINE`
---@param cap integer
LineCap = function(cap) end
-- Sets how sharp path corners are drawn
-- Options are under the `gfx` table prefixed with `LINE`
---@param join integer
LineJoin = function(join) end
-- Adds a line segment from the previous point to the specified point
---@param x number
---@param y number
LineTo = function(x, y) end
-- Loads all images of the specified folder as frames to be used for an animation
-- Returns an `animation` that can be used the same way as an `image`
---@param path string
---@param frameTime number # 1 / fps
---@param loopCount? integer # 0
---@param compressed boolean # false
-- if `compressed`, the animation will be stored in RAM and decoded on-demand; this uses more CPU but much less RAM
LoadAnimation = function(path, frameTime, loopCount, compressed) end
-- Loads a persistent texture from the `path` that can be accessed by the `name` in `gfx.GetSharedTexture` and `ShadedMesh:AddSharedTexture`
---@param name string
---@param path string
LoadSharedTexture = function(name, path) end
-- Loads all images from `skins/<skin>/textures/<path>` to be used for an animation
-- Returns an `animation` that can be used the same way as an `image`
---@param path string
---@param frameTime number # 1 / fps
---@param loopCount? integer # Default `0`
---@param compressed boolean
-- If `compressed`, the animation will be stored in RAM and decoded on-demand; this uses more CPU but much less RAM
LoadSkinAnimation = function(path, frameTime, loopCount, compressed) end
-- Loads a persistent texture from `skins/<skin>/textures/<path>` that can be accessed by the `name` in `gfx.GetSharedTexture` and `ShadedMesh:AddSharedTexture`
---@param name string
---@param path string
LoadSharedSkinTexture = function(name, path) end
-- Loads a font fromt the specified filename
-- Sets it as the current font if it is already loaded
---@param name? string
---@param filename string
LoadFont = function(name, filename) end
-- Loads an image outside of the main thread to prevent rendering lock-up
-- Image will be loaded at original size unless `w` and `h` are provided
---@param filepath string
---@param placeholder any # image created by `CreateImage` or `CreateSkinImage`
---@param w? number # 0
---@param h? number # 0
---@return any # returns `placeholder` until the image is loaded
LoadImageJob = function(filepath, placeholder, w, h) end
-- Loads a font from `skins/<skin>/textures/<path>`
-- Sets it as the current font if it is already loaded
---@param name? string
---@param filename string
LoadSkinFont = function(name, filename) end
-- Loads an image outside of the main thread to prevent rendering lock-up
-- Image will be loaded at original size unless `w` and `h` are provided
---@param url string # web url of image
---@param placeholder any # image created by `CreateImage` or `CreateSkinImage`
---@param w? number # 0
---@param h? number # 0
---@return any # returns `placeholder` until the image is loaded
LoadWebImageJob = function(url, placeholder, w, h) end
-- Sets the miter limit of the stroke style
---@param limit number
MiterLimit = function(limit) end
-- Starts a new sub-path at the specified point
---@param x number
---@param y number
MoveTo = function(x, y) end
-- Adds a quadratic bezier segment from the previous point to the specified point
-- Uses the control point `(cx, cy)`
---@param cx number
---@param cy number
---@param x number
---@param y number
QuadTo = function(cx, cy, x, y) end
-- Creates a radial gradient that can be used by `FillPaint` or `StrokePaint`
---@param cx number
---@param cy number
---@param inr number # inner radius
---@param outr number # outer radius
RadialGradient = function(cx, cy, inr, outr) end
-- Creates a new rectangle shaped sub-path
---@param x number
---@param y number
---@param w number
---@param h number
Rect = function(x, y, w, h) end
-- Resets the current render state to default values
-- This does not affect the render state stack
Reset = function() end
-- Resets and disables scissoring
ResetScissor = function() end
-- Resets all transforms done by `Rotate`, `Scale`, or `Translate`, etc.
ResetTransform = function() end
-- Pops/restores the current render state from the state stack
-- The render state is pushed/saved to the stack using `Save`
Restore = function() end
-- Rotates the current coordinates
---@param angle number # in radians
Rotate = function(angle) end
-- Creates a rounded rectangle shaped sub-path
---@param x number
---@param y number
---@param w number
---@param h number
---@param r number
RoundedRect = function(x, y, w, h, r) end
-- Creates a rounded rectangle shaped sub-path with varying radii for each corner
-- `r1` is the top-left corner and continues clockwise
---@param x number
---@param y number
---@param w number
---@param h number
---@param r1 number
---@param r2 number
---@param r3 number
---@param r4 number
RoundedRectVarying = function(x, y, w, h, r1, r2, r3, r4) end
-- Pushes/saves the current render state into a state stack
-- The render state can be popped/restored from the stack using `Restore`
Save = function() end
-- Scales the current coordinates by the given factors
---@param x number
---@param y number
Scale = function(x, y) end
-- Sets the current scissor rectangle
-- Scissoring allows you to clip any rendering into a rectangle (affected by the current transform)
---@param x number
---@param y number
---@param w number
---@param h number
Scissor = function(x, y, w, h) end
-- Sets the gauge color for the specified `index`
---@param index integer #
-- ```
-- 0 = Normal gauge fail (<70%)
-- 1 = Normal gauge clear (>=70%)
-- 2 = Hard gauge fail (<30%)
-- 3 = Hard gauge fail (>=30%)
-- ```
---@param r integer
---@param g integer
---@param b integer
SetGaugeColor = function(index, r, g, b) end
-- Multiplies the color given with all incoming drawn image colors
---@param r integer
---@param g integer
---@param b integer
SetImageTint = function(r, g, b) end
-- Skews the current coordinates along the x-axis
---@param angle number # in radians
SkewX = function(angle) end
-- Skews the current coordinates along the y-axis
---@param angle number # in radians
SkewY = function(angle) end
-- Strokes the current path with the current stroke style
Stroke = function() end
-- Sets the current stroke style to a solid color
---@param r integer
---@param g integer
---@param b integer
---@param a? integer # 255
StrokeColor = function(r, g, b, a) end
-- Sets the current stroke style to a paint
---@param paint any # pattern created by `ImagePattern` or gradient created by `BoxGradient`, `LinearGradient`, or `RadialGradient`
StrokePaint = function(paint) end
-- Sets the stroke width of the stroke style
---@param size number
StrokeWidth = function(size) end
-- Draws a string at the specified location
---@param text string
---@param x number
---@param y number
Text = function(text, x, y) end
-- Sets the text align of the current text style
-- Options are under the `gfx` table prefixed with `TEXT_ALIGN`
---@param align integer
TextAlign = function(align) end
-- Gets the bounding rectangle coordinates of a given text
---@param x number
---@param y number
---@param text string
---@return number x1, number y1, number x2, number y2
TextBounds = function(x, y, text); end
-- Progresses the given animation
---@param animation any # animation created by `LoadAnimation` or `LoadSkinAnimation`
---@param deltaTime number
TickAnimation = function(animation, deltaTime) end
-- Translates the current coordinates by `x` and `y`
---@param x number
---@param y number
Translate = function(x, y) end
-- Updates the properties of a created pattern
-- `(sx, sy)` is the top-left location of the pattern
-- `(ix, iy)` is the size of one image
---@param pattern any # pattern created by `ImagePattern`
---@param sx number
---@param sy number
---@param ix number
---@param iy number
---@param angle number # in radians
---@param alpha number # `0.0` to `1.0`
UpdateImagePattern = function(pattern, sx, sy, ix, iy, angle, alpha) end
-- Updates the properties of a created label
---@param label any # label created by `CreateLabel`
---@param text? string
---@param size? integer
UpdateLabel = function(label, text, size) end
---@type table
gfx = {
BLEND_ZERO = 1,
BLEND_ONE = 2,
BLEND_SRC_COLOR = 4,
BLEND_ONE_MINUS_SRC_COLOR = 8,
BLEND_DST_COLOR = 16,
BLEND_ONE_MINUS_DST_COLOR = 32,
BLEND_SRC_ALPHA = 64,
BLEND_ONE_MINUS_SRC_ALPHA = 128,
BLEND_DST_ALPHA = 256,
BLEND_ONE_MINUS_DST_ALPHA = 512,
BLEND_SRC_ALPHA_SATURATE = 1024,
BLEND_OP_SOURCE_OVER = 0,
BLEND_OP_SOURCE_IN = 1,
BLEND_OP_SOURCE_OUT = 2,
BLEND_OP_ATOP = 3,
BLEND_OP_DESTINATION_OVER = 4,
BLEND_OP_DESTINATION_IN = 5,
BLEND_OP_DESTINATION_OUT = 6,
BLEND_OP_DESTINATION_ATOP = 7,
BLEND_OP_LIGHTER = 8,
BLEND_OP_COPY = 9,
BLEND_OP_XOR = 10,
IMAGE_GENERATE_MIPMAPS = 1,
IMAGE_REPEATX = 2,
IMAGE_REPEATY = 4,
IMAGE_FLIPY = 8,
IMAGE_PREMULTIPLIED = 16,
IMAGE_NEAREST = 32,
LINE_BUTT = 0,
LINE_ROUND = 1,
LINE_SQUARE = 2,
LINE_BEVEL = 3,
LINE_MITER = 4,
TEXT_ALIGN_LEFT = 1,
TEXT_ALIGN_CENTER = 2,
TEXT_ALIGN_RIGHT = 4,
TEXT_ALIGN_TOP = 8,
TEXT_ALIGN_MIDDLE = 16,
TEXT_ALIGN_BOTTOM = 32,
TEXT_ALIGN_BASELINE = 64,
Arc = Arc,
ArcTo = ArcTo,
BeginPath = BeginPath,
BezierTo = BezierTo,
BoxGradient = BoxGradient,
Circle = Circle,
ClosePath = ClosePath,
CreateImage = CreateImage,
CreateLabel = CreateLabel,
CreateShadedMesh = CreateShadedMesh,
CreateSkinImage = CreateSkinImage,
DrawGauge = DrawGauge,
DrawLabel = DrawLabel,
Ellipse = Ellipse,
FastText = FastText,
FastTextSize = FastTextSize,
Fill = Fill,
FillColor = FillColor,
FillPaint = FillPaint,
FontFace = FontFace,
FontSize = FontSize,
ForceRender = ForceRender,
GetSharedTexture = GetSharedTexture,
GlobalAlpha = GlobalAlpha,
GlobalCompositeBlendFunc = GlobalCompositeBlendFunc,
GlobalCompositeBlendFuncSeparate = GlobalCompositeBlendFuncSeparate,
GlobalCompositeOperation = GlobalCompositeOperation,
GradientColors = GradientColors,
ImagePattern = ImagePattern,
ImageRect = ImageRect,
ImageSize = ImageSize,
IntersectScissor = IntersectScissor,
LabelSize = LabelSize,
LinearGradient = LinearGradient,
LineCap = LineCap,
LineJoin = LineJoin,
LineTo = LineTo,
LoadAnimation = LoadAnimation,
LoadSharedTexture = LoadSharedTexture,
LoadSkinAnimation = LoadSkinAnimation,
LoadSharedSkinTexture = LoadSharedSkinTexture,
LoadFont = LoadFont,
LoadImageJob = LoadImageJob,
LoadSkinFont = LoadSkinFont,
LoadWebImageJob = LoadWebImageJob,
MiterLimit = MiterLimit,
MoveTo = MoveTo,
QuadTo = QuadTo,
RadialGradient = RadialGradient,
Rect = Rect,
Reset = Reset,
ResetScissor = ResetScissor,
ResetTransform = ResetTransform,
Restore = Restore,
Rotate = Rotate,
RoundedRect = RoundedRect,
RoundedRectVarying = RoundedRectVarying,
Save = Save,
Scale = Scale,
Scissor = Scissor,
SetGaugeColor = SetGaugeColor,
SetImageTint = SetImageTint,
SkewX = SkewX,
SkewY = SkewY,
Stroke = Stroke,
StrokeColor = StrokeColor,
StrokePaint = StrokePaint,
StrokeWidth = StrokeWidth,
Text = Text,
TextAlign = TextAlign,
TextBounds = TextBounds,
TickAnimation = TickAnimation,
Translate = Translate,
UpdateImagePattern = UpdateImagePattern,
UpdateLabel = UpdateLabel,
};

44
docs/lua_api/http.lua Normal file
View File

@ -0,0 +1,44 @@
-- Global `Http` table
-- Executes a blocking `GET` request
---@param url string
---@param header table<string, string>
---@return HttpResponse
Get = function(url, header) end
-- Executes a `GET` request and calls `callback` with `HttpResponse` as a parameter
---@param url string
---@param header table<string, string>
---@param callback function
GetAsync = function(url, header, callback) end
-- Executes a blocking `POST` request
---@param url string
---@param content string
---@param header table<string, string>
---@return HttpResponse
Post = function(url, content, header) end
-- Executes a `POST` request and calls `callback` with `HttpResponse` as a parameter
---@param url string
---@param header table<string, string>
---@param callback function
PostAsync = function(url, header, callback) end
---@class HttpResponse
---@field cookies string
---@field double number
---@field header table<string, string>
---@field status integer
---@field error string
---@field text string
---@field url string
HttpResponse = {};
---@class Http
Http = {
Get = Get,
GetAsync = GetAsync,
Post = Post,
PostAsync = PostAsync,
};

View File

@ -0,0 +1,3 @@
-- Miscellaneous information
---@alias deltaTime number # Difference (delta) in time since the last frame, evaluates to `1 / current FPS`

7
docs/lua_api/readme.md Normal file
View File

@ -0,0 +1,7 @@
These files were taken from liqidwave to help with IDE autocompletion.
----
Thank you to
𝕕 𝕣 𝕖 𝕒 𝕞 𝕪 ouchaco#3407

106
docs/lua_api/result.lua Normal file
View File

@ -0,0 +1,106 @@
-- result and challengeresult `result` table
---@class HitStat
---@field timeFrac number -- Fraction of when in the chart the note was hit, `0.0` to `1.0`
---@field lane integer -- `0` = A, `1` = B, `2` = C, `3` = D, `4` = L, `5` = R, `6` = Left Laser, `7` = Right Laser
---@field time integer -- When in the chart the note was hit, in milliseconds
---@field delta integer -- Delta value of the hit from 0
---@field hold integer -- `0` for chip/laser, otherwise `# Ticks` of hold
---@field rating integer -- `0 = Miss`, `1 = Near`, `2 = Crit`
HitStat = {};
---@class HitWindow
---@field good integer # Near window, default `92`
---@field hold integer -- Hold window, default `138`
---@field miss integer -- Miss window, default `250`
---@field perfect integer -- Critical window, default `46`
---@field slam integer -- Slam window, default `84`
---@field type integer -- `1 = Normal` default, `2 = Hard` default values halved
HitWindow = {};
---@class Score
---@field auto_flags integer # Autoplay flag
---@field badge integer # `0` = Manual Exit, `1` = Played, `2` = Cleared, `3` = Hard Cleared, `4` = Full Chain, `5` = Perfect Chain
---@field gauge number # Ending gauge percentage, `0.0` to `1.0`
---@field gauge_option integer # Gauge option e.g. ARS
---@field gauge_type integer # `0` = Normal, `1` = Hard, `2` = Permissive, `3` = Blastive
---@field goods integer # Total near hits
---@field hitWindow HitWindow|nil # Hit windows of the score, only for singleplayer results screen
---@field mirror integer # Mirror mode flag
---@field misses integer # Total errors
---@field name nil|string # Only for multiplayer results, name of the player
---@field perfects integer # Total critical hits
---@field random integer # Random mode flag
---@field score integer # Result score
---@field timestamp integer # Unix timestamp of the score
---@field uid nil|string # Only for multiplayer results, UID of the player
Score = {};
---@class ChartResult : result
---@field passed boolean # Whether or not challenge requirements were met for this chart
---@field failReason string # Fail reason if a challenge requirement was not met
ChartResult = {};
---@class result
---@field artist string # Chart artist
---@field auto_flags integer # Autoplay flag
---@field autoplay boolean # Autoplay bool
---@field avgCrits integer # Only for challenge results, average number of critical hits across the charts
---@field avgErrors integer # Only for challenge results, average number of error hits across the charts
---@field avgGauge number # Only for challenge results, average gauge percentage across the charts
---@field avgNears integer # Only for challenge results, average number of near hits of the charts
---@field avgPercentage integer # Only for challenge results, average completion percentage across the charts
---@field avgScore integer # Only for challenge results, average score across the charts
---@field badge integer # `0` = Manual Exit, `1` = Played, `2` = Cleared, `3` = Hard Cleared, `4` = Full Chain, `5` = Perfect Chain
---@field bpm number # Chart BPM
---@field charts ChartResult[] # Only for challenge results, array of chart results
---@field chartHash string # Chart hash
---@field difficulty integer # Difficulty index
---@field displayIndex nil|integer # Only for multiplayer results, the index of the score being viewed
---@field duration integer # Chart duration, in milliseconds
---@field earlies integer # Total early hits
---@field effector string # Chart effector
---@field failReason string # Reason for failing the challenge
---@field flags integer # Gameplay option flags e.g. gauge type, mirror/random mode
---@field gauge number # Ending gauge percentage, `0.0` to `1.0`
---@field gauge_option integer # Gauge option e.g. ARS
---@field gauge_type integer # `0` = Normal, `1` = Hard, `2` = Permissive, `3` = Blastive
---@field gaugeSamples number[] # Gauge values sampled (256 total) throughout the play
---@field goods integer # Total near hits
---@field grade string # Result grade
---@field highScores Score[] # All scores
---@field hitWindow HitWindow # Result hit windows
---@field holdHitStats HitStat[]|nil # Hit stats for every hold object, only available for singleplayer if `isSelf = true`
---@field illustrator string # Chart jacket illustrator
---@field irState integer # Internet ranking flag
---@field isSelf boolean # Only for multiplayer, `false` if score is of another player
---@field jacketPath string # Full filepath to the jacket image on the disk
---@field laserHitStats HitStat[]|nil # Hit stats for every laser object, only available for singleplayer if `isSelf = true`
---@field lates integer # Total late hits
---@field level integer # Chart or challenge level
---@field maxCombo integer # Result max chain
---@field meanHitDelta number # Mean hit delta
---@field meanHitDeltaAbs number # Absolute value of mean hit delta
---@field medianHitDelta integer # Median hit delta
---@field medianHitDeltaAbs integer # Absolute value of median hit delta
---@field mirror boolean # Mirror mode bool
---@field misses integer # Total errors
---@field mission string # Only for practice mode
---@field noteHitStats HitStat[]|nil # Hit stats for every chip hit, only available for singleplayer if `isSelf = true`
---@field overallCrits integer # Only for challenge results, total number of critical hits across the charts
---@field overallErrors integer # Only for challenge results, total number of error hits across the charts
---@field overallNears integer # Only for challenge results, total number of near hits across the charts
---@field passed boolean # Only for challenge results, whether or not the challenge was passed
---@field perfects integer # Total critical hits
---@field playbackSpeed number # Only for practice mode, percentage from 0.25 to 1.0
---@field playerName nil|string # Only for multiplayer
---@field random boolean # Random mode bool,
---@field realTitle string # Chart title, always without player name
---@field requirement_text string # Only for challenge results, the challenge requirements separated by newline character `"\n"`
---@field retryCount integer # Only for practice mode
---@field score integer # Result score
---@field speedModType integer # Only for singleplayer, `0` = XMOD, `1` = MMOD, `2` = CMOD
---@field speedModValue number # Only for singleplayer, `HiSpeed` for `XMOD`, `ModSpeed` otherwise
---@field title string # Chart (with player name in multiplayer) or challenge title
---@field uid nil|string # Only for multiplayer, UID of the player
result = {};

181
docs/lua_api/shadedmesh.lua Normal file
View File

@ -0,0 +1,181 @@
-- Adds a texture that was loaded with `gfx.LoadSharedTexture` to the material that can be used in the shader code
---@param uniformName string
---@param textureName string
AddSharedTexture = function(uniformName, textureName) end
-- Adds a texture to the material that can be used in the shader code
---@param uniformName string
---@param path string # prepended with `skins/<skin>/textures/`
AddSkinTexture = function(uniformName, path) end
-- Adds a texture to the material that can be used in the shader code
---@param uniformName string
---@param path string
AddTexture = function(uniformName, path) end
-- Gets the translation of the mesh
---@return number x, number y, number z
GetPosition = function() end
-- Gets the rotation (in degrees) of the mesh
---@return number roll, number yaw, number pitch
GetRotation = function() end
-- Gets the scale of the mesh
---@return number x, number y, number z
GetScale = function() end
-- Sets the blending mode
---@param mode integer # options also available as fields of the object prefixed with `BLEND`
-- `Normal` = 0 (default)
-- `Additive` = 1
-- `Multiply` = 2
SetBlendMode = function(mode) end
-- Sets the geometry data
---@param data table # array of vertices in clockwise order starting from the top left e.g.
-- ```
-- {
-- { { 0, 0 }, { 0, 0 } },
-- { { 50, 0 }, { 1, 0 } },
-- { { 50, 50 }, { 1, 1 } },
-- { { 0, 50 }, { 0, 1 } },
-- }
-- ```
SetData = function(data) end
-- Sets the material is opaque or non-opaque (default)
---@param opaque boolean
SetOpaque = function(opaque) end
-- Sets the value of the specified uniform
---@param uniformName string
---@param value number # `float`
SetParam = function(uniformName, value) end
-- Sets the value of the specified 2d vector uniform
---@param uniformName string
---@param x number # `float`
---@param y number # `float`
SetParamVec2 = function(uniformName, x, y) end
-- Sets the value of the specified 3d vector uniform
---@param uniformName string
---@param x number # `float`
---@param y number # `float`
---@param z number # `float`
SetParamVec3 = function(uniformName, x, y, z) end
-- Sets the value of the specified 4d vector uniform
---@param uniformName string
---@param x number # `float`
---@param y number # `float`
---@param z number # `float`
---@param w number # `float`
SetParamVec4 = function(uniformName, x, y, z, w) end
-- Sets the translation for the mesh
-- Relative to the screen for `ShadedMesh`
-- Relative to the center of the crit line for `ShadedMeshOnTrack`
---@param x number
---@param y number
---@param z? number # Default `0`
SetPosition = function(x, y, z) end
-- Sets the format for geometry data provided by `SetData`
---@param type integer # options also available as fields of the object prefixed with `PRIM`
-- `TriangleList` = 0 (default)
-- `TriangleStrip` = 1
-- `TriangleFan` = 2
-- `LineList` = 3
-- `LineStrip` = 4
-- `PointList` = 5
SetPrimitiveType = function(type) end
-- Sets the rotation (in degrees) of the mesh
-- **WARNING:** For `ShadedMesh`, pitch and yaw may clip, rendering portions or the entire mesh invisible
---@param roll number
---@param yaw? number # Default `0`
---@param pitch? number # Default `0`
SetRotation = function(roll, yaw, pitch) end
-- Sets the scale of the mesh
---@param x number
---@param y number
---@param z? number # Default `0`
SetScale = function(x, y, z) end
-- Sets the wireframe mode of the object (does not render texture)
-- Useful for debugging models or geometry shaders
---@param useWireframe boolean
SetWireframe = function(useWireframe) end
-- Renders the `ShadedMesh` object
Draw = function() end
---@class ShadedMesh
ShadedMesh = {
BLEND_NORM = 0,
BLEND_ADD = 1,
BLEND_MULT = 2,
PRIM_TRILIST = 0,
PRIM_TRIFAN = 1,
PRIM_TRISTRIP = 2,
PRIM_LINELIST = 3,
PRIM_LINESTRIP = 4,
PRIM_POINTLIST = 5,
AddSharedTexture = AddSharedTexture,
AddSkinTexture = AddSkinTexture,
AddTexture = AddTexture,
Draw = Draw,
GetPosition = GetPosition,
GetRotation = GetRotation,
GetScale = GetScale,
SetBlendMode = SetBlendMode,
SetData = SetData,
SetOpaque = SetOpaque,
SetParam = SetParam,
SetParamVec2 = SetParamVec2,
SetParamVec3 = SetParamVec3,
SetParamVec4 = SetParamVec4,
SetPosition = SetPosition,
SetPrimitiveType = SetPrimitiveType,
SetRotation = SetRotation,
SetScale = SetScale,
SetWireframe = SetWireframe,
};
-- Gets the length of the mesh
---@return number length
GetLength = function() end
-- Sets the y-scale of the mesh based on its length
-- Useful for creating fake buttons which may have variable length based on duration
---@param length number
ScaleToLength = function(length) end
-- Stops meshes beyond the track from being rendered if `doClip`
---@param doClip boolean
SetClipWithTrack = function(doClip) end
-- Sets the length (in the y-direction relative to the track) of the mesh
---@param length number # Optional constants: `BUTTON_TEXTURE_LENGTH`, `FXBUTTON_TEXTURE_LENGTH`, and `TRACK_LENGTH`
SetLength = function(length) end
-- Uses an existing game mesh
---@param meshName string # Options: `'button'`, `'fxbutton'`, and `'track'`
UseGameMesh = function(meshName) end
---@class ShadedMeshOnTrack : ShadedMesh
---@field BUTTON_TEXTURE_LENGTH number
---@field FXBUTTON_TEXTURE_LENGTH number
---@field TRACK_LENGTH number
ShadedMeshOnTrack = {
GetLength = GetLength,
UseGameMesh = UseGameMesh,
ScaleToLength = ScaleToLength,
SetClipWithTrack = SetClipWithTrack,
SetLength = SetLength,
};

View File

@ -0,0 +1,29 @@
-- songwheel `songwheel` table
---@class Difficulty
---@field difficulty integer # Difficulty index
---@field hash string # Difficulty hash
---@field id integer # Difficulty id, unique static identifier
---@field illustrator string # Difficulty jacket illustrator
---@field jacketPath string # Full filepath to the jacket image on the disk
---@field level integer # Difficulty level
---@field scores Score[] # Scores for the current difficulty
---@field topBadge integer # `0 = Never Played`, `1 = Played`, `2 = Cleared`, `3 = Hard Cleared`, `4 = Full Chain`, `5 = Perfect Chain`
Difficulty = {};
---@class Song
---@field artist string # Chart artist
---@field difficulties Difficulty[] # Array of difficulties for the current song
---@field bpm number # Chart BPM
---@field id integer # Song id, unique static identifier
---@field path string # Full filepath to the chart folder on the disk
---@field title string # Chart title
Song = {};
---@class songwheel
---@field allSongs Song[] # Array of all available songs
---@field searchInputActive boolean # Search status
---@field searchStatus string # Current song database status
---@field searchText string # Search input text
---@field songs Song[] # Array of songs with the current filters/sorting applied
songwheel = {};

View File

@ -0,0 +1,4 @@
-- sortwheel `sorts` table
---@type string[] # Array of song sorts
sorts = {};

39
docs/lua_api/track.lua Normal file
View File

@ -0,0 +1,39 @@
-- `track` table
-- Only exists in `gameplay.lua` and background/foreground scripts
-- Creates a new `ShadedMeshOnTrack` object
---@param materialName string # Default `'guiTex'`, loaded from the current skin's `shaders` folder
-- `<materialName>.fs` and `<materialName>.vs` must exist at this location
---@return ShadedMeshOnTrack
CreateShadedMeshOnTrack = function(materialName) end
-- Gets the x-value for the left side of the given `lane`
---@param lane integer # `1` = A, `2` = B, `3` = C, `4` = D, `5` = L, `6` = R
---@return number x
GetCurrentLaneXPos = function(lane) end
-- Gets the y-length of a long note from `start` for `duration`, adjusted for the current track speed
---@param start integer # In miliseconds
---@param duration integer # In miliseconds
---@return number y
GetLengthForDuration = function(start, duration) end
-- Gets the y-position for an object at the given `time`, adjusted for the current track speed
---@param time integer # In miliseconds
---@return number y
GetYPosForTime = function(time) end
-- Hides an object in the given `lane` at the given `time`
-- If no object is found, hides the closest object after the given `time`
---@param time integer # In miliseconds
---@param lane integer # `1` = A, `2` = B, `3` = C, `4` = D, `5` = L, `6` = R
HideObject = function(time, lane) end
---@class track
track = {
CreateShadedMeshOnTrack = CreateShadedMeshOnTrack,
GetCurrentLaneXPos = GetCurrentLaneXPos,
GetLengthForDuration = GetLengthForDuration,
GetYPosForTime = GetYPosForTime,
HideObject = HideObject,
};