Beispiel #1
0
 def __init__ (self, sfc, size = None):
     if size is None:
         self.sfc = sfc
     else:
         self.sfc = blank_sfc(size)
         position_sfc(sfc, self.sfc)
     Widget.__init__(self, sfc.get_size())
Beispiel #2
0
 def _method_map (self, methods):
     width = self.size[0]
     pad = 1
     using_b_c = conf.LINE_COLOUR_BAD[0]
     affected_b_c = conf.LINE_COLOUR_GOOD[0]
     sz = conf.METHOD_ICON_SIZE
     n_per_row = (width + pad) / (sz + 6 + pad)
     x0 = (width - (n_per_row * (sz + 6) + (n_per_row - 1) * pad)) / 2
     rows = []
     row = [x0]
     for method in methods:
         method, disabled, using, affected = method
         if len(row) == 2 * n_per_row + 1:
             rows.append(row)
             rows.append(pad)
             row = [x0]
         img = game.img(method + '.png')
         sfc = blank_sfc((sz + 6, sz + 6))
         if using:
             sfc.fill(using_b_c)
         if affected:
             if using:
                 sfc.fill(affected_b_c, (1, 1, sz + 4, sz + 4))
             else:
                 sfc.fill(affected_b_c)
         if using or affected:
             sfc.fill((0, 0, 0, 0), (2, 2, sz + 2, sz + 2))
         sfc.blit(img, (3, 3))
         if disabled:
             sfc.fill((150, 150, 150), None, pg.BLEND_RGBA_MULT)
         row.append(sfc)
         row.append(pad)
     rows.append(row)
     row.pop(-1)
     return rows
Beispiel #3
0
 def __init__ (self, size, text, font, just = 1):
     text = game.render_text(font, text, conf.TEXT_COLOUR, width = size[0],
                             just = just)[0]
     ts = text.get_size()
     size = [ts[i] if size[i] is None else size[i] for i in (0, 1)]
     sfc = blank_sfc(size)
     position_sfc(text, sfc)
     Img.__init__(self, sfc)
Beispiel #4
0
 def __init__ (self, width, text, cb, *args, **kwargs):
     b_data = conf.BUTTON_BORDER
     bw = b_data['width']
     bc = b_data['colour']
     ListItem.__init__(self, width - 2 * bw, text)
     w, h = self.size
     w += 2 * bw
     h += 2 * bw
     self.size = (w, h)
     sfcs = []
     for bc in (bc, tuple(reversed(bc))):
         sfc = blank_sfc(self.size)
         sfc.blit(self.sfc, (bw, bw))
         sfc.fill(bc[0], (0, bw, bw, h))
         sfc.fill(bc[0], (0, 0, w, bw))
         sfc.fill(bc[1], (w - bw, bw, bw, h - 2 * bw))
         sfc.fill(bc[1], (bw, h - bw, w - bw, bw))
         sfcs.append(sfc)
     self._sfc, self._click_sfc = sfcs
     self.sfc = self._sfc
     self.cb = lambda *pre_args: cb(*(pre_args + args), **kwargs)
     self._down = []