- 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
This commit is contained in:
Mark Vejvoda
2012-07-26 06:47:59 +00:00
parent 6662f35347
commit 8d6cdfb5db
2 changed files with 17 additions and 7 deletions

View File

@@ -499,6 +499,8 @@ Intro::Intro(Program *program):
string introVideoFile = CoreData::getInstance().getIntroVideoFilename(); string introVideoFile = CoreData::getInstance().getIntroVideoFilename();
string introVideoFileFallback = CoreData::getInstance().getIntroVideoFilenameFallback(); 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.clearBuffers();
//renderer.reset3dMenu(); //renderer.reset3dMenu();
//renderer.clearZBuffer(); //renderer.clearZBuffer();

View File

@@ -121,14 +121,22 @@ Text * FontMetrics::getTextHandler() {
float FontMetrics::getTextWidth(const string &str) { float FontMetrics::getTextWidth(const string &str) {
string longestLine = ""; string longestLine = "";
size_t found = str.find("\n");
if (found == string::npos) {
longestLine = str;
}
else {
vector<string> lineTokens; vector<string> lineTokens;
Tokenize(str,lineTokens,"\n"); Tokenize(str,lineTokens,"\n");
if(lineTokens.size() > 0) {
for(unsigned int i = 0; i < lineTokens.size(); ++i) { for(unsigned int i = 0; i < lineTokens.size(); ++i) {
string currentStr = lineTokens[i]; string currentStr = lineTokens[i];
if(currentStr.length() > longestLine.length()) { if(currentStr.length() > longestLine.length()) {
longestLine = currentStr; longestLine = currentStr;
} }
} }
}
}
if(textHandler != NULL) { if(textHandler != NULL) {
//printf("str [%s] textHandler->Advance = %f Font::scaleFontValue = %f\n",str.c_str(),textHandler->Advance(str.c_str()),Font::scaleFontValue); //printf("str [%s] textHandler->Advance = %f Font::scaleFontValue = %f\n",str.c_str(),textHandler->Advance(str.c_str()),Font::scaleFontValue);