From fca8bffaa402ceea2764abe66e9b035a545b4e52 Mon Sep 17 00:00:00 2001 From: myk002 Date: Sun, 11 Jul 2021 13:22:33 -0700 Subject: [PATCH 1/2] update changelog --- docs/changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog.txt b/docs/changelog.txt index 7d9eb9265..d0d60c244 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -34,6 +34,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: # Future ## Misc Improvements +- `buildingplan`: now displays which items are attached and which items are still missing for planned buildings - `tiletypes-here`, `tiletypes-here-point`: add --cursor and --quiet options to support non-interactive use cases # 0.47.05-r2 From c6866ca33951e245b240715b0dc57fc60b078ff6 Mon Sep 17 00:00:00 2001 From: myk002 Date: Sun, 11 Jul 2021 13:22:57 -0700 Subject: [PATCH 2/2] display status of items (attached/pending) --- plugins/buildingplan.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/plugins/buildingplan.cpp b/plugins/buildingplan.cpp index 08888f2c7..1eb1dd9e6 100644 --- a/plugins/buildingplan.cpp +++ b/plugins/buildingplan.cpp @@ -498,6 +498,17 @@ struct buildingplan_query_hook : public df::viewscreen_dwarfmodest INTERPOSE_NEXT(feed)(input); } + static bool is_filter_satisfied(df::building *bld, int filter_idx) + { + if (!bld + || bld->jobs.size() < 1 + || bld->jobs[0]->job_items.size() <= filter_idx) + return false; + + // if all items for this filter are attached, the quantity will be 0 + return bld->jobs[0]->job_items[filter_idx]->quantity == 0; + } + DEFINE_VMETHOD_INTERPOSE(void, render, ()) { INTERPOSE_NEXT(render)(); @@ -515,10 +526,12 @@ struct buildingplan_query_hook : public df::viewscreen_dwarfmodest Screen::Pen pen(' ', COLOR_BLACK); Screen::fillRect(pen, x, y, dims.menu_x2, y); + bool attached = is_filter_satisfied(pb->getBuilding(), filter_idx); + auto & filter = pb->getFilters()[filter_idx]; y = 24; std::string item_label = - stl_sprintf("Item %d of %d", filter_count - filter_idx, filter_count); + stl_sprintf("Item %d of %d (%s)", filter_count - filter_idx, filter_count, attached ? "attached" : "pending"); OutputString(COLOR_WHITE, x, y, "Planned Building Filter", true, left_margin + 1); OutputString(COLOR_WHITE, x, y, item_label.c_str(), true, left_margin + 1); OutputString(COLOR_WHITE, x, y, get_item_label(toBuildingTypeKey(bld), filter_idx).c_str(), true, left_margin);