MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / resize

Method resize

src/bzflag/InputMenu.cpp:295–359  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

293}
294
295void InputMenu::resize(int _width, int _height) {
296 HUDDialog::resize(_width, _height);
297 FontSizer fs = FontSizer(_width, _height);
298
299 int i;
300
301 FontManager& fm = FontManager::instance();
302 const LocalFontFace* fontFace = MainMenu::getFontFace();
303
304 // use a big font for title, smaller font for the rest
305 fs.setMin(0, (int)(1.0 / BZDB.eval("headerFontSize") / 2.0));
306 const float titleFontSize = fs.getFontSize(fontFace->getFMFace(), "headerFontSize");
307
308 fs.setMin(0, 20);
309 const float fontSize = fs.getFontSize(fontFace->getFMFace(), "menuFontSize");
310
311 // reposition title
312 std::vector<HUDuiElement*>& listHUD = getElements();
313 HUDuiLabel* title = (HUDuiLabel*)listHUD[0];
314 title->setFontSize(titleFontSize);
315 const float titleWidth = fm.getStringWidth(fontFace->getFMFace(), titleFontSize, title->getString());
316 const float titleHeight = fm.getStringHeight(fontFace->getFMFace(), titleFontSize);
317 float x = 0.5f * ((float)_width - titleWidth);
318 float y = (float)_height - titleHeight;
319 title->setPosition(x, y);
320
321 // reposition options
322 x = 0.5f * ((float)_width + 0.5f * titleWidth);
323 y -= 1.0f * titleHeight;
324 const float h = fm.getStringHeight(fontFace->getFMFace(), fontSize);
325 const int count = (int)listHUD.size();
326 for (i = 1; i < count; i++) {
327 listHUD[i]->setFontSize(fontSize);
328 listHUD[i]->setPosition(x, y);
329 y -= 1.0f * h;
330 }
331
332 // load current settings
333 std::vector<std::string> *options = &activeInput->getList();
334 for (i = 0; i < (int)options->size(); i++) {
335 std::string currentOption = (*options)[i];
336 if (BZDB.get("activeInputDevice") == currentOption) {
337 activeInput->setIndex(i);
338 }
339 }
340 if (BZDB.isTrue("allowInputChange")) {
341 activeInput->setIndex(0);
342 }
343
344 for (i = 1; i < count; i++) {
345 if (listHUD[i]->getLabel() == "Confine mouse:") {
346 HUDuiList* list = reinterpret_cast<HUDuiList*>(listHUD[i]);
347 if (BZDB.isTrue("mousegrab")) {
348 list->setIndex(1);
349 }
350 else if (BZDB.isTrue("mouseClamp")) {
351 list->setIndex(2);
352 }

Callers

nothing calls this directly

Calls 15

FontSizerClass · 0.85
setMinMethod · 0.80
evalMethod · 0.80
getFMFaceMethod · 0.80
getStringWidthMethod · 0.80
getStringHeightMethod · 0.80
isTrueMethod · 0.80
getLabelMethod · 0.80
resizeFunction · 0.50
getFontSizeMethod · 0.45
setFontSizeMethod · 0.45
getStringMethod · 0.45

Tested by

no test coverage detected