Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/area_editor.py

    r236 r225  
    3232from nagslang.constants import SCREEN
    3333from nagslang.level import Level, POLY_COLORS, LINE_COLOR
    34 from nagslang.enemies import Enemy, get_editable_enemies
    35 from nagslang.game_object import get_editable_game_objects
    36 from nagslang.puzzle import get_editable_puzzlers
     34from nagslang.enemies import Enemy
     35
    3736
    3837# layout constants
     
    379378        row.rect = pygame.rect.Rect(0, 450, 700, 50)
    380379        edit_box.add(row)
    381         edit_box.get_selection = lambda: table.get_selection()
    382380        return edit_box
    383381
     
    385383        edit_box = self._make_edit_dialog(self.level._game_objects)
    386384        res = edit_box.present()
    387         choice = edit_box.get_selection()
    388         if choice is None:
    389             return
    390385        if res == 'OK':
    391386            # Edit object stuff goes here
     
    397392        edit_box = self._make_edit_dialog(self.level._enemies)
    398393        res = edit_box.present()
    399         choice = edit_box.get_selection()
    400         if choice is None:
    401             return
    402394        if res == 'OK':
    403395            # Edit object stuff goes here
    404396            pass
    405397        elif res == 'Delete':
    406             pass
    407 
    408     def _make_choice_dialog(self, classes):
    409         # Dialog to hold the editor
    410         data = []
    411         for cls_name, cls in classes:
    412             data.append({"classname": cls_name, "class": cls})
    413         edit_box = Dialog()
    414         edit_box.rect = pygame.rect.Rect(0, 0, 700, 500)
    415         table = ObjectTable(data)
    416         edit_box.add(table)
    417         buttons = []
    418         for text in ['OK', 'Cancel']:
    419             but = Button(text, action=lambda x=text: edit_box.dismiss(x))
    420             buttons.append(but)
    421         row = Row(buttons)
    422         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
    426 
    427     def add_game_object(self):
    428         classes = get_editable_game_objects()
    429         choose = self._make_choice_dialog(classes)
    430         res = choose.present()
    431         choice = choose.get_selection()
    432         if res == 'OK' and choice is not None:
    433             pass
    434 
    435     def add_enemy(self):
    436         classes = get_editable_enemies()
    437         choose = self._make_choice_dialog(classes)
    438         res = choose.present()
    439         choice = choose.get_selection()
    440         if res == 'OK' and choice is not None:
    441             pass
    442 
    443     def add_puzzler(self):
    444         classes = get_editable_puzzlers()
    445         choose = self._make_choice_dialog(classes)
    446         res = choose.present()
    447         choice = choose.get_selection()
    448         if res == 'OK' and choice is not None:
    449398            pass
    450399
     
    517466        y += MENU_BUTTON_HEIGHT + MENU_PAD
    518467
     468        save_but = Button('Save Level', action=self.save)
     469        save_but.rect = BUTTON_RECT.copy()
     470        save_but.rect.move_ip(MENU_LEFT, y)
     471        widgets.append(save_but)
     472        y += MENU_BUTTON_HEIGHT + MENU_PAD
     473
    519474        close_poly_but = Button('Close Polygon',
    520475                                action=self.level_widget.close_poly)
     
    543498        y += label.rect.height + MENU_PAD
    544499
    545         y += MENU_PAD
    546500        switch_but = Button('Switch to Objects', action=self.switch_to_objects)
    547501        switch_but.rect = BUTTON_RECT.copy()
     
    550504        y += switch_but.rect.height + MENU_PAD
    551505
    552         save_but = Button('Save Level', action=self.save)
    553         save_but.rect = BUTTON_RECT.copy()
    554         save_but.rect.move_ip(MENU_LEFT, y)
    555         widgets.append(save_but)
    556         y += MENU_BUTTON_HEIGHT + MENU_PAD
    557 
    558         y += MENU_PAD
    559506        quit_but = Button('Quit', action=self.quit)
    560507        quit_but.rect = BUTTON_RECT.copy()
     
    584531        y += MENU_BUTTON_HEIGHT + MENU_PAD
    585532
    586         add_obj_but = Button('Add Game Object',
    587                              action=self.level_widget.add_game_object)
    588         add_obj_but.rect = BUTTON_RECT.copy()
    589         add_obj_but.rect.move_ip(MENU_LEFT, y)
    590         widgets.append(add_obj_but)
    591         y += MENU_BUTTON_HEIGHT + MENU_PAD
    592 
    593         add_puzzle_but = Button('Add Puzzler',
    594                                 action=self.level_widget.add_puzzler)
    595         add_puzzle_but.rect = BUTTON_RECT.copy()
    596         add_puzzle_but.rect.move_ip(MENU_LEFT, y)
    597         widgets.append(add_puzzle_but)
    598         y += MENU_BUTTON_HEIGHT + MENU_PAD
    599 
    600         add_enemy_but = Button('Add Enemy',
    601                                action=self.level_widget.add_enemy)
    602         add_enemy_but.rect = BUTTON_RECT.copy()
    603         add_enemy_but.rect.move_ip(MENU_LEFT, y)
    604         widgets.append(add_enemy_but)
    605         y += MENU_BUTTON_HEIGHT + MENU_PAD
    606 
    607         y += MENU_PAD
     533        save_but = Button('Save Level', action=self.save)
     534        save_but.rect = BUTTON_RECT.copy()
     535        save_but.rect.move_ip(MENU_LEFT, y)
     536        widgets.append(save_but)
     537        y += MENU_BUTTON_HEIGHT + MENU_PAD
     538
    608539        switch_but = Button('Switch to Drawing', action=self.switch_to_draw)
    609540        switch_but.rect = BUTTON_RECT.copy()
     
    612543        y += switch_but.rect.height + MENU_PAD
    613544
    614         save_but = Button('Save Level', action=self.save)
    615         save_but.rect = BUTTON_RECT.copy()
    616         save_but.rect.move_ip(MENU_LEFT, y)
    617         widgets.append(save_but)
    618         y += MENU_BUTTON_HEIGHT + MENU_PAD
    619 
    620         y += MENU_PAD
    621545        quit_but = Button('Quit', action=self.quit)
    622546        quit_but.rect = BUTTON_RECT.copy()
Note: See TracChangeset for help on using the changeset viewer.