Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 25, 2009, 10:23:58 PM (14 years ago)
Author:
rgrieder
Message:

Merged presentation2 branch back to trunk.
Major new features:

  • Actual GUI with settings, etc.
  • Improved space ship steering (human interaction)
  • Rocket fire and more particle effects
  • Advanced sound framework
Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/libraries/core/Shell.cc

    r6105 r6417  
    4545    SetConsoleCommandShortcut(OutputHandler, debug);
    4646
    47     Shell::Shell(const std::string& consoleName, bool bScrollable, bool bPrependOutputLevel)
     47    Shell::Shell(const std::string& consoleName, bool bScrollable)
    4848        : OutputListener(consoleName)
    4949        , inputBuffer_(new InputBuffer())
    5050        , consoleName_(consoleName)
    51         , bPrependOutputLevel_(bPrependOutputLevel)
    5251        , bScrollable_(bScrollable)
    5352    {
     
    6362        this->configureInputBuffer();
    6463
    65         // Get a config file for the command history
    66         this->commandHistoryConfigFileType_ = ConfigFileManager::getInstance().getNewConfigFileType();
    67         ConfigFileManager::getInstance().setFilename(this->commandHistoryConfigFileType_, "commandHistory.ini");
    68 
    69         // Use a stringstream object to buffer the output and get it line by line in update()
     64        // Specify file for the command history
     65        ConfigFileManager::getInstance().setFilename(ConfigFileType::CommandHistory, "commandHistory.ini");
     66
     67        // Use a stringstream object to buffer the output
    7068        this->outputStream_ = &this->outputBuffer_;
    7169
     
    9997        SetConfigValue(historyOffset_, 0)
    10098            .callback(this, &Shell::commandHistoryOffsetChanged);
    101         SetConfigValueVectorGeneric(commandHistoryConfigFileType_, commandHistory_, std::vector<std::string>());
     99        setConfigValueGeneric(this, &commandHistory_, ConfigFileType::CommandHistory, "Shell", "commandHistory_", std::vector<std::string>());
    102100
    103101#ifdef ORXONOX_RELEASE
     
    106104        const unsigned int defaultLevel = 3;
    107105#endif
    108         SetConfigValueGeneric(ConfigFileType::Settings, softDebugLevel_, "softDebugLevel" + this->consoleName_, "OutputHandler", defaultLevel)
     106        setConfigValueGeneric(this, &softDebugLevel_, ConfigFileType::Settings, "OutputHandler", "softDebugLevel" + this->consoleName_, defaultLevel)
    109107            .description("The maximal level of debug output shown in the Shell");
    110108        this->setSoftDebugLevel(this->softDebugLevel_);
     
    163161
    164162        for (unsigned int i = instance.historyOffset_; i < instance.commandHistory_.size(); ++i)
    165             instance.addOutputLine(instance.commandHistory_[i], -1);
     163            instance.addOutput(instance.commandHistory_[i] + '\n', -1);
    166164        for (unsigned int i =  0; i < instance.historyOffset_; ++i)
    167             instance.addOutputLine(instance.commandHistory_[i], -1);
     165            instance.addOutput(instance.commandHistory_[i] + '\n', -1);
    168166    }
    169167    */
     
    191189    }
    192190
    193     void Shell::addOutputLine(const std::string& line, int level)
    194     {
    195         // Make sure we really only have one line per line (no new lines!)
    196         SubString lines(line, '\n');
    197         for (unsigned i = 0; i < lines.size(); ++i)
    198         {
    199             if (level <= this->softDebugLevel_)
    200                 this->outputLines_.push_front(lines[i]);
    201             this->updateListeners<&ShellListener::lineAdded>();
    202         }
     191    void Shell::addOutput(const std::string& text, LineType type)
     192    {
     193        this->outputBuffer_ << text;
     194        this->outputChanged(type);
    203195    }
    204196
     
    214206    }
    215207
    216     std::list<std::string>::const_iterator Shell::getNewestLineIterator() const
     208    Shell::LineList::const_iterator Shell::getNewestLineIterator() const
    217209    {
    218210        if (this->scrollPosition_)
     
    222214    }
    223215
    224     std::list<std::string>::const_iterator Shell::getEndIterator() const
     216    Shell::LineList::const_iterator Shell::getEndIterator() const
    225217    {
    226218        return this->outputLines_.end();
     
    234226    }
    235227
    236     std::string Shell::getFromHistory() const
     228    const std::string& Shell::getFromHistory() const
    237229    {
    238230        unsigned int index = mod(static_cast<int>(this->historyOffset_) - static_cast<int>(this->historyPosition_), this->maxHistoryLength_);
     
    240232            return this->commandHistory_[index];
    241233        else
    242             return "";
    243     }
    244 
    245     void Shell::outputChanged(int level)
     234            return BLANKSTRING;
     235    }
     236
     237    void Shell::outputChanged(int lineType)
    246238    {
    247239        bool newline = false;
     
    259251            newline = (!eof && !fail);
    260252
    261             if (!newline && output == "")
     253            if (!newline && output.empty())
    262254                break;
    263255
    264256            if (this->bFinishedLastLine_)
    265257            {
    266                 if (this->bPrependOutputLevel_)
    267                     output.insert(0, 1, static_cast<char>(level));
    268 
    269                 this->outputLines_.push_front(output);
     258                this->outputLines_.push_front(std::make_pair(output, static_cast<LineType>(lineType)));
    270259
    271260                if (this->scrollPosition_)
     
    277266
    278267                if (!this->scrollPosition_)
    279                 {
    280268                    this->updateListeners<&ShellListener::lineAdded>();
    281                 }
    282269            }
    283270            else
    284271            {
    285                 (*this->outputLines_.begin()) += output;
     272                this->outputLines_.front().first += output;
    286273                this->bFinishedLastLine_ = newline;
    287274                this->updateListeners<&ShellListener::onlyLastLineChanged>();
    288275            }
     276            this->bFinishedLastLine_ = newline;
    289277
    290278        } while (newline);
     
    320308
    321309        if (!CommandExecutor::execute(this->inputBuffer_->get()))
    322             this->addOutputLine("Error: Can't execute \"" + this->inputBuffer_->get() + "\".", 1);
     310        {
     311            this->outputBuffer_ << "Error: Can't execute \"" << this->inputBuffer_->get() << "\"." << std::endl;
     312            this->outputChanged(Error);
     313        }
    323314
    324315        this->clearInput();
     
    328319    {
    329320        this->inputBuffer_->set(CommandExecutor::complete(this->inputBuffer_->get()));
    330         this->addOutputLine(CommandExecutor::hint(this->inputBuffer_->get()), -1);
     321        this->outputBuffer_ << CommandExecutor::hint(this->inputBuffer_->get()) << std::endl;
     322        this->outputChanged(Hint);
    331323
    332324        this->inputChanged();
     
    408400            return;
    409401        unsigned int cursorPosition = this->getCursorPosition();
    410         std::string input_str(this->getInput().substr(0, cursorPosition)); // only search for the expression from the beginning of the inputline until the cursor position
     402        const std::string& input_str(this->getInput().substr(0, cursorPosition)); // only search for the expression from the beginning of the inputline until the cursor position
    411403        for (unsigned int newPos = this->historyPosition_ + 1; newPos <= this->historyOffset_; newPos++)
    412404        {
     
    426418            return;
    427419        unsigned int cursorPosition = this->getCursorPosition();
    428         std::string input_str(this->getInput().substr(0, cursorPosition)); // only search for the expression from the beginning
     420        const std::string& input_str(this->getInput().substr(0, cursorPosition)); // only search for the expression from the beginning
    429421        for (unsigned int newPos = this->historyPosition_ - 1; newPos > 0; newPos--)
    430422        {
Note: See TracChangeset for help on using the changeset viewer.