- Timestamp:
- Aug 21, 2005, 11:17:50 PM (19 years ago)
- Location:
- trunk/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/event/event.h
r5039 r5093 2 2 * @file event.h 3 3 * an abstract event 4 * 5 * @todo remove HUGE class-overhead. This could also be a struct 4 6 */ 5 7 -
trunk/src/lib/event/event_handler.cc
r4873 r5093 89 89 this->keyMapper->loadKeyBindings(iniParser); 90 90 } 91 92 93 /**94 * set the state of the event handler95 * @param state: to which the event handler shall change96 */97 void EventHandler::setState(elState state)98 {99 this->state = state;100 }101 102 91 103 92 /** -
trunk/src/lib/event/event_handler.h
r5039 r5093 26 26 void init(IniParser* iniParser); 27 27 28 void setState(elState state); 28 /** @param state: to which the event handler shall change */ 29 inline void setState(elState state) { this->state = state; }; 30 /** @returns the current state */ 31 inline elState getState() const { return this->state; }; 29 32 30 33 void subscribe(EventListener* el, elState state, int eventType); -
trunk/src/util/loading/game_loader.cc
r4885 r5093 78 78 79 79 this->eventHandler = EventHandler::getInstance(); 80 this->eventHandler->subscribe(this, ES_ ALL, KeyMapper::PEV_PAUSE);80 this->eventHandler->subscribe(this, ES_GAME, KeyMapper::PEV_PAUSE); 81 81 this->eventHandler->subscribe(this, ES_ALL, KeyMapper::PEV_QUIT); 82 this->eventHandler->subscribe(this, ES_ ALL, KeyMapper::PEV_NEXT_WORLD);83 this->eventHandler->subscribe(this, ES_ ALL, KeyMapper::PEV_PREVIOUS_WORLD);82 this->eventHandler->subscribe(this, ES_GAME, KeyMapper::PEV_NEXT_WORLD); 83 this->eventHandler->subscribe(this, ES_GAME, KeyMapper::PEV_PREVIOUS_WORLD); 84 84 } 85 85 -
trunk/src/util/shell.cc
r5092 r5093 20 20 #include "text_engine.h" 21 21 #include "list.h" 22 22 #include "graphics_engine.h" 23 #include "event_handler.h" 24 25 #include "debug.h" 23 26 #include <stdarg.h> 24 27 #include <stdio.h> … … 43 46 this->setBufferSize(100); 44 47 this->setBufferDisplaySize(10); 45 this->setAbsCoor2D(2, 400);48 this->setAbsCoor2D(2, GraphicsEngine::getInstance()->getResolutionY()); 46 49 this->setAbsDir2D(0); 47 50 48 51 this->inputLineText = TextEngine::getInstance()->createText("fonts/earth.ttf", 10, TEXT_DYNAMIC, 255, 0, 0); 49 52 this->inputLineText->setText(NULL); 53 this->inputLine = new char[1]; 54 this->inputLine[0] = '\0'; 55 56 EventHandler::getInstance()->subscribe(this, ES_GAME, SDLK_BACKQUOTE); 57 58 EventHandler* evh = EventHandler::getInstance(); 59 for (int i = 1; i < EV_NUMBER; i++) 60 EventHandler::getInstance()->subscribe(this, ES_SHELL, i); 50 61 } 51 62 … … 61 72 delete this->bufferText[i]; 62 73 delete this->bufferText; 74 63 75 delete this->inputLineText; 64 76 delete this->inputLine; 65 77 66 78 Shell::singletonRef = NULL; … … 243 255 delete this->inputLine; 244 256 this->inputLine = addCharLine; 257 this->inputLineText->setText(inputLine); 245 258 } 246 259 … … 256 269 delete this->inputLine; 257 270 this->inputLine = addCharLine; 271 this->inputLineText->setText(inputLine); 258 272 } 259 273 … … 264 278 void Shell::removeCharacters(unsigned int characterCount) 265 279 { 280 if (strlen(this->inputLine) == 0) 281 return; 282 266 283 if (characterCount > strlen(this->inputLine)) 267 284 characterCount = strlen(this->inputLine); … … 270 287 271 288 strncpy(removeCharLine, this->inputLine, strlen(inputLine)-characterCount); 289 removeCharLine[strlen(inputLine)-characterCount] = '\0'; 272 290 delete this->inputLine; 273 291 this->inputLine = removeCharLine; 274 } 275 292 this->inputLineText->setText(inputLine); 293 } 294 295 #include "key_names.h" 276 296 /** 277 297 * listens for some event … … 280 300 void Shell::process(const Event &event) 281 301 { 282 // if (event.type) 283 302 if (event.bPressed) 303 { 304 PRINTF(4)("Shell received command %s\n", SDLKToKeyname(event.type)); 305 if (event.type == SDLK_BACKQUOTE) 306 { 307 if (EventHandler::getInstance()->getState() == ES_GAME) 308 EventHandler::getInstance()->setState(ES_SHELL); 309 else 310 EventHandler::getInstance()->setState(ES_GAME); 311 } 312 313 else if (event.type == SDLK_TAB) 314 this->autoComplete(); 315 else if (event.type == SDLK_BACKSPACE) 316 this->removeCharacters(1); 317 else if (event.type < 127) 318 this->addCharacter(event.type); 319 } 284 320 } 285 321 … … 306 342 bool Shell::autoComplete() 307 343 { 308 344 PRINTF(3)("AutoCompletion not implemented yet\n"); 309 345 } 310 346
Note: See TracChangeset
for help on using the changeset viewer.