(WIP) Add custom work detail icons & related tools #1387
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
(when cloning this, don't forget to also clone the respective dfhack branch)
This is a very minimal proof of concept for a system that implements customizable work detail icons. In its current state, it offers the following:
make_icon_text(icondef, force_ascii, border, border_h)
:A
widgets.makeButtonLabelText
wrapper that parses anIconDef
frominternal/work-detail-icons/icon-definitions
(or elsewhere) and returns an icon in the form of label text. Once a tool to render images with transparency is implemented, this will be changed to support that.IconsOverlay
:An overlay that detects whenever there are work detail icons present and tries its best to cover them up with ones returned from the above function. It depends on the viewscreen having vanilla widgets to read values from, and so does not work in contexts that go without them (namely, the labor tab in unit viewsheets and the unit lists in zone details). We'll have to either wait until those screens are widgetized (if they ever will be) or find another way to get the data from them.
Since I only needed to write enough code to examplify the transparency issue, there is no actual logic to determine which icons to draw yet. The script accepts one icondef per subview, and draws that icon over all the vanilla ones indiscriminately, only sparing occupation icons.
https://youtu.be/E7einc7MI3k
As evident from the video, the current implementation is both quite slow, requiring a couple frames to catch up, and extremely taxing, with FPS dropping down from 50 to 30 whenever it is shown in a 200 population fort. I would really appreciate some advice on how to improve that.
TooltipOverlay
:The only feature that works at least semi-properly right now. This overlay detects whenever the mouse is hovering over a WD icon and displays a tooltip with the corresponding WD's name and restriction status.
https://youtu.be/JXQChejh1kQ
Since it is dependent on the same vanilla widgets and uses the same unoptimized functions for its data,
TooltipOverlay
also suffers from the same flaws as its graphics-based sibling. Other than that, though, it is complete. I could put it in a separate pull request, possibly as an addition to another script until the rest of this one is implemented.gui/work-detail-icons
:This is the future GUI that will let the user assign icons to WDs as well as create their own icons. There's nothing there yet, and I only included it in this first version because I need help with the on_activate method in the button overlay.