Mercurial > nagslang
comparison 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 |
comparison
equal
deleted
inserted
replaced
116:ecbcf6569fdb | 117:9f3557e4833a |
---|---|
165 elif ev.key == pgl.K_0: | 165 elif ev.key == pgl.K_0: |
166 self.change_poly(None) | 166 self.change_poly(None) |
167 elif ev.key == pgl.K_d and self.cur_poly: | 167 elif ev.key == pgl.K_d and self.cur_poly: |
168 self.level.delete_point(self.cur_poly) | 168 self.level.delete_point(self.cur_poly) |
169 elif ev.key == pgl.K_f: | 169 elif ev.key == pgl.K_f: |
170 if level.all_closed(): | 170 self.set_filled() |
171 self.cur_poly = None | 171 |
172 self.filled_mode = True | 172 def set_filled(self): |
173 else: | 173 if level.all_closed(): |
174 print 'Not all polygons closed, so not filling' | 174 self.cur_poly = None |
175 self.filled_mode = True | |
176 else: | |
177 print 'Not all polygons closed, so not filling' | |
175 | 178 |
176 def mouse_move(self, ev): | 179 def mouse_move(self, ev): |
177 old_pos = self.mouse_pos | 180 old_pos = self.mouse_pos |
178 self.mouse_pos = ev.pos | 181 self.mouse_pos = ev.pos |
179 if self.cur_poly and old_pos != self.mouse_pos: | 182 if self.cur_poly and old_pos != self.mouse_pos: |
227 end_poly_but = PolyButton(None, self.level_widget) | 230 end_poly_but = PolyButton(None, self.level_widget) |
228 end_poly_but.rect = pygame.rect.Rect(0, 0, MENU_WIDTH, | 231 end_poly_but.rect = pygame.rect.Rect(0, 0, MENU_WIDTH, |
229 MENU_BUTTON_HEIGHT) | 232 MENU_BUTTON_HEIGHT) |
230 end_poly_but.rect.move_ip(MENU_LEFT, y) | 233 end_poly_but.rect.move_ip(MENU_LEFT, y) |
231 self.add(end_poly_but) | 234 self.add(end_poly_but) |
235 y += MENU_BUTTON_HEIGHT + MENU_PAD | |
236 | |
237 fill_but = Button('Fill exterior', action=self.level_widget.set_filled) | |
238 fill_but.rect = pygame.rect.Rect(0, 0, MENU_WIDTH, MENU_BUTTON_HEIGHT) | |
239 fill_but.rect.move_ip(MENU_LEFT, y) | |
240 self.add(fill_but) | |
232 y += MENU_BUTTON_HEIGHT + MENU_PAD | 241 y += MENU_BUTTON_HEIGHT + MENU_PAD |
233 | 242 |
234 save_but = Button('Save Level', action=self.save) | 243 save_but = Button('Save Level', action=self.save) |
235 save_but.rect = pygame.rect.Rect(0, 0, MENU_WIDTH, MENU_BUTTON_HEIGHT) | 244 save_but.rect = pygame.rect.Rect(0, 0, MENU_WIDTH, MENU_BUTTON_HEIGHT) |
236 save_but.rect.move_ip(MENU_LEFT, y) | 245 save_but.rect.move_ip(MENU_LEFT, y) |