def init_archy(fullscreenFlag=0): global screen global fullscreen_mode if fullscreen_mode == fullscreenFlag: return fullscreen_mode = fullscreenFlag if fullscreenFlag: set_mouse_visibility(0) screen = pygame.display.set_mode(FULLSCREEN_SCREEN_SIZE, FULLSCREEN) else: set_mouse_visibility(1) screen = pygame.display.set_mode(WINDOWED_SCREEN_SIZE) margin = 4 screen.fill([255, 255, 255]) screen_surface = surfaces.PygameSurface(surface=screen.subsurface( [[margin, 0], [screen.get_width() - 2 * margin, screen.get_height()]])) archyState.init(screen_surface) print(user_directory) #Because the text documents have been entirely reinitialized the cursorObserver is no longer registered as an observer. If we want focus events to work (see cursor.py) we need to reregister the cursor observer by reinstantiate it. cursorObserver = commands.cursor.CursorObserver()
def doGenerateSymbolSurface(self, size, styleID): newSurface = surfaces.PygameSurface(size) newSurface.clear() newSurface.setBackgroundToTransparent() dot_center = (size[0] / 2, size[1] / 2) newSurface.drawCircle(dot_center, self.DOT_RADIUS, self.SYMBOL_COLOR) return newSurface
def __init__(self, size): self.height = size[1] self.width = size[0] self.ascent = self.height self.descent = 0 self.lineHeight = self.height self._surface = surfaces.PygameSurface(size) self._surface.clear() self._surface.setBackgroundToTransparent()
def _makeSurface(self): if self.width == 0: self._surface = None return newSurface = surfaces.PygameSurface((self.width, self.HEIGHT)) newSurface.clear() grayBarSize = (self.width - (self.MARGIN_SIZE * 2), self.HEIGHT - (self.MARGIN_SIZE * 1)) grayBarPos = (self.MARGIN_SIZE, self.MARGIN_SIZE) newSurface.drawRectangle(grayBarSize, grayBarPos, self.COLOR, 255) self._surface = newSurface
def doGenerateSymbolSurface(self, size, styleID): newSurface = surfaces.PygameSurface(size) newSurface.clear() newSurface.setBackgroundToTransparent() start = (self.ARROW_MARGIN, size[1] / 2) end = (size[0] - self.ARROW_MARGIN, size[1] / 2) arrowLine1 = (end[0] - self.ARROW_LENGTH, size[1] / 2 + self.ARROW_HEIGHT) arrowLine2 = (arrowLine1[0], size[1] / 2 - self.ARROW_HEIGHT) newSurface.drawLine(start, end, self.SYMBOL_COLOR, self.WIDTH) newSurface.drawLine(arrowLine1, end, self.SYMBOL_COLOR, self.WIDTH) newSurface.drawLine(arrowLine2, end, self.SYMBOL_COLOR, self.WIDTH) return newSurface
def makeSurface(self, screenWidth): if self._cached_screenWidth != screenWidth or self._height_changed: self._surface = surfaces.PygameSurface((screenWidth, self._height)) self._height_changed = 0 self._cached_screenWidth = screenWidth #print "bustin' a new surface. %d" % id(self._surface) if self.parent.isTransparent(): self._surface.setBackgroundToTransparent() # TODO: Maybe we can optimize out this clear() at some point. self._surface.clear() x = self._margin for glyph in self._glyphs: y = self._ascent - glyph.ascent self._surface.blitRectangle(glyph.render(), (x, y)) x += glyph.width
def __init__(self, width=0): self._char = "|" self.isWhitespace = 0 import pygame, os base = "keycaps" self._surface = surfaces.PygameSurface( surface=pygame.image.load(os.path.join(base, self.FILE))) self.height = self._surface.getHeight() self.width = self._surface.getWidth() self.ascent = self.height - 9 self.descent = 0 self.lineHeight = self.height
def render(self, char): if not self._characters.has_key(char): try: if self.outline: import pygame.font theFont = pygame.font.SysFont(self.fontName, self.size - 3, self.bold, self.italic) charSurf = outlineText(theFont, char, self.fgcolor) else: charSurf = self._font.render(char, self.ANTIALIAS, self.fgcolor, self.bgcolor) # Note here that if the character is invalid and SDL TTF can't render the glyph, we'll just insert a '?' character for now, so that Archy doesn't crash. except: charSurf = self._font.render('?', self.ANTIALIAS, self.fgcolor, self.bgcolor) self._characters[char] = surfaces.PygameSurface( surface=charSurf) #surfaces.PygameSurface(surface = ) return self._characters[char]