Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1120 for code


Ignore:
Timestamp:
Apr 21, 2008, 6:59:07 PM (17 years ago)
Author:
rgrieder
Message:
  • merged calculator into trunk
Location:
code/trunk/src
Files:
2 edited
2 copied

Legend:

Unmodified
Added
Removed
  • code/trunk/src/orxonox/Orxonox.cc

    r1092 r1120  
    5454//#include "util/Sleep.h"
    5555#include "util/ArgReader.h"
     56#include "util/ExprParser.h"
    5657
    5758// core
     
    123124      InputBuffer* ib_;
    124125  };
     126
     127  class Calculator
     128  {
     129  public:
     130    static void calculate(const std::string& calculation)
     131    {
     132      ExprParser expr(calculation);
     133      if (expr.getSuccess())
     134      {
     135        if (expr.getResult() == 42.0)
     136          std::cout << "Greetings from the restaurant at the end of the universe." << std::endl;
     137        // FIXME: insert modifier to display in full precision
     138        std::cout << "Result is: " << expr.getResult() << std::endl;
     139        if (expr.getRemains() != "")
     140          std::cout << "Warning: Expression could not be parsed to the end! Remains: '"
     141              << expr.getRemains() << "'" << std::endl;
     142      }
     143      else
     144        std::cout << "Cannot calculate expression: Parse error" << std::endl;
     145    }
     146  };
     147  ConsoleCommandShortcut(Calculator, calculate, AccessLevel::None);
    125148
    126149  /**
     
    410433      return;
    411434    }
     435    Ogre::Root& ogreRoot = Ogre::Root::getSingleton();
     436
    412437
    413438    // Contains the times of recently fired events
     
    429454          {
    430455                  // Pump messages in all registered RenderWindows
     456      // This calls the WindowEventListener objects.
    431457      Ogre::WindowEventUtilities::messagePump();
    432458
     
    452478      // don't forget to call _fireFrameStarted in ogre to make sure
    453479      // everything goes smoothly
    454       Ogre::Root::getSingleton()._fireFrameStarted(evt);
     480      ogreRoot._fireFrameStarted(evt);
    455481
    456482      // server still renders at the moment
    457483      //if (mode_ != SERVER)
    458       Ogre::Root::getSingleton()._updateAllRenderTargets(); // only render in non-server mode
     484      ogreRoot._updateAllRenderTargets(); // only render in non-server mode
    459485
    460486      // get current time
     
    466492
    467493      // again, just to be sure ogre works fine
    468       Ogre::Root::getSingleton()._fireFrameEnded(evt);
     494      ogreRoot._fireFrameEnded(evt);
    469495          }
    470496  }
  • code/trunk/src/util/CMakeLists.txt

    r1115 r1120  
    77  Clipboard.cc
    88  SubString.cc
     9  ExprParser.cc
    910  MultiTypePrimitive.cc
    1011  MultiTypeString.cc
Note: See TracChangeset for help on using the changeset viewer.