summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2009-03-11 20:01:06 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2009-03-11 20:01:06 +0000
commit4c540e1c4e99150305b9c5297928ed1794cec13c (patch)
tree3ce5ba4f11d96ba590256bdd446ae8204091a0a7 /crawl-ref/source
parentf792f9b19c0dcdbe4166ad0dc543f704822bfa29 (diff)
downloadcrawl-ref-4c540e1c4e99150305b9c5297928ed1794cec13c.tar.gz
crawl-ref-4c540e1c4e99150305b9c5297928ed1794cec13c.zip
Generalize the menu toggle from InvMenu to Menu and use it to properly
tie ability descriptions into the menu. Still haven't worked out how to update the titles, though. :( git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@9412 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/abl-show.cc70
-rw-r--r--crawl-ref/source/directn.cc9
-rw-r--r--crawl-ref/source/invent.cc9
-rw-r--r--crawl-ref/source/invent.h3
-rw-r--r--crawl-ref/source/menu.cc23
-rw-r--r--crawl-ref/source/menu.h7
-rw-r--r--crawl-ref/source/stash.cc20
-rw-r--r--crawl-ref/source/tilesdl.cc2
-rw-r--r--crawl-ref/source/tutorial.cc4
9 files changed, 71 insertions, 76 deletions
diff --git a/crawl-ref/source/abl-show.cc b/crawl-ref/source/abl-show.cc
index 586b3145db..0e5b696c34 100644
--- a/crawl-ref/source/abl-show.cc
+++ b/crawl-ref/source/abl-show.cc
@@ -831,7 +831,7 @@ bool activate_ability()
}
std::vector<talent> talents = your_talents(false);
- if ( talents.empty() )
+ if (talents.empty())
{
// Give messages if the character cannot use innate talents right now.
// * Vampires can't turn into bats when full of blood.
@@ -867,8 +867,7 @@ bool activate_ability()
int selected = -1;
while (selected < 0)
{
- msg::streams(MSGCH_PROMPT) << "Use which ability? (? or * to list, ! "
- "for descriptions)"
+ msg::streams(MSGCH_PROMPT) << "Use which ability? (? or * to list)"
<< std::endl;
const int keyin = get_ch();
@@ -882,19 +881,6 @@ bool activate_ability()
return (false);
}
}
- else if (keyin == '!')
- {
- while (true)
- {
- selected = choose_ability_menu(talents, true);
- if (selected == -1)
- {
- canned_msg( MSG_OK );
- return (false);
- }
- _print_talent_description(talents[selected]);
- }
- }
else if (keyin == ESCAPE || keyin == ' ' || keyin == '\r'
|| keyin == '\n')
{
@@ -1959,25 +1945,33 @@ int choose_ability_menu(const std::vector<talent>& talents, bool describe)
abil_menu.set_highlighter(NULL);
abil_menu.set_title(
- new MenuEntry(" Ability "
+ new MenuEntry(" Ability "
"Cost Success"));
- if (describe)
- {
- abil_menu.set_more(formatted_string::parse_string(
- "Choose any ability to read its description, "
- "or exit the menu with Escape."));
- abil_menu.set_flags(MF_SINGLESELECT | MF_ANYPRINTABLE |
- MF_ALWAYS_SHOW_MORE);
- }
- else if (Options.tutorial_left)
+ abil_menu.set_flags(MF_SINGLESELECT | MF_ANYPRINTABLE
+ | MF_ALWAYS_SHOW_MORE);
+
+ if (Options.tutorial_left)
{
// XXX This could be buggy if you manage to pick up lots and lots
// of abilities during the tutorial.
abil_menu.set_more(tut_abilities_info());
- abil_menu.set_flags(MF_SINGLESELECT | MF_ANYPRINTABLE |
- MF_ALWAYS_SHOW_MORE);
}
+ else if (describe)
+ {
+ abil_menu.set_more(formatted_string::parse_string(
+ "Choose any ability to read its description, "
+ "or exit the menu with Escape."));
+ }
+ else
+ {
+ abil_menu.set_more(formatted_string::parse_string(
+ "Press '<w>!</w>' or '<w>?</w>' to toggle "
+ "between ability selection and description."));
+ }
+
+ abil_menu.allow_toggle = true;
+ abil_menu.menu_action = Menu::ACT_EXECUTE;
int numbers[52];
for (int i = 0; i < 52; ++i)
@@ -2014,17 +2008,21 @@ int choose_ability_menu(const std::vector<talent>& talents, bool describe)
}
}
- std::vector<MenuEntry*> sel = abil_menu.show(false);
- redraw_screen();
- if (sel.empty())
- {
- return -1;
- }
- else
+ while (true)
{
+ std::vector<MenuEntry*> sel = abil_menu.show(false);
+ redraw_screen();
+ if (sel.empty())
+ return -1;
+
ASSERT(sel.size() == 1);
ASSERT(sel[0]->hotkeys.size() == 1);
- return (*(reinterpret_cast<int*>(sel[0]->data)));
+ int selected = *(reinterpret_cast<int*>(sel[0]->data));
+
+ if (abil_menu.menu_action == Menu::ACT_EXAMINE)
+ _print_talent_description(talents[selected]);
+ else
+ return (*(reinterpret_cast<int*>(sel[0]->data)));
}
}
diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc
index 2e935ce2ba..ffac5ff9c2 100644
--- a/crawl-ref/source/directn.cc
+++ b/crawl-ref/source/directn.cc
@@ -50,7 +50,7 @@ REVISION("$Rev$");
#ifdef USE_TILE
#include "tiles.h"
#include "tilereg.h"
- #include "tilesdl.h"
+// #include "tilesdl.h"
#endif
#include "terrain.h"
#include "traps.h"
@@ -663,7 +663,7 @@ void full_describe_view()
if (getch() == 0)
getch();
}
- else // ACT_TRAVEL, here used to view database entry
+ else // ACT_EXECUTE, here used to view database entry
{
describe_monsters(*m);
redraw_screen();
@@ -676,7 +676,7 @@ void full_describe_view()
item_def* i = (item_def*)(sel[0]->data);
if (desc_menu.menu_action == InvMenu::ACT_EXAMINE)
describe_item( *i );
- else // ACT_TRAVEL
+ else // ACT_EXECUTE -> travel to item
{
const coord_def c = i->pos;
start_travel( c );
@@ -692,6 +692,9 @@ void full_describe_view()
InvEntry *me = new InvEntry(list_items[0]);
me->set_show_glyph(false);
}
+#else
+ tiles.place_cursor(CURSOR_TUTORIAL, Region::NO_CURSOR);
+ tiles.clear_text_tags(TAG_TUTORIAL);
#endif
}
diff --git a/crawl-ref/source/invent.cc b/crawl-ref/source/invent.cc
index cb0f5ececf..81bf34f5ed 100644
--- a/crawl-ref/source/invent.cc
+++ b/crawl-ref/source/invent.cc
@@ -299,7 +299,7 @@ void InvEntry::set_show_glyph(bool doshow)
InvMenu::InvMenu(int mflags)
: Menu(mflags, "inventory", false), type(MT_INVLIST), pre_select(NULL),
- title_annotate(NULL), allow_toggle(false), menu_action(ACT_EXAMINE)
+ title_annotate(NULL)
{
mdisplay->set_num_columns(2);
}
@@ -750,13 +750,6 @@ bool InvMenu::process_key( int key )
draw_select_count(0, true);
return (true);
}
- else if (key == '!')
- {
- sel.clear();
- menu_action = (action)((menu_action+1) % ACT_NUM);
- update_title();
- return (true);
- }
return Menu::process_key( key );
}
diff --git a/crawl-ref/source/invent.h b/crawl-ref/source/invent.h
index 68679dc9f2..315cdb0f7c 100644
--- a/crawl-ref/source/invent.h
+++ b/crawl-ref/source/invent.h
@@ -123,9 +123,6 @@ class InvMenu : public Menu
public:
InvMenu(int mflags = MF_MULTISELECT);
- bool allow_toggle;
- enum action { ACT_TRAVEL, ACT_EXAMINE, ACT_NUM } menu_action;
-
public:
unsigned char getkey() const;
diff --git a/crawl-ref/source/menu.cc b/crawl-ref/source/menu.cc
index 12f284f7eb..c891e715d3 100644
--- a/crawl-ref/source/menu.cc
+++ b/crawl-ref/source/menu.cc
@@ -84,11 +84,12 @@ void MenuDisplayTile::set_num_columns(int columns)
#endif
Menu::Menu( int _flags, const std::string& tagname, bool text_only )
- : f_selitem(NULL), f_drawitem(NULL), f_keyfilter(NULL), title(NULL),
- flags(_flags), tag(tagname), first_entry(0), y_offset(0),
- pagesize(0), max_pagesize(0), more("-more-", true), items(),
- sel(), select_filter(), highlighter(new MenuHighlighter), num(-1),
- lastch(0), alive(false), last_selected(-1)
+ : f_selitem(NULL), f_drawitem(NULL), f_keyfilter(NULL), allow_toggle(false),
+ menu_action(ACT_EXAMINE), title(NULL), flags(_flags), tag(tagname),
+ first_entry(0), y_offset(0), pagesize(0), max_pagesize(0),
+ more("-more-", true), items(), sel(), select_filter(),
+ highlighter(new MenuHighlighter), num(-1), lastch(0), alive(false),
+ last_selected(-1)
{
#ifdef USE_TILE
if (text_only)
@@ -329,6 +330,13 @@ bool Menu::process_key( int keyin )
lastch = keyin;
return (false);
}
+ else if (allow_toggle && (keyin == '!' || keyin == '?'))
+ {
+ sel.clear();
+ menu_action = (action)((menu_action+1) % ACT_NUM);
+ update_title();
+ return (true);
+ }
bool nav = false, repaint = false;
@@ -820,6 +828,7 @@ void Menu::draw_title()
void Menu::write_title()
{
textattr( item_colour(-1, title) );
+
cprintf("%s", title->get_text().c_str());
if (flags & MF_SHOW_PAGENUMBERS)
{
@@ -1678,8 +1687,8 @@ bool formatted_scroller::line_down()
bool formatted_scroller::line_up()
{
- if (first_entry > 0 && items[first_entry-1]->level != MEL_TITLE &&
- items[first_entry]->level != MEL_TITLE)
+ if (first_entry > 0 && items[first_entry-1]->level != MEL_TITLE
+ && items[first_entry]->level != MEL_TITLE)
{
--first_entry;
return (true);
diff --git a/crawl-ref/source/menu.h b/crawl-ref/source/menu.h
index 86c3b6e556..7f8b4c6372 100644
--- a/crawl-ref/source/menu.h
+++ b/crawl-ref/source/menu.h
@@ -265,8 +265,8 @@ public:
virtual bool is_set( int flag ) const;
void set_tag(const std::string& t) { tag = t; }
- bool draw_title_suffix( const std::string &s, bool titlefirst = true );
- bool draw_title_suffix( const formatted_string &fs, bool titlefirst = true );
+ bool draw_title_suffix(const std::string &s, bool titlefirst = true);
+ bool draw_title_suffix(const formatted_string &fs, bool titlefirst = true);
void update_title();
// Sets a replacement for the --more-- string.
@@ -309,6 +309,9 @@ public:
drawitem_tfn f_drawitem;
keyfilter_tfn f_keyfilter;
+ bool allow_toggle;
+ enum action { ACT_EXECUTE, ACT_EXAMINE, ACT_NUM } menu_action;
+
protected:
MenuEntry *title;
int flags;
diff --git a/crawl-ref/source/stash.cc b/crawl-ref/source/stash.cc
index a6b03ceb81..ad98884048 100644
--- a/crawl-ref/source/stash.cc
+++ b/crawl-ref/source/stash.cc
@@ -1778,14 +1778,13 @@ public:
StashSearchMenu(const char* sort_style_)
: Menu(), can_travel(true),
request_toggle_sort_method(false),
- menu_action(ACT_TRAVEL),
+// allow_toggle(true), menu_action(ACT_EXECUTE),
sort_style(sort_style_)
{ }
public:
bool can_travel;
bool request_toggle_sort_method;
- enum action { ACT_TRAVEL, ACT_EXAMINE, ACT_NUM } menu_action;
const char* sort_style;
protected:
@@ -1806,8 +1805,8 @@ void StashSearchMenu::draw_title()
char buf[200];
snprintf(buf, 200,
- "<lightgrey> [<w>a-z</w>: %s <w>?</w>: change action <w>/</w>: change sort]",
- menu_action == ACT_TRAVEL ? "travel" : "examine");
+ "<lightgrey> [<w>a-z</w>: %s <w>?</w>/<w>!</w>: change action <w>/</w>: change sort]",
+ menu_action == ACT_EXECUTE ? "travel" : "examine");
draw_title_suffix(formatted_string::parse_string(buf), false);
}
@@ -1816,14 +1815,7 @@ void StashSearchMenu::draw_title()
bool StashSearchMenu::process_key(int key)
{
- if (key == '?')
- {
- sel.clear();
- menu_action = (action)((menu_action+1) % ACT_NUM);
- update_title();
- return (true);
- }
- else if (key == '/')
+ if (key == '/')
{
request_toggle_sort_method = true;
return (false);
@@ -1845,6 +1837,8 @@ bool StashTracker::display_search_results(
StashSearchMenu stashmenu(sort_style);
stashmenu.set_tag("stash");
stashmenu.can_travel = travelable;
+ stashmenu.allow_toggle = true;
+ stashmenu.menu_action = Menu::ACT_EXECUTE;
std::string title = "match";
MenuEntry *mtitle = new MenuEntry(title, MEL_TITLE);
@@ -1920,7 +1914,7 @@ bool StashTracker::display_search_results(
}
redraw_screen();
- if (sel.size() == 1 && stashmenu.menu_action == StashSearchMenu::ACT_TRAVEL)
+ if (sel.size() == 1 && stashmenu.menu_action == Menu::ACT_EXECUTE)
{
const stash_search_result *res =
static_cast<stash_search_result *>(sel[0]->data);
diff --git a/crawl-ref/source/tilesdl.cc b/crawl-ref/source/tilesdl.cc
index 45f4174e05..e4d56c6e99 100644
--- a/crawl-ref/source/tilesdl.cc
+++ b/crawl-ref/source/tilesdl.cc
@@ -592,8 +592,6 @@ static int _translate_keysym(SDL_keysym &keysym)
int TilesFramework::handle_mouse(MouseEvent &event)
{
-// m_region_tile->place_cursor(CURSOR_MOUSE, Region::NO_CURSOR);
-
// Note: the mouse event goes to all regions in the active layer because
// we want to be able to start some GUI event (e.g. far viewing) and
// stop if it moves to another region.
diff --git a/crawl-ref/source/tutorial.cc b/crawl-ref/source/tutorial.cc
index 33e51eb159..7cb022f58a 100644
--- a/crawl-ref/source/tutorial.cc
+++ b/crawl-ref/source/tutorial.cc
@@ -2826,8 +2826,8 @@ formatted_string tut_abilities_info()
std::string broken = "This screen shows your character's set of talents. "
"You can gain new abilities via certain items, through religion or by "
"way of mutations. Activation of an ability usually comes at a cost, "
- "e.g. nutrition or Magic power. If, from the main screen, you press "
- "<w>a!</w> you can read your abilities' descriptions.";
+ "e.g. nutrition or Magic power. Press '<w>!</w>' or '<w>?</w>' to "
+ "toggle between ability selection and description.";
linebreak_string2(broken, _get_tutorial_cols());
text << broken;