Add map parameter to Lua paintTile() and use in Painter

Also updated gui/siege-engine.lua
develop
lethosor 2017-06-02 12:42:51 -04:00
parent 9df35dd844
commit ae1aa49089
4 changed files with 15 additions and 7 deletions

@ -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.

@ -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;
}

@ -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

@ -1 +1 @@
Subproject commit c4f6877a69ac1c69a405d122dd6e75c5605fe782
Subproject commit 22cf766a9b81cdf892cfb4181305ca7eaf1d56a7