diff options
-rw-r--r-- | crawl-ref/docs/crawl_options.txt | 18 | ||||
-rw-r--r-- | crawl-ref/init.txt | 8 | ||||
-rw-r--r-- | crawl-ref/source/acr.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/direct.cc | 9 | ||||
-rw-r--r-- | crawl-ref/source/externs.h | 3 | ||||
-rw-r--r-- | crawl-ref/source/fight.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/initfile.cc | 5 | ||||
-rw-r--r-- | crawl-ref/source/libunix.cc | 38 | ||||
-rw-r--r-- | crawl-ref/source/libunix.h | 1 | ||||
-rw-r--r-- | crawl-ref/source/libutil.cc | 16 | ||||
-rw-r--r-- | crawl-ref/source/libutil.h | 15 | ||||
-rw-r--r-- | crawl-ref/source/view.cc | 8 |
12 files changed, 103 insertions, 22 deletions
diff --git a/crawl-ref/docs/crawl_options.txt b/crawl-ref/docs/crawl_options.txt index 51d52d92df..b8b087e46b 100644 --- a/crawl-ref/docs/crawl_options.txt +++ b/crawl-ref/docs/crawl_options.txt @@ -24,7 +24,8 @@ The contents of this text are: drop_mode, pickup_mode, drop_filter 4-b Targeting. target_zero_exp, target_oos, target_los_first, - confirm_self_target, default_target + confirm_self_target, default_target, + target_unshifted_dirs 4-c Passive Sightings (Detection and Rememberance). detected_monster_colour, detected_item_colour, remembered_monster_colour, colour_map, clean_map @@ -73,7 +74,7 @@ The contents of this text are: 6-b DOS and Windows. dos_use_background_intensity 6-c Unix - background + background, use_fake_cursor -------------------------------------------------------------------------------- @@ -369,6 +370,13 @@ default_target = false than on the character. If no monsters are in view, targeting will start on the character regardless. +target_unshifted_dirs = false + If set to true, targeting will use the old Stone Soup 0.1 / Crawl 4.0 + targeting keymap where unshifted direction keys fire in that direction + immediately. The default is to use the new targeting keymap where + unshifted direction keys move the targeting cursor (and shifted + directions fire in the given direction immediately). + 4-c Passive Sightings (via detection and rememberance). ----------------------------------------------------------- @@ -1047,3 +1055,9 @@ background = <colour> may be useful if you're using a terminal with a background colour other than black (such as an xterm), but this option is still experimental and the results may not be very good. + +use_fake_cursor = false + If true, Crawl draws the cursor explicitly on the level-map and + targeting screens instead of relying on the term to draw the cursor. + Use this if your term cannot show a cursor over darkgrey/black + squares. diff --git a/crawl-ref/init.txt b/crawl-ref/init.txt index f1a0457750..9a3631bde4 100644 --- a/crawl-ref/init.txt +++ b/crawl-ref/init.txt @@ -83,11 +83,12 @@ lua_file = lua/trapwalk.lua ##### 4-b Targetting ############################ # -# target_zero_exp = false +# target_zero_exp = true # target_oos = false # target_los_first = false # confirm_self_target = false # default_target = true +# target_unshifted_dirs = true ##### 4-c Passive Sightings ##################### # @@ -232,3 +233,8 @@ menu_colour = white:Reached XP level ##### 6-b DOS and Windows ####################### # # dos_use_background_intensity = true + + +##### 6-c Unix ################################## +# +# use_fake_cursor = true diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc index b7ded5c700..d673838ae4 100644 --- a/crawl-ref/source/acr.cc +++ b/crawl-ref/source/acr.cc @@ -882,7 +882,7 @@ static void input() handle_delay(); - gotoxy(18,9); + gotoxy(VIEW_CX, VIEW_CY); if ( you_are_delayed() ) { diff --git a/crawl-ref/source/direct.cc b/crawl-ref/source/direct.cc index 0aebaf1a28..b9be9325c7 100644 --- a/crawl-ref/source/direct.cc +++ b/crawl-ref/source/direct.cc @@ -273,6 +273,8 @@ void direction(struct dist& moves, targeting_type restricts, return; } + cursor_control con(!Options.use_fake_cursor); + int dir = 0; bool show_beam = false; ray_def ray; @@ -322,8 +324,7 @@ void direction(struct dist& moves, targeting_type restricts, moves.isEndpoint = false; moves.choseRay = false; - // I'm sure there's a perfectly good reason for the +1. - gotoxy( grid2viewX(moves.tx) + 1, grid2viewY(moves.ty) ); + cursorxy( grid2viewX(moves.tx), grid2viewY(moves.ty) ); command_type key_command; @@ -616,7 +617,7 @@ void direction(struct dist& moves, targeting_type restricts, // We'll go on looping. Redraw whatever is necessary. // Tried to step out of bounds - if ( !in_bounds(moves.tx, moves.ty) ) + if ( !in_viewport_bounds(grid2viewX(moves.tx), grid2viewY(moves.ty)) ) { moves.tx = old_tx; moves.ty = old_ty; @@ -686,6 +687,8 @@ void direction(struct dist& moves, targeting_type restricts, // cache and noted in the Dungeon (O)verview, names the stair. static void describe_oos_square(int x, int y) { + mpr("You can't see that place."); + if (!in_bounds(x, y) || !is_mapped(x, y)) return; diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h index 3fcb868c51..a222cee91b 100644 --- a/crawl-ref/source/externs.h +++ b/crawl-ref/source/externs.h @@ -1258,6 +1258,9 @@ public: bool remember_name; // Remember and reprompt with last name bool dos_use_background_intensity; + + bool use_fake_cursor; // Draw a fake cursor instead of relying + // on the term's own cursor. int level_map_cursor_step; // The cursor increment in the level // map. diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc index 621f1b9253..859a8f2e62 100644 --- a/crawl-ref/source/fight.cc +++ b/crawl-ref/source/fight.cc @@ -1501,7 +1501,7 @@ bool melee_attack::apply_damage_brand() break; case SPWPN_ORC_SLAYING: - if (def->mons_species() == MONS_ORC) + if (defender->mons_species() == MONS_ORC) { special_damage = 1 + random2(damage_done); special_damage_message = diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc index f99126ff23..5815807405 100644 --- a/crawl-ref/source/initfile.cc +++ b/crawl-ref/source/initfile.cc @@ -647,6 +647,7 @@ void game_options::reset_options() // 10 was the cursor step default on Linux. level_map_cursor_step = 7; + use_fake_cursor = false; stash_tracking = STM_ALL; @@ -1982,6 +1983,10 @@ void game_options::read_option_line(const std::string &str, bool runscript) if (level_map_cursor_step > 50) level_map_cursor_step = 50; } + else if (key == "use_fake_cursor") + { + use_fake_cursor = read_bool(field, use_fake_cursor); + } else if (key == "macro_meta_entry") { macro_meta_entry = read_bool(field, macro_meta_entry); diff --git a/crawl-ref/source/libunix.cc b/crawl-ref/source/libunix.cc index 3eb398237b..1ef0d2ea45 100644 --- a/crawl-ref/source/libunix.cc +++ b/crawl-ref/source/libunix.cc @@ -640,6 +640,44 @@ int gotoxy(int x, int y) return (move(y - 1, x - 1)); } +static unsigned oldch, oldmangledch; +static int faked_x = -1, faked_y; + +void fakecursorxy(int x, int y) +{ + if (oldch && faked_x != -1 + && mvinch(faked_y, faked_x) == oldmangledch) + { + if (faked_x != x - 1 || faked_y != y - 1) + mvaddch(faked_y, faked_x, oldch); + else + return; + } + + const unsigned c = mvinch(y - 1, x - 1); + const int ch = c & A_CHARTEXT; + const unsigned colour = c & A_COLOR; + const int pair = PAIR_NUMBER(colour); + + faked_x = x - 1; + faked_y = y - 1; + oldch = c; + + int fg = pair & 7; + int bg = (pair >> 3) & 7; + + if (pair == 63) + { + fg = COLOR_WHITE; + bg = COLOR_BLACK; + } + + const int newpair = (fg * 8 + bg); + + mvaddch( y - 1, x - 1, oldmangledch = ((ch & 127) | COLOR_PAIR(newpair)) ); + + move(y - 1, x - 1); +} int wherex() { diff --git a/crawl-ref/source/libunix.h b/crawl-ref/source/libunix.h index bcbb864e85..19cd2674e3 100644 --- a/crawl-ref/source/libunix.h +++ b/crawl-ref/source/libunix.h @@ -21,6 +21,7 @@ int getch_ck(void); int clrscr(void); int cprintf(const char *format,...); int gotoxy(int x, int y); +void fakecursorxy(int x, int y); int itoa(int value, char *strptr, int radix); int kbhit(void); int putch(unsigned char chr); diff --git a/crawl-ref/source/libutil.cc b/crawl-ref/source/libutil.cc index 5246c2704d..096eeffc8a 100644 --- a/crawl-ref/source/libutil.cc +++ b/crawl-ref/source/libutil.cc @@ -140,7 +140,7 @@ int unmangle_direction_keys(int keyin, int km) // the shell can do damage with. bool shell_safe(const char *file) { - int match = strcspn(file, "`$*?|><&\n"); + int match = strcspn(file, "\\`$*?|><&\n!"); return !(match >= 0 && file[match]); } @@ -302,6 +302,20 @@ int c_getch() #endif } +// Wrapper around gotoxy that can draw a fake cursor for Unix terms where +// cursoring over darkgray or black causes problems. +void cursorxy(int x, int y) +{ +#ifdef UNIX + if (Options.use_fake_cursor) + fakecursorxy(x, y); + else + gotoxy(x, y); +#else + gotoxy(x, y); +#endif +} + // cprintf that knows how to wrap down lines (primitive, but what the heck) int wrapcprintf( int wrapcol, const char *s, ... ) { diff --git a/crawl-ref/source/libutil.h b/crawl-ref/source/libutil.h index a84ab5a166..d5b7bf081e 100644 --- a/crawl-ref/source/libutil.h +++ b/crawl-ref/source/libutil.h @@ -19,6 +19,8 @@ #include <string> #include <vector> +void cursorxy(int x, int y); + // Converts a key to a direction key, converting keypad and other sequences // to vi key sequences (shifted/control key directions are also handled). Non // direction keys (hopefully) pass through unmangled. @@ -307,12 +309,8 @@ public: bool compile() const { - // This function is const because compiled_pattern is not really part of - // the state of the object. - - void *&cp = const_cast<text_pattern*>( this )->compiled_pattern; return !empty()? - !!(cp = compile_pattern(pattern.c_str(), ignore_case)) + !!(compiled_pattern = compile_pattern(pattern.c_str(), ignore_case)) : false; } @@ -324,8 +322,7 @@ public: bool valid() const { return isvalid && - (compiled_pattern || - (const_cast<text_pattern*>( this )->isvalid = compile())); + (compiled_pattern || (isvalid = compile())); } bool matches(const char *s, int length) const @@ -350,8 +347,8 @@ public: private: std::string pattern; - void *compiled_pattern; - bool isvalid; + mutable void *compiled_pattern; + mutable bool isvalid; bool ignore_case; }; diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc index 1c0a31ed0f..e8a73dc6d2 100644 --- a/crawl-ref/source/view.cc +++ b/crawl-ref/source/view.cc @@ -2088,7 +2088,7 @@ static void draw_level_map(int start_x, int start_y, bool travel_mode) // to get that. This function is still a mess, though. -- bwr void show_map( FixedVector<int, 2> &spec_place, bool travel_mode ) { - cursor_control con(true); + cursor_control ccon(!Options.use_fake_cursor); int i, j; char move_x = 0; @@ -2178,7 +2178,7 @@ void show_map( FixedVector<int, 2> &spec_place, bool travel_mode ) draw_level_map(start_x, start_y, travel_mode); redraw_map = true; - gotoxy(curs_x, curs_y + top - 1); + cursorxy(curs_x, curs_y + top - 1); getty = unmangle_direction_keys(getchm(KC_LEVELMAP), KC_LEVELMAP); @@ -3583,7 +3583,7 @@ void viewwindow(bool draw_it, bool do_updates) // avoiding unneeded draws when running if (!you.running || (you.running < 0 && Options.travel_delay > -1)) { - gotoxy( 2, 1 ); + gotoxy( 1, 1 ); bufcount = 0; for (count_y = 0; count_y < Y_SIZE; count_y++) @@ -3598,7 +3598,7 @@ void viewwindow(bool draw_it, bool do_updates) bufcount += 2; } - gotoxy( 2, count_y + 2 ); + gotoxy( 1, count_y + 2 ); } } |