root/src/turnMenu.py @ 54

Revision 54, 2.7 KB (checked in by mmorton, 2 years ago)
RevLine 
[42]1'''
2Created on Feb 18, 2012
3
4@author: TechTrek
5'''
[51]6from globals import *
[42]7from fileio import *
8from state import *
9from buildables import *
10from pygame import *
11from window import *
12
13class TurnMenu():
14   
15    def __init__(self):
16        None
17       
18    def createBuildMenu(self,state):
[54]19        buildMenu = Window('buildMenu',20,20)
20        buildMenu.setDefaultResponse(Response('windows',[],True,True))
[43]21        buildArt = pygame.image.load(os.path.abspath(resourceDir + os.sep + "menu_icons" + os.sep + "png" + os.sep + "build.png"))
[54]22        buildIcon = WindowEntry(Response('windows',[],False,False))
[44]23        buildIcon.addImage(Image((120,10),40,40,buildArt))
24        buildIcon.addImage(Image((345,10),40,40,buildArt))
[43]25        buildIcon.addRectangle(Rectangle((0,0),MENU_W,MENU_H,BLUE))
26        buildIcon.addText(Text((210,17),"BUILD",42,WHITE,))
27        buildMenu.addEntry(buildIcon)
28        buildables = self.calculateBuildables(state)
29       
[42]30        i = 0
31        for name in buildables:
[54]32            buildIcon = WindowEntry(Response('describe',[],False,False,name))
[43]33            buildArt = pygame.image.load(os.path.abspath(resourceDir + os.sep + 'menu_icons' + os.sep + buildingLUT[name].imageFileName))
[44]34            buildIcon.addImage(Image((390,110+ENTRY_SHIFT*i),ICON_SIZE,ICON_SIZE,buildArt))
[42]35            buildIcon.addRectangle(Rectangle((20,100+ENTRY_SHIFT*i),460,100,CYAN))
36            buildIcon.addText(Text((25,110+ENTRY_SHIFT*i),name,32,WHITE))
37            buildIcon.addText(Text((25,140+ENTRY_SHIFT*i), buildingLUT[name].menuDescript,24,WHITE))
38            buildMenu.addEntry(buildIcon)
39            i += 1
40        return buildMenu
41   
42    def calculateBuildables(self,state):
43        buildables = []
[43]44        for name in buildingLUT.keys():
[42]45            if state.checkThresh(name):
46                buildables.append(name)
47        return buildables
[43]48       
49    def createDescription(self, name):
[54]50        print 'awefohias'
51        descriptionWindow = Window(name,506,200)
52        descriptionWindow.setDefaultResponse(Response('windows',[],True,True))
53        buildIcon = WindowEntry(Response('build',[],True,False,name))
[43]54        buildArt = pygame.image.load(os.path.abspath(resourceDir + os.sep + 'menu_icons' + os.sep + buildingLUT[name].imageFileName))
[47]55        buildIcon.addImage(Image((390,110),ICON_SIZE,ICON_SIZE,buildArt))
[43]56        buildIcon.addRectangle(Rectangle((20,100),460,100,CYAN))
57        buildIcon.addText(Text((25,110),name,32,WHITE))
58        buildIcon.addText(Text((25,140), buildingLUT[name].detailedDescript,24,WHITE))
59        descriptionWindow.addEntry(buildIcon)
60        return descriptionWindow
61       
62       
63       
64       
65       
[42]66       
Note: See TracBrowser for help on using the browser.