Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 5, 2008, 4:09:04 AM (16 years ago)
Author:
landauf
Message:

some console tweaks

File:
1 edited

Legend:

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

    r1539 r1540  
    7171        RegisterObject(InGameConsole);
    7272
    73         this->active_ = false;
     73        this->bActive_ = false;
    7474        this->cursor_ = 0.0;
    7575        this->cursorSymbol_ = '|';
     
    201201        // for the beginning, don't scroll
    202202        this->scroll_ = 0;
    203         this->scrollTimer_ = 0;
    204203        this->cursor_ = 0;
    205204
     
    307306    void InGameConsole::tick(float dt)
    308307    {
    309         this->scrollTimer_ += dt;
    310         if (this->scrollTimer_ >= 0.01)
    311         {
    312             float top = this->consoleOverlayContainer_->getTop();
    313             float timePassed = scrollTimer_;
    314             this->scrollTimer_ = 0;
    315             if (this->scroll_ != 0)
    316             {
    317                 // scroll
    318                 top = top + timePassed * this->scroll_;
    319                 this->consoleOverlayContainer_->setTop(top);
    320             }
    321             if (top <= -1.2 * InGameConsole::REL_HEIGHT)
     308        if (this->scroll_ != 0)
     309        {
     310            float top = this->consoleOverlayContainer_->getTop() + dt * this->scroll_;
     311            this->consoleOverlayContainer_->setTop(top);
     312
     313            if (this->scroll_ < 0 && top <= -1.2 * InGameConsole::REL_HEIGHT)
    322314            {
    323315                // window has completely scrolled up
    324316                this->scroll_ = 0;
    325317                this->consoleOverlay_->hide();
    326                 this->active_ = false;
    327                 Shell::getInstance().unregisterListener(this);
    328             }
    329             if (top >= 0)
     318            }
     319
     320            if (this->scroll_ > 0 && top >= 0)
    330321            {
    331322                // window has completely scrolled down
    332323                this->scroll_ = 0;
    333324                this->consoleOverlayContainer_->setTop(0);
    334                 this->active_ = true;
    335             }
    336         }
    337 
    338         this->cursor_ += dt;
    339         if (this->cursor_ >= InGameConsole::BLINK)
    340         {
    341             this->cursor_ = 0;
    342             bShowCursor_ = !bShowCursor_;
    343             if (bShowCursor_)
    344               this->consoleOverlayCursor_->show();
    345             else
    346               this->consoleOverlayCursor_->hide();
    347         }
    348 
    349         /*if (this->cursor_ >= 2 * InGameConsole::BLINK)
    350           this->cursor_ = 0;
    351 
    352         if (this->cursor_ >= InGameConsole::BLINK && this->cursorSymbol_ == '|')
    353         {
    354             this->cursorSymbol_ = ' ';
     325            }
     326        }
     327
     328        if (this->bActive_)
     329        {
     330            this->cursor_ += dt;
     331            if (this->cursor_ >= InGameConsole::BLINK)
     332            {
     333                this->cursor_ = 0;
     334                bShowCursor_ = !bShowCursor_;
     335                if (bShowCursor_)
     336                  this->consoleOverlayCursor_->show();
     337                else
     338                  this->consoleOverlayCursor_->hide();
     339            }
     340
     341            /*if (this->cursor_ >= 2 * InGameConsole::BLINK)
     342              this->cursor_ = 0;
     343
     344            if (this->cursor_ >= InGameConsole::BLINK && this->cursorSymbol_ == '|')
     345            {
     346                this->cursorSymbol_ = ' ';
     347                this->cursorChanged();
     348            }
     349            else if (this->cursor_ < InGameConsole::BLINK && this->cursorSymbol_ == ' ')
     350            {
     351                this->cursorSymbol_ = '|';
     352                this->cursorChanged();
     353            }*/
     354
     355            // this creates a flickering effect
     356            this->consoleOverlayNoise_->setTiling(1, rand() % 5 + 1);
     357        }
     358    }
     359
     360    /**
     361        @brief Shows the InGameConsole.
     362    */
     363    void InGameConsole::activate()
     364    {
     365        if (!this->bActive_)
     366        {
     367            this->bActive_ = true;
     368            InputManager::setInputState(InputManager::IS_CONSOLE);
     369            Shell::getInstance().registerListener(this);
     370
     371            this->resize();
     372            this->linesChanged();
    355373            this->cursorChanged();
    356         }
    357         else if (this->cursor_ < InGameConsole::BLINK && this->cursorSymbol_ == ' ')
    358         {
    359             this->cursorSymbol_ = '|';
    360             this->cursorChanged();
    361         }*/
    362 
    363         // this creates a flickering effect
    364         this->consoleOverlayNoise_->setTiling(1, rand() % 5 + 1);
    365     }
    366 
    367     /**
    368         @brief Shows the InGameConsole.
    369     */
    370     void InGameConsole::activate()
    371     {
    372         InputManager::setInputState(InputManager::IS_CONSOLE);
    373         Shell::getInstance().registerListener(this);
    374         this->linesChanged();
    375         this->cursorChanged();
    376 
    377         this->consoleOverlay_->show();
    378         // just in case window size has changed...
    379         this->resize();
    380         // scroll down
    381         this->scroll_ = 1;
    382         // the rest is done by tick
     374            this->consoleOverlay_->show();
     375
     376            // scroll down
     377            this->scroll_ = 1;
     378            // the rest is done by tick
     379        }
    383380    }
    384381
     
    388385    void InGameConsole::deactivate()
    389386    {
    390         // scroll up
    391         this->scroll_ = -1;
    392         // the rest is done by tick
    393         InputManager::setInputState(InputManager::IS_NORMAL);
     387        if (this->bActive_)
     388        {
     389            this->bActive_ = false;
     390            InputManager::setInputState(InputManager::IS_NORMAL);
     391            Shell::getInstance().unregisterListener(this);
     392
     393            // scroll up
     394            this->scroll_ = -1;
     395            // the rest is done by tick
     396        }
    394397    }
    395398
Note: See TracChangeset for help on using the changeset viewer.