summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/skill_menu.h
diff options
context:
space:
mode:
authorRaphael Langella <raphael.langella@gmail.com>2011-07-03 15:19:24 +0200
committerRaphael Langella <raphael.langella@gmail.com>2011-07-04 23:58:53 +0200
commit55d5b58761fe2065f5126ca3fc3b48f3cff50236 (patch)
tree1277b0e593998dd4508ba00ecb4a5b29b87b0a9e /crawl-ref/source/skill_menu.h
parent49f5b3ea6cabf83a2bf369cec84ef5fcfb9152d4 (diff)
downloadcrawl-ref-55d5b58761fe2065f5126ca3fc3b48f3cff50236.tar.gz
crawl-ref-55d5b58761fe2065f5126ca3fc3b48f3cff50236.zip
New skill menu switches.
And a lot of rewritting and cleaning up.
Diffstat (limited to 'crawl-ref/source/skill_menu.h')
-rw-r--r--crawl-ref/source/skill_menu.h180
1 files changed, 105 insertions, 75 deletions
diff --git a/crawl-ref/source/skill_menu.h b/crawl-ref/source/skill_menu.h
index d884cf48a8..ea49f0d837 100644
--- a/crawl-ref/source/skill_menu.h
+++ b/crawl-ref/source/skill_menu.h
@@ -7,7 +7,6 @@
#ifndef SKILLS_MENU_H
#define SKILLS_MENU_H
-#include <queue>
#include "enum.h"
#include "menu.h"
#include "skills2.h"
@@ -16,28 +15,46 @@
enum skill_menu_flags
{
-//Actions
- SKMF_DO_PRACTISE = 0x0001,
- SKMF_DO_SHOW_DESC = 0x0002,
- SKMF_DO_RESKILL_FROM = 0x0004,
- SKMF_DO_RESKILL_TO = 0x0008,
- SKMF_ACTION_MASK = 0x000F,
-
-//Display
- SKMF_DISP_NORMAL = 0x0010,
- SKMF_DISP_ENHANCED = 0x0020,
- SKMF_DISP_RESKILL = 0x0040,
- SKMF_DISP_NEW_LEVEL = 0x0080,
- SKMF_DISP_POINTS = 0x0100,
- SKMF_DISP_MASK = 0x01F0,
- SKMF_DISP_ALL = 0x0200,
- SKMF_DISP_APTITUDE = 0x0400,
-
-//Ashenzari transfer knowledge ability set this flag.
- SKMF_RESKILLING = 0x0800,
-
- SKMF_SKILL_ICONS = 0x1000,
- SKMF_SIMPLE = 0x2000, // Simple mode for tutorial and hint mode.
+ //Ashenzari transfer knowledge ability.
+ SKMF_RESKILLING = 1<<0,
+ SKMF_RESKILL_FROM = 1<<1,
+ SKMF_RESKILL_TO = 1<<2,
+
+ SKMF_CROSSTRAIN = 1<<3,
+ SKMF_ANTITRAIN = 1<<4,
+ SKMF_ENHANCED = 1<<5,
+ SKMF_REDUCED = 1<<6,
+ SKMF_CHANGED = SKMF_ENHANCED | SKMF_REDUCED,
+
+ SKMF_SKILL_ICONS = 1<<7,
+ SKMF_APTITUDE = 1<<8,
+ SKMF_SIMPLE = 1<<9, // Simple mode for tutorial and hint mode.
+};
+
+enum skill_menu_switch
+{
+ SKM_MODE = -1,
+ SKM_DO = -2,
+ SKM_SHOW = -3,
+ SKM_LEVEL = -4,
+ SKM_VIEW = -5,
+};
+
+enum skill_menu_state
+{
+ SKM_NONE,
+ SKM_MODE_AUTO,
+ SKM_MODE_MANUAL,
+ SKM_DO_PRACTISE,
+ SKM_DO_DESCRIBE,
+ SKM_SHOW_KNOWN,
+ SKM_SHOW_ALL,
+ SKM_LEVEL_ENHANCED,
+ SKM_LEVEL_NORMAL,
+ SKM_VIEW_TRAINING,
+ SKM_VIEW_PROGRESS,
+ SKM_VIEW_TRANSFER,
+ SKM_VIEW_POINTS,
};
class SkillMenu;
@@ -49,16 +66,16 @@ public:
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();
- void refresh(bool keep_hotkey);
+ SkillMenuEntry(coord_def coord);
int get_id();
- bool is_set(int flag) const;
- bool is_selectable(bool keep_hotkey = true);
TextItem* get_name_item() const;
+ skill_type get_skill() const;
+ bool is_selectable(bool keep_hotkey = true);
+ bool is_set(int flag) const;
+ void refresh(bool keep_hotkey);
+ void set_display();
+ void set_name(bool keep_hotkey);
+ void set_skill(skill_type sk = SK_NONE);
private:
skill_type m_sk;
@@ -71,18 +88,40 @@ private:
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();
+ COLORS get_colour() const;
+ std::string get_prefix();
+ void set_aptitude();
+ void set_level();
+ void set_new_level();
#ifdef DEBUG_DIAGNOSTICS
- void _set_points();
+ void set_points();
#endif
+ void set_progress();
+ void set_reskill_progress();
+ void set_title();
+ void set_training();
+};
+
+class SkillMenuSwitch : public FormattedTextItem
+{
+public:
+ static SkillMenu* m_skm;
+
+ SkillMenuSwitch(std::string name, int hotkey);
+ void add(skill_menu_state state);
+ std::string get_help();
+ std::string get_name(skill_menu_state state);
+ skill_menu_state get_state();
+ void set_state(skill_menu_state state);
+ int size() const;
+ bool toggle();
+ void update();
+
+private:
+ std::string m_name;
+ skill_menu_state m_state;
+ std::vector<skill_menu_state> m_states;
};
static const int SK_ARR_LN = (ndisplayed_skills - 1) / 2;
@@ -92,57 +131,48 @@ class SkillMenu : public PrecisionMenu
{
public:
SkillMenu(bool reskilling);
+
+ void clear_flag(int flag);
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(bool init = false);
- void toggle_practise(skill_type sk, int keyn);
- void show_description(skill_type sk);
- void toggle_show_all();
+
+ void add_item(TextItem* item, const int size, coord_def &coord);
void clear_selections();
+ skill_menu_state get_state(skill_menu_switch sw);
+ void select(skill_type sk, int keyn);
+ void toggle(skill_menu_switch sw);
private:
MenuFreeform* m_ff;
BoxMenuHighlighter* m_highlighter;
int m_flags;
- int m_current_help;
coord_def m_min_coord;
coord_def m_max_coord;
coord_def m_pos;
- bool m_crosstrain;
- bool m_antitrain;
- bool m_enhanced;
- bool m_reduced;
-
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_flags(bool reskilling);
- 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 = 0);
- 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;
+
+ std::map<skill_menu_switch, SkillMenuSwitch*> m_switches;
+
+ SkillMenuEntry* find_entry(skill_type sk);
+ void init_flags(bool reskilling);
+ void init_help();
+ void init_title();
+ void init_switches();
+ void refresh_display();
+ void refresh_names();
+ void set_default_help();
+ void set_help(std::string msg);
+ void set_skills();
+ void set_title();
+ void show_description(skill_type sk);
+ void toggle_practise(skill_type sk, int keyn);
+
+ TextItem* find_closest_selectable(int start_ln, int col);
+ void set_links();
};
#endif