def __init__(self, rect, font, scrollback=1000, bg=(255, 165, 0)): image = pygame.Surface(rect.size) image.set_colorkey(bg) image.set_alpha(127) image.fill(bg) Sprite.__init__(self, rect, image) self.scrollback = scrollback self.buffer = [''] * scrollback self.font = font self.bg = bg self.linesize = linesize(font) self.numlines = int(self.rect.height / self.linesize) + 1 self.currentcolor = (255, 255, 255) self.offset = 0
def object_image_load(parameters): """ @param parameters: list with picture parameters (NAME, TRANSPARENCY, SIZE) @return: image descriptor """ from pygame.constants import RLEACCEL from pygame import error from pygame.transform import scale import pygame.image try: image = pygame.image.load('res/' + parameters[0] + '.bmp').convert() except error: error_message("Loading:", "not found " + parameters[0] + '.bmp') else: image.set_colorkey(image.get_at((0, 0)), RLEACCEL) image.set_alpha(parameters[1]) image = scale(image, (parameters[2][0], parameters[2][1])) return image
def mouseon(self): # we want the ORT to behave like an exit if self.nick == 'ORT_Number_1': self.server.whichmouseover('ov_tram_exit') if self.label is not None: print self.nick, 'on' self.label.die() # Strip color codes from the nick for display nicklist = list(self.nick) nick = '' avoid = list(string.digits) avoid.extend([',', '\x03']) found = 0 for n in nicklist: if n == '\x03': found = 1 if found == 1: try: test = avoid.index(n) except: found = 0 if found == 0: nick = nick + n sx, sy = _font.size(nick) s = _font.render(nick, 0, (255, 255, 255)) image = pygame.Surface((sx+2, sy+2)) image.set_colorkey((255,165,0)) image.fill((255,165,0)) for x in range(3): for y in range(3): image.blit(s, (x, y)) image.blit(_font.render(nick, 1, (0,0,0)), (1, 1)) image.set_alpha(127) x, y = self.rect.center nx, ny = self.noffset self.label = ClampingSprite((x+nx, y+ny), image, Rect(0, 0, 640, 480)) self.group.add(self.label) return [self.label.rect]