diff options
-rw-r--r-- | crawl-ref/source/direct.cc | 27 | ||||
-rw-r--r-- | crawl-ref/source/externs.h | 2 | ||||
-rw-r--r-- | crawl-ref/source/initfile.cc | 6 |
3 files changed, 32 insertions, 3 deletions
diff --git a/crawl-ref/source/direct.cc b/crawl-ref/source/direct.cc index eeb58d7532..0aebaf1a28 100644 --- a/crawl-ref/source/direct.cc +++ b/crawl-ref/source/direct.cc @@ -98,10 +98,19 @@ static bool is_mapped(int x, int y) return (is_player_mapped(x, y)); } -static command_type read_direction_key(bool just_looking = false) +static command_type read_direction_key( + bool just_looking = false, + bool target_unshifted = false, + coord_def where = coord_def()) { + const bool unshifted_dir = target_unshifted && where == you.pos(); + flush_input_buffer( FLUSH_BEFORE_COMMAND ); - const int key = unmangle_direction_keys(getchm(KC_TARGETING),KC_TARGETING); + + int key = unmangle_direction_keys(getchm(KC_TARGETING),KC_TARGETING); + if (unshifted_dir && strchr("hjklyubn", key)) + key = toupper(key); + switch ( key ) { case ESCAPE: return CMD_TARGET_CANCEL; @@ -278,6 +287,7 @@ void direction(struct dist& moves, targeting_type restricts, bool skip_iter = false; bool found_autotarget = false; + bool target_unshifted = Options.target_unshifted_dirs; // Find a default target if ( Options.default_target && mode == TARG_ENEMY ) @@ -325,7 +335,18 @@ void direction(struct dist& moves, targeting_type restricts, key_command = CMD_TARGET_CYCLE_FORWARD; // find closest enemy } else - key_command = read_direction_key(just_looking); + key_command = read_direction_key(just_looking, + target_unshifted, + coord_def(moves.tx, moves.ty)); + + if (target_unshifted && + (key_command == CMD_TARGET_CYCLE_FORWARD + || key_command == CMD_TARGET_CYCLE_BACK + || key_command == CMD_TARGET_OBJ_CYCLE_FORWARD + || key_command == CMD_TARGET_OBJ_CYCLE_BACK)) + { + target_unshifted = false; + } bool need_beam_redraw = false; bool force_redraw = false; diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h index c5d6b6f3f4..3fcb868c51 100644 --- a/crawl-ref/source/externs.h +++ b/crawl-ref/source/externs.h @@ -1238,6 +1238,8 @@ public: bool target_los_first; // 'x' look around first goes to visible // objects/features, then goes to stuff // outside LOS. + bool target_unshifted_dirs; // Unshifted keys target if cursor is + // on player. int drop_mode; // Controls whether single or multidrop // is the default. diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc index 01764ac3ba..f99126ff23 100644 --- a/crawl-ref/source/initfile.cc +++ b/crawl-ref/source/initfile.cc @@ -665,6 +665,8 @@ void game_options::reset_options() target_wrap = true; target_oos = true; target_los_first = true; + target_unshifted_dirs = false; + dump_kill_places = KDO_ONE_PLACE; dump_message_count = 7; dump_item_origins = IODS_ARTIFACTS | IODS_RODS; @@ -2227,6 +2229,10 @@ void game_options::read_option_line(const std::string &str, bool runscript) { target_los_first = read_bool(field, target_los_first); } + else if (key == "target_unshifted_dirs") + { + target_unshifted_dirs = read_bool(field, target_unshifted_dirs); + } else if (key == "drop_mode") { if (field.find("multi") != std::string::npos) |