From: <Blu...@us...> - 2010-09-09 15:26:11
|
Revision: 397 http://virtplayground.svn.sourceforge.net/virtplayground/?rev=397&view=rev Author: BlueWolf_ Date: 2010-09-09 15:26:04 +0000 (Thu, 09 Sep 2010) Log Message: ----------- The topbar has now text, although it's still static yet (except for the name of course) Modified Paths: -------------- trunk/client/layout.py Modified: trunk/client/layout.py =================================================================== --- trunk/client/layout.py 2010-09-08 19:10:55 UTC (rev 396) +++ trunk/client/layout.py 2010-09-09 15:26:04 UTC (rev 397) @@ -39,6 +39,8 @@ # Playground stuff self.topbar = None self.toppos = None + self.topbar_mainfont = None + self.topbar_subfont = None def event(self, ev): if self.status == "playground": @@ -98,7 +100,12 @@ self.hover = None self.toppos = 0 + self.topbar_mainfont = pygame.font.Font(real_path(\ + "fonts", "DejaVuSans-Bold.ttf"), 19) + self.topbar_subfont = pygame.font.Font(real_path(\ + "fonts", "DejaVuSans-Bold.ttf"), 10) + # Slide the topbar in sh['timer'].start("layout-topslide", self.timer, \ time.time(), 1) @@ -108,10 +115,14 @@ def updatetop(self, wholebar = False): if wholebar: + # This happens when the WHOLE bar needs to be updated + # For example: When the startup-animation is happening self.surf.fill([0,0,0,0]) self.surf.blit(self.topbar, (0,self.toppos), (0,0,1000,TOPHEIGHT)) - + + # Walkthrough every button for i in range(TOPBUTTONS): + # Calculating and setting all variables left = TOPLEFT + (TOPBUTTONWIDTH*i) rect = Rect(left, self.toppos, TOPBUTTONWIDTH, TOPHEIGHT) @@ -119,18 +130,75 @@ if self.selected is i: # This button is selected rect2 = rect.move(0,TOPHEIGHT*2) + textcolor_main = (159, 159, 159) + textcolor_sub = (116, 116, 116) + textpos_main = 6 + textpos_sub = 1 elif self.hover is i: # This button is hovered rect2 = rect.move(0,TOPHEIGHT) - + textcolor_main = (132, 125, 114) + textcolor_sub = (116, 108, 96) + textpos_main = 5 + textpos_sub = 0 else: rect2 = rect.move(0,0) + textcolor_main = (119, 119, 119) + textcolor_sub = (90, 90, 90) + textpos_main = 5 + textpos_sub = 0 + + textcolor_mainshadow = (0, 0, 0) + textcolor_subshadow = (0, 0, 0) + if i == 0: + text_main = "General" + text_sub = sh['client'].username + ": 0 V" + textpos_sub += 30 + + elif i == 1: + text_main = "Who is online" + text_sub = "Only you" + textpos_sub += 32 + elif i == 2: + text_main = "Items" + text_sub = "0 items" + textpos_sub += 30 + + + # Blit image rect2.move_ip(0, -self.toppos) self.surf.blit(self.topbar, rect, rect2) + + + # Blit text + # Main-shadow + text = self.topbar_mainfont.render(text_main, True, \ + textcolor_mainshadow) + textpos = [(302/2)-(text.get_width()/2), textpos_main] + textpos[0] += rect.left + textpos[1] += rect.top + self.surf.blit(text, (textpos[0], textpos[1]-1)) + # Main + text = self.topbar_mainfont.render(text_main, True, textcolor_main) + self.surf.blit(text, textpos) + + # Sub-shadow + text = self.topbar_subfont.render(text_sub, True, \ + textcolor_subshadow) + textpos = [(302/2)-(text.get_width()/2), textpos_sub] + textpos[0] += rect.left + textpos[1] += rect.top + self.surf.blit(text, (textpos[0], textpos[1]-1)) + # Sub + text = self.topbar_subfont.render(text_sub, True, textcolor_sub) + self.surf.blit(text, textpos) + + sh['update']((0,0, 1000, 65)) + def topbarcursor(self, pos): if pos[0] > TOPLEFT and pos[0] < (TOPBUTTONWIDTH*TOPBUTTONS+TOPLEFT) \ and pos[1] < 55: @@ -149,6 +217,8 @@ if direction == 0 : # Up # Clear the bar self.topbar = None + self.topbar_mainfont = None + self.topbar_subfont = None self.surf.fill([0,0,0,0]) sh['update']((0,0, 1000, 65)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |