- Timestamp:
- Apr 6, 2015, 10:00:37 PM (10 years ago)
- Location:
- code/branches/core7/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core7/src/libraries/core/command/CommandExecutor.cc
r10347 r10348 296 296 // create a new console command with the given alias as its name 297 297 if (tokens.size() == 1) 298 createConsoleCommand(tokens[0], executor);298 new ConsoleCommand(tokens[0], executor); 299 299 else if (tokens.size() == 2) 300 createConsoleCommand(tokens[0], tokens[1], executor);300 new ConsoleCommand(tokens[0], tokens[1], executor); 301 301 else 302 302 orxout(user_error) << "\"" << alias << "\" is not a valid alias name (must have one or two words)." << endl; -
code/branches/core7/src/libraries/core/command/ConsoleCommand.cc
r10347 r10348 44 44 { 45 45 /** 46 @brief Constructor: Initializes all values and registers the command. 46 @brief Constructor: Initializes all values and registers the command (without a group). 47 @param name The name of the command 48 @param executor The executor of the command 49 @param bInitialized If true, the executor is used for both, the definition of the function-header AND to executute the command. If false, the command is inactive and needs to be assigned a function before it can be used. 50 */ 51 ConsoleCommand::ConsoleCommand(const std::string& name, const ExecutorPtr& executor, bool bInitialized) 52 { 53 this->init("", name, executor, bInitialized); 54 } 55 56 /** 57 @brief Constructor: Initializes all values and registers the command (with a group). 47 58 @param group The group of the command 48 59 @param name The name of the command … … 51 62 */ 52 63 ConsoleCommand::ConsoleCommand(const std::string& group, const std::string& name, const ExecutorPtr& executor, bool bInitialized) 64 { 65 this->init(group, name, executor, bInitialized); 66 } 67 68 void ConsoleCommand::init(const std::string& group, const std::string& name, const ExecutorPtr& executor, bool bInitialized) 53 69 { 54 70 this->bActive_ = true; -
code/branches/core7/src/libraries/core/command/ConsoleCommand.h
r10347 r10348 261 261 262 262 public: 263 ConsoleCommand(const std::string& name, const ExecutorPtr& executor, bool bInitialized = true); 263 264 ConsoleCommand(const std::string& group, const std::string& name, const ExecutorPtr& executor, bool bInitialized = true); 264 265 ~ConsoleCommand(); … … 360 361 361 362 private: 363 void init(const std::string& group, const std::string& name, const ExecutorPtr& executor, bool bInitialized); 364 362 365 bool headersMatch(const FunctorPtr& functor); 363 366 bool headersMatch(const ExecutorPtr& executor); -
code/branches/core7/src/libraries/core/command/ConsoleCommandIncludes.h
r10347 r10348 264 264 /// Internal macro 265 265 #define SetConsoleCommandGeneric(group, name, functor) \ 266 static orxonox::ConsoleCommand& BOOST_PP_CAT(__consolecommand_, __UNIQUE_NUMBER__) = (* orxonox::createConsoleCommand(group, name, orxonox::createExecutor(functor)))266 static orxonox::ConsoleCommand& BOOST_PP_CAT(__consolecommand_, __UNIQUE_NUMBER__) = (*new orxonox::ConsoleCommand(group, name, orxonox::createExecutor(functor))) 267 267 268 268 … … 299 299 /// Internal macro 300 300 #define DeclareConsoleCommandGeneric(group, name, functor) \ 301 static orxonox::ConsoleCommand& BOOST_PP_CAT(__consolecommand_, __UNIQUE_NUMBER__) = (* orxonox::createConsoleCommand(group, name, orxonox::createExecutor(functor), false))301 static orxonox::ConsoleCommand& BOOST_PP_CAT(__consolecommand_, __UNIQUE_NUMBER__) = (*new orxonox::ConsoleCommand(group, name, orxonox::createExecutor(functor), false)) 302 302 303 303 304 304 namespace orxonox 305 305 { 306 /**307 @brief Creates a new ConsoleCommand.308 @param name The name of the command309 @param executor The executor of the command310 @param bInitialized If true, the command is ready to be executed, otherwise it has to be activated first.311 */312 inline ConsoleCommand* createConsoleCommand(const std::string& name, const ExecutorPtr& executor, bool bInitialized = true)313 { return new ConsoleCommand("", name, executor, bInitialized); }314 /**315 @brief Creates a new ConsoleCommand.316 @param group The group of the command317 @param name The name of the command318 @param executor The executor of the command319 @param bInitialized If true, the command is ready to be executed, otherwise it has to be activated first.320 */321 inline ConsoleCommand* createConsoleCommand(const std::string& group, const std::string& name, const ExecutorPtr& executor, bool bInitialized = true)322 { return new ConsoleCommand(group, name, executor, bInitialized); }323 324 325 306 /** 326 307 @brief Returns a manipulator for a command with the given name. -
code/branches/core7/src/modules/towerdefense/TowerDefense.cc
r10347 r10348 108 108 109 109 /* Temporary hack to allow the player to add towers and upgrade them */ 110 this->dedicatedAddTower_ = createConsoleCommand( "addTower", createExecutor( createFunctor(&TowerDefense::addTower, this) ) );111 this->dedicatedUpgradeTower_ = createConsoleCommand( "upgradeTower", createExecutor( createFunctor(&TowerDefense::upgradeTower, this) ) );110 this->dedicatedAddTower_ = new ConsoleCommand( "addTower", createExecutor( createFunctor(&TowerDefense::addTower, this) ) ); 111 this->dedicatedUpgradeTower_ = new ConsoleCommand( "upgradeTower", createExecutor( createFunctor(&TowerDefense::upgradeTower, this) ) ); 112 112 } 113 113 -
code/branches/core7/src/orxonox/gametypes/Gametype.cc
r10347 r10348 85 85 86 86 /* HACK HACK HACK */ 87 this->dedicatedAddBots_ = createConsoleCommand( "dedicatedAddBots", createExecutor( createFunctor(&Gametype::addBots, this) ) );88 this->dedicatedKillBots_ = createConsoleCommand( "dedicatedKillBots", createExecutor( createFunctor(&Gametype::killBots, this) ) );87 this->dedicatedAddBots_ = new ConsoleCommand( "dedicatedAddBots", createExecutor( createFunctor(&Gametype::addBots, this) ) ); 88 this->dedicatedKillBots_ = new ConsoleCommand( "dedicatedKillBots", createExecutor( createFunctor(&Gametype::killBots, this) ) ); 89 89 /* HACK HACK HACK */ 90 90 }
Note: See TracChangeset
for help on using the changeset viewer.