예제 #1
0
    def __init__(self, parent, ms, map_name):
        wx.Window.__init__(self, parent, id=wx.ID_ANY,
                            style=wx.WANTS_CHARS
                          #| wx.RAISED_BORDER
                          #| wx.SUNKEN_BORDER
                           , name="sink")

        self.map_name = map_name
        doc = etree.ElementTree(file='map.xml')
        map_xml = doc.xpath('//map[@name="%s"]' % map_name)[0]

        if map_xml.get('image'):
            bg_image_path = os.path.expanduser('~/bin/el_linux/maps/%s' % map_xml.get('image'))
            self.image = wx.Image(bg_image_path, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
        else:
            self.image = None


        self.ms = ms
        self.doors = map(lambda x: DoorSprite(self.ms, x),
                         self.ms.doors(map_name))

        self.rooms = map(lambda x: RoomSprite(ms, map_name,
                                              str_to_touple(x.get('p1')),
                                              str_to_touple(x.get('p2'))),
                         map_xml.xpath('room'))
        self.Bind(wx.EVT_PAINT, self.OnPaint)
        self.Bind(wx.EVT_SIZE, self.OnSize)
        self.Bind(wx.EVT_MOUSE_EVENTS, self.OnMouse)
예제 #2
0
 def beam_location(self):
     loc_xml = self.doc.xpath('//beam')[0]
     return Location(self.map_name(loc_xml),
                     str_to_touple(loc_xml.get('loc')))
예제 #3
0
 def map_size(self, map_name):
     map_xml = self.doc.xpath('//map[@name="%s"]' % map_name)[0]
     return str_to_touple(map_xml.get('size'))