Пример #1
0
    def render3D(self):
        if self.gameStarted:
            return
        if self.items == []:
            return

        with self.engine.view.orthogonalProjection(normalize=True):
            self.engine.view.setViewport(1, 0)
            w, h = self.engine.view.geometry[2:4]

            if self.img_background:
                drawImage(self.img_background, scale=(1.0, -1.0), coord=(w/2, h/2), stretched=FULL_SCREEN)

            if self.mode == 0:
                self.renderSetlist()
                if self.moreInfoTime > 0:
                    self.engine.theme.setlist.renderMoreInfo(self)
                if self.miniLobbyTime > 0:
                    self.engine.theme.setlist.renderMiniLobby(self)
            # I am unsure how I want to handle this for now. Perhaps as dialogs, perhaps in SCS.
            elif self.mode == 1:
                # self.renderSpeedSelect(visibility, topMost)  ##undefined
                pass
            elif self.mode == 2:
                # self.renderTimeSelect(visibility, topMost)   ##undefined
                pass
Пример #2
0
    def render(self, visibility):
        """
        Render the layer.

        @param visibility:  Floating point visibility factor (1 = opaque, 0 = invisibile)
        """
        w, h = self.stage.engine.view.geometry[2:4]
        v = 1.0 - visibility ** 2

        color = self.color

        #coordinates are positioned with (0,0) being in the middle of the screen
        coord = [w/2 + self.position[0] * w/2, h/2 - self.position[1] * h/2]
        if v > .01:
            color = [self.color[0], self.color[1], self.color[2], visibility]
        scale = [self.scale[0], -self.scale[1]]
        rot = self.angle

        self.transforms = [scale, coord, rot, color]
        # Blend in all the effects
        for effect in self.effects:
            effect.apply()

        gl.glBlendFunc(self.srcBlending, self.dstBlending)
        drawImage(self.drawing, self.transforms[0], self.transforms[1],
                                                  self.transforms[2], self.transforms[3])
        gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
Пример #3
0
    def render(self, visibility):
        """
        Render the layer.

        @param visibility:  Floating point visibility factor (1 = opaque, 0 = invisibile)
        """
        w, h = self.stage.engine.view.geometry[2:4]
        v = 1.0 - visibility ** 2

        color = self.color

        #coordinates are positioned with (0,0) being in the middle of the screen
        coord = [w/2 + self.position[0] * w/2, h/2 - self.position[1] * h/2]
        if v > .01:
            color = [self.color[0], self.color[1], self.color[2], visibility]
        scale = [self.scale[0], -self.scale[1]]
        rot = self.angle

        self.transforms = [scale, coord, rot, color]
        # Blend in all the effects
        for effect in self.effects:
            effect.apply()

        gl.glBlendFunc(self.srcBlending, self.dstBlending)
        drawImage(self.drawing, self.transforms[0], self.transforms[1],
                                                  self.transforms[2], self.transforms[3])
        gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
Пример #4
0
    def render3D(self):
        if self.gameStarted:
            return
        if self.items == []:
            return

        with self.engine.view.orthogonalProjection(normalize=True):
            self.engine.view.setViewport(1, 0)
            w, h = self.engine.view.geometry[2:4]

            if self.img_background:
                drawImage(self.img_background, scale=(1.0, -1.0), coord=(w/2, h/2), stretched=FULL_SCREEN)

            if self.mode == 0:
                self.renderSetlist()
                if self.moreInfoTime > 0:
                    self.engine.theme.setlist.renderMoreInfo(self)
                if self.miniLobbyTime > 0:
                    self.engine.theme.setlist.renderMiniLobby(self)
            # I am unsure how I want to handle this for now. Perhaps as dialogs, perhaps in SCS.
            elif self.mode == 1:
                # self.renderSpeedSelect(visibility, topMost)  ##undefined
                pass
            elif self.mode == 2:
                # self.renderTimeSelect(visibility, topMost)   ##undefined
                pass
Пример #5
0
 def render(self, offset):
     # Font rendering is insane; offset of 0.5 is about 2/3 down the screen.
     offset = offset * 4 / 3  # Hack pos to match text
     w, h = self.engine.view.geometry[2:4]
     drawImage(self.drawing,
               scale=(1, -1),
               coord=(.5 * w, (1 - offset) * h))
