Changeset 7219 for code/branches/consolecommands3/src/libraries/core
- Timestamp:
- Aug 26, 2010, 12:09:12 AM (14 years ago)
- Location:
- code/branches/consolecommands3/src/libraries/core
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/consolecommands3/src/libraries/core/ConfigFileManager.cc
r7204 r7219 425 425 //////////////////////// 426 426 427 static const std::string __CC_load_name = "reloadSettings"; 428 static const std::string __CC_setFilename_name = "setSettingsFile"; 429 static const std::string __CC_config_name = "config"; 430 static const std::string __CC_tconfig_name = "tconfig"; 431 static const std::string __CC_getConfig_name = "getConfig"; 432 433 _SetConsoleCommand(__CC_load_name, &ConfigFile::load); 434 _SetConsoleCommand(__CC_setFilename_name, &SettingsConfigFile::setFilename); 435 _SetConsoleCommand(__CC_config_name, &SettingsConfigFile::config).argumentCompleter(0, autocompletion::settingssections()).argumentCompleter(1, autocompletion::settingsentries()).argumentCompleter(2, autocompletion::settingsvalue()); 436 _SetConsoleCommand(__CC_tconfig_name, &SettingsConfigFile::tconfig).argumentCompleter(0, autocompletion::settingssections()).argumentCompleter(1, autocompletion::settingsentries()).argumentCompleter(2, autocompletion::settingsvalue()); 437 _SetConsoleCommand(__CC_getConfig_name, &SettingsConfigFile::getConfig).argumentCompleter(0, autocompletion::settingssections()).argumentCompleter(1, autocompletion::settingsentries()); 438 427 439 SettingsConfigFile* SettingsConfigFile::singletonPtr_s = 0; 428 440 … … 430 442 : ConfigFile(filename) 431 443 { 432 ConsoleCommand* command = createConsoleCommand(createFunctor(&ConfigFile::load, this), "reloadSettings"); 433 CommandExecutor::addConsoleCommandShortcut(command); 434 command = createConsoleCommand(createFunctor(&SettingsConfigFile::setFilename, this), "setSettingsFile"); 435 CommandExecutor::addConsoleCommandShortcut(command); 436 command = createConsoleCommand(createFunctor(&SettingsConfigFile::config, this), "config"); 437 CommandExecutor::addConsoleCommandShortcut(command).argumentCompleter(0, autocompletion::settingssections()).argumentCompleter(1, autocompletion::settingsentries()).argumentCompleter(2, autocompletion::settingsvalue()); 438 command = createConsoleCommand(createFunctor(&SettingsConfigFile::tconfig, this), "tconfig"); 439 CommandExecutor::addConsoleCommandShortcut(command).argumentCompleter(0, autocompletion::settingssections()).argumentCompleter(1, autocompletion::settingsentries()).argumentCompleter(2, autocompletion::settingsvalue()); 440 command = createConsoleCommand(createFunctor(&SettingsConfigFile::getConfig, this), "getConfig"); 441 CommandExecutor::addConsoleCommandShortcut(command).argumentCompleter(0, autocompletion::settingssections()).argumentCompleter(1, autocompletion::settingsentries()); 444 _ModifyConsoleCommand(__CC_load_name).setObject(this); 445 _ModifyConsoleCommand(__CC_setFilename_name).setObject(this); 446 _ModifyConsoleCommand(__CC_config_name).setObject(this); 447 _ModifyConsoleCommand(__CC_tconfig_name).setObject(this); 448 _ModifyConsoleCommand(__CC_getConfig_name).setObject(this); 442 449 } 443 450 444 451 SettingsConfigFile::~SettingsConfigFile() 445 452 { 453 _ModifyConsoleCommand(__CC_load_name).setObject(0); 454 _ModifyConsoleCommand(__CC_setFilename_name).setObject(0); 455 _ModifyConsoleCommand(__CC_config_name).setObject(0); 456 _ModifyConsoleCommand(__CC_tconfig_name).setObject(0); 457 _ModifyConsoleCommand(__CC_getConfig_name).setObject(0); 446 458 } 447 459 -
code/branches/consolecommands3/src/libraries/core/Core.cc
r7207 r7219 66 66 #include "Language.h" 67 67 #include "LuaState.h" 68 #include "command/Co mmandExecutor.h"68 #include "command/ConsoleCommand.h" 69 69 #include "command/IOConsole.h" 70 70 #include "command/TclBind.h" … … 88 88 : identifierDestroyer_(Identifier::destroyAllIdentifiers) 89 89 // Cleanup guard for external console commands that don't belong to an Identifier 90 , consoleCommandDestroyer_( CommandExecutor::destroyExternalCommands)90 , consoleCommandDestroyer_(_ConsoleCommand::destroyAll) 91 91 , bGraphicsLoaded_(false) 92 92 , bStartIOConsole_(true) -
code/branches/consolecommands3/src/libraries/core/CorePrereqs.h
r7212 r7219 194 194 class ArgumentCompletionListElement; 195 195 class CommandEvaluation; 196 class ConsoleCommand;196 class _ConsoleCommand; 197 197 class Executor; 198 198 template <class T> -
code/branches/consolecommands3/src/libraries/core/GUIManager.cc
r7204 r7219 71 71 static void key_esc() 72 72 { GUIManager::getInstance().keyESC(); } 73 SetConsoleCommandShortcutExternAlias(key_esc, "keyESC");73 _SetConsoleCommand("keyESC", &key_esc); 74 74 75 75 class CEGUILogger : public CEGUI::DefaultLogger … … 99 99 GUIManager* GUIManager::singletonPtr_s = 0; 100 100 101 SetConsoleCommandShortcut(GUIManager, showGUI).accessLevel(AccessLevel::User).defaultValue(1, false).defaultValue(2, true);102 SetConsoleCommandShortcut(GUIManager, hideGUI).accessLevel(AccessLevel::User);101 _SetConsoleCommand("showGUI", &GUIManager::showGUI).defaultValue(1, false).defaultValue(2, true); 102 _SetConsoleCommand("hideGUI", &GUIManager::hideGUI); 103 103 104 104 /** -
code/branches/consolecommands3/src/libraries/core/Game.cc
r7204 r7219 57 57 static void stop_game() 58 58 { Game::getInstance().stop(); } 59 SetConsoleCommandShortcutExternAlias(stop_game, "exit");59 _SetConsoleCommand("exit", &stop_game); 60 60 static void printFPS() 61 61 { COUT(0) << Game::getInstance().getAvgFPS() << std::endl; } 62 SetConsoleCommandShortcutExternAlias(printFPS, "printFPS");62 _SetConsoleCommand("printFPS", &printFPS); 63 63 static void printTickTime() 64 64 { COUT(0) << Game::getInstance().getAvgTickTime() << std::endl; } 65 SetConsoleCommandShortcutExternAlias(printTickTime, "printTickTime");65 _SetConsoleCommand("printTickTime", &printTickTime); 66 66 67 67 std::map<std::string, GameStateInfo> Game::gameStateDeclarations_s; -
code/branches/consolecommands3/src/libraries/core/GraphicsManager.cc
r7204 r7219 65 65 namespace orxonox 66 66 { 67 static const std::string __CC_printScreen_name = "printScreen"; 68 _DeclareConsoleCommand(__CC_printScreen_name, &prototype::void__void); 69 67 70 class OgreWindowEventListener : public Ogre::WindowEventListener 68 71 { … … 131 134 132 135 Ogre::WindowEventUtilities::removeWindowEventListener(renderWindow_, ogreWindowEventListener_.get()); 133 // TODO: Destroy the console command136 _ModifyConsoleCommand(__CC_printScreen_name).resetFunction(); 134 137 135 138 // Undeclare the resources … … 321 324 322 325 // add console commands 323 ccPrintScreen_ = createConsoleCommand(createFunctor(&GraphicsManager::printScreen, this), "printScreen"); 324 CommandExecutor::addConsoleCommandShortcut(ccPrintScreen_); 326 _ModifyConsoleCommand(__CC_printScreen_name).setFunction(&GraphicsManager::printScreen, this); 325 327 } 326 328 -
code/branches/consolecommands3/src/libraries/core/GraphicsManager.h
r6417 r7219 114 114 int ogreLogLevelCritical_; //!< Corresponding Orxonox debug level for LL_CRITICAL 115 115 116 // console commands117 ConsoleCommand* ccPrintScreen_;118 119 116 static GraphicsManager* singletonPtr_s; //!< Pointer to the Singleton 120 117 }; -
code/branches/consolecommands3/src/libraries/core/command/ConsoleCommandCompilation.cc
r7202 r7219 37 37 #include "util/StringUtils.h" 38 38 #include "ConsoleCommand.h" 39 #include "CommandExecutor.h" 39 40 40 41 namespace orxonox 41 42 { 42 SetConsoleCommandShortcutExtern(source).argumentCompleter(0, autocompletion::files());43 SetConsoleCommandShortcutExtern(echo);44 SetConsoleCommandShortcutExtern(puts);43 _SetConsoleCommand("source", source).argumentCompleter(0, autocompletion::files()); 44 _SetConsoleCommand("echo", echo); 45 _SetConsoleCommand("puts", puts); 45 46 46 SetConsoleCommandShortcutExtern(read).argumentCompleter(0, autocompletion::files());47 SetConsoleCommandShortcutExtern(append).argumentCompleter(0, autocompletion::files());48 SetConsoleCommandShortcutExtern(write).argumentCompleter(0, autocompletion::files());47 _SetConsoleCommand("read", read).argumentCompleter(0, autocompletion::files()); 48 _SetConsoleCommand("append", append).argumentCompleter(0, autocompletion::files()); 49 _SetConsoleCommand("write", write).argumentCompleter(0, autocompletion::files()); 49 50 50 SetConsoleCommandShortcutExtern(calculate);51 _SetConsoleCommand("calculate", calculate); 51 52 52 53 void source(const std::string& filename) -
code/branches/consolecommands3/src/libraries/core/command/IRC.cc
r7203 r7219 42 42 static const unsigned int IRC_TCL_THREADID = 1421421421; 43 43 44 SetConsoleCommand(IRC, say, true).accessLevel(AccessLevel::User);45 SetConsoleCommand(IRC, msg, false).accessLevel(AccessLevel::User);46 SetConsoleCommand(IRC, nick, false).accessLevel(AccessLevel::User);44 _SetConsoleCommand("IRC", "say", &IRC::say); 45 _SetConsoleCommand("IRC", "msg", &IRC::msg); 46 _SetConsoleCommand("IRC", "nick", &IRC::nick); 47 47 48 48 IRC::IRC() -
code/branches/consolecommands3/src/libraries/core/command/Shell.cc
r7203 r7219 40 40 namespace orxonox 41 41 { 42 SetConsoleCommandShortcut(OutputHandler, log);43 SetConsoleCommandShortcut(OutputHandler, error);44 SetConsoleCommandShortcut(OutputHandler,warning);45 SetConsoleCommandShortcut(OutputHandler, info);46 SetConsoleCommandShortcut(OutputHandler, debug);42 _SetConsoleCommand("log", OutputHandler::log ); 43 _SetConsoleCommand("error", OutputHandler::error ); 44 _SetConsoleCommand("warning", OutputHandler::warning); 45 _SetConsoleCommand("info", OutputHandler::info ); 46 _SetConsoleCommand("debug", OutputHandler::debug ); 47 47 48 48 Shell::Shell(const std::string& consoleName, bool bScrollable) -
code/branches/consolecommands3/src/libraries/core/command/TclBind.cc
r7203 r7219 44 44 namespace orxonox 45 45 { 46 SetConsoleCommandShortcut(TclBind,tcl);47 SetConsoleCommandShortcut(TclBind,bgerror);46 _SetConsoleCommand("tcl", &TclBind::tcl); 47 _SetConsoleCommand("bgerror", &TclBind::bgerror); 48 48 49 49 TclBind* TclBind::singletonPtr_s = 0; -
code/branches/consolecommands3/src/libraries/core/command/TclThreadManager.cc
r7203 r7219 50 50 const float TCLTHREADMANAGER_MAX_CPU_USAGE = 0.50f; 51 51 52 SetConsoleCommandShortcutAlias(TclThreadManager, execute, "tclexecute").argumentCompleter(0, autocompletion::tclthreads());53 SetConsoleCommandShortcutAlias(TclThreadManager, query, "tclquery").argumentCompleter(0, autocompletion::tclthreads());54 SetConsoleCommand(TclThreadManager, create, false);55 SetConsoleCommand(TclThreadManager, destroy, false).argumentCompleter(0, autocompletion::tclthreads());56 SetConsoleCommand(TclThreadManager, execute, false).argumentCompleter(0, autocompletion::tclthreads());57 SetConsoleCommand(TclThreadManager, query, false).argumentCompleter(0, autocompletion::tclthreads());58 SetConsoleCommand(TclThreadManager, source, false).argumentCompleter(0, autocompletion::tclthreads());52 _SetConsoleCommand("tclexecute", &TclThreadManager::execute).argumentCompleter(0, autocompletion::tclthreads()); 53 _SetConsoleCommand("tclquery", &TclThreadManager::query ).argumentCompleter(0, autocompletion::tclthreads()); 54 _SetConsoleCommand("TclThreadManager", "create", &TclThreadManager::create); 55 _SetConsoleCommand("TclThreadManager", "destroy", &TclThreadManager::destroy).argumentCompleter(0, autocompletion::tclthreads()); 56 _SetConsoleCommand("TclThreadManager", "execute", &TclThreadManager::execute).argumentCompleter(0, autocompletion::tclthreads()); 57 _SetConsoleCommand("TclThreadManager", "query", &TclThreadManager::query ).argumentCompleter(0, autocompletion::tclthreads()); 58 _SetConsoleCommand("TclThreadManager", "source", &TclThreadManager::source ).argumentCompleter(0, autocompletion::tclthreads()); 59 59 60 60 /** -
code/branches/consolecommands3/src/libraries/core/input/InputManager.cc
r7204 r7219 62 62 SetCommandLineSwitch(keyboard_no_grab).information("Whether not to exclusively grab the keyboard"); 63 63 64 static const std::string __CC_InputManager_name = "InputManager"; 65 static const std::string __CC_calibrate_name = "calibrate"; 66 static const std::string __CC_reload_name = "reload"; 67 68 _SetConsoleCommand(__CC_InputManager_name, __CC_calibrate_name, &InputManager::calibrate).addShortcut(); 69 _SetConsoleCommand(__CC_InputManager_name, __CC_reload_name, &InputManager::reload ); 70 64 71 // Abuse of this source file for the InputHandler 65 72 InputHandler InputHandler::EMPTY; … … 118 125 this->updateActiveStates(); 119 126 120 // calibrate console command 121 this->getIdentifier()->addConsoleCommand(createConsoleCommand(createFunctor(&InputManager::calibrate, this), "calibrate"), true); 122 // reload console command 123 this->getIdentifier()->addConsoleCommand(createConsoleCommand(createFunctor(&InputManager::reload, this), "reload"), false); 127 _ModifyConsoleCommand(__CC_InputManager_name, __CC_calibrate_name).setObject(this); 128 _ModifyConsoleCommand(__CC_InputManager_name, __CC_reload_name).setObject(this); 124 129 125 130 CCOUT(4) << "Construction complete." << std::endl; … … 287 292 if (!(internalState_ & Bad)) 288 293 this->destroyDevices(); 294 295 // Reset console commands 296 _ModifyConsoleCommand(__CC_InputManager_name, __CC_calibrate_name).setObject(0); 297 _ModifyConsoleCommand(__CC_InputManager_name, __CC_reload_name).setObject(0); 289 298 290 299 CCOUT(3) << "Destruction complete." << std::endl; -
code/branches/consolecommands3/src/libraries/core/input/KeyBinderManager.cc
r7207 r7219 43 43 ManageScopedSingleton(KeyBinderManager, ScopeID::Graphics, false); 44 44 45 static const std::string __CC_keybind_name = "keybind"; 46 static const std::string __CC_tkeybind_name = "tkeybind"; 47 static const std::string __CC_unbind_name = "unbind"; 48 static const std::string __CC_tunbind_name = "tunbind"; 49 50 _SetConsoleCommand(__CC_keybind_name, &KeyBinderManager::keybind).defaultValues(""); 51 _SetConsoleCommand(__CC_tkeybind_name, &KeyBinderManager::tkeybind).defaultValues(""); 52 _SetConsoleCommand(__CC_unbind_name, &KeyBinderManager::unbind).defaultValues(""); 53 _SetConsoleCommand(__CC_tunbind_name, &KeyBinderManager::tunbind).defaultValues(""); 54 45 55 KeyBinderManager::KeyBinderManager() 46 56 : currentBinder_(NULL) … … 52 62 53 63 // keybind console commands 54 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&KeyBinderManager::keybind, this), "keybind" )) 55 .defaultValues(""); 56 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&KeyBinderManager::tkeybind, this), "tkeybind")) 57 .defaultValues(""); 58 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&KeyBinderManager::unbind, this), "unbind")) 59 .defaultValues(""); 60 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&KeyBinderManager::tunbind, this), "tunbind")) 61 .defaultValues(""); 64 _ModifyConsoleCommand(__CC_keybind_name ).setObject(this); 65 _ModifyConsoleCommand(__CC_tkeybind_name).setObject(this); 66 _ModifyConsoleCommand(__CC_unbind_name ).setObject(this); 67 _ModifyConsoleCommand(__CC_tunbind_name ).setObject(this); 62 68 63 69 // Load default key binder … … 70 76 for (std::map<std::string, KeyBinder*>::const_iterator it = this->binders_.begin(); it != this->binders_.end(); ++it) 71 77 delete it->second; 78 79 // Reset console commands 80 _ModifyConsoleCommand(__CC_keybind_name ).setObject(0); 81 _ModifyConsoleCommand(__CC_tkeybind_name).setObject(0); 82 _ModifyConsoleCommand(__CC_unbind_name ).setObject(0); 83 _ModifyConsoleCommand(__CC_tunbind_name ).setObject(0); 72 84 } 73 85 -
code/branches/consolecommands3/src/libraries/core/input/KeyDetector.cc
r7207 r7219 38 38 namespace orxonox 39 39 { 40 std::string KeyDetector::callbackCommand_s = "KeyDetectorKeyPressed";41 40 ManageScopedSingleton(KeyDetector, ScopeID::Graphics, false); 41 42 static const std::string __CC_KeyDetector_callback_name = "KeyDetectorKeyPressed"; 43 _DeclareConsoleCommand(__CC_KeyDetector_callback_name, &prototype::void__string); 42 44 43 45 KeyDetector::KeyDetector() … … 46 48 RegisterObject(KeyDetector); 47 49 48 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&KeyDetector::callback, this), callbackCommand_s)); 50 _ModifyConsoleCommand(__CC_KeyDetector_callback_name).setFunction(&KeyDetector::callback, this); 51 49 52 this->assignCommands(); 50 53 … … 59 62 inputState_->setHandler(NULL); 60 63 InputManager::getInstance().destroyState("detector"); 64 _ModifyConsoleCommand(__CC_KeyDetector_callback_name).resetFunction(); 61 65 } 62 66 … … 65 69 // Assign every button/axis the same command, but with its name as argument 66 70 for (std::map<std::string, Button*>::const_iterator it = allButtons_.begin(); it != allButtons_.end(); ++it) 67 it->second->parse( callbackCommand_s+ ' ' + it->second->groupName_ + "." + it->second->name_);71 it->second->parse(__CC_KeyDetector_callback_name + ' ' + it->second->groupName_ + "." + it->second->name_); 68 72 } 69 73 -
code/branches/consolecommands3/src/libraries/core/input/KeyDetector.h
r7198 r7219 57 57 FunctorPtr callbackFunction_; 58 58 InputState* inputState_; 59 static std::string callbackCommand_s;60 59 static KeyDetector* singletonPtr_s; 61 60 };
Note: See TracChangeset
for help on using the changeset viewer.