Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 20, 2009, 4:55:40 PM (14 years ago)
Author:
rgrieder
Message:

Merged console branch back to trunk.

Location:
code/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/overlays/InGameConsole.cc

    r5960 r6105  
    6868    */
    6969    InGameConsole::InGameConsole()
    70         : consoleOverlay_(0)
     70        : shell_(new Shell("InGameConsole", true, true))
     71        , consoleOverlay_(0)
    7172        , consoleOverlayContainer_(0)
    7273        , consoleOverlayNoise_(0)
     
    99100        // destroy the input state previously created (InputBuffer gets destroyed by the Shell)
    100101        InputManager::getInstance().destroyState("console");
     102
     103        // destroy the underlaying shell
     104        this->shell_->destroy();
    101105
    102106        Ogre::OverlayManager* ovMan = Ogre::OverlayManager::getSingletonPtr();
     
    174178        // create the corresponding input state
    175179        inputState_ = InputManager::getInstance().createInputState("console", false, false, InputStatePriority::Console);
    176         inputState_->setKeyHandler(Shell::getInstance().getInputBuffer());
     180        inputState_->setKeyHandler(this->shell_->getInputBuffer());
    177181        bHidesAllInputChanged();
    178182
     
    252256        this->consoleOverlayContainer_->setTop(-1.3 * this->relativeHeight);
    253257
    254         Shell::getInstance().addOutputLevel(true);
    255 
    256258        COUT(4) << "Info: InGameConsole initialized" << std::endl;
    257259    }
     
    266268    void InGameConsole::linesChanged()
    267269    {
    268         std::list<std::string>::const_iterator it = Shell::getInstance().getNewestLineIterator();
     270        std::list<std::string>::const_iterator it = this->shell_->getNewestLineIterator();
    269271        int max = 0;
    270272        for (int i = 1; i < LINES; ++i)
    271273        {
    272             if (it != Shell::getInstance().getEndIterator())
     274            if (it != this->shell_->getEndIterator())
    273275            {
    274276                ++it;
     
    295297    {
    296298        if (LINES > 1)
    297             this->print(*Shell::getInstance().getNewestLineIterator(), 1);
     299            this->print(*this->shell_->getNewestLineIterator(), 1);
    298300    }
    299301
     
    314316    {
    315317        if (LINES > 0)
    316             this->print(Shell::getInstance().getInput(), 0);
    317 
    318         if (Shell::getInstance().getInput() == "" || Shell::getInstance().getInput().size() == 0)
     318            this->print(this->shell_->getInput(), 0);
     319
     320        if (this->shell_->getInput() == "" || this->shell_->getInput().size() == 0)
    319321            this->inputWindowStart_ = 0;
    320322    }
     
    325327    void InGameConsole::cursorChanged()
    326328    {
    327         unsigned int pos = Shell::getInstance().getCursorPosition() - inputWindowStart_;
     329        unsigned int pos = this->shell_->getCursorPosition() - inputWindowStart_;
    328330        if (pos > maxCharsPerLine_)
    329331            pos = maxCharsPerLine_;
     
    331333        this->consoleOverlayCursor_->setCaption(std::string(pos,' ') + cursorSymbol_);
    332334        this->consoleOverlayCursor_->setTop(static_cast<int>(this->windowH_ * this->relativeHeight) - 24);
     335    }
     336
     337    /**
     338        @brief Called if a command is about to be executed
     339    */
     340    void InGameConsole::executed()
     341    {
     342        this->shell_->addOutputLine(this->shell_->getInput());
    333343    }
    334344
     
    482492                if (output.size() > this->maxCharsPerLine_)
    483493                {
    484                     if (Shell::getInstance().getInputBuffer()->getCursorPosition() < this->inputWindowStart_)
    485                         this->inputWindowStart_ = Shell::getInstance().getInputBuffer()->getCursorPosition();
    486                     else if (Shell::getInstance().getInputBuffer()->getCursorPosition() >= (this->inputWindowStart_ + this->maxCharsPerLine_ - 1))
    487                         this->inputWindowStart_ = Shell::getInstance().getInputBuffer()->getCursorPosition() - this->maxCharsPerLine_ + 1;
     494                    if (this->shell_->getInputBuffer()->getCursorPosition() < this->inputWindowStart_)
     495                        this->inputWindowStart_ = this->shell_->getInputBuffer()->getCursorPosition();
     496                    else if (this->shell_->getInputBuffer()->getCursorPosition() >= (this->inputWindowStart_ + this->maxCharsPerLine_ - 1))
     497                        this->inputWindowStart_ = this->shell_->getInputBuffer()->getCursorPosition() - this->maxCharsPerLine_ + 1;
    488498
    489499                    output = output.substr(this->inputWindowStart_, this->maxCharsPerLine_);
     
    506516            this->bActive_ = true;
    507517            InputManager::getInstance().enterState("console");
    508             Shell::getInstance().registerListener(this);
     518            this->shell_->registerListener(this);
    509519
    510520            this->windowResized(this->windowW_, this->windowH_);
     
    528538            this->bActive_ = false;
    529539            InputManager::getInstance().leaveState("console");
    530             Shell::getInstance().unregisterListener(this);
     540            this->shell_->unregisterListener(this);
    531541
    532542            // scroll up
     
    588598    }
    589599
    590     // ###############################
    591     // ###      satic methods      ###
    592     // ###############################
     600    // ################################
     601    // ###      static methods      ###
     602    // ################################
    593603
    594604    /**
  • code/trunk/src/orxonox/overlays/InGameConsole.h

    r5929 r6105  
    6868        void inputChanged();
    6969        void cursorChanged();
     70        void executed();
    7071        void exit();
    7172
     
    8182
    8283    private: // variables
     84        Shell* shell_;
    8385        bool bActive_;
    8486        int windowW_;
Note: See TracChangeset for help on using the changeset viewer.