Mercurial > fife-parpg
comparison engine/core/eventchannel/eventmanager.h @ 428:a1884665aa95
Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Mon, 22 Feb 2010 21:23:01 +0000 |
parents | bb9902910067 |
children | b312d170ab0c |
comparison
equal
deleted
inserted
replaced
427:68aa65e5bd9c | 428:a1884665aa95 |
---|---|
22 #ifndef FIFE_EVENTCHANNEL_EVENTMANAGER_H | 22 #ifndef FIFE_EVENTCHANNEL_EVENTMANAGER_H |
23 #define FIFE_EVENTCHANNEL_EVENTMANAGER_H | 23 #define FIFE_EVENTCHANNEL_EVENTMANAGER_H |
24 | 24 |
25 // Standard C++ library includes | 25 // Standard C++ library includes |
26 // | 26 // |
27 #include <vector> | 27 #include <deque> |
28 #include <map> | 28 #include <map> |
29 #include <list> | 29 #include <list> |
30 | 30 |
31 // 3rd party library includes | 31 // 3rd party library includes |
32 // | 32 // |
62 class KeyEvent; | 62 class KeyEvent; |
63 class IKeyFilter; | 63 class IKeyFilter; |
64 | 64 |
65 /** Event Manager manages all events related to FIFE | 65 /** Event Manager manages all events related to FIFE |
66 */ | 66 */ |
67 class EventManager: | 67 class EventManager: |
68 public ICommandController, | 68 public ICommandController, |
69 public IKeyController, | 69 public IKeyController, |
70 public IMouseController, | 70 public IMouseController, |
71 public ISdlEventController, | 71 public ISdlEventController, |
72 public IEventSource, | 72 public IEventSource, |
73 public ITriggerController { | 73 public ITriggerController { |
74 public: | 74 public: |
75 /** Constructor. | 75 /** Constructor. |
76 */ | 76 */ |
79 /** Destructor | 79 /** Destructor |
80 */ | 80 */ |
81 virtual ~EventManager(); | 81 virtual ~EventManager(); |
82 | 82 |
83 void addCommandListener(ICommandListener* listener); | 83 void addCommandListener(ICommandListener* listener); |
84 void addCommandListenerFront(ICommandListener* listener); | |
84 void removeCommandListener(ICommandListener* listener); | 85 void removeCommandListener(ICommandListener* listener); |
85 void dispatchCommand(Command& command); | 86 void dispatchCommand(Command& command); |
86 void addKeyListener(IKeyListener* listener); | 87 void addKeyListener(IKeyListener* listener); |
88 void addKeyListenerFront(IKeyListener* listener); | |
87 void removeKeyListener(IKeyListener* listener); | 89 void removeKeyListener(IKeyListener* listener); |
88 void addMouseListener(IMouseListener* listener); | 90 void addMouseListener(IMouseListener* listener); |
91 void addMouseListenerFront(IMouseListener* listener); | |
89 void removeMouseListener(IMouseListener* listener); | 92 void removeMouseListener(IMouseListener* listener); |
90 void addSdlEventListener(ISdlEventListener* listener); | 93 void addSdlEventListener(ISdlEventListener* listener); |
94 void addSdlEventListenerFront(ISdlEventListener* listener); | |
91 void removeSdlEventListener(ISdlEventListener* listener); | 95 void removeSdlEventListener(ISdlEventListener* listener); |
92 EventSourceType getEventSourceType(); | 96 EventSourceType getEventSourceType(); |
93 | 97 |
94 void registerTrigger(Trigger& trigger); | 98 void registerTrigger(Trigger& trigger); |
95 void unregisterTrigger(Trigger& trigger); | 99 void unregisterTrigger(Trigger& trigger); |
96 | 100 |
97 /** Process the SDL event queue. | 101 /** Process the SDL event queue. |
98 * This is to be called only by the engine itself once per frame. | 102 * This is to be called only by the engine itself once per frame. |
99 * It passes appropriate events to their listeners | 103 * It passes appropriate events to their listeners |
100 */ | 104 */ |
101 void processEvents(); | 105 void processEvents(); |
102 | 106 |
103 void setKeyFilter(IKeyFilter* keyFilter); | 107 void setKeyFilter(IKeyFilter* keyFilter); |
118 void fillModifiers(InputEvent& evt); | 122 void fillModifiers(InputEvent& evt); |
119 void fillKeyEvent(const SDL_Event& sdlevt, KeyEvent& keyevt); | 123 void fillKeyEvent(const SDL_Event& sdlevt, KeyEvent& keyevt); |
120 void fillMouseEvent(const SDL_Event& sdlevt, MouseEvent& mouseevt); | 124 void fillMouseEvent(const SDL_Event& sdlevt, MouseEvent& mouseevt); |
121 | 125 |
122 void pollTriggers(); | 126 void pollTriggers(); |
123 | |
124 std::vector<ICommandListener*> m_commandlisteners; | |
125 std::vector<ICommandListener*> m_pending_commandlisteners; | |
126 std::vector<ICommandListener*> m_pending_cldeletions; | |
127 | 127 |
128 std::vector<IKeyListener*> m_keylisteners; | 128 std::deque<ICommandListener*> m_commandlisteners; |
129 std::vector<IKeyListener*> m_pending_keylisteners; | 129 std::deque<ICommandListener*> m_pending_commandlisteners; |
130 std::vector<IKeyListener*> m_pending_kldeletions; | 130 std::deque<ICommandListener*> m_pending_commandlisteners_front; |
131 std::deque<ICommandListener*> m_pending_cldeletions; | |
131 | 132 |
132 std::vector<IMouseListener*> m_mouselisteners; | 133 std::deque<IKeyListener*> m_keylisteners; |
133 std::vector<IMouseListener*> m_pending_mouselisteners; | 134 std::deque<IKeyListener*> m_pending_keylisteners; |
134 std::vector<IMouseListener*> m_pending_mldeletions; | 135 std::deque<IKeyListener*> m_pending_keylisteners_front; |
136 std::deque<IKeyListener*> m_pending_kldeletions; | |
135 | 137 |
136 std::vector<ISdlEventListener*> m_sdleventlisteners; | 138 std::deque<IMouseListener*> m_mouselisteners; |
137 std::vector<ISdlEventListener*> m_pending_sdleventlisteners; | 139 std::deque<IMouseListener*> m_pending_mouselisteners; |
138 std::vector<ISdlEventListener*> m_pending_sdldeletions; | 140 std::deque<IMouseListener*> m_pending_mouselisteners_front; |
141 std::deque<IMouseListener*> m_pending_mldeletions; | |
142 | |
143 std::deque<ISdlEventListener*> m_sdleventlisteners; | |
144 std::deque<ISdlEventListener*> m_pending_sdleventlisteners; | |
145 std::deque<ISdlEventListener*> m_pending_sdleventlisteners_front; | |
146 std::deque<ISdlEventListener*> m_pending_sdldeletions; | |
139 | 147 |
140 std::map<int, bool> m_keystatemap; | 148 std::map<int, bool> m_keystatemap; |
141 IKeyFilter* m_keyfilter; | 149 IKeyFilter* m_keyfilter; |
142 int m_mousestate; | 150 int m_mousestate; |
143 MouseEvent::MouseButtonType m_mostrecentbtn; | 151 MouseEvent::MouseButtonType m_mostrecentbtn; |