diff options
author | Neil Moore <neil@s-z.org> | 2013-11-30 11:43:47 -0500 |
---|---|---|
committer | Neil Moore <neil@s-z.org> | 2013-11-30 11:43:47 -0500 |
commit | b4cf04c5a356e7eca90cbf5ab50fc1044e89e02d (patch) | |
tree | 50e486f68e421dbb218796aa17e2c871de220a37 /crawl-ref/source/invent.cc | |
parent | 82f56c9d7c4d18eb93f3f61a78fc1a98d171b1c5 (diff) | |
download | crawl-ref-b4cf04c5a356e7eca90cbf5ab50fc1044e89e02d.tar.gz crawl-ref-b4cf04c5a356e7eca90cbf5ab50fc1044e89e02d.zip |
Trim long inscriptions in inventory, handle unicode (#5675)
We were trimming inscriptions to fit only if show_inventory_weights was
on. The excess was usually being overwritten by the next line, but not
if that line was sufficiently short.
Also, count and trim by width, not bytes, both with and without
show_inventory_weights.
Diffstat (limited to 'crawl-ref/source/invent.cc')
-rw-r--r-- | crawl-ref/source/invent.cc | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/crawl-ref/source/invent.cc b/crawl-ref/source/invent.cc index ff27f1b019..735a3cec8e 100644 --- a/crawl-ref/source/invent.cc +++ b/crawl-ref/source/invent.cc @@ -231,16 +231,15 @@ string InvEntry::get_text(bool need_cursor) const } if (Options.show_inventory_weights) - { max_chars_in_line -= 1; - const int w_weight = 10; //length of " (999 aum)" - int excess = strwidth(tstr.str()) - colour_tag_adjustment - + text.size() + w_weight - max_chars_in_line; - if (excess > 0) - tstr << text.substr(0, max<int>(0, text.size() - excess - 2)) << ".."; - else - tstr << text; - } + + const int w_weight = Options.show_inventory_weights + ? 10 //length of " (999 aum)" + : 0; + const int excess = strwidth(tstr.str()) - colour_tag_adjustment + + strwidth(text) + w_weight - max_chars_in_line; + if (excess > 0) + tstr << chop_string(text, max(0, strwidth(text) - excess - 2)) << ".."; else tstr << text; |