| 36 | } |
| 37 | |
| 38 | void HelpInstructionsMenu::resize(int _width, int _height) { |
| 39 | HelpMenu::resize(_width, _height); |
| 40 | FontSizer fs = FontSizer(_width, _height); |
| 41 | |
| 42 | // find good font size |
| 43 | FontManager& fm = FontManager::instance(); |
| 44 | std::vector<HUDuiElement*>& listHUD = getElements(); |
| 45 | const int count = (const int)listHUD.size(); |
| 46 | const LocalFontFace* fontFace = listHUD[2]->getFontFace(); |
| 47 | |
| 48 | float fontSize = fs.getFontSize(fontFace->getFMFace(), "infoFontSize"); |
| 49 | |
| 50 | #if 0 /* XXX FIXME XXX */ |
| 51 | fontSize = _height; // guaranteed to be too big |
| 52 | const float workingWidth = _width - 2 * getLeftSide(_width, _height); |
| 53 | |
| 54 | // find the longest localized string |
| 55 | float longestLength = 0; |
| 56 | std::string longestString = ""; |
| 57 | std::vector<HUDuiElement*>& listHUD = getElements(); |
| 58 | for (int i = 2; i < count; ++i) { |
| 59 | float thisLength = fm.getStringWidth(fontFace->getFMFace(), fontSize, ((HUDuiLabel*)listHUD[i])->getString()); |
| 60 | if (thisLength > longestLength) { |
| 61 | longestLength = thisLength; |
| 62 | longestString = ((HUDuiLabel*)listHUD[i])->getString(); |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | // make the longest fit perfectly in the working width, and use that font size |
| 67 | for (fontSize = ((float)_height / 5.0f); longestLength > workingWidth; --fontSize) { |
| 68 | longestLength = fm.getStringWidth(fontFace->getFMFace(), fontSize, longestString); |
| 69 | } |
| 70 | #endif |
| 71 | |
| 72 | // reposition instruction text |
| 73 | const float h = fm.getStringHeight(fontFace->getFMFace(), fontSize); |
| 74 | const float x = getLeftSide(_width, _height); |
| 75 | float y = listHUD[2]->getY(); |
| 76 | for (int i = 2; i < count; ++i) { |
| 77 | listHUD[i]->setFontSize(fontSize); |
| 78 | listHUD[i]->setPosition(x, y); |
| 79 | y -= 1.0f * h; |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | // Local Variables: *** |
| 84 | // mode: C++ *** |
nothing calls this directly
no test coverage detected