mail[Wesnoth-commits] r28685 - /trunk/src/addon_management.cpp


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

Header


Content

Posted by shadowm2006 on August 17, 2008 - 20:04:
Author: shadowmaster
Date: Sun Aug 17 20:04:41 2008
New Revision: 28685

URL: http://svn.gna.org/viewcvs/wesnoth?rev=28685&view=rev
Log:
* Update add-ons dialog won't appear if there's nothing to update.
* Simplified _info.cfg template in the C++ code.

Modified:
    trunk/src/addon_management.cpp

Modified: trunk/src/addon_management.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/addon_management.cpp?rev=28685&r1=28684&r2=28685&view=diff
==============================================================================
--- trunk/src/addon_management.cpp (original)
+++ trunk/src/addon_management.cpp Sun Aug 17 20:04:41 2008
@@ -639,19 +639,26 @@
                LOG_CFG << "generating version info for addon '" << addon_id 
<< "'\n";
                config f;
                f["name"] = "_info.cfg";
-               std::string s;
-               s += "#\n"
-                               "# Automatically generated by Wesnoth to keep 
track\n"
-                               "# of version information on installed 
add-ons.\n"
-                               "#\n";
-               s += "[info]\n";
-               if(!addon_type_str.empty()) {
-               s += "    type=\"" + addon_type_str + "\"\n";
-               }
-               s += "    uploads=\"" + addon_uploads_str + "\"\n";
-               s += "    version=\"" + addon_version_str + "\"\n";
-               s += "[/info]\n";
-               f["contents"] = s;
+               
+               utils::string_map info_tab;
+               info_tab["type"] = addon_type_str.empty() ? addon_type_str : 
std::string("unknown");
+               info_tab["uploads"] = addon_uploads_str;
+               info_tab["version"] = addon_version_str;
+
+               static std::string const info_template =
+                       "#\n"
+                       "# File automatically generated by Wesnoth to keep 
track\n"
+                       "# of version information on installed add-ons. DO 
NOT EDIT!\n"
+                       "#\n"
+                       "[info]\n"
+                       "    type=\"$type\"\n"
+                       "    uploads=\"$uploads\"\n"
+                       "    version=\"$version\"\n"
+                       "[/info]\n";
+               std::string const info_file_contents =
+                       
utils::interpolate_variables_into_string(info_template, &info_tab);
+               f["contents"] = info_file_contents;
+
                maindir->add_child("file", f);
                LOG_CFG << "generated version info, unpacking...\n";
                unarchive_addon(cfg);
@@ -735,6 +742,12 @@
                        gui::dialog(disp, warn_title, warn_entrytxt + 
unsafe_list.str(), gui::MESSAGE).show();
                }
                
+               if(safe_matches.empty()) {
+                       gui::dialog(disp, _("No add-ons to update"), _("Could 
not find any updated add-ons on this server."),
+                                   gui::MESSAGE).show();
+                       return;
+               }
+               
                // column contents
                std::vector<std::string> addons, titles, oldversions, 
newversions, options, filtered_opts;
                std::vector<int> sizes;




Related Messages


Powered by MHonArc, Updated Sun Aug 17 20:42:06 2008