comparison pyntnclick/gamescreen.py @ 646:edcca10b8a53 pyntnclick

Return of the centred detail views
author Neil Muller <neil@dip.sun.ac.za>
date Sun, 12 Feb 2012 11:45:34 +0200
parents 4aae15dedc29
children 96daa4119745
comparison
equal deleted inserted replaced
645:4aae15dedc29 646:edcca10b8a53
123 # self._mouse_move(mouse.get_pos()) 123 # self._mouse_move(mouse.get_pos())
124 124
125 def show_detail(self, detail): 125 def show_detail(self, detail):
126 self.clear_detail() 126 self.clear_detail()
127 detail_obj = self.game.set_current_detail(detail) 127 detail_obj = self.game.set_current_detail(detail)
128 self.detail.set_image_rect(Rect((0, 0), detail_obj.get_detail_size()))
129 self.add(self.detail) 128 self.add(self.detail)
129 detail_rect = Rect((0, 0), detail_obj.get_detail_size())
130 # Centre the widget
131 detail_rect.center = self.rect.center
132 self.detail.set_image_rect(detail_rect)
130 self.game.do_enter_detail() 133 self.game.do_enter_detail()
131 134
132 def clear_detail(self): 135 def clear_detail(self):
133 """Hide the detail view""" 136 """Hide the detail view"""
134 if self.game.current_detail is not None: 137 if self.game.current_detail is not None:
163 self.parent.end_game() 166 self.parent.end_game()
164 167
165 def set_image_rect(self, rect): 168 def set_image_rect(self, rect):
166 bw = self.border_width 169 bw = self.border_width
167 self.image_rect = rect 170 self.image_rect = rect
168 self.image_rect.topleft = (bw, bw)
169 self.rect = rect.inflate(bw * 2, bw * 2) 171 self.rect = rect.inflate(bw * 2, bw * 2)
170 self.close.rect.midbottom = rect.midbottom 172 self.close.rect.midbottom = rect.midbottom
171 173
172 def draw(self, surface): 174 def draw(self, surface):
173 # scene_surface = self.get_root().surface.subsurface(self.parent.rect) 175 # scene_surface = self.get_root().surface.subsurface(self.parent.rect)