Changeset 528:811481b20689


Ignore:
Timestamp:
Sep 7, 2013, 6:54:13 PM (7 years ago)
Author:
Simon Cross <hodgestar@…>
Branch:
default
rebase_source:
0fe1460c4601d3cd6f0b8fa3510903dbf93ee5bd
Message:

Add support for collectables.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • nagslang/collectable.py

    r385 r528  
    77                                  make_body)
    88from nagslang.resources import resources
     9
     10
     11def get_editable_game_objects():
     12    classes = []
     13    for cls_name, cls in globals().iteritems():
     14        if isinstance(cls, type) and hasattr(cls, 'requires'):
     15            classes.append((cls_name, cls))
     16    return classes
    917
    1018
  • tools/area_editor.py

    r524 r528  
    3636import nagslang.enemies as ne
    3737import nagslang.game_object as ngo
     38import nagslang.collectable as collectable
    3839import nagslang.puzzle as np
    3940
     
    201202        modules = {
    202203            'game_object': ngo,
     204            'collectable': collectable,
    203205            'enemies': ne,
    204206            'puzzle': np,
    205             }
     207        }
    206208        if '.' in classname:
    207209            modname, classname = classname.split('.')
     
    824826    def add_game_object(self):
    825827        classes = ngo.get_editable_game_objects()
     828        classes.extend(("collectable.%s" % cls_name, cls)
     829                       for cls_name, cls
     830                       in collectable.get_editable_game_objects())
    826831        choose = self._make_choice_dialog(classes)
    827832        res = choose.present()
Note: See TracChangeset for help on using the changeset viewer.