| 137 | #endif |
| 138 | |
| 139 | void 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 | |
| 190 | void Frame::guiDestroy() { |
| 191 | #ifndef EDITOR |
nothing calls this directly
no test coverage detected