Skip to content

Commit

Permalink
add flag to json image import
Browse files Browse the repository at this point in the history
  • Loading branch information
spacek531 committed May 10, 2024
1 parent d586731 commit c2e9b84
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/openrct2/drawing/ImageImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include "../core/Imaging.h"
#include "../core/Json.hpp"
#include "../util/Util.h"

#include <cstring>
#include <stdexcept>
Expand Down Expand Up @@ -49,6 +50,7 @@ namespace OpenRCT2::Drawing
outElement.x_offset = meta.offset.x;
outElement.y_offset = meta.offset.y;
outElement.zoomed_offset = meta.zoomedOffset;
outElement.flags |= meta.importFlags & ImportFlags::NoDrawOnZoom ? G1_FLAG_NO_ZOOM_DRAW : 0;

ImageImporter::ImportResult result;
result.Element = outElement;
Expand Down Expand Up @@ -390,15 +392,19 @@ namespace OpenRCT2::Drawing
auto palette = keepPalette ? Palette::KeepIndices : Palette::OpenRCT2;

auto raw = Json::GetString(input["format"]) == "raw";
auto flags = raw ? ImportFlags::None : ImportFlags::RLE;

auto flags = EnumValue(raw ? ImportFlags::None : ImportFlags::RLE);
flags |= Json::GetFlags<uint32_t>(
input,
{
{ "noDrawOnZoom", ImportFlags::NoDrawOnZoom },
});
auto srcX = Json::GetNumber<int16_t>(input["srcX"]);
auto srcY = Json::GetNumber<int16_t>(input["srcY"]);
auto srcWidth = Json::GetNumber<int16_t>(input["srcWidth"]);
auto srcHeight = Json::GetNumber<int16_t>(input["srcHeight"]);
auto zoomedOffset = Json::GetNumber<int32_t>(input["zoom"]);

return ImageImportMeta{ { xOffset, yOffset }, palette, flags, ImportMode::Default, { srcX, srcY },
return ImageImportMeta{ { xOffset, yOffset }, palette, static_cast<ImportFlags>(flags), ImportMode::Default, { srcX, srcY },
{ srcWidth, srcHeight }, zoomedOffset };
};
} // namespace OpenRCT2::Drawing
1 change: 1 addition & 0 deletions src/openrct2/drawing/ImageImporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ namespace OpenRCT2::Drawing
{
None = 0,
RLE = 1 << 1,
NoDrawOnZoom = 1 << 2,
};

enum class Palette : uint8_t
Expand Down

0 comments on commit c2e9b84

Please sign in to comment.