root/src/buildMenuEntry.py @ 572

Revision 572, 2.6 KB (checked in by ecoughlan, 2 years ago)

unused imports and DIM files

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 globals import *
12from hoverDescription import HoverDescription
13
14
15class BuildMenuEntry(MenuEntry):
16    """
17        the entries to the build menus.
18    """
19   
20    def __init__(self, pos, visible, building):
21        """
22            initializes the build menu entries.
23           
24            input type: (int int)(pos) bool(visible) building(building)
25            return type: none
26        """
27        self.able = (CAN_BUILD, "")
28        self.building = building
29        self.info = Info()
30        self.info.createFromBuilding(building, False, self.able)
31        MenuEntry.__init__(self, pos, visible, self.info)
32
33        self.info.createFromBuilding(building, True, self.able)
34        popup = BuildDescription((0, 0), False, self.info, self.able)
35        self.addWindow(popup)
36        self.addResponse((popup.toggleVisible,))
37        self.hoverDescription = HoverDescription(building.menuDescript)
38
39    def setYesResponse(self, response):
40        """
41            Sets the build response for the menu entry
42
43            input type: function pointer
44            return type: none
45        """
46        self.buildResponse = response
47        self.subwindows[0].setYesResponse((self.doBuild,))
48
49    def doBuild(self):
50        """
51            runs the build response
52           
53            input type: none
54            return type: none
55        """
56        self.buildResponse(self.building)
57
58    def update(self, state):
59        """
60            defines the update response of the object.
61           
62            input type: state
63            return type: none
64        """
65        newAvailability = state.checkThresh(self.building.name)
66        if not (self.able == newAvailability):
67            self.able = newAvailability
68            self.subwindows = []
69            self.info.createFromBuilding(self.building, False, self.able)
70            MenuEntry.__init__(self, self.pos, self.visible, self.info)
71
72            self.info.createFromBuilding(self.building, True, self.able)
73            popup = BuildDescription((0, 0), False, self.info, self.able)
74            popup.setYesResponse((self.doBuild,))
75            self.addWindow(popup)
76            self.addResponse((popup.toggleVisible,))
77
78    def hover(self, surface):
79        """
80            Define the hover window for the object, by default none.
81
82            input type: None
83            return type: None
84        """
85        self.hoverDescription.render(surface)
Note: See TracBrowser for help on using the browser.