summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/skills2.h
diff options
context:
space:
mode:
authorAdam Borowski <kilobyte@angband.pl>2011-01-05 13:10:51 +0100
committerAdam Borowski <kilobyte@angband.pl>2011-01-05 13:10:51 +0100
commit90ec54410b65d43855db7a68348ede3908979558 (patch)
tree9cf053445bb26b6f06422eb2290a140546812d1e /crawl-ref/source/skills2.h
parent11214880ea8006145d52dc12ab3cb3511d033835 (diff)
parentfd18e77ace0f15f861fa5a74c583966cccfd2ac6 (diff)
downloadcrawl-ref-90ec54410b65d43855db7a68348ede3908979558.tar.gz
crawl-ref-90ec54410b65d43855db7a68348ede3908979558.zip
Merge branch 'master' into ench-split
Diffstat (limited to 'crawl-ref/source/skills2.h')
-rw-r--r--crawl-ref/source/skills2.h186
1 files changed, 172 insertions, 14 deletions
diff --git a/crawl-ref/source/skills2.h b/crawl-ref/source/skills2.h
index 12a7806ec2..076d90934e 100644
--- a/crawl-ref/source/skills2.h
+++ b/crawl-ref/source/skills2.h
@@ -10,19 +10,11 @@
const int MAX_SKILL_ORDER = 100;
+#include <queue>
#include "enum.h"
+#include "menu.h"
#include "player.h"
-enum sk_menu_flags
-{
- SK_MENU_NONE = 0,
- SK_MENU_SHOW_APT = 0x01,
- SK_MENU_SHOW_DESC = 0x02,
- SK_MENU_SHOW_RESKILL = 0x04,
- SK_MENU_SHOW_ALL = 0x08,
- SK_MENU_RESKILL = 0x10
-};
-
int get_skill_percentage(const skill_type x);
const char *skill_name(skill_type which_skill);
skill_type str_to_skill(const std::string &skill);
@@ -53,15 +45,181 @@ unsigned int skill_exp_needed(int lev, skill_type sk,
species_type sp = you.species);
float crosstrain_bonus(skill_type sk);
-bool crosstrain_other(skill_type sk);
+bool crosstrain_other(skill_type sk, bool show_zero);
bool is_antitrained(skill_type sk);
-bool antitrain_other(skill_type sk);
+bool antitrain_other(skill_type sk, bool show_zero);
-void show_skills();
+void skill_menu(bool reskilling = false);
void wield_warning(bool newWeapon = true);
bool is_invalid_skill(skill_type skill);
void dump_skills(std::string &text);
-skill_type select_skill(bool show_all = false);
+int skill_transfer_amount(skill_type sk);
int transfer_skill_points(skill_type fsk, skill_type tsk, int skp_max,
bool simu);
+
+static const skill_type skill_display_order[] =
+{
+ SK_TITLE,
+ SK_FIGHTING, SK_SHORT_BLADES, SK_LONG_BLADES, SK_AXES,
+ SK_MACES_FLAILS, SK_POLEARMS, SK_STAVES, SK_UNARMED_COMBAT,
+
+ SK_BLANK_LINE,
+
+ SK_BOWS, SK_CROSSBOWS, SK_THROWING, SK_SLINGS,
+
+ SK_BLANK_LINE,
+
+ SK_ARMOUR, SK_DODGING, SK_STEALTH, SK_SHIELDS,
+
+ SK_COLUMN_BREAK, SK_TITLE,
+
+ SK_STABBING, SK_TRAPS_DOORS,
+
+ SK_BLANK_LINE,
+
+ SK_SPELLCASTING, SK_CONJURATIONS, SK_HEXES, SK_CHARMS, SK_SUMMONINGS,
+ SK_NECROMANCY, SK_TRANSLOCATIONS, SK_TRANSMUTATIONS,
+ SK_FIRE_MAGIC, SK_ICE_MAGIC, SK_AIR_MAGIC, SK_EARTH_MAGIC, SK_POISON_MAGIC,
+
+ SK_BLANK_LINE,
+
+ SK_INVOCATIONS, SK_EVOCATIONS,
+
+ SK_COLUMN_BREAK,
+};
+
+static const int ndisplayed_skills =
+ sizeof(skill_display_order) / sizeof(*skill_display_order);
+
+// Skill Menu
+
+enum skill_menu_flags
+{
+ SKMF_NONE = 0,
+
+//Actions
+ SKMF_DO_PRACTISE = 0x001,
+ SKMF_DO_SHOW_DESC = 0x002,
+ SKMF_DO_RESKILL_FROM = 0x004,
+ SKMF_DO_RESKILL_TO = 0x008,
+ SKMF_ACTION_MASK = 0x00F,
+
+//Display
+ SKMF_DISP_PROGRESS = 0x010,
+ SKMF_DISP_RESKILL = 0x020,
+ SKMF_DISP_NEW_LEVEL = 0x040,
+ SKMF_DISP_POINTS = 0x080,
+ SKMF_DISP_MASK = 0x0F0,
+ SKMF_DISP_ALL = 0x100,
+ SKMF_DISP_APTITUDE = 0x200,
+
+//Ashenzari transfer knowledge ability set this flag.
+ SKMF_RESKILLING = 0x400,
+
+ SKMF_SKILL_ICONS = 0x800,
+};
+
+class SkillMenu;
+
+class SkillMenuEntry
+{
+public:
+ static menu_letter m_letter;
+ static SkillMenu* m_skm;
+
+ SkillMenuEntry() {};
+ SkillMenuEntry(coord_def coord, MenuFreeform* ff);
+ void set_skill(skill_type sk = SK_NONE);
+ skill_type get_skill() const;
+ void set_name(bool keep_hotkey);
+ void set_display();
+ int get_id();
+ bool is_set(int flag) const;
+ bool is_selectable() const;
+ TextItem* get_name_item() const;
+
+private:
+ skill_type m_sk;
+
+ TextItem* m_name;
+#ifdef USE_TILE
+ TextTileItem* m_name_tile;
+#endif
+ NoSelectTextItem* m_level;
+ NoSelectTextItem* m_progress;
+ FormattedTextItem* m_aptitude;
+
+ COLORS _get_colour() const;
+ std::string _get_prefix();
+ void _set_level();
+ void _set_progress();
+ void _set_aptitude();
+ void _set_reskill_progress();
+ void _set_new_level();
+ void _set_title();
+ void _clear();
+#ifdef DEBUG_DIAGNOSTICS
+ void _set_points();
+#endif
+};
+
+static const int SK_ARR_LN = (ndisplayed_skills - 1) / 2;
+static const int SK_ARR_COL = 2;
+
+class SkillMenu : public PrecisionMenu
+{
+public:
+ SkillMenu(int flags);
+ bool is_set(int flag) const;
+ void set_flag(int flag);
+ void clear_flag(int flag);
+ void toggle_flag(int flag);
+ void change_action();
+ void change_display();
+ void toggle_practise(skill_type sk, int keyn);
+ void show_description(skill_type sk);
+ void toggle_show_all();
+ void clear_selections();
+ void set_crosstrain();
+ void set_antitrain();
+
+private:
+ MenuFreeform* m_ff;
+ BoxMenuHighlighter* m_highlighter;
+
+ int m_flags;
+ int m_current_help;
+ coord_def m_min_coord;
+ coord_def m_max_coord;
+
+ bool m_crosstrain;
+ bool m_antitrain;
+
+ SkillMenuEntry m_skills[SK_ARR_LN][SK_ARR_COL];
+
+ NoSelectTextItem* m_title;
+ FormattedTextItem* m_help;
+ NoSelectTextItem* m_current_action;
+ TextItem* m_next_action;
+ TextItem* m_next_display;
+ TextItem* m_show_all;
+
+ std::queue<int> m_disp_queue;
+
+ SkillMenuEntry* _find_entry(skill_type sk);
+ void _init_disp_queue();
+ void _init_title();
+ void _init_footer(coord_def coord);
+ void _refresh_display();
+ void _refresh_names();
+ void _set_title();
+ void _set_skills();
+ void _set_help(int flag = SKMF_NONE);
+ void _set_footer();
+ TextItem* _find_closest_selectable(int start_ln, int col);
+ void _set_links();
+ int _get_next_action() const;
+ int _get_next_display() const;
+};
+
#endif