From 6e1cc1abcff78fb383e25641b0b424bfb1d2ebb4 Mon Sep 17 00:00:00 2001 From: Robert Vollmert Date: Sat, 28 Nov 2009 15:06:46 +0100 Subject: Add an option to draw the player cursor manually. Set use_fake_player_cursor = true to use this. This allows defaulting the cursor to off, which means less cursor blinking say when travelling. This patch also moves the cursor control closer to where it's used, so that the cursor is only turned on for actual input prompts. I've definitely missed some prompts here: almost anything that prompts for a single character and reads it using getch() will not have a cursor with use_fake_player_cursor set at the moment. --- crawl-ref/docs/options_guide.txt | 8 +++++++- crawl-ref/settings/init.txt | 1 + crawl-ref/source/cio.cc | 3 ++- crawl-ref/source/command.cc | 7 +++++-- crawl-ref/source/directn.cc | 2 +- crawl-ref/source/initfile.cc | 2 ++ crawl-ref/source/l_crawl.cc | 2 -- crawl-ref/source/main.cc | 24 ++++++++++++------------ crawl-ref/source/options.h | 1 + crawl-ref/source/travel.cc | 1 - crawl-ref/source/view.cc | 3 ++- 11 files changed, 33 insertions(+), 21 deletions(-) (limited to 'crawl-ref') diff --git a/crawl-ref/docs/options_guide.txt b/crawl-ref/docs/options_guide.txt index 93d2cac83f..e9f55dd4ca 100644 --- a/crawl-ref/docs/options_guide.txt +++ b/crawl-ref/docs/options_guide.txt @@ -114,7 +114,8 @@ The contents of this text are: 6-a All OS. mouse_input, wiz_mode, char_set, classic_item_colours, colour, char_set, cset_ascii, cset_ibm, cset_dec, - cset_unicode, feature, mon_glyph, pizza + cset_unicode, feature, mon_glyph, pizza, + use_fake_player_cursor 6-b DOS and Windows. dos_use_background_intensity @@ -2094,6 +2095,11 @@ mon_glyph = : pizza = The player's choice of pizza topping. +use_fake_player_cursor = false + Makes the main view highlight the player without using the + terminal cursor. This means it won't flicker when the cursor + is turned off to move elsewhere for drawing, and allows + turning the cursor off by default. 6-b DOS and Windows. ------------------------ diff --git a/crawl-ref/settings/init.txt b/crawl-ref/settings/init.txt index 15fbe56cf3..6056ea971b 100644 --- a/crawl-ref/settings/init.txt +++ b/crawl-ref/settings/init.txt @@ -406,3 +406,4 @@ note_monsters = orb of fire, ancient lich, Sigmund ##### 6-c Unix ################################## # # use_fake_cursor = false +# use_fake_player_cursor = true diff --git a/crawl-ref/source/cio.cc b/crawl-ref/source/cio.cc index 6f95297d84..87f37df0cd 100644 --- a/crawl-ref/source/cio.cc +++ b/crawl-ref/source/cio.cc @@ -300,6 +300,7 @@ int cancelable_get_line( char *buf, int len, int maxcol, input_history *mh, int (*keyproc)(int &ch) ) { flush_prev_message(); + line_reader reader(buf, len, maxcol); reader.set_input_history(mh); reader.set_keyproc(keyproc); @@ -408,7 +409,7 @@ int line_reader::read_line(bool clear_previous) if (bufsz <= 0) return (false); - cursor_control coff(true); + cursor_control con(true); if (clear_previous) *buffer = 0; diff --git a/crawl-ref/source/command.cc b/crawl-ref/source/command.cc index a1d2128127..28218e61c0 100644 --- a/crawl-ref/source/command.cc +++ b/crawl-ref/source/command.cc @@ -1507,8 +1507,11 @@ static bool _find_description(bool &again, std::string& error_inout) mpr(error_inout.c_str(), MSGCH_PROMPT); mpr("Describe a (M)onster, (S)pell, s(K)ill, (I)tem, (F)eature, (G)od, " "(A)bility, (B)ranch, or (C)ard? ", MSGCH_PROMPT); - - int ch = toupper(getch()); + int ch; + { + cursor_control con(true); + ch = toupper(getch()); + } std::string type; std::string extra; db_find_filter filter = NULL; diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc index 5a5d70b731..1abc47b275 100644 --- a/crawl-ref/source/directn.cc +++ b/crawl-ref/source/directn.cc @@ -1042,7 +1042,7 @@ void direction(dist& moves, const targetting_type restricts, return; } - cursor_control con(!Options.use_fake_cursor); + cursor_control ccon(!Options.use_fake_cursor); mouse_control mc(needs_path && !just_looking ? MOUSE_MODE_TARGET_PATH : MOUSE_MODE_TARGET); range_view_annotator rva(range); diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc index 76431c8238..559239da67 100644 --- a/crawl-ref/source/initfile.cc +++ b/crawl-ref/source/initfile.cc @@ -751,6 +751,7 @@ void game_options::reset_options() #else use_fake_cursor = false; #endif + use_fake_player_cursor = false; stash_tracking = STM_ALL; @@ -2756,6 +2757,7 @@ void game_options::read_option_line(const std::string &str, bool runscript) level_map_cursor_step = 50; } else BOOL_OPTION(use_fake_cursor); + else BOOL_OPTION(use_fake_player_cursor); else BOOL_OPTION(macro_meta_entry); else if (key == "stop_travel" || key == "travel_stop_message") { diff --git a/crawl-ref/source/l_crawl.cc b/crawl-ref/source/l_crawl.cc index aebb011182..5425a04930 100644 --- a/crawl-ref/source/l_crawl.cc +++ b/crawl-ref/source/l_crawl.cc @@ -150,7 +150,6 @@ static int crawl_yesno(lua_State *ls) const bool noprompt = lua_isnone(ls, 6) ? false : lua_toboolean(ls, 6); - cursor_control con(true); lua_pushboolean(ls, yesno(prompt, safe, safeanswer, clear_after, interrupt_delays, noprompt)); return (1); @@ -168,7 +167,6 @@ static int crawl_yesnoquit(lua_State *ls) // Skipping the other params until somebody needs them. - cursor_control con(true); lua_pushnumber(ls, yesnoquit(prompt, safe, safeanswer, allow_all, clear_after)); return (1); diff --git a/crawl-ref/source/main.cc b/crawl-ref/source/main.cc index 68f5440389..1ea36c2d5f 100644 --- a/crawl-ref/source/main.cc +++ b/crawl-ref/source/main.cc @@ -300,6 +300,7 @@ int main( int argc, char *argv[] ) // to dismiss a level-up prompt. level_change(); + cursor_control ccon(!Options.use_fake_player_cursor); while (true) _input(); @@ -658,8 +659,11 @@ static void _handle_wizard_command( void ) } } - mpr("Enter Wizard Command (? - help): ", MSGCH_PROMPT); - wiz_command = getch(); + { + mpr("Enter Wizard Command (? - help): ", MSGCH_PROMPT); + cursor_control con(true); + wiz_command = getch(); + } if (crawl_state.cmd_repeat_start) { @@ -1063,11 +1067,6 @@ static void _input() #ifdef USE_TILE cursor_control con(false); -#else - // Enable the cursor to read input. The cursor stays on while - // the command is being processed, so subsidiary prompts - // shouldn't need to turn it on explicitly. - cursor_control con(true); #endif const command_type cmd = _get_next_cmd(); @@ -1595,8 +1594,11 @@ void process_command( command_type cmd ) mpr("Change to (d)efault, (n)othing, (f)riend-dropped, (p)layer, " "or (a)ll? ", MSGCH_PROMPT); - - char type = (char) getchm(KMC_DEFAULT); + char type; + { + cursor_control con(true); + type = (char) getchm(KMC_DEFAULT); + } type = tolower(type); if (type == 'd') @@ -4292,9 +4294,7 @@ static void _setup_cmd_repeat() repeat_again_rec.keys.pop_back(); mpr("Enter command to be repeated: "); - // Enable the cursor to read input. The cursor stays on while - // the command is being processed, so subsidiary prompts - // shouldn't need to turn it on explicitly. + // Enable the cursor to read input. cursor_control con(true); crawl_state.waiting_for_command = true; diff --git a/crawl-ref/source/options.h b/crawl-ref/source/options.h index 006641fbe3..8467480cdc 100644 --- a/crawl-ref/source/options.h +++ b/crawl-ref/source/options.h @@ -300,6 +300,7 @@ public: bool use_fake_cursor; // Draw a fake cursor instead of relying // on the term's own cursor. + bool use_fake_player_cursor; int level_map_cursor_step; // The cursor increment in the level // map. diff --git a/crawl-ref/source/travel.cc b/crawl-ref/source/travel.cc index b3d9b38c0f..f8e4eb55cb 100644 --- a/crawl-ref/source/travel.cc +++ b/crawl-ref/source/travel.cc @@ -181,7 +181,6 @@ bool deviant_route_warning::warn_continue_travel( // If the user says "Yes, shut up and take me there", we won't ask // again for that destination. If the user says "No", we will // prompt again. - cursor_control con(true); return ((warned = yesno(prompt.c_str(), true, 'n', true, false))); } diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc index f22623bc4c..ef6cb52244 100644 --- a/crawl-ref/source/view.cc +++ b/crawl-ref/source/view.cc @@ -800,6 +800,8 @@ static void draw_player(screen_buffer_t* buffy, else buffy[1] = CYAN; } + if (Options.use_fake_player_cursor) + buffy[1] |= COLFLAG_REVERSE; #else buffy[0] = env.tile_fg(ep) = tileidx_player(you.char_class); buffy[1] = env.tile_bg(ep); @@ -951,7 +953,6 @@ void viewwindow(bool monster_updates, bool show_updates) crawl_view.viewp.x + crawl_view.viewsz.x - 1, crawl_view.viewp.y + crawl_view.viewsz.y - 1, buffy); - update_monster_pane(); #else tiles.set_need_redraw(); -- cgit v1.2.3-54-g00ecf