From af3cd3ff34ef5da884b2c673afe1321f0cf372e7 Mon Sep 17 00:00:00 2001 From: ennewalker Date: Tue, 15 Jul 2008 04:07:07 +0000 Subject: Large tiles-related changes. Platform-specific rendering removed and replaced with SDL/OpenGL. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6550 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/directn.cc | 41 +++++++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 8 deletions(-) (limited to 'crawl-ref/source/directn.cc') diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc index 746ac18bb3..c16b552c6b 100644 --- a/crawl-ref/source/directn.cc +++ b/crawl-ref/source/directn.cc @@ -121,16 +121,45 @@ void direction_choose_compass( dist& moves, targeting_behaviour *beh) moves.isCancel = false; moves.dx = moves.dy = 0; -#ifdef USE_TILE mouse_control mc(MOUSE_MODE_TARGET_DIR); -#endif beh->compass = true; +#ifdef USE_TILE + // Force update of mouse cursor to direction-compatible location. + tiles.place_cursor(CURSOR_MOUSE, tiles.get_cursor()); +#endif + do { const command_type key_command = beh->get_command(); +#ifdef USE_TILE + if (key_command == CMD_TARGET_MOUSE_MOVE) + { + continue; + } + else if (key_command == CMD_TARGET_MOUSE_SELECT) + { + const coord_def &gc = tiles.get_cursor(); + if (gc == Region::NO_CURSOR) + continue; + + coord_def delta = gc - you.pos(); + if (delta.x < -1 || delta.x > 1 + || delta.y < -1 || delta.y > 1) + { + // This shouldn't happen. + continue; + } + + moves.dx = delta.x; + moves.dy = delta.y; + moves.isMe = (delta.x == 0) && (delta.y == 0); + break; + } +#endif + if (key_command == CMD_TARGET_SELECT) { moves.dx = moves.dy = 0; @@ -597,9 +626,7 @@ void direction(dist& moves, targeting_type restricts, } else { -#ifdef USE_TILE mouse_control mc(MOUSE_MODE_TARGET); -#endif key_command = beh->get_command(); } @@ -608,8 +635,8 @@ void direction(dist& moves, targeting_type restricts, if (key_command == CMD_TARGET_MOUSE_MOVE || key_command == CMD_TARGET_MOUSE_SELECT) { - coord_def gc; - if (gui_get_mouse_grid_pos(gc)) + const coord_def &gc = tiles.get_cursor(); + if (gc != Region::NO_CURSOR) { moves.tx = gc.x; moves.ty = gc.y; @@ -2663,9 +2690,7 @@ targeting_behaviour::~targeting_behaviour() int targeting_behaviour::get_key() { -#ifdef USE_TILE mouse_control mc(MOUSE_MODE_TARGET_DIR); -#endif if (!crawl_state.is_replaying_keys()) flush_input_buffer(FLUSH_BEFORE_COMMAND); -- cgit v1.2.3-54-g00ecf