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SBAPL2FZNOR2R2NIJQITPHLQCMUE53U54GAENUSIN4526NHCPAC
M47QBURKKRV2JFK6U7GQNVWK7RUTBVPBJ5FHURC55SKQSXAUFSBAC
IIN7AVA6JYRBXH6ZYRR7BY7TV6PW7ANAQ2A3PD55FKBKKQFEEF2AC
25CH7HH4LKXFIZ75YNMXS3TSXO6O27DYSOPLOD45K4OCNFWLS4LQC
for (int i = 0; i < NUM_MONSTER_SPELL_SLOTS; i++)
mprf( MSGCH_DIAGNOSTICS, "Spell #%d: %d (%s)",
i, spells[i], spell_title(spells[i]) );
// Only for ghosts, too spammy to use for all monsters.
if (book == MST_GHOST)
{
for (int i = 0; i < NUM_MONSTER_SPELL_SLOTS; i++)
mprf( MSGCH_DIAGNOSTICS, "Spell #%d: %d (%s)",
i, spells[i], spell_title(spells[i]) );
}
// Initializes a Menu from a formatted_string as follows:
//
// 1) Splits the formatted_string on EOL (this is not necessarily \n).
// 2) Picks the most recently used non-whitespace colour as the colour
// for the next line (so it can't do multiple colours on one line).
// 3) Ignores all cursor movement ops in the formatted_string.
//
// These are limitations that should be fixed eventually.
//
Menu( const formatted_string &fs );
: 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), 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)
}
Menu::Menu( const formatted_string &fs )
: f_selitem(NULL), f_drawitem(NULL), f_keyfilter(NULL), title(NULL),
// This is a text-viewer menu, init flags to be easy on the user.
flags(MF_NOSELECT | MF_EASY_EXIT),
tag(), 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)
{
int colour = LIGHTGREY;
int last_text_colour = LIGHTGREY;
std::string line;
for (formatted_string::oplist::const_iterator i = fs.ops.begin();
i != fs.ops.end(); ++i)
{
const formatted_string::fs_op &op(*i);
switch (op.type)
{
case FSOP_COLOUR:
colour = op.x;
break;
case FSOP_TEXT:
line += op.text;
if (op.text.find_first_not_of(" \t\r\n") != std::string::npos)
last_text_colour = colour;
check_add_formatted_line(last_text_colour, line, true);
break;
default:
break;
}
}
check_add_formatted_line(colour, line, false);
if (check_eol && line.find(EOL) == std::string::npos)
return;
std::vector<std::string> lines = split_string(EOL, line, false, true);
int size = lines.size();
// If we have stuff after EOL, leave that in the line variable and
// don't add an entry for it, unless the caller told us not to
// check EOL sanity.
if (check_eol && !ends_with(line, EOL))
line = lines[--size];
else
line.clear();
for (int i = 0; i < size; ++i)
{
std::string &s(lines[i]);
trim_string_right(s);
MenuEntry *me = new MenuEntry(s);
me->colour = col;
if (!title)
set_title(me);
else
add_entry(me);
}
line.clear();
}
}
// to highlight species in aptitudes list ('?%')
static std::string get_species_key()
{
if (player_genus(GENPC_DRACONIAN) && you.experience_level < 7)
return "";
std::string result = "";
switch (you.species)
{
case SP_RED_DRACONIAN: result = "Red"; break;
case SP_WHITE_DRACONIAN: result = "White"; break;
case SP_GREEN_DRACONIAN: result = "Green"; break;
case SP_GOLDEN_DRACONIAN: result = "Yellow"; break;
case SP_GREY_DRACONIAN: result = "Grey"; break;
case SP_BLACK_DRACONIAN: result = "Black"; break;
case SP_PURPLE_DRACONIAN: result = "Purple"; break;
case SP_MOTTLED_DRACONIAN: result = "Mottled"; break;
case SP_PALE_DRACONIAN: result = "Pale"; break;
default:
result = species_name(you.species, 1);
}
result += " ";
return (result);
// Parses a formatted string in much the same way as parse_string, but
// handles EOL by moving the cursor down to the next line instead of
// using a literal EOL. This is important if the text is not supposed
// to clobber existing text to the right of the lines being displayed
// (some of the tutorial messages need this).
//
}
///////////////////////////////////////////////////////////////////////////
// Manual menu highlighter.
class help_highlighter : public MenuHighlighter
{
public:
help_highlighter();
int entry_colour(const MenuEntry *entry) const;
private:
text_pattern pattern;
std::string get_species_key() const;
};
help_highlighter::help_highlighter()
: pattern(get_species_key())
{
}
int help_highlighter::entry_colour(const MenuEntry *entry) const
{
return !pattern.empty() && pattern.matches(entry->text)? WHITE : -1;
}
// to highlight species in aptitudes list ('?%')
std::string help_highlighter::get_species_key() const
{
if (player_genus(GENPC_DRACONIAN) && you.experience_level < 7)
return "";
std::string result = species_name(you.species, you.experience_level);
if (player_genus(GENPC_DRACONIAN))
strip_tag(result,
species_name(you.species, you.experience_level, true));
result += " ";
return (result);