aseprite/src/app/script/site_class.cpp

62 lines
1.0 KiB
C++
Raw Normal View History

// Aseprite
// Copyright (C) 2018 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
2018-08-20 22:25:08 +08:00
#include "app/script/engine.h"
#include "app/script/luacpp.h"
#include "app/site.h"
namespace app {
2018-08-20 22:25:08 +08:00
namespace script {
namespace {
2018-08-20 22:25:08 +08:00
int Site_get_sprite(lua_State* L)
{
2018-08-20 22:25:08 +08:00
auto site = get_obj<Site>(L, 1);
if (site->sprite())
2018-08-20 22:25:08 +08:00
push_ptr(L, site->sprite());
else
2018-08-20 22:25:08 +08:00
lua_pushnil(L);
return 1;
}
2018-08-20 22:25:08 +08:00
int Site_get_image(lua_State* L)
{
2018-08-20 22:25:08 +08:00
auto site = get_obj<Site>(L, 1);
if (site->cel())
push_cel_image(L, site->cel());
else
2018-08-20 22:25:08 +08:00
lua_pushnil(L);
return 1;
}
2018-08-20 22:25:08 +08:00
const luaL_Reg Site_methods[] = {
{ nullptr, nullptr }
};
2018-08-20 22:25:08 +08:00
const Property Site_properties[] = {
{ "sprite", Site_get_sprite, nullptr },
{ "image", Site_get_image, nullptr },
2018-08-20 22:25:08 +08:00
{ nullptr, nullptr, nullptr }
};
} // anonymous namespace
2018-08-20 22:25:08 +08:00
DEF_MTNAME(app::Site);
2018-08-20 22:25:08 +08:00
void register_site_class(lua_State* L)
{
2018-08-20 22:25:08 +08:00
REG_CLASS(L, Site);
REG_CLASS_PROPERTIES(L, Site);
}
2018-08-20 22:25:08 +08:00
} // namespace script
} // namespace app