diff options
author | haranp <haranp@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-12-11 10:08:18 +0000 |
---|---|---|
committer | haranp <haranp@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-12-11 10:08:18 +0000 |
commit | 6abfdfb2cdb6e78d530512692b80200d46211aff (patch) | |
tree | d835230486b3539820405f82ba8b417675cb89a5 /crawl-ref/source/menu.cc | |
parent | cdeeda046914bb54948d0c89e92988ff630f3ad7 (diff) | |
download | crawl-ref-6abfdfb2cdb6e78d530512692b80200d46211aff.tar.gz crawl-ref-6abfdfb2cdb6e78d530512692b80200d46211aff.zip |
Added an MF_SHOW_PAGENUMBERS flag to Menu, which will show "(page X of Y)"
as part of the title. This can get a bit confusing when scrolling using
up and down (as opposed to page-up/page-down.) Currently only used for
select_items().
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3047 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/menu.cc')
-rw-r--r-- | crawl-ref/source/menu.cc | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/crawl-ref/source/menu.cc b/crawl-ref/source/menu.cc index f9afedac4c..a486b9cea9 100644 --- a/crawl-ref/source/menu.cc +++ b/crawl-ref/source/menu.cc @@ -604,6 +604,18 @@ void Menu::write_title() { textattr( item_colour(-1, title) ); cprintf("%s", title->get_text().c_str()); + if ( flags & MF_SHOW_PAGENUMBERS ) + { + // The total number of pages is well defined, but the current + // page a bit less so. To make sense, we hack it so that your + // current page is based on the first line you're seeing, *unless* + // you're seeing the last item. + int numpages = items.empty() ? 1 : ((items.size()-1) / pagesize + 1); + int curpage = first_entry / pagesize + 1; + if ( in_page(items.size() - 1) ) + curpage = numpages; + cprintf(" (page %d of %d)", curpage, numpages); + } const int x = wherex(), y = wherey(); cprintf("%-*s", get_number_of_cols() - x, ""); |