From bffc012d16e5ccb6cfc5f00e92796b276a46f7f6 Mon Sep 17 00:00:00 2001 From: Hielke Morsink Date: Thu, 30 May 2019 14:34:20 +0200 Subject: [PATCH] Implement #1260: --transparent switch for screenshot command --- src/openrct2/cmdline/ScreenshotCommands.cpp | 1 + src/openrct2/interface/Screenshot.cpp | 7 +++++++ src/openrct2/interface/Screenshot.h | 1 + src/openrct2/interface/Viewport.h | 1 + src/openrct2/paint/tile_element/Paint.TileElement.cpp | 4 ++-- 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/openrct2/cmdline/ScreenshotCommands.cpp b/src/openrct2/cmdline/ScreenshotCommands.cpp index a0ca954873..c0e8725ab7 100644 --- a/src/openrct2/cmdline/ScreenshotCommands.cpp +++ b/src/openrct2/cmdline/ScreenshotCommands.cpp @@ -24,6 +24,7 @@ static constexpr const CommandLineOptionDefinition ScreenshotOptionsDef[] { CMDLINE_TYPE_SWITCH, &options.fix_vandalism, NAC, "fix-vandalism", "fix vandalism for the screenshot" }, { CMDLINE_TYPE_SWITCH, &options.remove_litter, NAC, "remove-litter", "remove litter for the screenshot" }, { CMDLINE_TYPE_SWITCH, &options.tidy_up_park, NAC, "tidy-up-park", "clear grass, water plants, fix vandalism and remove litter" }, + { CMDLINE_TYPE_SWITCH, &options.transparent, NAC, "transparent", "make the background transparent" }, OptionTableEnd }; diff --git a/src/openrct2/interface/Screenshot.cpp b/src/openrct2/interface/Screenshot.cpp index c9e22efee6..0a4bdd176a 100644 --- a/src/openrct2/interface/Screenshot.cpp +++ b/src/openrct2/interface/Screenshot.cpp @@ -562,6 +562,8 @@ int32_t cmdline_for_screenshot(const char** argv, int32_t argc, ScreenshotOption dpi.bits = (uint8_t*)malloc(dpi.width * dpi.height); dpi.DrawingEngine = context->GetDrawingEngine(); + std::memset(dpi.bits, PALETTE_INDEX_0, dpi.width * dpi.height); + if (options->hide_guests) { viewport.flags |= VIEWPORT_FLAG_INVISIBLE_PEEPS; @@ -597,6 +599,11 @@ int32_t cmdline_for_screenshot(const char** argv, int32_t argc, ScreenshotOption CheatsSet(CheatType::RemoveLitter); } + if (options->transparent) + { + viewport.flags |= VIEWPORT_FLAG_TRANSPARENT_BACKGROUND; + } + viewport_render(&dpi, &viewport, 0, 0, viewport.width, viewport.height); rct_palette renderedPalette; diff --git a/src/openrct2/interface/Screenshot.h b/src/openrct2/interface/Screenshot.h index 8e0b3c60ab..f0e29bf8ba 100644 --- a/src/openrct2/interface/Screenshot.h +++ b/src/openrct2/interface/Screenshot.h @@ -28,6 +28,7 @@ struct ScreenshotOptions bool fix_vandalism = false; bool remove_litter = false; bool tidy_up_park = false; + bool transparent = false; }; void screenshot_check(); diff --git a/src/openrct2/interface/Viewport.h b/src/openrct2/interface/Viewport.h index 8c0ebac2e4..ec5a567c68 100644 --- a/src/openrct2/interface/Viewport.h +++ b/src/openrct2/interface/Viewport.h @@ -46,6 +46,7 @@ enum VIEWPORT_FLAG_SEETHROUGH_PATHS = (1 << 16), VIEWPORT_FLAG_CLIP_VIEW = (1 << 17), VIEWPORT_FLAG_HIGHLIGHT_PATH_ISSUES = (1 << 18), + VIEWPORT_FLAG_TRANSPARENT_BACKGROUND = (1 << 19), }; enum diff --git a/src/openrct2/paint/tile_element/Paint.TileElement.cpp b/src/openrct2/paint/tile_element/Paint.TileElement.cpp index 0632f8f7c0..baab66d438 100644 --- a/src/openrct2/paint/tile_element/Paint.TileElement.cpp +++ b/src/openrct2/paint/tile_element/Paint.TileElement.cpp @@ -57,7 +57,7 @@ void tile_element_paint_setup(paint_session* session, int32_t x, int32_t y) sub_68B3FB(session, x, y); } - else + else if (!(session->ViewFlags & VIEWPORT_FLAG_TRANSPARENT_BACKGROUND)) { blank_tiles_paint(session, x, y); } @@ -78,7 +78,7 @@ void sub_68B2B7(paint_session* session, int32_t x, int32_t y) sub_68B3FB(session, x, y); } - else + else if (!(session->ViewFlags & VIEWPORT_FLAG_TRANSPARENT_BACKGROUND)) { blank_tiles_paint(session, x, y); }