Changeset 7895 in orxonox.OLD for branches/gui
- Timestamp:
- May 27, 2006, 5:29:48 AM (19 years ago)
- Location:
- branches/gui/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/gui/src/lib/event/event_handler.cc
r7868 r7895 42 42 43 43 /* now initialize them all to zero */ 44 this->withUNICODE(false); 44 for (unsigned int i = 0; i < ES_NUMBER; i++) 45 this->bUNICODE[i] = false; 45 46 this->grabEvents(false); 46 47 … … 87 88 this->keyMapper.loadKeyBindings(); 88 89 } 90 91 /** 92 * @param state: to which the event handler shall change 93 */ 94 void EventHandler::setState(elState state) 95 { 96 this->state = state; 97 SDL_EnableUNICODE(this->bUNICODE[state]); 98 }; 99 89 100 90 101 /** … … 144 155 { 145 156 for(unsigned int i = 0; i < ES_NUMBER; i++) 146 {147 if( !likely(this->listeners[i][eventType].empty()))148 {149 PRINTF(2)("'%s' of class '%s' tried to subscribe to event %i @ state %i but this event has already been subscribed\n", el->getName(), el->getClassName(), eventType, state);150 }151 157 this->listeners[i][eventType].push_back(el); 152 } 153 } 154 else 155 { 156 if( likely(!this->listeners[state][eventType].empty())) 157 { 158 PRINTF(2)("%s of class %s tried to subscribe to event %i @ state %i but this event has already been subscribed\n", el->getName(), el->getClassName(), eventType, state); 159 } 158 } 159 else 160 160 this->listeners[state][eventType].push_back(el); 161 }162 161 } 163 162 … … 178 177 { 179 178 std::vector<EventListener*>::iterator listener = 180 181 182 179 std::find(this->listeners[i][eventType].begin(), 180 this->listeners[i][eventType].end(), 181 el); 183 182 if (listener != this->listeners[i][eventType].end()) 184 183 this->listeners[i][eventType].erase(listener); … … 187 186 { 188 187 std::vector<EventListener*>::iterator listener = 189 190 191 188 std::find(this->listeners[state][eventType].begin(), 189 this->listeners[state][eventType].end(), 190 el); 192 191 if (listener != this->listeners[state][eventType].end()) 193 192 this->listeners[state][eventType].erase(listener); … … 261 260 262 261 263 void EventHandler::withUNICODE(bool enableUNICODE) 264 { 265 SDL_EnableUNICODE(enableUNICODE); 266 this->bUNICODE = enableUNICODE; 262 void EventHandler::withUNICODE(elState state, bool enableUNICODE) 263 { 264 this->bUNICODE[state] = enableUNICODE; 265 if (this->state == state) 266 SDL_EnableUNICODE(enableUNICODE); 267 267 } 268 268 … … 283 283 284 284 /** 285 * core function of event handler: receives all events from SDL286 287 288 */285 * @brief core function of event handler: receives all events from SDL 286 * 287 * The event from the SDL framework are collected here and distributed to all listeners. 288 */ 289 289 void EventHandler::process() 290 290 { … … 299 299 ev.bPressed = true; 300 300 ev.type = event.key.keysym.sym; 301 if (unlikely(this->bUNICODE ))301 if (unlikely(this->bUNICODE[this->state])) 302 302 ev.x = event.key.keysym.unicode; 303 303 break; … … 305 305 ev.bPressed = false; 306 306 ev.type = event.key.keysym.sym; 307 if (unlikely(this->bUNICODE ))307 if (unlikely(this->bUNICODE[this->state])) 308 308 ev.x = event.key.keysym.unicode; 309 309 break; … … 358 358 /* small debug routine: shows all events dispatched by the event handler */ 359 359 PRINT(4)("\n==========================| EventHandler::process () |===\n"); 360 PRINT(4)("= Got Event nr %i, for state %i", ev.type, this->state); 361 362 363 for (unsigned int i = 0; i < this->listeners[this->state][ev.type].size(); i++) 360 PRINT(4)("= Got Event nr %i, for state %i\n", ev.type, this->state); 361 362 /// setting a temporary state in case of an EventListener's process changes the state. 363 elState currentState = this->state; 364 for (unsigned int i = 0; i < this->listeners[currentState][ev.type].size(); i++) 364 365 { 365 366 PRINT(4)("= Event dispatcher msg: This event has been consumed\n"); 367 PRINT(4)("= Got Event nr %i, for state %i %s::%s\n", ev.type, currentState, this->listeners[this->state][ev.type][i]->getClassName(), this->listeners[currentState][ev.type][i]->getName()); 366 368 PRINT(4)("=======================================================\n"); 367 listeners[this->state][ev.type][i]->process(ev);369 this->listeners[currentState][ev.type][i]->process(ev); 368 370 } 369 371 /* else … … 375 377 } 376 378 377 379 /** 380 * @brief An eventFilter. 381 * @param event the Event to be filtered. 382 * @returns 0 on filtered Event. 1 Otherwise. 383 */ 378 384 int EventHandler::eventFilter(const SDL_Event *event) 379 385 { … … 400 406 401 407 /** 402 * outputs some nice information about the EventHandler408 * @brief outputs some nice information about the EventHandler 403 409 */ 404 410 void EventHandler::debug() const … … 408 414 PRINT(0)("===============================\n"); 409 415 for(int i = 0; i < ES_NUMBER; ++i) 416 { 410 417 for(int j = 0; j < EV_NUMBER; ++j) 411 418 for (unsigned int evl = 0; evl < this->listeners[i][j].size(); evl++) 412 419 PRINT(0)("Event %d of State %d subscribed to %s (%p)\n", j, i, this->listeners[i][j][evl]->getName(), this->listeners[i][j][evl]); 420 } 413 421 PRINT(0)("============================EH=\n"); 414 422 } -
branches/gui/src/lib/event/event_handler.h
r7868 r7895 26 26 void init(); 27 27 28 /** @param state: to which the event handler shall change */ 29 inline void setState(elState state) { this->state = state; }; 28 void setState(elState state); 30 29 /** @returns the current state */ 31 30 inline elState getState() const { return this->state; }; … … 42 41 43 42 44 void withUNICODE( bool enableUNICODE);43 void withUNICODE(elState state, bool enableUNICODE); 45 44 void grabEvents(bool grabEvents); 46 45 bool grabbedEvents() const { return this->eventsGrabbed; }; … … 62 61 KeyMapper keyMapper; //!< reference to the key mapper. 63 62 64 bool bUNICODE ;//!< If unicode should be enabled.63 bool bUNICODE[ES_NUMBER]; //!< If unicode should be enabled. 65 64 bool eventsGrabbed; //!< If the events should be grabbed 66 65 }; -
branches/gui/src/lib/gui/gl_gui/glgui_handler.cc
r7893 r7895 37 37 38 38 39 EventHandler::getInstance()->withUNICODE(ES_MENU, true ); 40 39 41 this->cursor = NULL; 40 42 for (unsigned int i = 0; i < EV_NUMBER; i++) … … 42 44 this->subscribeEvent(ES_MENU, i); 43 45 } 44 45 46 } 46 47 … … 79 80 EventHandler::getInstance()->pushState(ES_MENU); 80 81 82 83 81 84 } 82 85 … … 84 87 { 85 88 EventHandler::getInstance()->popState(); 89 86 90 87 91 } -
branches/gui/src/lib/gui/gl_gui/glgui_inputline.cc
r7894 r7895 36 36 {} 37 37 38 float GLGuiInputLine::repeatDelay = 1.0;39 float GLGuiInputLine::repeatRate = .1;38 float GLGuiInputLine::repeatDelay = 0.3f; 39 float GLGuiInputLine::repeatRate = 0.01f; 40 40 41 41 … … 97 97 else if (likely(event.type < 127)) 98 98 { 99 this->delayNext = GLGuiInputLine::repeatDelay; 100 99 101 this->appendCharacter(event.x); 100 102 this->pressedKey = event.type; … … 102 104 return true; 103 105 } 104 this->delayNext = this->repeatDelay;105 106 } 106 107 else // if(!event.bPressed) … … 113 114 return true; 114 115 } 115 }116 117 if (likely(event.type < 127))118 {119 this->appendCharacter(event.type);120 return true;121 116 } 122 117 … … 135 130 if (this->delayNext > 0.0) 136 131 this->delayNext -= dt; 132 else if (this->pressedKey != SDLK_FIRST ) 133 { 134 this->delayNext = GLGuiInputLine::repeatRate; 135 switch (this->pressedKey) 136 { 137 case SDLK_BACKSPACE: 138 this->removeCharacters(1); 139 break; 140 default: 141 { 142 if (likely(this->pressedKey < 127)) 143 this->appendCharacter(this->pressedKeyName); 144 } 145 } 146 } 147 148 137 149 } 138 150 -
branches/gui/src/lib/shell/shell.cc
r7868 r7895 70 70 this->subscribeEvent(ES_SHELL, SDLK_PAGEDOWN); 71 71 this->subscribeEvent(ES_SHELL, EV_VIDEO_RESIZE); 72 EventHandler::getInstance()->withUNICODE(ES_SHELL, true); 72 73 73 74 // BUFFER … … 83 84 this->textSize = 15; 84 85 this->lineSpacing = 0; 85 this->bActive = true;86 this->bActive = false; 86 87 this->fontFile = SHELL_DEFAULT_FONT; 87 88 … … 121 122 122 123 EventHandler::getInstance()->pushState(ES_SHELL); 123 EventHandler::getInstance()->withUNICODE(true);124 124 125 125 this->setRelCoorSoft2D(0, 0, 5); … … 152 152 this->deactivate2D(); 153 153 154 EventHandler::getInstance()->withUNICODE(false);155 154 EventHandler::getInstance()->popState(); 156 155 -
branches/gui/src/story_entities/simple_game_menu.cc
r7893 r7895 84 84 85 85 OrxGui::GLGuiHandler::getInstance()->activateCursor(); 86 OrxGui::GLGuiHandler::getInstance()->activate(); 86 87 ///// 87 88 if (root != NULL)
Note: See TracChangeset
for help on using the changeset viewer.