From: <geo...@us...> - 2014-04-12 09:00:24
|
Revision: 7045 http://sourceforge.net/p/freeorion/code/7045 Author: geoffthemedio Date: 2014-04-12 09:00:21 +0000 (Sat, 12 Apr 2014) Log Message: ----------- Enabled sitrep filters as an observer. Modified Paths: -------------- trunk/FreeOrion/UI/SitRepPanel.cpp Modified: trunk/FreeOrion/UI/SitRepPanel.cpp =================================================================== --- trunk/FreeOrion/UI/SitRepPanel.cpp 2014-04-12 08:58:43 UTC (rev 7044) +++ trunk/FreeOrion/UI/SitRepPanel.cpp 2014-04-12 09:00:21 UTC (rev 7045) @@ -78,17 +78,35 @@ return sitrep_order; } - std::vector<std::string> AllSitRepTemplateStrings() { + std::set<std::string> EmpireSitRepTemplateStrings(int empire_id) { std::set<std::string> template_set; - std::vector<std::string> retval; - Empire *empire = HumanClientApp::GetApp()->Empires().Lookup(HumanClientApp::GetApp()->EmpireID()); + + Empire *empire = HumanClientApp::GetApp()->Empires().Lookup(empire_id); if (!empire) - return retval; + return template_set; + for (Empire::SitRepItr sitrep_it = empire->SitRepBegin(); sitrep_it != empire->SitRepEnd(); ++sitrep_it) { template_set.insert(sitrep_it->GetTemplateString()); } + + return template_set; + } + + std::vector<std::string> AllSitRepTemplateStrings() { + std::set<std::string> template_set; + + // get templates for each empire + for (EmpireManager::iterator it = Empires().begin(); + it != Empires().end(); ++it) + { + std::set<std::string> empire_strings = EmpireSitRepTemplateStrings(it->first); + template_set.insert(empire_strings.begin(), empire_strings.end()); + } + + std::vector<std::string> retval; + + // only use those ordered templates actually in the current set of sitrep templates std::vector<std::string> ordered_templates = OrderedSitrepTemplateStrings(); - // only use those ordered templates actually in the current set of sitrep templates for (std::vector<std::string>::iterator it = ordered_templates.begin(); it!=ordered_templates.end(); it++) { @@ -96,10 +114,12 @@ (std::find(retval.begin(), retval.end(), *it) == retval.end()) ) { retval.push_back(*it); } } + //now add the current templates that did not have a specified order for (std::set<std::string>::iterator it = template_set.begin(); it!= template_set.end(); it++) if (std::find(retval.begin(), retval.end(), *it) == retval.end()) retval.push_back(*it); + return retval; } @@ -340,7 +360,8 @@ GG::PopupMenu popup(m_filter_button->Left(), m_filter_button->Bottom(), ClientUI::GetFont(), menu_contents, ClientUI::TextColor(), - ClientUI::WndOuterBorderColor(), ClientUI::WndColor(), ClientUI::EditHiliteColor()); + ClientUI::WndOuterBorderColor(), ClientUI::WndColor(), + ClientUI::EditHiliteColor()); if (!popup.Run()) return; int selected_menu_item = popup.MenuID(); |