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

Method feed

plugins/manipulator.cpp:1457–1927  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1455}
1456
1457void viewscreen_unitlaborsst::feed(set<df::interface_key> *events)
1458{
1459 int8_t modstate = Core::getInstance().getModstate();
1460 bool leave_all = events->count(interface_key::LEAVESCREEN_ALL);
1461 if (leave_all || events->count(interface_key::LEAVESCREEN))
1462 {
1463 events->clear();
1464 Screen::dismiss(this);
1465 if (leave_all)
1466 {
1467 events->insert(interface_key::LEAVESCREEN);
1468 parent->feed(events);
1469 events->clear();
1470 }
1471 return;
1472 }
1473
1474 if (!units.size())
1475 return;
1476
1477 if (do_refresh_names)
1478 refreshNames();
1479
1480 int old_sel_row = sel_row;
1481
1482 if (events->count(interface_key::CURSOR_UP) || events->count(interface_key::CURSOR_UPLEFT) || events->count(interface_key::CURSOR_UPRIGHT))
1483 sel_row--;
1484 if (events->count(interface_key::CURSOR_UP_FAST) || events->count(interface_key::CURSOR_UPLEFT_FAST) || events->count(interface_key::CURSOR_UPRIGHT_FAST))
1485 sel_row -= 10;
1486 if (events->count(interface_key::CURSOR_DOWN) || events->count(interface_key::CURSOR_DOWNLEFT) || events->count(interface_key::CURSOR_DOWNRIGHT))
1487 sel_row++;
1488 if (events->count(interface_key::CURSOR_DOWN_FAST) || events->count(interface_key::CURSOR_DOWNLEFT_FAST) || events->count(interface_key::CURSOR_DOWNRIGHT_FAST))
1489 sel_row += 10;
1490
1491 if ((sel_row > 0) && events->count(interface_key::CURSOR_UP_Z_AUX))
1492 {
1493 sel_row = 0;
1494 }
1495 if ((size_t(sel_row) < units.size()-1) && events->count(interface_key::CURSOR_DOWN_Z_AUX))
1496 {
1497 sel_row = units.size()-1;
1498 }
1499
1500 if (sel_row < 0)
1501 {
1502 if (old_sel_row == 0 && events->count(interface_key::CURSOR_UP))
1503 sel_row = units.size() - 1;
1504 else
1505 sel_row = 0;
1506 }
1507
1508 if (size_t(sel_row) > units.size() - 1)
1509 {
1510 if (size_t(old_sel_row) == units.size()-1 && events->count(interface_key::CURSOR_DOWN))
1511 sel_row = 0;
1512 else
1513 sel_row = units.size() - 1;
1514 }

Callers 2

feedMethod · 0.45
feedMethod · 0.45

Calls 8

showFunction · 0.85
save_from_unitMethod · 0.80
countMethod · 0.45
clearMethod · 0.45
insertMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected