Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 21, 2008, 1:33:42 AM (16 years ago)
Author:
landauf
Message:

big commit, but not much changes in code:

  • put CommandEvaluation into it's own .cc and .h files
  • put some basic ConsoleCommands into ConsoleCommandCompilation.cc and .h
  • created a new class, ConsoleCommand, inheriting from ExecutorStatic, implementing all command-related features that were located in the Executor until now (at the moment only accessLevel_, but more will come - from reto and me)
  • renamed ConsoleCommand-macros to SetConsoleCommand (all related macros were changed the same way)
  • added a new command named "killdelays", that kills all delayed commands. helpful to stop disco ;)
Location:
code/branches/console/src/orxonox
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • code/branches/console/src/orxonox/Orxonox.cc

    r1334 r1341  
    5454//#include "util/Sleep.h"
    5555#include "util/ArgReader.h"
    56 #include "util/ExprParser.h"
    5756
    5857// core
     
    6059#include "core/ConsoleCommand.h"
    6160#include "core/Debug.h"
    62 #include "core/Factory.h"
    6361#include "core/Loader.h"
    6462#include "core/Tickable.h"
    65 #include "core/InputBuffer.h"
    6663#include "core/InputManager.h"
    6764
     
    7471
    7572// objects and tools
    76 #include "tools/Timer.h"
    7773#include "hud/HUD.h"
    7874//#include "console/InGameConsole.h"
     
    8581namespace orxonox
    8682{
    87   ConsoleCommand(Orxonox, exit, AccessLevel::None, true);
    88   ConsoleCommand(Orxonox, slomo, AccessLevel::Offline, true).setDefaultValue(0, 1.0);
    89   ConsoleCommand(Orxonox, setTimeFactor, AccessLevel::Offline, false).setDefaultValue(0, 1.0);
    90 
    91   class Calculator
    92   {
    93   public:
    94     static float calculate(const std::string& calculation)
    95     {
    96       ExprParser expr(calculation);
    97       if (expr.getSuccess())
    98       {
    99         if (expr.getResult() == 42.0)
    100           std::cout << "Greetings from the restaurant at the end of the universe." << std::endl;
    101         // FIXME: insert modifier to display in full precision
    102         std::cout << "Result is: " << expr.getResult() << std::endl;
    103         if (expr.getRemains() != "")
    104           std::cout << "Warning: Expression could not be parsed to the end! Remains: '"
    105               << expr.getRemains() << "'" << std::endl;
    106         return expr.getResult();
    107       }
    108       else
    109       {
    110         std::cout << "Cannot calculate expression: Parse error" << std::endl;
    111         return 0;
    112       }
    113     }
    114   };
    115   ConsoleCommandShortcut(Calculator, calculate, AccessLevel::None);
     83  SetConsoleCommand(Orxonox, exit, true);
     84  SetConsoleCommand(Orxonox, slomo, true).setDefaultValue(0, 1.0).setAccessLevel(AccessLevel::Offline);
     85  SetConsoleCommand(Orxonox, setTimeFactor, false).setDefaultValue(0, 1.0).setAccessLevel(AccessLevel::Offline);
    11686
    11787  /**
  • code/branches/console/src/orxonox/console/InGameConsole.cc

    r1338 r1341  
    4949namespace orxonox
    5050{
    51     ConsoleCommand(InGameConsole, openConsole, AccessLevel::None, true);
    52     ConsoleCommand(InGameConsole, closeConsole, AccessLevel::None, true);
     51    SetConsoleCommand(InGameConsole, openConsole, true);
     52    SetConsoleCommand(InGameConsole, closeConsole, true);
    5353
    5454    using namespace Ogre;
  • code/branches/console/src/orxonox/objects/Ambient.cc

    r1064 r1341  
    4747namespace orxonox
    4848{
    49     ConsoleCommand(Ambient, setAmbientLightTest, AccessLevel::Offline, false).setDefaultValues(ColourValue(1, 1, 1, 1));
     49    SetConsoleCommand(Ambient, setAmbientLightTest, false).setDefaultValues(ColourValue(1, 1, 1, 1)).setAccessLevel(AccessLevel::Offline);
    5050
    5151    CreateFactory(Ambient);
  • code/branches/console/src/orxonox/objects/SpaceShip.cc

    r1064 r1341  
    5353namespace orxonox
    5454{
    55     ConsoleCommand(SpaceShip, setMaxSpeedTest, AccessLevel::Debug, false);
    56     ConsoleCommandGeneric(test1, SpaceShip, createExecutor(createFunctor(&SpaceShip::setMaxSpeedTest), "setMaxSpeed", AccessLevel::Debug), false);
    57     ConsoleCommandGeneric(test2, SpaceShip, createExecutor(createFunctor(&SpaceShip::setMaxSpeedTest), "setMaxBlubber", AccessLevel::Debug), false);
    58     ConsoleCommandGeneric(test3, SpaceShip, createExecutor(createFunctor(&SpaceShip::setMaxSpeedTest), "setRofl", AccessLevel::Debug), false);
     55    SetConsoleCommand(SpaceShip, setMaxSpeedTest, false).setAccessLevel(AccessLevel::Debug);
     56    SetConsoleCommandGeneric(test1, SpaceShip, createExecutor(createFunctor(&SpaceShip::setMaxSpeedTest), "setMaxSpeed"), false).setAccessLevel(AccessLevel::Debug);
     57    SetConsoleCommandGeneric(test2, SpaceShip, createExecutor(createFunctor(&SpaceShip::setMaxSpeedTest), "setMaxBlubber"), false).setAccessLevel(AccessLevel::Debug);
     58    SetConsoleCommandGeneric(test3, SpaceShip, createExecutor(createFunctor(&SpaceShip::setMaxSpeedTest), "setRofl"), false).setAccessLevel(AccessLevel::Debug);
    5959
    6060    CreateFactory(SpaceShip);
  • code/branches/console/src/orxonox/tools/Timer.cc

    r1063 r1341  
    2727 */
    2828
     29#include <set>
     30
    2931#include "OrxonoxStableHeaders.h"
    3032#include "Timer.h"
     
    3739namespace orxonox
    3840{
    39     ConsoleCommandShortcutExtern(delay, AccessLevel::None);
     41    SetConsoleCommandShortcutExtern(delay);
     42    SetConsoleCommandShortcutExtern(killdelays);
     43
     44    static std::set<StaticTimer*> delaytimerset;
    4045
    4146    /**
     
    4752    {
    4853        StaticTimer *delaytimer = new StaticTimer();
     54        delaytimerset.insert(delaytimer);
     55
    4956        ExecutorStatic* delayexecutor = createExecutor(createFunctor(&executeDelayedCommand));
    5057        delayexecutor->setDefaultValues(delaytimer, command);
     
    6168        CommandExecutor::execute(command);
    6269        delete timer;
     70        delaytimerset.erase(timer);
     71    }
     72
     73    /**
     74        @brief Kills all delayed commands.
     75    */
     76    void killdelays()
     77    {
     78        for (std::set<StaticTimer*>::iterator it = delaytimerset.begin(); it != delaytimerset.end(); ++it)
     79            delete (*it);
     80
     81        delaytimerset.clear();
    6382    }
    6483
  • code/branches/console/src/orxonox/tools/Timer.h

    r1056 r1341  
    6969    class StaticTimer;
    7070    void delay(float delay, const std::string& command);
     71    void killdelays();
    7172    void executeDelayedCommand(StaticTimer* timer, const std::string& command);
    7273
Note: See TracChangeset for help on using the changeset viewer.