[Orxonox-commit 4130] r8801 - in code/branches/output/src: libraries/core libraries/core/command libraries/util libraries/util/output orxonox/overlays
landauf at orxonox.net
landauf at orxonox.net
Sat Jul 30 21:31:05 CEST 2011
Author: landauf
Date: 2011-07-30 21:31:05 +0200 (Sat, 30 Jul 2011)
New Revision: 8801
Modified:
code/branches/output/src/libraries/core/LuaState.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/StringUtils.cc
code/branches/output/src/libraries/util/StringUtils.h
code/branches/output/src/libraries/util/output/OutputManager.cc
code/branches/output/src/orxonox/overlays/InGameConsole.cc
Log:
fixed bug with multiple lines in shell.
adjusted colors in IOConsole and InGameConsole a bit
Modified: code/branches/output/src/libraries/core/LuaState.cc
===================================================================
--- code/branches/output/src/libraries/core/LuaState.cc 2011-07-30 19:25:32 UTC (rev 8800)
+++ code/branches/output/src/libraries/core/LuaState.cc 2011-07-30 19:31:05 UTC (rev 8801)
@@ -238,7 +238,7 @@
void LuaState::luaLog(unsigned int level, const std::string& message)
{
-#pragma message(__FILE__ "("BOOST_PP_STRINGIZE(__LINE__)") : Warning: TODO: use correct level (and remove boost include)")
+#pragma message(__FILE__ "("BOOST_PP_STRINGIZE(__LINE__)") : Warning: TODO: use correct level, inspect lua support (and remove boost include)")
orxout(debug_output, context::lua) << "luaLog (level: " << level << "): " << message << endl;
}
Modified: code/branches/output/src/libraries/core/command/IOConsoleWindows.cc
===================================================================
--- code/branches/output/src/libraries/core/command/IOConsoleWindows.cc 2011-07-30 19:25:32 UTC (rev 8800)
+++ code/branches/output/src/libraries/core/command/IOConsoleWindows.cc 2011-07-30 19:31:05 UTC (rev 8801)
@@ -213,8 +213,8 @@
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::VerboseMore: colour = FOREGROUND_INTENSITY | 0 | 0 | FOREGROUND_BLUE; break;
+ case Shell::VerboseUltra: colour = FOREGROUND_INTENSITY | 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;
Modified: code/branches/output/src/libraries/core/command/Shell.cc
===================================================================
--- code/branches/output/src/libraries/core/command/Shell.cc 2011-07-30 19:25:32 UTC (rev 8800)
+++ code/branches/output/src/libraries/core/command/Shell.cc 2011-07-30 19:31:05 UTC (rev 8801)
@@ -33,6 +33,8 @@
#include "Shell.h"
+#include <boost/preprocessor/stringize.hpp>
+
#include "util/Math.h"
#include "util/StringUtils.h"
#include "util/SubString.h"
@@ -47,6 +49,7 @@
namespace orxonox
{
+#pragma message(__FILE__ "("BOOST_PP_STRINGIZE(__LINE__)") : Warning: TODO: add commands again, inspect tcl support (and remove boost include)")
// SetConsoleCommand("log", OutputHandler::log );
// SetConsoleCommand("error", OutputHandler::error ).hide();
// SetConsoleCommand("warning", OutputHandler::warning).hide();
@@ -250,12 +253,24 @@
}
/**
- @brief Sends output to the internal output buffer.
+ @brief Adds multiple lines to the internal output buffer.
*/
void Shell::addOutput(const std::string& text, LineType type)
{
+ std::vector<std::string> lines;
+ vectorize(text, '\n', &lines);
+
+ for (size_t i = 0; i < lines.size(); ++i)
+ this->addLine(lines[i], type);
+ }
+
+ /**
+ @brief Adds a line to the internal output buffer.
+ */
+ void Shell::addLine(const std::string& line, LineType type)
+ {
// yes it was - push the new line to the list
- this->outputLines_.push_front(std::make_pair(text, static_cast<LineType>(type)));
+ this->outputLines_.push_front(std::make_pair(line, static_cast<LineType>(type)));
// adjust the scroll position if needed
if (this->scrollPosition_)
@@ -285,7 +300,7 @@
*/
void Shell::printLine(const std::string& line, OutputLevel level)
{
- this->addOutput(line, static_cast<LineType>(level));
+ this->addLine(line, static_cast<LineType>(level));
}
/**
Modified: code/branches/output/src/libraries/core/command/Shell.h
===================================================================
--- code/branches/output/src/libraries/core/command/Shell.h 2011-07-30 19:25:32 UTC (rev 8800)
+++ code/branches/output/src/libraries/core/command/Shell.h 2011-07-30 19:31:05 UTC (rev 8801)
@@ -131,6 +131,7 @@
LineList::const_iterator getEndIterator() const;
void addOutput(const std::string& text, LineType type = DebugOutput);
+ void addLine(const std::string& line, LineType type = DebugOutput);
void clearOutput();
/// Returns the number of output-lines that are displayed in the shell.
Modified: code/branches/output/src/libraries/util/StringUtils.cc
===================================================================
--- code/branches/output/src/libraries/util/StringUtils.cc 2011-07-30 19:25:32 UTC (rev 8800)
+++ code/branches/output/src/libraries/util/StringUtils.cc 2011-07-30 19:31:05 UTC (rev 8801)
@@ -80,6 +80,16 @@
return str.substr(pos1, pos2 - pos1 + 1);
}
+ /// Splits a given string by a delimiter and stores it in an output vector
+ void vectorize(const std::string& str, char delimiter, std::vector<std::string>* output)
+ {
+ for (size_t start = 0, end = 0; end != std::string::npos; start = end + 1)
+ {
+ end = str.find_first_of(delimiter, start);
+ output->push_back(str.substr(start, end - start));
+ }
+ }
+
/**
@brief Returns the position of the next quotation mark in the string, starting with start.
@param str The string
@@ -516,7 +526,7 @@
return matrix[(rows-1)*cols + cols-1];
}
-
+
/**
@brief
Get a timestamp for the curent time instant.
Modified: code/branches/output/src/libraries/util/StringUtils.h
===================================================================
--- code/branches/output/src/libraries/util/StringUtils.h 2011-07-30 19:25:32 UTC (rev 8800)
+++ code/branches/output/src/libraries/util/StringUtils.h 2011-07-30 19:31:05 UTC (rev 8801)
@@ -42,6 +42,7 @@
#include "UtilPrereqs.h"
#include <string>
+#include <vector>
namespace orxonox
{
@@ -54,6 +55,8 @@
_UtilExport std::string removeTrailingWhitespaces(const std::string& str);
+ _UtilExport void vectorize(const std::string& str, char delimiter, std::vector<std::string>* output);
+
_UtilExport size_t getNextQuote(const std::string& str, size_t start);
_UtilExport bool isBetweenQuotes(const std::string& str, size_t pos);
@@ -87,7 +90,7 @@
_UtilExport size_t replaceCharacters(std::string& str, char target, char replacement);
_UtilExport unsigned int getLevenshteinDistance(const std::string& str1, const std::string& str2);
-
+
_UtilExport std::string getTimestamp(void);
}
Modified: code/branches/output/src/libraries/util/output/OutputManager.cc
===================================================================
--- code/branches/output/src/libraries/util/output/OutputManager.cc 2011-07-30 19:25:32 UTC (rev 8800)
+++ code/branches/output/src/libraries/util/output/OutputManager.cc 2011-07-30 19:31:05 UTC (rev 8801)
@@ -31,6 +31,7 @@
#include "MemoryWriter.h"
#include "ConsoleWriter.h"
#include "LogWriter.h"
+#include "util/StringUtils.h"
namespace orxonox
{
@@ -64,11 +65,7 @@
void OutputManager::pushMessage(OutputLevel level, OutputContext context, const std::string& message)
{
std::vector<std::string> lines;
- for (size_t start = 0, end = 0; end != std::string::npos; start = end + 1)
- {
- end = message.find_first_of('\n', start);
- lines.push_back(message.substr(start, end));
- }
+ vectorize(message, '\n', &lines);
for (size_t i = 0; i < this->listeners_.size(); ++i)
this->listeners_[i]->unfilteredOutput(level, context, lines);
Modified: code/branches/output/src/orxonox/overlays/InGameConsole.cc
===================================================================
--- code/branches/output/src/orxonox/overlays/InGameConsole.cc 2011-07-30 19:25:32 UTC (rev 8800)
+++ code/branches/output/src/orxonox/overlays/InGameConsole.cc 2011-07-30 19:31:05 UTC (rev 8801)
@@ -560,19 +560,19 @@
{
case Shell::DebugOutput: colourTop = ColourValue(0.9f, 0.9f, 0.9f); 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::UserError: colourTop = ColourValue(0.9f, 0.0f, 0.0f); break;
+ case Shell::UserWarning: colourTop = ColourValue(0.9f, 0.5f, 0.0f); break;
+ case Shell::UserStatus: colourTop = ColourValue(0.0f, 0.9f, 0.0f); break;
+ case Shell::UserInfo: colourTop = ColourValue(0.0f, 0.8f, 0.8f); 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::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.3f, 0.3f, 0.9f); break;
+ case Shell::VerboseMore: colourTop = ColourValue(0.2f, 0.2f, 0.7f); break;
+ case Shell::VerboseUltra: colourTop = ColourValue(0.1f, 0.1f, 0.5f); 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;
More information about the Orxonox-commit
mailing list