Add hidden preference to show deprecation messages in chat area

In 1.15 the preference will be added to the advanced preferences pane.
This commit is contained in:
Celtic Minstrel 2018-03-04 13:36:44 -05:00 committed by Celtic Minstrel
parent dc0d6474e8
commit 32b6a3de45
2 changed files with 13 additions and 2 deletions

View file

@ -185,6 +185,15 @@
[/advanced_preference]
#ifdef __UNUSED__
[advanced_preference]
field=show_deprecation
# TODO: Add translation marks and enable this after 1.14
name="Show deprecation messages in-game"
description="Show warnings about deprecated API in the in-game chat area. These messages will still be shown in the log, even if this is disabled. In addition, the deprecation log-domain controls how many messages are printed."
type=boolean
default=no
[/advanced_preference]
[advanced_preference]
field=joystick_support_enabled
name= _ "Joystick support"

View file

@ -19,6 +19,7 @@
#include "tstring.hpp"
#include "game_config.hpp"
#include "version.hpp"
#include "preferences/general.hpp"
// Set the default severity with the second parameter.
// -1 means the default is to never log on this domain.
@ -61,11 +62,12 @@ std::string deprecated_message(const std::string& elem_name, int level, const ve
message += "\n ";
message += detail;
}
// TODO: Decide when to dump to wml_error()
if(log_ptr && !log_ptr->dont_log(log_deprecate)) {
const lg::logger& out_log = *log_ptr;
out_log(log_deprecate) << message << '\n';
//lg::wml_error() << message << '\n';
if(preferences::get("show_deprecation", false)) {
lg::wml_error() << message << '\n';
}
}
return message;
}