Mercurial > rinkhals
changeset 492:e8430f93b23a
toggling select/move can now be initiated from no selected tool and in any toolbar where select/move is allowed
author | Adrianna Pińska <adrianna.pinska@gmail.com> |
---|---|
date | Wed, 25 Nov 2009 22:15:29 +0000 |
parents | 75ef6ea3b7a6 |
children | ee883d390ff0 |
files | gamelib/gameboard.py gamelib/toolbar.py |
diffstat | 2 files changed, 17 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/gamelib/gameboard.py Wed Nov 25 22:12:08 2009 +0000 +++ b/gamelib/gameboard.py Wed Nov 25 22:15:29 2009 +0000 @@ -265,14 +265,15 @@ if not self.day: return if e.button == 3: # Right button - if self.selected_tool == constants.TOOL_PLACE_ANIMALS: - self.set_selected_tool(constants.TOOL_SELECT_CHICKENS, cursors.cursors["select"]) - if self.toolbar.IS_DEFAULT: - self.toolbar.toggle_select_on() - elif self.selected_tool == constants.TOOL_SELECT_CHICKENS: - self.set_selected_tool(constants.TOOL_PLACE_ANIMALS, cursors.cursors["chicken"]) - if self.toolbar.IS_DEFAULT: - self.toolbar.toggle_move_on() + if self.toolbar.MOVE_SELECT_PERMITTED: + if self.selected_tool != constants.TOOL_SELECT_CHICKENS: + self.set_selected_tool(constants.TOOL_SELECT_CHICKENS, cursors.cursors["select"]) + if self.toolbar.IS_DEFAULT: + self.toolbar.toggle_select_on() + elif self.selected_tool == constants.TOOL_SELECT_CHICKENS: + self.set_selected_tool(constants.TOOL_PLACE_ANIMALS, cursors.cursors["chicken"]) + if self.toolbar.IS_DEFAULT: + self.toolbar.toggle_move_on() return elif e.button == 2: # Middle button self.reset_states()
--- a/gamelib/toolbar.py Wed Nov 25 22:12:08 2009 +0000 +++ b/gamelib/toolbar.py Wed Nov 25 22:15:29 2009 +0000 @@ -62,6 +62,7 @@ class BaseToolBar(gui.Table): IS_DEFAULT = False + MOVE_SELECT_PERMITTED = False def __init__(self, gameboard, **params): gui.Table.__init__(self, **params) @@ -232,6 +233,7 @@ class DefaultToolBar(BaseToolBar): IS_DEFAULT = True + MOVE_SELECT_PERMITTED = True def __init__(self, gameboard, **params): BaseToolBar.__init__(self, gameboard, **params) @@ -339,6 +341,9 @@ width=self.style.width)) class EquipmentToolBar(BaseToolBar): + + MOVE_SELECT_PERMITTED = True + def __init__(self, gameboard, **params): BaseToolBar.__init__(self, gameboard, **params) self.group = gui.Group(name='equipment_toolbar', value=None) @@ -383,6 +388,9 @@ width=self.style.width)) class WoodToolBar(BaseToolBar): + + MOVE_SELECT_PERMITTED = True + def __init__(self, gameboard, **params): BaseToolBar.__init__(self, gameboard, **params) self.group = gui.Group(name='wood_toolbar', value=None)