Skip to content

(WIP) Add custom work detail icons & related tools #1387

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

nibirubingus
Copy link
Contributor

@nibirubingus nibirubingus commented Jan 31, 2025

(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 an IconDef from internal/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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant