Use Units module to get unit colors, fix initial scroll position

develop
Quietust 2012-08-22 16:54:34 -05:00
parent 1e28ceff6d
commit 132491e868
1 changed files with 8 additions and 7 deletions

@ -369,6 +369,10 @@ void viewscreen_unitlaborsst::calcSize()
labors_width--; labors_width--;
} }
// don't adjust scroll position immediately after the window opened
if (units.size() == 0)
return;
// if the window grows vertically, scroll upward to eliminate blank rows from the bottom // if the window grows vertically, scroll upward to eliminate blank rows from the bottom
if (first_row > units.size() - height) if (first_row > units.size() - height)
first_row = units.size() - height; first_row = units.size() - height;
@ -494,9 +498,9 @@ void viewscreen_unitlaborsst::render()
if (col_offset >= NUM_COLUMNS) if (col_offset >= NUM_COLUMNS)
break; break;
int8_t fg = ENUM_ATTR(profession, color, columns[col_offset].profession), bg = 0; int8_t fg = Units::getCasteProfessionColor(ui->race_id, -1, columns[col_offset].profession);
if (fg == -1) int8_t bg = 0;
fg = 3; // teal
if (col_offset == sel_column) if (col_offset == sel_column)
{ {
fg = 0; fg = 0;
@ -524,10 +528,7 @@ void viewscreen_unitlaborsst::render()
Screen::paintString(Screen::Pen(' ', fg, bg), 1, 3 + row, name); Screen::paintString(Screen::Pen(' ', fg, bg), 1, 3 + row, name);
string profession = Units::getProfessionName(unit); string profession = Units::getProfessionName(unit);
fg = ENUM_ATTR(profession, color, unit->profession); fg = Units::getProfessionColor(unit);
if (fg == -1)
fg = 3; // TODO: fetch from creature raws
// TODO: check for entity positions and alter profession/color accordingly
bg = 0; bg = 0;
Screen::paintString(Screen::Pen(' ', fg, bg), 1 + prof_width + 1, 3 + row, profession); Screen::paintString(Screen::Pen(' ', fg, bg), 1 + prof_width + 1, 3 + row, profession);