Skip to content

Commit 266004d

Browse files
committed
Update LuaCATS definition files
Based on in-progress #3755 and #4689
1 parent 12e2474 commit 266004d

19 files changed

Lines changed: 450 additions & 161 deletions
Lines changed: 292 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,292 @@
1+
-- Lua functions available in EmuHawk 2.11
2+
-- https://tasvideos.org/Bizhawk
3+
4+
error("This is a definition file for Lua Language Server and not a usable script")
5+
6+
---@meta _
7+
8+
---Represents a canvas object, as returned by the `gui.createcanvas()` method.
9+
---Note that the member functions do not have a `self` parameter, and so must be called with the regular invocation syntax, not the OOP syntax.
10+
---@class LuaCanvas
11+
local LuaCanvas = {}
12+
13+
---Clears the canvas
14+
---
15+
---Example:
16+
---
17+
--- LuaCanvas.Clear( 0x000000FF );
18+
---@param color? color
19+
function LuaCanvas.Clear(color) end
20+
21+
---clears the image cache that is built up by using gui.drawImage, also releases the file handle for cached images
22+
---
23+
---Example:
24+
---
25+
--- LuaCanvas.ClearImageCache( );
26+
function LuaCanvas.ClearImageCache() end
27+
28+
---draws a Arc shape at the given coordinates and the given width and height
29+
---
30+
---Example:
31+
---
32+
--- LuaCanvas.DrawArc( 16, 32, 77, 99, 180, 90, 0x007F00FF );
33+
---@param x integer
34+
---@param y integer
35+
---@param width integer
36+
---@param height integer
37+
---@param startAngle integer
38+
---@param sweepAngle integer
39+
---@param line? color
40+
function LuaCanvas.DrawArc(x, y, width, height, startAngle, sweepAngle, line) end
41+
42+
---Draws an axis of the specified size at the coordinate pair.)
43+
---
44+
---Example:
45+
---
46+
--- LuaCanvas.DrawAxis( 16, 32, int size, 0xFFFFFFFF );
47+
---@param x integer
48+
---@param y integer
49+
---@param size integer
50+
---@param color? color
51+
function LuaCanvas.DrawAxis(x, y, size, color) end
52+
53+
---Draws a Bezier curve using the table of coordinates provided in the given color
54+
---
55+
---Example:
56+
---
57+
--- LuaCanvas.DrawBezier( { { 5, 10 }, { 10, 10 }, { 10, 20 }, { 5, 20 } }, 0x000000FF );
58+
---@param points? drawingpoint[]
59+
---@param color? color
60+
function LuaCanvas.DrawBezier(points, color) end
61+
62+
---Draws a rectangle on screen from x1/y1 to x2/y2. Same as drawRectangle except it receives two points intead of a point and width/height
63+
---
64+
---Example:
65+
---
66+
--- LuaCanvas.DrawBox( 16, 32, 162, 322, 0x007F00FF, 0x7F7F7FFF );
67+
---@param x integer
68+
---@param y integer
69+
---@param x2 integer
70+
---@param y2 integer
71+
---@param line? color
72+
---@param background? color
73+
function LuaCanvas.DrawBox(x, y, x2, y2, line, background) end
74+
75+
---Draws an ellipse at the given coordinates and the given width and height. Line is the color of the ellipse. Background is the optional fill color
76+
---
77+
---Example:
78+
---
79+
--- LuaCanvas.DrawEllipse( 16, 32, 77, 99, 0x007F00FF, 0x7F7F7FFF );
80+
---@param x integer
81+
---@param y integer
82+
---@param width integer
83+
---@param height integer
84+
---@param line? color
85+
---@param background? color
86+
function LuaCanvas.DrawEllipse(x, y, width, height, line, background) end
87+
88+
---Draws the image in the given .ico file to the referenced canvas. The image will be positioned such that its top-left corner will be at (x, y) on the canvas. If width and height are both nil/unset, the image will be drawn at full size (100%). If both are specified, the image will be stretched to that size.
89+
---
90+
---Example:
91+
---
92+
--- canvas.DrawIcon("C:\\icon.ico", 16, 32, 18, 24);
93+
---@param path? string
94+
---@param x integer
95+
---@param y integer
96+
---@param width? integer
97+
---@param height? integer
98+
function LuaCanvas.DrawIcon(path, x, y, width, height) end
99+
100+
---Draws the image in the given file (.bmp, .gif, .jpg, .png, or .tif) to the referenced canvas. The image will be positioned such that its top-left corner will be at (x, y) on the canvas. If width and height are both nil/unset, the image will be drawn at full size (100%). If both are specified, the image will be stretched to that size. If true is passed for the cache parameter, or if it's omitted, the file contents will be cached and re-used next time this function is called with the same path on this canvas. The canvas' cache can be cleared with ClearImageCache.
101+
---
102+
---Example:
103+
---
104+
--- canvas.DrawImage("C:\\image.png", 16, 32, 18, 24, false);
105+
---@param path? string
106+
---@param x integer
107+
---@param y integer
108+
---@param width? integer
109+
---@param height? integer
110+
---@param cache? boolean Defaults to `true`
111+
function LuaCanvas.DrawImage(path, x, y, width, height, cache) end
112+
113+
---Draws part of the image in the given file (.bmp, .gif, .jpg, .png, or .tif) to the referenced canvas. Consult this diagram to see its usage (renders embedded on the TASVideos Wiki): ![Diagram showing how to use forms.drawImageRegion](https://user-images.githubusercontent.com/13409956/198868522-55dc1e5f-ae67-4ebb-a75f-558656cb4468.png) The file contents will be cached and re-used next time this function is called with the same path on this canvas. The canvas' cache can be cleared with ClearImageCache.
114+
---
115+
---Example:
116+
---
117+
--- canvas.DrawImageRegion("C:\\image.png", 11, 22, 33, 44, 21, 43, 34, 45);
118+
---@param path? string
119+
---@param sourceX integer
120+
---@param sourceY integer
121+
---@param sourceWidth integer
122+
---@param sourceHeight integer
123+
---@param destX integer
124+
---@param destY integer
125+
---@param destWidth? integer
126+
---@param destHeight? integer
127+
function LuaCanvas.DrawImageRegion(path, sourceX, sourceY, sourceWidth, sourceHeight, destX, destY, destWidth, destHeight) end
128+
129+
---Draws a line from the first coordinate pair to the 2nd. Color is optional (if not specified it will be drawn black)
130+
---
131+
---Example:
132+
---
133+
--- LuaCanvas.DrawLine( 161, 321, 162, 322, 0xFFFFFFFF );
134+
---@param x1 integer
135+
---@param y1 integer
136+
---@param x2 integer
137+
---@param y2 integer
138+
---@param color? color
139+
function LuaCanvas.DrawLine(x1, y1, x2, y2, color) end
140+
141+
---draws a Pie shape at the given coordinates and the given width and height
142+
---
143+
---Example:
144+
---
145+
--- LuaCanvas.DrawPie( 16, 32, 77, 99, 180, 90, 0x007F00FF, 0x7F7F7FFF );
146+
---@param x integer
147+
---@param y integer
148+
---@param width integer
149+
---@param height integer
150+
---@param startAngle integer
151+
---@param sweepAngle integer
152+
---@param line? color
153+
---@param background? color
154+
function LuaCanvas.DrawPie(x, y, width, height, startAngle, sweepAngle, line, background) end
155+
156+
---Draws a single pixel at the given coordinates in the given color. Color is optional (if not specified it will be drawn black)
157+
---
158+
---Example:
159+
---
160+
--- LuaCanvas.DrawPixel( 16, 32, 0xFFFFFFFF );
161+
---@param x integer
162+
---@param y integer
163+
---@param color? color
164+
function LuaCanvas.DrawPixel(x, y, color) end
165+
166+
---Draws a polygon (cyclic polyline) to the referenced canvas. The polygon must be given as a list of length-2 lists (co-ordinate pairs). Each pair is interpreted as the absolute co-ordinates of one of the vertices, and these are joined together in sequence to form a polygon. The last is connected to the first; you DON'T need to end with a copy of the first to close the cycle. If the x and y parameters are both specified, the whole polygon will be offset by that amount. If a value is passed for the line parameter, the polygon's edges are drawn in that color (i.e. the stroke color). If a value is passed for the background parameter, the polygon's face is filled in that color.
167+
---
168+
---Example:
169+
---
170+
--- canvas.DrawPolygon({ { 5, 10 }, { 10, 10 }, { 10, 20 }, { 5, 20 } }, 10, 30, 0x007F00FF, 0x7F7F7FFF);
171+
---@param points? drawingpoint[]
172+
---@param x? integer
173+
---@param y? integer
174+
---@param line? color
175+
---@param background? color
176+
function LuaCanvas.DrawPolygon(points, x, y, line, background) end
177+
178+
---Draws a rectangle at the given coordinate and the given width and height. Line is the color of the box. Background is the optional fill color
179+
---
180+
---Example:
181+
---
182+
--- LuaCanvas.DrawRectangle( 16, 32, 77, 99, 0x007F00FF, 0x7F7F7FFF );
183+
---@param x integer
184+
---@param y integer
185+
---@param width integer
186+
---@param height integer
187+
---@param line? color
188+
---@param background? color
189+
function LuaCanvas.DrawRectangle(x, y, width, height, line, background) end
190+
191+
---Alias of DrawText()
192+
---
193+
---Example:
194+
---
195+
--- LuaCanvas.DrawString( 16, 32, "Some message", 0x7F0000FF, 0x00007FFF, 8, "Arial Narrow", "bold", "center", "middle" );
196+
---@param x integer
197+
---@param y integer
198+
---@param message? string|number
199+
---@param foreColor? color
200+
---@param backColor? color
201+
---@param fontSize? integer
202+
---@param fontFamily? string
203+
---@param fontStyle? string
204+
---@param horizontalAlign? string
205+
---@param verticalAlign? string
206+
function LuaCanvas.DrawString(x, y, message, foreColor, backColor, fontSize, fontFamily, fontStyle, horizontalAlign, verticalAlign) end
207+
208+
---Draws the given message at the given x,y coordinates and the given color. The default color is white. A fontfamily can be specified and is monospace generic if none is specified (font family options are the same as the .NET FontFamily class). The fontsize default is 12. The default font style is regular. Font style options are regular, bold, italic, strikethrough, underline. Horizontal alignment options are left (default), center, or right. Vertical alignment options are bottom (default), middle, or top. Alignment options specify which ends of the text will be drawn at the x and y coordinates.
209+
---
210+
---Example:
211+
---
212+
--- LuaCanvas.DrawText( 16, 32, "Some message", 0x7F0000FF, 0x00007FFF, 8, "Arial Narrow", "bold", "center", "middle" );
213+
---@param x integer
214+
---@param y integer
215+
---@param message? string|number
216+
---@param foreColor? color
217+
---@param backColor? color
218+
---@param fontSize? integer
219+
---@param fontFamily? string
220+
---@param fontStyle? string
221+
---@param horizontalAlign? string
222+
---@param verticalAlign? string
223+
function LuaCanvas.DrawText(x, y, message, foreColor, backColor, fontSize, fontFamily, fontStyle, horizontalAlign, verticalAlign) end
224+
225+
---Returns an integer representation of the mouse X coordinate relative to the canvas window.
226+
---
227+
---Example:
228+
---
229+
--- local inLuaget = LuaCanvas.GetMouseX( );
230+
---@return integer
231+
function LuaCanvas.GetMouseX() end
232+
233+
---Returns an integer representation of the mouse Y coordinate relative to the canvas window.
234+
---
235+
---Example:
236+
---
237+
--- local inLuaget = LuaCanvas.GetMouseY( );
238+
---@return integer
239+
function LuaCanvas.GetMouseY() end
240+
241+
---Redraws the canvas
242+
---
243+
---Example:
244+
---
245+
--- LuaCanvas.Refresh( );
246+
function LuaCanvas.Refresh() end
247+
248+
---Saves everything that's been drawn to a .png file at the given path. Relative paths are relative to the path set for "Screenshots" for the current system.
249+
---@param path? string
250+
function LuaCanvas.save_image_to_disk(path) end
251+
252+
---Sets the default background color to use in drawing methods, transparent by default
253+
---
254+
---Example:
255+
---
256+
--- LuaCanvas.SetDefaultBackgroundColor( 0x000000FF );
257+
---@param color? color
258+
function LuaCanvas.SetDefaultBackgroundColor(color) end
259+
260+
---Sets the default foreground color to use in drawing methods, white by default
261+
---
262+
---Example:
263+
---
264+
--- LuaCanvas.SetDefaultForegroundColor( 0x000000FF );
265+
---@param color? color
266+
function LuaCanvas.SetDefaultForegroundColor(color) end
267+
268+
---Sets the default background color to use in text drawing methods, half-transparent black by default
269+
---
270+
---Example:
271+
---
272+
--- LuaCanvas.SetDefaultTextBackground( 0x000000FF );
273+
---@param color? color
274+
function LuaCanvas.SetDefaultTextBackground(color) end
275+
276+
---Sets the location of the canvas window
277+
---
278+
---Example:
279+
---
280+
--- LuaCanvas.SetLocation( 16, 32 );
281+
---@param x integer
282+
---@param y integer
283+
function LuaCanvas.SetLocation(x, y) end
284+
285+
---Sets the canvas window title
286+
---
287+
---Example:
288+
---
289+
--- LuaCanvas.SetTitle( "Title" );
290+
---@param title? string
291+
function LuaCanvas.SetTitle(title) end
292+

Assets/Lua/_docs_luacats/SQL.d.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function SQL.opendatabase(name) end
3333
---
3434
--- local obSQLrea = SQL.readcommand( "SELECT * FROM eg_tab WHERE eg_tab_id = 1;" );
3535
---@param query? string
36-
---@return any
36+
---@return string|table<string, any>
3737
function SQL.readcommand(query) end
3838

3939
---Runs a SQLite write command which includes CREATE,INSERT, UPDATE. Ex: create TABLE rewards (ID integer PRIMARY KEY, action VARCHAR(20))

0 commit comments

Comments
 (0)