Пример #6
0
    def render(self, visibility, topMost):
        v = 1.0 - ((1 - visibility) ** 2)

        # render the background
        w, h = self.engine.view.geometry[2:4]

        with self.engine.view.orthogonalProjection(normalize = True):
            if self.background:
                drawImage(self.background, scale = (1.0,-1.0), coord = (w/2,h/2), stretched = FULL_SCREEN)
            else:
                self.engine.fadeScreen(.4)
            self.doneList = []

            # render the scroller elements
            y = self.offset
            glTranslatef(-(1 - v), 0, 0)
            for element in self.credits:
                hE = element.getHeight()
                if y + hE > 0.0 and y < 1.0:
                    element.render(y)
                if y + hE < 0.0:
                    self.doneList.append(element)
                y += hE
                if y > 1.0:
                    break
            if self.topLayer:
                wFactor = 640.000/self.topLayer.width1()
                hPos = h - ((self.topLayer.height1() * wFactor)*.75)
                if hPos < h * .6:
                    hPos = h * .6
                drawImage(self.topLayer, scale = (wFactor,-wFactor), coord = (w/2,hPos))
Пример #7
0
    def render(self, visibility, playerNum):

        #don't try to render an image layer if the texture doesn't even exist
        if not self.drawing:
            return

        coord = self.position
        scale = self.scale
        rot = self.angle
        color = self.color
        alignment = self.alignment
        valignment = self.valignment
        drawing = self.drawing
        rect = self.rect

        #frameX  = self.frameX
        #frameY  = self.frameY

        if bool(eval(self.condition)):
            drawImage(drawing,
                      scale,
                      coord,
                      rot,
                      color,
                      rect,
                      alignment=alignment,
                      valignment=valignment)
Пример #8
0
    def render(self, visibility, topMost):
        v = 1.0 - ((1 - visibility) ** 2)

        # render the background
        w, h = self.engine.view.geometry[2:4]

        with self.engine.view.orthogonalProjection(normalize = True):
            if self.background:
                drawImage(self.background, scale = (1.0,-1.0), coord = (w/2,h/2), stretched = FULL_SCREEN)
            else:
                self.engine.fadeScreen(.4)
            self.doneList = []

            # render the scroller elements
            y = self.offset
            glTranslatef(-(1 - v), 0, 0)
            for element in self.credits:
                hE = element.getHeight()
                if y + hE > 0.0 and y < 1.0:
                    element.render(y)
                if y + hE < 0.0:
                    self.doneList.append(element)
                y += hE
                if y > 1.0:
                    break
            if self.topLayer:
                wFactor = 640.000/self.topLayer.width1()
                hPos = h - ((self.topLayer.height1() * wFactor)*.75)
                if hPos < h * .6:
                    hPos = h * .6
                drawImage(self.topLayer, scale = (wFactor,-wFactor), coord = (w/2,hPos))
Пример #9
0
    def render(self, visibility, playerNum):
        super(ImageLayer, self).render(visibility, playerNum)

        # don't try to render an image layer if the texture doesn't even exist
        if not self.drawing:
            return

        # get vars
        coord = self.position
        scale = self.scale
        rot = self.angle
        color = self.color
        alignment = self.alignment
        valignment = self.valignment
        drawing = self.drawing
        rect = self.rect

        # render the image
        if bool(eval(self.condition)):
            drawImage(drawing,
                      scale,
                      coord,
                      rot,
                      color,
                      rect,
                      alignment=alignment,
                      valignment=valignment)
Пример #10
0
 def render(self, offset):
     offset = (offset * 4.0) / 3.0  #stump: get it back into alignment...
     w, h = self.engine.view.geometry[2:4]
     drawImage(
         self.drawing,
         scale=(1, -1),
         coord=(.5 * w,
                h - (.5 * self.height + offset) * h * float(w) / float(h)))
Пример #11
0
    def renderBackground(self):
        #myfingershurt: multiple rotation modes
        if self.mode != 2:
            if self.rotationMode == 0:
                drawImage(self.background, scale = (1.0,-1.0),
                                      coord = (self.wFull/2,self.hFull/2), stretched = FULL_SCREEN)

            #myfingershurt:
            else:
                #MFH - use precalculated scale factors instead
                drawImage(self.imgArr[self.arrNum], scale = (1.0,-1.0),
                                      coord = (self.wFull/2,self.hFull/2), stretched = FULL_SCREEN)
Пример #12
0
    def renderBackground(self):
        #myfingershurt: multiple rotation modes
        if self.mode != 2:
            if self.rotationMode == 0:
                drawImage(self.background, scale = (1.0,-1.0),
                                      coord = (self.wFull/2,self.hFull/2), stretched = FULL_SCREEN)

            #myfingershurt:
            else:
                #MFH - use precalculated scale factors instead
                drawImage(self.imgArr[self.arrNum], scale = (1.0,-1.0),
                                      coord = (self.wFull/2,self.hFull/2), stretched = FULL_SCREEN)
