diff options
Diffstat (limited to 'crawl-ref')
-rw-r--r-- | crawl-ref/docs/options_guide.txt | 10 | ||||
-rw-r--r-- | crawl-ref/source/acr.cc | 8 | ||||
-rw-r--r-- | crawl-ref/source/cio.cc | 1 | ||||
-rw-r--r-- | crawl-ref/source/debug.cc | 16 | ||||
-rw-r--r-- | crawl-ref/source/message.cc | 68 | ||||
-rw-r--r-- | crawl-ref/source/message.h | 3 | ||||
-rw-r--r-- | crawl-ref/source/view.cc | 2 |
7 files changed, 88 insertions, 20 deletions
diff --git a/crawl-ref/docs/options_guide.txt b/crawl-ref/docs/options_guide.txt index 73346a7c9c..224d86d347 100644 --- a/crawl-ref/docs/options_guide.txt +++ b/crawl-ref/docs/options_guide.txt @@ -1398,10 +1398,12 @@ force_more_message = <list of regexes> The syntax is identical to that of travel_stop_message (4-g). msg_condense_repeats = true - If the same message is repeated multiple times, then the Show - Previous Message command (Ctrl-P) will condense them into one - line indicating how many times it was repeated. For example: - You hear a distant "Zot!" (x3) + If the same message is repeated multiple times during the same + turn, then it will be output in a condensed format indicating + how many times it was repeated. If the same output (including the + counter) is repeated over several turns, the Show Previous Message + command (Ctrl-P) will likewise condense them into one. For example: + The killer bee misses you. (x5) 4-k Missiles. ----------------- diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc index 0d75164a24..3502c222c4 100644 --- a/crawl-ref/source/acr.cc +++ b/crawl-ref/source/acr.cc @@ -880,6 +880,7 @@ static void _input() // Currently only set if Xom accidentally kills the player. you.reset_escaped_death(); + flush_prev_message(); if (crawl_state.is_replaying_keys() && crawl_state.is_repeating_cmd() && kbhit()) @@ -909,7 +910,7 @@ static void _input() else if (player_feels_safe && you.level_type != LEVEL_ABYSS) { // We don't want those "Whew, it's safe to rest now" messages - // when you were just cast into the Abyss. Right? + // if you were just cast into the Abyss. Right? if (2 * you.hp < you.hp_max || 2 * you.magic_points < you.max_magic_points) @@ -946,9 +947,10 @@ static void _input() if (you.cannot_act()) { if (crawl_state.repeat_cmd != CMD_WIZARD) + { crawl_state.cancel_cmd_repeat("Cannot move, cancelling command " "repetition."); - + } world_reacts(); return; } @@ -990,6 +992,8 @@ static void _input() crawl_state.input_line_curr = 0; { + flush_prev_message(); + // 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. diff --git a/crawl-ref/source/cio.cc b/crawl-ref/source/cio.cc index d82edfcd83..f8ac4bb957 100644 --- a/crawl-ref/source/cio.cc +++ b/crawl-ref/source/cio.cc @@ -126,7 +126,6 @@ void get_input_line( char *const buff, int len ) std::string &line = crawl_state.input_line_strs[curr]; strcpy(buff, line.c_str()); - return; } diff --git a/crawl-ref/source/debug.cc b/crawl-ref/source/debug.cc index 27610c837e..903a3ca841 100644 --- a/crawl-ref/source/debug.cc +++ b/crawl-ref/source/debug.cc @@ -1592,13 +1592,16 @@ bool get_item_by_name(item_def *item, char* specs, { const char* prompt; if (item->sub_type == POT_BLOOD) + { prompt = "# turns away from coagulation? " "[ENTER for fully fresh] "; + } else + { prompt = "# turns away from rotting? " "[ENTER for fully fresh] "; - int age = - _debug_prompt_for_int(prompt, false); + } + int age = _debug_prompt_for_int(prompt, false); if (age <= 0) age = -1; @@ -1766,7 +1769,7 @@ static void _tweak_randart(item_def &item) { case RAP_VAL_BOOL: mprf(MSGCH_PROMPT, "Toggling %s to %s.", _prop_name[choice], - props[choice] ? "off" : "on"); + props[choice] ? "off" : "on", 1); randart_set_property(item, static_cast<randart_prop_type>(choice), !props[choice]); break; @@ -1820,11 +1823,15 @@ void wizard_tweak_object(void) mpr( you.inv[item].name(DESC_INVENTORY_EQUIP).c_str() ); if (is_art) + { mpr( "a - plus b - plus2 c - art props d - quantity " "e - flags ESC - exit", MSGCH_PROMPT ); + } else + { mpr( "a - plus b - plus2 c - special d - quantity " "e - flags ESC - exit", MSGCH_PROMPT ); + } mpr( "Which field? ", MSGCH_PROMPT ); @@ -1908,7 +1915,8 @@ static bool _make_book_randart(item_def &book) { mpr("Make book fixed [t]heme or fixed [l]evel? ", MSGCH_PROMPT); type = tolower(getch()); - } while (type != 't' && type != 'l'); + } + while (type != 't' && type != 'l'); if (type == 'l') return make_book_level_randart(book); diff --git a/crawl-ref/source/message.cc b/crawl-ref/source/message.cc index ffabd700a3..8f7c88c88b 100644 --- a/crawl-ref/source/message.cc +++ b/crawl-ref/source/message.cc @@ -56,6 +56,7 @@ public: // Circular buffer for keeping past messages. message_item Store_Message[ NUM_STORED_MESSAGES ]; // buffer of old messages +message_item prev_message; int Next_Message = 0; // end of messages int Message_Line = 0; // line of next (previous?) message @@ -65,7 +66,7 @@ static FILE* _msg_dump_file = NULL; static bool suppress_messages = false; static void base_mpr(const char *inf, msg_channel_type channel, int param, - unsigned char colour); + unsigned char colour, bool check_previous_msg = true); static unsigned char prepare_message(const std::string& imsg, msg_channel_type channel, int param); @@ -660,11 +661,11 @@ static void mpr_store_messages(const std::string& message, if (prev_message_num < 0) prev_message_num = NUM_STORED_MESSAGES - 1; - message_item &prev_message = Store_Message[prev_message_num]; + message_item &prev_msg = Store_Message[prev_message_num]; - if (prev_message.repeats > 0 && prev_message.channel == channel - && prev_message.param == param && prev_message.text == message - && prev_message.colour == colour) + if (prev_msg.repeats > 0 && prev_msg.channel == channel + && prev_msg.param == param && prev_msg.text == message + && prev_msg.colour == colour) { prev_message.repeats++; was_repeat = true; @@ -750,14 +751,65 @@ static void handle_more(int colour) } } -static void base_mpr(const char *inf, msg_channel_type channel, int param, - unsigned char colour) +// Output the previous message. +// Needs to be called whenever the player gets a turn or needs to do +// something, e.g. answer a prompt. +void flush_prev_message() { - const std::string imsg = inf; + if (prev_message.text.empty()) + return; + + if (prev_message.repeats > 1) + { + snprintf(info, INFO_SIZE, "%s (x%d)", + prev_message.text.c_str(), prev_message.repeats); + prev_message.text = info; + } + base_mpr(prev_message.text.c_str(), prev_message.channel, + prev_message.param, prev_message.colour, false); + prev_message = message_item(); +} + +static void base_mpr(const char *inf, msg_channel_type channel, int param, + unsigned char colour, bool check_previous_msg) +{ if (colour == MSGCOL_MUTED) return; + const std::string imsg = inf; + + if (check_previous_msg) + { + if (!prev_message.text.empty()) + { + // If a message is identical to the previous one, increase the + // counter. + if (Options.msg_condense_repeats && prev_message.channel == channel + && prev_message.param == param && prev_message.text == imsg + && prev_message.colour == colour) + { + prev_message.repeats++; + return; + } + flush_prev_message(); + } + + // Always output prompts right away. + if (channel == MSGCH_PROMPT) + prev_message = message_item(); + else + { + // Store other messages until later. + prev_message.text = imsg; + prev_message.channel = channel; + prev_message.param = param; + prev_message.colour = colour; + prev_message.repeats = 1; + return; + } + } + handle_more(colour); if (need_prefix) diff --git a/crawl-ref/source/message.h b/crawl-ref/source/message.h index 49830df41f..86474a585e 100644 --- a/crawl-ref/source/message.h +++ b/crawl-ref/source/message.h @@ -22,8 +22,9 @@ * misc - player - spell - spl-book - spells1 - spells2 - * spells3 * *********************************************************************** */ -void mesclr( bool force = false ); +void mesclr(bool force = false); +void flush_prev_message(); // last updated 12may2000 {dlb} /* *********************************************************************** diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc index adf8159188..37886423ce 100644 --- a/crawl-ref/source/view.cc +++ b/crawl-ref/source/view.cc @@ -5085,6 +5085,8 @@ static void _debug_pane_bounds() //--------------------------------------------------------------- void viewwindow(bool draw_it, bool do_updates) { + flush_prev_message(); + #ifdef USE_TILE std::vector<unsigned int> tileb( crawl_view.viewsz.y * crawl_view.viewsz.x * 2); |