[Orxonox-commit 4124] r8795 - in code/branches/output/src: libraries/core/command libraries/util/output orxonox/overlays

landauf at orxonox.net landauf at orxonox.net
Fri Jul 29 22:26:45 CEST 2011


Author: landauf
Date: 2011-07-29 22:26:45 +0200 (Fri, 29 Jul 2011)
New Revision: 8795

Modified:
   code/branches/output/src/libraries/core/command/IOConsolePOSIX.cc
   code/branches/output/src/libraries/core/command/IOConsoleWindows.cc
   code/branches/output/src/libraries/core/command/Shell.cc
   code/branches/output/src/libraries/core/command/Shell.h
   code/branches/output/src/libraries/util/output/BaseWriter.cc
   code/branches/output/src/libraries/util/output/BaseWriter.h
   code/branches/output/src/libraries/util/output/ConsoleWriter.cc
   code/branches/output/src/libraries/util/output/ConsoleWriter.h
   code/branches/output/src/libraries/util/output/LogWriter.cc
   code/branches/output/src/libraries/util/output/LogWriter.h
   code/branches/output/src/orxonox/overlays/InGameConsole.cc
Log:
Shell and its derivatives are now based on the new output system

Modified: code/branches/output/src/libraries/core/command/IOConsolePOSIX.cc
===================================================================
--- code/branches/output/src/libraries/core/command/IOConsolePOSIX.cc	2011-07-28 20:35:41 UTC (rev 8794)
+++ code/branches/output/src/libraries/core/command/IOConsolePOSIX.cc	2011-07-29 20:26:45 UTC (rev 8795)
@@ -36,6 +36,7 @@
 
 #include "util/Clock.h"
 #include "util/Math.h"
+#include "util/output/ConsoleWriter.h"
 #include "core/Game.h"
 #include "core/input/InputBuffer.h"
 
@@ -73,7 +74,7 @@
         this->lastTerminalHeight_ = this->terminalHeight_;
 
         // Disable standard std::cout logging
-        OutputHandler::getInstance().disableCout();
+        ConsoleWriter::getInstance().disable();
         // Redirect std::cout to an ostringstream
         // (Other part is in the initialiser list)
         std::cout.rdbuf(this->origCout_.rdbuf());
@@ -87,7 +88,7 @@
         // Process output written to std::cout in the meantime
         std::cout.flush();
         if (!this->origCout_.str().empty())
-            this->shell_->addOutput(this->origCout_.str(), Shell::None);
+            this->shell_->addOutput(this->origCout_.str(), Shell::Cout);
         // Erase input and status lines
         this->cout_ << "\033[1G\033[J";
         // Move cursor to the bottom
@@ -101,7 +102,7 @@
         // Restore this->cout_ redirection
         std::cout.rdbuf(this->cout_.rdbuf());
         // Enable standard std::cout logging again
-        OutputHandler::getInstance().enableCout();
+        ConsoleWriter::getInstance().enable();
     }
 
     void IOConsole::preUpdate(const Clock& time)
@@ -228,7 +229,7 @@
         std::cout.flush();
         if (!this->origCout_.str().empty())
         {
-            this->shell_->addOutput(this->origCout_.str(), Shell::None);
+            this->shell_->addOutput(this->origCout_.str(), Shell::Cout);
             this->origCout_.str("");
         }
     }
@@ -238,16 +239,26 @@
         // Colour line
         switch (type)
         {
-        case Shell::Error:   this->cout_ << "\033[91m"; break;
-        case Shell::Warning: this->cout_ << "\033[93m"; break;
-        case Shell::Info:    this->cout_ << "\033[90m"; break;
-        case Shell::Debug:   this->cout_ << "\033[90m"; break;
-        case Shell::Verbose: this->cout_ << "\033[90m"; break;
-        case Shell::Ultra:   this->cout_ << "\033[90m"; break;
-        case Shell::Command: this->cout_ << "\033[36m"; break;
-        case Shell::Hint:    this->cout_ << "\033[33m"; break;
-        case Shell::TDebug:  this->cout_ << "\033[95m"; break;
-        default: break;
+            case Shell::DebugOutput:     this->cout_ << "\033[0m"; break;
+
+            case Shell::UserError:       this->cout_ << "\033[91m"; break;
+            case Shell::UserWarning:     this->cout_ << "\033[93m"; break;
+            case Shell::UserStatus:      this->cout_ << "\033[92m"; break;
+            case Shell::UserInfo:        this->cout_ << "\033[96m"; break;
+
+            case Shell::InternalError:   this->cout_ << "\033[31m"; break;
+            case Shell::InternalWarning: this->cout_ << "\033[33m"; break;
+            case Shell::InternalStatus:  this->cout_ << "\033[32m"; break;
+            case Shell::InternalInfo:    this->cout_ << "\033[36m"; break;
+
+            case Shell::Verbose:         this->cout_ << "\033[94m"; break;
+            case Shell::VerboseMore:     this->cout_ << "\033[34m"; break;
+            case Shell::VerboseUltra:    this->cout_ << "\033[34m"; break;
+
+            case Shell::Command:         this->cout_ << "\033[95m"; break;
+            case Shell::Hint:            this->cout_ << "\033[35m"; break;
+
+            default:                     this->cout_ << "\033[37m"; break;
         }
 
         // Print output line

