mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-08 10:51:11 +00:00
SDL: Improve debug and warning messages when saving screenshots
In particular this adds a warning when failing to save a screenshot in OpenGL mode (there was already one in SurfaceSDL mode).
This commit is contained in:
parent
e96c057c3d
commit
a9ae691513
@ -1302,7 +1302,7 @@ const Graphics::Font *OpenGLGraphicsManager::getFontOSD() {
|
||||
}
|
||||
#endif
|
||||
|
||||
void OpenGLGraphicsManager::saveScreenshot(const Common::String &filename) const {
|
||||
bool OpenGLGraphicsManager::saveScreenshot(const Common::String &filename) const {
|
||||
const uint width = _outputScreenWidth;
|
||||
const uint height = _outputScreenHeight;
|
||||
|
||||
@ -1332,7 +1332,10 @@ void OpenGLGraphicsManager::saveScreenshot(const Common::String &filename) const
|
||||
|
||||
// Open file
|
||||
Common::DumpFile out;
|
||||
out.open(filename);
|
||||
if (!out.open(filename)) {
|
||||
delete[] pixels;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Write BMP header
|
||||
out.writeByte('B');
|
||||
@ -1357,6 +1360,7 @@ void OpenGLGraphicsManager::saveScreenshot(const Common::String &filename) const
|
||||
|
||||
// Free allocated memory
|
||||
delete[] pixels;
|
||||
return true;
|
||||
}
|
||||
|
||||
} // End of namespace OpenGL
|
||||
|
@ -296,8 +296,9 @@ protected:
|
||||
* uses Common::DumpFile for writing the screenshot.
|
||||
*
|
||||
* @param filename The output filename.
|
||||
* @return true on success, false otherwise
|
||||
*/
|
||||
void saveScreenshot(const Common::String &filename) const;
|
||||
bool saveScreenshot(const Common::String &filename) const;
|
||||
|
||||
private:
|
||||
//
|
||||
|
@ -642,8 +642,17 @@ bool OpenGLSdlGraphicsManager::notifyEvent(const Common::Event &event) {
|
||||
SDL_RWclose(file);
|
||||
}
|
||||
|
||||
saveScreenshot((screenshotsPath + filename).c_str());
|
||||
debug("Saved screenshot '%s'", filename.c_str());
|
||||
if (saveScreenshot(screenshotsPath + filename)) {
|
||||
if (screenshotsPath.empty())
|
||||
debug("Saved screenshot '%s' in current directory", filename.c_str());
|
||||
else
|
||||
debug("Saved screenshot '%s' in directory '%s'", filename.c_str(), screenshotsPath.c_str());
|
||||
} else {
|
||||
if (screenshotsPath.empty())
|
||||
warning("Could not save screenshot in current directory");
|
||||
else
|
||||
warning("Could not save screenshot in directory '%s'", screenshotsPath.c_str());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -2543,10 +2543,17 @@ bool SurfaceSdlGraphicsManager::notifyEvent(const Common::Event &event) {
|
||||
SDL_RWclose(file);
|
||||
}
|
||||
|
||||
if (saveScreenshot((screenshotsPath + filename).c_str()))
|
||||
debug("Saved screenshot '%s'", filename.c_str());
|
||||
else
|
||||
warning("Could not save screenshot");
|
||||
if (saveScreenshot((screenshotsPath + filename).c_str())) {
|
||||
if (screenshotsPath.empty())
|
||||
debug("Saved screenshot '%s' in current directory", filename.c_str());
|
||||
else
|
||||
debug("Saved screenshot '%s' in directory '%s'", filename.c_str(), screenshotsPath.c_str());
|
||||
} else {
|
||||
if (screenshotsPath.empty())
|
||||
warning("Could not save screenshot in current directory");
|
||||
else
|
||||
warning("Could not save screenshot in directory '%s'", screenshotsPath.c_str());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user