Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 23, 2011, 12:45:53 AM (13 years ago)
Author:
landauf
Message:

merged output branch back to trunk.

Changes:

  • you have to include util/Output.h instead of util/Debug.h
  • COUT(x) is now called orxout(level)
  • output levels are now defined by an enum instead of numbers. see util/Output.h for the definition
  • it's possible to use output contexts with orxout(level, context). see util/Output.h for some common contexts. you can define more contexts
  • you must use 'endl' at the end of an output message, '\n' does not flush the message

Output levels:

  • instead of COUT(0) use orxout()
  • instead of COUT(1) use orxout(user_error) or orxout(internal_error)
  • instead of COUT(2) use orxout(user_warning) or orxout(internal_warning)
  • instead of COUT(3) use orxout(user_status/user_info) or orxout(internal_status/internal_info)
  • instead of COUT(4) use orxout(verbose)
  • instead of COUT(5) use orxout(verbose_more)
  • instead of COUT(6) use orxout(verbose_ultra)

Guidelines:

  • user_* levels are for the user, visible in the console and the log-file
  • internal_* levels are for developers, visible in the log-file
  • verbose_* levels are for debugging, only visible if the context of the output is activated

Usage in C++:

  • orxout() << "message" << endl;
  • orxout(level) << "message" << endl;
  • orxout(level, context) << "message" << endl;

Usage in Lua:

  • orxout("message")
  • orxout(orxonox.level.levelname, "message")
  • orxout(orxonox.level.levelname, "context", "message")

Usage in Tcl (and in the in-game-console):

  • orxout levelname message
  • orxout_context levelname context message
  • shortcuts: log message, error message, warning message, status message, info message, debug message
