diff options
Diffstat (limited to 'crawl-ref')
-rw-r--r-- | crawl-ref/source/libdos.cc | 12 | ||||
-rw-r--r-- | crawl-ref/source/libdos.h | 3 | ||||
-rw-r--r-- | crawl-ref/source/libgui.cc | 4 | ||||
-rw-r--r-- | crawl-ref/source/libgui.h | 2 | ||||
-rw-r--r-- | crawl-ref/source/libunix.cc | 13 | ||||
-rw-r--r-- | crawl-ref/source/libunix.h | 3 | ||||
-rw-r--r-- | crawl-ref/source/libw32c.cc | 11 | ||||
-rw-r--r-- | crawl-ref/source/libw32c.h | 3 | ||||
-rw-r--r-- | crawl-ref/source/message.cc | 38 | ||||
-rw-r--r-- | crawl-ref/source/tilesdl.cc | 13 |
10 files changed, 50 insertions, 52 deletions
diff --git a/crawl-ref/source/libdos.cc b/crawl-ref/source/libdos.cc index 62e90ae93d..f20d809fd6 100644 --- a/crawl-ref/source/libdos.cc +++ b/crawl-ref/source/libdos.cc @@ -57,20 +57,22 @@ static void scroll_message_window() cgotoxy(x, y - 1); } -void message_out(int which_line, int colour, const char *s, int firstcol, - bool newline) +void message_out(int *which_line, int colour, const char *s, int firstcol) { if (!firstcol) firstcol = Options.delay_message_clear? 2 : 1; + while (*which_line > crawl_view.msgsz.y - 1) + { + scroll_message_window(); + (*which_line)--; + } + cgotoxy(firstcol + crawl_view.msgp.x - 1, which_line + crawl_view.msgp.y); textcolor(colour); cprintf("%s", s); - - if (newline && which_line == crawl_view.msgsz.y - 1) - scroll_message_window(); } void set_cursor_enabled(bool enabled) diff --git a/crawl-ref/source/libdos.h b/crawl-ref/source/libdos.h index 6691d499d9..99f326e6de 100644 --- a/crawl-ref/source/libdos.h +++ b/crawl-ref/source/libdos.h @@ -28,8 +28,7 @@ void clear_to_end_of_line(); int getch_ck(); static inline void set_mouse_enabled(bool enabled) { } -void message_out(int mline, int colour, const char *str, int firstcol = 0, - bool newline = true); +void message_out(int *mline, int colour, const char *str, int firstcol = 0); void clear_message_window(); inline void update_screen() { diff --git a/crawl-ref/source/libgui.cc b/crawl-ref/source/libgui.cc index 6eb4339076..568faa0d69 100644 --- a/crawl-ref/source/libgui.cc +++ b/crawl-ref/source/libgui.cc @@ -311,9 +311,9 @@ int clrscr() return 0; } -void message_out(int which_line, int colour, const char *s, int firstcol, bool newline) +void message_out(int *which_line, int colour, const char *s, int firstcol) { - tiles.message_out(which_line, colour, s, firstcol, newline); + tiles.message_out(*which_line, colour, s, firstcol); } void cgotoxy(int x, int y, int region) diff --git a/crawl-ref/source/libgui.h b/crawl-ref/source/libgui.h index 9932520a83..d738075d7e 100644 --- a/crawl-ref/source/libgui.h +++ b/crawl-ref/source/libgui.h @@ -57,7 +57,7 @@ int window(int x1, int y1, int x2, int y2); extern "C" int getch(); int getch_ck(); int clrscr(); -void message_out(int which_line, int colour, const char *s, int firstcol = 0, bool newline = true); +void message_out(int *which_line, int colour, const char *s, int firstcol = 0); void cgotoxy(int x, int y, int region = GOTO_CRT); void clear_message_window(); void delay(int ms); diff --git a/crawl-ref/source/libunix.cc b/crawl-ref/source/libunix.cc index f8c462edce..11b7419c85 100644 --- a/crawl-ref/source/libunix.cc +++ b/crawl-ref/source/libunix.cc @@ -419,8 +419,7 @@ void clear_message_window() wrefresh( Message_Window ); } -void message_out(int which_line, int color, const char *s, int firstcol, - bool newline) +void message_out(int *which_line, int color, const char *s, int firstcol) { (void)wattrset( Message_Window, curs_fg_attr(color) ); @@ -429,20 +428,22 @@ void message_out(int which_line, int color, const char *s, int firstcol, else firstcol--; - int x, y; - getyx(Message_Window, y, x); - if (newline && which_line == y && which_line == crawl_view.msgsz.y - 1) + while (*which_line >= crawl_view.msgsz.y) { + int x, y; + getyx(Message_Window, y, x); scroll(Message_Window); wmove(Message_Window, y - 1, x); + (*which_line)--; } - wmove(Message_Window, which_line, firstcol); + wmove(Message_Window, *which_line, firstcol); waddstr_with_altcharset(Message_Window, s); // Fix stdscr cursor to same place as Message_Window cursor. This // is necessary because when reading input we use stdscr. { + int x, y; getyx(Message_Window, y, x); move(y + crawl_view.msgp.y - 1, crawl_view.msgp.x - 1 + x); } diff --git a/crawl-ref/source/libunix.h b/crawl-ref/source/libunix.h index 8da80d559c..3a9df9f6d8 100644 --- a/crawl-ref/source/libunix.h +++ b/crawl-ref/source/libunix.h @@ -23,8 +23,7 @@ typedef unsigned short screen_buffer_t; char getche(void); -void message_out(int mline, int colour, const char *str, int firstcol = 0, - bool newline = true); +void message_out(int *mline, int colour, const char *str, int firstcol = 0); void clear_message_window(); int get_number_of_lines(); diff --git a/crawl-ref/source/libw32c.cc b/crawl-ref/source/libw32c.cc index 36cc261851..18eb36cbac 100644 --- a/crawl-ref/source/libw32c.cc +++ b/crawl-ref/source/libw32c.cc @@ -617,20 +617,23 @@ static void scroll_message_window() cgotoxy(wherex(), wherey() - 1); } -void message_out(int which_line, int colour, const char *s, int firstcol, - bool newline) +void message_out(int *which_line, int colour, const char *s, int firstcol) { if (!firstcol) firstcol = Options.delay_message_clear? 2 : 1; + while (*which_line > crawl_view.msgsz.y - 1) + { + scroll_message_window(); + (*which_line)--; + } + cgotoxy(firstcol - 1 + crawl_view.msgp.x, which_line + crawl_view.msgp.y); textcolor(colour); cprintf("%s", s); - if (newline && which_line == crawl_view.msgsz.y - 1) - scroll_message_window(); } static void cprintf_aux(const char *s) diff --git a/crawl-ref/source/libw32c.h b/crawl-ref/source/libw32c.h index 58689abb15..c7eed44478 100644 --- a/crawl-ref/source/libw32c.h +++ b/crawl-ref/source/libw32c.h @@ -12,8 +12,7 @@ typedef unsigned short screen_buffer_t; void init_libw32c(void); void deinit_libw32c(void); -void message_out(int mline, int colour, const char *str, int firstcol = 0, - bool newline = true); +void message_out(int *mline, int colour, const char *str, int firstcol = 0); void clear_message_window(); int get_number_of_lines(); diff --git a/crawl-ref/source/message.cc b/crawl-ref/source/message.cc index 093fdb4df0..561247b7ea 100644 --- a/crawl-ref/source/message.cc +++ b/crawl-ref/source/message.cc @@ -676,8 +676,6 @@ static void mpr_store_messages(const std::string& message, msg_channel_type channel, int param, unsigned char colour, int repeats = 1) { - const int num_lines = crawl_view.msgsz.y; - bool was_repeat = false; if (Options.msg_condense_repeats) @@ -704,8 +702,7 @@ static void mpr_store_messages(const std::string& message, if (channel != MSGCH_PROMPT) New_Message_Count++; - if (Message_Line < num_lines - 1) - Message_Line++; + Message_Line++; // Reset colour. textcolor(LIGHTGREY); @@ -726,8 +723,6 @@ static void mpr_store_messages(const std::string& message, } } -static bool did_prefix = false; - // Does the work common to base_mpr and formatted_mpr. // Returns the default colour of the message, or MSGCOL_MUTED if // the message should be suppressed. @@ -840,9 +835,8 @@ static void base_mpr(const char *inf, msg_channel_type channel, int param, snprintf(info, INFO_SIZE, "%s (x%d)", inf, repeats); inf = info; } - message_out(Message_Line, colour, inf, - Options.delay_message_clear ? 2 : 1, !did_prefix); - did_prefix = false; + message_out(&Message_Line, colour, inf, + Options.delay_message_clear ? 2 : 1); if (channel == MSGCH_PROMPT || channel == MSGCH_ERROR) set_more_autoclear(false); @@ -885,15 +879,13 @@ static void mpr_formatted_output(formatted_string fs, int colour) colour = fs.ops[i].x; break; case FSOP_TEXT: - message_out(Message_Line, colour, fs.ops[i].text.c_str(), curcol, - (i == last_text) && !did_prefix); + message_out(&Message_Line, colour, fs.ops[i].text.c_str(), curcol); curcol += multibyte_strlen(fs.ops[i].text); break; case FSOP_CURSOR: break; } } - did_prefix = false; } // Line wrapping is not available here! @@ -993,7 +985,7 @@ bool any_messages(void) return (Message_Line > 0); } -void mesclr( bool force ) +void mesclr(bool force) { if (crawl_state.game_crashed) return; @@ -1009,9 +1001,7 @@ void mesclr( bool force ) if (!force && Options.delay_message_clear) { - if (!did_prefix) - message_out( Message_Line, WHITE, "-", 1, true); - did_prefix = true; + message_out(&Message_Line, WHITE, "-", 1); return; } @@ -1019,7 +1009,6 @@ void mesclr( bool force ) cursor_control cs(false); clear_message_window(); - did_prefix = false; Message_Line = 0; } @@ -1070,19 +1059,22 @@ void more(bool user_forced) int keypress = 0; + int line = crawl_view.msgsz.y - 1; + + // Force scroll. + if (Options.delay_message_clear) + line++; + if (Tutorial.tutorial_left) { - message_out(crawl_view.msgsz.y - 1, - LIGHTGREY, + message_out(&line, LIGHTGREY, "--more-- " "Press Ctrl-P to reread old messages.", - 2, Options.delay_message_clear); + 2); } else { - message_out(crawl_view.msgsz.y - 1, - LIGHTGREY, "--more--", 2, - Options.delay_message_clear); + message_out(&line, LIGHTGREY, "--more--", 2); } mouse_control mc(MOUSE_MODE_MORE); diff --git a/crawl-ref/source/tilesdl.cc b/crawl-ref/source/tilesdl.cc index 51ed39ea10..de5782ff75 100644 --- a/crawl-ref/source/tilesdl.cc +++ b/crawl-ref/source/tilesdl.cc @@ -1207,19 +1207,22 @@ void TilesFramework::clrscr() cgotoxy(1,1); } -void TilesFramework::message_out(int which_line, int colour, const char *s, - int firstcol, bool newline) +void TilesFramework::message_out(int *which_line, int colour, const char *s, + int firstcol) { if (!firstcol) firstcol = Options.delay_message_clear ? 2 : 1; + while (*which_line > crawl_view.msgsz.y - 1) + { + m_region_msg->scroll(); + (*which_line)--; + } + cgotoxy(firstcol, which_line + 1, GOTO_MSG); textcolor(colour); cprintf("%s", s); - - if (newline && which_line == crawl_view.msgsz.y - 1) - m_region_msg->scroll(); } void TilesFramework::clear_message_window() |