def drawPartImage( self, lobby, parttype, scale, coord, ): if not lobby.partImages[self.currentImage]: return if parttype in GUITARTYPES: if self.fadeTime < 1000 or self.nextImage \ == self.currentImage: lobby.drawImage( lobby.partImages[self.currentImage], scale = scale, coord = coord, stretched = 11 ) else: lobby.drawImage( lobby.partImages[self.currentImage], scale = scale, coord = coord, color = ( 1, 1, 1, ( 2500.0 - self.fadeTime ) / 1500.0 ), stretched = 11 ) lobby.drawImage( lobby.partImages[self.nextImage], scale = scale, coord = coord, color = ( 1, 1, 1, ( self.fadeTime - 1000.0 ) / 1500.0 ), stretched = 11 ) glColor4f( 1, 1, 1, 1 ) elif parttype in DRUMTYPES: if lobby.partImages[4]: lobby.drawImage( lobby.partImages[4], scale = scale, coord = coord, stretched = 11 ) else: if lobby.partImages[5]: lobby.drawImage( lobby.partImages[5], scale = scale, coord = coord, stretched = 11 )
def render(self, offset): offset = (offset * 4.0) / 3.0 # akedrou - font rendering fix if self.alignment == "left": x = 0.1 elif self.alignment == "right": x = 0.9 - self.size[0] elif self.alignment == "center": x = 0.5 - self.size[0] / 2 glColor4f(*self.color) self.font.render(self.text, (x, offset), scale=self.scale)
def renderIncomingNeck(self, visibility, song, pos, time, neckTexture): #MFH - attempt to "scroll" an incoming guitar solo neck towards the player if not song: return if not song.readyToGo: return def project(beat): return 0.125 * beat / self.beatsPerUnit # glorandwarf: was 0.12 v = visibility w = self.boardWidth l = self.boardLength #offset = (pos - self.lastBpmChange) / self.currentPeriod + self.baseBeat offset = 0 z = ((time - pos) / self.currentPeriod) / self.beatsPerUnit color = (1,1,1) glEnable(GL_TEXTURE_2D) if neckTexture: neckTexture.texture.bind() glBegin(GL_TRIANGLE_STRIP) glColor4f(color[0],color[1],color[2], 0) glTexCoord2f(0.0, project(offset - 2 * self.beatsPerUnit)) #glVertex3f(-w / 2, 0, -2) glVertex3f(-w / 2, 0, z) #point A glTexCoord2f(1.0, project(offset - 2 * self.beatsPerUnit)) #glVertex3f( w / 2, 0, -2) glVertex3f( w / 2, 0, z) #point B glColor4f(color[0],color[1],color[2], v) glTexCoord2f(0.0, project(offset - 1 * self.beatsPerUnit)) #glVertex3f(-w / 2, 0, -1) glVertex3f(-w / 2, 0, z+1) #point C glTexCoord2f(1.0, project(offset - 1 * self.beatsPerUnit)) #glVertex3f( w / 2, 0, -1) glVertex3f( w / 2, 0, z+1) #point D glTexCoord2f(0.0, project(offset + l * self.beatsPerUnit * .7)) #glVertex3f(-w / 2, 0, l * .7) glVertex3f(-w / 2, 0, z+2+l * .7) #point E glTexCoord2f(1.0, project(offset + l * self.beatsPerUnit * .7)) #glVertex3f( w / 2, 0, l * .7) glVertex3f( w / 2, 0, z+2+l * .7) #point F glColor4f(color[0],color[1],color[2], 0) glTexCoord2f(0.0, project(offset + l * self.beatsPerUnit)) #glVertex3f(-w / 2, 0, l) glVertex3f(-w / 2, 0, z+2+l) #point G glTexCoord2f(1.0, project(offset + l * self.beatsPerUnit)) #glVertex3f( w / 2, 0, l) glVertex3f( w / 2, 0, z+2+l) #point H glEnd() glDisable(GL_TEXTURE_2D)
def draw(self, color = (1, 1, 1, 1), rect = (0,1,0,1), lOffset = 0.0, rOffset = 0.0): with cmglPushedSpecificMatrix(GL_TEXTURE): with cmglPushedSpecificMatrix(GL_PROJECTION): with cmglMatrixMode(GL_PROJECTION): self.context.setProjection() with cmglPushedMatrix(): glLoadIdentity() self._getEffectiveTransform().applyGL() glScalef(self.texture.pixelSize[0], self.texture.pixelSize[1], 1) glTranslatef(-.5, -.5, 0) glColor4f(*color) glEnable(GL_TEXTURE_2D) self.texture.bind() self.triangVtx[0,0] = 0.0-lOffset self.triangVtx[0,1] = 1.0 self.triangVtx[1,0] = 1.0-rOffset self.triangVtx[1,1] = 1.0 self.triangVtx[2,0] = 0.0+lOffset self.triangVtx[2,1] = 0.0 self.triangVtx[3,0] = 1.0+rOffset self.triangVtx[3,1] = 0.0 self.textriangVtx[0,0] = rect[0] self.textriangVtx[0,1] = rect[3] self.textriangVtx[1,0] = rect[1] self.textriangVtx[1,1] = rect[3] self.textriangVtx[2,0] = rect[0] self.textriangVtx[2,1] = rect[2] self.textriangVtx[3,0] = rect[1] self.textriangVtx[3,1] = rect[2] cmglDrawArrays(GL_TRIANGLE_STRIP, vertices=self.triangVtx, texcoords=self.textriangVtx) glDisable(GL_TEXTURE_2D)
def renderUnselectedItem(self, scene, i, n): ( w, h ) = scene.geometry font = scene.fontDict['songListFont'] font = scene.fontDict['songListFont'] if not scene.items or scene.itemIcons is None: return item = scene.items[i] if scene.img_tier: imgwidth = scene.img_tier.width1() imgheight = scene.img_tier.height1() wfactor = 1160.0/imgwidth hfactor = 60.00/imgheight if isinstance(item, Song.TitleInfo) or isinstance(item, Song.SortTitleInfo): scene.drawImage(scene.img_tier, scale = (wfactor,-hfactor), coord = (w/2.8762, ((-n*.0565)*h )+ h/1.235), stretched = 11) icon = None if isinstance( item, Song.LibraryInfo ): try: icon = scene.itemIcons['Library'] wfactor = 0.02 scene.drawImage( icon, scale = ( wfactor, -wfactor ), coord = ( w / 1.025, h - 0.055 * h * ( n + 1 ) - 0.2 * h ), stretched = 11 ) except KeyError: pass elif isinstance( item, Song.RandomSongInfo ): try: icon = scene.itemIcons['Random'] wfactor = 0.02 scene.drawImage( icon, scale = ( wfactor, -wfactor ), coord = ( w / 1.025, h - 0.055 * h * ( n + 1 ) - 0.2 * h ), stretched = 11 ) except KeyError: pass if isinstance( item, Song.SongInfo ) or isinstance( item, Song.LibraryInfo ): ( c1, c2, c3 ) = self.song_name_text_color glColor4f( c1, c2, c3, 1 ) elif isinstance( item, Song.TitleInfo ) or isinstance( item, Song.SortTitleInfo ): ( c1, c2, c3 ) = self.career_title_color glColor4f( c1, c2, c3, 1 ) elif isinstance( item, Song.RandomSongInfo ): ( c1, c2, c3 ) = self.song_name_text_color glColor4f( c1, c2, c3, 1 ) text = item.name if isinstance( item, Song.SongInfo ) and item.getLocked(): text = _( '-- Locked --' ) maxwidth = .43 scale = 0.0016 ( wt, ht ) = font.getStringSize( text, scale = scale ) while wt > maxwidth: tlength = len( text ) - 2 text = text[:tlength] + '...' ( wt, ht ) = font.getStringSize( text, scale = scale ) if wt < maxwidth: break font.render( text, ( .07, .043 * ( n + 1 ) + .098 ), scale = scale ) if isinstance( item, Song.SongInfo ): score = _( "Nil" ) stars = 0 name = "" if not item.getLocked(): try: difficulties = item.partDifficulties[scene.scorePart.id] except KeyError: difficulties = [] for d in difficulties: if d.id == scene.scoreDifficulty.id: scores = item.getHighscores( d, part = scene.scorePart ) if scores: ( score, stars, name, scoreExt ) = scores[0] try: ( notesHit, notesTotal, noteStreak, modVersion, handicap, handicapLong, originalScore, ) = scoreExt except ValueError: ( notesHit, notesTotal, noteStreak, modVersion, oldScores1, oldScores2, ) = scoreExt break else: ( score, stars, name ) = ( 0, 0, '---' ) if score == _( 'Nil' ) and scene.nilShowNextScore: for d in difficulties: scores = item.getHighscores( d, part = scene.scorePart ) if scores: ( score, stars, name, scoreExt ) = scores[0] try: ( notesHit, notesTotal, noteStreak, modVersion, handicap, handicapLong, originalScore, ) = scoreExt except ValueError: ( notesHit, notesTotal, noteStreak, modVersion, oldScores1, oldScores2, ) = scoreExt break else: ( score, stars, name ) = ( 0, 0, '---' ) else: ( score, stars, name ) = ( _( 'Nil' ), 0, '---' ) scale = 0.0010 if score != _( 'Nil' ) and score > 0 \ and notesTotal != 0: text = '%.1f%%' % (float( notesHit ) / notesTotal * 100.0) font.render( text, ( 0.56, .043 * ( n + 1 ) + .098 ), scale = scale, align = 2 ) if scene.img_starwhite and scene.img_stargold: imgwidth = scene.img_starwhite.width1() wfactor1 = 2.0 / imgwidth if stars == 6: for k in range( 0, 5 ): scene.drawImage( scene.img_stargold, scale = ( wfactor1 * 1.2, -wfactor1 * 1.2), coord = ( ( .58 + .025 * k ) * w, ((-n*.0565)*h )+ h/1.235), stretched = 11 ) else: for k in range( 0, stars ): scene.drawImage( scene.img_starwhite, scale = ( wfactor1 * 1.2, -wfactor1 * 1.2), coord = ( ( .58 + .025 * k ) * w, ((-n*.0565)*h )+ h/1.235), stretched = 11 )
def renderSelectedItem( self, scene, n ): ( w, h ) = scene.geometry font = scene.fontDict['songListFont'] item = scene.selectedItem if not item: return if isinstance( item, Song.BlankSpaceInfo ): return if scene.img_tier: imgwidth = scene.img_tier.width1() imgheight = scene.img_tier.height1() wfactor = 1160.0/imgwidth hfactor = 60.00/imgheight if isinstance(item, Song.TitleInfo) or isinstance(item, Song.SortTitleInfo): scene.drawImage(scene.img_tier, scale = (wfactor,-hfactor), coord = (w/2.8762, ((-n*.0565)*h )+ h/1.235), stretched = 11) if scene.img_selected: imgwidth = scene.img_selected.width1() imgheight = scene.img_selected.height1() wfactor = 1160.0/imgwidth hfactor = 60.00/imgheight scene.drawImage(scene.img_selected, scale = (wfactor,-hfactor), coord = (w/2.8762, ((-n*.0565)*h )+ h/1.235), stretched = 11) icon = None if isinstance( item, Song.SongInfo ) and scene.practiceMode: ( c1, c2, c3 ) = self.song_name_selected_color glColor3f( c1, c2, c3 ) text = _( 'Practice' ) elif isinstance( item, Song.LibraryInfo ): ( c1, c2, c3 ) = self.library_selected_color glColor3f( c1, c2, c3 ) if item.songCount == 1: text = _( 'There Is 1 Song In This Setlist.' ) elif item.songCount > 1: text = _( 'There Are %d Songs In This Setlist.' ) % item.songCount else: text = '' else: text = '' font.render( text, ( 0.05, .155 ), scale = 0.0015, align = 2 ) if isinstance( item, Song.SongInfo ) or isinstance( item, Song.LibraryInfo ) or isinstance( item, Song.RandomSongInfo ): ( c1, c2, c3 ) = self.song_name_selected_color glColor4f( c1, c2, c3, 1 ) if isinstance( item, Song.TitleInfo ) or isinstance( item, Song.SortTitleInfo ): ( c1, c2, c3 ) = self.career_title_color glColor4f( c1, c2, c3, 1 ) text = item.name maxwidth = .43 scale = 0.0016 ( wt, ht ) = font.getStringSize( text, scale = scale ) while wt > maxwidth: tlength = len( text ) - 2 text = text[:tlength] + '...' ( wt, ht ) = font.getStringSize( text, scale = scale ) if wt < maxwidth: break font.render( text, ( .07, .043 * ( n + 1 ) + .098 ), scale = scale ) if isinstance( item, Song.SongInfo ): score = _( "Nil" ) stars = 0 name = "" if not item.getLocked(): try: difficulties = item.partDifficulties[scene.scorePart.id] except KeyError: difficulties = [] for d in difficulties: if d.id == scene.scoreDifficulty.id: scores = item.getHighscores( d, part = scene.scorePart ) if scores: ( score, stars, name, scoreExt ) = scores[0] try: ( notesHit, notesTotal, noteStreak, modVersion, handicap, handicapLong, originalScore, ) = scoreExt except ValueError: ( notesHit, notesTotal, noteStreak, modVersion, oldScores1, oldScores2, ) = scoreExt break else: ( score, stars, name ) = ( 0, 0, '---' ) if score == _( 'Nil' ) and scene.nilShowNextScore: for d in difficulties: scores = item.getHighscores( d, part = scene.scorePart ) if scores: ( score, stars, name, scoreExt ) = scores[0] try: ( notesHit, notesTotal, noteStreak, modVersion, handicap, handicapLong, originalScore, ) = scoreExt except ValueError: ( notesHit, notesTotal, noteStreak, modVersion, oldScores1, oldScores2, ) = scoreExt break else: ( score, stars, name ) = ( 0, 0, '---' ) else: ( score, stars, name ) = ( _( 'Nil' ), 0, '---' ) scale = 0.0010 if score != _( 'Nil' ) and score > 0 and notesTotal != 0: text = '%.1f%%' % ( float( notesHit ) / notesTotal * 100.0) ( w, h ) = font.getStringSize( text, scale = scale ) font.render( text, ( 0.56, .043 * ( n + 1 ) + .098 ), scale = scale, align = 2 ) if scene.img_starwhite and scene.img_stargold: ( w, h ) = scene.geometry imgwidth = scene.img_starwhite.width1() wfactor1 = 2.0 / imgwidth if stars == 6: for k in range( 0, 5 ): scene.drawImage( scene.img_stargold, scale = ( wfactor1 * 1.2, -wfactor1 * 1.2), coord = ( ( .58 + .025 * k ) * w, ((-n*.0565)*h )+ h/1.235), stretched = 11 ) else: for k in range( 0, stars ): scene.drawImage( scene.img_starwhite, scale = ( wfactor1 * 1.2, -wfactor1 * 1.2), coord = ( ( .58 + .025 * k ) * w, ((-n*.0565)*h )+ h/1.235), stretched = 11 )
def render(self, text, pos = (0, 0), rotate = 0, scale = DEFAULT_SCALE, shadowoffset = (.0022, .0005), align = LEFT, new = False): """ Draw some text. @param text: Text to draw @param pos: Text coordinate tuple (x, y) @param rotate: Angle to rotate text, in degrees @param scale: Scale factor """ # deufeufeu : new drawing relaying only on pygame.font.render # : I know me miss special unicodes characters, but the gain # : is really important. # evilynux : Use arrays to increase performance def drawSquare(w,h,tw,th): self.square_prim[1,0] = self.square_prim[3,0] = w self.square_prim[2,1] = self.square_prim[3,1] = h self.square_tex[0,1] = self.square_tex[1,1] = th self.square_tex[1,0] = self.square_tex[3,0] = tw cmglDrawArrays(GL_TRIANGLE_STRIP, vertices=self.square_prim, texcoords=self.square_tex) if not text: return try: t,w,h = self.stringsCache.get(text) except KeyError: s = self.font.render(text, True, (255,255,255)) t = Texture() t.setFilter(GL_LINEAR, GL_LINEAR) t.setRepeat(GL_CLAMP, GL_CLAMP) t.loadSurface(s, alphaChannel = True) del s w, h = self.font.size(text) self.stringsCache.add(text,(t,w,h)) x, y = pos scale *= self.scale w, h = w*scale*self.aspectRatioFactor, h*scale if align == CENTER: #we have already done all the calculating. Why not add this? - akedrou x -= (w/2) elif align == RIGHT: x -= w y -= (h/2) tw,th = t.size glEnable(GL_TEXTURE_2D) with cmglPushedMatrix(): if rotate: if not isinstance(rotate, tuple): glRotatef(rotate, 0, 0, 1.0) else: glRotatef(0, *rotate) glTranslatef(x,y,0) t.bind() if self.outline: with cmglPushedAttrib(GL_CURRENT_BIT): glColor4f(0, 0, 0, .25 * glGetDoublev(GL_CURRENT_COLOR)[3]) blur = 2 * DEFAULT_SCALE for offset in [(-.7, -.7), (0, -1), (.7, -.7), (-1, 0), (1, 0), (-.7, .7), (0, 1), (.7, .7)]: with cmglPushedMatrix(): glTranslatef(blur * offset[0], blur * offset[1], 0) drawSquare(w,h,tw,th) if self.shadow: with cmglPushedAttrib(GL_CURRENT_BIT): glColor4f(0, 0, 0, 1) with cmglPushedMatrix(): glTranslatef(shadowoffset[0], shadowoffset[1], 0) drawSquare(w,h,tw,th) drawSquare(w,h,tw,th) glDisable(GL_TEXTURE_2D)
def renderSelectedItem( self, scene, n ): ( w, h ) = scene.geometry font = scene.fontDict['songListFont'] item = scene.selectedItem if not item: return if isinstance( item, Song.BlankSpaceInfo ): return if self.setlist_type == 3: y = h * ( .7825 - .0459 * n ) if scene.img_tier: imgwidth = scene.img_tier.width1() imgheight = scene.img_tier.height1() wfactor = 381.1 / imgwidth hfactor = 24.000 / imgheight if isinstance( item, Song.TitleInfo ) or isinstance( item, Song.SortTitleInfo ): scene.drawImage( scene.img_tier, scale = ( wfactor, - hfactor ), coord = ( w / 1.587, h - 0.055 * h * ( n + 1 ) - 0.219 * h ) ) if scene.img_selected: imgwidth = scene.img_selected.width1() imgheight = scene.img_selected.height1() wfactor = 0.03 scene.drawImage( scene.img_selected, scale = ( wfactor, - wfactor ), coord = ( w / 1.587, y * 1.2 - h * .213 ), stretched = 11 ) icon = None if isinstance( item, Song.SongInfo ): if item.icon != '': try: icon = scene.itemIcons[item.icon] wfactor = 0.03 scene.drawImage( icon, scale = ( wfactor, - wfactor ), coord = ( w / 1.052, h - 0.055 * h * ( n + 1 ) - 0.20000000000000001 * h ), stretched = 11 ) except KeyError: pass ( c1, c2, c3 ) = self.song_name_selected_color glColor3f( c1, c2, c3 ) if item.getLocked(): text = item.getUnlockText() elif scene.careerMode and not item.completed: text = _( 'Play To Advance' ) elif scene.practiceMode: text = _( 'Practice' ) elif item.count: count = int( item.count ) if count == 1: text = _( 'Played Once' ) else: text = _( 'Played %d times.' ) % count else: text = _( 'Quickplay' ) elif isinstance( item, Song.LibraryInfo ): try: icon = scene.itemIcons['Library'] wfactor = 0.03 scene.drawImage( icon, scale = ( wfactor, -wfactor ), coord = ( w / 1.052, h - 0.055 * h * ( n + 1 ) - 0.20000000000000001 * h ), stretched = 11 ) except KeyError: pass ( c1, c2, c3 ) = self.library_selected_color glColor3f( c1, c2, c3 ) if item.songCount == 1: text = _( 'There Is 1 Song In This Setlist.' ) elif item.songCount > 1: text = _( 'There Are %d Songs In This Setlist.' ) \ % item.songCount else: text = '' elif isinstance( item, Song.TitleInfo ) or isinstance( item, Song.SortTitleInfo ): text = _( 'Tier' ) ( c1, c2, c3 ) = self.career_title_color glColor3f( c1, c2, c3 ) elif isinstance( item, Song.RandomSongInfo ): try: icon = scene.itemIcons['Random'] wfactor = 0.03 scene.drawImage( icon, scale = ( wfactor, -wfactor ), coord = ( w / 1.052, h - 0.055 * h * ( n + 1 ) - 0.20000000000000001 * h ), stretched = 11 ) except KeyError: pass text = _( 'Random Song' ) ( c1, c2, c3 ) = self.career_title_color glColor3f( c1, c2, c3 ) font.render( text, ( 0.92000000000000003, .155 ), scale = 0.00150001, align = 2 ) maxwidth = 0.20000000000000001 if isinstance( item, Song.SongInfo ) or isinstance( item, Song.LibraryInfo ) or isinstance( item, Song.RandomSongInfo ): ( c1, c2, c3 ) = self.song_name_selected_color glColor4f( c1, c2, c3, 1 ) if isinstance( item, Song.TitleInfo ) or isinstance( item, Song.SortTitleInfo ): ( c1, c2, c3 ) = self.career_title_color glColor4f( c1, c2, c3, 1 ) text = item.name if isinstance( item, Song.SongInfo ) and item.getLocked(): text = _( '-- Locked --' ) if isinstance( item, Song.SongInfo ): if scene.tiersPresent or icon: text = ' ' + text if isinstance( item, Song.TitleInfo ) or isinstance( item, Song.SortTitleInfo ): maxwidth = 0.20000000000000001 text = string.upper( text ) scale = 0.00160001 ( wt, ht ) = font.getStringSize( text, scale = scale ) while wt > maxwidth: tlength = len( text ) - 4 text = text[:tlength] + '...' ( wt, ht ) = font.getStringSize( text, scale = scale ) if wt < .45: break font.render( text, ( .40, .0413 * ( n + 1 ) + .15 ), scale = scale ) if isinstance( item, Song.SongInfo ): score = _( "Nil" ) stars = 0 name = "" if not item.getLocked(): try: difficulties = \ item.partDifficulties[scene.scorePart.id] except KeyError: difficulties = [] for d in difficulties: if d.id == scene.scoreDifficulty.id: scores = item.getHighscores( d, part = scene.scorePart ) if scores: ( score, stars, name, scoreExt ) = \ scores[0] try: ( notesHit, notesTotal, noteStreak, modVersion, handicap, handicapLong, originalScore, ) = scoreExt except ValueError: ( notesHit, notesTotal, noteStreak, modVersion, oldScores1, oldScores2, ) = scoreExt break else: ( score, stars, name ) = ( 0, 0, '---' ) if score == _( 'Nil' ) and scene.nilShowNextScore: for d in difficulties: scores = item.getHighscores( d, part = scene.scorePart ) if scores: ( score, stars, name, scoreExt ) = \ scores[0] try: ( notesHit, notesTotal, noteStreak, modVersion, handicap, handicapLong, originalScore, ) = scoreExt except ValueError: ( notesHit, notesTotal, noteStreak, modVersion, oldScores1, oldScores2, ) = scoreExt break else: ( score, stars, name ) = ( 0, 0, '---' ) else: ( score, stars, name ) = ( _( 'Nil' ), 0, '---' ) scale = 0.0010 if score != _( 'Nil' ) and score > 0 \ and notesTotal != 0: text = '%.1f%% (%d)' % ( float( notesHit ) / notesTotal * 100.0, noteStreak ) ( w, h ) = font.getStringSize( text, scale = scale ) font.render( text, ( 0.92000000000000003, .0413 * ( n + 1 ) + .163 ), scale = scale, align = 2 ) text = str( score ) font.render( text, ( 0.92000000000000003, .0413 * ( n + 1 ) + .15 ), scale = scale, align = 2 )
def renderUnselectedItem( self, scene, i, n, ): ( w, h ) = scene.geometry font = scene.fontDict['songListFont'] if self.setlist_type == 3: font = scene.fontDict['songListFont'] if not scene.items or scene.itemIcons is None: return item = scene.items[i] if scene.img_tier: imgwidth = scene.img_tier.width1() imgheight = scene.img_tier.height1() wfactor = 0.02 if isinstance( item, Song.TitleInfo ) or isinstance( item, Song.SortTitleInfo ) and scene.img_tier: scene.drawImage( scene.img_tier, scale = ( wfactor, - hfactor ), coord = ( w / 1.587, h - 0.055 * h * ( n + 1 ) - 0.219 * h ) ) icon = None if isinstance( item, Song.SongInfo ): if item.icon != '': try: icon = scene.itemIcons[item.icon] wfactor = 0.02 scene.drawImage( icon, scale = ( wfactor, - wfactor ), coord = ( w / 1.052, h - 0.055 * h * ( n + 1 ) - 0.20000000000000001 * h ), stretched = 11 ) except KeyError: pass elif isinstance( item, Song.LibraryInfo ): try: icon = scene.itemIcons['Library'] wfactor = 0.02 scene.drawImage( icon, scale = ( wfactor, -wfactor ), coord = ( w / 1.052, h - 0.055 * h * ( n + 1 ) - 0.20000000000000001 * h ), stretched = 11 ) except KeyError: pass elif isinstance( item, Song.RandomSongInfo ): try: icon = scene.itemIcons['Random'] wfactor = 0.02 scene.drawImage( icon, scale = ( wfactor, -wfactor ), coord = ( w / 1.052, h - 0.055 * h * ( n + 1 ) - 0.20000000000000001 * h ), stretched = 11 ) except KeyError: pass if isinstance( item, Song.SongInfo ) or isinstance( item, Song.LibraryInfo ): ( c1, c2, c3 ) = self.song_name_text_color glColor4f( c1, c2, c3, 1 ) elif isinstance( item, Song.TitleInfo ) or isinstance( item, Song.SortTitleInfo ): ( c1, c2, c3 ) = self.career_title_color glColor4f( c1, c2, c3, 1 ) elif isinstance( item, Song.RandomSongInfo ): ( c1, c2, c3 ) = self.song_name_text_color glColor4f( c1, c2, c3, 1 ) text = item.name if isinstance( item, Song.SongInfo ) and item.getLocked(): text = _( '-- Locked --' ) if isinstance( item, Song.SongInfo ): if scene.tiersPresent or icon: text = ' ' + text maxwidth = .3 if isinstance( item, Song.TitleInfo ) or isinstance( item, Song.SortTitleInfo ): text = string.upper( text ) scale = 0.00160001 ( wt, ht ) = font.getStringSize( text, scale = scale ) while wt > maxwidth: tlength = len( text ) - 4 text = text[:tlength] + '...' ( wt, ht ) = font.getStringSize( text, scale = scale ) if wt < .45: break font.render( text, ( .40, .0413 * ( n + 1 ) + .15 ), scale = scale ) if isinstance( item, Song.SongInfo ): score = _( "Nil" ) stars = 0 name = "" if not item.getLocked(): try: difficulties = \ item.partDifficulties[scene.scorePart.id] except KeyError: difficulties = [] for d in difficulties: if d.id == scene.scoreDifficulty.id: scores = item.getHighscores( d, part = scene.scorePart ) if scores: ( score, stars, name, scoreExt ) = \ scores[0] try: ( notesHit, notesTotal, noteStreak, modVersion, handicap, handicapLong, originalScore, ) = scoreExt except ValueError: ( notesHit, notesTotal, noteStreak, modVersion, oldScores1, oldScores2, ) = scoreExt break else: ( score, stars, name ) = ( 0, 0, '---' ) if score == _( 'Nil' ) and scene.nilShowNextScore: for d in difficulties: scores = item.getHighscores( d, part = scene.scorePart ) if scores: ( score, stars, name, scoreExt ) = \ scores[0] try: ( notesHit, notesTotal, noteStreak, modVersion, handicap, handicapLong, originalScore, ) = scoreExt except ValueError: ( notesHit, notesTotal, noteStreak, modVersion, oldScores1, oldScores2, ) = scoreExt break else: ( score, stars, name ) = ( 0, 0, '---' ) else: ( score, stars, name ) = ( _( 'Nil' ), 0, '---' ) scale = 0.0010 if score != _( 'Nil' ) and score > 0 \ and notesTotal != 0: text = '%.1f%% (%d)' % ( float( notesHit ) / notesTotal * 100.0, noteStreak ) font.render( text, ( 0.92000000000000003, .0413 * ( n + 1 ) + .163 ), scale = scale, align = 2 ) text = str( score ) font.render( text, ( 0.92000000000000003, .0413 * ( n + 1 ) + .15 ), scale = scale, align = 2 )