From 8d6cdfb5dbee56c17b68fdf5720117d714805bc2 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Thu, 26 Jul 2012 06:47:59 +0000 Subject: [PATCH] - tomreyn broken the intro text centering but adding empty intro text properties, so i commented the properties out - added more info / safer logic to center text --- source/glest_game/main/intro.cpp | 2 ++ source/shared_lib/sources/graphics/font.cpp | 22 ++++++++++++++------- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/source/glest_game/main/intro.cpp b/source/glest_game/main/intro.cpp index 71539831..9ba45ce7 100644 --- a/source/glest_game/main/intro.cpp +++ b/source/glest_game/main/intro.cpp @@ -499,6 +499,8 @@ Intro::Intro(Program *program): string introVideoFile = CoreData::getInstance().getIntroVideoFilename(); string introVideoFileFallback = CoreData::getInstance().getIntroVideoFilenameFallback(); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Intro Video [%s] [%s]\n",introVideoFile.c_str(),introVideoFileFallback.c_str()); + //renderer.clearBuffers(); //renderer.reset3dMenu(); //renderer.clearZBuffer(); diff --git a/source/shared_lib/sources/graphics/font.cpp b/source/shared_lib/sources/graphics/font.cpp index 53ffd8ff..bbd0067a 100644 --- a/source/shared_lib/sources/graphics/font.cpp +++ b/source/shared_lib/sources/graphics/font.cpp @@ -121,13 +121,21 @@ Text * FontMetrics::getTextHandler() { float FontMetrics::getTextWidth(const string &str) { string longestLine = ""; - vector lineTokens; - Tokenize(str,lineTokens,"\n"); - for(unsigned int i = 0; i < lineTokens.size(); ++i) { - string currentStr = lineTokens[i]; - if(currentStr.length() > longestLine.length()) { - longestLine = currentStr; - } + size_t found = str.find("\n"); + if (found == string::npos) { + longestLine = str; + } + else { + vector lineTokens; + Tokenize(str,lineTokens,"\n"); + if(lineTokens.size() > 0) { + for(unsigned int i = 0; i < lineTokens.size(); ++i) { + string currentStr = lineTokens[i]; + if(currentStr.length() > longestLine.length()) { + longestLine = currentStr; + } + } + } } if(textHandler != NULL) {