[lua] Add possibility to draw tiles w/app.useTool{ tilemapMode=TilemapMode.TILES... }

This commit is contained in:
David Capello 2020-07-14 17:27:40 -03:00
parent c86b4a28a6
commit 27e2a287bf
2 changed files with 15 additions and 0 deletions

View File

@ -387,6 +387,13 @@ int App_useTool(lua_State* L)
params.freehandAlgorithm = get_value_from_lua<tools::FreehandAlgorithm>(L, -1);
lua_pop(L, 1);
// Are we going to modify pixels or tiles?
type = lua_getfield(L, 1, "tilemapMode");
if (type != LUA_TNIL) {
site.tilemapMode(TilemapMode(lua_tointeger(L, -1)));
}
lua_pop(L, 1);
// How the tileset must be modified depending on this tool usage
type = lua_getfield(L, 1, "tilesetMode");
if (type != LUA_TNIL) {

View File

@ -18,6 +18,7 @@
#include "app/script/luacpp.h"
#include "app/script/security.h"
#include "app/sprite_sheet_type.h"
#include "app/tilemap_mode.h"
#include "app/tileset_mode.h"
#include "app/tools/ink_type.h"
#include "base/chrono.h"
@ -370,6 +371,13 @@ Engine::Engine()
setfield_integer(L, "X2", (int)ui::kButtonX2);
lua_pop(L, 1);
lua_newtable(L);
lua_pushvalue(L, -1);
lua_setglobal(L, "TilemapMode");
setfield_integer(L, "PIXELS", TilemapMode::Pixels);
setfield_integer(L, "TILES", TilemapMode::Tiles);
lua_pop(L, 1);
lua_newtable(L);
lua_pushvalue(L, -1);
lua_setglobal(L, "TilesetMode");