diff options
Diffstat (limited to 'crawl-ref/source/describe.h')
-rw-r--r-- | crawl-ref/source/describe.h | 30 |
1 files changed, 21 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) { |