Changeset 224

Show
Ignore:
Timestamp:
05/24/2012 10:03:37 AM (23 months ago)
Author:
andefodahl
Message:

buttons should be working now

Location:
traintris
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • traintris/constants.py

    r218 r224  
    140140        self.CATEGORY, self.ORGANISM, self.MENU, self.DIALOG = range(4) 
    141141        self.carnivoreList = ["Fox", "Falcon", "Lion", "Lynx", "Tiger", "Bear", "Wolf", "Snake"] 
    142         self.plantList = ["Trees", "Shrubs", "Bananas", "Grass", "Vegetables", "Berries"] 
     142        self.plantList = ["Trees", "Shrubs", "Bananas", "Grass", "Vegetables", "Berries", "", ""] 
    143143        self.herbivoreList = ["Deer", "Sheep", "Rabbit", "Squirrel", "Cow", "Elephant", "Giraffe", "Rats"] 
     144        self.omnivoreList = ["Human", "", "", "", "", "", "", ""] 
    144145     
    145146class gameNumbers: 
  • traintris/gameboardview.py

    r223 r224  
    114114        self.message = False 
    115115         
     116        self.drawCategoryButtons() 
    116117        self.draw() 
    117118         
     
    198199        self.graphics.drawMenuBox() 
    199200        self.graphics.drawBottomBar(self.daysTillChange, self.season) 
    200         # self.panelDraw() 
    201         self.drawCategoryButtons() 
    202201        for button in self.buttonList: 
    203202            self.graphics.drawButton(button.images, button.mode, button.pos) 
     
    213212        self.buttonList.append(Button(text, imageName, size, pos, type)) 
    214213         
    215     def removeButton(self, imageName): 
     214    def removeButton(self, imageName):  
    216215        for button in self.buttonList: 
    217216            if button.imageName == imageName: 
     
    220219    def drawCategoryButtons(self): 
    221220        buttonsize = (self.screen.get_width() / 4) 
    222         self.addButton( "Producers", "topbutton", (buttonsize, 90), (0,0), CONSTANTS.CATEGORY) 
    223         self.addButton( "Herbivores", "topbutton", (buttonsize, 90), (buttonsize, 0), CONSTANTS.CATEGORY) 
    224         self.addButton( "Carnivores", "topbutton", (buttonsize, 90), (2*buttonsize, 0), CONSTANTS.CATEGORY) 
    225         self.addButton( "Humans", "topbutton", (buttonsize, 90), (3*buttonsize, 0), CONSTANTS.CATEGORY) 
    226         self.addButton("","testbutton",(100,100),(100,100),CONSTANTS.CATEGORY) 
     221        self.addButton( "Producers", "topbutton", (buttonsize, 65), (0,0), CONSTANTS.CATEGORY) 
     222        self.addButton( "Herbivores", "topbutton", (buttonsize, 65), (buttonsize, 0), CONSTANTS.CATEGORY) 
     223        self.addButton( "Carnivores", "topbutton", (buttonsize, 65), (2*buttonsize, 0), CONSTANTS.CATEGORY) 
     224        self.addButton( "Humans", "topbutton", (buttonsize, 65), (3*buttonsize, 0), CONSTANTS.CATEGORY) 
    227225         
    228226    def drawOrganismBar(self, animalList): 
    229         buttonsize = (self.screen.get_width() / len(animalList)) 
     227        buttonsize = (self.screen.get_width() / 8)+1 # 1 more pixel is needed because of rounding 
     228        print self.screen.get_width() 
    230229        for x in range(len(animalList)): 
    231             self.addButton( animalList[x], "tr", (buttonsize, 90), ((x+1)*buttonsize, 0), CONSTANTS.ORGANISM) 
     230            self.addButton( animalList[x], "tr", (buttonsize, 90), ((x)*buttonsize, 65), CONSTANTS.ORGANISM) 
    232231 
    233232    ############################################################################ 
     
    521520                    if self.x > button.pos[0] and self.x < button.pos[0]+button.size[0] \ 
    522521                    and self.y > button.pos[1] and self.y < button.pos[1]+button.size[1]: 
     522                        if button.type == CONSTANTS.CATEGORY: 
     523                            if button.text == "Producers": 
     524                                self.drawOrganismBar(CONSTANTS.plantList) 
     525                            if button.text == "Herbivores": 
     526                                self.drawOrganismBar(CONSTANTS.herbivoreList) 
     527                            if button.text == "Carnivores": 
     528                                self.drawOrganismBar(CONSTANTS.carnivoreList) 
     529                            if button.text == "Humans": 
     530                                self.drawOrganismBar(CONSTANTS.omnivoreList) 
    523531                        self.lastButtonClicked = button 
    524532                        button.mode = CONSTANTS.DEPRESSED 
     
    600608    def __init__(self, text, imageName, size, pos, type): 
    601609        self.mode = CONSTANTS.NEUTRAL 
     610        self.text = text 
    602611        self.pos = pos 
    603612        self.imageName = imageName