Пример #13
0
    def renderSetlist(self, visibility, topMost):
        w, h = self.engine.view.geometry[2:4]

        #render the background (including the header and footer)
        if self.setlistStyle == 1 and self.img_list_bg:
            drawImage(self.img_list_bg, scale = (1.0, -1.0), coord = (w/2,h/2), stretched = KEEP_ASPECT | FIT_WIDTH)
        elif self.img_list_bg:
            drawImage(self.img_list_bg, scale = (1.0, -1.0), coord = (w/2,h/2), stretched = FULL_SCREEN)
        if self.img_list_head:
            o = 0
            if self.setlistStyle == 1:
                o = self.yPos
            drawImage(self.img_list_head, scale = (1.0, -1.0), coord = (w/2,h+o), stretched = KEEP_ASPECT | FIT_WIDTH, fit = TOP)
        if self.setlistStyle in [0, 2] and self.img_list_foot:
            drawImage(self.img_list_foot, scale = (1.0, -1.0), coord = (w/2,0), stretched = FULL_SCREEN, fit = BOTTOM)
        elif self.img_list_foot:
            maxPos = max(len(self.items) - self.itemsPerPage, 0)
            o = (-self.itemSize[1]*h*maxPos) + self.yPos
            drawImage(self.img_list_foot, scale = (1.0, -1.0), coord = (w/2,o), stretched = KEEP_ASPECT | FIT_WIDTH, fit = BOTTOM)

        self.engine.theme.setlist.renderHeader(self)

        #render the artwork
        self.engine.theme.setlist.renderAlbumArt(self)

        #render the item list itself
        ns = 0   #the n value of the selectedItem
        if self.setlistStyle == 2:
            for n, i in enumerate(range(self.pos-self.itemsPerPage+self.followItemPos, self.pos+self.itemsPerPage)):
                if i == self.selectedIndex:
                    ns = n
                    continue
                i = i%len(self.items)
                self.engine.theme.setlist.renderUnselectedItem(self, i, n)
        else:
            for n, i in enumerate(range(self.pos, self.pos+self.itemsPerPage)):
                if i >= len(self.items):
                    break
                if i == self.selectedIndex:
                    ns = n
                    continue
                if isinstance(self.items[i], song.BlankSpaceInfo):
                    continue
                self.engine.theme.setlist.renderUnselectedItem(self, i, n)
        self.engine.theme.setlist.renderSelectedItem(self, ns) #we render this last to allow overlapping effects.

        #render the additional information for the selected item
        self.engine.theme.setlist.renderSelectedInfo(self)

        #render the foreground stuff last
        self.engine.theme.setlist.renderForeground(self)
Пример #14
0
 def render(self, visibility, topMost):
     if not visibility:
         self.active = False
         return
     if not self.active:
         self.getPlayers()
     self.active = True
     self.done   = True
     if self.playerNum >= self.maxPlayers:
         return
     with self.engine.view.orthogonalProjection(normalize = True):
         w, h = self.fullView
         if self.img_background:
             drawImage(self.img_background, scale = (1.0, -1.0), coord = (w/2,h/2), stretched = FULL_SCREEN)
         self.engine.theme.themeLobby.renderPanels(self)
Пример #15
0
    def render(self, visibility, playerNum):

        #don't try to render image layer if the texture doesn't even exist
        if not self.drawing:
            return

        coord     = self.position
        scale     = self.scale
        rot       = self.angle
        color     = self.color
        alignment = self.alignment
        ratio     = self.ratio

        if bool(eval(self.condition)):
            degrees = int(360*ratio) - (int(360*ratio) % 5)
            drawImage(self.drawnOverlays[degrees], scale,
                                  coord, rot, color, alignment = alignment)
