Mercurial > boomslang
comparison pyntnclick/tools/rect_drawer.py @ 664:d1c1253fcd77 pyntnclick
Now with somewhat fewer crashy bits
author | Neil Muller <neil@dip.sun.ac.za> |
---|---|
date | Sun, 12 Feb 2012 16:53:40 +0200 |
parents | b67fdd4a152d |
children | b27b5c6c54e8 |
comparison
equal
deleted
inserted
replaced
663:b67fdd4a152d | 664:d1c1253fcd77 |
---|---|
180 print ' Object %s and %s' % (num, num2) | 180 print ' Object %s and %s' % (num, num2) |
181 print " Rects", my_rect, other_rect | 181 print " Rects", my_rect, other_rect |
182 print | 182 print |
183 print | 183 print |
184 | 184 |
185 def toggle_things(self): | 185 def toggle_things(self, ev, widget): |
186 self.draw_things = not self.draw_things | 186 self.draw_things = not self.draw_things |
187 | 187 |
188 def toggle_thing_rects(self): | 188 def toggle_thing_rects(self, ev, widget): |
189 self.draw_thing_rects = not self.draw_thing_rects | 189 self.draw_thing_rects = not self.draw_thing_rects |
190 scene = self._get_scene() | 190 scene = self._get_scene() |
191 for thing in scene.things.itervalues(): | 191 for thing in scene.things.itervalues(): |
192 if not self.draw_thing_rects: | 192 if not self.draw_thing_rects: |
193 if not hasattr(thing, 'old_colour'): | 193 if not hasattr(thing, 'old_colour'): |
194 thing.old_colour = thing._interact_hilight_color | 194 thing.old_colour = thing._interact_hilight_color |
195 thing._interact_hilight_color = None | 195 thing._interact_hilight_color = None |
196 else: | 196 else: |
197 thing._interact_hilight_color = thing.old_colour | 197 thing._interact_hilight_color = thing.old_colour |
198 | 198 |
199 def toggle_images(self): | 199 def toggle_images(self, ev, widget): |
200 self.draw_images = not self.draw_images | 200 self.draw_images = not self.draw_images |
201 | 201 |
202 def toggle_trans_images(self): | 202 def toggle_trans_images(self, ev, widget): |
203 self.trans_images = not self.trans_images | 203 self.trans_images = not self.trans_images |
204 self.invalidate() | 204 self.invalidate() |
205 | 205 |
206 def toggle_rects(self): | 206 def toggle_rects(self, ev, widget): |
207 self.draw_rects = not self.draw_rects | 207 self.draw_rects = not self.draw_rects |
208 | 208 |
209 def toggle_toolbar(self): | 209 def toggle_toolbar(self, ev, widget): |
210 self.draw_toolbar = not self.draw_toolbar | 210 self.draw_toolbar = not self.draw_toolbar |
211 | 211 |
212 def toggle_zoom(self): | 212 def toggle_zoom(self, ev, widget): |
213 self.zoom_display = not self.zoom_display | 213 self.zoom_display = not self.zoom_display |
214 | 214 |
215 def toggle_anim(self): | 215 def toggle_anim(self, ev, widget): |
216 self.draw_anim = not self.draw_anim | 216 self.draw_anim = not self.draw_anim |
217 | 217 |
218 def draw_mode(self): | 218 def draw_mode(self, ev, widget): |
219 self.mode = 'draw' | 219 self.mode = 'draw' |
220 | 220 |
221 def del_mode(self): | 221 def del_mode(self, ev, widget): |
222 self.mode = 'del' | 222 self.mode = 'del' |
223 self.start_pos = None | 223 self.start_pos = None |
224 self.end_pos = None | 224 self.end_pos = None |
225 | 225 |
226 def draw_sub_image(self, image, surface, cropped_rect): | 226 def draw_sub_image(self, image, surface, cropped_rect): |
343 .move(constants.screen[0] + constants.menu_width, | 343 .move(constants.screen[0] + constants.menu_width, |
344 constants.screen[1]) | 344 constants.screen[1]) |
345 except pygame.error, e: | 345 except pygame.error, e: |
346 print 'Unable to load image %s' % e | 346 print 'Unable to load image %s' % e |
347 | 347 |
348 def image_mode(self): | 348 def image_mode(self, ev, widget): |
349 self.mode = 'image' | 349 self.mode = 'image' |
350 self.start_pos = None | 350 self.start_pos = None |
351 self.end_pos = None | 351 self.end_pos = None |
352 # So we do the right thing for off screen images | 352 # So we do the right thing for off screen images |
353 self.old_mouse_pos = None | 353 self.old_mouse_pos = None |
354 | 354 |
355 def cycle_mode(self): | 355 def cycle_mode(self, ev, widget): |
356 self.mode = 'cycle' | 356 self.mode = 'cycle' |
357 | 357 |
358 def _conv_pos(self, mouse_pos): | 358 def _conv_pos(self, mouse_pos): |
359 if self.zoom_display: | 359 if self.zoom_display: |
360 pos = ((mouse_pos[0] + self.zoom_offset[0]) / constants.zoom, | 360 pos = ((mouse_pos[0] + self.zoom_offset[0]) / constants.zoom, |
426 self._move_zoom(0, -1) | 426 self._move_zoom(0, -1) |
427 elif e.key == K_DOWN: | 427 elif e.key == K_DOWN: |
428 self._move_zoom(0, 1) | 428 self._move_zoom(0, 1) |
429 | 429 |
430 if e.key == K_o: | 430 if e.key == K_o: |
431 self.toggle_trans_images() | 431 self.toggle_trans_images(None, None) |
432 elif e.key == K_t: | 432 elif e.key == K_t: |
433 self.toggle_things() | 433 self.toggle_things(None, None) |
434 elif e.key == K_r: | 434 elif e.key == K_r: |
435 self.toggle_thing_rects() | 435 self.toggle_thing_rects(None, None) |
436 elif e.key == K_i: | 436 elif e.key == K_i: |
437 self.toggle_images() | 437 self.toggle_images(None, None) |
438 elif e.key == K_d: | 438 elif e.key == K_d: |
439 self.toggle_rects() | 439 self.toggle_rects(None, None) |
440 elif e.key == K_b: | 440 elif e.key == K_b: |
441 self.toggle_toolbar() | 441 self.toggle_toolbar(None, None) |
442 elif e.key == K_z: | 442 elif e.key == K_z: |
443 self.toggle_zoom() | 443 self.toggle_zoom(None, None) |
444 elif e.key == K_a: | 444 elif e.key == K_a: |
445 self.toggle_anim() | 445 self.toggle_anim(None, None) |
446 | 446 |
447 def mouse_down(self, e): | 447 def mouse_down(self, e): |
448 pos = self._conv_pos(e.pos) | 448 pos = self._conv_pos(e.pos) |
449 if self.mode == 'del': | 449 if self.mode == 'del': |
450 cand = None | 450 cand = None |