Changeset 3255 for code/branches/core4/src
- Timestamp:
- Jun 29, 2009, 11:59:29 PM (15 years ago)
- Location:
- code/branches/core4/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core4/src/core/CommandLine.cc
r3250 r3255 29 29 #include "CommandLine.h" 30 30 31 #include <sstream> 31 32 #include <boost/filesystem.hpp> 32 33 … … 231 232 { 232 233 COUT(0) << "Could not parse command line (including additional files): " << ex.what() << std::endl; 233 COUT(0) << "Usage:" << std::endl << "orxonox " <<CommandLine::getUsageInformation() << std::endl;234 COUT(0) << CommandLine::getUsageInformation() << std::endl; 234 235 throw GeneralException(""); 235 236 } … … 272 273 std::string CommandLine::getUsageInformation() 273 274 { 274 CommandLine* inst = &_getInstance(); 275 std::string infoStr; 276 for (std::map<std::string, CommandLineArgument*>::const_iterator it = inst->cmdLineArgs_.begin(); 277 it != inst->cmdLineArgs_.end(); ++it) 278 { 279 infoStr += "[--" + it->second->getName() + " " + it->second->getInformation() + "] "; 280 } 281 return infoStr; 275 CommandLine& inst = _getInstance(); 276 std::ostringstream infoStr; 277 278 // determine maximum name size 279 size_t maxNameSize = 0; 280 for (std::map<std::string, CommandLineArgument*>::const_iterator it = inst.cmdLineArgs_.begin(); 281 it != inst.cmdLineArgs_.end(); ++it) 282 { 283 maxNameSize = std::max(it->second->getName().size(), maxNameSize); 284 } 285 286 infoStr << "Usage: orxonox [options]" << std::endl; 287 infoStr << "Available options:" << std::endl; 288 289 for (std::map<std::string, CommandLineArgument*>::const_iterator it = inst.cmdLineArgs_.begin(); 290 it != inst.cmdLineArgs_.end(); ++it) 291 { 292 if (it->second->getShortcut() != "") 293 infoStr << " [-" << it->second->getShortcut() << "] "; 294 else 295 infoStr << " "; 296 infoStr << "--" << it->second->getName() << " "; 297 if (it->second->getValue().getType() != MT_bool) 298 infoStr << "ARG "; 299 else 300 infoStr << " "; 301 // fill with the necessary amount of blanks 302 infoStr << std::string(maxNameSize - it->second->getName().size(), ' '); 303 infoStr << ": " << it->second->getInformation(); 304 infoStr << std::endl; 305 } 306 return infoStr.str(); 282 307 } 283 308 -
code/branches/core4/src/core/CommandLine.h
r3246 r3255 80 80 81 81 //! Returns the shortcut (example: "-p 22" for "--port 22") of the argument. 82 //! Evaluates to "" if nonethere is none.82 //! Evaluates to "" if there is none. 83 83 const std::string& getShortcut() const { return shortcut_; } 84 84 //! Sets the shortcut for the argument … … 213 213 OrxAssert(!_getInstance().existsArgument(name), 214 214 "Cannot add a command line argument with name '" + name + "' twice."); 215 OrxAssert(MultiType(defaultValue).getType() != MT_bool || MultiType(defaultValue).getBool() != true, 216 "Boolean command line arguments with positive default values are not supported." << std::endl 217 << "Please use SetCommandLineSwitch and adjust your argument: " << name); 215 218 216 219 return *(_getInstance().cmdLineArgs_[name] = new CommandLineArgument(name, defaultValue, bCommandLineOnly)); -
code/branches/core4/src/core/Core.cc
r3253 r3255 80 80 Core* Core::singletonRef_s = 0; 81 81 82 SetCommandLineArgument(mediaPath, "").information("PATH"); 83 SetCommandLineOnlyArgument(writingPathSuffix, "").information("DIR"); 84 SetCommandLineArgument(settingsFile, "orxonox.ini"); 85 SetCommandLineArgument(limitToCPU, 0).information("0: off | #cpu"); 82 SetCommandLineArgument(mediaPath, "").information("Path to the media/data files"); 83 SetCommandLineOnlyArgument(writingPathSuffix, "").information("Additional subfolder for config and log files"); 84 SetCommandLineArgument(settingsFile, "orxonox.ini").information("THE configuration file"); 85 #ifdef ORXONOX_PLATFORM_WINDOWS 86 SetCommandLineArgument(limitToCPU, 0).information("Limits the program to one cpu/core (1, 2, 3, etc.). 0 turns it off (default)"); 87 #endif 86 88 87 89 /** … … 263 265 CommandLine::parseFile(); 264 266 267 #ifdef ORXONOX_PLATFORM_WINDOWS 265 268 // limit the main thread to the first core so that QueryPerformanceCounter doesn't jump 266 269 // do this after ogre has initialised. Somehow Ogre changes the settings again (not through … … 269 272 if (limitToCPU > 0) 270 273 setThreadAffinity(static_cast<unsigned int>(limitToCPU)); 274 #endif 271 275 272 276 // Manage ini files and set the default settings file (usually orxonox.ini) … … 423 427 void Core::setThreadAffinity(int limitToCPU) 424 428 { 429 #ifdef ORXONOX_PLATFORM_WINDOWS 430 425 431 if (limitToCPU <= 0) 426 432 return; 427 433 428 #ifdef ORXONOX_PLATFORM_WINDOWS429 434 unsigned int coreNr = limitToCPU - 1; 430 435 // Get the current process core mask -
code/branches/core4/src/core/input/InputManager.cc
r3237 r3255 70 70 SetConsoleCommand(InputManager, ungrabMouse, true); 71 71 #endif 72 SetCommandLineSwitch(keyboard_no_grab) ;72 SetCommandLineSwitch(keyboard_no_grab).information("Whether not to exclusively grab the keyboard"); 73 73 74 74 EmptyHandler InputManager::EMPTY_HANDLER; -
code/branches/core4/src/orxonox/LevelManager.cc
r3249 r3255 40 40 namespace orxonox 41 41 { 42 SetCommandLineArgument(level, "").shortcut("l") ;42 SetCommandLineArgument(level, "").shortcut("l").information("Default level file (overrides LevelManager::defaultLevelName_ configValue)"); 43 43 44 44 LevelManager* LevelManager::singletonRef_s = 0; … … 55 55 if (!CommandLine::getArgument("level")->hasDefaultValue()) 56 56 { 57 ModifyConfigValue(defaultLevelName_, tset, CommandLine::getValue(" mediaPath").getString());57 ModifyConfigValue(defaultLevelName_, tset, CommandLine::getValue("level").getString()); 58 58 } 59 59 } -
code/branches/core4/src/orxonox/gamestates/GSClient.cc
r3243 r3255 40 40 DeclareGameState(GSClient, "client", false, true); 41 41 42 SetCommandLineArgument(ip, "127.0.0.1").information(" #.#.#.#");42 SetCommandLineArgument(ip, "127.0.0.1").information("Sever IP as strin in the form #.#.#.#"); 43 43 44 44 GSClient::GSClient(const GameStateConstrParams& params) -
code/branches/core4/src/orxonox/gamestates/GSRoot.cc
r3245 r3255 42 42 { 43 43 DeclareGameState(GSRoot, "root", true, false); 44 SetCommandLineSwitch(console) ;44 SetCommandLineSwitch(console).information("Start in console mode (text IO only)"); 45 45 // Shortcuts for easy direct loading 46 SetCommandLineSwitch(server) ;47 SetCommandLineSwitch(client) ;48 SetCommandLineSwitch(dedicated) ;49 SetCommandLineSwitch(standalone) ;46 SetCommandLineSwitch(server).information("Start in server mode"); 47 SetCommandLineSwitch(client).information("Start in client mode"); 48 SetCommandLineSwitch(dedicated).information("Start in dedicated server mode"); 49 SetCommandLineSwitch(standalone).information("Start in standalone mode"); 50 50 51 51 GSRoot::GSRoot(const GameStateConstrParams& params) -
code/branches/core4/src/orxonox/gamestates/GSServer.cc
r3243 r3255 39 39 DeclareGameState(GSServer, "server", false, true); 40 40 41 SetCommandLineArgument(port, 55556).shortcut("p").information(" 0-65535");41 SetCommandLineArgument(port, 55556).shortcut("p").information("Network communication port to be used 0-65535 (default: 55556)"); 42 42 43 43 GSServer::GSServer(const GameStateConstrParams& params)
Note: See TracChangeset
for help on using the changeset viewer.