diff options
-rw-r--r-- | crawl-ref/source/describe.h | 30 | ||||
-rw-r--r-- | crawl-ref/source/directn.cc | 6 |
2 files changed, 27 insertions, 9 deletions
diff --git a/crawl-ref/source/describe.h b/crawl-ref/source/describe.h index 9e71c2a337..5751678335 100644 --- a/crawl-ref/source/describe.h +++ b/crawl-ref/source/describe.h @@ -136,22 +136,34 @@ inline void process_description(T &proc, const describe_info &inf) std::string desc; - if (inf.title.empty()) - desc = inf.body.str(); - else - { - desc = inf.title + "$$"; - desc += inf.body.str(); - } - - int num_lines = count_desc_lines(desc, line_width) + 1; + // How mnay lines is the title, we also seem to be adding 1 to + // start with. + int num_lines = count_desc_lines(inf.title, line_width) + 1; + int body_lines = count_desc_lines(inf.body.str(), line_width); const int suffix_lines = count_desc_lines(inf.suffix, line_width); const int prefix_lines = count_desc_lines(inf.prefix, line_width); const int footer_lines = count_desc_lines(inf.footer, line_width) + (inf.footer.empty() ? 0 : 1); const int quote_lines = count_desc_lines(inf.quote, line_width); + // Maybe skip the body if body + title would be too many lines + if(inf.title.empty()) + { + desc = inf.body.str(); + // There is a default 1 line addition for some reason + num_lines = body_lines + 1; + } + else if(body_lines + num_lines + 2 <= height) + { + desc = inf.title + "$$"; + desc += inf.body.str(); + // Got 2 lines from the two $s that weren't counted yet + num_lines += body_lines + 2; + } + else + desc = inf.title + "$"; + // Prefer the footer over the suffix. if (num_lines + suffix_lines + footer_lines <= height) { diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc index dfa9dfd251..7dc912ccba 100644 --- a/crawl-ref/source/directn.cc +++ b/crawl-ref/source/directn.cc @@ -456,6 +456,12 @@ static void _direction_again(dist& moves, targetting_type restricts, class view_desc_proc { public: + view_desc_proc() + { + // This thing seems to be starting off 1 line above where it + // should be. -cao + nextline(); + } int width() { return crawl_view.msgsz.x; } int height() { return crawl_view.msgsz.y; } void print(const std::string &str) { cprintf("%s", str.c_str()); } |