From 5dcd9d87142224a7a0dcfc5d575eef13d7789100 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Wed, 2 Nov 2011 19:02:25 +0000 Subject: [PATCH] fixed UI placement of playername in menus --- .../glest_game/menu/menu_state_connected_game.cpp | 2 +- source/glest_game/menu/menu_state_custom_game.cpp | 13 ++++++++----- source/shared_lib/sources/graphics/font.cpp | 4 +++- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/source/glest_game/menu/menu_state_connected_game.cpp b/source/glest_game/menu/menu_state_connected_game.cpp index 41d72143..d789b39e 100644 --- a/source/glest_game/menu/menu_state_connected_game.cpp +++ b/source/glest_game/menu/menu_state_connected_game.cpp @@ -244,7 +244,7 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM listBoxMap.setEditable(false); labelMapInfo.registerGraphicComponent(containerName,"labelMapInfo"); - labelMapInfo.init(xoffset+100, mapPos-labelOffset-6, 200, 40); + labelMapInfo.init(xoffset+100, mapPos-labelOffset-10, 200, 40); labelMapInfo.setText("?"); labelMap.registerGraphicComponent(containerName,"labelMap"); diff --git a/source/glest_game/menu/menu_state_custom_game.cpp b/source/glest_game/menu/menu_state_custom_game.cpp index 484c9976..a5f9ca40 100644 --- a/source/glest_game/menu/menu_state_custom_game.cpp +++ b/source/glest_game/menu/menu_state_custom_game.cpp @@ -227,7 +227,7 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, listBoxMap.setSelectedItemIndex(initialMapSelection); labelMapInfo.registerGraphicComponent(containerName,"labelMapInfo"); - labelMapInfo.init(xoffset+100, mapPos-labelOffset-6, 200, 40); + labelMapInfo.init(xoffset+100, mapPos-labelOffset-10, 200, 40); // MapFilter labelMapFilter.registerGraphicComponent(containerName,"labelMapFilter"); @@ -1679,18 +1679,21 @@ void MenuStateCustomGame::render() { const Metrics &metrics= Metrics::getInstance(); FontMetrics *fontMetrics= NULL; if(Renderer::renderText3DEnabled == false) { - fontMetrics = CoreData::getInstance().getMenuFontNormal()->getMetrics(); + fontMetrics = labelPlayers[i].getFont()->getMetrics(); } else { - fontMetrics = CoreData::getInstance().getMenuFontNormal3D()->getMetrics(); + fontMetrics = labelPlayers[i].getFont3D()->getMetrics(); } if(fontMetrics == NULL) { throw runtime_error("fontMetrics == NULL"); } - int curWidth = (metrics.toVirtualX(fontMetrics->getTextWidth(labelPlayers[i].getText()))); + //int curWidth = (metrics.toVirtualX(fontMetrics->getTextWidth(labelPlayers[i].getText()))); + int curWidth = (fontMetrics->getTextWidth(labelPlayers[i].getText())); + int newOffsetPosition = labelPlayers[i].getX() + curWidth + 2; + + //printf("labelPlayers[i].getX() = %d curWidth = %d labelPlayerNames[i].getX() = %d offsetPosition = %d newOffsetPosition = %d [%s]\n",labelPlayers[i].getX(),curWidth,labelPlayerNames[i].getX(),offsetPosition,newOffsetPosition,labelPlayers[i].getText().c_str()); if(labelPlayers[i].getX() + curWidth >= labelPlayerNames[i].getX()) { - int newOffsetPosition = labelPlayers[i].getX() + curWidth + 2; if(offsetPosition < newOffsetPosition) { offsetPosition = newOffsetPosition; } diff --git a/source/shared_lib/sources/graphics/font.cpp b/source/shared_lib/sources/graphics/font.cpp index 06447cf4..76a565c8 100644 --- a/source/shared_lib/sources/graphics/font.cpp +++ b/source/shared_lib/sources/graphics/font.cpp @@ -109,7 +109,9 @@ Text * FontMetrics::getTextHandler() { float FontMetrics::getTextWidth(const string &str) { if(textHandler != NULL) { - return (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(str.c_str())); } else { float width= 0.f;