Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Colored chat working as expected for both freetype and non-freetype b…
…uilds. @nerzhul improvements * Add unit tests * Fix coding style * move guiChatConsole.hpp to client/
- Loading branch information
Showing
13 changed files
with
998 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,68 @@ | |||
/* | |||
Copyright (C) 2013 xyz, Ilya Zhuravlev <whatever@xyz.is> | |||
This program is free software; you can redistribute it and/or modify | |||
it under the terms of the GNU Lesser General Public License as published by | |||
the Free Software Foundation; either version 2.1 of the License, or | |||
(at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU Lesser General Public License for more details. | |||
You should have received a copy of the GNU Lesser General Public License along | |||
with this program; if not, write to the Free Software Foundation, Inc., | |||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |||
*/ | |||
|
|||
#include "coloredstring.h" | |||
#include "util/string.h" | |||
|
|||
ColoredString::ColoredString() | |||
{} | |||
|
|||
ColoredString::ColoredString(const std::wstring &string, const std::vector<SColor> &colors): | |||
m_string(string), | |||
m_colors(colors) | |||
{} | |||
|
|||
ColoredString::ColoredString(const std::wstring &s) { | |||
m_string = colorizeText(s, m_colors, SColor(255, 255, 255, 255)); | |||
} | |||
|
|||
void ColoredString::operator=(const wchar_t *str) { | |||
m_string = colorizeText(str, m_colors, SColor(255, 255, 255, 255)); | |||
} | |||
|
|||
size_t ColoredString::size() const { | |||
return m_string.size(); | |||
} | |||
|
|||
ColoredString ColoredString::substr(size_t pos, size_t len) const { | |||
if (pos == m_string.length()) | |||
return ColoredString(); | |||
if (len == std::string::npos || pos + len > m_string.length()) { | |||
return ColoredString( | |||
m_string.substr(pos, std::string::npos), | |||
std::vector<SColor>(m_colors.begin() + pos, m_colors.end()) | |||
); | |||
} else { | |||
return ColoredString( | |||
m_string.substr(pos, len), | |||
std::vector<SColor>(m_colors.begin() + pos, m_colors.begin() + pos + len) | |||
); | |||
} | |||
} | |||
|
|||
const wchar_t *ColoredString::c_str() const { | |||
return m_string.c_str(); | |||
} | |||
|
|||
const std::vector<SColor> &ColoredString::getColors() const { | |||
return m_colors; | |||
} | |||
|
|||
const std::wstring &ColoredString::getString() const { | |||
return m_string; | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,44 @@ | |||
/* | |||
Copyright (C) 2013 xyz, Ilya Zhuravlev <whatever@xyz.is> | |||
This program is free software; you can redistribute it and/or modify | |||
it under the terms of the GNU Lesser General Public License as published by | |||
the Free Software Foundation; either version 2.1 of the License, or | |||
(at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU Lesser General Public License for more details. | |||
You should have received a copy of the GNU Lesser General Public License along | |||
with this program; if not, write to the Free Software Foundation, Inc., | |||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |||
*/ | |||
|
|||
#ifndef COLOREDSTRING_HEADER | |||
#define COLOREDSTRING_HEADER | |||
|
|||
#include <string> | |||
#include <vector> | |||
#include <SColor.h> | |||
|
|||
using namespace irr::video; | |||
|
|||
class ColoredString { | |||
public: | |||
ColoredString(); | |||
ColoredString(const std::wstring &s); | |||
ColoredString(const std::wstring &string, const std::vector<SColor> &colors); | |||
void operator=(const wchar_t *str); | |||
size_t size() const; | |||
ColoredString substr(size_t pos = 0, size_t len = std::string::npos) const; | |||
const wchar_t *c_str() const; | |||
const std::vector<SColor> &getColors() const; | |||
const std::wstring &getString() const; | |||
private: | |||
std::wstring m_string; | |||
std::vector<SColor> m_colors; | |||
}; | |||
|
|||
#endif |
Oops, something went wrong.