Пример #16
0
 def render(self, visibility, topMost):
     try:
         font = self.engine.data.fontDict[self.engine.theme.characterCreateOptionFont]
         helpFont = self.engine.data.fontDict[self.engine.theme.characterCreateHelpFont]
     except KeyError:
         font = self.engine.data.font
         helpFont = self.engine.data.loadingFont
     with self.engine.view.orthogonalProjection(normalize = True):
         v = ((1 - visibility) **2)
         w, h = self.fullView
         if self.img_creator:
             drawImage(self.img_creator, scale = (1.0, -1.0), coord = (w/2,h/2), stretched = FULL_SCREEN)
         helpFont.render(_("Player %d") % (self.playerNum + 1), pos = (.5, .1), scale = self.engine.theme.characterCreateScale, align = 1)
         for i, option in enumerate(self.options):
             r, g, b = self.engine.theme.characterCreateHelpColor
             glColor3f(r, g, b)
             cursor = ""
             if self.selected == i:
                 wText, hText = helpFont.getStringSize(option[1], scale = self.engine.theme.characterCreateScale)
                 helpFont.render(option[1], (self.engine.theme.characterCreateHelpX-(wText/2), self.engine.theme.characterCreateHelpY-hText), scale = self.engine.theme.characterCreateHelpScale)
                 r, g, b = self.engine.theme.characterCreateSelectColor
                 glColor3f(r, g, b)
                 cursor = self.cursor
             else:
                 r, g, b = self.engine.theme.characterCreateFontColor
                 glColor3f(r, g, b)
             wText, hText = font.getStringSize(option[0], scale = self.engine.theme.characterCreateScale)
             font.render(option[0], (self.engine.theme.characterCreateX, self.engine.theme.characterCreateY+self.engine.theme.characterCreateSpace*i), scale = self.engine.theme.characterCreateScale)
             if self.active and self.selected == i:
                 self.engine.theme.setSelectedColor(1-v)
             if i == 0 or i > 6:
                 wText, hText = font.getStringSize(self.choices[i], scale = self.engine.theme.characterCreateScale)
                 font.render(self.choices[i]+cursor, (self.engine.theme.characterCreateOptionX-wText, self.engine.theme.characterCreateY+self.engine.theme.characterCreateSpace*i), scale = self.engine.theme.characterCreateScale)
             else:
                 if i == self.selected:
                     str = "< %s >" % self.values[i-1][self.choices[i]]
                 else:
                     str = self.values[i-1][self.choices[i]]
                 wText, hText = font.getStringSize(str, scale = self.engine.theme.characterCreateScale)
                 font.render(str, (self.engine.theme.characterCreateOptionX-wText, self.engine.theme.characterCreateY+self.engine.theme.characterCreateSpace*i), scale = self.engine.theme.characterCreateScale)
         if self.img_creator_top:
             drawImage(self.img_creator_top, scale = (1.0, -1.0), coord = (w/2,h/2), stretched = FULL_SCREEN)
Пример #17
0
    def render(self, visibility, playerNum):

        #don't try to render an image layer if the texture doesn't even exist
        if not self.drawing:
            return

        coord      = self.position
        scale      = self.scale
        rot        = self.angle
        color      = self.color
        alignment  = self.alignment
        valignment = self.valignment
        drawing    = self.drawing
        rect       = self.rect

        #frameX  = self.frameX
        #frameY  = self.frameY

        if bool(eval(self.condition)):
            drawImage(drawing, scale, coord, rot, color, rect,
                                  alignment = alignment, valignment = valignment)
Пример #18
0
    def drawStarScore(self, screenwidth, screenheight, xpos, ypos, stars, scale = None, horiz_spacing = 1.2, space = 1.0, hqStar = False, align = LEFT):
        minScale = 0.02
        w = screenwidth
        h = screenheight
        if not scale:
            scale = minScale
        elif scale < minScale:
            scale = minScale
        if self.data.fcStars and stars == 7:
            star = self.data.starFC
        else:
            star = self.data.starPerfect
        wide = scale * horiz_spacing
        if align == CENTER: #center - akedrou (simplifying the alignment...)
            xpos  -= (2 * wide)
        elif align == RIGHT: #right
            xpos  -= (4 * wide)
        if stars > 5:
            for j in range(5):

                if self.data.maskStars:
                    if self.data.theme == 2:
                        drawImage(star, scale = (scale,-scale), coord = (w*(xpos+wide*j)*space**4,h*ypos), color = (1, 1, 0, 1), stretched = KEEP_ASPECT | FIT_WIDTH)
                    else:
                        drawImage(star, scale = (scale,-scale), coord = (w*(xpos+wide*j)*space**4,h*ypos), color = (0, 1, 0, 1), stretched = KEEP_ASPECT | FIT_WIDTH)
                else:
                    drawImage(star, scale = (scale,-scale), coord = (w*(xpos+wide*j)*space**4,h*ypos), stretched = KEEP_ASPECT | FIT_WIDTH)
        else:
            for j in range(5):
                if j < stars:
                    if hqStar:
                        star = self.data.star4
                    else:
                        star = self.data.star2
                else:
                    if hqStar:
                        star = self.data.star3
                    else:
                        star = self.data.star1
                drawImage(star, scale = (scale,-scale), coord = (w*(xpos+wide*j)*space**4,h*ypos), stretched = KEEP_ASPECT | FIT_WIDTH)
