diff options
-rw-r--r-- | crawl-ref/source/externs.h | 1 | ||||
-rw-r--r-- | crawl-ref/source/initfile.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/message.cc | 26 | ||||
-rw-r--r-- | crawl-ref/source/message.h | 9 |
4 files changed, 35 insertions, 3 deletions
diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h index a5b7c8dae0..62cdd301cf 100644 --- a/crawl-ref/source/externs.h +++ b/crawl-ref/source/externs.h @@ -1602,6 +1602,7 @@ public: int msg_max_height; bool mlist_allow_alternate_layout; bool classic_hud; + bool msg_condense_repeats; // The view lock variables force centering the viewport around the PC @ // at all times (the default). If view locking is not enabled, the viewport diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc index 3f53faf6bd..cfcc7cd326 100644 --- a/crawl-ref/source/initfile.cc +++ b/crawl-ref/source/initfile.cc @@ -616,6 +616,7 @@ void game_options::reset_options() msg_max_height = 10; mlist_allow_alternate_layout = false; classic_hud = false; + msg_condense_repeats = true; view_lock_x = true; view_lock_y = true; @@ -2200,6 +2201,7 @@ void game_options::read_option_line(const std::string &str, bool runscript) else INT_OPTION(msg_max_height, 6, INT_MAX); else BOOL_OPTION(mlist_allow_alternate_layout); else BOOL_OPTION(classic_hud); + else BOOL_OPTION(msg_condense_repeats); else BOOL_OPTION(view_lock_x); else BOOL_OPTION(view_lock_y); else if (key == "view_lock") diff --git a/crawl-ref/source/message.cc b/crawl-ref/source/message.cc index 479899d853..159af003eb 100644 --- a/crawl-ref/source/message.cc +++ b/crawl-ref/source/message.cc @@ -577,6 +577,25 @@ static void mpr_store_messages(const std::string& message, { const int num_lines = crawl_view.msgsz.y; + bool was_repeat = false; + + if (Options.msg_condense_repeats) + { + int prev_message_num = Next_Message - 1; + + if (prev_message_num < 0) + prev_message_num = NUM_STORED_MESSAGES - 1; + + message_item &prev_message = Store_Message[prev_message_num]; + + if (prev_message.repeats > 0 && prev_message.channel == channel + && prev_message.param == param && prev_message.text == message) + { + prev_message.repeats++; + was_repeat = true; + } + } + // Prompt lines are presumably shown to / seen by the player accompanied // by a request for input, which should do the equivalent of a more(); to // save annoyance, don't bump New_Message_Count for prompts. @@ -590,12 +609,13 @@ static void mpr_store_messages(const std::string& message, textcolor(LIGHTGREY); // Equipment lists just waste space in the message recall. - if (channel_message_history(channel)) + if (!was_repeat && channel_message_history(channel)) { // Put the message into Store_Message, and move the '---' line forward Store_Message[ Next_Message ].text = message; Store_Message[ Next_Message ].channel = channel; Store_Message[ Next_Message ].param = param; + Store_Message[ Next_Message ].repeats = 1; Next_Message++; if (Next_Message >= NUM_STORED_MESSAGES) @@ -989,8 +1009,10 @@ void replay_messages(void) break; } } - cprintf(EOL); textcolor(LIGHTGREY); + if (Store_Message[ line ].repeats > 1) + cprintf(" (x%d)", Store_Message[ line ].repeats); + cprintf(EOL); } // print a footer -- note: relative co-ordinates start at 1 diff --git a/crawl-ref/source/message.h b/crawl-ref/source/message.h index 210e833010..9ce1c31ac0 100644 --- a/crawl-ref/source/message.h +++ b/crawl-ref/source/message.h @@ -21,10 +21,17 @@ #include "enum.h" #include "mpr.h" -struct message_item { +class message_item { +public: msg_channel_type channel; // message channel int param; // param for channel (god, enchantment) std::string text; // text of message + int repeats; + + message_item() : channel(NUM_MESSAGE_CHANNELS), param(0), text(""), + repeats(0) + { + } }; |