Baggu fixed again

+Bonus document formatted
This commit is contained in:
FakeShemp
2016-03-09 22:11:17 +01:00
parent 42af029a26
commit 981dc3467e
+15 -6
View File
@@ -54,7 +54,9 @@ std::string TextPass::parseColors(std::string text, std::map<int, glm::vec4>& co
for (std::string::const_iterator c = parsedString.begin(); c != parsedString.end(); c++) { for (std::string::const_iterator c = parsedString.begin(); c != parsedString.end(); c++) {
if (*c == char(92)) { // Backlash if (*c == char(92)) { // Backlash
if ((c + 1) != parsedString.end()) {
if (*(c + 1) == char('C')) { // C for Color if (*(c + 1) == char('C')) { // C for Color
if ((c + 7) != parsedString.end()) {
bool hasCorrectFormat = true; bool hasCorrectFormat = true;
for (std::string::const_iterator colorC = c + 2; colorC != c + 8; colorC++) { for (std::string::const_iterator colorC = c + 2; colorC != c + 8; colorC++) {
@@ -82,8 +84,10 @@ std::string TextPass::parseColors(std::string text, std::map<int, glm::vec4>& co
parsedString.erase(c, (c + 8)); parsedString.erase(c, (c + 8));
} }
} }
}
if (*(c + 1) == char('A')) { // A for Alpha if (*(c + 1) == char('A')) { // A for Alpha
if ((c + 3) != parsedString.end()) {
bool hasCorrectFormat = true; bool hasCorrectFormat = true;
for (std::string::const_iterator colorC = c + 2; colorC != c + 4; colorC++) { for (std::string::const_iterator colorC = c + 2; colorC != c + 4; colorC++) {
@@ -91,6 +95,7 @@ std::string TextPass::parseColors(std::string text, std::map<int, glm::vec4>& co
hasCorrectFormat = false; hasCorrectFormat = false;
break; break;
} }
}
if (hasCorrectFormat == true) { if (hasCorrectFormat == true) {
colorChange = true; colorChange = true;
@@ -111,7 +116,8 @@ std::string TextPass::parseColors(std::string text, std::map<int, glm::vec4>& co
if ((*(c + 1) >= '1' && *(c + 1) <= '9') || *(c + 1) == 'B' || *(c + 1) == 'E' || *(c + 1) == 'F') { // Icons if ((*(c + 1) >= '1' && *(c + 1) <= '9') || *(c + 1) == 'B' || *(c + 1) == 'E' || *(c + 1) == 'F') { // Icons
if (*(c + 1) >= '1' && *(c + 1) <= '9') { if (*(c + 1) >= '1' && *(c + 1) <= '9') {
parsedString.replace(c, (c + 2), 1, (*(c + 1) - 48)); parsedString.replace(c, (c + 2), 1, (*(c + 1) - 48));
} else { }
else {
parsedString.replace(c, (c + 2), 1, (*(c + 1) - 55)); parsedString.replace(c, (c + 2), 1, (*(c + 1) - 55));
} }
} }
@@ -121,6 +127,7 @@ std::string TextPass::parseColors(std::string text, std::map<int, glm::vec4>& co
} }
} }
} }
}
@@ -131,7 +138,7 @@ void TextPass::renderText(std::string text, Font* font, TextJob::AlignmentEnum a
{ {
GLfloat penX = 0; GLfloat penX = 0;
GLfloat penY = 0; GLfloat penY = 0;
GLfloat scale = 1.0/font->FontSize; GLfloat scale = 1.0 / font->FontSize;
GLfloat stringWidth = 0.f; GLfloat stringWidth = 0.f;
@@ -143,11 +150,13 @@ void TextPass::renderText(std::string text, Font* font, TextJob::AlignmentEnum a
stringWidth += (ch.Advance >> 6) * scale; stringWidth += (ch.Advance >> 6) * scale;
} }
if(alignment == TextJob::AlignmentEnum::Center) { if (alignment == TextJob::AlignmentEnum::Center) {
penX = -stringWidth/2.f; penX = -stringWidth / 2.f;
} else if (alignment == TextJob::AlignmentEnum::Right) { }
else if (alignment == TextJob::AlignmentEnum::Right) {
penX = -stringWidth; penX = -stringWidth;
} else { }
else {
penX = 0; penX = 0;
} }