Author: elias
Date: Fri May  2 15:21:09 2008
New Revision: 26314

URL: http://svn.gna.org/viewcvs/wesnoth?rev=26314&view=rev
Log:
wmlunits: Make base_unit work recursively (one unit in EE needed that) and 
write lots of verbose error about missing attack icons :P

Modified:
    trunk/data/tools/unit_tree/helpers.py
    trunk/data/tools/wmlunits

Modified: trunk/data/tools/unit_tree/helpers.py
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/tools/unit_tree/helpers.py?rev=26314&r1=26313&r2=26314&view=diff
==============================================================================
--- trunk/data/tools/unit_tree/helpers.py (original)
+++ trunk/data/tools/unit_tree/helpers.py Fri May  2 15:21:09 2008
@@ -79,7 +79,6 @@
             bases = [os.path.join(self.datadir, "core/images")]
         else:
             bases = [os.path.join(self.datadir, "core/images")]
-            bases += [os.path.join(self.datadir, "core/images/attacks")]
             binpaths = self.pathes_per_campaign.get(c, [])
             binpaths.reverse()
             for x in binpaths:
@@ -93,11 +92,12 @@
             if os.path.exists(ipath): return ipath, None
         return None, bases
 
-    def add_image(self, campaign, path):
-        if (campaign, path) in self.notfound: return self.notfound[(campaign, 
path)]
+    def add_image_check(self, campaign, path):
+        if (campaign, path) in self.notfound:
+            return self.notfound[(campaign, path)], True
         ipath, error = self.find_image(path, campaign)
         if ipath in self.ipathes:
-            return self.ipathes[ipath]
+            return self.ipathes[ipath], False
     
         name = "%05d_" % self.id
         name += os.path.basename(path)
@@ -106,8 +106,13 @@
         self.images[name] = ipath, path, campaign, error
         if ipath:
             self.ipathes[ipath] = name
+            return name, False
         else:
             self.notfound[(campaign, path)] = name
+            return name, True
+        
+    def add_image(self, campaign, path):
+        name, error = self.add_image_check(campaign, path)
         return name
 
     def copy_and_color_images(self, target_path):

Modified: trunk/data/tools/wmlunits
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/tools/wmlunits?rev=26314&r1=26313&r2=26314&view=diff
==============================================================================
--- trunk/data/tools/wmlunits (original)
+++ trunk/data/tools/wmlunits Fri May  2 15:21:09 2008
@@ -497,8 +497,6 @@
         write(html_header % {"path" : "../"})
         self.write_navbar()
 
-        base_unit = self.wesnoth.get_base_unit(unit)
-
         # Write unit name, picture and description.
         uid = unit.get_text_val("id")
         uname = self.wesnoth.get_unit_value(unit, "name")
@@ -599,22 +597,27 @@
                 if isinstance(c, wmldata.DataText):
                     copy_to.set_text_val(c.name, c.data)
         
-        # Use attacks of base_units as base, if we have one.
-        attacks = []
-        if base_unit:
-            attacks = base_unit.get_all("attack")
-        for i, attack in enumerate(unit.get_all("attack")):
-            aid = attack.get_text_val("name")
-            if aid:
-                for already in attacks:
-                    if already.get_text_val("name") == aid:
-                        copy_attributes(attack, already)
-                        break
+        def get_recursive_attacks(this_unit):
+            # Use attacks of base_units as base, if we have one.
+            base_unit = self.wesnoth.get_base_unit(this_unit)
+            attacks = []
+            if base_unit:
+                attacks = get_recursive_attacks(base_unit)
+            
+            for i, attack in enumerate(this_unit.get_all("attack")):
+                aid = attack.get_text_val("name")
+                if aid:
+                    for already in attacks:
+                        if already.get_text_val("name") == aid:
+                            copy_attributes(attack, already)
+                            break
+                    else:
+                        attacks.append(attack)
                 else:
-                    attacks.append(attack)
-            else:
-                copy_attributes(attack, attacks[i])
-
+                    copy_attributes(attack, attacks[i])
+            return attacks
+
+        attacks = get_recursive_attacks(unit)
         for attack in attacks:
             write("<tr>")
 
@@ -624,11 +627,11 @@
             icon = attack.get_text_val("icon")
             if not icon:
                 icon = "attacks/%s.png" % aid
-            
-            if not icon:
-                sys.stderr.write("Warning: " + uid + " has attack icon.\n")
-
-            picname = image_collector.add_image(unit.campaign, icon)
+
+            picname, error = image_collector.add_image_check(unit.campaign, 
icon)
+            if error:
+                sys.stderr.write("Error: No attack icon '%s' found for 
'%s'.\n" % (
+                    icon, uid))
             icon = os.path.join("../pics", picname)
             write("<td><img src=\"%s\" alt=\"(image)\"/></td>" % icon)
 


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to