MCPcopy Create free account
hub / github.com/crawl/crawl / SpellLibraryMenu

Method SpellLibraryMenu

crawl-ref/source/spl-book.cc:855–933  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

853
854public:
855 SpellLibraryMenu(spell_list& list, action _default_action)
856 : Menu(MF_SINGLESELECT | MF_ALLOW_FORMATTING
857 | MF_ARROWS_SELECT | MF_INIT_HOVER | MF_SHOW_EMPTY
858 // To have the ctrl-f menu show up in webtiles
859 | MF_ALLOW_FILTER, "spell"),
860 current_action(_default_action),
861 default_action(_default_action),
862 spells(list),
863 hidden_count(0)
864 {
865 set_highlighter(nullptr);
866 // Actual text handled by calc_title
867 set_title(new MenuEntry(""), true, true);
868
869 if (you.divine_exegesis)
870 {
871 spell_levels_str = make_stringf(
872 "<lightgreen>Select a spell to cast with Divine Exegesis: %d MP available</lightgreen>",
873 you.magic_points);
874 }
875 else if (default_action == action::imbue)
876 spell_levels_str = "<lightgreen>Select a spell to imbue your Spellspark Servitor with:</lightgreen>";
877 else
878 {
879 spell_levels_str = make_stringf("<lightgreen>%d spell level%s"
880 "</lightgreen>", player_spell_levels(),
881 (player_spell_levels() > 1 || player_spell_levels() == 0)
882 ? "s left" : " left ");
883 if (player_spell_levels() < 9)
884 spell_levels_str += " ";
885 }
886
887#ifdef USE_TILE_LOCAL
888 FontWrapper *font = tiles.get_crt_font();
889 int title_width = font->string_width(calc_title());
890 m_ui.vbox->min_size().width = 38 + title_width + 10;
891#endif
892 m_ui.scroller->expand_v = true; // TODO: doesn't work on webtiles
893
894 update_entries();
895 update_more();
896
897 on_examine = [](const MenuEntry& item)
898 {
899 const spell_type spell = *static_cast<spell_type*>(item.data);
900 ASSERT(is_valid_spell(spell));
901 describe_spell(spell, nullptr);
902 return true;
903 };
904
905 on_single_selection = [this](const MenuEntry& item)
906 {
907 const spell_type spell = *static_cast<spell_type*>(item.data);
908 ASSERT(is_valid_spell(spell));
909
910 switch (current_action)
911 {
912 case action::memorise:

Callers

nothing calls this directly

Calls 11

make_stringfFunction · 0.85
player_spell_levelsFunction · 0.85
update_moreFunction · 0.85
is_valid_spellFunction · 0.85
update_menuFunction · 0.85
get_crt_fontMethod · 0.80
string_widthMethod · 0.80
describe_spellFunction · 0.70
sizeMethod · 0.45
setMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected