summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/menu.cc
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-05-08 09:13:07 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-05-08 09:13:07 +0000
commit90a4b849d15c2e762dc00195a448e0caa642cbaf (patch)
tree54c63fc984d2fd84fda9eb4a4c7623eb3d97758b /crawl-ref/source/menu.cc
parentc8dad26d1f8ad2c61d515bff20b58f8eeae5e9b2 (diff)
downloadcrawl-ref-90a4b849d15c2e762dc00195a448e0caa642cbaf.tar.gz
crawl-ref-90a4b849d15c2e762dc00195a448e0caa642cbaf.zip
Changed list_spells() somewhat. It's now a slider wraparound menu.
(Also changed the meaning of what some of the flags do to slider_menu, the default behaviour should be unaltered.) git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1423 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/menu.cc')
-rw-r--r--crawl-ref/source/menu.cc26
1 files changed, 20 insertions, 6 deletions
diff --git a/crawl-ref/source/menu.cc b/crawl-ref/source/menu.cc
index da948d09cc..d1b2d7ad6c 100644
--- a/crawl-ref/source/menu.cc
+++ b/crawl-ref/source/menu.cc
@@ -660,9 +660,9 @@ bool slider_menu::process_key(int key)
return (false);
}
- if (selected == 0 &&
- (key == CK_UP || key == CK_PGUP || key == '<' || key == ';') &&
- Menu::is_set(MF_EASY_EXIT))
+ if (Menu::is_set(MF_NOWRAP) &&
+ selected == 0 &&
+ (key == CK_UP || key == CK_PGUP || key == '<' || key == ';'))
{
oldselect = selected;
selected = -1;
@@ -862,9 +862,23 @@ bool slider_menu::fix_entry(int recurse_depth)
void slider_menu::new_selection(int nsel)
{
if (nsel < 0)
- nsel = 0;
- if (nsel >= (int) items.size())
- nsel = items.size() - 1;
+ {
+ if ( !is_set(MF_NOWRAP) )
+ do {
+ nsel += items.size();
+ } while ( nsel < 0 );
+ else
+ nsel = 0;
+ }
+ if (nsel >= static_cast<int>(items.size()))
+ {
+ if ( !is_set(MF_NOWRAP) )
+ do {
+ nsel -= items.size();
+ } while ( nsel >= static_cast<int>(items.size()) );
+ else
+ nsel = items.size() - 1;
+ }
const int old = selected;
selected = nsel;