diff tools/area_editor.py @ 117:9f3557e4833a

Add fill button
author Neil Muller <drnlmuller@gmail.com>
date Mon, 02 Sep 2013 15:29:37 +0200
parents ecbcf6569fdb
children 02423600d958
line wrap: on
line diff
--- a/tools/area_editor.py	Mon Sep 02 15:24:21 2013 +0200
+++ b/tools/area_editor.py	Mon Sep 02 15:29:37 2013 +0200
@@ -167,11 +167,14 @@
         elif ev.key == pgl.K_d and self.cur_poly:
             self.level.delete_point(self.cur_poly)
         elif ev.key == pgl.K_f:
-            if level.all_closed():
-                self.cur_poly = None
-                self.filled_mode = True
-            else:
-                print 'Not all polygons closed, so not filling'
+            self.set_filled()
+
+    def set_filled(self):
+        if level.all_closed():
+            self.cur_poly = None
+            self.filled_mode = True
+        else:
+            print 'Not all polygons closed, so not filling'
 
     def mouse_move(self, ev):
         old_pos = self.mouse_pos
@@ -231,6 +234,12 @@
         self.add(end_poly_but)
         y += MENU_BUTTON_HEIGHT + MENU_PAD
 
+        fill_but = Button('Fill exterior', action=self.level_widget.set_filled)
+        fill_but.rect = pygame.rect.Rect(0, 0, MENU_WIDTH, MENU_BUTTON_HEIGHT)
+        fill_but.rect.move_ip(MENU_LEFT, y)
+        self.add(fill_but)
+        y += MENU_BUTTON_HEIGHT + MENU_PAD
+
         save_but = Button('Save Level', action=self.save)
         save_but.rect = pygame.rect.Rect(0, 0, MENU_WIDTH, MENU_BUTTON_HEIGHT)
         save_but.rect.move_ip(MENU_LEFT, y)