Modified: code/branches/output/src/libraries/core/command/IOConsoleWindows.cc
===================================================================
--- code/branches/output/src/libraries/core/command/IOConsoleWindows.cc	2011-07-28 20:35:41 UTC (rev 8794)
+++ code/branches/output/src/libraries/core/command/IOConsoleWindows.cc	2011-07-29 20:26:45 UTC (rev 8795)
@@ -33,6 +33,7 @@
 
 #include "util/Clock.h"
 #include "util/Math.h"
+#include "util/output/ConsoleWriter.h"
 #include "core/Game.h"
 #include "core/input/InputBuffer.h"
 
@@ -51,7 +52,7 @@
         , lastOutputLineHeight_(0)
     {
         // Disable standard this->cout_ logging
-        OutputHandler::getInstance().disableCout();
+        ConsoleWriter::getInstance().disable();
         // Redirect std::cout to an ostringstream
         // (Other part is in the initialiser list)
         std::cout.rdbuf(this->origCout_.rdbuf());
@@ -94,7 +95,7 @@
         // Process output written to std::cout in the meantime
         std::cout.flush();
         if (!this->origCout_.str().empty())
-            this->shell_->addOutput(this->origCout_.str(), Shell::None);
+            this->shell_->addOutput(this->origCout_.str(), Shell::Cout);
 
         this->shell_->unregisterListener(this);
 
@@ -107,7 +108,7 @@
         // Restore this->cout_ redirection
         std::cout.rdbuf(this->cout_.rdbuf());
         // Enable standard this->cout_ logging again
-        OutputHandler::getInstance().enableCout();
+        ConsoleWriter::getInstance().enable();
 
         resetTerminalMode();
         this->shell_->destroy();
@@ -187,7 +188,7 @@
         std::cout.flush();
         if (!this->origCout_.str().empty())
         {
-            this->shell_->addOutput(this->origCout_.str(), Shell::None);
+            this->shell_->addOutput(this->origCout_.str(), Shell::Cout);
             this->origCout_.str("");
         }
     }
@@ -199,16 +200,26 @@
         WORD colour = 0;
         switch (type)
         {
-        case Shell::Error:   colour = FOREGROUND_INTENSITY                    | FOREGROUND_RED; break;
-        case Shell::Warning: colour = FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_RED; break;
-        case Shell::Info:
-        case Shell::Debug:
-        case Shell::Verbose:
-        case Shell::Ultra:   colour = FOREGROUND_INTENSITY                                     ; break;
-        case Shell::Command: colour =                        FOREGROUND_GREEN                  | FOREGROUND_BLUE; break;
-        case Shell::Hint:    colour =                        FOREGROUND_GREEN | FOREGROUND_RED                  ; break;
-        case Shell::TDebug:  colour = FOREGROUND_INTENSITY                    | FOREGROUND_RED | FOREGROUND_BLUE; break;
-        default:             colour =                        FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE; break;
+            case Shell::DebugOutput:     colour = FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE; break;
+
+            case Shell::UserError:       colour = FOREGROUND_INTENSITY | FOREGROUND_RED | 0                | 0              ; break;
+            case Shell::UserWarning:     colour = FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | 0              ; break;
+            case Shell::UserStatus:      colour = FOREGROUND_INTENSITY | 0              | FOREGROUND_GREEN | 0              ; break;
+            case Shell::UserInfo:        colour = FOREGROUND_INTENSITY | 0              | FOREGROUND_GREEN | FOREGROUND_BLUE; break;
+
+            case Shell::InternalError:   colour = 0                    | FOREGROUND_RED | 0                | 0              ; break;
+            case Shell::InternalWarning: colour = 0                    | FOREGROUND_RED | FOREGROUND_GREEN | 0              ; break;
+            case Shell::InternalStatus:  colour = 0                    | 0              | FOREGROUND_GREEN | 0              ; break;
+            case Shell::InternalInfo:    colour = 0                    | 0              | FOREGROUND_GREEN | FOREGROUND_BLUE; break;
+
+            case Shell::Verbose:         colour = FOREGROUND_INTENSITY | 0              | 0                | FOREGROUND_BLUE; break;
+            case Shell::VerboseMore:     colour = 0                    | 0              | 0                | FOREGROUND_BLUE; break;
+            case Shell::VerboseUltra:    colour = 0                    | 0              | 0                | FOREGROUND_BLUE; break;
+
+            case Shell::Command:         colour = FOREGROUND_INTENSITY | FOREGROUND_RED | 0                | FOREGROUND_BLUE; break;
+            case Shell::Hint:            colour = 0                    | FOREGROUND_RED | 0                | FOREGROUND_BLUE; break;
+
+            default:                     colour = 0                    | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE; break;
         }
 
         // Print output line

