mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-01 18:00:26 +00:00
Merge pull request #3682 from aseprite/tile-set-image
[lua] Add Tile_set_image method
This commit is contained in:
commit
45ce79e594
@ -8,6 +8,7 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "app/cmd/replace_image.h"
|
||||
#include "app/cmd/set_tile_data.h"
|
||||
#include "app/cmd/set_tile_data_properties.h"
|
||||
#include "app/script/docobj.h"
|
||||
@ -55,6 +56,23 @@ int Tile_get_image(lua_State* L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Tile_set_image(lua_State* L)
|
||||
{
|
||||
auto tile = get_obj<Tile>(L, 1);
|
||||
auto ts = doc::get<Tileset>(tile->id);
|
||||
auto srcImage = get_image_from_arg(L, 2);
|
||||
ImageRef newImage(Image::createCopy(srcImage));
|
||||
|
||||
if (ts && ts->sprite()) {
|
||||
Tx tx;
|
||||
tx(new cmd::ReplaceImage(ts->sprite(),
|
||||
ts->get(tile->ti),
|
||||
newImage));
|
||||
tx.commit();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Tile_get_data(lua_State* L)
|
||||
{
|
||||
auto tile = get_obj<Tile>(L, 1);
|
||||
@ -173,7 +191,7 @@ const luaL_Reg Tile_methods[] = {
|
||||
|
||||
const Property Tile_properties[] = {
|
||||
{ "index", Tile_get_index, nullptr },
|
||||
{ "image", Tile_get_image, nullptr }, // TODO Tile_set_image
|
||||
{ "image", Tile_get_image, Tile_set_image },
|
||||
{ "data", Tile_get_data, Tile_set_data },
|
||||
{ "color", Tile_get_color, Tile_set_color },
|
||||
{ "properties", Tile_get_properties, Tile_set_properties },
|
||||
|
Loading…
Reference in New Issue
Block a user