Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1334


Ignore:
Timestamp:
May 20, 2008, 1:48:40 AM (16 years ago)
Author:
landauf
Message:
  • added colored output in the InGameConsole, depending on the output level (error = red, …).
  • increased performance of InGameConsole and Shell
Location:
code/branches/console/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • code/branches/console/src/core/InputBuffer.cc

    r1317 r1334  
    163163    bool InputBuffer::keyPressed(const OIS::KeyEvent &e)
    164164    {
     165        if (this->keyboard_->isModifierDown(OIS::Keyboard::Alt) && e.key == OIS::KC_TAB)
     166            return true;
     167
    165168        for (std::list<InputBufferListenerTuple>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
    166169        {
  • code/branches/console/src/core/OutputBuffer.cc

    r1322 r1334  
    7878
    7979        bool eof = this->stream_.eof();
     80        bool fail = this->stream_.fail();
    8081
    8182        if (eof)
     
    8586        }
    8687
    87         return (!eof);
     88        return (!eof && !fail);
    8889    }
    8990
  • code/branches/console/src/core/Script.cc

    r1255 r1334  
    6868    output_ += str;
    6969//    COUT(4) << "Lua_output!:" << std::endl << str << std::endl << "***" << std::endl;
    70     COUT(5) << str << std::endl;
     70    COUT(5) << str;
    7171  }
    7272
  • code/branches/console/src/core/Shell.cc

    r1327 r1334  
    4848        this->historyOffset_ = 0;
    4949        this->finishedLastLine_ = true;
     50        this->bAddOutputLevel_ = false;
    5051
    5152        this->clearLines();
     
    131132    }
    132133
    133     void Shell::addLine(const std::string& line, unsigned int level)
     134    void Shell::addLine(const std::string& line, int level)
    134135    {
    135136        int original_level = OutputHandler::getOutStream().getOutputLevel();
     
    196197            if (this->finishedLastLine_)
    197198            {
     199                if (this->bAddOutputLevel_)
     200                    output.insert(0, 1, (char)OutputHandler::getOutStream().getOutputLevel());
     201
    198202                this->lines_.insert(this->lines_.begin(), output);
    199203
     
    239243    void Shell::hintandcomplete()
    240244    {
    241         this->addLine(CommandExecutor::hint(this->inputBuffer_.get()), 0);
     245        this->addLine(CommandExecutor::hint(this->inputBuffer_.get()), -1);
    242246        this->inputBuffer_.set(CommandExecutor::complete(this->inputBuffer_.get()));
    243247
  • code/branches/console/src/core/Shell.h

    r1326 r1334  
    8383            std::list<std::string>::const_iterator getEndIterator() const;
    8484
    85             void addLine(const std::string& line, unsigned int level);
     85            void addLine(const std::string& line, int level);
    8686            void clearLines();
    8787
     
    9090            inline unsigned int getScrollPosition() const
    9191                { return this->scrollPosition_; }
     92
     93            inline void addOutputLevel(bool bAddOutputLevel)
     94                { this->bAddOutputLevel_ = bAddOutputLevel; }
    9295
    9396        private:
     
    127130            unsigned int historyPosition_;
    128131            unsigned int historyOffset_;
     132            bool bAddOutputLevel_;
    129133    };
    130134}
  • code/branches/console/src/orxonox/Orxonox.cc

    r1317 r1334  
    8888  ConsoleCommand(Orxonox, slomo, AccessLevel::Offline, true).setDefaultValue(0, 1.0);
    8989  ConsoleCommand(Orxonox, setTimeFactor, AccessLevel::Offline, false).setDefaultValue(0, 1.0);
    90 /*
    91   class Testconsole : public InputBufferListener
    92   {
    93     public:
    94       Testconsole(InputBuffer* ib) : ib_(ib) {}
    95       void listen() const
    96       {
    97         std::cout << "> " << this->ib_->get() << std::endl;
    98       }
    99       void execute() const
    100       {
    101         std::cout << ">> " << this->ib_->get() << std::endl;
    102         if (!CommandExecutor::execute(this->ib_->get()))
    103           std::cout << "Error" << std::endl;
    104         this->ib_->clear();
    105       }
    106       void hintandcomplete() const
    107       {
    108         std::cout << CommandExecutor::hint(this->ib_->get()) << std::endl;
    109         this->ib_->set(CommandExecutor::complete(this->ib_->get()));
    110       }
    111       void clear() const
    112       {
    113         this->ib_->clear();
    114       }
    115       void removeLast() const
    116       {
    117         this->ib_->removeBehindCursor();
    118       }
    119       void exit() const
    120       {
    121         CommandExecutor::execute("setInputMode 2");
    122       }
    123 
    124     private:
    125       InputBuffer* ib_;
    126   };
    127 */
     90
    12891  class Calculator
    12992  {
     
    421384  void Orxonox::startRenderLoop()
    422385  {
    423 
    424 //    InputBuffer* ib = new InputBuffer();
    425 //    InputManager::getSingleton().feedInputBuffer(ib);
    426     /*
    427     Testconsole* console = new Testconsole(ib);
    428     ib->registerListener(console, &Testconsole::listen, true);
    429     ib->registerListener(console, &Testconsole::execute, '\r', false);
    430     ib->registerListener(console, &Testconsole::hintandcomplete, '\t', true);
    431     ib->registerListener(console, &Testconsole::clear, '§', true);
    432     ib->registerListener(console, &Testconsole::removeLast, '\b', true);
    433     ib->registerListener(console, &Testconsole::exit, (char)0x1B, true);
    434     */
    435     /*
    436     orxonoxConsole_ = new InGameConsole(ib);
    437     ib->registerListener(orxonoxConsole_, &InGameConsole::listen, true);
    438     ib->registerListener(orxonoxConsole_, &InGameConsole::execute, '\r', false);
    439     ib->registerListener(orxonoxConsole_, &InGameConsole::hintandcomplete, '\t', true);
    440     ib->registerListener(orxonoxConsole_, &InGameConsole::clear, '§', true);
    441     ib->registerListener(orxonoxConsole_, &InGameConsole::removeLast, '\b', true);
    442     ib->registerListener(orxonoxConsole_, &InGameConsole::exit, (char)0x1B, true);
    443     */
    444386    // first check whether ogre root object has been created
    445387    if (Ogre::Root::getSingletonPtr() == 0)
     
    490432      for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; ++it)
    491433        it->tick((float)evt.timeSinceLastFrame * this->timefactor_);
    492 //      orxonoxConsole_->tick((float)evt.timeSinceLastFrame * this->timefactor_);
    493434
    494435      // don't forget to call _fireFrameStarted in ogre to make sure
  • code/branches/console/src/orxonox/Orxonox.h

    r1317 r1334  
    105105      // TODO: make this a config-value by creating a config class for orxonox
    106106      float                 frameSmoothingTime_;
    107 //      InGameConsole*        orxonoxConsole_;
    108107      HUD*                  orxonoxHUD_;
    109108      bool                  bAbort_;        //!< aborts the render loop if true
  • code/branches/console/src/orxonox/console/InGameConsole.cc

    r1327 r1334  
    4545#include "GraphicsEngine.h"
    4646
    47 #define LINES 20
     47#define LINES 30
    4848
    4949namespace orxonox
     
    7272        this->setConfigValues();
    7373
    74         Shell::getInstance().registerListener(this);
     74        Shell::getInstance().addOutputLevel(true);
    7575    }
    7676
     
    139139    void InGameConsole::lineAdded()
    140140    {
    141         this->linesChanged();
    142141        for (unsigned int i = LINES - 1; i > 1; --i)
     142        {
    143143            this->consoleOverlayTextAreas_[i]->setCaption(this->consoleOverlayTextAreas_[i - 1]->getCaption());
     144            this->consoleOverlayTextAreas_[i]->setColourTop(this->consoleOverlayTextAreas_[i - 1]->getColourTop());
     145            this->consoleOverlayTextAreas_[i]->setColourBottom(this->consoleOverlayTextAreas_[i - 1]->getColourBottom());
     146        }
    144147
    145148        this->onlyLastLineChanged();
     
    214217            this->consoleOverlayTextAreas_[i]->setMetricsMode(Ogre::GMM_PIXELS);
    215218            this->consoleOverlayTextAreas_[i]->setFontName("Console");
    216             this->consoleOverlayTextAreas_[i]->setCharHeight(20);
     219            this->consoleOverlayTextAreas_[i]->setCharHeight(18);
    217220            this->consoleOverlayTextAreas_[i]->setParameter("colour_top", "0.21 0.69 0.21");
    218221            this->consoleOverlayTextAreas_[i]->setLeft(8);
     
    267270                this->consoleOverlay_->hide();
    268271                this->active_ = false;
     272                Shell::getInstance().unregisterListener(this);
    269273            }
    270274            if (top >= 0)
     
    311315        {
    312316            this->consoleOverlayTextAreas_[i]->setWidth((int) this->windowW_ * InGameConsole::REL_WIDTH);
    313             this->consoleOverlayTextAreas_[i]->setTop((int) this->windowH_ * InGameConsole::REL_HEIGHT - 24 - 16*i);
     317            this->consoleOverlayTextAreas_[i]->setTop((int) this->windowH_ * InGameConsole::REL_HEIGHT - 24 - 14*i);
    314318        }
    315319    }
     
    320324    void InGameConsole::activate()
    321325    {
     326        Shell::getInstance().registerListener(this);
    322327        this->linesChanged();
    323328
     
    362367    void InGameConsole::print(const std::string& text, int index)
    363368    {
     369        char level = 0;
     370        if (text.size() > 0)
     371            level = text[0];
     372
     373        std::string output = text;
     374
     375        if (level >= -1 && level <= 5)
     376            output.erase(0, 1);
     377
    364378        if (LINES > index)
    365             this->consoleOverlayTextAreas_[index]->setCaption(convert2UTF(text));
     379        {
     380            if (level == -1)
     381            {
     382                this->consoleOverlayTextAreas_[index]->setColourTop   (ColourValue(0.90, 0.90, 0.90, 1.00));
     383                this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(1.00, 1.00, 1.00, 1.00));
     384            }
     385            else if (level == 1)
     386            {
     387                this->consoleOverlayTextAreas_[index]->setColourTop   (ColourValue(0.95, 0.25, 0.25, 1.00));
     388                this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(1.00, 0.50, 0.50, 1.00));
     389            }
     390            else if (level == 2)
     391            {
     392                this->consoleOverlayTextAreas_[index]->setColourTop   (ColourValue(0.95, 0.50, 0.20, 1.00));
     393                this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(1.00, 0.70, 0.50, 1.00));
     394            }
     395            else if (level == 3)
     396            {
     397                this->consoleOverlayTextAreas_[index]->setColourTop   (ColourValue(0.25, 0.25, 0.75, 1.00));
     398                this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(0.80, 0.80, 1.00, 1.00));
     399            }
     400            else if (level == 4)
     401            {
     402                this->consoleOverlayTextAreas_[index]->setColourTop   (ColourValue(0.65, 0.48, 0.44, 1.00));
     403                this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(1.00, 0.90, 0.90, 1.00));
     404            }
     405            else if (level == 5)
     406            {
     407                this->consoleOverlayTextAreas_[index]->setColourTop   (ColourValue(0.40, 0.20, 0.40, 1.00));
     408                this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(0.80, 0.60, 0.80, 1.00));
     409            }
     410            else
     411            {
     412                this->consoleOverlayTextAreas_[index]->setColourTop   (ColourValue(0.21, 0.69, 0.21, 1.00));
     413                this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(0.80, 1.00, 0.80, 1.00));
     414            }
     415
     416            this->consoleOverlayTextAreas_[index]->setCaption(convert2UTF(output));
     417        }
    366418    }
    367419
Note: See TracChangeset for help on using the changeset viewer.