comparison tools/rect_drawer.py @ 275:d78ce15bccc8

Crew quarters background and toolbar on the rect tool.
author Jeremy Thurgood <firxen@gmail.com>
date Fri, 27 Aug 2010 21:57:13 +0200
parents e4ea9def56b2
children 75f4ee46ac58
comparison
equal deleted inserted replaced
274:8f7936e5d615 275:d78ce15bccc8
87 self.add(self.close_button) 87 self.add(self.close_button)
88 88
89 self.draw_rects = True 89 self.draw_rects = True
90 self.draw_things = True 90 self.draw_things = True
91 self.draw_images = True 91 self.draw_images = True
92 self.draw_toolbar = True
92 93
93 def toggle_things(self): 94 def toggle_things(self):
94 self.draw_things = not self.draw_things 95 self.draw_things = not self.draw_things
95 96
96 def toggle_images(self): 97 def toggle_images(self):
97 self.draw_images = not self.draw_images 98 self.draw_images = not self.draw_images
98 99
99 def toggle_rects(self): 100 def toggle_rects(self):
100 self.draw_rects = not self.draw_rects 101 self.draw_rects = not self.draw_rects
102
103 def toggle_toolbar(self):
104 self.draw_toolbar = not self.draw_toolbar
101 105
102 106
103 def draw_mode(self): 107 def draw_mode(self):
104 self.mode = 'draw' 108 self.mode = 'draw'
105 109
138 if self.current_image and self.mode == 'image': 142 if self.current_image and self.mode == 'image':
139 if self.current_image.rect.colliderect(surface.get_rect()): 143 if self.current_image.rect.colliderect(surface.get_rect()):
140 cropped_rect = self.current_image.rect.clip(surface.get_rect()) 144 cropped_rect = self.current_image.rect.clip(surface.get_rect())
141 sub = surface.subsurface(cropped_rect) 145 sub = surface.subsurface(cropped_rect)
142 self.current_image.draw(sub) 146 self.current_image.draw(sub)
147 if self.draw_toolbar:
148 toolbar_rect = pygame.rect.Rect(0, 550, 800, 50)
149 tb_surf = surface.subsurface(0, 550, 800, 50).convert_alpha()
150 tb_surf.fill(Color(127, 0, 0, 127))
151 surface.blit(tb_surf)
152 frame_rect(surface, (127, 0, 0), toolbar_rect, 5)
143 153
144 def _make_dict(self): 154 def _make_dict(self):
145 d = {} 155 d = {}
146 for col, rect in self.rects: 156 for col, rect in self.rects:
147 col = (col.r, col.g, col.b) 157 col = (col.r, col.g, col.b)
291 app.add(toggle_things) 301 app.add(toggle_things)
292 toggle_images = make_button("Toggle Images", image.toggle_images, 400) 302 toggle_images = make_button("Toggle Images", image.toggle_images, 400)
293 app.add(toggle_images) 303 app.add(toggle_images)
294 toggle_rects = make_button("Toggle Rects", image.toggle_rects, 440) 304 toggle_rects = make_button("Toggle Rects", image.toggle_rects, 440)
295 app.add(toggle_rects) 305 app.add(toggle_rects)
306 toggle_toolbar = make_button("Toggle Toolbar", image.toggle_toolbar, 480)
307 app.add(toggle_toolbar)
296 quit_but = make_button("Quit", app.quit, 560) 308 quit_but = make_button("Quit", app.quit, 560)
297 app.add(quit_but) 309 app.add(quit_but)
298 app.run() 310 app.run()