From 6abfdfb2cdb6e78d530512692b80200d46211aff Mon Sep 17 00:00:00 2001 From: haranp Date: Tue, 11 Dec 2007 10:08:18 +0000 Subject: 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 --- crawl-ref/source/menu.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'crawl-ref/source/menu.cc') 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, ""); -- cgit v1.2.3-54-g00ecf