Modified: code/branches/output/src/libraries/core/command/Shell.cc
===================================================================
--- code/branches/output/src/libraries/core/command/Shell.cc	2011-07-28 20:35:41 UTC (rev 8794)
+++ code/branches/output/src/libraries/core/command/Shell.cc	2011-07-29 20:26:45 UTC (rev 8795)
@@ -34,9 +34,9 @@
 #include "Shell.h"
 
 #include "util/Math.h"
-#include "util/OutputHandler.h"
 #include "util/StringUtils.h"
 #include "util/SubString.h"
+#include "util/output/MemoryWriter.h"
 #include "core/CoreIncludes.h"
 #include "core/ConfigFileManager.h"
 #include "core/ConfigValueIncludes.h"
@@ -47,22 +47,21 @@
 
 namespace orxonox
 {
-    SetConsoleCommand("log",     OutputHandler::log    );
-    SetConsoleCommand("error",   OutputHandler::error  ).hide();
-    SetConsoleCommand("warning", OutputHandler::warning).hide();
-    SetConsoleCommand("info",    OutputHandler::info   ).hide();
-    SetConsoleCommand("debug",   OutputHandler::debug  ).hide();
+//    SetConsoleCommand("log",     OutputHandler::log    );
+//    SetConsoleCommand("error",   OutputHandler::error  ).hide();
+//    SetConsoleCommand("warning", OutputHandler::warning).hide();
+//    SetConsoleCommand("info",    OutputHandler::info   ).hide();
+//    SetConsoleCommand("debug",   OutputHandler::debug  ).hide();
 
     unsigned int Shell::cacheSize_s;
 
     /**
-        @brief Constructor: Initializes the values and registers itself at OutputHandler.
+        @brief Constructor: Initializes the values.
         @param consoleName The name of the shell - used to define the name of the soft-debug-level config-value
         @param bScrollable If true, the user is allowed to scroll through the output-lines
     */
     Shell::Shell(const std::string& consoleName, bool bScrollable)
-        : OutputListener(consoleName)
-        , inputBuffer_(new InputBuffer())
+        : inputBuffer_(new InputBuffer())
         , consoleName_(consoleName)
         , bScrollable_(bScrollable)
     {
@@ -72,7 +71,6 @@
         this->maxHistoryLength_ = 100;
         this->historyPosition_ = 0;
         this->historyOffset_ = 0;
-        this->bFinishedLastLine_ = true;
 
         this->clearOutput();
         this->configureInputBuffer();
@@ -80,40 +78,24 @@
         // Specify file for the command history
         ConfigFileManager::getInstance().setFilename(ConfigFileType::CommandHistory, "commandHistory.ini");
 
-        // Use a stringstream object to buffer the output
-        this->outputStream_ = &this->outputBuffer_;
-
         this->setConfigValues();
 
         // Get the previous output and add it to the Shell
-        OutputHandler::OutputVector::const_iterator it = OutputHandler::getInstance().getOutput().begin();
-        for (;it != OutputHandler::getInstance().getOutput().end(); ++it)
-        {
-            if (it->first <= debugLevel_)
-            {
-                this->outputBuffer_ << it->second;
-                this->outputChanged(it->first);
-            }
-        }
-
-        // Register the shell as output listener
-        OutputHandler::getInstance().registerOutputListener(this);
-        OutputHandler::getInstance().setSoftDebugLevel(consoleName_, debugLevel_);
+        MemoryWriter::getInstance().resendOutput(this);
     }
 
     /**
-        @brief Destructor: Unregisters the shell from OutputHandler.
+        @brief Destructor
     */
     Shell::~Shell()
     {
-        OutputHandler::getInstance().unregisterOutputListener(this);
         this->inputBuffer_->destroy();
     }
 
     namespace DefaultLogLevel
     {
-        const OutputLevel::Value Dev  = OutputLevel::Info;
-        const OutputLevel::Value User = OutputLevel::Error;
+        const OutputLevel Dev  = level::internal_warning;
+        const OutputLevel User = level::user_info;
     }
 
     /**
@@ -129,10 +111,10 @@
         SetConfigValue(cacheSize_s, 32);
 
         // Choose the default level according to the path Orxonox was started (build directory or not)
-        OutputLevel::Value defaultDebugLevel = (PathConfig::buildDirectoryRun() ? DefaultLogLevel::Dev : DefaultLogLevel::User);
+        OutputLevel defaultDebugLevel = (PathConfig::buildDirectoryRun() ? DefaultLogLevel::Dev : DefaultLogLevel::User);
         SetConfigValueExternal(debugLevel_, "OutputHandler", "debugLevel" + consoleName_, defaultDebugLevel)
             .description("The maximum level of debug output shown in the " + consoleName_);
-        OutputHandler::getInstance().setSoftDebugLevel(consoleName_, debugLevel_);
+        this->setLevelMax(this->debugLevel_);
     }
 
     /**
@@ -171,7 +153,7 @@
         }
         else
         {
-            OutputLevel::Value level = (value ? DefaultLogLevel::Dev : DefaultLogLevel::User);
+            OutputLevel level = (value ? DefaultLogLevel::Dev : DefaultLogLevel::User);
             ModifyConfigValueExternal(debugLevel_, "debugLevel" + consoleName_, tset, level);
         }
     }
@@ -255,8 +237,17 @@
     */
     void Shell::addOutput(const std::string& text, LineType type)
     {
-        this->outputBuffer_ << text;
-        this->outputChanged(type);
+        // yes it was - push the new line to the list
+        this->outputLines_.push_front(std::make_pair(text, static_cast<LineType>(type)));
+
+        // adjust the scroll position if needed
+        if (this->scrollPosition_)
+            this->scrollPosition_++;
+        else
+            this->scrollIterator_ = this->outputLines_.begin();
+
+        if (!this->scrollPosition_)
+            this->updateListeners<&ShellListener::lineAdded>();
     }
 
     /**
@@ -268,12 +259,19 @@
         this->scrollIterator_ = this->outputLines_.begin();
 
         this->scrollPosition_ = 0;
-        this->bFinishedLastLine_ = true;
 
         this->updateListeners<&ShellListener::linesChanged>();
     }
 
     /**
+        @brief Inherited from BaseWriter (LogListener), called if a new line of output was sent.
+    */
+    void Shell::printLine(const std::string& line, OutputLevel level)
+    {
+        this->addOutput(line, static_cast<LineType>(level));
+    }
+
+    /**
         @brief Returns an iterator to the newest line of output (except if the user is currently scrolling through the output).
     */
     Shell::LineList::const_iterator Shell::getNewestLineIterator() const
@@ -322,61 +320,6 @@
     }
 
     /**
-        @brief Called by OutputHandler or internally whenever output was sent to the output buffer. Reads from the buffer and writes the new output-lines to the list.
-    */
-    void Shell::outputChanged(int lineType)
-    {
-        bool newline = false;
-        do
-        {
-            // get the first line from the buffer
-            std::string output;
-            std::getline(this->outputBuffer_, output);
-
-            // check the state of the buffer
-            bool eof = this->outputBuffer_.eof();
-            bool fail = this->outputBuffer_.fail();
-            if (eof)
-                this->outputBuffer_.flush(); // check if more output was received in the meantime
-            if (eof || fail)
-                this->outputBuffer_.clear(); // clear the error flags
-
-            // the line is terminated with a line-break if neither an error occurred nor the end of the file was reached
-            newline = (!eof && !fail);
-
-            // no output retrieved - break the loop
-            if (!newline && output.empty())
-                break;
-
-            // check if the last line was terminated with a line-break
-            if (this->bFinishedLastLine_)
-            {
-                // yes it was - push the new line to the list
-                this->outputLines_.push_front(std::make_pair(output, static_cast<LineType>(lineType)));
-
-                // adjust the scroll position if needed
-                if (this->scrollPosition_)
-                    this->scrollPosition_++;
-                else
-                    this->scrollIterator_ = this->outputLines_.begin();
-
-                if (!this->scrollPosition_)
-                    this->updateListeners<&ShellListener::lineAdded>();
-            }
-            else
-            {
-                // no it wasn't - add the new output to the last line
-                this->outputLines_.front().first += output;
-                this->updateListeners<&ShellListener::onlyLastLineChanged>();
-            }
-
-            // remember if the last line was terminated with a line-break
-            this->bFinishedLastLine_ = newline;
-
-        } while (newline); // loop as long as more lines are in the buffer
-    }
-
-    /**
         @brief Clears the text in the input buffer.
     */
     void Shell::clearInput()
