| 853 | |
| 854 | public: |
| 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: |
nothing calls this directly
no test coverage detected