Changeset 5388 in orxonox.OLD for trunk/src/lib/event/event_handler.cc
- Timestamp:
- Oct 16, 2005, 2:05:26 AM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/event/event_handler.cc
r5371 r5388 26 26 #include "class_list.h" 27 27 28 #include "t_stack.h" 29 28 30 using namespace std; 29 31 … … 47 49 this->state = ES_GAME; 48 50 this->keyMapper = NULL; 51 this->stateStack = NULL; 49 52 } 50 53 … … 72 75 } 73 76 } 77 delete this->stateStack; 74 78 delete this->keyMapper; 75 79 … … 87 91 void EventHandler::init(IniParser* iniParser) 88 92 { 89 this->keyMapper = new KeyMapper(); 90 this->keyMapper->loadKeyBindings(iniParser); 91 } 93 if (this->keyMapper == NULL) 94 { 95 this->keyMapper = new KeyMapper(); 96 this->keyMapper->loadKeyBindings(iniParser); 97 } 98 if (this->stateStack == NULL) 99 this->stateStack = new tStack<short>; 100 } 101 102 /** 103 * pushes the current State in the State-stack, and selects state 104 * @param state the new State to set 105 */ 106 void EventHandler::pushState(elState state) 107 { 108 if (likely(state != ES_NULL && state != ES_ALL && this->stateStack != NULL)) 109 { 110 this->stateStack->push(this->state); 111 this->setState(state); 112 } 113 else 114 { 115 PRINTF(2)("unable to push State\n"); 116 } 117 } 118 119 /** 120 * this removes the topmost stack-entry and select the underlying one 121 * @returns the next stack-entry 122 */ 123 elState EventHandler::popState() 124 { 125 if (unlikely(this->stateStack == NULL)) 126 return ES_NULL; 127 elState state = (elState)this->stateStack->pop(); 128 if (state == ES_NULL) 129 { 130 PRINTF(2)("No more states availiable. (unable to pop state)\n"); 131 return ES_NULL; 132 } 133 else 134 { 135 this->setState(state); 136 return state; 137 } 138 } 139 92 140 93 141 /**
Note: See TracChangeset
for help on using the changeset viewer.