Ejemplo n.º 1
0
    def __init__(self, height, font, ps1, ps2):
        borders = (None,None,None, shader.HorizontalBevel((200,200,0),
            (128,128,0), (64,64,0), 1, 3, 1), None, None, None, None)

        shader.Frame.__init__(self, borders, alpha=255, name="ConsoleFrame")

        try:
            self.log = open(logFile, 'w')
        except:
            parole.warn('Unable to open console log file "%s" for writing.',
                    logFile)
            self.log = cStringIO.StringIO()

        try:
            self.histf = open(historyFile, 'a')
        except:
            parole.warn('Unable to open console history file "%s" for writing.',
                    logFile)
            self.histf = cStringIO.StringIO()

        self.ps1, self.ps2 = ps1, ps2
        self.__font = font

        screenWidth = display.getSurface().get_width()
        self.readLineBox = shader.ReadLineBox(font, screenWidth-5,
                prompt=self.ps1)
        self.scroll = shader.ScrollView((screenWidth, height - \
            self.readLineBox.height),
            vbar=shader.VerticalScrollbar((128,128,0), (64,64,0), 10),
            followY=True)
        self.textblock = shader.TextBlockPass(font, (255,255,255),
                wrap_width=screenWidth-20, ignoreMarkup=True)
        self.background = shader.ColorField((0,0,128,220), (screenWidth,
            height))

        self.addPass(self.background)
        self.scroll.addPass(self.textblock, pos=(5,0))
        self.addPass(self.scroll)

        self.addPass(self.readLineBox, pos=(5, height -
            self.readLineBox.height))

        self.active = False

        self.cmdMap = input.CommandMap(parole.conf.console.commands,
                self.handleCommand, peek=True)
        self.readLine = input.ReadLine(self.onNewline, 
                self.readLineBox.onInput)
Ejemplo n.º 2
0
    def __init__(self):
        super(SplashShader, self).__init__("SplashShader",
                size=display.getSurface().get_size())
        self.startTime = 0
        self.endTime = 0

        self.goldSound = resource.getSound('sounds/enginesplash.wav')

        # Background field
        self.pBG = shader.ColorField((255,255,255), self.size)
        self.addPass(self.pBG, pos=(0,0))

        font = resource.getFont('fonts/monaco.ttf', 12)

        # Copyright
        gray = (108,108,108)
        copyright = "Engine copyright 2012 by Max Bane"
        copyrightSize = font.size(copyright)
        copyrightPass = shader.TextBlockPass(font, gray,
                text=copyright)
        copyrightPos = (self.size[0]/2 - copyrightSize[0]/2,
                        self.size[1] - copyrightSize[1])
        self.addPass(copyrightPass, pos=copyrightPos)

        font = resource.getFont('fonts/monaco.ttf', 18)
        self.font = font

        # P A R O L E - initial positions
        paroleSize = font.size("P A R O L E")
        spaceWidth = font.size(" ")[0]
        parolePos = (self.size[0]/2 - paroleSize[0]/2, 
                     self.size[1]/4 - paroleSize[1])
        green = (0,128,0)
        pos = list(parolePos)
        self.pStarts = {}
        self.pP = shader.TextBlockPass(font, green, text="P")
        self.addPass(self.pP, pos=tuple(pos))
        self.pStarts[self.pP] = tuple(pos)
        pos[0] += font.size("P")[0] + spaceWidth
        self.pA = shader.TextBlockPass(font, green, text="A")
        self.addPass(self.pA, pos=tuple(pos))
        self.pStarts[self.pA] = tuple(pos)
        pos[0] += font.size("A")[0] + spaceWidth
        self.pR = shader.TextBlockPass(font, green, text="R")
        self.addPass(self.pR, pos=tuple(pos))
        self.pStarts[self.pR] = tuple(pos)
        pos[0] += font.size("R")[0] + spaceWidth
        self.pO = shader.TextBlockPass(font, green, text="O")
        self.addPass(self.pO, pos=tuple(pos))
        self.pStarts[self.pO] = tuple(pos)
        pos[0] += font.size("O")[0] + spaceWidth
        self.pL = shader.TextBlockPass(font, green, text="L")
        self.addPass(self.pL, pos=tuple(pos))
        self.pStarts[self.pL] = tuple(pos)
        pos[0] += font.size("L")[0] + spaceWidth
        self.pE = shader.TextBlockPass(font, green, text="E")
        self.addPass(self.pE, pos=tuple(pos))
        self.pStarts[self.pE] = tuple(pos)

        # title
        self.pDests = {}
        smoke = (64, 64, 64)
        titleSize = font.size("Python Advanced ROgueLike Engine")
        self.titleSize = titleSize
        pos = [self.size[0]/2 - titleSize[0]/2,
               self.size[1]/2 - titleSize[1]]
        self.titlePos = tuple(pos)
        titlePasses = {}
        self.pDests[self.pP] = tuple(pos)
        pos[0] += font.size("P")[0]
        titlePasses[shader.TextBlockPass(font, smoke, text="ython ")] = \
            tuple(pos)
        pos[0] += font.size("ython ")[0]
        self.pDests[self.pA] = tuple(pos)
        pos[0] += font.size("A")[0]
        titlePasses[shader.TextBlockPass(font, smoke, text="dvanced ")] = \
            tuple(pos)
        pos[0] += font.size("dvanced ")[0]
        self.pDests[self.pR] = tuple(pos)
        pos[0] += font.size("R")[0]
        self.pDests[self.pO] = tuple(pos)
        pos[0] += font.size("O")[0]
        titlePasses[shader.TextBlockPass(font, smoke, text="gue")] = \
            tuple(pos)
        pos[0] += font.size("gue")[0]
        self.pDests[self.pL] = tuple(pos)
        pos[0] += font.size("L")[0]
        titlePasses[shader.TextBlockPass(font, smoke, text="ike ")] = \
            tuple(pos)
        pos[0] += font.size("ike ")[0]
        self.pDests[self.pE] = tuple(pos)
        pos[0] += font.size("E")[0]
        titlePasses[shader.TextBlockPass(font, smoke, text="ngine")] = \
            tuple(pos)
        self.titlePasses = titlePasses

        self.addUpdateFunc(SplashShader.updateSplash)
        self.touch()

        self.movementDone = False
        self.gold = False
        self.fadeAlpha = 0
        self.fader = shader.ColorField((0,0,0, 0), self.size)