Changeset 4866 in orxonox.OLD for orxonox/trunk/src/lib
- Timestamp:
- Jul 14, 2005, 10:38:21 PM (19 years ago)
- Location:
- orxonox/trunk/src/lib/event
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/event/event_handler.cc
r4838 r4866 63 63 EventHandler::~EventHandler () 64 64 { 65 EventHandler::singletonRef = NULL;66 delete this->keyMapper;67 68 65 for(int i = 0; i < ES_NUMBER; ++i) 69 66 { 70 for(int j = 0; j < SDLK_LAST; ++j)67 for(int j = 0; j < EV_NUMBER; ++j) 71 68 { 72 69 if( this->listeners[i][j] != NULL) … … 76 73 } 77 74 } 75 delete this->keyMapper; 76 EventHandler::singletonRef = NULL; 78 77 } 79 78 … … 84 83 this has to be called before the use of the event handler 85 84 */ 86 void EventHandler::init( )85 void EventHandler::init(IniParser* iniParser) 87 86 { 88 87 this->keyMapper = new KeyMapper(); 89 this->keyMapper->loadKeyBindings( );88 this->keyMapper->loadKeyBindings(iniParser); 90 89 } 91 90 -
orxonox/trunk/src/lib/event/event_handler.h
r4836 r4866 15 15 class EventListener; 16 16 template <class T> class tList; 17 class IniParser; 17 18 18 19 //! The one Event Handler from Orxonox … … 23 24 /** @returns a Pointer to the only object of this Class */ 24 25 inline static EventHandler* getInstance() { if (!singletonRef) singletonRef = new EventHandler(); return singletonRef; }; 25 void init( );26 void init(IniParser* iniParser); 26 27 27 28 void setState(elState state); -
orxonox/trunk/src/lib/event/event_listener.cc
r4836 r4866 37 37 { 38 38 /* unsubscribes itself from the event listener */ 39 EventHandler::getInstance()->unsubscribe(this );39 EventHandler::getInstance()->unsubscribe(this, ES_ALL); 40 40 } -
orxonox/trunk/src/lib/event/key_mapper.cc
r4864 r4866 115 115 void KeyMapper::loadKeyBindings (const char* fileName) 116 116 { 117 FILE* stream;118 119 PRINTF(4)("Loading key bindings from %s\n", fileName);120 121 // create parser122 117 IniParser parser(fileName); 123 if( parser.getSection (CONFIG_SECTION_PLAYER "1") == -1) 124 { 125 PRINTF(1)("Could not find key bindings " CONFIG_SECTION_PLAYER"1 in %s\n", fileName); 126 return; 127 } 118 this->loadKeyBindings(&parser); 119 } 120 121 void KeyMapper::loadKeyBindings(IniParser* iniParser) 122 { 123 if( iniParser->getSection (CONFIG_SECTION_PLAYER "1") == -1) 124 { 125 PRINTF(1)("Could not find key bindings " CONFIG_SECTION_PLAYER"1\n"); 126 return; 127 } 128 128 // allocate empty lookup table 129 129 … … 134 134 int* index; 135 135 136 while( parser.nextVar (namebuf, valuebuf) != -1)137 138 139 140 136 while( iniParser->nextVar (namebuf, valuebuf) != -1) 137 { 138 PRINTF(3)("Keys: Parsing %s, %s now.\n", namebuf, valuebuf); 139 index = nameToIndex (valuebuf); 140 this->mapKeys(namebuf, index[1]); 141 141 142 142 /* 143 144 145 146 147 148 149 150 151 152 153 143 switch( index[0]) 144 { 145 case 0: 146 this->mapKeys(namebuf, index[1]); 147 break; 148 case 1: 149 this->mapKeys(namebuf, index[1]); 150 break; 151 default: 152 break; 153 } 154 154 */ 155 156 157 155 memset (namebuf, 0, 256); 156 memset (valuebuf, 0, 256); 157 } 158 158 159 159 160 160 // PARSE MISC SECTION 161 if( parser.getSection (CONFIG_SECTION_MISC_KEYS) == -1)162 163 PRINTF(1)("Could not find key bindings in %s\n", fileName);164 165 166 167 while( parser.nextVar (namebuf, valuebuf) != -1)168 169 170 171 161 if( iniParser->getSection (CONFIG_SECTION_MISC_KEYS) == -1) 162 { 163 PRINTF(1)("Could not find key bindings\n"); 164 return; 165 } 166 167 while( iniParser->nextVar (namebuf, valuebuf) != -1) 168 { 169 PRINTF(3)("MISC: Parsing %s, %s now.\n", namebuf, valuebuf); 170 index = nameToIndex (valuebuf); 171 this->mapKeys(namebuf, index[1]); 172 172 /* 173 174 175 176 177 178 179 180 181 182 183 173 switch( index[0]) 174 { 175 case 0: 176 this->mapKeys(namebuf, index[1]); 177 break; 178 case 1: 179 this->mapKeys(namebuf, index[1]); 180 break; 181 default: 182 break; 183 } 184 184 */ 185 memset (namebuf, 0, 256); 186 memset (valuebuf, 0, 256); 187 } 188 } 189 185 memset (namebuf, 0, 256); 186 memset (valuebuf, 0, 256); 187 } 188 } 190 189 191 190 /** -
orxonox/trunk/src/lib/event/key_mapper.h
r4836 r4866 1 /*! 1 /*! 2 2 \file key_mapper.h 3 3 * a construct to map player defined keys to SDL keys … … 12 12 #include "event_def.h" 13 13 14 class IniParser; 14 15 15 16 //! A mapping from key-name to key-id … … 29 30 30 31 void loadKeyBindings(const char* fileName = DEFAULT_CONFIG_FILE); 32 void loadKeyBindings(IniParser* iniParser); 31 33 32 34 void debug(); … … 41 43 static int PEV_LEFT; //!< left button 42 44 static int PEV_RIGHT; //!< right button 43 45 44 46 static int PEV_STRAFE_LEFT; //!< strafe left button 45 47 static int PEV_STRAFE_RIGHT; //!< strafe right button 46 48 47 49 static int PEV_FIRE1; //!< fire button 1 48 50 static int PEV_FIRE2; //!< fire button 2
Note: See TracChangeset
for help on using the changeset viewer.