Skip to content

Commit

Permalink
Add hidden preference to show deprecation messages in chat area
Browse files Browse the repository at this point in the history
In 1.15 the preference will be added to the advanced preferences pane.
  • Loading branch information
CelticMinstrel committed Mar 4, 2018
1 parent e72ecc5 commit a290fe8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
9 changes: 9 additions & 0 deletions data/advanced_preferences.cfg
Expand Up @@ -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"
Expand Down
6 changes: 4 additions & 2 deletions src/deprecation.cpp
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
}

0 comments on commit a290fe8

Please sign in to comment.