@@ -411,17 +354,15 @@
         {
             switch (error)
             {
-                case CommandExecutor::Error:       this->outputBuffer_ << "Error: Can't execute \"" << this->inputBuffer_->get() << "\", command doesn't exist. (S)" << std::endl; break;
-                case CommandExecutor::Incomplete:  this->outputBuffer_ << "Error: Can't execute \"" << this->inputBuffer_->get() << "\", not enough arguments given. (S)" << std::endl; break;
-                case CommandExecutor::Deactivated: this->outputBuffer_ << "Error: Can't execute \"" << this->inputBuffer_->get() << "\", command is not active. (S)" << std::endl; break;
-                case CommandExecutor::Denied:      this->outputBuffer_ << "Error: Can't execute \"" << this->inputBuffer_->get() << "\", access denied. (S)" << std::endl; break;
+                case CommandExecutor::Error:       this->addOutput("Error: Can't execute \"" + this->inputBuffer_->get() + "\", command doesn't exist. (S)", UserError); break;
+                case CommandExecutor::Incomplete:  this->addOutput("Error: Can't execute \"" + this->inputBuffer_->get() + "\", not enough arguments given. (S)", UserError); break;
+                case CommandExecutor::Deactivated: this->addOutput("Error: Can't execute \"" + this->inputBuffer_->get() + "\", command is not active. (S)", UserError); break;
+                case CommandExecutor::Denied:      this->addOutput("Error: Can't execute \"" + this->inputBuffer_->get() + "\", access denied. (S)", UserError); break;
             }
-            this->outputChanged(Error);
         }
         else if (result != "")
         {
-            this->outputBuffer_ << result << std::endl;
-            this->outputChanged(Command);
+            this->addOutput(result, Command);
         }
 
         this->clearInput();