Пример #19
0
    def drawStarScore(self, screenwidth, screenheight, xpos, ypos, stars, scale = None, horiz_spacing = 1.2, space = 1.0, hqStar = False, align = LEFT):
        minScale = 0.02
        w = screenwidth
        h = screenheight
        if not scale:
            scale = minScale
        elif scale < minScale:
            scale = minScale
        if self.data.fcStars and stars == 7:
            star = self.data.starFC
        else:
            star = self.data.starPerfect
        wide = scale * horiz_spacing
        if align == CENTER: #center - akedrou (simplifying the alignment...)
            xpos  -= (2 * wide)
        elif align == RIGHT: #right
            xpos  -= (4 * wide)
        if stars > 5:
            for j in range(5):

                if self.data.maskStars:
                    if self.data.theme == 2:
                        drawImage(star, scale = (scale,-scale), coord = (w*(xpos+wide*j)*space**4,h*ypos), color = (1, 1, 0, 1), stretched = KEEP_ASPECT | FIT_WIDTH)
                    else:
                        drawImage(star, scale = (scale,-scale), coord = (w*(xpos+wide*j)*space**4,h*ypos), color = (0, 1, 0, 1), stretched = KEEP_ASPECT | FIT_WIDTH)
                else:
                    drawImage(star, scale = (scale,-scale), coord = (w*(xpos+wide*j)*space**4,h*ypos), stretched = KEEP_ASPECT | FIT_WIDTH)
        else:
            for j in range(5):
                if j < stars:
                    if hqStar:
                        star = self.data.star4
                    else:
                        star = self.data.star2
                else:
                    if hqStar:
                        star = self.data.star3
                    else:
                        star = self.data.star1
                drawImage(star, scale = (scale,-scale), coord = (w*(xpos+wide*j)*space**4,h*ypos), stretched = KEEP_ASPECT | FIT_WIDTH)
