00001
00002
00003
00004
00005
00006
00007
00008 #ifndef DIRECT_H
00009 #define DIRECT_H
00010
00011 #include "describe.h"
00012 #include "externs.h"
00013 #include "enum.h"
00014 #include "ray.h"
00015 #include "state.h"
00016
00017 class range_view_annotator
00018 {
00019 public:
00020 range_view_annotator(int range);
00021 virtual ~range_view_annotator();
00022 };
00023
00024
00025 class targeting_behaviour
00026 {
00027 public:
00028 targeting_behaviour(bool just_looking = false);
00029 virtual ~targeting_behaviour();
00030
00031
00032 virtual int get_key();
00033 virtual command_type get_command(int key = -1);
00034
00035
00036 virtual bool should_redraw() const { return false; }
00037
00038 virtual void clear_redraw() { return; }
00039
00040
00041 virtual void update_top_prompt(std::string* p_top_prompt) {}
00042
00043 private:
00044 std::string prompt;
00045
00046 public:
00047 bool just_looking;
00048 bool compass;
00049 };
00050
00051
00052 class dist
00053 {
00054 public:
00055 dist();
00056
00057 bool isMe() const;
00058 void confusion_fuzz();
00059
00060 bool isValid;
00061 bool isTarget;
00062 bool isEndpoint;
00063 bool isCancel;
00064 bool choseRay;
00065 coord_def target;
00066 coord_def delta;
00067 ray_def ray;
00068 };
00069
00070 struct direction_chooser_args
00071 {
00072 targeting_type restricts;
00073 targ_mode_type mode;
00074 int range;
00075 bool just_looking;
00076 bool needs_path;
00077 bool may_target_monster;
00078 bool may_target_self;
00079 const char *target_prefix;
00080 std::string top_prompt;
00081 targeting_behaviour *behaviour;
00082 bool cancel_at_self;
00083 bool show_floor_desc;
00084
00085 direction_chooser_args() :
00086 restricts(DIR_NONE),
00087 mode(TARG_ANY),
00088 range(-1),
00089 just_looking(false),
00090 needs_path(true),
00091 may_target_monster(true),
00092 may_target_self(false),
00093 target_prefix(NULL),
00094 behaviour(NULL),
00095 cancel_at_self(false),
00096 show_floor_desc(false) {}
00097 };
00098
00099 class direction_chooser
00100 {
00101 public:
00102 direction_chooser(dist& moves, const direction_chooser_args& args);
00103 bool choose_direction();
00104
00105 private:
00106 bool choose_compass();
00107
00108 bool do_main_loop();
00109
00110
00111 coord_def find_default_target() const;
00112
00113 void handle_mlist_cycle_command(command_type key_command);
00114 void handle_wizard_command(command_type key_command, bool* loop_done);
00115 void handle_movement_key(command_type key_command, bool* loop_done);
00116
00117 bool in_range(const coord_def& p) const;
00118
00119
00120 void move_to_you();
00121
00122
00123 void object_cycle(int dir);
00124
00125
00126 void monster_cycle(int dir);
00127
00128
00129 void feature_cycle_forward(int feature);
00130
00131
00132 void update_previous_target() const;
00133
00134
00135
00136 bool select(bool allow_out_of_range, bool endpoint);
00137 bool select_compass_direction(const coord_def& delta);
00138 bool select_previous_target();
00139
00140
00141 bool handle_signals();
00142
00143 void reinitialize_move_flags();
00144
00145
00146 const coord_def& target() const;
00147 void set_target(const coord_def& new_target);
00148
00149 std::string build_targeting_hint_string() const;
00150
00151 actor* targeted_actor() const;
00152 monster* targeted_monster() const;
00153
00154
00155
00156
00157
00158
00159
00160 void print_top_prompt() const;
00161
00162
00163 void print_key_hints() const;
00164
00165
00166
00167
00168
00169 void print_target_description(bool &did_cloud) const;
00170
00171
00172 void print_target_monster_description(bool &did_cloud) const;
00173 void print_target_object_description() const;
00174
00175
00176
00177 void print_items_description() const;
00178
00179
00180
00181
00182
00183 void print_floor_description(bool boring_too) const;
00184
00185 std::string target_interesting_terrain_description() const;
00186 std::string target_cloud_description() const;
00187 std::string target_sanctuary_description() const;
00188 std::string target_silence_description() const;
00189 std::vector<std::string> target_cell_description_suffixes() const;
00190 std::vector<std::string> monster_description_suffixes(
00191 const monster_info& mi) const;
00192
00193 void describe_cell() const;
00194
00195
00196
00197
00198 bool tiles_update_target();
00199
00200
00201 void show_initial_prompt();
00202
00203 void toggle_beam();
00204
00205 void finalize_moves();
00206 command_type massage_command(command_type key_command) const;
00207 void draw_beam_if_needed();
00208 void do_redraws();
00209
00210
00211 bool looking_at_you() const;
00212
00213
00214 bool move_is_ok() const;
00215
00216 void cycle_targeting_mode();
00217
00218 void describe_target();
00219 void show_help();
00220
00221
00222 dist& moves;
00223 targeting_type restricts;
00224 targ_mode_type mode;
00225 int range;
00226 bool just_looking;
00227 bool needs_path;
00228 bool may_target_monster;
00229 bool may_target_self;
00230 const char *target_prefix;
00231 std::string top_prompt;
00232 targeting_behaviour *behaviour;
00233 bool cancel_at_self;
00234 bool show_floor_desc;
00235
00236
00237 ray_def beam;
00238 bool show_beam;
00239 bool have_beam;
00240 coord_def objfind_pos, monsfind_pos;
00241
00242
00243 bool need_beam_redraw;
00244 bool need_cursor_redraw;
00245 bool need_text_redraw;
00246 bool need_all_redraw;
00247
00248 bool show_items_once;
00249 bool target_unshifted;
00250
00251
00252 static targeting_behaviour stock_behaviour;
00253
00254 };
00255
00256 #ifndef USE_TILE
00257 char mlist_index_to_letter(int index);
00258 #endif
00259
00260 void direction(dist &moves, const direction_chooser_args& args);
00261
00262 std::string thing_do_grammar(description_level_type dtype,
00263 bool add_stop,
00264 bool force_article,
00265 std::string desc);
00266
00267 std::string get_terse_square_desc(const coord_def &gc);
00268 void terse_describe_square(const coord_def &c, bool in_range = true);
00269 void full_describe_square(const coord_def &c);
00270 void get_square_desc(const coord_def &c, describe_info &inf,
00271 bool examine_mons = false, bool show_floor = false);
00272
00273 void describe_floor();
00274 std::string get_monster_equipment_desc(const monster_info& mi,
00275 bool full_desc = true,
00276 description_level_type mondtype = DESC_CAP_A,
00277 bool print_attitude = false);
00278
00279 int dos_direction_unmunge(int doskey);
00280
00281 std::string feature_description(const coord_def& where, bool covering = false,
00282 description_level_type dtype = DESC_CAP_A,
00283 bool add_stop = true, bool base_desc = false);
00284 std::string raw_feature_description(dungeon_feature_type grid,
00285 trap_type tr = NUM_TRAPS,
00286 bool base_desc = false);
00287 std::string feature_description(dungeon_feature_type grid,
00288 trap_type trap = NUM_TRAPS,
00289 const std::string & cover_desc = "",
00290 description_level_type dtype = DESC_CAP_A,
00291 bool add_stop = true, bool base_desc = false);
00292
00293 void set_feature_desc_short(dungeon_feature_type grid,
00294 const std::string &desc);
00295 void set_feature_desc_short(const std::string &base_name,
00296 const std::string &desc);
00297
00298 void setup_feature_descs_short();
00299
00300 std::vector<dungeon_feature_type> features_by_desc(const base_pattern &pattern);
00301
00302 void full_describe_view(void);
00303
00304 extern const struct coord_def Compass[8];
00305
00306 #endif