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

Method resize

src/bzflag/SaveWorldMenu.cpp:84–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82}
83
84void SaveWorldMenu::resize(int _width, int _height) {
85 HUDDialog::resize(_width, _height);
86 FontSizer fs = FontSizer(_width, _height);
87
88 FontManager& fm = FontManager::instance();
89 std::vector<HUDuiElement*>& listHUD = getElements();
90 HUDuiLabel* title = (HUDuiLabel*)listHUD[0];
91 const LocalFontFace* fontFace = title->getFontFace();
92
93 // use a big font for the body, bigger for the title
94 fs.setMin(0, (int)(1.0 / BZDB.eval("headerFontSize") / 2.0));
95 const float titleFontSize = fs.getFontSize(fontFace->getFMFace(), "headerFontSize");
96
97 fs.setMin(0, 20);
98 float fontSize = fs.getFontSize(fontFace->getFMFace(), "menuFontSize");
99
100 // reposition title
101 title->setFontSize(titleFontSize);
102 const float titleWidth = fm.getStringWidth(fontFace->getFMFace(), titleFontSize, title->getString());
103 const float titleHeight = fm.getStringHeight(fontFace->getFMFace(), titleFontSize);
104 float x = 0.5f * ((float)_width - titleWidth);
105 float y = (float)_height - titleHeight;
106 title->setPosition(x, y);
107
108 // reposition options
109 x = 0.5f * ((float)_width - 0.75f * titleWidth);
110 y -= 0.6f * 3 * titleHeight;
111 const float h = fm.getStringHeight(fontFace->getFMFace(), fontSize);
112 const int count = (const int)listHUD.size();
113 int i;
114 for (i = 1; i < count - 1; i++) {
115 listHUD[i]->setFontSize(fontSize);
116 listHUD[i]->setPosition(x, y);
117 y -= 1.0f * h;
118 }
119
120 x = 100.0f;
121 y -= 100.0f;
122 listHUD[i]->setFontSize(fontSize);
123 listHUD[i]->setPosition(x, y);
124}
125
126// Local Variables: ***
127// mode: C++ ***

Callers

nothing calls this directly

Calls 13

FontSizerClass · 0.85
setMinMethod · 0.80
evalMethod · 0.80
getFMFaceMethod · 0.80
getStringWidthMethod · 0.80
getStringHeightMethod · 0.80
resizeFunction · 0.50
getFontFaceMethod · 0.45
getFontSizeMethod · 0.45
setFontSizeMethod · 0.45
getStringMethod · 0.45
setPositionMethod · 0.45

Tested by

no test coverage detected