[Scummvm-git-logs] scummvm master -> 87e9cdee28ceb3c57c04be64a14bbb575bbffd50
sev-
sev at scummvm.org
Sun Jun 21 15:51:52 UTC 2020
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
87e9cdee28 DIRECTOR: implement debugflag for screenshotting
Commit: 87e9cdee28ceb3c57c04be64a14bbb575bbffd50
https://github.com/scummvm/scummvm/commit/87e9cdee28ceb3c57c04be64a14bbb575bbffd50
Author: Roland van Laar (roland at rolandvanlaar.nl)
Date: 2020-06-21T17:51:48+02:00
Commit Message:
DIRECTOR: implement debugflag for screenshotting
It's now possible to screenshot all played frames by using:
`--debugflags=screenshot`
The screenshots are stored in `dumps/<archivename>-movie-<frameran#>.png`.
Note: it's PNG only.
Changed paths:
engines/director/director.cpp
engines/director/director.h
engines/director/score.cpp
engines/director/score.h
diff --git a/engines/director/director.cpp b/engines/director/director.cpp
index 7a5848c994..a6d2b32fa2 100644
--- a/engines/director/director.cpp
+++ b/engines/director/director.cpp
@@ -61,6 +61,7 @@ DirectorEngine::DirectorEngine(OSystem *syst, const DirectorGameDescription *gam
DebugMan.addDebugChannel(kDebugBytecode, "bytecode", "Execute Lscr bytecode");
DebugMan.addDebugChannel(kDebugFewFramesOnly, "fewframesonly", "Only run the first 10 frames");
DebugMan.addDebugChannel(kDebugPreprocess, "preprocess", "Lingo preprocessing");
+ DebugMan.addDebugChannel(kDebugScreenshot, "screenshot", "screenshot each frame");
g_director = this;
diff --git a/engines/director/director.h b/engines/director/director.h
index 651ab2d8b1..dabfbd498f 100644
--- a/engines/director/director.h
+++ b/engines/director/director.h
@@ -74,7 +74,8 @@ enum {
kDebugNoLoop = 1 << 10,
kDebugBytecode = 1 << 11,
kDebugFewFramesOnly = 1 << 12,
- kDebugPreprocess = 1 << 13
+ kDebugPreprocess = 1 << 13,
+ kDebugScreenshot = 1 << 14
};
struct MovieReference {
diff --git a/engines/director/score.cpp b/engines/director/score.cpp
index c782e903ca..b504d2db8e 100644
--- a/engines/director/score.cpp
+++ b/engines/director/score.cpp
@@ -20,12 +20,19 @@
*
*/
+#include "common/config-manager.h"
+#include "common/file.h"
#include "common/system.h"
#include "engines/util.h"
#include "graphics/primitives.h"
#include "graphics/macgui/macwindowmanager.h"
#include "graphics/macgui/mactext.h"
+#include "graphics/surface.h"
+
+#ifdef USE_PNG
+#include "image/png.h"
+#endif
#include "director/director.h"
#include "director/cast.h"
@@ -34,6 +41,7 @@
#include "director/sound.h"
#include "director/sprite.h"
#include "director/stxt.h"
+#include "director/util.h"
#include "director/lingo/lingo.h"
namespace Director {
@@ -144,7 +152,7 @@ Score::Score(DirectorEngine *vm) {
_numChannelsDisplayed = 0;
- _framesRan = 0; // used by kDebugFewFramesOnly
+ _framesRan = 0; // used by kDebugFewFramesOnly and kDebugScreenshot
_window = nullptr;
@@ -415,14 +423,16 @@ void Score::startLoop() {
if (_currentFrame < _frames.size())
_vm->processEvents();
- if (debugChannelSet(-1, kDebugFewFramesOnly)) {
+ if (debugChannelSet(-1, kDebugFewFramesOnly) || debugChannelSet(-1, kDebugScreenshot))
_framesRan++;
- if (_framesRan > 9) {
- warning("Score::startLoop(): exiting due to debug few frames only");
- break;
- }
+ if (debugChannelSet(-1, kDebugFewFramesOnly) && _framesRan > 9) {
+ warning("Score::startLoop(): exiting due to debug few frames only");
+ break;
}
+
+ if (debugChannelSet(-1, kDebugScreenshot))
+ screenShot();
}
_lingo->processEvent(kEventStopMovie);
@@ -640,6 +650,26 @@ void Score::renderFrame(uint16 frameId, bool forceUpdate, bool updateStageOnly)
}
g_system->copyRectToScreen(_surface->getPixels(), _surface->pitch, 0, 0, _surface->getBounds().width(), _surface->getBounds().height());
+
+}
+
+void Score::screenShot() {
+ Graphics::Surface rawSurface = _surface->rawSurface();
+ const Graphics::PixelFormat requiredFormat_4byte(4, 8, 8, 8, 8, 0, 8, 16, 24);
+ Graphics::Surface newSurface = *(rawSurface.convertTo(requiredFormat_4byte, _vm->getPalette()));
+ Common::String currentPath = _vm->getCurrentPath().c_str();
+ Common::replace(currentPath, "/", "-"); // exclude '/' from screenshot filename prefix
+ Common::String prefix = Common::String::format("%s%s", currentPath.c_str(), _macName.c_str());
+ Common::String filename = dumpScriptName(prefix.c_str(), kMovieScript, _framesRan, "png");
+
+ Common::DumpFile screenshotFile;
+ if (screenshotFile.open(filename)) {
+#ifdef USE_PNG
+ Image::writePNG(screenshotFile, newSurface);
+#else
+ warning("Screenshot requested, but PNG support is not compiled in");
+#endif
+ }
}
void Score::unrenderSprite(int spriteId) {
diff --git a/engines/director/score.h b/engines/director/score.h
index 3c950cf545..ddb6a2bc8b 100644
--- a/engines/director/score.h
+++ b/engines/director/score.h
@@ -180,6 +180,7 @@ private:
void loadFileInfo(Common::SeekableSubReadStreamEndian &stream);
void loadFontMap(Common::SeekableSubReadStreamEndian &stream);
void dumpScript(const char *script, ScriptType type, uint16 id);
+ void screenShot();
Common::String getString(Common::String str);
Common::Array<Common::String> loadStrings(Common::SeekableSubReadStreamEndian &stream, uint32 &entryType, bool hasHeader = true);
More information about the Scummvm-git-logs
mailing list