summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/view.cc
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-06-20 19:00:52 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-06-20 19:00:52 +0000
commit8ad4f44fa747a32e0d476971beeaf2c0550f16e5 (patch)
tree4cb0fa4b6f7cfc3fd7068ebee1564e1ade6bb2a6 /crawl-ref/source/view.cc
parent2d4c05e46de7f35c454f1dfbf3892ad589038a58 (diff)
downloadcrawl-ref-8ad4f44fa747a32e0d476971beeaf2c0550f16e5.tar.gz
crawl-ref-8ad4f44fa747a32e0d476971beeaf2c0550f16e5.zip
Experimental mouse support for ncurses (enable with mouse_input=yes in
.crawlrc). git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1610 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/view.cc')
-rw-r--r--crawl-ref/source/view.cc47
1 files changed, 45 insertions, 2 deletions
diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc
index fe384a5809..a3fb63f251 100644
--- a/crawl-ref/source/view.cc
+++ b/crawl-ref/source/view.cc
@@ -37,6 +37,7 @@
#include "externs.h"
#include "command.h"
+#include "cio.h"
#include "cloud.h"
#include "clua.h"
#include "debug.h"
@@ -2518,7 +2519,7 @@ void show_map( FixedVector<int, 2> &spec_place, bool travel_mode )
char move_x = 0;
char move_y = 0;
- char getty = 0;
+ int getty = 0;
// Vector to track all features we can travel to, in order of distance.
std::vector<coord_def> features;
@@ -2605,8 +2606,10 @@ void show_map( FixedVector<int, 2> &spec_place, bool travel_mode )
redraw_map = true;
cursorxy(curs_x, curs_y + top - 1);
+ c_input_reset(true);
getty = unmangle_direction_keys(getchm(KC_LEVELMAP), KC_LEVELMAP,
false, false);
+ c_input_reset(false);
switch (getty)
{
@@ -2641,7 +2644,7 @@ void show_map( FixedVector<int, 2> &spec_place, bool travel_mode )
move_x = move_y = 0;
break;
}
-
+
case CONTROL('E'):
case CONTROL('X'):
{
@@ -2805,6 +2808,46 @@ void show_map( FixedVector<int, 2> &spec_place, bool travel_mode )
search_found, &move_x, &move_y);
break;
}
+
+ case CK_MOUSE_MOVE:
+ move_x = move_y = 0;
+ break;
+
+ case CK_MOUSE_CLICK:
+ {
+ const c_mouse_event cme = get_mouse_event();
+ const coord_def curp(start_x + curs_x - 1, start_y + curs_y - 1);
+ const coord_def grdp =
+ cme.pos + coord_def(start_x - 1, start_y - top);
+
+ if (cme.left_clicked() && in_bounds(grdp))
+ {
+ spec_place[0] = grdp.x;
+ spec_place[1] = grdp.y;
+ map_alive = false;
+ }
+ else if (cme.scroll_up())
+ {
+ move_y = -block_step * ((curs_y - top + 1) / block_step + 1);
+ move_x = 0;
+ }
+ else if (cme.scroll_down())
+ {
+ move_y =
+ block_step *
+ ((get_number_of_lines() - curs_y + top - 1) / block_step
+ + 1);
+ move_x = 0;
+ }
+ else if (cme.right_clicked())
+ {
+ const coord_def delta = grdp - curp;
+ move_y = delta.y;
+ move_x = delta.x;
+ }
+ break;
+ }
+
case '.':
case '\r':
case 'S':