2018-08-21 02:15:38 +08:00
|
|
|
// 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"
|
2018-08-21 02:15:38 +08:00
|
|
|
#include "app/site.h"
|
|
|
|
|
|
|
|
namespace app {
|
2018-08-20 22:25:08 +08:00
|
|
|
namespace script {
|
2018-08-21 02:15:38 +08:00
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
2018-08-20 22:25:08 +08:00
|
|
|
int Site_get_sprite(lua_State* L)
|
2018-08-21 02:15:38 +08:00
|
|
|
{
|
2018-08-20 22:25:08 +08:00
|
|
|
auto site = get_obj<Site>(L, 1);
|
2018-08-21 02:15:38 +08:00
|
|
|
if (site->sprite())
|
2018-08-20 22:25:08 +08:00
|
|
|
push_ptr(L, site->sprite());
|
2018-08-21 02:15:38 +08:00
|
|
|
else
|
2018-08-20 22:25:08 +08:00
|
|
|
lua_pushnil(L);
|
|
|
|
return 1;
|
2018-08-21 02:15:38 +08:00
|
|
|
}
|
|
|
|
|
2018-08-20 22:25:08 +08:00
|
|
|
int Site_get_image(lua_State* L)
|
2018-08-21 02:15:38 +08:00
|
|
|
{
|
2018-08-20 22:25:08 +08:00
|
|
|
auto site = get_obj<Site>(L, 1);
|
2018-08-31 07:47:11 +08:00
|
|
|
if (site->cel())
|
|
|
|
push_cel_image(L, site->cel());
|
2018-08-21 02:15:38 +08:00
|
|
|
else
|
2018-08-20 22:25:08 +08:00
|
|
|
lua_pushnil(L);
|
|
|
|
return 1;
|
2018-08-21 02:15:38 +08:00
|
|
|
}
|
|
|
|
|
2018-08-20 22:25:08 +08:00
|
|
|
const luaL_Reg Site_methods[] = {
|
|
|
|
{ nullptr, nullptr }
|
2018-08-21 02:15:38 +08:00
|
|
|
};
|
|
|
|
|
2018-08-20 22:25:08 +08:00
|
|
|
const Property Site_properties[] = {
|
2018-08-21 02:15:38 +08:00
|
|
|
{ "sprite", Site_get_sprite, nullptr },
|
|
|
|
{ "image", Site_get_image, nullptr },
|
2018-08-20 22:25:08 +08:00
|
|
|
{ nullptr, nullptr, nullptr }
|
2018-08-21 02:15:38 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // anonymous namespace
|
|
|
|
|
2018-08-20 22:25:08 +08:00
|
|
|
DEF_MTNAME(app::Site);
|
2018-08-21 02:15:38 +08:00
|
|
|
|
2018-08-20 22:25:08 +08:00
|
|
|
void register_site_class(lua_State* L)
|
2018-08-21 02:15:38 +08:00
|
|
|
{
|
2018-08-20 22:25:08 +08:00
|
|
|
REG_CLASS(L, Site);
|
|
|
|
REG_CLASS_PROPERTIES(L, Site);
|
2018-08-21 02:15:38 +08:00
|
|
|
}
|
|
|
|
|
2018-08-20 22:25:08 +08:00
|
|
|
} // namespace script
|
2018-08-21 02:15:38 +08:00
|
|
|
} // namespace app
|