MCPcopy Create free account
hub / github.com/DFHack/dfhack / populateDwarfColumn

Method populateDwarfColumn

plugins/dwarfmonitor.cpp:218–265  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

216 }
217
218 void populateDwarfColumn(df::unit *starting_selection = NULL)
219 {
220 selected_column = 0;
221
222 auto last_selected_index = dwarf_activity_column.highlighted_index;
223 dwarves_column.clear();
224 dwarf_activity_values.clear();
225
226 for (auto it = work_history.begin(); it != work_history.end();)
227 {
228 auto unit = it->first;
229 if (!Units::isActive(unit))
230 {
231 work_history.erase(it++);
232 continue;
233 }
234
235 deque<activity_type> *work_list = &it->second;
236 ++it;
237
238 size_t dwarf_total = 0;
239 dwarf_activity_values[unit] = map<activity_type, size_t>();
240 size_t count = window_days * ticks_per_day;
241 for (auto entry = work_list->rbegin(); entry != work_list->rend() && count > 0; entry++, count--)
242 {
243 if (*entry == JOB_UNKNOWN || *entry == job_type::DrinkBlood)
244 continue;
245
246 ++dwarf_total;
247 addDwarfActivity(unit, *entry);
248 }
249
250 auto &values = dwarf_activity_values[unit];
251 for (auto it = values.begin(); it != values.end(); ++it)
252 it->second = getPercentage(it->second, dwarf_total);
253
254 dwarves_column.add(getUnitName(unit), unit);
255 }
256
257 dwarf_activity_column.left_margin = dwarves_column.fixWidth() + 2;
258 dwarves_column.filterDisplay();
259 if (starting_selection)
260 dwarves_column.selectItem(starting_selection);
261 else
262 dwarves_column.setHighlight(last_selected_index);
263
264 populateActivityColumn();
265 }
266
267 void populateActivityColumn()
268 {

Callers

nothing calls this directly

Calls 11

getPercentageFunction · 0.85
getUnitNameFunction · 0.85
fixWidthMethod · 0.80
filterDisplayMethod · 0.80
selectItemMethod · 0.80
setHighlightMethod · 0.80
clearMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
eraseMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected