fixed UI placement of playername in menus

This commit is contained in:
Mark Vejvoda 2011-11-02 19:02:25 +00:00
parent 30e1f45cc7
commit 5dcd9d8714
3 changed files with 12 additions and 7 deletions

View File

@ -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");

View File

@ -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;
}

View File

@ -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;