@@ -431,8 +372,7 @@
     void Shell::hintAndComplete()
     {
         this->inputBuffer_->set(CommandExecutor::evaluate(this->inputBuffer_->get()).complete());
-        this->outputBuffer_ << CommandExecutor::evaluate(this->inputBuffer_->get()).hint() << std::endl;
-        this->outputChanged(Hint);
+        this->addOutput(CommandExecutor::evaluate(this->inputBuffer_->get()).hint(), Hint);
 
         this->inputChanged();
     }

Modified: code/branches/output/src/libraries/core/command/Shell.h
===================================================================
--- code/branches/output/src/libraries/core/command/Shell.h	2011-07-28 20:35:41 UTC (rev 8794)
+++ code/branches/output/src/libraries/core/command/Shell.h	2011-07-29 20:26:45 UTC (rev 8795)
@@ -47,7 +47,7 @@
 #include <string>
 #include <vector>
 
-#include "util/OutputHandler.h"
+#include "util/output/BaseWriter.h"
 #include "core/Core.h"
 #include "core/OrxonoxClass.h"
 
@@ -77,27 +77,32 @@
     /**
         @brief The Shell is the logical component of the console that displays output to the user and allows him to enter commands.
 
-        The Shell gathers output sent from OutputHandler by inheriting from OutputListener.
+        The Shell gathers output sent from OutputManager by inheriting from BaseWriter.
         The output-lines are stored in the shell, so they can be displayed in a graphical
         console. Additionally the Shell has an InputBuffer which is needed by the user to
         enter commands.
 
         Different graphical consoles build upon a Shell, for example InGameConsole and IOConsole.
     */
