root/src/buildMenuEntry.py @ 420

Revision 420, 2.1 KB (checked in by ecoughlan, 2 years ago)

Fixed incorrect locations

Line 
1'''
2Created on Mar 24, 2012
3
4@author: TechTrek
5'''
6
7from state import State
8from menuEntry import MenuEntry
9from buildDescription import BuildDescription
10from info import Info
11from stats import Stats
12from dim import buildMenuEntryDim as DIM
13from globals import *
14
15
16class BuildMenuEntry(MenuEntry):
17    def __init__(self, pos, visible, building):
18        self.able = (CAN_BUILD, "")
19        self.building = building
20        self.info = Info()
21        self.info.createFromBuilding(building, False, self.able)
22
23        buildingStats = self.building.stats.contSpecs.getAllStats()
24        self.stats = Stats((DIM.DESCRIP_LEFT + 50, DIM.DESCRIP_TOP + 125),False, buildingStats,isBuilding=True)
25        MenuEntry.__init__(self, pos, visible, self.info)
26       
27        self.stats.stayBack = True
28        self.info.createFromBuilding(building, True, self.able)
29        popup = BuildDescription((DIM.DESCRIP_LEFT, DIM.DESCRIP_TOP), False, self.info, self.able)
30        popup.addWindow(self.stats)
31        self.subwindows.append(popup)
32        self.addResponse((popup.toggle,))
33
34    def setYesResponse(self, response):
35        """
36            Sets the build response for the menu entry
37
38            input type: function pointer
39        """
40        self.buildResponse = response
41        self.subwindows[0].setYesResponse((self.doBuild,))
42
43    def doBuild(self):
44        self.buildResponse(self.building)
45
46    def update(self, state):
47        newAvailability = state.checkThresh(self.building.name)
48        if not (self.able == newAvailability):
49            self.able = newAvailability
50            self.subwindows = []
51            self.info.createFromBuilding(self.building, False, self.able)
52            MenuEntry.__init__(self, self.pos, self.visible, self.info)
53
54            self.info.createFromBuilding(self.building, True, self.able)
55            popup = BuildDescription((DIM.DESCRIP_LEFT, DIM.DESCRIP_TOP), False, self.info, self.able)
56            popup.setYesResponse((self.doBuild,))
57            popup.addWindow(self.stats)
58            self.subwindows.append(popup)
59            self.addResponse((popup.toggle,))
Note: See TracBrowser for help on using the browser.