| 194 | |
| 195 | |
| 196 | void TextOptionsMenu::resize(int _width, int _height) { |
| 197 | HUDDialog::resize(_width, _height); |
| 198 | FontSizer fs = FontSizer(_width, _height); |
| 199 | |
| 200 | FontManager& fm = FontManager::instance(); |
| 201 | const LocalFontFace* fontFace = MainMenu::getFontFace(); |
| 202 | |
| 203 | // use a big font for title, smaller font for the rest |
| 204 | fs.setMin(0, (int)(1.0 / BZDB.eval("headerFontSize") / 2.0)); |
| 205 | const float titleFontSize = fs.getFontSize(fontFace->getFMFace(), "headerFontSize"); |
| 206 | |
| 207 | fs.setMin(0, 30); |
| 208 | const float fontSize = fs.getFontSize(fontFace->getFMFace(), "menuFontSize"); |
| 209 | |
| 210 | // reposition title |
| 211 | std::vector<HUDuiElement*>& listHUD = getElements(); |
| 212 | HUDuiLabel* title = (HUDuiLabel*)listHUD[0]; |
| 213 | title->setFontSize(titleFontSize); |
| 214 | const float titleWidth = fm.getStringWidth(fontFace->getFMFace(), titleFontSize, title->getString()); |
| 215 | const float titleHeight = fm.getStringHeight(fontFace->getFMFace(), titleFontSize); |
| 216 | float x = 0.5f * ((float)_width - titleWidth); |
| 217 | float y = (float)_height - titleHeight; |
| 218 | title->setPosition(x, y); |
| 219 | |
| 220 | // reposition options |
| 221 | x = 0.54f * (float)_width; |
| 222 | y -= 1.0f * titleHeight; |
| 223 | const float h = fm.getStringHeight(fontFace->getFMFace(), fontSize); |
| 224 | const int count = (const int)listHUD.size(); |
| 225 | for (int i = 1; i < count; i++) { |
| 226 | listHUD[i]->setFontSize(fontSize); |
| 227 | listHUD[i]->setPosition(x, y); |
| 228 | y -= 1.0f * h; |
| 229 | } |
| 230 | |
| 231 | // load current settings |
| 232 | |
| 233 | int i = 1; |
| 234 | i++; // locale |
| 235 | i++; // font options |
| 236 | ((HUDuiList*)listHUD[i++])->setIndex(BZDB.evalInt("fontOutline")); |
| 237 | ((HUDuiList*)listHUD[i++])->setIndex(BZDB.evalInt("scoreFontSize") / fontStep); |
| 238 | ((HUDuiList*)listHUD[i++])->setIndex(BZDB.evalInt("consoleFontSize") / fontStep); |
| 239 | ((HUDuiList*)listHUD[i++])->setIndex(BZDB.isTrue("colorful") ? 1 : 0); |
| 240 | |
| 241 | // underline color - find index of mode string in options |
| 242 | const std::vector<std::string> &opts = ((HUDuiList*)listHUD[i])->getList(); |
| 243 | std::string uColor = BZDB.get("underlineColor"); |
| 244 | ((HUDuiList*)listHUD[i++])->setIndex((int)(std::find(opts.begin(), opts.end(), uColor) - |
| 245 | opts.begin())); |
| 246 | |
| 247 | ((HUDuiList*)listHUD[i++])->setIndex(BZDB.evalInt("killerhighlight")); |
| 248 | ((HUDuiList*)listHUD[i++])->setIndex(int(BZDB.eval("pulseRate") * 5.0f) - 1); |
| 249 | ((HUDuiList*)listHUD[i++])->setIndex(int(BZDB.eval("pulseDepth") * 10.0f) - 1); |
| 250 | } |
| 251 | |
| 252 | |
| 253 | void TextOptionsMenu::callback(HUDuiControl* w, void* data) { |
no test coverage detected