From 7db47d41a1e8c783f0cf9aba41b835cc9950fc96 Mon Sep 17 00:00:00 2001 From: ennewalker Date: Sat, 25 Oct 2008 17:47:37 +0000 Subject: More graphical menu improvements. Inventory menus now have columns. Long entries are now wrapped and then truncated. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7296 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/format.cc | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'crawl-ref/source/format.cc') diff --git a/crawl-ref/source/format.cc b/crawl-ref/source/format.cc index 9cd282e058..cf884f8220 100644 --- a/crawl-ref/source/format.cc +++ b/crawl-ref/source/format.cc @@ -329,6 +329,27 @@ inline void cap(int &i, int max) i = 0; } +char &formatted_string::operator [] (size_t idx) +{ + size_t rel_idx = idx; + int size = ops.size(); + for (int i = 0; i < size; ++i) + { + if (ops[i] != FSOP_TEXT) + continue; + + size_t len = ops[i].text.length(); + if (rel_idx >= len) + rel_idx -= len; + else + return ops[i].text[rel_idx]; + } + ASSERT(!"Invalid index"); + char *invalid = NULL; + return *invalid; +} + + std::string formatted_string::tostring(int s, int e) const { std::string st; -- cgit v1.2.3-54-g00ecf