Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1470


Ignore:
Timestamp:
May 29, 2008, 2:56:17 AM (16 years ago)
Author:
rgrieder
Message:
  • graphical cursor in console should work now

I hope the fonts behave equally on other platforms…

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

Legend:

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

    r1469 r1470  
    4747
    4848#define LINES 30
    49 #define CHAR_WIDTH 7.85 // fix this please - determine the char-width dynamically
     49#define CHAR_WIDTH1 7.34 // fix this please - determine the char-width dynamically
     50#define CHAR_WIDTH2 8.28 // fix this please - determine the char-width dynamically
     51#define CHAR_WIDTH3 7.78 // fix this please - determine the char-width dynamically
    5052
    5153namespace orxonox
     
    177179    void InGameConsole::cursorChanged()
    178180    {
    179         std::string input = Shell::getInstance().getInput();
     181        /*std::string input = Shell::getInstance().getInput();
    180182        input.insert(Shell::getInstance().getCursorPosition(), 1, this->cursorSymbol_);
    181183        if (LINES > 0)
    182             this->print(input, 0);
     184            this->print(input, 0);*/
     185        this->setCursorPosition(Shell::getInstance().getCursorPosition() - inputWindowStart_);
    183186    }
    184187
     
    245248        this->consoleOverlayCursor_ = static_cast<PanelOverlayElement*>(this->om_->createOverlayElement("Panel", "InGameConsoleCursor"));
    246249        this->consoleOverlayCursor_->setMetricsMode(Ogre::GMM_PIXELS);
    247         this->consoleOverlayCursor_->setPosition(40,217);
    248         this->consoleOverlayCursor_->setDimensions(2, 20);
    249         this->consoleOverlayCursor_->setMaterialName("ConsoleNoise");
     250        this->consoleOverlayCursor_->setPosition(5,219);
     251        this->consoleOverlayCursor_->setDimensions(1, 14);
     252        this->consoleOverlayCursor_->setMaterialName("Orxonox/GreenDot");
    250253
    251254        this->consoleOverlay_ = this->om_->create("InGameConsoleConsole");
     
    285288
    286289        if (LINES > 0)
    287             this->maxCharsPerLine_ = max((unsigned int)10, (unsigned int) ((float)this->desiredTextWidth_ / CHAR_WIDTH));
     290            this->maxCharsPerLine_ = max((unsigned int)10, (unsigned int) ((float)this->desiredTextWidth_ / CHAR_WIDTH3));
    288291        else
    289292            this->maxCharsPerLine_ = 10;
     
    333336
    334337        this->cursor_ += dt;
    335         if (this->cursor_ >= 2 * InGameConsole::BLINK)
     338        if (this->cursor_ >= InGameConsole::BLINK)
     339        {
    336340            this->cursor_ = 0;
     341            bShowCursor_ = !bShowCursor_;
     342            if (bShowCursor_)
     343              this->consoleOverlayCursor_->show();
     344            else
     345              this->consoleOverlayCursor_->hide();
     346        }
     347
     348        /*if (this->cursor_ >= 2 * InGameConsole::BLINK)
     349          this->cursor_ = 0;
    337350
    338351        if (this->cursor_ >= InGameConsole::BLINK && this->cursorSymbol_ == '|')
     
    345358            this->cursorSymbol_ = '|';
    346359            this->cursorChanged();
    347         }
     360        }*/
    348361
    349362        // this creates a flickering effect
     
    445458            this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(0.80, 1.00, 0.80, 1.00));
    446459        }
     460    }
     461
     462    void InGameConsole::setCursorPosition(int pos)
     463    {
     464        static std::string char1 = "bdefgilpqtzCEGIJKNOPQT5[}äü";
     465        static std::string char2 = "Z4";
     466
     467        if (pos > maxCharsPerLine_)
     468          pos = maxCharsPerLine_;
     469        else if (pos < 0)
     470          pos = 0;
     471
     472        float width = 0;
     473        for (int i = 0; i < pos; ++i)
     474        {
     475            if (char1.find(displayedText_[i]) != std::string::npos)
     476                width += CHAR_WIDTH1;
     477            else if (char2.find(displayedText_[i]) != std::string::npos)
     478                width += CHAR_WIDTH2;
     479            else
     480                width += CHAR_WIDTH3;
     481        }
     482        this->consoleOverlayCursor_->setPosition(width + 5, 219);
    447483    }
    448484
     
    480516                }
    481517                this->consoleOverlayTextAreas_[index]->setCaption(convert2UTF(output));
     518                this->displayedText_ = output;
    482519                this->numLinesShifted_ = linesUsed;
    483520            }
     
    493530                    output = output.substr(this->inputWindowStart_, this->maxCharsPerLine_);
    494531                }
     532                else
     533                  this->inputWindowStart_ = 0;
     534                this->displayedText_ = output;
    495535                this->consoleOverlayTextAreas_[index]->setCaption(convert2UTF(output));
    496536            }
  • code/branches/network/src/orxonox/console/InGameConsole.h

    r1469 r1470  
    7272            void shiftLines();
    7373            void colourLine(int colourcode, int index);
     74            void setCursorPosition(int pos);
    7475            void print(const std::string& text, int index, bool alwaysShift = false);
    7576            static Ogre::UTFString convert2UTF(std::string s);
     
    9091            char cursorSymbol_;
    9192            bool active_;
     93            bool bShowCursor_;
     94            std::string displayedText_;
    9295            Ogre::OverlayManager* om_;
    9396            Ogre::Overlay* consoleOverlay_;
Note: See TracChangeset for help on using the changeset viewer.