mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-19 00:15:30 +00:00
STARK: Handle window resizes happening while the engine is paused
This commit is contained in:
parent
32fc54531b
commit
b28d8de2ff
@ -66,23 +66,31 @@ void Driver::toggleFullscreen() const {
|
|||||||
g_system->setFeatureState(OSystem::kFeatureFullscreenMode, !oldFullscreen);
|
g_system->setFeatureState(OSystem::kFeatureFullscreenMode, !oldFullscreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Driver::computeScreenViewport() {
|
bool Driver::computeScreenViewport() {
|
||||||
int32 screenWidth = g_system->getWidth();
|
int32 screenWidth = g_system->getWidth();
|
||||||
int32 screenHeight = g_system->getHeight();
|
int32 screenHeight = g_system->getHeight();
|
||||||
|
|
||||||
|
Common::Rect viewport;
|
||||||
if (g_system->getFeatureState(OSystem::kFeatureAspectRatioCorrection)) {
|
if (g_system->getFeatureState(OSystem::kFeatureAspectRatioCorrection)) {
|
||||||
// Aspect ratio correction
|
// Aspect ratio correction
|
||||||
int32 viewportWidth = MIN<int32>(screenWidth, screenHeight * kOriginalWidth / kOriginalHeight);
|
int32 viewportWidth = MIN<int32>(screenWidth, screenHeight * kOriginalWidth / kOriginalHeight);
|
||||||
int32 viewportHeight = MIN<int32>(screenHeight, screenWidth * kOriginalHeight / kOriginalWidth);
|
int32 viewportHeight = MIN<int32>(screenHeight, screenWidth * kOriginalHeight / kOriginalWidth);
|
||||||
_screenViewport = Common::Rect(viewportWidth, viewportHeight);
|
viewport = Common::Rect(viewportWidth, viewportHeight);
|
||||||
|
|
||||||
// Pillarboxing
|
// Pillarboxing
|
||||||
_screenViewport.translate((screenWidth - viewportWidth) / 2,
|
viewport.translate((screenWidth - viewportWidth) / 2,
|
||||||
(screenHeight - viewportHeight) / 2);
|
(screenHeight - viewportHeight) / 2);
|
||||||
} else {
|
} else {
|
||||||
// Aspect ratio correction disabled, just stretch
|
// Aspect ratio correction disabled, just stretch
|
||||||
_screenViewport = Common::Rect(screenWidth, screenHeight);
|
viewport = Common::Rect(screenWidth, screenHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (viewport == _screenViewport) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
_screenViewport = viewport;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::Rect Driver::gameViewport() const {
|
Common::Rect Driver::gameViewport() const {
|
||||||
|
@ -54,7 +54,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
void toggleFullscreen() const;
|
void toggleFullscreen() const;
|
||||||
|
|
||||||
void computeScreenViewport();
|
bool computeScreenViewport();
|
||||||
virtual void setScreenViewport(bool noScaling) = 0; // deprecated
|
virtual void setScreenViewport(bool noScaling) = 0; // deprecated
|
||||||
|
|
||||||
virtual void setViewport(const Common::Rect &rect) = 0;
|
virtual void setViewport(const Common::Rect &rect) = 0;
|
||||||
|
@ -338,9 +338,7 @@ void StarkEngine::processEvents() {
|
|||||||
} else if (e.type == Common::EVENT_RBUTTONDOWN) {
|
} else if (e.type == Common::EVENT_RBUTTONDOWN) {
|
||||||
_userInterface->handleRightClick();
|
_userInterface->handleRightClick();
|
||||||
} else if (e.type == Common::EVENT_SCREEN_CHANGED) {
|
} else if (e.type == Common::EVENT_SCREEN_CHANGED) {
|
||||||
_gfx->computeScreenViewport();
|
onScreenChanged();
|
||||||
_fontProvider->initFonts();
|
|
||||||
_userInterface->onScreenChanged();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -500,19 +498,19 @@ Common::String StarkEngine::formatSaveName(const char *target, int slot) {
|
|||||||
void StarkEngine::pauseEngineIntern(bool pause) {
|
void StarkEngine::pauseEngineIntern(bool pause) {
|
||||||
Engine::pauseEngineIntern(pause);
|
Engine::pauseEngineIntern(pause);
|
||||||
|
|
||||||
if (!_global || !_global->getLevel() || !_global->getCurrent() || !_frameLimiter) {
|
// This function may be called when an error occurs before the engine is fully initialized
|
||||||
// This function may be called when an error occurs before the engine is fully initialized
|
if (_global && _global->getLevel() && _global->getCurrent()) {
|
||||||
return;
|
_global->getLevel()->onEnginePause(pause);
|
||||||
|
_global->getCurrent()->getLevel()->onEnginePause(pause);
|
||||||
|
_global->getCurrent()->getLocation()->onEnginePause(pause);
|
||||||
}
|
}
|
||||||
|
|
||||||
_global->getLevel()->onEnginePause(pause);
|
if (_frameLimiter) {
|
||||||
_global->getCurrent()->getLevel()->onEnginePause(pause);
|
_frameLimiter->pause(pause);
|
||||||
_global->getCurrent()->getLocation()->onEnginePause(pause);
|
}
|
||||||
|
|
||||||
_frameLimiter->pause(pause);
|
|
||||||
|
|
||||||
// Grab a game screen thumbnail in case we need one when writing a save file
|
// Grab a game screen thumbnail in case we need one when writing a save file
|
||||||
if (_userInterface->isInGameScreen()) {
|
if (_userInterface && _userInterface->isInGameScreen()) {
|
||||||
if (pause) {
|
if (pause) {
|
||||||
_userInterface->saveGameScreenThumbnail();
|
_userInterface->saveGameScreenThumbnail();
|
||||||
} else {
|
} else {
|
||||||
@ -520,9 +518,19 @@ void StarkEngine::pauseEngineIntern(bool pause) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The user may have moved the mouse while the engine was paused
|
// The user may have moved the mouse or resized the window while the engine was paused
|
||||||
if (!pause) {
|
if (!pause && _userInterface) {
|
||||||
StarkUserInterface->handleMouseMove(_eventMan->getMousePos());
|
onScreenChanged();
|
||||||
|
_userInterface->handleMouseMove(_eventMan->getMousePos());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void StarkEngine::onScreenChanged() const {
|
||||||
|
bool changed = _gfx->computeScreenViewport();
|
||||||
|
if (changed) {
|
||||||
|
_fontProvider->initFonts();
|
||||||
|
_userInterface->onScreenChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // End of namespace Stark
|
} // End of namespace Stark
|
||||||
|
@ -77,6 +77,7 @@ private:
|
|||||||
void mainLoop();
|
void mainLoop();
|
||||||
void updateDisplayScene();
|
void updateDisplayScene();
|
||||||
void processEvents();
|
void processEvents();
|
||||||
|
void onScreenChanged() const;
|
||||||
|
|
||||||
Gfx::Driver *_gfx;
|
Gfx::Driver *_gfx;
|
||||||
Gfx::FrameLimiter *_frameLimiter;
|
Gfx::FrameLimiter *_frameLimiter;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user