lua: Add possibility to change Sprite.filename property

This commit is contained in:
David Capello 2019-01-10 16:19:11 -03:00
parent d11296af31
commit f1f888a819

View File

@ -611,6 +611,14 @@ int Sprite_set_transparentColor(lua_State* L)
return 0; return 0;
} }
int Sprite_set_filename(lua_State* L)
{
auto sprite = get_docobj<Sprite>(L, 1);
const char* fn = lua_tostring(L, 2);
sprite->document()->setFilename(fn ? std::string(fn): std::string());
return 0;
}
int Sprite_set_width(lua_State* L) int Sprite_set_width(lua_State* L)
{ {
auto sprite = get_docobj<Sprite>(L, 1); auto sprite = get_docobj<Sprite>(L, 1);
@ -670,7 +678,7 @@ const luaL_Reg Sprite_methods[] = {
}; };
const Property Sprite_properties[] = { const Property Sprite_properties[] = {
{ "filename", Sprite_get_filename, nullptr }, { "filename", Sprite_get_filename, Sprite_set_filename },
{ "width", Sprite_get_width, Sprite_set_width }, { "width", Sprite_get_width, Sprite_set_width },
{ "height", Sprite_get_height, Sprite_set_height }, { "height", Sprite_get_height, Sprite_set_height },
{ "colorMode", Sprite_get_colorMode, nullptr }, { "colorMode", Sprite_get_colorMode, nullptr },