MCPcopy Create free account
hub / github.com/TurningWheel/Barony / guiInit

Method guiInit

src/ui/Frame.cpp:139–188  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

137#endif
138
139void Frame::guiInit() {
140 if ( _virtualScreenX == 0 && _virtualScreenY == 0 ) {
141 constexpr float defaultWidth = 1280.f;
142 constexpr float defaultHeight = 720.f;
143
144 const int lockedHeightY = defaultHeight * 2.f - defaultHeight * ((uiScale - .5f) / .5f);
145 const int lockedHeightX = (xres * lockedHeightY) / yres;
146 const int lockedHeightSize = lockedHeightX * lockedHeightY;
147
148 const int lockedWidthX = defaultWidth * 2.f - defaultWidth * ((uiScale - .5f) / .5f);
149 const int lockedWidthY = (yres * lockedWidthX) / xres;
150 const int lockedWidthSize = lockedWidthX * lockedWidthY;
151
152 if (lockedWidthSize > lockedHeightSize) {
153 _virtualScreenX = std::max(lockedWidthX, _virtualScreenMinWidth);
154 _virtualScreenY = std::max(lockedWidthY, _virtualScreenMinHeight);
155 } else {
156 _virtualScreenX = std::max(lockedHeightX, _virtualScreenMinWidth);
157 _virtualScreenY = std::max(lockedHeightY, _virtualScreenMinHeight);
158 }
159 }
160 fboInit();
161
162 assert(!gui && "gui already exists!");
163 gui = new Frame("root");
164 SDL_Rect guiRect;
165 guiRect.x = 0;
166 guiRect.y = 0;
167 guiRect.w = Frame::virtualScreenX;
168 guiRect.h = Frame::virtualScreenY;
169 gui->setSize(guiRect);
170 gui->setActualSize(guiRect);
171 gui->setHollow(true);
172
173#ifndef EDITOR
174 doSharedMinimap();
175 for ( int i = 0; i < MAXPLAYERS; ++i )
176 {
177 char name[32] = "";
178 snprintf(name, sizeof(name), "game_ui_%d", i);
179 gameUIFrame[i] = gui->addFrame(name);
180 gameUIFrame[i]->setSize(guiRect);
181 gameUIFrame[i]->setActualSize(guiRect);
182 gameUIFrame[i]->setHollow(true);
183 gameUIFrame[i]->setOwner(i);
184 gameUIFrame[i]->setDisabled(true);
185 }
186 UIToastNotificationManager.init();
187#endif
188}
189
190void Frame::guiDestroy() {
191#ifndef EDITOR

Callers

nothing calls this directly

Calls 7

setActualSizeMethod · 0.80
setHollowMethod · 0.80
addFrameMethod · 0.80
setOwnerMethod · 0.80
setSizeMethod · 0.45
setDisabledMethod · 0.45
initMethod · 0.45

Tested by

no test coverage detected