-    class _CoreExport Shell : public OutputListener, public DevModeListener
+    class _CoreExport Shell : public BaseWriter, public DevModeListener
     {
         public:
             /// Defines the type of a line of text in the Shell - some types depend on the output level, others are of internal use.
             enum LineType
             {
-                TDebug  = OutputLevel::TDebug,
-                None    = OutputLevel::None,
-                Warning = OutputLevel::Warning,
-                Error   = OutputLevel::Error,
-                Info    = OutputLevel::Info,
-                Debug   = OutputLevel::Debug,
-                Verbose = OutputLevel::Verbose,
-                Ultra   = OutputLevel::Ultra,
+                DebugOutput     = debug_output,
+                UserError       = user_error,
+                UserWarning     = user_warning,
+                UserStatus      = user_status,
+                UserInfo        = user_info,
+                InternalError   = internal_error,
+                InternalWarning = internal_warning,
+                InternalStatus  = internal_status,
+                InternalInfo    = internal_info,
+                Verbose         = verbose,
+                VerboseMore     = verbose_more,
+                VerboseUltra    = verbose_ultra,
+                Cout,
                 Input,
                 Command,
                 Hint
@@ -126,7 +131,7 @@
             LineList::const_iterator getNewestLineIterator() const;
             LineList::const_iterator getEndIterator() const;
 
-            void addOutput(const std::string& text, LineType type = None);
+            void addOutput(const std::string& text, LineType type = DebugOutput);
             void clearOutput();
 
             /// Returns the number of output-lines that are displayed in the shell.
@@ -149,8 +154,8 @@
             void addToHistory(const std::string& command);
             const std::string& getFromHistory() const;
             void clearInput();
-            // OutputListener
-            void outputChanged(int level);
+            // BaseWriter
+            virtual void printLine(const std::string& line, OutputLevel level);
 
             void configureInputBuffer();
 
@@ -182,8 +187,6 @@
 
             std::list<ShellListener*> listeners_;           ///< The registered shell listeners
             InputBuffer*              inputBuffer_;         ///< The input buffer that is needed by the user to enter text
-            std::stringstream         outputBuffer_;        ///< The output buffer that is used to retrieve lines of output from OutputListener
-            bool                      bFinishedLastLine_;   ///< Stores if the most recent output-line was terminated with a line-break or if more output is expected for this line
             LineList                  outputLines_;         ///< A list of all output-lines that were displayed in the shell so far
             LineList::const_iterator  scrollIterator_;      ///< An iterator to an entry of the list of output-lines, changes if the user scrolls through the output in the shell
             unsigned int              scrollPosition_;      ///< The number of the line that is currently being referenced by scrollIterator_
@@ -196,7 +199,7 @@
             unsigned int              maxHistoryLength_;    ///< The maximum number of saved commands
             unsigned int              historyOffset_;       ///< The command history is a circular buffer, this variable defines the current write-offset
             std::vector<std::string>  commandHistory_;      ///< The history of commands that were entered by the user
-            int                       debugLevel_;          //!< The maximum level of output that is displayed in the shell (will be passed to OutputListener to filter output)
+            OutputLevel               debugLevel_;          //!< The maximum level of output that is displayed in the shell (will be passed to OutputListener to filter output)
             static unsigned int       cacheSize_s;          ///< The maximum cache size of the CommandExecutor - this is stored here for better readability of the config file and because CommandExecutor is no OrxonoxClass
     };
 }

Modified: code/branches/output/src/libraries/util/output/BaseWriter.cc
===================================================================
--- code/branches/output/src/libraries/util/output/BaseWriter.cc	2011-07-28 20:35:41 UTC (rev 8794)
+++ code/branches/output/src/libraries/util/output/BaseWriter.cc	2011-07-29 20:26:45 UTC (rev 8795)
@@ -46,6 +46,6 @@
         std::string blanks(prefix.length(), ' ');
 
         for (size_t i = 0; i < lines.size(); ++i)
-            this->printLine((i == 0 ? prefix : blanks) + lines[i]);
+            this->printLine((i == 0 ? prefix : blanks) + lines[i], level);
     }
 }

Modified: code/branches/output/src/libraries/util/output/BaseWriter.h
===================================================================
--- code/branches/output/src/libraries/util/output/BaseWriter.h	2011-07-28 20:35:41 UTC (rev 8794)
+++ code/branches/output/src/libraries/util/output/BaseWriter.h	2011-07-29 20:26:45 UTC (rev 8795)
@@ -44,7 +44,7 @@
             virtual void output(OutputLevel level, OutputContext context, const std::vector<std::string>& lines);
 
         private:
-            virtual void printLine(const std::string& line) = 0;
+            virtual void printLine(const std::string& line, OutputLevel level) = 0;
     };
 }
 

