summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authorRobert Vollmert <rvollmert@gmx.net>2009-11-28 15:06:46 +0100
committerRobert Vollmert <rvollmert@gmx.net>2009-11-28 18:18:15 +0100
commit6e1cc1abcff78fb383e25641b0b424bfb1d2ebb4 (patch)
tree87c7d71c9d0487c5e67ca9dff733675fd7f1c2f3 /crawl-ref/source
parenta7280a4d1b2470ff6f78f82b5afb2d3b6dfccd09 (diff)
downloadcrawl-ref-6e1cc1abcff78fb383e25641b0b424bfb1d2ebb4.tar.gz
crawl-ref-6e1cc1abcff78fb383e25641b0b424bfb1d2ebb4.zip
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.
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/cio.cc3
-rw-r--r--crawl-ref/source/command.cc7
-rw-r--r--crawl-ref/source/directn.cc2
-rw-r--r--crawl-ref/source/initfile.cc2
-rw-r--r--crawl-ref/source/l_crawl.cc2
-rw-r--r--crawl-ref/source/main.cc24
-rw-r--r--crawl-ref/source/options.h1
-rw-r--r--crawl-ref/source/travel.cc1
-rw-r--r--crawl-ref/source/view.cc3
9 files changed, 25 insertions, 20 deletions
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();