mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-12 03:39:51 +00:00
[lua] Add Cel.frame setter to move a cel quickly
This commit is contained in:
parent
b4e9d7b155
commit
11417c56ac
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2018 Igara Studio S.A.
|
||||
// Copyright (C) 2018-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -12,6 +12,7 @@
|
||||
#include "app/cmd/replace_image.h"
|
||||
#include "app/cmd/set_cel_opacity.h"
|
||||
#include "app/cmd/set_cel_position.h"
|
||||
#include "app/doc_api.h"
|
||||
#include "app/script/docobj.h"
|
||||
#include "app/script/engine.h"
|
||||
#include "app/script/luacpp.h"
|
||||
@ -93,6 +94,23 @@ int Cel_get_opacity(lua_State* L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Cel_set_frame(lua_State* L)
|
||||
{
|
||||
const auto cel = get_docobj<Cel>(L, 1);
|
||||
doc::frame_t frame = get_frame_number_from_arg(L, 2);
|
||||
|
||||
if (cel->frame() == frame)
|
||||
return 0;
|
||||
|
||||
Tx tx;
|
||||
Doc* doc = static_cast<Doc*>(cel->document());
|
||||
DocApi api = doc->getApi(tx);
|
||||
api.moveCel(cel->layer(), cel->frame(),
|
||||
cel->layer(), frame);
|
||||
tx.commit();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Cel_set_image(lua_State* L)
|
||||
{
|
||||
auto cel = get_docobj<Cel>(L, 1);
|
||||
@ -134,8 +152,8 @@ const luaL_Reg Cel_methods[] = {
|
||||
const Property Cel_properties[] = {
|
||||
{ "sprite", Cel_get_sprite, nullptr },
|
||||
{ "layer", Cel_get_layer, nullptr },
|
||||
{ "frame", Cel_get_frame, nullptr },
|
||||
{ "frameNumber", Cel_get_frameNumber, nullptr },
|
||||
{ "frame", Cel_get_frame, Cel_set_frame },
|
||||
{ "frameNumber", Cel_get_frameNumber, Cel_set_frame },
|
||||
{ "image", Cel_get_image, Cel_set_image },
|
||||
{ "bounds", Cel_get_bounds, nullptr },
|
||||
{ "position", Cel_get_position, Cel_set_position },
|
||||
|
Loading…
x
Reference in New Issue
Block a user