Ignore:
Timestamp:
09/02/13 14:40:56 (8 years ago)
Author:
Neil Muller <drnlmuller@…>
Branch:
default
Phase:
public
Message:

Use dialogs to report save results

File:
1 edited

Legend:

Unmodified
Added
Removed
  • nagslang/level.py

    r118 r122  
    6767        """Check if all the polygons are closed"""
    6868        closed = True
    69         for poly in self.polygons.values():
     69        messages = []
     70        for index, poly in self.polygons.items():
    7071            if len(poly) == 0:
    7172                # We ignore empty polygons
     
    7374            elif len(poly) == 1:
    7475                closed = False
    75                 print "\033[31mError: polygon too small\033[0m"
     76                messages.append("Error: polygon %s too small" % index)
    7677            elif poly[-1] != poly[0]:
    7778                closed = False
    78                 print "\033[31mError: polygon not closed\033[0m"
    79         return closed
     79                messages.append("Error: polygon %s not closed" % index)
     80        return closed, messages
    8081
    8182    def save(self):
    82         closed = self.all_closed()
     83        closed, _ = self.all_closed()
    8384        if not closed:
    84             print 'Not saving the level'
    85             return
     85            return False
    8686        with resources.get_file('levels', self.name, mode='w') as f:
    8787            f.write('X-Size: %s\n' % self.x)
     
    9494                for point in poly:
    9595                    f.write('Point: %d %d\n' % point)
    96         print 'level %s saved' % self.name
     96        return True
    9797
    9898    def get_size(self):
Note: See TracChangeset for help on using the changeset viewer.