- hint text now centered on screen when game is loading
This commit is contained in:
parent
378b2e0a33
commit
5cb761e5a6
|
@ -241,17 +241,30 @@ void Logger::renderLoadingScreen() {
|
||||||
56 * metrics.getVirtualH() / 100, false);
|
56 * metrics.getVirtualH() / 100, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(gameHintToShow!=""){
|
|
||||||
|
if(gameHintToShow != "") {
|
||||||
|
Lang &lang= Lang::getInstance();
|
||||||
|
string hintText = lang.get("Hint");
|
||||||
|
char szBuf[8096]="";
|
||||||
|
sprintf(szBuf,hintText.c_str(),gameHintToShow.c_str());
|
||||||
|
hintText = szBuf;
|
||||||
|
|
||||||
if(Renderer::renderText3DEnabled) {
|
if(Renderer::renderText3DEnabled) {
|
||||||
|
int xLocationHint = (metrics.getVirtualW() / 2) - (coreData.getMenuFontBig3D()->getMetrics()->getTextWidth(hintText) / 2);
|
||||||
|
|
||||||
renderer.renderText3D(
|
renderer.renderText3D(
|
||||||
"Hint:\n"+gameHintToShow, coreData.getMenuFontBig3D(), Vec3f(1.f),
|
hintText, coreData.getMenuFontBig3D(), Vec3f(1.f),
|
||||||
xLocation*1.5f,
|
//xLocation*1.5f,
|
||||||
90 * metrics.getVirtualH() / 100, false);
|
xLocationHint,
|
||||||
|
90 * metrics.getVirtualH() / 100, false);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
int xLocationHint = (metrics.getVirtualW() / 2) - (coreData.getMenuFontBig()->getMetrics()->getTextWidth(hintText) / 2);
|
||||||
|
|
||||||
renderer.renderText(
|
renderer.renderText(
|
||||||
"Hint:\n"+gameHintToShow, coreData.getMenuFontBig(), Vec3f(1.f),
|
hintText, coreData.getMenuFontBig(), Vec3f(1.f),
|
||||||
xLocation*1.5f,
|
//xLocation*1.5f,
|
||||||
|
xLocationHint,
|
||||||
90 * metrics.getVirtualH() / 100, false);
|
90 * metrics.getVirtualH() / 100, false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,24 +120,34 @@ Text * FontMetrics::getTextHandler() {
|
||||||
}
|
}
|
||||||
|
|
||||||
float FontMetrics::getTextWidth(const string &str) {
|
float FontMetrics::getTextWidth(const string &str) {
|
||||||
|
string longestLine = "";
|
||||||
|
vector<string> 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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);
|
||||||
return (textHandler->Advance(str.c_str()) * Font::scaleFontValue);
|
return (textHandler->Advance(longestLine.c_str()) * Font::scaleFontValue);
|
||||||
//return (textHandler->Advance(str.c_str()));
|
//return (textHandler->Advance(str.c_str()));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
float width= 0.f;
|
float width= 0.f;
|
||||||
for(unsigned int i=0; i< str.size() && (int)i < Font::charCount; ++i){
|
for(unsigned int i=0; i< longestLine.size() && (int)i < Font::charCount; ++i){
|
||||||
if(str[i] >= Font::charCount) {
|
if(longestLine[i] >= Font::charCount) {
|
||||||
string sError = "str[i] >= Font::charCount, [" + str + "] i = " + intToStr(i);
|
string sError = "str[i] >= Font::charCount, [" + longestLine + "] i = " + intToStr(i);
|
||||||
throw megaglest_runtime_error(sError);
|
throw megaglest_runtime_error(sError);
|
||||||
}
|
}
|
||||||
//Treat 2 byte characters as spaces
|
//Treat 2 byte characters as spaces
|
||||||
if(str[i] < 0) {
|
if(longestLine[i] < 0) {
|
||||||
width+= (widths[97]); // This is the letter a which is a normal wide character and good to use for spacing
|
width+= (widths[97]); // This is the letter a which is a normal wide character and good to use for spacing
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
width+= widths[str[i]];
|
width+= widths[longestLine[i]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return width;
|
return width;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user