From f2dadb170e53ea704a03718b1d322a927cd9ff43 Mon Sep 17 00:00:00 2001 From: ennewalker Date: Sun, 11 Jan 2009 22:49:25 +0000 Subject: [2499508] Left-clicking on the minimap now behaves identically to left-clicking on the dungeon (in both travel behavior and shift/ctrl-clicking.) git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8418 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/tilereg.cc | 54 +++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 26 deletions(-) (limited to 'crawl-ref/source/tilereg.cc') diff --git a/crawl-ref/source/tilereg.cc b/crawl-ref/source/tilereg.cc index cc4f543043..4291b18a74 100644 --- a/crawl-ref/source/tilereg.cc +++ b/crawl-ref/source/tilereg.cc @@ -786,6 +786,32 @@ static int _adjacent_cmd(const coord_def &gc, const MouseEvent &event) return 0; } +static int _click_travel(const coord_def &gc, MouseEvent &event) +{ + if (!in_bounds(gc)) + return 0; + + int cmd = _adjacent_cmd(gc, event); + if (cmd) + return cmd; + + if (i_feel_safe()) + { + start_travel(gc); + return CK_MOUSE_CMD; + } + + // If not safe, then take one step towards the click. + travel_pathfind tp; + tp.set_src_dst(you.pos(), gc); + const coord_def dest = tp.pathfind(RMODE_TRAVEL); + + if (!dest.x && !dest.y) + return 0; + + return _adjacent_cmd(dest, event); +} + int DungeonRegion::handle_mouse(MouseEvent &event) { tiles.clear_text_tags(TAG_CELL_DESC); @@ -878,28 +904,7 @@ int DungeonRegion::handle_mouse(MouseEvent &event) if (event.button != MouseEvent::LEFT) return 0; - if (!in_bounds(gc)) - return 0; - - int cmd = _adjacent_cmd(gc, event); - if (cmd) - return cmd; - - if (i_feel_safe()) - { - start_travel(gc); - return CK_MOUSE_CMD; - } - - // If not safe, then take one step towards the click. - travel_pathfind tp; - tp.set_src_dst(you.pos(), gc); - const coord_def dest = tp.pathfind(RMODE_TRAVEL); - - if (!dest.x && !dest.y) - return 0; - - return _adjacent_cmd(dest, event); + return _click_travel(gc, event); } void DungeonRegion::to_screen_coords(const coord_def &gc, coord_def &pc) const @@ -1899,10 +1904,7 @@ int MapRegion::handle_mouse(MouseEvent &event) case MouseEvent::PRESS: if (event.button == MouseEvent::LEFT) { - if (!in_bounds(gc)) - return 0; - - start_travel(gc); + return _click_travel(gc, event); } else if (event.button == MouseEvent::RIGHT) { -- cgit v1.2.3-54-g00ecf