Mercurial > rinkhals
comparison gamelib/gameboard.py @ 521:787eb032bf8a
Cursor hint for Ctrl-click move
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Fri, 27 Nov 2009 14:08:28 +0000 |
parents | f84ad10a9625 |
children | 6f41a565e910 |
comparison
equal
deleted
inserted
replaced
520:3e19a7f5333e | 521:787eb032bf8a |
---|---|
1 import random | 1 import random |
2 | 2 |
3 import pygame | 3 import pygame |
4 from pygame.locals import MOUSEBUTTONDOWN, MOUSEMOTION, KEYDOWN, K_UP, K_DOWN, \ | 4 from pygame.locals import MOUSEBUTTONDOWN, MOUSEMOTION, KEYDOWN, K_UP, K_DOWN, \ |
5 K_LEFT, K_RIGHT, KMOD_SHIFT, K_0, K_1, K_2, K_3, K_4, K_5, K_6, K_7, \ | 5 K_LEFT, K_RIGHT, KMOD_SHIFT, K_0, K_1, K_2, K_3, K_4, K_5, K_6, K_7, \ |
6 K_8, K_9, KMOD_CTRL | 6 K_8, K_9, KMOD_CTRL, KEYUP |
7 from pgu import gui | 7 from pgu import gui |
8 | 8 |
9 import tiles | 9 import tiles |
10 import icons | 10 import icons |
11 import constants | 11 import constants |
803 if mods & KMOD_CTRL: | 803 if mods & KMOD_CTRL: |
804 # store current selection | 804 # store current selection |
805 self.stored_selections[e.key] = self.selected_chickens[:] | 805 self.stored_selections[e.key] = self.selected_chickens[:] |
806 else: | 806 else: |
807 self.restore_selection(self.stored_selections.get(e.key, [])) | 807 self.restore_selection(self.stored_selections.get(e.key, [])) |
808 elif e.type == KEYDOWN: | |
809 mods = pygame.key.get_mods() | |
810 if mods & KMOD_CTRL and self.selected_tool == constants.TOOL_SELECT_CHICKENS and self.selected_chickens: | |
811 pygame.mouse.set_cursor(*cursors.cursors['chicken']) | |
812 elif e.type == KEYUP: | |
813 mods = pygame.key.get_mods() | |
814 if not (mods & KMOD_CTRL) and self.selected_tool == constants.TOOL_SELECT_CHICKENS: | |
815 pygame.mouse.set_cursor(*cursors.cursors['select']) | |
808 return False | 816 return False |
809 | 817 |
810 def restore_selection(self, selection): | 818 def restore_selection(self, selection): |
811 self.unselect_all() | 819 self.unselect_all() |
812 for chick in selection[:]: | 820 for chick in selection[:]: |