Merge remote-tracking branch 'myk002/myk_buildingplan_attached' into develop

develop
lethosor 2021-08-10 01:07:35 -04:00
commit 0140ace317
No known key found for this signature in database
GPG Key ID: 76A269552F4F58C1
2 changed files with 15 additions and 1 deletions

@ -40,6 +40,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
- Core: ``alt`` keydown state is now cleared when DF loses and regains focus, ensuring the ``alt`` modifier state is not stuck on for systems that don't send standard keyup events in response to ``alt-tab`` window manager events
## 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
## Documentation

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