Пример #20
0
    def render(self, visibility, topMost):
        #MFH - display version in any menu:

        if not visibility:
            self.active = False
            return

        self.active = True
        if self.graphicMenu and self.menuBackground:
            self.engine.graphicMenuShown = True
        else:
            self.engine.graphicMenuShown = False

        with self.engine.view.orthogonalProjection(normalize = True):
            v = (1 - visibility) ** 2
            # Default to this font if none was specified

            font = self.font
            tipFont = self.tipFont

            if self.fadeScreen:
                self.engine.fadeScreen(v)

            wS, hS = self.engine.view.geometry[2:4]

            if self.graphicMenu and self.menuBackground:
                #volshebnyi - better menu scaling
                drawImage(self.menuBackground, scale = (1.0,-1.0), coord = (wS/2,hS/2), stretched = FULL_SCREEN)
            else:
                glEnable(GL_BLEND)
                glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
                glEnable(GL_COLOR_MATERIAL)

            n = len(self.choices)
            x, y = self.pos

            for i, choice in enumerate(self.choices[self.viewOffset:self.viewOffset + self.viewSize]):
                if self.graphicMenu:
                    if self.currentIndex == i:
                        xpos = (.5,1)
                    else:
                        xpos = (0,.5)
                    ypos = float(i+self.viewOffset)
                    drawImage(self.menuText, scale = (.5*self.menuScale,(-1.0/n*self.menuScale)),
                                          coord = (wS*self.menux,(hS*self.menuy)-(hS*self.vSpace)*i),
                                          rect = (xpos[0],xpos[1],ypos/n,(ypos+1.0)/n), stretched = KEEP_ASPECT | FIT_WIDTH)
                else:
                    text = choice.getText(i + self.viewOffset == self.currentIndex)
                    glPushMatrix()
                    glRotate(v * 45, 0, 0, 1)

                    scale = self.engine.theme.settingsmenuScale

                    w, h = font.getStringSize(" ", scale = scale)

                    # Draw arrows if scrolling is needed to see all items
                    if i == 0 and self.viewOffset > 0:
                        self.engine.theme.setBaseColor((1 - v) * max(.1, 1 - (1.0 / self.viewOffset) / 3))
                        glPushMatrix()
                        glTranslatef(x - v / 4 - w * 2, y + h / 2, 0)
                        self.renderTriangle(up = (0, -1), s = .015)
                        glPopMatrix()
                    elif i == self.viewSize - 1 and self.viewOffset + self.viewSize < n:
                        self.engine.theme.setBaseColor((1 - v) * max(.1, 1 - (1.0 / (n - self.viewOffset - self.viewSize)) / 3))
                        glPushMatrix()
                        glTranslatef(x - v / 4 - w * 2, y + h / 2, 0)
                        self.renderTriangle(up = (0, 1), s = .015)
                        glPopMatrix()

                    if i + self.viewOffset == self.currentIndex:
                        if choice.tipText and self.showTips:
                            if self.tipColor:
                                c1, c2, c3 = self.tipColor
                                glColor3f(c1,c2,c3)
                            elif self.textColor:
                                c1, c2, c3 = self.textColor
                                glColor3f(c1,c2,c3)
                            else:
                                self.engine.theme.setBaseColor(1-v)
                            tipScale = self.tipScale
                            if self.tipScroll > -(self.tipSize) and self.tipScroll < 1:
                                tipFont.render(choice.tipText, (self.tipScroll, self.tipY), scale = tipScale)
                            if self.tipScrollMode == 0:
                                if self.tipScrollB > -(self.tipSize) and self.tipScrollB < 1:
                                    tipFont.render(choice.tipText, (self.tipScrollB, self.tipY), scale = tipScale)
                        a = (math.sin(self.time) * .15 + .75) * (1 - v * 2)
                        self.engine.theme.setSelectedColor(a)
                        a *= -.005
                        glTranslatef(a, a, a)
                    else:
                        self.engine.theme.setBaseColor(1 - v)

                    #MFH - settable color through Menu constructor
                    if i + self.viewOffset == self.currentIndex and self.selectedColor:
                        c1,c2,c3 = self.selectedColor
                        glColor3f(c1,c2,c3)
                    elif self.textColor:
                        c1,c2,c3 = self.textColor
                        glColor3f(c1,c2,c3)

                    #MFH - now to catch " >" main menu options and blank them:
                    if text == " >":
                        text = ""

                    if self.engine.data.submenuSelectFound and len(text) > 0 and not self.mainMenu and self.useSelectedBox:
                        Tw, Th = font.getStringSize(text,scale)
                        boxXOffset = (x + (Tw/2))*wS
                        boxYOffset = (1.0 - (y*4.0/3.0) - (Th*1.2/2))*hS
                        drawImage(self.engine.data.submenuSelect,
                                              scale = (tempWScale,tempHScale), #FIXME
                                              coord = (boxXOffset,boxYOffset))

                    font.render(text, (x - v / 4, y), scale = scale)


                    v *= 2
                    if self.theme == 1 and self.font == self.engine.data.pauseFont: # evilynux - Ugly workaround for Gh3
                        y += h*.70      #Worldrave - Changed Pause menu spacing back to .70 from .65 for now.
                    else:
                        y += h
                    glPopMatrix()
Пример #21
0
    def render(self, visibility, topMost):
        self.engine.view.setViewport(1,0)
        self.visibility = visibility
        if self.rbmenu:
            v = 1.0 - ((1 - visibility) ** 2)
        else:
            v = 1
        if v == 1:
            self.engine.view.transitionTime = 1

        if self.menu.active and not self.active:
            self.active = True

        w, h, = self.engine.view.geometry[2:4]

        if self.active:
            if self.engine.view.topLayer() is not None:
                if self.optionsBG:
                    drawImage(self.optionsBG, (self.opt_bkg_size[2],-self.opt_bkg_size[3]), (w*self.opt_bkg_size[0],h*self.opt_bkg_size[1]), stretched = FULL_SCREEN)
                if self.optionsPanel:
                    drawImage(self.optionsPanel, (1.0,-1.0), (w/2, h/2), stretched = FULL_SCREEN)
            else:
                drawImage(self.engine.data.loadingImage, (1.0,-1.0), (w/2, h/2), stretched = FULL_SCREEN)

        if self.menu.active and self.engine.cmdPlay == 0:
            if self.background is not None:
                #MFH - auto-scaling
                drawImage(self.background, (1.0,-1.0), (w/2, h/2), stretched = FULL_SCREEN)

            if self.BGText:
                numOfChoices = len(self.menu.choices)
                for i in range(numOfChoices):
                    #Item selected
                    if self.menu.currentIndex == i:
                        xpos = (.5,1)
                    #Item unselected
                    else:
                        xpos = (0,.5)
                    #which item?
                    ypos = (1/float(numOfChoices) * i, 1/float(numOfChoices) * (i + 1))

                    textcoord = (w*self.menux,h*self.menuy-(h*self.main_menu_vspacing)*i)
                    sFactor = self.main_menu_scale
                    wFactor = xpos[1] - xpos[0]
                    hFactor = ypos[1] - ypos[0]
                    drawImage(self.BGText,
                                        scale = (wFactor*sFactor,-hFactor*sFactor),
                                        coord = textcoord,
                                        rect  = (xpos[0],xpos[1],ypos[0],ypos[1]), stretched = KEEP_ASPECT | FIT_WIDTH)

        #racer: added version tag to main menu:
        if self.version is not None:
            wfactor = (w * self.engine.theme.versiontagScale) / self.version.width1()
            drawImage(self.version,( wfactor, -wfactor ),(w*self.engine.theme.versiontagposX, h*self.engine.theme.versiontagposY)) #worldrave - Added theme settings to control X+Y positions of versiontag.
