MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / windowSizeChanged

Function windowSizeChanged

src/OpenLoco/src/Ui.cpp:458–490  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

456 }
457
458 void windowSizeChanged(int32_t width, int32_t height)
459 {
460 int32_t pixelWidth = width;
461 int32_t pixelHeight = height;
462 if (!SDL_GetWindowSizeInPixels(_window, &pixelWidth, &pixelHeight))
463 {
464 pixelWidth = width;
465 pixelHeight = height;
466 }
467
468 auto& drawingEngine = Gfx::getDrawingEngine();
469 drawingEngine.resize(pixelWidth, pixelHeight);
470
471 Gui::resize();
472 Gfx::invalidateScreen();
473
474 // Save window size to config if NOT maximized
475 auto wf = SDL_GetWindowFlags(_window);
476 if (!_isChangingDisplayMode && !(wf & SDL_WINDOW_MAXIMIZED) && !(wf & SDL_WINDOW_FULLSCREEN))
477 {
478 int32_t windowWidth = width;
479 int32_t windowHeight = height;
480 SDL_GetWindowSize(_window, &windowWidth, &windowHeight);
481
482 auto& cfg = Config::get().display;
483 if (cfg.mode == Config::ScreenMode::window)
484 {
485 cfg.windowResolution = { windowWidth, windowHeight };
486 _lastWindowedResolution = cfg.windowResolution;
487 Config::write();
488 }
489 }
490 }
491
492 void triggerResize()
493 {

Callers 1

triggerResizeFunction · 0.85

Calls 5

resizeFunction · 0.85
invalidateScreenFunction · 0.85
writeFunction · 0.85
getFunction · 0.70
resizeMethod · 0.45

Tested by

no test coverage detected