Fixed wrong language messages being selected.

Fixes #181.
This commit is contained in:
WrinklyNinja
2014-07-11 20:44:28 +01:00
parent 896181c3e7
commit 0c19368338
4 changed files with 18 additions and 15 deletions
+1 -1
View File
@@ -200,7 +200,7 @@ namespace loot {
bool Message::EvalCondition(loot::Game& game, const unsigned int language) {
BOOST_LOG_TRIVIAL(trace) << "Choosing message language.";
BOOST_LOG_TRIVIAL(trace) << "Choosing message content for language: " << Language(language).Name();
if (_content.size() > 1) {
if (language == Language::any) //Can use a message of any language, so use the first string.
+3 -3
View File
@@ -184,7 +184,7 @@ namespace loot {
}
}
std::pair<std::string, std::string> UpdateMasterlist(Game& game, std::list<Message>& parsingErrors, std::list<Plugin>& plugins, std::list<Message>& messages) {
std::pair<std::string, std::string> UpdateMasterlist(Game& game, std::list<Message>& parsingErrors, std::list<Plugin>& plugins, std::list<Message>& messages, const unsigned int language) {
git_handler git;
fs::path repo_path = game.MasterlistPath().parent_path();
string repo_branch = game.RepoBranch();
@@ -428,11 +428,11 @@ namespace loot {
plugins = mlist["plugins"].as< list<loot::Plugin> >();
for (auto &plugin: plugins) {
plugin.EvalAllConditions(game, Language::any);
plugin.EvalAllConditions(game, language);
}
for (auto &message: messages) {
message.EvalCondition(game, Language::any);
message.EvalCondition(game, language);
}
parsingFailed = false;
+1 -1
View File
@@ -33,7 +33,7 @@
namespace loot {
std::pair<std::string, std::string> UpdateMasterlist(Game& game, std::list<Message>& parsingErrors, std::list<Plugin>& plugins, std::list<Message>& messages);
std::pair<std::string, std::string> UpdateMasterlist(Game& game, std::list<Message>& parsingErrors, std::list<Plugin>& plugins, std::list<Message>& messages, const unsigned int language);
std::pair<std::string, std::string> GetMasterlistRevision(const Game& game);
}
+13 -10
View File
@@ -103,14 +103,14 @@ struct plugin_list_loader {
};
struct masterlist_updater_parser {
masterlist_updater_parser(bool doUpdate, loot::Game& game, list<loot::Message>& errors, list<loot::Plugin>& plugins, list<loot::Message>& messages, string& revision, string& date) : _doUpdate(doUpdate), _game(game), _errors(errors), _plugins(plugins), _messages(messages), _revision(revision), _date(date) {}
masterlist_updater_parser(bool doUpdate, loot::Game& game, list<loot::Message>& errors, list<loot::Plugin>& plugins, list<loot::Message>& messages, string& revision, string& date, const unsigned int language) : _doUpdate(doUpdate), _game(game), _errors(errors), _plugins(plugins), _messages(messages), _revision(revision), _date(date), _language(language) {}
void operator () () {
if (_doUpdate) {
BOOST_LOG_TRIVIAL(debug) << "Updating masterlist";
try {
pair<string, string> ret = UpdateMasterlist(_game, _errors, _plugins, _messages);
pair<string, string> ret = UpdateMasterlist(_game, _errors, _plugins, _messages, _language);
_revision = ret.first;
_date = ret.second;
} catch (std::exception& e) {
@@ -185,6 +185,7 @@ struct masterlist_updater_parser {
list<loot::Message>& _messages;
string& _revision;
string& _date;
unsigned int _language;
};
bool LOOT::OnInit() {
@@ -730,8 +731,17 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) {
// Load Plugins & Lists
///////////////////////////////////////////////////////
//Set language.
unsigned int lang;
if (_settings["Language"])
lang = Language(_settings["Language"].as<string>()).Code();
else
lang = loot::Language::any;
BOOST_LOG_TRIVIAL(info) << "Using message language: " << Language(lang).Name();
bool doUpdate = _settings["Update Masterlist"] && _settings["Update Masterlist"].as<bool>();
masterlist_updater_parser mup(doUpdate, *_game, messages, mlist_plugins, mlist_messages, revision, date);
masterlist_updater_parser mup(doUpdate, *_game, messages, mlist_plugins, mlist_messages, revision, date, lang);
group.create_thread(mup);
//First calculate the mean plugin size. Store it temporarily in a map to reduce filesystem lookups and file size recalculation.
@@ -792,13 +802,6 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) {
// Merge & Check Metadata
///////////////////////////////////////////////////////
//Set language.
unsigned int lang;
if (_settings["Language"])
lang = Language(_settings["Language"].as<string>()).Code();
else
lang = loot::Language::any;
if (fs::exists(_game->MasterlistPath()) || fs::exists(_game->UserlistPath())) {