Пример #22
0
    def render(self, visibility, topMost):
        self.engine.view.setViewport(1,0)
        self.visibility = visibility
        if self.rbmenu:
            v = 1.0 - ((1 - visibility) ** 2)
        else:
            v = 1
        if v == 1:
            self.engine.view.transitionTime = 1

        if self.menu.active and not self.active:
            self.active = True

        w, h, = self.engine.view.geometry[2:4]

        if self.active:
            if self.engine.view.topLayer() is not None:
                if self.optionsBG:
                    drawImage(self.optionsBG, (self.opt_bkg_size[2],-self.opt_bkg_size[3]), (w*self.opt_bkg_size[0],h*self.opt_bkg_size[1]), stretched = FULL_SCREEN)
                if self.optionsPanel:
                    drawImage(self.optionsPanel, (1.0,-1.0), (w/2, h/2), stretched = FULL_SCREEN)
            else:
                drawImage(self.engine.data.loadingImage, (1.0,-1.0), (w/2, h/2), stretched = FULL_SCREEN)

        if self.menu.active and self.engine.cmdPlay == 0:
            if self.background is not None:
                #MFH - auto-scaling
                drawImage(self.background, (1.0,-1.0), (w/2, h/2), stretched = FULL_SCREEN)

            if self.BGText:
                numOfChoices = len(self.menu.choices)
                for i in range(numOfChoices):
                    #Item selected
                    if self.menu.currentIndex == i:
                        xpos = (.5,1)
                    #Item unselected
                    else:
                        xpos = (0,.5)
                    #which item?
                    ypos = (1/float(numOfChoices) * i, 1/float(numOfChoices) * (i + 1))

                    textcoord = (w*self.menux,h*self.menuy-(h*self.main_menu_vspacing)*i)
                    sFactor = self.main_menu_scale
                    wFactor = xpos[1] - xpos[0]
                    hFactor = ypos[1] - ypos[0]
                    drawImage(self.BGText,
                                        scale = (wFactor*sFactor,-hFactor*sFactor),
                                        coord = textcoord,
                                        rect  = (xpos[0],xpos[1],ypos[0],ypos[1]), stretched = KEEP_ASPECT | FIT_WIDTH)

        #racer: added version tag to main menu:
        if self.version is not None:
            wfactor = (w * self.engine.theme.versiontagScale) / self.version.width1()
            drawImage(self.version,( wfactor, -wfactor ),(w*self.engine.theme.versiontagposX, h*self.engine.theme.versiontagposY)) #worldrave - Added theme settings to control X+Y positions of versiontag.
