- Timestamp:
- Dec 15, 2008, 1:38:02 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy2/src/orxonox/gamestates/GSRoot.cc
r2406 r2462 69 69 : RootGameState("root") 70 70 , timeFactor_(1.0f) 71 , bPaused_(false) 72 , timeFactorPauseBackup_(1.0f) 71 73 , settings_(0) 72 74 , tclBind_(0) … … 78 80 79 81 this->ccSetTimeFactor_ = 0; 82 this->ccPause_ = 0; 80 83 } 81 84 … … 125 128 setThreadAffinity((unsigned int)(limitToCPU - 1)); 126 129 127 // add console commands 128 FunctorMember<GSRoot>* functor1 = createFunctor(&GSRoot::exitGame); 129 functor1->setObject(this); 130 ccExit_ = createConsoleCommand(functor1, "exit"); 131 CommandExecutor::addConsoleCommandShortcut(ccExit_); 132 133 // add console commands 134 FunctorMember01<GameStateBase, const std::string&>* functor2 = createFunctor(&GameStateBase::requestState); 135 functor2->setObject(this); 136 ccSelectGameState_ = createConsoleCommand(functor2, "selectGameState"); 137 CommandExecutor::addConsoleCommandShortcut(ccSelectGameState_); 138 139 // time factor console command 140 FunctorMember<GSRoot>* functor = createFunctor(&GSRoot::setTimeFactor); 141 functor->setObject(this); 142 ccSetTimeFactor_ = createConsoleCommand(functor, "setTimeFactor"); 143 CommandExecutor::addConsoleCommandShortcut(ccSetTimeFactor_).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);; 130 { 131 // add console commands 132 FunctorMember<GSRoot>* functor = createFunctor(&GSRoot::exitGame); 133 functor->setObject(this); 134 this->ccExit_ = createConsoleCommand(functor, "exit"); 135 CommandExecutor::addConsoleCommandShortcut(this->ccExit_); 136 } 137 138 { 139 // add console commands 140 FunctorMember01<GameStateBase, const std::string&>* functor = createFunctor(&GameStateBase::requestState); 141 functor->setObject(this); 142 this->ccSelectGameState_ = createConsoleCommand(functor, "selectGameState"); 143 CommandExecutor::addConsoleCommandShortcut(this->ccSelectGameState_); 144 } 145 146 { 147 // time factor console command 148 FunctorMember<GSRoot>* functor = createFunctor(&GSRoot::setTimeFactor); 149 functor->setObject(this); 150 this->ccSetTimeFactor_ = createConsoleCommand(functor, "setTimeFactor"); 151 CommandExecutor::addConsoleCommandShortcut(this->ccSetTimeFactor_).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0); 152 } 153 154 { 155 // time factor console command 156 FunctorMember<GSRoot>* functor = createFunctor(&GSRoot::pause); 157 functor->setObject(this); 158 this->ccPause_ = createConsoleCommand(functor, "pause"); 159 CommandExecutor::addConsoleCommandShortcut(this->ccPause_).accessLevel(AccessLevel::Offline); 160 } 144 161 } 145 162 … … 161 178 delete this->ccSetTimeFactor_; 162 179 this->ccSetTimeFactor_ = 0; 180 } 181 182 if (this->ccPause_) 183 { 184 delete this->ccPause_; 185 this->ccPause_ = 0; 163 186 } 164 187 } … … 229 252 if (Core::isMaster()) 230 253 { 231 TimeFactorListener::timefactor_s = factor; 232 233 for (ObjectList<TimeFactorListener>::iterator it = ObjectList<TimeFactorListener>::begin(); it != ObjectList<TimeFactorListener>::end(); ++it) 234 it->changedTimeFactor(factor, this->timeFactor_); 235 236 this->timeFactor_ = factor; 254 if (!this->bPaused_) 255 { 256 TimeFactorListener::timefactor_s = factor; 257 258 for (ObjectList<TimeFactorListener>::iterator it = ObjectList<TimeFactorListener>::begin(); it != ObjectList<TimeFactorListener>::end(); ++it) 259 it->changedTimeFactor(factor, this->timeFactor_); 260 261 this->timeFactor_ = factor; 262 } 263 else 264 this->timeFactorPauseBackup_ = factor; 265 } 266 } 267 268 void GSRoot::pause() 269 { 270 if (Core::isMaster()) 271 { 272 if (!this->bPaused_) 273 { 274 this->timeFactorPauseBackup_ = this->timeFactor_; 275 this->setTimeFactor(0.0f); 276 this->bPaused_ = true; 277 } 278 else 279 { 280 this->bPaused_ = false; 281 this->setTimeFactor(this->timeFactorPauseBackup_); 282 } 237 283 } 238 284 }
Note: See TracChangeset
for help on using the changeset viewer.