From e442e23589d582d7836012037e8030473e747e3d Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Tue, 31 Jan 2023 23:54:27 -0800 Subject: [PATCH] allow tile in Label tokens to be either pen or id --- docs/changelog.txt | 1 + docs/dev/Lua API.rst | 3 ++- library/lua/gui/widgets.lua | 4 +++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index a78b14fc7..7fac2030c 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -68,6 +68,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: - `helpdb`: changed from auto-refreshing every 60 seconds to only refreshing on explicit call to ``helpdb.refresh()``. docs very rarely change during a play session, and the automatic database refreshes were slowing down the startup of `gui/launcher` - ``widgets.Label``: ``label.scroll()`` now understands ``home`` and ``end`` keywords for scrolling to the top or bottom - ``dfhack.units.getCitizens()``: gets a list of citizens +- ``Label``: token ``tile`` properties can now be either pens or numeric texture ids ## Removed - `autohauler`: no plans to port to v50, as it just doesn't make sense with the new work detail system diff --git a/docs/dev/Lua API.rst b/docs/dev/Lua API.rst index 658893ec1..78b324f63 100644 --- a/docs/dev/Lua API.rst +++ b/docs/dev/Lua API.rst @@ -4658,7 +4658,8 @@ containing newlines, or a table with the following possible fields: * ``token.tile = pen`` - Specifies a pen to paint as one tile before the main part of the token. + Specifies a pen or texture index to paint as one tile before the main part of + the token. * ``token.width = ...`` diff --git a/library/lua/gui/widgets.lua b/library/lua/gui/widgets.lua index 0696459cd..4228bc9ad 100644 --- a/library/lua/gui/widgets.lua +++ b/library/lua/gui/widgets.lua @@ -1110,7 +1110,9 @@ function render_text(obj,dc,x0,y0,pen,dpen,disabled) if token.tile then x = x + 1 if dc then - dc:tile(nil, token.tile) + local tile_pen = tonumber(token.tile) and + to_pen{tile=token.tile} or token.tile + dc:char(nil, token.tile) if token.width then dc:advance(token.width-1) end