Commit Graph

81 Commits

Author SHA1 Message Date
David Capello 7172de5007 [lua] Use internal variables to store ptrs to original unsecure functions
Instead of using Lua upvalues/closures.
2024-04-21 13:25:56 -03:00
David Capello 53bb6aceec [lua] Disable loadfile() without args in GUI mode
Waiting for stdin input will hang the program.
2024-04-21 13:14:09 -03:00
David Capello d886e20f6c [lua] Secure io.popen() access (and enable popen on Linux) 2024-04-10 12:01:29 -03:00
Martín Capello 26523156da Improve script engine's exception handling
More details about the implications of this change can be found
in https://github.com/aseprite/aseprite/pull/4057
2023-10-26 11:24:51 -03:00
Martín Capello d21f47f827 [lua] Add selected tab retrieval/selection through Dialog's data and possibility to set the tabs selector at the bottom 2023-09-12 17:21:00 -03:00
Martín Capello 115e20d2a5 Add tab widget to lua api 2023-08-14 18:08:33 -03:00
David Capello 32009723c5 [lua] Ask for access for package.loadlib() function 2023-07-19 09:15:15 -03:00
David Capello a2d8a080f5 [lua] Create app.window to access new main window properties (#3927)
We moved the app.width/heigth to app.window.width/height and
app.events.on('resize', ...) to app.window.events.on('resize', ...).
2023-07-18 17:54:57 -03:00
David Capello 86a50e2e9a [lua] Add native API to decode/encode JSON text (fix #3233)
New json.decode(jsonText) and json.encode(luaTable) functions.

In this way we don't depend on third-party libraries to decode/encode
JSON text which is a quite common task (in tests and export scripts).
2023-07-17 09:25:13 -03:00
David Capello a98ad46a55 Use the existent doc::algorithm::FlipType instead of a new app::script::FlipType 2023-05-18 13:14:50 -03:00
Gaspar Capello f3ed22e1a6 [lua] Add Image:flip() 2023-05-18 13:02:07 -03:00
David Capello d7af7f4312 [lua] Add new app.editor object (fix aseprite/Attachment-System#104) 2023-04-19 19:10:28 -03:00
David Capello 1c6e583c87 [lua] Add require() function (fix aseprite/api#10)
This is the first attempt to finally implement the require() function
on Lua. The main problem was how to solve conflicts between plugins
that use the same library name. Here we separate each plugin like in a
namespace, so require(name) inside a plugin will save the module in
_LOADED["pluginName/libraryName"] to avoid conflicts with other
libraryName from other plugins.
2023-04-18 19:41:01 -03:00
David Capello 636cce6f0d [lua] Add Uuid type (fix #3809) 2023-04-12 13:51:37 -03:00
David Capello 17c66181ae [lua] Replace Paint() class with GraphicsContext.blendMode/opacity properties
In some way we prefer to simplify the GraphicsContext class instead of
exposing a new Paint() class (which might be confusing with the
app.useTool() too).

Now BlendMode can be used for GraphicsContext.blendMode and
Layer.blendMode (not all modes are available in both cases).

This reverts commit 3d7c05c8f1.
2023-03-13 21:19:23 -03:00
David Capello 3d7c05c8f1 [lua] Add Paint class and argument to GraphicsContext::drawImage(img, srcRc, dstRc, paint) function 2023-03-13 18:18:44 -03:00
David Capello c2f8335891 [lua] Add Timer() type (fix #3251) 2023-02-22 20:00:07 -03:00
David Capello 81b2507bb6 [lua] Add Tileset:tile(tileIndex) API to get tile image/data/properties (fix #3653)
This should replace the old Tileset:getTile(tileIndex) which returns
only the image.
2023-01-06 19:50:04 -03:00
David Capello 76a398b162 [lua] Add access to user data properties in Sprite object (aseprite/api#88)
This is a basic implementation where we can only access basic
properties (not maps or vectors yet).
2023-01-02 12:54:37 -03:00
David Capello d683aaf437 [lua] Rename MouseCursor.HIDDEN -> MouseCursor.NONE 2022-12-26 18:31:37 -03:00
David Capello a6a7519178 [lua] Add possibility to modify the mouseCursor of a canvas 2022-12-26 15:33:14 -03:00
David Capello 3d9021d717 [lua] Add app.theme.dimension/color.id to access theme values 2022-12-16 10:55:11 -03:00
David Capello 2cb526a19b [lua] Add new GraphicsContext type for Canvas onpaint event
We include a simple initial API for the GraphicsContext (like
stroking/filling rectangles and images).
2022-12-14 18:59:44 -03:00
David Capello 4f96d37b1f Add repeat field to animation tags (#1275, #1740) 2022-10-19 12:25:06 -03:00
David Capello ab2cef1c29 Merge branch 'main' into beta 2022-04-06 00:00:44 -03:00
David Capello 2594892dd5 Fix crash when a Lua error happens in a Dialog onclose (fix #3237) 2022-04-05 23:57:36 -03:00
David Capello d077900fe5 Merge branch 'main' into beta 2021-10-13 10:15:39 -03:00
David Capello 212e9fbe6c New initial Lua debugger version (#1967)
Incomplete version of the Lua debugger.
Some available features:

* Break in next executed instruction
* Step in, over, out
* See & navigate stacktrace
* See local variables

Some missing features:

* Breakpoints
* Eval user expressions with local variables

The UX needs some improvement yet.
2021-10-12 16:52:14 -03:00
David Capello db44eeb269 Merge branch 'main' into beta 2021-10-12 10:45:33 -03:00
David Capello cd342f5630 [lua] Add events handling with Sprite.events & App.events
Added a new Events object with :on() and :off() methods to start or
stop listening to a specific event respectively. This also allows to
add several callbacks for the same event.

Replaced the temporal Site.onChange & Sprite.onChange implementations.

Related to several issues (enable more possibilities for): #138, #1403, #1949, #2965, #2980
2021-10-07 18:56:39 -03:00
lampysprites 4354be1d7a Add CMake option to disable websockets 2021-10-03 12:40:29 +07:00
lampysprites b0f10ee276 Add Websocket client API 2021-10-02 13:57:51 +07:00
David Capello ecbd845aae Merge branch 'main' into beta 2021-04-22 14:02:36 -03:00
David Capello d7a1c71df0 lua: Add support for selection tools in app.useTool()
Fix https://github.com/aseprite/api/issues/37
2021-04-22 13:51:56 -03:00
David Capello d8f6c666de Merge branch 'beta' into tilemap-editor 2020-07-30 16:49:17 -03:00
David Capello 7656627605 [lua] Fix calling onclose Dialog event when we close the app (fix https://github.com/aseprite/api/issues/28) 2020-07-28 10:35:38 -03:00
David Capello 27e2a287bf [lua] Add possibility to draw tiles w/app.useTool{ tilemapMode=TilemapMode.TILES... } 2020-07-14 17:27:40 -03:00
David Capello a10efb187b Merge branch 'master' into tilemap-editor 2020-06-01 16:21:32 -03:00
David Capello f56931a612 Add missing #include in engine.cpp 2020-05-22 11:15:15 -03:00
David Capello 1ec502d242 Add "ink" parameter to app.useTool() + minor needed refactors 2020-05-20 17:15:30 -03:00
David Capello a80af2b304 Merge branch 'master' into tilemap-editor 2020-05-18 20:24:22 -03:00
David Capello 6b6b9057bf Add support for scripts on extensions (#1949)
It still need some work to associate the command to menus easily.

Related issues:
  https://github.com/aseprite/aseprite/issues/1403
  https://github.com/aseprite/aseprite/issues/1949
  https://github.com/aseprite/api/issues/20
  https://community.aseprite.org/t/lua-script-extension-and-menu-api/5085
2020-04-02 20:21:21 -03:00
David Capello 32fd67e187 [lua] Add ev.button property onclick of shades widget 2020-03-27 16:14:00 -03:00
David Capello f2abf09bbf Change TilesetMode names: Manual/Auto/Stack 2020-02-17 09:06:02 -03:00
David Capello 92b794d457 Add the final TilesetModes UI: Manual/Semi/Auto 2020-02-17 09:06:01 -03:00
David Capello 26139c4ae2 Add tilemap layers (#977)
This is the first commit with a simple tilemap editor. Still buggy but
functional in several ways. Several changes were made:

* NewLayer command can receive a tilemap=true to create a new tilemap
  layer
* New ToggleTilesMode command added to switch between the palette and
  the tileset in the ColorBar (the ColorBar was expanded to show
  colors or tilesets with a generic AbstractPaletteViewAdapter)
* All commands to create new layers were moved to Layer >
  New... submenu
* There are a new tileset chunk to save tilesets in .aseprite files,
  and a new kind of cels to save tilemaps
* Added doc::LayerTilemap, doc::Tileset, etc. and several other types
  to handle tilesets/tilemaps in the doc layer.
* Added doc::Grid class with grid specifications that indicates how a
  tilemap <-> tileset must be drawn
* Added and expanded cel operations to work with tilemaps and
  conversions between regular LayerImage cels <-> LayerTilemap cels
  (e.g. copy cels in the timeline between layer types)
2020-02-17 09:06:00 -03:00
David Capello 45fc74f596 lua: Fix crash on program exit if some metatable.__gc calls print() 2019-12-11 23:46:33 -03:00
David Capello ff2af4f3e8 lua: Add app.fs object with some functions/properties for file names 2019-12-11 15:39:40 -03:00
David Capello d6c6b00b32 Now using -script from CLI can return an error code (exit code != 0) 2019-11-01 15:04:22 -03:00
David Capello aa66ff35a2 Refactor DocExporter::DataFormat -> SpriteSheetDataFormat 2019-10-07 17:22:27 -03:00