diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 01dd632538..3063b045ad 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -23,6 +23,7 @@ - Feature: [#13969] [Plugin] Add APIs for editing title sequences. - Feature: [#14002] [Plugin] Use allowed_hosts when checking the binding IP for listening. - Feature: [#14059] [Plugin] Add optional filter to custom tools. +- Feature: [#14142] [Plugin] Add option for taking transparent screenshots. - Change: [#13346] [Plugin] Renamed FootpathScenery to FootpathAddition, fix typos. - Change: [#13857] Change Rotation Control Toggle to track element number 256 - Fix: [#4605, #11912] Water palettes are not updated properly when selected in Object Selection. diff --git a/distribution/openrct2.d.ts b/distribution/openrct2.d.ts index 326f16dfc6..fd3dad75de 100644 --- a/distribution/openrct2.d.ts +++ b/distribution/openrct2.d.ts @@ -314,6 +314,11 @@ declare global { * Rotation of the camera from 0 to 3. */ rotation: number; + + /** + * Whether to enable transparency in the screenshot. + */ + transparent?: boolean; } type ObjectType = diff --git a/src/openrct2/interface/Screenshot.cpp b/src/openrct2/interface/Screenshot.cpp index a50981552d..850a23b84f 100644 --- a/src/openrct2/interface/Screenshot.cpp +++ b/src/openrct2/interface/Screenshot.cpp @@ -814,6 +814,11 @@ void CaptureImage(const CaptureOptions& options) auto backupRotation = gCurrentRotation; gCurrentRotation = options.Rotation; + if (options.Transparent) + { + viewport.flags |= VIEWPORT_FLAG_TRANSPARENT_BACKGROUND; + } + auto outputPath = ResolveFilenameForCapture(options.Filename); auto dpi = CreateDPI(viewport); RenderViewport(nullptr, viewport, dpi); diff --git a/src/openrct2/interface/Screenshot.h b/src/openrct2/interface/Screenshot.h index 4d74d16d70..417c39903e 100644 --- a/src/openrct2/interface/Screenshot.h +++ b/src/openrct2/interface/Screenshot.h @@ -49,6 +49,7 @@ struct CaptureOptions std::optional View; ZoomLevel Zoom; uint8_t Rotation{}; + bool Transparent{}; }; void screenshot_check(); diff --git a/src/openrct2/scripting/ScContext.hpp b/src/openrct2/scripting/ScContext.hpp index 51fecb37f9..83b1905065 100644 --- a/src/openrct2/scripting/ScContext.hpp +++ b/src/openrct2/scripting/ScContext.hpp @@ -62,6 +62,7 @@ namespace OpenRCT2::Scripting captureOptions.Filename = fs::u8path(AsOrDefault(options["filename"], "")); captureOptions.Rotation = options["rotation"].as_int() & 3; captureOptions.Zoom = ZoomLevel(options["zoom"].as_int()); + captureOptions.Transparent = AsOrDefault(options["transparent"], false); auto dukPosition = options["position"]; if (dukPosition.type() == DukValue::Type::OBJECT) diff --git a/src/openrct2/scripting/ScriptEngine.cpp b/src/openrct2/scripting/ScriptEngine.cpp index a169753ddf..b7c3911337 100644 --- a/src/openrct2/scripting/ScriptEngine.cpp +++ b/src/openrct2/scripting/ScriptEngine.cpp @@ -44,7 +44,7 @@ using namespace OpenRCT2; using namespace OpenRCT2::Scripting; -static constexpr int32_t OPENRCT2_PLUGIN_API_VERSION = 21; +static constexpr int32_t OPENRCT2_PLUGIN_API_VERSION = 22; struct ExpressionStringifier final {