Mercurial > nagslang
comparison tools/area_editor.py @ 518:83f3a376e9a7
Allow choosing polygon for outlines
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Sat, 07 Sep 2013 19:59:30 +0200 |
parents | b5838fb35db3 |
children | 9868bc79a6ff |
comparison
equal
deleted
inserted
replaced
517:51b5b8bf505a | 518:83f3a376e9a7 |
---|---|
359 hintlabel = Label(hint) | 359 hintlabel = Label(hint) |
360 hintlabel.rect = pygame.rect.Rect(640, y, 250, 25) | 360 hintlabel.rect = pygame.rect.Rect(640, y, 250, 25) |
361 self.add(hintlabel) | 361 self.add(hintlabel) |
362 y += 30 | 362 y += 30 |
363 if self.poly_field: | 363 if self.poly_field: |
364 y += 20 | 364 y += 40 |
365 button = Button('Use Polygon 6', action=self.get_poly) | 365 label = Label("Polygon to use:") |
366 label.rect = pygame.rect.Rect(40, y, 200, 25) | |
367 self.add(label) | |
368 self.poly_choice = TextField() | |
369 self.poly_choice.rect = pygame.Rect(280, y, 400, 25) | |
370 self.add(self.poly_choice) | |
371 y += 30 | |
372 button = Button('Use Polygon X', action=self.get_poly) | |
366 button.rect = pygame.rect.Rect(350, y, 250, 30) | 373 button.rect = pygame.rect.Rect(350, y, 250, 30) |
367 self.add(button) | 374 self.add(button) |
368 buttons = [] | 375 buttons = [] |
369 if delete: | 376 if delete: |
370 labels = ['OK', 'Delete', 'Cancel'] | 377 labels = ['OK', 'Delete', 'Cancel'] |
377 row.rect = pygame.rect.Rect(250, 500, 700, 50) | 384 row.rect = pygame.rect.Rect(250, 500, 700, 50) |
378 self.add(row) | 385 self.add(row) |
379 | 386 |
380 def get_poly(self): | 387 def get_poly(self): |
381 try: | 388 try: |
382 data = self.level_widget.level.polygons[6][:] | 389 try: |
390 index = int(self.poly_choice.get_text()) | |
391 except TypeError: | |
392 index = 0 | |
393 data = self.level_widget.level.polygons[index][:] | |
383 except KeyError: | 394 except KeyError: |
384 data = [] | 395 data = [] |
385 if data: | 396 if data: |
386 # We unclose the polygon, because that's what pymunk | 397 # We unclose the polygon, because that's what pymunk |
387 # wants | 398 # wants |