Changeset 239:30137dc83a72


Ignore:
Timestamp:
Sep 4, 2013, 8:20:36 PM (7 years ago)
Author:
Neil Muller <drnlmuller@…>
Branch:
default
Message:

Can has delete objects

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/area_editor.py

    r236 r239  
    3434from nagslang.enemies import Enemy, get_editable_enemies
    3535from nagslang.game_object import get_editable_game_objects
    36 from nagslang.puzzle import get_editable_puzzlers
     36from nagslang.puzzle import get_editable_puzzlers, PuzzleGlue
    3737
    3838# layout constants
     
    172172        return self._surface.copy()
    173173
     174    def reset_objs(self):
     175        # Reset the object state - needed when changing stuff
     176        self.drawables = []
     177        self.overlay_drawables = []
     178        self._glue = PuzzleGlue()
     179        for game_object_dict in self._game_objects:
     180            self._create_game_object(pymunk.Space(), **game_object_dict)
     181        for enemy_dict in self._enemies:
     182            self._create_enemy(pymunk.Space(), **enemy_dict)
     183
    174184
    175185class ObjectTable(TableView):
     
    392402            pass
    393403        elif res == 'Delete':
    394             pass
     404            self.level._game_objects.remove(choice)
     405            self.level.reset_objs()
    395406
    396407    def edit_enemies(self):
     
    404415            pass
    405416        elif res == 'Delete':
    406             pass
     417            self.level._enemies.remove(choice)
     418            self.level.reset_objs()
    407419
    408420    def _make_choice_dialog(self, classes):
     
    411423        for cls_name, cls in classes:
    412424            data.append({"classname": cls_name, "class": cls})
    413         edit_box = Dialog()
    414         edit_box.rect = pygame.rect.Rect(0, 0, 700, 500)
     425        choice_box = Dialog()
     426        choice_box.rect = pygame.rect.Rect(0, 0, 700, 500)
    415427        table = ObjectTable(data)
    416         edit_box.add(table)
     428        choice_box.add(table)
    417429        buttons = []
    418430        for text in ['OK', 'Cancel']:
    419             but = Button(text, action=lambda x=text: edit_box.dismiss(x))
     431            but = Button(text, action=lambda x=text: choice_box.dismiss(x))
    420432            buttons.append(but)
    421433        row = Row(buttons)
    422434        row.rect = pygame.rect.Rect(0, 450, 700, 50)
    423         edit_box.add(row)
    424         edit_box.get_selection = lambda: table.get_selection()
    425         return edit_box
     435        choice_box.add(row)
     436        choice_box.get_selection = lambda: table.get_selection()
     437        return choice_box
    426438
    427439    def add_game_object(self):
Note: See TracChangeset for help on using the changeset viewer.