Пример #23
0
    def render(self, visibility, topMost):
        #MFH - display version in any menu:

        if not visibility:
            self.active = False
            return

        self.active = True
        if self.graphicMenu and self.menuBackground:
            self.engine.graphicMenuShown = True
        else:
            self.engine.graphicMenuShown = False

        with self.engine.view.orthogonalProjection(normalize = True):
            v = (1 - visibility) ** 2
            # Default to this font if none was specified

            font = self.font
            tipFont = self.tipFont

            if self.fadeScreen:
                self.engine.fadeScreen(v)

            wS, hS = self.engine.view.geometry[2:4]

            if self.graphicMenu and self.menuBackground:
                #volshebnyi - better menu scaling
                drawImage(self.menuBackground, scale = (1.0,-1.0), coord = (wS/2,hS/2), stretched = FULL_SCREEN)
            else:
                glEnable(GL_BLEND)
                glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
                glEnable(GL_COLOR_MATERIAL)

            n = len(self.choices)
            x, y = self.pos

            for i, choice in enumerate(self.choices[self.viewOffset:self.viewOffset + self.viewSize]):
                if self.graphicMenu:
                    if self.currentIndex == i:
                        xpos = (.5,1)
                    else:
                        xpos = (0,.5)
                    ypos = float(i+self.viewOffset)
                    drawImage(self.menuText, scale = (.5*self.menuScale,(-1.0/n*self.menuScale)),
                                          coord = (wS*self.menux,(hS*self.menuy)-(hS*self.vSpace)*i),
                                          rect = (xpos[0],xpos[1],ypos/n,(ypos+1.0)/n), stretched = KEEP_ASPECT | FIT_WIDTH)
                else:
                    text = choice.getText(i + self.viewOffset == self.currentIndex)
                    glPushMatrix()
                    glRotate(v * 45, 0, 0, 1)

                    scale = self.engine.theme.settingsmenuScale

                    w, h = font.getStringSize(" ", scale = scale)

                    # Draw arrows if scrolling is needed to see all items
                    if i == 0 and self.viewOffset > 0:
                        self.engine.theme.setBaseColor((1 - v) * max(.1, 1 - (1.0 / self.viewOffset) / 3))
                        glPushMatrix()
                        glTranslatef(x - v / 4 - w * 2, y + h / 2, 0)
                        self.renderTriangle(up = (0, -1), s = .015)
                        glPopMatrix()
                    elif i == self.viewSize - 1 and self.viewOffset + self.viewSize < n:
                        self.engine.theme.setBaseColor((1 - v) * max(.1, 1 - (1.0 / (n - self.viewOffset - self.viewSize)) / 3))
                        glPushMatrix()
                        glTranslatef(x - v / 4 - w * 2, y + h / 2, 0)
                        self.renderTriangle(up = (0, 1), s = .015)
                        glPopMatrix()

                    if i + self.viewOffset == self.currentIndex:
                        if choice.tipText and self.showTips:
                            if self.tipColor:
                                c1, c2, c3 = self.tipColor
                                glColor3f(c1,c2,c3)
                            elif self.textColor:
                                c1, c2, c3 = self.textColor
                                glColor3f(c1,c2,c3)
                            else:
                                self.engine.theme.setBaseColor(1-v)
                            tipScale = self.tipScale
                            if self.tipScroll > -(self.tipSize) and self.tipScroll < 1:
                                tipFont.render(choice.tipText, (self.tipScroll, self.tipY), scale = tipScale)
                            if self.tipScrollMode == 0:
                                if self.tipScrollB > -(self.tipSize) and self.tipScrollB < 1:
                                    tipFont.render(choice.tipText, (self.tipScrollB, self.tipY), scale = tipScale)
                        a = (math.sin(self.time) * .15 + .75) * (1 - v * 2)
                        self.engine.theme.setSelectedColor(a)
                        a *= -.005
                        glTranslatef(a, a, a)
                    else:
                        self.engine.theme.setBaseColor(1 - v)

                    #MFH - settable color through Menu constructor
                    if i + self.viewOffset == self.currentIndex and self.selectedColor:
                        c1,c2,c3 = self.selectedColor
                        glColor3f(c1,c2,c3)
                    elif self.textColor:
                        c1,c2,c3 = self.textColor
                        glColor3f(c1,c2,c3)

                    #MFH - now to catch " >" main menu options and blank them:
                    if text == " >":
                        text = ""

                    if self.engine.data.submenuSelectFound and len(text) > 0 and not self.mainMenu and self.useSelectedBox:
                        Tw, Th = font.getStringSize(text,scale)
                        boxXOffset = (x + (Tw/2))*wS
                        boxYOffset = (1.0 - (y*4.0/3.0) - (Th*1.2/2))*hS
                        drawImage(self.engine.data.submenuSelect,
                                              scale = (tempWScale,tempHScale), #FIXME
                                              coord = (boxXOffset,boxYOffset))

                    font.render(text, (x - v / 4, y), scale = scale)


                    v *= 2
                    if self.theme == 1 and self.font == self.engine.data.pauseFont: # evilynux - Ugly workaround for Gh3
                        y += h*.70      #Worldrave - Changed Pause menu spacing back to .70 from .65 for now.
                    else:
                        y += h
                    glPopMatrix()
Пример #24
0
 def render(self, offset):
     offset = (offset*4.0)/3.0  #stump: get it back into alignment...
     w, h = self.engine.view.geometry[2:4]
     drawImage(self.drawing, scale = (1, -1),
                           coord = (.5 * w, h - (.5 * self.height + offset) * h * float(w) / float(h)))
Пример #25
0
 def render(self, offset):
     # Font rendering is insane; offset of 0.5 is about 2/3 down the screen.
     offset = offset * 4 / 3   # Hack pos to match text
     w, h = self.engine.view.geometry[2:4]
     drawImage(self.drawing, scale=(1, -1), coord=(.5 * w, (1-offset) * h))