Modified: code/branches/output/src/libraries/util/output/ConsoleWriter.cc
===================================================================
--- code/branches/output/src/libraries/util/output/ConsoleWriter.cc	2011-07-28 20:35:41 UTC (rev 8794)
+++ code/branches/output/src/libraries/util/output/ConsoleWriter.cc	2011-07-29 20:26:45 UTC (rev 8795)
@@ -36,7 +36,11 @@
 {
     ConsoleWriter::ConsoleWriter()
     {
+#ifdef ORXONOX_RELEASE
         this->setLevelMax(level::user_info);
+#else
+        this->setLevelMax(level::internal_warning);
+#endif
         this->bEnabled_ = true;
     }
 
@@ -50,7 +54,7 @@
         return instance;
     }
 
-    void ConsoleWriter::printLine(const std::string& line)
+    void ConsoleWriter::printLine(const std::string& line, OutputLevel)
     {
         std::cout << line << std::endl;
     }

Modified: code/branches/output/src/libraries/util/output/ConsoleWriter.h
===================================================================
--- code/branches/output/src/libraries/util/output/ConsoleWriter.h	2011-07-28 20:35:41 UTC (rev 8794)
+++ code/branches/output/src/libraries/util/output/ConsoleWriter.h	2011-07-29 20:26:45 UTC (rev 8795)
@@ -43,7 +43,7 @@
             void disable();
 
         protected:
-            virtual void printLine(const std::string& line);
+            virtual void printLine(const std::string& line, OutputLevel level);
 
         private:
             ConsoleWriter();

Modified: code/branches/output/src/libraries/util/output/LogWriter.cc
===================================================================
--- code/branches/output/src/libraries/util/output/LogWriter.cc	2011-07-28 20:35:41 UTC (rev 8794)
+++ code/branches/output/src/libraries/util/output/LogWriter.cc	2011-07-29 20:26:45 UTC (rev 8795)
@@ -73,7 +73,7 @@
         this->file_.open(name.c_str(), std::fstream::out);
 
         if (this->file_.is_open())
-            this->printLine("Log file opened");
+            this->printLine("Log file opened", level::none);
         else
             OutputManager::getInstance().pushMessage(level::user_warning, context::output(), "Failed to open log file. File logging disabled.");
     }
@@ -82,7 +82,7 @@
     {
         if (this->file_.is_open())
         {
-            this->printLine("Log file closed");
+            this->printLine("Log file closed", level::none);
             this->file_.close();
         }
     }
@@ -99,7 +99,7 @@
         MemoryWriter::getInstance().resendOutput(this);
     }
 