Location:
code/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

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

    r8729 r8858  
    4646#include "util/DisplayStringConversions.h"
    4747#include "util/ScopedSingletonManager.h"
     48#include "util/output/MemoryWriter.h"
    4849#include "core/CoreIncludes.h"
    4950#include "core/ConfigValueIncludes.h"
     
    5859{
    5960    const int LINES = 30;
    60     const float CHAR_WIDTH = 7.45f; // fix this please - determine the char-width dynamically
     61    const float CHAR_WIDTH = 8.0f; // fix this please - determine the char-width dynamically
    6162
    6263    SetConsoleCommand("InGameConsole", "openConsole", &InGameConsole::openConsole);
     
    9495        // Output buffering is not anymore needed. Not the best solution to do
    9596        // this here, but there isn't much of another way.
    96         OutputHandler::getInstance().disableMemoryLog();
     97        MemoryWriter::getInstance().disable();
    9798    }
    9899
     
    262263        this->consoleOverlayContainer_->setTop(-1.3f * this->relativeHeight);
    263264
    264         COUT(4) << "Info: InGameConsole initialized" << std::endl;
     265        orxout(internal_info) << "InGameConsole initialized" << endl;
    265266    }
    266267
     
    288289
    289290        for (int i = LINES - 1; i > max; --i)
    290             this->print("", Shell::None, i, true);
     291            this->print("", Shell::DebugOutput, i, true);
    291292
    292293        for (int i = max; i >= 1; --i)
     
    298299
    299300    /**
    300         @brief Called if only the last output-line has changed.
    301     */
    302     void InGameConsole::onlyLastLineChanged()
    303     {
     301        @brief Called if a new output-line was added.
     302    */
     303    void InGameConsole::lineAdded()
     304    {
     305        this->numLinesShifted_ = 0;
     306        this->shiftLines();
    304307        if (LINES > 1)
    305308            this->print(this->shell_->getNewestLineIterator()->first, this->shell_->getNewestLineIterator()->second, 1);
    306     }
    307 
    308     /**
    309         @brief Called if a new output-line was added.
    310     */
    311     void InGameConsole::lineAdded()
    312     {
    313         this->numLinesShifted_ = 0;
    314         this->shiftLines();
    315         this->onlyLastLineChanged();
    316309    }
    317310
     
    346339    void InGameConsole::executed()
    347340    {
    348         this->shell_->addOutput(this->shell_->getInput() + '\n', Shell::Command);
     341        this->shell_->addOutput(this->shell_->getInput(), Shell::Command);
    349342    }
    350343
     
    437430
    438431        // now adjust the text lines...
    439         this->desiredTextWidth_ = static_cast<int>(this->windowW_ * this->relativeWidth) - 12;
     432        this->desiredTextWidth_ = static_cast<int>(this->windowW_ * this->relativeWidth) - 24;
    440433
    441434        if (LINES > 0)
     
    566559        switch (type)
    567560        {
    568         case Shell::Error:   colourTop = ColourValue(0.95f, 0.25f, 0.25f, 1.00f);
    569                           colourBottom = ColourValue(1.00f, 0.50f, 0.50f, 1.00f); break;
    570 
    571         case Shell::Warning: colourTop = ColourValue(0.95f, 0.50f, 0.20f, 1.00f);
    572                           colourBottom = ColourValue(1.00f, 0.70f, 0.50f, 1.00f); break;
    573 
    574         case Shell::Info:    colourTop = ColourValue(0.50f, 0.50f, 0.95f, 1.00f);
    575                           colourBottom = ColourValue(0.80f, 0.80f, 1.00f, 1.00f); break;
    576 
    577         case Shell::Debug:   colourTop = ColourValue(0.65f, 0.48f, 0.44f, 1.00f);
    578                           colourBottom = ColourValue(1.00f, 0.90f, 0.90f, 1.00f); break;
    579 
    580         case Shell::Verbose: colourTop = ColourValue(0.40f, 0.20f, 0.40f, 1.00f);
    581                           colourBottom = ColourValue(0.80f, 0.60f, 0.80f, 1.00f); break;
    582 
    583         case Shell::Ultra:   colourTop = ColourValue(0.21f, 0.69f, 0.21f, 1.00f);
    584                           colourBottom = ColourValue(0.80f, 1.00f, 0.80f, 1.00f); break;
    585 
    586         case Shell::Command: colourTop = ColourValue(0.80f, 0.80f, 0.80f, 1.00f);
    587                           colourBottom = ColourValue(0.90f, 0.90f, 0.90f, 0.90f); break;
    588 
    589         case Shell::Hint:    colourTop = ColourValue(0.80f, 0.80f, 0.80f, 1.00f);
    590                           colourBottom = ColourValue(0.90f, 0.90f, 0.90f, 1.00f); break;
    591 
    592         case Shell::TDebug:  colourTop = ColourValue(0.90f, 0.00f, 0.90f, 1.00f);
    593                           colourBottom = ColourValue(1.00f, 0.00f, 1.00f, 1.00f); break;
    594 
    595         default:             colourTop = ColourValue(0.90f, 0.90f, 0.90f, 1.00f);
    596                           colourBottom = ColourValue(1.00f, 1.00f, 1.00f, 1.00f); break;
    597         }
     561            case Shell::Message:
     562            case Shell::DebugOutput:     colourTop = ColourValue(0.9f, 0.9f, 0.9f); break;
     563
     564            case Shell::UserError:       colourTop = ColourValue(0.9f, 0.0f, 0.0f); break;
     565            case Shell::UserWarning:     colourTop = ColourValue(0.9f, 0.5f, 0.0f); break;
     566            case Shell::UserStatus:      colourTop = ColourValue(0.0f, 0.9f, 0.0f); break;
     567            case Shell::UserInfo:        colourTop = ColourValue(0.0f, 0.8f, 0.8f); break;
     568
     569            case Shell::InternalError:   colourTop = ColourValue(0.5f, 0.0f, 0.0f); break;
     570            case Shell::InternalWarning: colourTop = ColourValue(0.5f, 0.2f, 0.0f); break;
     571            case Shell::InternalStatus:  colourTop = ColourValue(0.0f, 0.5f, 0.0f); break;
     572            case Shell::InternalInfo:    colourTop = ColourValue(0.0f, 0.4f, 0.4f); break;
     573
     574            case Shell::Verbose:         colourTop = ColourValue(0.3f, 0.3f, 0.9f); break;
     575            case Shell::VerboseMore:     colourTop = ColourValue(0.2f, 0.2f, 0.7f); break;
     576            case Shell::VerboseUltra:    colourTop = ColourValue(0.1f, 0.1f, 0.5f); break;
     577
     578            case Shell::Command:         colourTop = ColourValue(0.8f, 0.2f, 0.8f); break;
     579            case Shell::Hint:            colourTop = ColourValue(0.4f, 0.0f, 0.4f); break;
     580            case Shell::Input:           colourTop = ColourValue(0.9f, 0.9f, 0.9f); break;
     581
     582            default:                     colourTop = ColourValue(0.5f, 0.5f, 0.5f); break;
     583        }
     584
     585        colourBottom = ColourValue(sqrt(colourTop.r), sqrt(colourTop.g), sqrt(colourTop.b));
    598586
    599587        this->consoleOverlayTextAreas_[index]->setColourTop   (colourTop);
  • code/trunk/src/orxonox/overlays/InGameConsole.h

    r7284 r8858  
    6464
    6565        void linesChanged();
    66         void onlyLastLineChanged();
    6766        void lineAdded();
    6867        void inputChanged();
  • code/trunk/src/orxonox/overlays/OrxonoxOverlay.cc

    r8706 r8858  
    147147
    148148        if (OrxonoxOverlay::overlays_s.find(this->getName()) != OrxonoxOverlay::overlays_s.end())
    149             COUT(1) << "Overlay names should be unique or you cannnot access them via console. Name: \"" << this->getName() << '"' << std::endl;
     149            orxout(internal_warning) << "Overlay names should be unique or you cannnot access them via console. Name: \"" << this->getName() << '"' << endl;
    150150
    151151        OrxonoxOverlay::overlays_s[this->getName()] = this;
     
    362362            {
    363363                overlay->hide();
    364                 COUT(4) << "HIDE " << name << std::endl;
     364                orxout(verbose, context::misc::overlays) << "HIDE " << name << endl;
    365365            }
    366366            else
    367367            {
    368368                overlay->show();
    369                 COUT(4) << "SHOW " << name << std::endl;
     369                orxout(verbose, context::misc::overlays) << "SHOW " << name << endl;
    370370            }
    371371        }
Note: See TracChangeset for help on using the changeset viewer.