comparison tools/area_editor.py @ 528:811481b20689

Add support for collectables.
author Simon Cross <hodgestar@gmail.com>
date Sat, 07 Sep 2013 20:54:13 +0200
parents 011a087c4370
children 80264aee0af2
comparison
equal deleted inserted replaced
527:276f664ec5da 528:811481b20689
33 from nagslang.constants import SCREEN 33 from nagslang.constants import SCREEN
34 from nagslang.level import Level, POLY_COLORS, LINE_COLOR 34 from nagslang.level import Level, POLY_COLORS, LINE_COLOR
35 from nagslang.yamlish import load_s 35 from nagslang.yamlish import load_s
36 import nagslang.enemies as ne 36 import nagslang.enemies as ne
37 import nagslang.game_object as ngo 37 import nagslang.game_object as ngo
38 import nagslang.collectable as collectable
38 import nagslang.puzzle as np 39 import nagslang.puzzle as np
39 40
40 # layout constants 41 # layout constants
41 MENU_BUTTON_HEIGHT = 35 42 MENU_BUTTON_HEIGHT = 35
42 MENU_PAD = 4 43 MENU_PAD = 4
198 199
199 def get_class(self, classname, mod=None): 200 def get_class(self, classname, mod=None):
200 # Get the class given the classname 201 # Get the class given the classname
201 modules = { 202 modules = {
202 'game_object': ngo, 203 'game_object': ngo,
204 'collectable': collectable,
203 'enemies': ne, 205 'enemies': ne,
204 'puzzle': np, 206 'puzzle': np,
205 } 207 }
206 if '.' in classname: 208 if '.' in classname:
207 modname, classname = classname.split('.') 209 modname, classname = classname.split('.')
208 mod = modules[modname] 210 mod = modules[modname]
209 if mod is None: 211 if mod is None:
210 mod = ngo 212 mod = ngo
821 choice_box.get_selection = lambda: table.get_selection() 823 choice_box.get_selection = lambda: table.get_selection()
822 return choice_box 824 return choice_box
823 825
824 def add_game_object(self): 826 def add_game_object(self):
825 classes = ngo.get_editable_game_objects() 827 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())
826 choose = self._make_choice_dialog(classes) 831 choose = self._make_choice_dialog(classes)
827 res = choose.present() 832 res = choose.present()
828 choice = choose.get_selection() 833 choice = choose.get_selection()
829 if res == 'OK' and choice is not None: 834 if res == 'OK' and choice is not None:
830 classname = choice['classname'] 835 classname = choice['classname']