From 630b860361ef96c367743da0da276f320209e61d Mon Sep 17 00:00:00 2001 From: haranp Date: Thu, 31 Jul 2008 12:06:58 +0000 Subject: Implemented basic range darkening while targeting. Nothing uses this yet, I believe, because most calls to direction() use the default range (-1). git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6739 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/directn.cc | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'crawl-ref/source/directn.cc') diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc index dc5240794a..6a5e4897bf 100644 --- a/crawl-ref/source/directn.cc +++ b/crawl-ref/source/directn.cc @@ -511,6 +511,42 @@ static int _mlist_letter_to_index(char idx) } #endif +class range_view_annotator +{ +public: + range_view_annotator(int range) { + orig_colours.init(-1); + if ( range < 0 ) + return; + for ( radius_iterator ri(you.pos(), LOS_RADIUS); ri; ++ri ) + { + if (grid_is_solid(*ri) && grid_distance(you.pos(), *ri) > range) + { + orig_colours(*ri - you.pos() + coord_def(9,9)) = + env.grid_colours( *ri ); + env.grid_colours(*ri) = DARKGREY; + } + } + viewwindow(true, false); + } + + ~range_view_annotator() { + coord_def c; + for ( c.x = 0; c.x < 19; ++c.x ) + { + for ( c.y = 0; c.y < 19; ++c.y ) + { + const int old_colour = orig_colours(c); + if ( old_colour != -1 ) + env.grid_colours(you.pos()+c-coord_def(9,9)) = old_colour; + } + } + viewwindow(true, false); + } +private: + FixedArray orig_colours; +}; + void direction(dist& moves, targeting_type restricts, targ_mode_type mode, int range, bool just_looking, bool needs_path, bool may_target_monster, @@ -560,6 +596,7 @@ void direction(dist& moves, targeting_type restricts, cursor_control con(!Options.use_fake_cursor); mouse_control mc(MOUSE_MODE_TARGET); + range_view_annotator rva(range); int dir = 0; bool show_beam = Options.show_beam && !just_looking && needs_path; -- cgit v1.2.3-54-g00ecf