changeset 515:1b1bd4f39e5c

Ask before quitting the level editor
author Neil Muller <drnlmuller@gmail.com>
date Sat, 07 Sep 2013 19:47:48 +0200
parents 04066416fcec
children b5838fb35db3
files tools/area_editor.py
diffstat 1 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/tools/area_editor.py	Sat Sep 07 19:44:31 2013 +0200
+++ b/tools/area_editor.py	Sat Sep 07 19:47:48 2013 +0200
@@ -24,7 +24,7 @@
 from albow.root import RootWidget
 from albow.widget import Widget
 from albow.controls import Button, Label, CheckBox
-from albow.dialogs import alert, Dialog
+from albow.dialogs import alert, Dialog, ask
 from albow.layout import Row
 from albow.fields import TextField
 from albow.table_view import TableView, TableColumn
@@ -1074,7 +1074,7 @@
         widgets.append(zoom_in)
 
         y = SCREEN[1] - MENU_BUTTON_HEIGHT - MENU_PAD
-        quit_but = Button('Quit', action=self.quit)
+        quit_but = Button('Quit', action=self.do_quit)
         quit_but.rect = BUTTON_RECT.copy()
         quit_but.rect.move_ip(MENU_LEFT, y)
         widgets.append(quit_but)
@@ -1167,7 +1167,7 @@
         y += MENU_BUTTON_HEIGHT + MENU_PAD
 
         y = SCREEN[1] - MENU_BUTTON_HEIGHT - MENU_PAD
-        quit_but = Button('Quit', action=self.quit)
+        quit_but = Button('Quit', action=self.do_quit)
         quit_but.rect = BUTTON_RECT.copy()
         quit_but.rect.move_ip(MENU_LEFT, y)
         widgets.append(quit_but)
@@ -1176,12 +1176,17 @@
 
     def key_down(self, ev):
         if ev.key == pgl.K_ESCAPE:
-            self.quit()
+            self.do_quit()
         elif ev.key == pgl.K_s:
             self.save()
         else:
             self.level_widget.key_down(ev)
 
+    def do_quit(self):
+        res = ask("Really Quit?")
+        if res == "OK":
+            self.quit()
+
     def save(self):
         closed, messages = self.level.all_closed()
         if closed: