Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 30, 2009, 12:39:51 PM (15 years ago)
Author:
rgrieder
Message:

De-singletonised Shell so that both consoles have their own Shell instance. However they share the history.
Also modified IOConsole to hopefully work with status lines.

Location:
code/branches/console/src/orxonox/overlays
Files:
2 edited

Legend:

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

    r5992 r6004  
    6868    */
    6969    InGameConsole::InGameConsole()
    70         : shell_(Shell::getInstance())
     70        : shell_(new Shell("InGameConsole", true))
    7171        , consoleOverlay_(0)
    7272        , consoleOverlayContainer_(0)
     
    100100        // destroy the input state previously created (InputBuffer gets destroyed by the Shell)
    101101        InputManager::getInstance().destroyState("console");
     102
     103        // destroy the underlaying shell
     104        this->shell_->destroy();
    102105
    103106        Ogre::OverlayManager* ovMan = Ogre::OverlayManager::getSingletonPtr();
     
    175178        // create the corresponding input state
    176179        inputState_ = InputManager::getInstance().createInputState("console", false, false, InputStatePriority::Console);
    177         inputState_->setKeyHandler(this->shell_.getInputBuffer());
     180        inputState_->setKeyHandler(this->shell_->getInputBuffer());
    178181        bHidesAllInputChanged();
    179182
     
    253256        this->consoleOverlayContainer_->setTop(-1.2 * this->relativeHeight);
    254257
    255         this->shell_.addOutputLevel(true);
     258        this->shell_->addOutputLevel(true);
    256259
    257260        COUT(4) << "Info: InGameConsole initialized" << std::endl;
     
    267270    void InGameConsole::linesChanged()
    268271    {
    269         std::list<std::string>::const_iterator it = this->shell_.getNewestLineIterator();
     272        std::list<std::string>::const_iterator it = this->shell_->getNewestLineIterator();
    270273        int max = 0;
    271274        for (int i = 1; i < LINES; ++i)
    272275        {
    273             if (it != this->shell_.getEndIterator())
     276            if (it != this->shell_->getEndIterator())
    274277            {
    275278                ++it;
     
    296299    {
    297300        if (LINES > 1)
    298             this->print(*this->shell_.getNewestLineIterator(), 1);
     301            this->print(*this->shell_->getNewestLineIterator(), 1);
    299302    }
    300303
     
    315318    {
    316319        if (LINES > 0)
    317             this->print(this->shell_.getInput(), 0);
    318 
    319         if (this->shell_.getInput() == "" || this->shell_.getInput().size() == 0)
     320            this->print(this->shell_->getInput(), 0);
     321
     322        if (this->shell_->getInput() == "" || this->shell_->getInput().size() == 0)
    320323            this->inputWindowStart_ = 0;
    321324    }
     
    326329    void InGameConsole::cursorChanged()
    327330    {
    328         unsigned int pos = this->shell_.getCursorPosition() - inputWindowStart_;
     331        unsigned int pos = this->shell_->getCursorPosition() - inputWindowStart_;
    329332        if (pos > maxCharsPerLine_)
    330333            pos = maxCharsPerLine_;
     
    483486                if (output.size() > this->maxCharsPerLine_)
    484487                {
    485                     if (this->shell_.getInputBuffer()->getCursorPosition() < this->inputWindowStart_)
    486                         this->inputWindowStart_ = this->shell_.getInputBuffer()->getCursorPosition();
    487                     else if (this->shell_.getInputBuffer()->getCursorPosition() >= (this->inputWindowStart_ + this->maxCharsPerLine_ - 1))
    488                         this->inputWindowStart_ = this->shell_.getInputBuffer()->getCursorPosition() - this->maxCharsPerLine_ + 1;
     488                    if (this->shell_->getInputBuffer()->getCursorPosition() < this->inputWindowStart_)
     489                        this->inputWindowStart_ = this->shell_->getInputBuffer()->getCursorPosition();
     490                    else if (this->shell_->getInputBuffer()->getCursorPosition() >= (this->inputWindowStart_ + this->maxCharsPerLine_ - 1))
     491                        this->inputWindowStart_ = this->shell_->getInputBuffer()->getCursorPosition() - this->maxCharsPerLine_ + 1;
    489492
    490493                    output = output.substr(this->inputWindowStart_, this->maxCharsPerLine_);
     
    507510            this->bActive_ = true;
    508511            InputManager::getInstance().enterState("console");
    509             this->shell_.registerListener(this);
     512            this->shell_->registerListener(this);
    510513
    511514            this->windowResized(this->windowW_, this->windowH_);
     
    529532            this->bActive_ = false;
    530533            InputManager::getInstance().leaveState("console");
    531             this->shell_.unregisterListener(this);
     534            this->shell_->unregisterListener(this);
    532535
    533536            // scroll up
  • code/branches/console/src/orxonox/overlays/InGameConsole.h

    r5969 r6004  
    8181
    8282    private: // variables
    83         Shell& shell_;
     83        Shell* shell_;
    8484        bool bActive_;
    8585        int windowW_;
Note: See TracChangeset for help on using the changeset viewer.