mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-08 12:40:50 +00:00
lua: Add support to receive Frame/frame number in all functions
This commit is contained in:
parent
0a558aabcf
commit
ed1a6233eb
@ -166,7 +166,7 @@ int Image_drawSprite(lua_State* L)
|
|||||||
{
|
{
|
||||||
auto obj = get_obj<ImageObj>(L, 1);
|
auto obj = get_obj<ImageObj>(L, 1);
|
||||||
const auto sprite = get_docobj<Sprite>(L, 2);
|
const auto sprite = get_docobj<Sprite>(L, 2);
|
||||||
doc::frame_t frame = lua_tointeger(L, 3)-1;
|
doc::frame_t frame = get_frame_number_from_arg(L, 3);
|
||||||
gfx::Point pos = convert_args_into_point(L, 4);
|
gfx::Point pos = convert_args_into_point(L, 4);
|
||||||
doc::Image* dst = obj->image(L);
|
doc::Image* dst = obj->image(L);
|
||||||
|
|
||||||
|
@ -266,7 +266,7 @@ int Sprite_newFrame(lua_State* L)
|
|||||||
auto sprite = get_docobj<Sprite>(L, 1);
|
auto sprite = get_docobj<Sprite>(L, 1);
|
||||||
doc::frame_t frame = sprite->lastFrame()+1;
|
doc::frame_t frame = sprite->lastFrame()+1;
|
||||||
if (lua_gettop(L) >= 2) {
|
if (lua_gettop(L) >= 2) {
|
||||||
frame = lua_tointeger(L, 2)-1;
|
frame = get_frame_number_from_arg(L, 2);
|
||||||
if (frame < 0)
|
if (frame < 0)
|
||||||
return luaL_error(L, "frame index out of bounds %d", frame+1);
|
return luaL_error(L, "frame index out of bounds %d", frame+1);
|
||||||
}
|
}
|
||||||
@ -285,8 +285,8 @@ int Sprite_newEmptyFrame(lua_State* L)
|
|||||||
{
|
{
|
||||||
auto sprite = get_docobj<Sprite>(L, 1);
|
auto sprite = get_docobj<Sprite>(L, 1);
|
||||||
doc::frame_t frame = sprite->lastFrame()+1;
|
doc::frame_t frame = sprite->lastFrame()+1;
|
||||||
if (lua_gettop(L) >= 1) {
|
if (lua_gettop(L) >= 2) {
|
||||||
frame = lua_tointeger(L, 2)-1;
|
frame = get_frame_number_from_arg(L, 2);
|
||||||
if (frame < 0)
|
if (frame < 0)
|
||||||
return luaL_error(L, "frame index out of bounds %d", frame+1);
|
return luaL_error(L, "frame index out of bounds %d", frame+1);
|
||||||
}
|
}
|
||||||
@ -304,7 +304,7 @@ int Sprite_newEmptyFrame(lua_State* L)
|
|||||||
int Sprite_deleteFrame(lua_State* L)
|
int Sprite_deleteFrame(lua_State* L)
|
||||||
{
|
{
|
||||||
auto sprite = get_docobj<Sprite>(L, 1);
|
auto sprite = get_docobj<Sprite>(L, 1);
|
||||||
doc::frame_t frame = lua_tointeger(L, 2)-1;
|
doc::frame_t frame = get_frame_number_from_arg(L, 2);
|
||||||
if (frame < 0 || frame > sprite->lastFrame())
|
if (frame < 0 || frame > sprite->lastFrame())
|
||||||
return luaL_error(L, "frame index out of bounds %d", frame+1);
|
return luaL_error(L, "frame index out of bounds %d", frame+1);
|
||||||
|
|
||||||
@ -323,7 +323,7 @@ int Sprite_newCel(lua_State* L)
|
|||||||
if (!layerBase->isImage())
|
if (!layerBase->isImage())
|
||||||
return luaL_error(L, "unexpected kinf of layer in Sprite:newCel()");
|
return luaL_error(L, "unexpected kinf of layer in Sprite:newCel()");
|
||||||
|
|
||||||
frame_t frame = lua_tointeger(L, 3)-1;
|
frame_t frame = get_frame_number_from_arg(L, 3);
|
||||||
if (frame < 0 || frame > sprite->lastFrame())
|
if (frame < 0 || frame > sprite->lastFrame())
|
||||||
return luaL_error(L, "frame index out of bounds %d", frame+1);
|
return luaL_error(L, "frame index out of bounds %d", frame+1);
|
||||||
|
|
||||||
@ -364,7 +364,7 @@ int Sprite_deleteCel(lua_State* L)
|
|||||||
auto cel = may_get_docobj<doc::Cel>(L, 2);
|
auto cel = may_get_docobj<doc::Cel>(L, 2);
|
||||||
if (!cel) {
|
if (!cel) {
|
||||||
if (auto layer = may_get_docobj<doc::Layer>(L, 2)) {
|
if (auto layer = may_get_docobj<doc::Layer>(L, 2)) {
|
||||||
doc::frame_t frame = lua_tointeger(L, 3);
|
doc::frame_t frame = get_frame_number_from_arg(L, 3);
|
||||||
if (layer->isImage())
|
if (layer->isImage())
|
||||||
cel = static_cast<doc::LayerImage*>(layer)->cel(frame);
|
cel = static_cast<doc::LayerImage*>(layer)->cel(frame);
|
||||||
}
|
}
|
||||||
@ -384,8 +384,8 @@ int Sprite_deleteCel(lua_State* L)
|
|||||||
int Sprite_newTag(lua_State* L)
|
int Sprite_newTag(lua_State* L)
|
||||||
{
|
{
|
||||||
auto sprite = get_docobj<Sprite>(L, 1);
|
auto sprite = get_docobj<Sprite>(L, 1);
|
||||||
auto from = lua_tointeger(L, 2)-1;
|
auto from = get_frame_number_from_arg(L, 2);
|
||||||
auto to = lua_tointeger(L, 3)-1;
|
auto to = get_frame_number_from_arg(L, 3);
|
||||||
auto tag = new doc::FrameTag(from, to);
|
auto tag = new doc::FrameTag(from, to);
|
||||||
sprite->frameTags().add(tag);
|
sprite->frameTags().add(tag);
|
||||||
push_docobj(L, tag);
|
push_docobj(L, tag);
|
||||||
|
Loading…
Reference in New Issue
Block a user