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

Function skill_menu

crawl-ref/source/skill-menu.cc:1815–1931  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1813#endif
1814
1815void skill_menu(int flag, int exp)
1816{
1817 // experience potion; you may elect to put experience in normally
1818 // untrainable skills (e.g. skills that your god hates). The only
1819 // case where we abort is if all in-principle trainable skills are maxed.
1820 if (flag & SKMF_EXPERIENCE && !trainable_skills(true))
1821 {
1822 mpr("You feel omnipotent.");
1823 return;
1824 }
1825
1826 unwind_bool xp_gain(crawl_state.simulating_xp_gain, flag & SKMF_EXPERIENCE);
1827
1828 // notify the player again
1829 you.received_noskill_warning = false;
1830
1831 you.exp_available += exp;
1832
1833 bool done = false;
1834 auto skill_menu_ui = make_shared<UISkillMenu>(flag);
1835 auto popup = make_shared<ui::Popup>(skill_menu_ui);
1836
1837 skill_menu_ui->on_keydown_event([&done, &skill_menu_ui](const KeyEvent& ev) {
1838 const auto keyn = numpad_to_regular(ev.key(), true);
1839
1840 skill_menu_ui->_expose();
1841
1842 if (!skm.process_key(keyn))
1843 {
1844 switch (keyn)
1845 {
1846 case CK_UP:
1847 case CK_DOWN:
1848 case CK_LEFT:
1849 case CK_RIGHT:
1850 return true;
1851 case CK_ENTER:
1852 if (!skm.is_set(SKMF_EXPERIENCE))
1853 return true;
1854 // Fallthrough. In experience mode, you can exit with enter.
1855 case CK_ESCAPE:
1856 // Escape cancels help if it is being displayed.
1857 if (skm.is_set(SKMF_HELP))
1858 {
1859 skm.cancel_help();
1860 return true;
1861 }
1862 else if (skm.is_set(SKMF_SET_TARGET))
1863 {
1864 skm.cancel_set_target();
1865 return true;
1866 }
1867 // Fallthrough
1868 default:
1869 if (ui::key_exits_popup(keyn, true) && skm.exit(false))
1870 return done = true;
1871 // Don't exit from !experience on random keys.
1872 if (!skm.is_set(SKMF_EXPERIENCE) && skm.exit(false))

Callers 4

process_commandFunction · 0.85
check_selected_skillsFunction · 0.85
fixup_skillsFunction · 0.85
effectMethod · 0.85

Calls 15

trainable_skillsFunction · 0.85
mprFunction · 0.85
numpad_to_regularFunction · 0.85
key_exits_popupFunction · 0.85
dprfFunction · 0.85
is_invalid_skillFunction · 0.85
run_layoutFunction · 0.85
keyMethod · 0.80
_exposeMethod · 0.80
cancel_helpMethod · 0.80
cancel_set_targetMethod · 0.80
exitMethod · 0.80

Tested by

no test coverage detected