From 132491e868df855d7cb53f0dafff6de7801400a8 Mon Sep 17 00:00:00 2001 From: Quietust Date: Wed, 22 Aug 2012 16:54:34 -0500 Subject: [PATCH] Use Units module to get unit colors, fix initial scroll position --- plugins/manipulator.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/plugins/manipulator.cpp b/plugins/manipulator.cpp index 48081095a..dfc20da06 100644 --- a/plugins/manipulator.cpp +++ b/plugins/manipulator.cpp @@ -369,6 +369,10 @@ void viewscreen_unitlaborsst::calcSize() 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 (first_row > units.size() - height) first_row = units.size() - height; @@ -494,9 +498,9 @@ void viewscreen_unitlaborsst::render() if (col_offset >= NUM_COLUMNS) break; - int8_t fg = ENUM_ATTR(profession, color, columns[col_offset].profession), bg = 0; - if (fg == -1) - fg = 3; // teal + int8_t fg = Units::getCasteProfessionColor(ui->race_id, -1, columns[col_offset].profession); + int8_t bg = 0; + if (col_offset == sel_column) { fg = 0; @@ -524,10 +528,7 @@ void viewscreen_unitlaborsst::render() Screen::paintString(Screen::Pen(' ', fg, bg), 1, 3 + row, name); string profession = Units::getProfessionName(unit); - fg = ENUM_ATTR(profession, color, unit->profession); - if (fg == -1) - fg = 3; // TODO: fetch from creature raws - // TODO: check for entity positions and alter profession/color accordingly + fg = Units::getProfessionColor(unit); bg = 0; Screen::paintString(Screen::Pen(' ', fg, bg), 1 + prof_width + 1, 3 + row, profession);