mail[Wesnoth-commits] r33912 - /trunk/src/game_preferences_display.cpp


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by guillaume . melquiond on March 20, 2009 - 08:09:
Author: silene
Date: Fri Mar 20 08:09:12 2009
New Revision: 33912

URL: http://svn.gna.org/viewcvs/wesnoth?rev=33912&view=rev
Log:
Removed config::get_children.

Modified:
    trunk/src/game_preferences_display.cpp

Modified: trunk/src/game_preferences_display.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_preferences_display.cpp?rev=33912&r1=33911&r2=33912&view=diff
==============================================================================
--- trunk/src/game_preferences_display.cpp (original)
+++ trunk/src/game_preferences_display.cpp Fri Mar 20 08:09:12 2009
@@ -18,6 +18,7 @@
 #include "display.hpp"
 #include "filesystem.hpp"
 #include "filechooser.hpp"
+#include "foreach.hpp"
 #include "gettext.hpp"
 #include "preferences_display.hpp"
 #include "wml_separators.hpp"
@@ -942,9 +943,11 @@
 
 const config* preferences_dialog::get_advanced_pref() const
 {
-       const config::child_list& adv = 
game_cfg_.get_children("advanced_preference");
-       if(advanced_selection_ >= 0 && advanced_selection_ < int(adv.size())) 
{
-               return adv[advanced_selection_];
+       config::const_child_itors itors = 
game_cfg_.child_range("advanced_preference");
+       int nb_prefs = std::distance(itors.first, itors.second);
+       if (advanced_selection_ >= 0 && advanced_selection_ < nb_prefs) {
+               std::advance(itors.first, advanced_selection_);
+               return &*itors.first;
        } else {
                return NULL;
        }
@@ -953,12 +956,12 @@
 void preferences_dialog::set_advanced_menu()
 {
        std::vector<std::string> advanced_items;
-       const config::child_list& adv = 
game_cfg_.get_children("advanced_preference");
-       for(config::child_list::const_iterator i = adv.begin(); i != 
adv.end(); ++i) {
+       foreach (const config &adv, 
game_cfg_.child_range("advanced_preference"))
+       {
                std::ostringstream str;
-               std::string field = preferences::get((**i)["field"]);
+               std::string field = preferences::get(adv["field"]);
                if(field.empty()) {
-                       field = (**i)["default"];
+                       field = adv["default"];
                }
 
                if(field == "yes") {
@@ -967,7 +970,7 @@
                        field = _("no");
                }
 
-               str << (**i)["name"] << COLUMN_SEPARATOR << field;
+               str << adv["name"] << COLUMN_SEPARATOR << field;
                advanced_items.push_back(str.str());
        }
 




Related Messages


Powered by MHonArc, Updated Fri Mar 20 08:20:30 2009