- fixed debug output font position --> just for you james!

This commit is contained in:
Mark Vejvoda 2011-11-28 05:54:31 +00:00
parent 03a7a72ef5
commit 1658306b59
6 changed files with 28 additions and 13 deletions

View File

@ -2896,7 +2896,7 @@ void Game::render2d(){
if(renderer.getShowDebugUI() == true) {
const Metrics &metrics= Metrics::getInstance();
//int mx= metrics.getMinimapX();
//int my= metrics.getMinimapY();
int my= metrics.getMinimapY();
//int mw= metrics.getMinimapW();
int mh= metrics.getMinimapH();
const Vec4f fontColor=getGui()->getDisplay()->getColor();
@ -2910,6 +2910,14 @@ void Game::render2d(){
fontColor, 10, metrics.getVirtualH() - mh - 60, false);
}
vector<string> lineTokens;
Tokenize(str,lineTokens,"\n");
int fontHeightNormal = (Renderer::renderText3DEnabled == true ? coreData.getMenuFontNormal3D()->getMetrics()->getHeight("W") : coreData.getMenuFontNormal()->getMetrics()->getHeight("W"));
int fontHeightBig = (Renderer::renderText3DEnabled == true ? coreData.getMenuFontBig3D()->getMetrics()->getHeight("W") : coreData.getMenuFontBig()->getMetrics()->getHeight("W"));
int playerPosY = lineTokens.size() * fontHeightNormal;
//printf("lineTokens.size() = %d\n",lineTokens.size());
for(int i = 0; i < world.getFactionCount(); ++i) {
string factionInfo = factionDebugInfo[i];
Vec3f playerColor = world.getFaction(i)->getTexture()->getPixmapConst()->getPixel3f(0, 0);
@ -2917,12 +2925,18 @@ void Game::render2d(){
if(Renderer::renderText3DEnabled == true) {
renderer.renderText3D(factionInfo, coreData.getMenuFontBig3D(),
Vec4f(playerColor.x,playerColor.y,playerColor.z,1.0),
10, metrics.getVirtualH() - mh - 90 - 280 - (i * 16), false);
10,
//metrics.getVirtualH() - mh - 90 - 280 - (i * 16),
metrics.getVirtualH() - mh - 60 - playerPosY - (fontHeightBig * i),
false);
}
else {
renderer.renderText(factionInfo, coreData.getMenuFontBig(),
Vec4f(playerColor.x,playerColor.y,playerColor.z,1.0),
10, metrics.getVirtualH() - mh - 90 - 280 - (i * 16), false);
10,
//metrics.getVirtualH() - mh - 90 - 280 - (i * 16),
metrics.getVirtualH() - mh - 60 - playerPosY - (fontHeightBig * i),
false);
}
}

View File

@ -1845,7 +1845,7 @@ Vec2i computeCenteredPos(const string &text, Font2D *font, int x, int y) {
}
int virtualX = (fontMetrics->getTextWidth(text) > 0 ? static_cast<int>(fontMetrics->getTextWidth(text)/2.f) : 5);
int virtualY = (fontMetrics->getHeight() > 0 ? static_cast<int>(fontMetrics->getHeight()/2.f) : 5);
int virtualY = (fontMetrics->getHeight(text) > 0 ? static_cast<int>(fontMetrics->getHeight(text)/2.f) : 5);
Vec2i textPos(
x-metrics.toVirtualX(virtualX),
@ -1868,7 +1868,7 @@ Vec2i computeCenteredPos(const string &text, Font3D *font, int x, int y) {
}
int virtualX = (fontMetrics->getTextWidth(text) > 0 ? static_cast<int>(fontMetrics->getTextWidth(text) / 2.f) : 5);
int virtualY = (fontMetrics->getHeight() > 0 ? static_cast<int>(fontMetrics->getHeight() / 2.f) : 5);
int virtualY = (fontMetrics->getHeight(text) > 0 ? static_cast<int>(fontMetrics->getHeight(text) / 2.f) : 5);
Vec2i textPos(
x-metrics.toVirtualX(virtualX),
@ -7356,7 +7356,7 @@ void Renderer::renderPopupMenu(PopupMenu *menu) {
int renderX = (menu->getX() + (menu->getW() / 2));
//int renderY = (menu->getY() + (menu->getH() / 2));
FontMetrics *fontMetrics= menu->getFont()->getMetrics();
int renderY = menu->getY() + menu->getH() - fontMetrics->getHeight();
int renderY = menu->getY() + menu->getH() - fontMetrics->getHeight(menu->getHeader());
renderTextShadow(
menu->getHeader(), menu->getFont(),fontColor,
renderX, renderY,

View File

@ -704,7 +704,7 @@ void Intro::render() {
if(renderY < 0) {
const Metrics &metrics= Metrics::getInstance();
int h= metrics.getVirtualH();
renderY = (h / 2) + (text->getFont3D()->getMetrics()->getHeight() / 2);
renderY = (h / 2) + (text->getFont3D()->getMetrics()->getHeight(text->getText()) / 2);
}
renderer.renderText3D(

View File

@ -51,7 +51,7 @@ public:
void setHeight(float height) {this->height= height;}
float getTextWidth(const string &str);
float getHeight() const;
float getHeight(const string &str) const;
};
// =====================================================

View File

@ -141,10 +141,11 @@ float FontMetrics::getTextWidth(const string &str) {
}
}
float FontMetrics::getHeight() const {
float FontMetrics::getHeight(const string &str) const {
if(textHandler != NULL) {
//printf("(textHandler->LineHeight(" ") = %f Font::scaleFontValue = %f\n",textHandler->LineHeight(" "),Font::scaleFontValue);
return (textHandler->LineHeight(" ") * Font::scaleFontValue);
//return (textHandler->LineHeight(str.c_str()) * Font::scaleFontValue);
return (textHandler->LineHeight(str.c_str()));
}
else {
return height;

View File

@ -88,7 +88,7 @@ void TextRenderer2DGl::render(const string &text, float x, float y, bool centere
metrics= font->getMetrics();
if(centered) {
rasterPos.x= x-metrics->getTextWidth(renderText)/2.f;
rasterPos.y= y+metrics->getHeight()/2.f;
rasterPos.y= y + metrics->getHeight(renderText)/2.f;
}
else {
rasterPos= Vec2f(static_cast<float>(x), static_cast<float>(y));
@ -328,7 +328,7 @@ void TextRenderer2DGl::render(const string &text, float x, float y, bool centere
break;
case '\n':
line++;
rasterPos= Vec2f(static_cast<float>(x), y-(metrics->getHeight()*2.f)*line);
rasterPos= Vec2f(static_cast<float>(x), y-(metrics->getHeight("W")*2.f)*line);
glRasterPos2f(rasterPos.x, rasterPos.y);
break;
default:
@ -511,7 +511,7 @@ void TextRenderer3DGl::internalRender(const string &text, float x, float y, boo
if(centered) {
//glTranslatef(x-scale*metrics->getTextWidth(text)/2.f, y-scale*metrics->getHeight()/2.f, 0);
translatePos.x = x-scale*metrics->getTextWidth(renderText)/2.f;
translatePos.y = y-scale*metrics->getHeight()/2.f;
translatePos.y = y-scale*metrics->getHeight(renderText)/2.f;
translatePos.z = 0;
}
else {