mirror of
https://github.com/glest/glest-source.git
synced 2025-08-22 07:52:51 +02:00
- fixed debug output font position --> just for you james!
This commit is contained in:
@@ -2896,7 +2896,7 @@ void Game::render2d(){
|
|||||||
if(renderer.getShowDebugUI() == true) {
|
if(renderer.getShowDebugUI() == true) {
|
||||||
const Metrics &metrics= Metrics::getInstance();
|
const Metrics &metrics= Metrics::getInstance();
|
||||||
//int mx= metrics.getMinimapX();
|
//int mx= metrics.getMinimapX();
|
||||||
//int my= metrics.getMinimapY();
|
int my= metrics.getMinimapY();
|
||||||
//int mw= metrics.getMinimapW();
|
//int mw= metrics.getMinimapW();
|
||||||
int mh= metrics.getMinimapH();
|
int mh= metrics.getMinimapH();
|
||||||
const Vec4f fontColor=getGui()->getDisplay()->getColor();
|
const Vec4f fontColor=getGui()->getDisplay()->getColor();
|
||||||
@@ -2910,6 +2910,14 @@ void Game::render2d(){
|
|||||||
fontColor, 10, metrics.getVirtualH() - mh - 60, false);
|
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) {
|
for(int i = 0; i < world.getFactionCount(); ++i) {
|
||||||
string factionInfo = factionDebugInfo[i];
|
string factionInfo = factionDebugInfo[i];
|
||||||
Vec3f playerColor = world.getFaction(i)->getTexture()->getPixmapConst()->getPixel3f(0, 0);
|
Vec3f playerColor = world.getFaction(i)->getTexture()->getPixmapConst()->getPixel3f(0, 0);
|
||||||
@@ -2917,12 +2925,18 @@ void Game::render2d(){
|
|||||||
if(Renderer::renderText3DEnabled == true) {
|
if(Renderer::renderText3DEnabled == true) {
|
||||||
renderer.renderText3D(factionInfo, coreData.getMenuFontBig3D(),
|
renderer.renderText3D(factionInfo, coreData.getMenuFontBig3D(),
|
||||||
Vec4f(playerColor.x,playerColor.y,playerColor.z,1.0),
|
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 {
|
else {
|
||||||
renderer.renderText(factionInfo, coreData.getMenuFontBig(),
|
renderer.renderText(factionInfo, coreData.getMenuFontBig(),
|
||||||
Vec4f(playerColor.x,playerColor.y,playerColor.z,1.0),
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -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 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(
|
Vec2i textPos(
|
||||||
x-metrics.toVirtualX(virtualX),
|
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 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(
|
Vec2i textPos(
|
||||||
x-metrics.toVirtualX(virtualX),
|
x-metrics.toVirtualX(virtualX),
|
||||||
@@ -7356,7 +7356,7 @@ void Renderer::renderPopupMenu(PopupMenu *menu) {
|
|||||||
int renderX = (menu->getX() + (menu->getW() / 2));
|
int renderX = (menu->getX() + (menu->getW() / 2));
|
||||||
//int renderY = (menu->getY() + (menu->getH() / 2));
|
//int renderY = (menu->getY() + (menu->getH() / 2));
|
||||||
FontMetrics *fontMetrics= menu->getFont()->getMetrics();
|
FontMetrics *fontMetrics= menu->getFont()->getMetrics();
|
||||||
int renderY = menu->getY() + menu->getH() - fontMetrics->getHeight();
|
int renderY = menu->getY() + menu->getH() - fontMetrics->getHeight(menu->getHeader());
|
||||||
renderTextShadow(
|
renderTextShadow(
|
||||||
menu->getHeader(), menu->getFont(),fontColor,
|
menu->getHeader(), menu->getFont(),fontColor,
|
||||||
renderX, renderY,
|
renderX, renderY,
|
||||||
|
@@ -704,7 +704,7 @@ void Intro::render() {
|
|||||||
if(renderY < 0) {
|
if(renderY < 0) {
|
||||||
const Metrics &metrics= Metrics::getInstance();
|
const Metrics &metrics= Metrics::getInstance();
|
||||||
int h= metrics.getVirtualH();
|
int h= metrics.getVirtualH();
|
||||||
renderY = (h / 2) + (text->getFont3D()->getMetrics()->getHeight() / 2);
|
renderY = (h / 2) + (text->getFont3D()->getMetrics()->getHeight(text->getText()) / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
renderer.renderText3D(
|
renderer.renderText3D(
|
||||||
|
@@ -51,7 +51,7 @@ public:
|
|||||||
void setHeight(float height) {this->height= height;}
|
void setHeight(float height) {this->height= height;}
|
||||||
|
|
||||||
float getTextWidth(const string &str);
|
float getTextWidth(const string &str);
|
||||||
float getHeight() const;
|
float getHeight(const string &str) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
@@ -141,10 +141,11 @@ float FontMetrics::getTextWidth(const string &str) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float FontMetrics::getHeight() const {
|
float FontMetrics::getHeight(const string &str) const {
|
||||||
if(textHandler != NULL) {
|
if(textHandler != NULL) {
|
||||||
//printf("(textHandler->LineHeight(" ") = %f Font::scaleFontValue = %f\n",textHandler->LineHeight(" "),Font::scaleFontValue);
|
//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 {
|
else {
|
||||||
return height;
|
return height;
|
||||||
|
@@ -88,7 +88,7 @@ void TextRenderer2DGl::render(const string &text, float x, float y, bool centere
|
|||||||
metrics= font->getMetrics();
|
metrics= font->getMetrics();
|
||||||
if(centered) {
|
if(centered) {
|
||||||
rasterPos.x= x-metrics->getTextWidth(renderText)/2.f;
|
rasterPos.x= x-metrics->getTextWidth(renderText)/2.f;
|
||||||
rasterPos.y= y+metrics->getHeight()/2.f;
|
rasterPos.y= y + metrics->getHeight(renderText)/2.f;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
rasterPos= Vec2f(static_cast<float>(x), static_cast<float>(y));
|
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;
|
break;
|
||||||
case '\n':
|
case '\n':
|
||||||
line++;
|
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);
|
glRasterPos2f(rasterPos.x, rasterPos.y);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -511,7 +511,7 @@ void TextRenderer3DGl::internalRender(const string &text, float x, float y, boo
|
|||||||
if(centered) {
|
if(centered) {
|
||||||
//glTranslatef(x-scale*metrics->getTextWidth(text)/2.f, y-scale*metrics->getHeight()/2.f, 0);
|
//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.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;
|
translatePos.z = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
Reference in New Issue
Block a user