Changeset 59


Ignore:
Timestamp:
02/29/12 03:10:47 (3 years ago)
Author:
jelinson
Message:

Added color features to stats like different colors and pop-up with actual value and description

Location:
src
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • src/color.py

    r53 r59  
    1212RED = (255,0,0)
    1313GREEN = (0,255,0)
     14LIGHT_GREEN = (85, 255, 85)
    1415BLUE = (0,0,255)
    1516MAGENTA = (255,0,255)
  • src/fileio.py

    r17 r59  
    77
    88resourceDir = ".." + os.sep + "resources"
     9pngDir = resourceDir + os.sep + 'menu_icons' + os.sep + 'png' + os.sep
  • src/game.py

    r58 r59  
    4444        return self.currentTurn.displayStats()
    4545   
     46    def displayDetailedStat(self, statID):
     47        return self.currentTurn.displayDetailedStat(statID)
     48   
    4649    def build(self,name):
    4750        if self.currentTurn.buildingPossible(name) and self.map.checkSpace():
  • src/main.py

    r58 r59  
    6363                    for j in windows:
    6464                        ui.addWindow(j)
    65                        
     65
    6666                       
    6767                elif i.responseType == 'describe':
     
    6969                   
    7070                   
     71                elif i.responseType == 'stats':
     72                    ui.addWindow(game.displayDetailedStat(i.ID))
     73                   
     74                   
    7175                else: # response == 'windows'
     76                    if DEBUG:
     77                        print "Else response case type: ", i.responseType
    7278                    for otherWindow in i.windowList:
    7379                        windows = game.createWindow(otherWindow)
  • src/spec.py

    r54 r59  
    5555       
    5656    def getAllStats(self):
    57         return [('money', self.money), ('power', self.power), ('material', self.material), ('space', self.space), ('pollution', self.pollution)]
    58    
     57        return [('money', self.money, GREEN), # ideally these colors should be dynamic with relative magnitude
     58                ('power', self.power, GREEN),
     59                ('material', self.material, GREEN),
     60                ('space', self.space, GREEN),
     61                ('pollution', self.pollution, RED)]
     62           
    5963    def getScaledStats(self):
    6064        return [('money', self.money), ('power', self.power), ('material', self.material), ('space', self.space), ('pollution', self.pollution)]
     
    7579        self.setPollution(self.getPollution() + otherSpec.getPollution())
    7680        return self
     81   
     82    def stringToValue(self, statID):
     83        if statID == 'money':
     84            return self.money
     85        elif statID == 'power':
     86            return self.power
     87        elif statID == 'material':
     88            return self.material
     89        elif statID == 'space':
     90            return self.space
     91        elif statID == 'pollution':
     92            return self.pollution
     93        else:
     94            if DEBUG:
     95                print "Unknown statID"
     96            return 0
  • src/state.py

    r58 r59  
    6161       
    6262        i = 0
    63         for (name,value) in stats:
    64             buildIcon = WindowEntry(Response('windows',[],False,False))
    65             buildArt = pygame.image.load(os.path.abspath(resourceDir + os.sep + 'menu_icons' + os.sep + 'png' + os.sep + name + '.png'))
     63        for (name, value, color) in stats:
     64            buildIcon = WindowEntry(Response('stats',[],False,False, name))
     65            buildArt = pygame.image.load(os.path.abspath(pngDir + name + '.png'))
    6666            buildIcon.addImage(Image((30+STAT_SHIFT*i,240),STAT_ICON_SIZE,STAT_ICON_SIZE,buildArt))
    6767            buildIcon.addRectangle(Rectangle((40+STAT_SHIFT*i,25),20,205,FAKEBLACK))
    6868            if value > 200:
    6969                value = 200
    70             buildIcon.addRectangle(Rectangle((40+STAT_SHIFT*i,230 - value),20,value,GREEN))
     70            buildIcon.addRectangle(Rectangle((40+STAT_SHIFT*i,230 - value),20,value,color))
    7171            statBars.addEntry(buildIcon)
    7272            i += 1
    7373        return statBars
    7474
     75    def displayDetailedStat(self, statID):
     76        stat = Window('',600, 480)
     77        stat.setDefaultResponse(Response('windows',[], True, True))
     78        details = WindowEntry(Response('windows',[], True, True))
     79        details.addRectangle(Rectangle((40,50), STAT_W-80, 70, MAUVE))
     80        statDescription = statID.capitalize() + ": " + str(self.specs.stringToValue(statID)) + " - "
     81        # this text should be dynamic
     82        statDescription = statDescription + "To improve this stat, try researching in something intelligent."
     83        details.addText(Text((40,50), statDescription, 32, WHITE, STAT_W-80))
     84       
     85        stat.addEntry(details)
     86        return stat
    7587   
  • src/staticWindows.py

    r57 r59  
    3636#buildGameMenu = Window('buildButton',40,720)
    3737buildIcon = WindowEntry(Response('windows',['buildMenu'],False,False))
    38 buildArt = pygame.image.load(os.path.abspath(resourceDir + os.sep + "menu_icons" + os.sep + "png" + os.sep + "build.png"))
     38buildArt = pygame.image.load(os.path.abspath(pngDir + "build.png"))
    3939buildIcon.addImage(Image((5,5),SMALL,SMALL,buildArt,))
    4040buildIcon.addRectangle(Rectangle((0,0),BUTTON_W,BUTTON_H,BLUE))
     
    6868#    # Hard coded for now, but eventually will be a for loop through each object
    6969#    buildIcon = WindowEntry(('',False,False))
    70 #    buildArt = pygame.image.load(os.path.abspath(resourceDir + os.sep + "menu_icons" + os.sep + "png" + os.sep + "build.png"))
     70#    buildArt = pygame.image.load(os.path.abspath(pngDir + "build.png"))
    7171#    buildIcon.addImage(Image((120,10),40,40,buildArt))
    7272#    buildIcon.addImage(Image((345,10),40,40,buildArt))
     
    8080# Hard coded for now, but eventually will be a for loop through each object
    8181researchIcon = WindowEntry(Response('windows',[],False,False))
    82 researchArt = pygame.image.load(os.path.abspath(resourceDir + os.sep + "menu_icons" + os.sep + "png" + os.sep + "research.png"))
     82researchArt = pygame.image.load(os.path.abspath(pngDir + "research.png"))
    8383researchIcon.addImage(Image((120,10),40,40,researchArt))
    8484researchIcon.addImage(Image((345,10),40,40,researchArt,))
     
    9393
    9494researchIcon = WindowEntry(Response('windows',['researchPower'],False,False))
    95 buildArt = pygame.image.load(os.path.abspath(resourceDir + os.sep + "menu_icons" + os.sep + "png" + os.sep + "power.png"))
     95buildArt = pygame.image.load(os.path.abspath(pngDir + "power.png"))
    9696researchIcon.addImage(Image((390,110),ICON_SIZE,ICON_SIZE,buildArt))
    9797researchIcon.addRectangle(Rectangle((20,100),460,100,CYAN))
     
    101101
    102102researchIcon = WindowEntry(Response('windows',['researchMoney'],False,False))
    103 buildArt = pygame.image.load(os.path.abspath(resourceDir + os.sep + "menu_icons" + os.sep + "png" + os.sep + "coins.png"))
     103buildArt = pygame.image.load(os.path.abspath(pngDir + "coins.png"))
    104104researchIcon.addImage(Image((390,230),ICON_SIZE,ICON_SIZE,buildArt))
    105105researchIcon.addRectangle(Rectangle((20,220),460,100,CYAN))
     
    109109
    110110researchIcon = WindowEntry(Response('windows',['researchMaterial'],False,False))
    111 buildArt = pygame.image.load(os.path.abspath(resourceDir + os.sep + "menu_icons" + os.sep + "png" + os.sep + "material.png"))
     111buildArt = pygame.image.load(os.path.abspath(pngDir + "material.png"))
    112112researchIcon.addImage(Image((390,350),ICON_SIZE,ICON_SIZE,buildArt))
    113113researchIcon.addRectangle(Rectangle((20,340),460,100,CYAN))
  • src/turn.py

    r54 r59  
    1313       
    1414    def describe(self,name):
    15         print 'awefdasdcaew turn'
     15        if DEBUG:
     16            print 'awefdasdcaew turn'
    1617        return self.turnMenu.createDescription(name)
    1718   
     
    3435    def displayStats(self):
    3536        return self.currentState.displayStats()
     37   
     38    def displayDetailedStat(self, statID):
     39        return self.currentState.displayDetailedStat(statID)
  • src/turnMenu.py

    r58 r59  
    1919        buildMenu = Window('buildMenu',20,20)
    2020        buildMenu.setDefaultResponse(Response('windows',[],True,True))
    21         buildArt = pygame.image.load(os.path.abspath(resourceDir + os.sep + "menu_icons" + os.sep + "png" + os.sep + "build.png"))
     21        buildArt = pygame.image.load(os.path.abspath(pngDir + "build.png"))
    2222        buildIcon = WindowEntry(Response('windows',[],False,False))
    2323        buildIcon.addImage(Image((120,10),40,40,buildArt))
  • src/ui.py

    r58 r59  
    9090            surface.blit(windowSurface,(self.windows[i].left,self.windows[i].top))
    9191        pygame.display.update()
     92             
    9293                       
    9394    def initialize(self, windows):
  • src/windowEntry.py

    r56 r59  
    3737        for i in range(len(self.rectangles)):
    3838            if self.rectangles[i].getRect().collidepoint(pos):
     39                if DEBUG:
     40                    print "Rect collision"
    3941                return True
    4042        for i in range(len(self.images)):
    4143            if self.images[i].getRect().collidepoint(pos):
     44                if DEBUG:
     45                    print "Image collision"
    4246                return True
    4347        return False
Note: See TracChangeset for help on using the changeset viewer.