summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-12-11 10:08:18 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-12-11 10:08:18 +0000
commit6abfdfb2cdb6e78d530512692b80200d46211aff (patch)
treed835230486b3539820405f82ba8b417675cb89a5
parentcdeeda046914bb54948d0c89e92988ff630f3ad7 (diff)
downloadcrawl-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
-rw-r--r--crawl-ref/source/invent.cc4
-rw-r--r--crawl-ref/source/menu.cc12
-rw-r--r--crawl-ref/source/menu.h1
3 files changed, 15 insertions, 2 deletions
diff --git a/crawl-ref/source/invent.cc b/crawl-ref/source/invent.cc
index f8af3d11e1..f55cdd856b 100644
--- a/crawl-ref/source/invent.cc
+++ b/crawl-ref/source/invent.cc
@@ -698,8 +698,8 @@ std::vector<SelItem> select_items( const std::vector<const item_def*> &items,
menu.set_type(mtype);
menu.set_title(title);
menu.load_items(items);
- menu.set_flags(noselect ? MF_NOSELECT :
- MF_MULTISELECT | MF_ALLOW_FILTER);
+ menu.set_flags(noselect ? MF_NOSELECT | MF_SHOW_PAGENUMBERS :
+ MF_MULTISELECT | MF_ALLOW_FILTER | MF_SHOW_PAGENUMBERS);
menu.show();
selected = menu.get_selitems();
}
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, "");
diff --git a/crawl-ref/source/menu.h b/crawl-ref/source/menu.h
index f7a57f0834..014932cd77 100644
--- a/crawl-ref/source/menu.h
+++ b/crawl-ref/source/menu.h
@@ -165,6 +165,7 @@ enum MenuFlag
MF_ALLOW_FILTER = 0x0080, // Control-F will ask for regex and
// select the appropriate items.
MF_ALLOW_FORMATTING = 0x0100, // Parse index for formatted-string
+ MF_SHOW_PAGENUMBERS = 0x0200, // Show "(page X of Y)" when appropriate
MF_EASY_EXIT = 0x1000
};