summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crawl-ref/docs/crawl_options.txt25
-rw-r--r--crawl-ref/init.txt3
-rw-r--r--crawl-ref/source/acr.cc5
-rw-r--r--crawl-ref/source/libw32c.cc43
-rw-r--r--crawl-ref/source/view.cc55
5 files changed, 87 insertions, 44 deletions
diff --git a/crawl-ref/docs/crawl_options.txt b/crawl-ref/docs/crawl_options.txt
index 9656bf5bda..331b61f004 100644
--- a/crawl-ref/docs/crawl_options.txt
+++ b/crawl-ref/docs/crawl_options.txt
@@ -76,8 +76,9 @@ The contents of this text are:
note_messages, note_all_spells
6- Miscellaneous.
6-a All OS.
- macro_meta_entry, wiz_mode, colours, char_set, cset_ascii,
- cset_ibm, cset_dec, feature, classic_item_colours
+ macro_meta_entry, mouse_input, wiz_mode, colours,
+ char_set, cset_ascii, cset_ibm, cset_dec, feature,
+ classic_item_colours
6-b DOS and Windows.
dos_use_background_intensity
6-c Unix
@@ -1144,6 +1145,26 @@ macro_meta_entry = true
creating a macro. For instance, if you want to keymap 0 to Escape, you'd
use a target keycode of \{27}.
+mouse_input = false
+ When enabled, the mouse_input option allows the game to use
+ mouse input events on certain platforms (Windows and Unix).
+ Note that the extent of mouse support varies greatly across
+ platforms and is strongly influenced by your terminal
+ settings.
+
+ On Unixes, you're only likely to get mouse support working
+ with ncurses in xterms (specifically your $TERM probably needs
+ to contain "xterm" for ncurses to activate its mouse events;
+ if you're running Crawl in GNU screen in an xterm, the mouse
+ will probably not work).
+
+ On Windows, you'll need to disable QuickEdit Mode on your
+ console for Crawl to use the mouse (QuickEdit is disabled by
+ default, so you shouldn't need to change anything if you're
+ using a stock console). You can disable QuickEdit by
+ right-clicking the titlebar of your command-prompt, selecting
+ Properties and disabling QuickEdit in the Options tab.
+
colour.OLDCOLOUR = NEWCOLOUR
Useful for terminals where some colours are hard to read (and cannot
be adjusted), as well as for creating a custom scheme, especially when
diff --git a/crawl-ref/init.txt b/crawl-ref/init.txt
index 82e76b8e8c..3bdffe37e3 100644
--- a/crawl-ref/init.txt
+++ b/crawl-ref/init.txt
@@ -242,6 +242,9 @@ message_colour = lightcyan:LOW MAGIC WARNING
#
##### 6-a All OS ################################
#
+# macro_meta_entry = false
+# mouse_input = true
+#
# colour.lightgray = black
# colour.lightcyan = cyan
# colour.yellow = brown
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc
index df5ff8929d..43d2a7933d 100644
--- a/crawl-ref/source/acr.cc
+++ b/crawl-ref/source/acr.cc
@@ -1420,7 +1420,12 @@ void process_command( command_type cmd )
break;
case CMD_MOUSE_MOVE:
+ {
+ const coord_def dest = view2grid(crawl_view.mousep);
+ if (in_bounds(dest))
+ terse_describe_square(dest);
break;
+ }
case CMD_MOUSE_CLICK:
{
diff --git a/crawl-ref/source/libw32c.cc b/crawl-ref/source/libw32c.cc
index de676656b7..7d670e25e1 100644
--- a/crawl-ref/source/libw32c.cc
+++ b/crawl-ref/source/libw32c.cc
@@ -86,8 +86,6 @@ static int chsx=0, chex=0, chy=-1;
// cursor position (start at 0,0 --> 1,1)
static int cx=0, cy=0;
-//static FILE *foo = NULL; //DEBUG
-
// and now, for the screen buffer
static CHAR_INFO *screen = NULL;
static COORD screensize;
@@ -792,6 +790,40 @@ int m_getch()
return getch();
}
+static int w32_proc_mouse_event(const MOUSE_EVENT_RECORD &mer)
+{
+ const coord_def pos(mer.dwMousePosition.X + 1, mer.dwMousePosition.Y + 1);
+ crawl_view.mousep = pos;
+
+ if (!crawl_state.mouse_enabled)
+ return (0);
+
+ c_mouse_event cme(pos);
+ if (mer.dwEventFlags & MOUSE_MOVED)
+ return (CK_MOUSE_MOVE);
+
+ if (mer.dwButtonState & FROM_LEFT_1ST_BUTTON_PRESSED)
+ cme.bstate |= c_mouse_event::BUTTON1;
+ else if (mer.dwButtonState & RIGHTMOST_BUTTON_PRESSED)
+ cme.bstate |= c_mouse_event::BUTTON3;
+
+ if ((mer.dwEventFlags & MOUSE_WHEELED) && mer.dwButtonState)
+ {
+ if (!(mer.dwButtonState & 0x10000000UL))
+ cme.bstate |= c_mouse_event::BUTTON_SCRL_UP;
+ else
+ cme.bstate |= c_mouse_event::BUTTON_SCRL_DN;
+ }
+
+ if (cme)
+ {
+ new_mouse_event(cme);
+ return (CK_MOUSE_CLICK);
+ }
+
+ return (0);
+}
+
int getch_ck(void)
{
INPUT_RECORD ir;
@@ -824,7 +856,7 @@ int getch_ck(void)
switch (ir.EventType)
{
case KEY_EVENT:
- kr = &(ir.Event.KeyEvent);
+ kr = &ir.Event.KeyEvent;
// ignore if it is a 'key up' - we only want 'key down'
if (kr->bKeyDown == true)
{
@@ -844,6 +876,11 @@ int getch_ck(void)
case WINDOW_BUFFER_SIZE_EVENT:
w32_handle_resize_event();
break;
+
+ case MOUSE_EVENT:
+ if ((key = w32_proc_mouse_event(ir.Event.MouseEvent)))
+ waiting_for_event = false;
+ break;
}
}
}
diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc
index a3fb63f251..df22892032 100644
--- a/crawl-ref/source/view.cc
+++ b/crawl-ref/source/view.cc
@@ -2255,9 +2255,9 @@ bool is_feature(int feature, int x, int y)
}
}
-static int find_feature(unsigned char feature, int curs_x, int curs_y,
+static int find_feature(int feature, int curs_x, int curs_y,
int start_x, int start_y, int anchor_x, int anchor_y,
- int ignore_count, char *move_x, char *move_y)
+ int ignore_count, int *move_x, int *move_y)
{
int cx = anchor_x,
cy = anchor_y;
@@ -2329,10 +2329,10 @@ void find_features(const std::vector<coord_def>& features,
}
static int find_feature( const std::vector<coord_def>& features,
- unsigned char feature, int curs_x, int curs_y,
+ int feature, int curs_x, int curs_y,
int start_x, int start_y,
int ignore_count,
- char *move_x, char *move_y,
+ int *move_x, int *move_y,
bool forward)
{
int firstx = -1, firsty = -1, firstmatch = -1;
@@ -2517,8 +2517,7 @@ void show_map( FixedVector<int, 2> &spec_place, bool travel_mode )
cursor_control ccon(!Options.use_fake_cursor);
int i, j;
- char move_x = 0;
- char move_y = 0;
+ int move_x = 0, move_y = 0, scroll_y = 0;
int getty = 0;
// Vector to track all features we can travel to, in order of distance.
@@ -2658,7 +2657,7 @@ void show_map( FixedVector<int, 2> &spec_place, bool travel_mode )
move_x = move_y = 0;
break;
}
-
+
case 'b':
case '1':
move_x = -1;
@@ -2750,16 +2749,12 @@ void show_map( FixedVector<int, 2> &spec_place, bool travel_mode )
case '+':
move_y = 20;
move_x = 0;
+ scroll_y = 20;
break;
case '-':
move_y = -20;
move_x = 0;
- break;
- case '!':
- mprf("Terrain seen: %s",
- is_terrain_seen(start_x + curs_x - 1,
- start_y + curs_y - 1)? "yes" : "no");
- more();
+ scroll_y = -20;
break;
case '<':
case '>':
@@ -2827,18 +2822,9 @@ void show_map( FixedVector<int, 2> &spec_place, bool travel_mode )
map_alive = false;
}
else if (cme.scroll_up())
- {
- move_y = -block_step * ((curs_y - top + 1) / block_step + 1);
- move_x = 0;
- }
+ scroll_y = -block_step;
else if (cme.scroll_down())
- {
- move_y =
- block_step *
- ((get_number_of_lines() - curs_y + top - 1) / block_step
- + 1);
- move_x = 0;
- }
+ scroll_y = block_step;
else if (cme.right_clicked())
{
const coord_def delta = grdp - curp;
@@ -2896,23 +2882,14 @@ void show_map( FixedVector<int, 2> &spec_place, bool travel_mode )
{
// Scrolling only happens when we don't have a large enough
// display to show the known map.
- if (getty == '-' || getty == '+')
- {
- if (getty == '-')
- screen_y -= 20;
+ if (scroll_y < 0 && ((screen_y += scroll_y) <= min_y + half_screen))
+ screen_y = min_y + half_screen;
- if (screen_y <= min_y + half_screen)
- screen_y = min_y + half_screen;
-
- if (getty == '+')
- screen_y += 20;
-
- if (screen_y >= max_y - half_screen)
- screen_y = max_y - half_screen;
-
- continue;
- }
+ if (scroll_y > 0 && ((screen_y += scroll_y) >= max_y - half_screen))
+ screen_y = max_y - half_screen;
+ scroll_y = 0;
+
if (curs_y + move_y < 1)
{
screen_y += move_y;