Changeset 4407 in orxonox.OLD for orxonox/trunk/src/util/event
- Timestamp:
- May 31, 2005, 12:04:15 AM (20 years ago)
- Location:
- orxonox/trunk/src/util/event
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/util/event/event_handler.cc
r4406 r4407 47 47 } 48 48 } 49 } 49 this->state = ES_GAME; 50 } 51 50 52 51 53 /** … … 53 55 */ 54 56 EventHandler* EventHandler::singletonRef = NULL; 57 55 58 56 59 /** … … 64 67 } 65 68 69 66 70 /** 67 71 \brief standard deconstructor … … 71 75 { 72 76 EventHandler::singletonRef = NULL; 77 delete this->keyMapper; 78 } 79 80 81 82 void EventHandler::init() 83 { 84 this->keyMapper = new KeyMapper(); 85 this->keyMapper->loadKeyBindings(); 73 86 } 74 87 … … 80 93 } 81 94 95 82 96 void EventHandler::subscribe(EventListener* el, elState state, int eventType) 83 97 { 84 98 PRINTF(0)("Subscribing event type: %i\n", eventType); 85 if( likely(this->listeners[state][eventType] == NULL)) 86 this->listeners[state][eventType] = el; 87 else 88 PRINTF(0)("Someone tried to subscribe to event %i @ state %i but this event has already been subscribed\n", eventType, state); 99 if( state == ES_ALL ) 100 { 101 for(int i = 0; i < ES_NUMBER; ++i) 102 if( likely(this->listeners[state][eventType] == NULL)) 103 this->listeners[i][eventType] = el; 104 else 105 PRINTF(0)("Someone tried to subscribe to event %i @ state %i but this event has already been subscribed\n", eventType, state); 106 } 107 else 108 if( likely(this->listeners[state][eventType] == NULL)) 109 { 110 this->listeners[state][eventType] = el; 111 } 112 else 113 PRINTF(0)("Someone tried to subscribe to event %i @ state %i but this event has already been subscribed\n", eventType, state); 89 114 } 90 115 … … 123 148 SDL_Event event; 124 149 Event ev; 125 EventListener* listener ;150 EventListener* listener = NULL; 126 151 while( SDL_PollEvent (&event)) 127 152 { … … 178 203 /* small debug routine: shows alle events dispatched by the event handler */ 179 204 PRINT(0)("\n==========================| EventHandler::process () |===\n"); 180 PRINT(0)("= Got Event nr %i\n, for state %i", event.type, this->state);205 PRINT(0)("= Got Event nr %i, for state %i", ev.type, this->state); 181 206 182 listener = this->listeners[this->state][ev ent.key.keysym.sym];207 listener = this->listeners[this->state][ev.type]; 183 208 if( listener != NULL) 184 209 { 210 PRINTF(0)("= Event dispatcher msg: This event has been consumed\n"); 185 211 listener->process(ev); 186 PRINTF(0)("= Event dispatcher msg: This event has been consumed\n");187 212 } 188 213 else -
orxonox/trunk/src/util/event/event_handler.h
r4405 r4407 22 22 virtual ~EventHandler(void); 23 23 24 void init(); 25 24 26 void setState(elState state); 25 27 … … 41 43 EventListener*** listeners; //!< a list of registered listeners 42 44 elState state; 43 45 KeyMapper* keyMapper; 44 46 }; 45 47
Note: See TracChangeset
for help on using the changeset viewer.