annotate clients/editor/scripts/events/events.py @ 367:598547404022

* Initial support for closing maps: * Lots of cleanup functions has been added * TODO: Cameras are only removed when all maps are closed * TODO: Screen leaves traces when the last map is closed * Replaced pre/postMapRemove events with pre/postMapClosed * Fixed a bug in the Toolbar where it didn't properly handle removal of actions from an actiongroup
author cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
date Thu, 29 Oct 2009 22:11:48 +0000
parents ad5818097cd6
children 22222a900751
rev   line source
355
8b125ec749d7 Started cleaning up the editor source code:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 325
diff changeset
1 # -*- coding: utf-8 -*-
8b125ec749d7 Started cleaning up the editor source code:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 325
diff changeset
2
8b125ec749d7 Started cleaning up the editor source code:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 325
diff changeset
3 # ####################################################################
8b125ec749d7 Started cleaning up the editor source code:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 325
diff changeset
4 # Copyright (C) 2005-2009 by the FIFE team
8b125ec749d7 Started cleaning up the editor source code:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 325
diff changeset
5 # http://www.fifengine.de
8b125ec749d7 Started cleaning up the editor source code:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 325
diff changeset
6 # This file is part of FIFE.
8b125ec749d7 Started cleaning up the editor source code:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 325
diff changeset
7 #
8b125ec749d7 Started cleaning up the editor source code:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 325
diff changeset
8 # FIFE is free software; you can redistribute it and/or
8b125ec749d7 Started cleaning up the editor source code:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 325
diff changeset
9 # modify it under the terms of the GNU Lesser General Public
8b125ec749d7 Started cleaning up the editor source code:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 325
diff changeset
10 # License as published by the Free Software Foundation; either
8b125ec749d7 Started cleaning up the editor source code:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 325
diff changeset
11 # version 2.1 of the License, or (at your option) any later version.
8b125ec749d7 Started cleaning up the editor source code:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 325
diff changeset
12 #
8b125ec749d7 Started cleaning up the editor source code:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 325
diff changeset
13 # This library is distributed in the hope that it will be useful,
8b125ec749d7 Started cleaning up the editor source code:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 325
diff changeset
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8b125ec749d7 Started cleaning up the editor source code:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 325
diff changeset
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8b125ec749d7 Started cleaning up the editor source code:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 325
diff changeset
16 # Lesser General Public License for more details.
8b125ec749d7 Started cleaning up the editor source code:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 325
diff changeset
17 #
8b125ec749d7 Started cleaning up the editor source code:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 325
diff changeset
18 # You should have received a copy of the GNU Lesser General Public
8b125ec749d7 Started cleaning up the editor source code:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 325
diff changeset
19 # License along with this library; if not, write to the
8b125ec749d7 Started cleaning up the editor source code:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 325
diff changeset
20 # Free Software Foundation, Inc.,
8b125ec749d7 Started cleaning up the editor source code:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 325
diff changeset
21 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
8b125ec749d7 Started cleaning up the editor source code:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 325
diff changeset
22 # ####################################################################
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
23 import fife, scripts
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
24 from fife import IKeyListener, ICommandListener, IMouseListener, LayerChangeListener, MapChangeListener, ConsoleExecuter
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
25 from signal import Signal
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
26 import pdb
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
27
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
28 #--- Signals ---#
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
29 onPump = Signal()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
30 preSave = Signal(providing_args=["mapview"])
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
31 postSave = Signal(providing_args=["mapview"])
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
32 mapAdded = Signal(providing_args=["mapview"])
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
33 preMapShown = Signal(providing_args=["mapview"])
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
34 postMapShown = Signal(providing_args=["mapview"])
367
598547404022 * Initial support for closing maps:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 359
diff changeset
35 preMapClosed = Signal(providing_args=["mapview"])
598547404022 * Initial support for closing maps:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 359
diff changeset
36 postMapClosed = Signal(providing_args=["mapview"])
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
37 onInstancesSelected = Signal(providing_args=["instances"])
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
38 onObjectSelected = Signal(providing_args=["object"])
325
54de5aebf732 * ObjectSelector will now select and scroll to selected object automatically
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 324
diff changeset
39 onObjectsImported = Signal(providing_args=[])
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
40
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
41 # Signals emitted by EventListener
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
42 onQuit = Signal(providing_args=[])
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
43 keyPressed = Signal(providing_args=["event"])
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
44 keyReleased = Signal(providing_args=["event"])
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
45 mouseEntered = Signal(providing_args=["event"])
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
46 mouseExited = Signal(providing_args=["event"])
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
47 mousePressed = Signal(providing_args=["event"])
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
48 mouseReleased = Signal(providing_args=["event"])
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
49 mouseClicked = Signal(providing_args=["event"])
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
50 mouseWheelMovedUp = Signal(providing_args=["event"])
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
51 mouseWheelMovedDown = Signal(providing_args=["event"])
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
52 mouseMoved = Signal(providing_args=["event"])
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
53 mouseDragged = Signal(providing_args=["event"])
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
54 onLayerChanged = Signal(providing_args=["layer", "changedInstances"])
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
55 onInstanceCreate = Signal(providing_args=["layer", "instance"])
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
56 onInstanceDelete = Signal(providing_args=["layer", "instance"])
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
57 onMapChanged = Signal(providing_args=["map", "changedLayers"])
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
58 onLayerCreate = Signal(providing_args=["map", "layer"])
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
59 onLayerDelete = Signal(providing_args=["map", "layer"])
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
60 onToolsClick = Signal(providing_args=[])
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
61 onCommand = Signal(providing_args=["command"])
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
62 onConsoleCommand= Signal(providing_args=["command"])
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
63
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
64 class KeySequence(object):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
65 def __init__(self):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
66 self.key = None
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
67 self.modifiers = {"alt":False,"ctrl":False,"shift":False,"meta":False}
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
68 self.signal = None
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
69
324
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
70 class EventListener:
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
71 # NOTE: As FIFEdit currently covers the entire screen with widgets,
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
72 # FIFE doesn't receive any mouse or key events. Therefore we have to add
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
73 # mouse and key event tracking for the central widget
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
74
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
75 def __init__(self, engine):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
76 self.engine = engine
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
77
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
78 eventmanager = self.engine.getEventManager()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
79 self.keysequences = []
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
80
324
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
81 self.keylistener = _IKeyListener(engine)
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
82 self.mouselistener = _IMouseListener(engine)
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
83 self.mapchangelistener = _MapChangeListener(engine)
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
84 self.layerchangelistener = _LayerChangeListener(engine)
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
85 self.commandlistener = _ICommandListener(engine)
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
86 self.consoleexecuter = _ConsoleExecuter(engine)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
87
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
88 self.controlPressed = False
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
89 self.altPressed = False
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
90 self.shiftPressed = False
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
91 self.metaPressed = False
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
92
324
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
93 eventmanager.addKeyListener(self.keylistener)
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
94 eventmanager.addCommandListener(self.commandlistener)
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
95 eventmanager.addMouseListener(self.mouselistener)
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
96 self.engine.getGuiManager().getConsole().setConsoleExecuter(self.consoleexecuter)
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
97
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
98 keyPressed.connect(self.keyPressed)
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
99 keyReleased.connect(self.keyReleased)
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
100
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
101
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
102 def getKeySequenceSignal(self, key, modifiers=[]):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
103 # Parse modifiers
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
104 mods = {"alt":False,"ctrl":False,"shift":False,"meta":False}
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
105 for m in modifiers:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
106 m = m.lower()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
107 if m in mods:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
108 mods[m] = True
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
109 else:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
110 print "Unknown modifier:",m
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
111
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
112 # Check if signal for keysequence has been created
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
113 for k in self.keysequences:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
114 if k.key == key and k.modifiers == mods:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
115 return k.signal
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
116
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
117 # Create keysequence and signal
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
118 keysequence = KeySequence()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
119 keysequence.key = key
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
120 keysequence.modifiers = mods
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
121 keysequence.signal = Signal(providing_args=["event"])
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
122 self.keysequences.append(keysequence)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
123
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
124 return keysequence.signal
324
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
125
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
126 # IKeyListener
324
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
127 def keyPressed(self, event):
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
128 keyval = event.getKey().getValue()
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
129 keystr = event.getKey().getAsString().lower()
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
130
324
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
131 self.controlPressed = event.isControlPressed()
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
132 self.altPressed = event.isAltPressed()
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
133 self.shiftPressed = event.isShiftPressed()
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
134 self.metaPressed = event.isMetaPressed()
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
135
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
136 if keyval in (fife.Key.LEFT_CONTROL, fife.Key.RIGHT_CONTROL):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
137 self.controlPressed = True
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
138 elif keyval in (fife.Key.LEFT_SHIFT, fife.Key.RIGHT_SHIFT):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
139 self.shiftPressed = True
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
140 elif keyval in (fife.Key.LEFT_ALT, fife.Key.RIGHT_ALT):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
141 self.altPressed = True
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
142 elif keyval in (fife.Key.RIGHT_META, fife.Key.LEFT_META):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
143 self.metaPressed = True
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
144
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
145 elif keyval == fife.Key.ESCAPE:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
146 scripts.editor.getEditor().quit()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
147 elif keyval == fife.Key.F10:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
148 self.engine.getGuiManager().getConsole().toggleShowHide()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
149 elif keystr == "d":
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
150 pdb.set_trace()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
151
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
152 # Check keysequences
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
153 for k in self.keysequences:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
154 if k.modifiers["alt"] != self.altPressed: continue
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
155 if k.modifiers["ctrl"] != self.controlPressed: continue
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
156 if k.modifiers["shift"] != self.shiftPressed: continue
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
157 if k.modifiers["meta"] != self.metaPressed: continue
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
158 if keyval != k.key: continue
324
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
159 k.signal.send(sender=self, event=event)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
160
324
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
161 def keyReleased(self, event):
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
162 keyval = event.getKey().getValue()
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
163
324
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
164 self.controlPressed = event.isControlPressed()
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
165 self.altPressed = event.isAltPressed()
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
166 self.shiftPressed = event.isShiftPressed()
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
167 self.metaPressed = event.isMetaPressed()
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
168
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
169 if keyval in (fife.Key.LEFT_CONTROL, fife.Key.RIGHT_CONTROL):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
170 self.controlPressed = False
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
171 elif keyval in (fife.Key.LEFT_SHIFT, fife.Key.RIGHT_SHIFT):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
172 self.shiftPressed = False
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
173 elif keyval in (fife.Key.LEFT_ALT, fife.Key.RIGHT_ALT):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
174 self.altPressed = False
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
175 elif keyval in (fife.Key.RIGHT_META, fife.Key.LEFT_META):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
176 self.metaPressed = False
324
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
177
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
178
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
179 #--- Internal sublistener classes ---#
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
180 class _IKeyListener(IKeyListener):
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
181 def __init__(self, engine):
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
182 IKeyListener.__init__(self)
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
183 self.engine = engine
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
184
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
185 # IKeyListener
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
186 def keyPressed(self, evt):
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
187 keyPressed.send(sender=self.engine, event=evt)
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
188
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
189 def keyReleased(self, evt):
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
190 keyReleased.send(sender=self.engine, event=evt)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
191
324
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
192 class _ICommandListener(ICommandListener):
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
193 def __init__(self, engine):
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
194 ICommandListener.__init__(self)
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
195 self.engine = engine
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
196
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
197 # ICommandListener
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
198 def onCommand(self, command):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
199 if command.getCommandType() == fife.CMD_QUIT_GAME:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
200 scripts.editor.getEditor().quit()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
201 else:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
202 onCommand.send(sender=self.engine, command=command)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
203
324
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
204 class _IMouseListener(IMouseListener):
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
205 def __init__(self, engine):
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
206 IMouseListener.__init__(self)
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
207 self.engine = engine
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
208
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
209 # IMouseListener
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
210 def mouseEntered(self, evt):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
211 mouseEntered.send(sender=self.engine, event=evt)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
212
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
213 def mouseExited(self, evt):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
214 mouseExited.send(sender=self.engine, event=evt)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
215
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
216 def mousePressed(self, evt):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
217 mousePressed.send(sender=self.engine, event=evt)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
218
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
219 def mouseReleased(self, evt):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
220 mouseReleased.send(sender=self.engine, event=evt)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
221
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
222 def mouseClicked(self, evt):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
223 mouseClicked.send(sender=self.engine, event=evt)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
224
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
225 def mouseWheelMovedUp(self, evt):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
226 mouseWheelMovedUp.send(sender=self.engine, event=evt)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
227
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
228 def mouseWheelMovedDown(self, evt):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
229 mouseWheelMovedDown.send(sender=self.engine, event=evt)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
230
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
231 def mouseMoved(self, evt):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
232 mouseMoved.send(sender=self.engine, event=evt)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
233
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
234 def mouseDragged(self, evt):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
235 mouseDragged.send(sender=self.engine, event=evt)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
236
324
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
237 class _MapChangeListener(MapChangeListener):
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
238 def __init__(self, engine):
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
239 MapChangeListener.__init__(self)
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
240 self.engine = engine
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
241
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
242 # MapChangeListener
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
243 def onMapChanged(self, map, changedLayers):
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
244 onMapChanged.send(sender=self.engine, map=map, changedLayers=changedLayers)
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
245
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
246 def onLayerCreate(self, map, layer):
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
247 onLayerCreate.send(sender=self.engine, map=map, layer=layer)
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
248
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
249 def onLayerDelete(self, map, layer):
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
250 onLayerDelete.send(sender=self.engine, map=map, layer=layer)
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
251
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
252 class _LayerChangeListener(LayerChangeListener):
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
253 def __init__(self, engine):
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
254 LayerChangeListener.__init__(self)
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
255 self.engine = engine
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
256
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
257 # LayerChangeListener
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
258 def onLayerChanged(self, layer, changedInstances):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
259 onLayerChanged.send(sender=self.engine, layer=layer, changedInstances=changedInstances)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
260
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
261 def onInstanceCreate(self, layer, instance):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
262 onInstanceCreate.send(sender=self.engine, layer=layer, instance=instance)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
263
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
264 def onInstanceDelete(self, layer, instance):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
265 onInstanceDelete.send(sender=self.engine, layer=layer, instance=instance)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
266
324
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
267 class _ConsoleExecuter(ConsoleExecuter):
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
268 def __init__(self, engine):
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
269 ConsoleExecuter.__init__(self)
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
270 self.engine = engine
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
271
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
272 # ConsoleExecuter
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
273 def onToolsClick(self):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
274 onToolsClick.send(sender=self.engine)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
275
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
276 def onConsoleCommand(self, command):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
277 onConsoleCommand.send(sender=self.engine, command=command)
324
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
278
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
279