-    void LogWriter::printLine(const std::string& line)
+    void LogWriter::printLine(const std::string& line, OutputLevel)
     {
         if (!this->file_.is_open())
             return;

Modified: code/branches/output/src/libraries/util/output/LogWriter.h
===================================================================
--- code/branches/output/src/libraries/util/output/LogWriter.h	2011-07-28 20:35:41 UTC (rev 8794)
+++ code/branches/output/src/libraries/util/output/LogWriter.h	2011-07-29 20:26:45 UTC (rev 8795)
@@ -45,7 +45,7 @@
             void setLogPath(const std::string& path);
 
         protected:
-            virtual void printLine(const std::string& line);
+            virtual void printLine(const std::string& line, OutputLevel level);
 
         private:
             LogWriter();

Modified: code/branches/output/src/orxonox/overlays/InGameConsole.cc
===================================================================
--- code/branches/output/src/orxonox/overlays/InGameConsole.cc	2011-07-28 20:35:41 UTC (rev 8794)
+++ code/branches/output/src/orxonox/overlays/InGameConsole.cc	2011-07-29 20:26:45 UTC (rev 8795)
@@ -45,6 +45,7 @@
 #include "util/Math.h"
 #include "util/DisplayStringConversions.h"
 #include "util/ScopedSingletonManager.h"
+#include "util/output/MemoryWriter.h"
 #include "core/CoreIncludes.h"
 #include "core/ConfigValueIncludes.h"
 #include "core/command/ConsoleCommand.h"
@@ -93,7 +94,7 @@
 
         // Output buffering is not anymore needed. Not the best solution to do
         // this here, but there isn't much of another way.
-        OutputHandler::getInstance().disableMemoryLog();
+        MemoryWriter::getInstance().disable();
     }
 
     /**
@@ -287,7 +288,7 @@
         }
 
         for (int i = LINES - 1; i > max; --i)
-            this->print("", Shell::None, i, true);
+            this->print("", Shell::DebugOutput, i, true);
 
         for (int i = max; i >= 1; --i)
         {
@@ -565,37 +566,31 @@
         ColourValue colourTop, colourBottom;
         switch (type)
         {
-        case Shell::Error:   colourTop = ColourValue(0.95f, 0.25f, 0.25f, 1.00f);
-                          colourBottom = ColourValue(1.00f, 0.50f, 0.50f, 1.00f); break;
+            case Shell::DebugOutput:     colourTop = ColourValue(0.9f, 0.9f, 0.9f); break;
 
-        case Shell::Warning: colourTop = ColourValue(0.95f, 0.50f, 0.20f, 1.00f);
-                          colourBottom = ColourValue(1.00f, 0.70f, 0.50f, 1.00f); break;
+            case Shell::UserError:       colourTop = ColourValue(0.9f, 0.2f, 0.2f); break;
+            case Shell::UserWarning:     colourTop = ColourValue(0.9f, 0.5f, 0.2f); break;
+            case Shell::UserStatus:      colourTop = ColourValue(0.2f, 0.9f, 0.2f); break;
+            case Shell::UserInfo:        colourTop = ColourValue(0.2f, 0.8f, 0.8f); break;
 
-        case Shell::Info:    colourTop = ColourValue(0.50f, 0.50f, 0.95f, 1.00f);
-                          colourBottom = ColourValue(0.80f, 0.80f, 1.00f, 1.00f); break;
+            case Shell::InternalError:   colourTop = ColourValue(0.5f, 0.0f, 0.0f); break;
+            case Shell::InternalWarning: colourTop = ColourValue(0.5f, 0.2f, 0.0f); break;
+            case Shell::InternalStatus:  colourTop = ColourValue(0.0f, 0.5f, 0.0f); break;
+            case Shell::InternalInfo:    colourTop = ColourValue(0.0f, 0.4f, 0.4f); break;
 
-        case Shell::Debug:   colourTop = ColourValue(0.65f, 0.48f, 0.44f, 1.00f);
-                          colourBottom = ColourValue(1.00f, 0.90f, 0.90f, 1.00f); break;
+            case Shell::Verbose:         colourTop = ColourValue(0.2f, 0.2f, 0.9f); break;
+            case Shell::VerboseMore:     colourTop = ColourValue(0.1f, 0.1f, 0.6f); break;
+            case Shell::VerboseUltra:    colourTop = ColourValue(0.0f, 0.0f, 0.4f); break;
 
-        case Shell::Verbose: colourTop = ColourValue(0.40f, 0.20f, 0.40f, 1.00f);
-                          colourBottom = ColourValue(0.80f, 0.60f, 0.80f, 1.00f); break;
+            case Shell::Command:         colourTop = ColourValue(0.8f, 0.2f, 0.8f); break;
+            case Shell::Hint:            colourTop = ColourValue(0.4f, 0.0f, 0.4f); break;
+            case Shell::Input:           colourTop = ColourValue(0.9f, 0.9f, 0.9f); break;
 
-        case Shell::Ultra:   colourTop = ColourValue(0.21f, 0.69f, 0.21f, 1.00f);
-                          colourBottom = ColourValue(0.80f, 1.00f, 0.80f, 1.00f); break;
-
-        case Shell::Command: colourTop = ColourValue(0.80f, 0.80f, 0.80f, 1.00f);
-                          colourBottom = ColourValue(0.90f, 0.90f, 0.90f, 0.90f); break;
-
-        case Shell::Hint:    colourTop = ColourValue(0.80f, 0.80f, 0.80f, 1.00f);
-                          colourBottom = ColourValue(0.90f, 0.90f, 0.90f, 1.00f); break;
-
-        case Shell::TDebug:  colourTop = ColourValue(0.90f, 0.00f, 0.90f, 1.00f);
-                          colourBottom = ColourValue(1.00f, 0.00f, 1.00f, 1.00f); break;
-
-        default:             colourTop = ColourValue(0.90f, 0.90f, 0.90f, 1.00f);
-                          colourBottom = ColourValue(1.00f, 1.00f, 1.00f, 1.00f); break;
+            default:                     colourTop = ColourValue(0.5f, 0.5f, 0.5f); break;
         }
 
+        colourBottom = ColourValue(sqrt(colourTop.r), sqrt(colourTop.g), sqrt(colourTop.b));
+
         this->consoleOverlayTextAreas_[index]->setColourTop   (colourTop);
         this->consoleOverlayTextAreas_[index]->setColourBottom(colourBottom);
     }




More information about the Orxonox-commit mailing list