Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 31, 2010, 3:37:40 AM (14 years ago)
Author:
landauf
Message:

merged consolecommands3 branch back to trunk.

note: the console command interface has changed completely, but the documentation is not yet up to date. just copy an existing command and change it to your needs, it's pretty self-explanatory. also the include files related to console commands are now located in core/command/. in the game it should work exactly like before, except for some changes in the auto-completion.

Location:
code/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/gamestates/GSGraphics.cc

    r7163 r7284  
    3535#include "GSGraphics.h"
    3636
    37 #include "core/CommandExecutor.h"
    38 #include "core/ConsoleCommand.h"
    3937#include "core/Game.h"
    4038#include "core/GUIManager.h"
     39#include "core/command/ConsoleCommand.h"
     40#include "core/command/CommandExecutor.h"
    4141
    4242namespace orxonox
  • code/trunk/src/orxonox/gamestates/GSLevel.cc

    r6746 r7284  
    3636#include "core/input/InputState.h"
    3737#include "core/input/KeyBinderManager.h"
    38 #include "core/ConsoleCommand.h"
    3938#include "core/Game.h"
    4039#include "core/GameMode.h"
     
    4241#include "core/Loader.h"
    4342#include "core/XMLFile.h"
     43#include "core/command/ConsoleCommand.h"
    4444
    4545#include "LevelManager.h"
  • code/trunk/src/orxonox/gamestates/GSMainMenu.cc

    r6746 r7284  
    3333#include "core/input/KeyBinderManager.h"
    3434#include "core/Game.h"
    35 #include "core/ConsoleCommand.h"
    3635#include "core/ConfigValueIncludes.h"
    3736#include "core/CoreIncludes.h"
    3837#include "core/GraphicsManager.h"
    3938#include "core/GUIManager.h"
     39#include "core/command/ConsoleCommand.h"
    4040#include "Scene.h"
    4141#include "sound/AmbientSound.h"
     
    4848    DeclareGameState(GSMainMenu, "mainMenu", false, true);
    4949
     50    static const std::string __CC_startStandalone_name      = "startGame";
     51    static const std::string __CC_startServer_name          = "startServer";
     52    static const std::string __CC_startClient_name          = "startClient";
     53    static const std::string __CC_startDedicated_name       = "startDedicated";
     54    static const std::string __CC_startMainMenu_name        = "startMainMenu";
     55    static const std::string __CC_setMainMenuSoundPath_name = "setMMSoundPath";
     56
     57    SetConsoleCommand(__CC_startStandalone_name,      &GSMainMenu::startStandalone).deactivate();
     58    SetConsoleCommand(__CC_startServer_name,          &GSMainMenu::startServer    ).deactivate();
     59    SetConsoleCommand(__CC_startClient_name,          &GSMainMenu::startClient    ).deactivate();
     60    SetConsoleCommand(__CC_startDedicated_name,       &GSMainMenu::startDedicated ).deactivate();
     61    SetConsoleCommand(__CC_startMainMenu_name,        &GSMainMenu::startMainMenu  ).deactivate();
     62    SetConsoleCommand(__CC_setMainMenuSoundPath_name, &GSMainMenu::setMainMenuSoundPath).hide();
     63
    5064    GSMainMenu::GSMainMenu(const GameStateInfo& info)
    5165        : GameState(info)
     
    89103        InputManager::getInstance().enterState("MainMenuHackery");
    90104
    91         CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&GSMainMenu::startStandalone), "startGame"));
    92         CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&GSMainMenu::startServer), "startServer"));
    93         CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&GSMainMenu::startClient), "startClient"));
    94         CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&GSMainMenu::startDedicated), "startDedicated"));
    95         CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&GSMainMenu::startMainMenu), "startMainMenu"));
    96 
    97         // create command to change sound path
    98         CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&GSMainMenu::setMainMenuSoundPath, this), "setMMSoundPath"));
     105        ModifyConsoleCommand(__CC_startStandalone_name).activate();
     106        ModifyConsoleCommand(__CC_startServer_name    ).activate();
     107        ModifyConsoleCommand(__CC_startClient_name    ).activate();
     108        ModifyConsoleCommand(__CC_startDedicated_name ).activate();
     109        ModifyConsoleCommand(__CC_startMainMenu_name  ).activate();
     110        ModifyConsoleCommand(__CC_setMainMenuSoundPath_name).setObject(this);
    99111
    100112        KeyBinderManager::getInstance().setToDefault();
     
    122134        GUIManager::hideGUI("MainMenu");
    123135        GraphicsManager::getInstance().setCamera(0);
     136
     137        ModifyConsoleCommand(__CC_startStandalone_name).deactivate();
     138        ModifyConsoleCommand(__CC_startServer_name    ).deactivate();
     139        ModifyConsoleCommand(__CC_startClient_name    ).deactivate();
     140        ModifyConsoleCommand(__CC_startDedicated_name ).deactivate();
     141        ModifyConsoleCommand(__CC_startMainMenu_name  ).deactivate();
     142        ModifyConsoleCommand(__CC_setMainMenuSoundPath_name).setObject(0);
    124143    }
    125144
  • code/trunk/src/orxonox/gamestates/GSRoot.cc

    r7172 r7284  
    3131#include "util/Clock.h"
    3232#include "core/BaseObject.h"
    33 #include "core/ConsoleCommand.h"
    3433#include "core/Game.h"
    3534#include "core/GameMode.h"
     35#include "core/command/ConsoleCommand.h"
    3636#include "network/NetworkFunction.h"
    3737#include "tools/Timer.h"
     
    4141{
    4242    DeclareGameState(GSRoot, "root", false, false);
    43     SetConsoleCommandShortcut(GSRoot, printObjects);
     43
     44    static const std::string __CC_setTimeFactor_name = "setTimeFactor";
     45    static const std::string __CC_pause_name = "pause";
     46
     47    SetConsoleCommand("printObjects", &GSRoot::printObjects).hide();
     48    SetConsoleCommand(__CC_setTimeFactor_name, &GSRoot::setTimeFactor).accessLevel(AccessLevel::Master).defaultValues(1.0);
     49    SetConsoleCommand(__CC_pause_name,         &GSRoot::pause        ).accessLevel(AccessLevel::Master);
    4450
    4551    registerStaticNetworkFunction(&TimeFactorListener::setTimeFactor);
     
    7682        TimeFactorListener::setTimeFactor(1.0f);
    7783
    78         // time factor console command
    79         ConsoleCommand* command = createConsoleCommand(createFunctor(&GSRoot::setTimeFactor, this), "setTimeFactor");
    80         CommandExecutor::addConsoleCommandShortcut(command).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);
    81 
    82         // time factor console command
    83         command = createConsoleCommand(createFunctor(&GSRoot::pause, this), "pause");
    84         CommandExecutor::addConsoleCommandShortcut(command).accessLevel(AccessLevel::Offline);
     84        ModifyConsoleCommand(__CC_setTimeFactor_name).setObject(this);
     85        ModifyConsoleCommand(__CC_pause_name).setObject(this);
    8586    }
    8687
    8788    void GSRoot::deactivate()
    8889    {
     90        ModifyConsoleCommand(__CC_setTimeFactor_name).setObject(0);
     91        ModifyConsoleCommand(__CC_pause_name).setObject(0);
    8992    }
    9093
Note: See TracChangeset for help on using the changeset viewer.