From ae1aa49089ccf8fb8d564d247371de70e333eb36 Mon Sep 17 00:00:00 2001 From: lethosor Date: Fri, 2 Jun 2017 12:42:51 -0400 Subject: [PATCH] Add map parameter to Lua paintTile() and use in Painter Also updated gui/siege-engine.lua --- docs/Lua API.rst | 2 +- library/LuaApi.cpp | 3 ++- library/lua/gui.lua | 15 +++++++++++---- scripts | 2 +- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/docs/Lua API.rst b/docs/Lua API.rst index cd2379c48..96d459a88 100644 --- a/docs/Lua API.rst +++ b/docs/Lua API.rst @@ -1634,7 +1634,7 @@ Basic painting functions: Checks if [GRAPHICS:YES] was specified in init. -* ``dfhack.screen.paintTile(pen,x,y[,char,tile])`` +* ``dfhack.screen.paintTile(pen,x,y[,char,tile,map])`` Paints a tile using given parameters. See below for a description of pen. diff --git a/library/LuaApi.cpp b/library/LuaApi.cpp index a0b09714d..ea834992a 100644 --- a/library/LuaApi.cpp +++ b/library/LuaApi.cpp @@ -2091,7 +2091,8 @@ static int screen_paintTile(lua_State *L) } if (lua_gettop(L) >= 5 && !lua_isnil(L, 5)) pen.tile = luaL_checkint(L, 5); - lua_pushboolean(L, Screen::paintTile(pen, x, y)); + bool map = lua_toboolean(L, 6); + lua_pushboolean(L, Screen::paintTile(pen, x, y, map)); return 1; } diff --git a/library/lua/gui.lua b/library/lua/gui.lua index b83691acf..3a829c529 100644 --- a/library/lua/gui.lua +++ b/library/lua/gui.lua @@ -221,6 +221,7 @@ function Painter:init(args) self.y = self.y1 self.cur_pen = to_pen(args.pen or COLOR_GREY) self.cur_key_pen = to_pen(args.key_pen or COLOR_LIGHTGREEN) + self.to_map = false end function Painter.new(rect, pen) @@ -295,6 +296,11 @@ function Painter:key_pen(pen,...) return self end +function Painter:map(to_map) + self.to_map = to_map + return self +end + function Painter:clear() dscreen.fillRect(CLEAR_PEN, self.clip_x1, self.clip_y1, self.clip_x2, self.clip_y2) return self @@ -308,20 +314,20 @@ function Painter:fill(x1,y1,x2,y2,pen,bg,bold) y1 = math.max(y1+self.y1,self.clip_y1) x2 = math.min(x2+self.x1,self.clip_x2) y2 = math.min(y2+self.y1,self.clip_y2) - dscreen.fillRect(to_pen(self.cur_pen,pen,bg,bold),x1,y1,x2,y2) + dscreen.fillRect(to_pen(self.cur_pen,pen,bg,bold),x1,y1,x2,y2,self.to_map) return self end function Painter:char(char,pen,...) if self:isValidPos() then - dscreen.paintTile(to_pen(self.cur_pen, pen, ...), self.x, self.y, char) + dscreen.paintTile(to_pen(self.cur_pen, pen, ...), self.x, self.y, char, nil, self.to_map) end return self:advance(1, nil) end function Painter:tile(char,tile,pen,...) if self:isValidPos() then - dscreen.paintTile(to_pen(self.cur_pen, pen, ...), self.x, self.y, char, tile) + dscreen.paintTile(to_pen(self.cur_pen, pen, ...), self.x, self.y, char, tile, self.to_map) end return self:advance(1, nil) end @@ -340,7 +346,8 @@ function Painter:string(text,pen,...) dscreen.paintString( to_pen(self.cur_pen, pen, ...), self.x+dx, self.y, - string.sub(text,dx+1,len) + string.sub(text,dx+1,len), + self.to_map ) end end diff --git a/scripts b/scripts index c4f6877a6..22cf766a9 160000 --- a/scripts +++ b/scripts @@ -1 +1 @@ -Subproject commit c4f6877a69ac1c69a405d122dd6e75c5605fe782 +Subproject commit 22cf766a9b81cdf892cfb4181305ca7eaf1d56a7