display status of items (attached/pending)

develop
myk002 2021-07-11 13:22:57 -07:00
parent fca8bffaa4
commit c6866ca339
No known key found for this signature in database
GPG Key ID: 8A39CA0FA0C16E78
1 changed files with 14 additions and 1 deletions

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