Made [wml_message] much more useful...

...by outputting the messages to the in-game interface (chat)
according to the log severity of the "wml" log domain.
This commit is contained in:
Ignacio R. Morelle 2009-01-12 01:11:07 +00:00
parent 7473a388bb
commit a6a2932504
2 changed files with 34 additions and 1 deletions

View File

@ -36,6 +36,10 @@ Version 1.5.7+svn:
* deprecated tag [debug_message]; use [wml_message] instead, which
now offers the debug/dbg logger and uses the "wml" log domain
(i.e. --log-*=wml should be used instead of --log-*=notifs).
* The text output created by [wml_message] to stderr is echoed in-game
using the chat user interface like [deprecated_message] and other
Invalid-WML messages; the level of verbosity is controlled by the log
level for the "wml" log domain.
* the animate_unit action can now animate multiple units
* the animate_unit action can now change the direction the unit is facing
with a SLF

View File

@ -130,12 +130,16 @@ static void put_wml_message(const std::string& logger, const std::string& messag
{
if (logger == "err" || logger == "error") {
lg::err(lg::wml) << message << "\n";
wml_messages_stream << _("Error: ") << message << "\n";
} else if (logger == "warn" || logger == "wrn" || logger == "warning") {
lg::warn(lg::wml) << message << "\n";
wml_messages_stream << _("Warning: ") << message << "\n";
} else if((logger == "debug" || logger == "dbg") && !lg::debug.dont_log(lg::wml)) {
lg::debug(lg::wml) << message << "\n";
} else {
wml_messages_stream << _("Debug: ") << message << "\n";
} else if(!lg::info.dont_log(lg::wml)) {
lg::info(lg::wml) << message << "\n";
wml_messages_stream << _("Info: ") << message << "\n";
}
}
@ -200,6 +204,30 @@ static void show_wml_errors()
}
}
static void show_wml_messages()
{
// Get all unique messages in messages,
// with the number of encounters for these messages
std::map<std::string, int> messages;
fill_wml_messages_map(messages, wml_messages_stream);
// Show the messages collected
std::string caption = "WML";
for(std::map<std::string, int>::const_iterator itor = messages.begin();
itor != messages.end(); ++itor) {
std::stringstream msg;
msg << itor->first;
if(itor->second > 1) {
msg << " (" << itor->second << ")";
}
(screen)->add_chat_message(time(NULL), caption, 0, msg.str(),
game_display::MESSAGE_PUBLIC, false);
std::cerr << caption << ": " << msg.str() << '\n';
}
}
namespace game_events {
@ -3570,6 +3598,7 @@ namespace game_events {
// Dialogs can only be shown if the display is not locked
if(! (screen)->video().update_locked()) {
show_wml_errors();
show_wml_messages();
}
}