comparison tools/area_editor.py @ 134:2e1059b1a247

Tweak button creation code
author Neil Muller <drnlmuller@gmail.com>
date Mon, 02 Sep 2013 17:57:06 +0200
parents 02423600d958
children c9b6685ebebf
comparison
equal deleted inserted replaced
133:79e1888573d3 134:2e1059b1a247
226 but.rect.move_ip(MENU_LEFT + MENU_WIDTH // 2 - MENU_HALF_PAD, 226 but.rect.move_ip(MENU_LEFT + MENU_WIDTH // 2 - MENU_HALF_PAD,
227 y) 227 y)
228 y += MENU_BUTTON_HEIGHT + MENU_PAD 228 y += MENU_BUTTON_HEIGHT + MENU_PAD
229 self.add(but) 229 self.add(but)
230 230
231 button_rect = pygame.rect.Rect(0, 0, MENU_WIDTH, MENU_BUTTON_HEIGHT)
232
231 end_poly_but = PolyButton(None, self.level_widget) 233 end_poly_but = PolyButton(None, self.level_widget)
232 end_poly_but.rect = pygame.rect.Rect(0, 0, MENU_WIDTH, 234 end_poly_but.rect = button_rect.copy()
233 MENU_BUTTON_HEIGHT)
234 end_poly_but.rect.move_ip(MENU_LEFT, y) 235 end_poly_but.rect.move_ip(MENU_LEFT, y)
235 self.add(end_poly_but) 236 self.add(end_poly_but)
236 y += MENU_BUTTON_HEIGHT + MENU_PAD 237 y += MENU_BUTTON_HEIGHT + MENU_PAD
237 238
238 fill_but = Button('Fill exterior', action=self.level_widget.set_filled) 239 fill_but = Button('Fill exterior', action=self.level_widget.set_filled)
239 fill_but.rect = pygame.rect.Rect(0, 0, MENU_WIDTH, MENU_BUTTON_HEIGHT) 240 fill_but.rect = button_rect.copy()
240 fill_but.rect.move_ip(MENU_LEFT, y) 241 fill_but.rect.move_ip(MENU_LEFT, y)
241 self.add(fill_but) 242 self.add(fill_but)
242 y += MENU_BUTTON_HEIGHT + MENU_PAD 243 y += MENU_BUTTON_HEIGHT + MENU_PAD
243 244
244 save_but = Button('Save Level', action=self.save) 245 save_but = Button('Save Level', action=self.save)
245 save_but.rect = pygame.rect.Rect(0, 0, MENU_WIDTH, MENU_BUTTON_HEIGHT) 246 save_but.rect = button_rect.copy()
246 save_but.rect.move_ip(MENU_LEFT, y) 247 save_but.rect.move_ip(MENU_LEFT, y)
247 self.add(save_but) 248 self.add(save_but)
248 y += MENU_BUTTON_HEIGHT + MENU_PAD 249 y += MENU_BUTTON_HEIGHT + MENU_PAD
249 250
250 quit_but = Button('Quit', action=self.quit) 251 quit_but = Button('Quit', action=self.quit)
251 quit_but.rect = pygame.rect.Rect(0, 0, MENU_WIDTH, MENU_BUTTON_HEIGHT) 252 quit_but.rect = button_rect.copy()
252 quit_but.rect.move_ip(MENU_LEFT, y) 253 quit_but.rect.move_ip(MENU_LEFT, y)
253 self.add(quit_but) 254 self.add(quit_but)
254 255
255 def key_down(self, ev): 256 def key_down(self, ev):
256 if ev.key == pgl.K_ESCAPE: 257 if ev.key == pgl.K_ESCAPE: