AIAlert fixup.

This commit is contained in:
Aleric Inglewood
2013-11-09 15:42:29 +01:00
parent a7e72ceb32
commit 5f9c6f1b08
5 changed files with 52 additions and 26 deletions

View File

@@ -25,6 +25,7 @@
#include "linden_common.h"
#include "llnotificationsutil.h"
#include "lltrans.h"
#include "llnotifications.h"
#include "llsd.h"
@@ -33,7 +34,7 @@
namespace AIAlert
{
LLNotificationPtr add(Error const& error, modal_nt type, unsigned int suppress_mask)
LLNotificationPtr add(Error const& error, unsigned int suppress_mask, modal_nt type)
{
return LLNotifications::instance().add(error, type, suppress_mask);
}
@@ -68,6 +69,30 @@ LLNotificationPtr add(std::string const& xml_desc, AIArgs const& args, Error con
return LLNotifications::instance().add(Error(Prefix(), type, xml_desc, args, error), type, suppress_mask);
}
std::string text(Error const& error, int suppress_mask)
{
std::string alert_text;
bool suppress_newlines = false;
bool last_was_prefix = false;
for (Error::lines_type::const_iterator line = error.lines().begin(); line != error.lines().end(); ++line)
{
// Even if a line is suppressed, we print its leading newline if requested, but never more than one.
if (!suppress_newlines && line->prepend_newline())
{
alert_text += '\n';
suppress_newlines = true;
}
if (!line->suppressed(suppress_mask))
{
if (last_was_prefix) alert_text += ' '; // The translation system strips off spaces... add them back.
alert_text += LLTrans::getString(line->getXmlDesc(), line->args());
suppress_newlines = false;
last_was_prefix = line->is_prefix();
}
}
return alert_text;
}
} // namespace AIAlert
LLNotificationPtr LLNotificationsUtil::add(const std::string& name)