mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-24 00:03:11 +01:00
Refactor rct_palette to GamePalette
This commit is contained in:
@@ -155,23 +155,23 @@ public:
|
|||||||
ConfigureBits(width, height, width);
|
ConfigureBits(width, height, width);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetPalette(const rct_palette_entry* palette) override
|
void SetPalette(const GamePalette& palette) override
|
||||||
{
|
{
|
||||||
if (_screenTextureFormat != nullptr)
|
if (_screenTextureFormat != nullptr)
|
||||||
{
|
{
|
||||||
for (int32_t i = 0; i < 256; i++)
|
for (int32_t i = 0; i < 256; i++)
|
||||||
{
|
{
|
||||||
_paletteHWMapped[i] = SDL_MapRGB(_screenTextureFormat, palette[i].red, palette[i].green, palette[i].blue);
|
_paletteHWMapped[i] = SDL_MapRGB(_screenTextureFormat, palette[i].Red, palette[i].Green, palette[i].Blue);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __ENABLE_LIGHTFX__
|
#ifdef __ENABLE_LIGHTFX__
|
||||||
if (gConfigGeneral.enable_light_fx)
|
if (gConfigGeneral.enable_light_fx)
|
||||||
{
|
{
|
||||||
auto lightPalette = lightfx_get_palette();
|
auto& lightPalette = lightfx_get_palette();
|
||||||
for (int32_t i = 0; i < 256; i++)
|
for (int32_t i = 0; i < 256; i++)
|
||||||
{
|
{
|
||||||
auto src = &lightPalette->entries[i];
|
const auto& src = lightPalette[i];
|
||||||
_lightPaletteHWMapped[i] = SDL_MapRGBA(_screenTextureFormat, src->red, src->green, src->blue, src->alpha);
|
_lightPaletteHWMapped[i] = SDL_MapRGBA(_screenTextureFormat, src.Red, src.Green, src.Blue, src.Alpha);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ public:
|
|||||||
ConfigureBits(width, height, _surface->pitch);
|
ConfigureBits(width, height, _surface->pitch);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetPalette(const rct_palette_entry* palette) override
|
void SetPalette(const GamePalette& palette) override
|
||||||
{
|
{
|
||||||
SDL_Surface* windowSurface = SDL_GetWindowSurface(_window);
|
SDL_Surface* windowSurface = SDL_GetWindowSurface(_window);
|
||||||
if (windowSurface != nullptr && _palette != nullptr)
|
if (windowSurface != nullptr && _palette != nullptr)
|
||||||
@@ -85,10 +85,10 @@ public:
|
|||||||
SDL_Colour colours[256];
|
SDL_Colour colours[256];
|
||||||
for (int32_t i = 0; i < 256; i++)
|
for (int32_t i = 0; i < 256; i++)
|
||||||
{
|
{
|
||||||
colours[i].r = palette[i].red;
|
colours[i].r = palette[i].Red;
|
||||||
colours[i].g = palette[i].green;
|
colours[i].g = palette[i].Green;
|
||||||
colours[i].b = palette[i].blue;
|
colours[i].b = palette[i].Blue;
|
||||||
colours[i].a = palette[i].alpha;
|
colours[i].a = palette[i].Alpha;
|
||||||
}
|
}
|
||||||
SDL_SetPaletteColors(_palette, colours, 0, 256);
|
SDL_SetPaletteColors(_palette, colours, 0, 256);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -255,14 +255,14 @@ public:
|
|||||||
_drawingContext->Resize(width, height);
|
_drawingContext->Resize(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetPalette(const rct_palette_entry* palette) override
|
void SetPalette(const GamePalette& palette) override
|
||||||
{
|
{
|
||||||
for (int32_t i = 0; i < 256; i++)
|
for (int32_t i = 0; i < 256; i++)
|
||||||
{
|
{
|
||||||
SDL_Color colour;
|
SDL_Color colour;
|
||||||
colour.r = palette[i].red;
|
colour.r = palette[i].Red;
|
||||||
colour.g = palette[i].green;
|
colour.g = palette[i].Green;
|
||||||
colour.b = palette[i].blue;
|
colour.b = palette[i].Blue;
|
||||||
colour.a = i == 0 ? 0 : 255;
|
colour.a = i == 0 ? 0 : 255;
|
||||||
|
|
||||||
Palette[i] = colour;
|
Palette[i] = colour;
|
||||||
|
|||||||
@@ -245,7 +245,7 @@ static bool sprite_file_export(rct_g1_element* spriteHeader, const char* outPath
|
|||||||
image.Height = dpi.height;
|
image.Height = dpi.height;
|
||||||
image.Depth = 8;
|
image.Depth = 8;
|
||||||
image.Stride = dpi.width + dpi.pitch;
|
image.Stride = dpi.width + dpi.pitch;
|
||||||
image.Palette = std::make_unique<rct_palette>(*(reinterpret_cast<rct_palette*>(&spriteFilePalette)));
|
image.Palette = std::make_unique<GamePalette>(StandardPalette);
|
||||||
image.Pixels = std::vector<uint8_t>(pixels8, pixels8 + pixelsLen);
|
image.Pixels = std::vector<uint8_t>(pixels8, pixels8 + pixelsLen);
|
||||||
Imaging::WriteToFile(outPath, image, IMAGE_FORMAT::PNG);
|
Imaging::WriteToFile(outPath, image, IMAGE_FORMAT::PNG);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -200,10 +200,10 @@ namespace Imaging
|
|||||||
}
|
}
|
||||||
for (size_t i = 0; i < PNG_MAX_PALETTE_LENGTH; i++)
|
for (size_t i = 0; i < PNG_MAX_PALETTE_LENGTH; i++)
|
||||||
{
|
{
|
||||||
const auto entry = &image.Palette->entries[i];
|
const auto& entry = (*image.Palette)[static_cast<uint16_t>(i)];
|
||||||
png_palette[i].blue = entry->blue;
|
png_palette[i].blue = entry.Blue;
|
||||||
png_palette[i].green = entry->green;
|
png_palette[i].green = entry.Green;
|
||||||
png_palette[i].red = entry->red;
|
png_palette[i].red = entry.Red;
|
||||||
}
|
}
|
||||||
png_set_PLTE(png_ptr, info_ptr, png_palette, PNG_MAX_PALETTE_LENGTH);
|
png_set_PLTE(png_ptr, info_ptr, png_palette, PNG_MAX_PALETTE_LENGTH);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,36 +19,6 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
struct rct_drawpixelinfo;
|
struct rct_drawpixelinfo;
|
||||||
struct rct_palette;
|
|
||||||
|
|
||||||
struct PaletteBGRA
|
|
||||||
{
|
|
||||||
uint8_t Blue{};
|
|
||||||
uint8_t Green{};
|
|
||||||
uint8_t Red{};
|
|
||||||
uint8_t Alpha{};
|
|
||||||
};
|
|
||||||
|
|
||||||
constexpr const auto PALETTE_SIZE = 256;
|
|
||||||
|
|
||||||
struct GamePalette
|
|
||||||
{
|
|
||||||
PaletteBGRA Colour[PALETTE_SIZE];
|
|
||||||
|
|
||||||
const PaletteBGRA operator[](uint16_t idx) const
|
|
||||||
{
|
|
||||||
assert(idx < PALETTE_SIZE);
|
|
||||||
if (idx >= PALETTE_SIZE)
|
|
||||||
return {};
|
|
||||||
|
|
||||||
return Colour[idx];
|
|
||||||
}
|
|
||||||
|
|
||||||
explicit operator uint8_t*()
|
|
||||||
{
|
|
||||||
return reinterpret_cast<uint8_t*>(Colour);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class IMAGE_FORMAT
|
enum class IMAGE_FORMAT
|
||||||
{
|
{
|
||||||
@@ -68,7 +38,7 @@ struct Image
|
|||||||
|
|
||||||
// Data
|
// Data
|
||||||
std::vector<uint8_t> Pixels;
|
std::vector<uint8_t> Pixels;
|
||||||
std::unique_ptr<rct_palette> Palette;
|
std::unique_ptr<GamePalette> Palette;
|
||||||
uint32_t Stride{};
|
uint32_t Stride{};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#include "../interface/Colour.h"
|
#include "../interface/Colour.h"
|
||||||
#include "../interface/ZoomLevel.hpp"
|
#include "../interface/ZoomLevel.hpp"
|
||||||
|
|
||||||
|
#include <optional>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
struct ScreenCoordsXY;
|
struct ScreenCoordsXY;
|
||||||
|
|
||||||
@@ -28,6 +29,47 @@ namespace OpenRCT2::Drawing
|
|||||||
interface IDrawingEngine;
|
interface IDrawingEngine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct PaletteBGRA
|
||||||
|
{
|
||||||
|
uint8_t Blue{};
|
||||||
|
uint8_t Green{};
|
||||||
|
uint8_t Red{};
|
||||||
|
uint8_t Alpha{};
|
||||||
|
};
|
||||||
|
|
||||||
|
constexpr const auto PALETTE_SIZE = 256;
|
||||||
|
|
||||||
|
struct GamePalette
|
||||||
|
{
|
||||||
|
PaletteBGRA Colour[PALETTE_SIZE]{};
|
||||||
|
|
||||||
|
PaletteBGRA& operator[](uint16_t idx)
|
||||||
|
{
|
||||||
|
assert(idx < PALETTE_SIZE);
|
||||||
|
if (idx >= PALETTE_SIZE)
|
||||||
|
{
|
||||||
|
static PaletteBGRA dummy;
|
||||||
|
return dummy;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Colour[idx];
|
||||||
|
}
|
||||||
|
|
||||||
|
const PaletteBGRA operator[](uint16_t idx) const
|
||||||
|
{
|
||||||
|
assert(idx < PALETTE_SIZE);
|
||||||
|
if (idx >= PALETTE_SIZE)
|
||||||
|
return {};
|
||||||
|
|
||||||
|
return Colour[idx];
|
||||||
|
}
|
||||||
|
|
||||||
|
explicit operator uint8_t*()
|
||||||
|
{
|
||||||
|
return reinterpret_cast<uint8_t*>(Colour);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
struct rct_g1_element
|
struct rct_g1_element
|
||||||
{
|
{
|
||||||
uint8_t* offset; // 0x00
|
uint8_t* offset; // 0x00
|
||||||
@@ -227,24 +269,6 @@ struct translucent_window_palette
|
|||||||
FILTER_PALETTE_ID shadow;
|
FILTER_PALETTE_ID shadow;
|
||||||
};
|
};
|
||||||
|
|
||||||
#pragma pack(push, 1)
|
|
||||||
|
|
||||||
struct rct_palette_entry
|
|
||||||
{
|
|
||||||
uint8_t blue;
|
|
||||||
uint8_t green;
|
|
||||||
uint8_t red;
|
|
||||||
uint8_t alpha;
|
|
||||||
};
|
|
||||||
assert_struct_size(rct_palette_entry, 4);
|
|
||||||
|
|
||||||
#pragma pack(pop)
|
|
||||||
|
|
||||||
struct rct_palette
|
|
||||||
{
|
|
||||||
rct_palette_entry entries[256];
|
|
||||||
};
|
|
||||||
|
|
||||||
struct rct_size16
|
struct rct_size16
|
||||||
{
|
{
|
||||||
int16_t width;
|
int16_t width;
|
||||||
@@ -443,7 +467,7 @@ public:
|
|||||||
extern thread_local int16_t gCurrentFontSpriteBase;
|
extern thread_local int16_t gCurrentFontSpriteBase;
|
||||||
extern thread_local uint16_t gCurrentFontFlags;
|
extern thread_local uint16_t gCurrentFontFlags;
|
||||||
|
|
||||||
extern rct_palette_entry gPalette[256];
|
extern GamePalette gPalette;
|
||||||
extern uint8_t gGamePalette[256 * 4];
|
extern uint8_t gGamePalette[256 * 4];
|
||||||
extern uint32_t gPaletteEffectFrame;
|
extern uint32_t gPaletteEffectFrame;
|
||||||
extern const FILTER_PALETTE_ID GlassPaletteIds[COLOUR_COUNT];
|
extern const FILTER_PALETTE_ID GlassPaletteIds[COLOUR_COUNT];
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ enum DRAWING_ENGINE_FLAGS
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct rct_drawpixelinfo;
|
struct rct_drawpixelinfo;
|
||||||
struct rct_palette_entry;
|
struct GamePalette;
|
||||||
|
|
||||||
namespace OpenRCT2::Ui
|
namespace OpenRCT2::Ui
|
||||||
{
|
{
|
||||||
@@ -54,7 +54,7 @@ namespace OpenRCT2::Drawing
|
|||||||
|
|
||||||
virtual void Initialise() abstract;
|
virtual void Initialise() abstract;
|
||||||
virtual void Resize(uint32_t width, uint32_t height) abstract;
|
virtual void Resize(uint32_t width, uint32_t height) abstract;
|
||||||
virtual void SetPalette(const rct_palette_entry* colours) abstract;
|
virtual void SetPalette(const GamePalette& colours) abstract;
|
||||||
|
|
||||||
virtual void SetVSync(bool vsync) abstract;
|
virtual void SetVSync(bool vsync) abstract;
|
||||||
|
|
||||||
|
|||||||
@@ -225,7 +225,7 @@ std::tuple<void*, size_t> ImageImporter::EncodeRLE(const int32_t* pixels, uint32
|
|||||||
int32_t ImageImporter::CalculatePaletteIndex(
|
int32_t ImageImporter::CalculatePaletteIndex(
|
||||||
IMPORT_MODE mode, int16_t* rgbaSrc, int32_t x, int32_t y, int32_t width, int32_t height)
|
IMPORT_MODE mode, int16_t* rgbaSrc, int32_t x, int32_t y, int32_t width, int32_t height)
|
||||||
{
|
{
|
||||||
auto palette = StandardPalette;
|
auto& palette = StandardPalette;
|
||||||
auto paletteIndex = GetPaletteIndex(palette, rgbaSrc);
|
auto paletteIndex = GetPaletteIndex(palette, rgbaSrc);
|
||||||
if (mode == IMPORT_MODE::CLOSEST || mode == IMPORT_MODE::DITHERING)
|
if (mode == IMPORT_MODE::CLOSEST || mode == IMPORT_MODE::DITHERING)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ static uint8_t _current_view_rotation_back = 0;
|
|||||||
static ZoomLevel _current_view_zoom_back = 0;
|
static ZoomLevel _current_view_zoom_back = 0;
|
||||||
static ZoomLevel _current_view_zoom_back_delay = 0;
|
static ZoomLevel _current_view_zoom_back_delay = 0;
|
||||||
|
|
||||||
static rct_palette gPalette_light;
|
static GamePalette gPalette_light;
|
||||||
|
|
||||||
static uint8_t calc_light_intensity_lantern(int32_t x, int32_t y)
|
static uint8_t calc_light_intensity_lantern(int32_t x, int32_t y)
|
||||||
{
|
{
|
||||||
@@ -614,9 +614,9 @@ void* lightfx_get_front_buffer()
|
|||||||
return _light_rendered_buffer_front;
|
return _light_rendered_buffer_front;
|
||||||
}
|
}
|
||||||
|
|
||||||
const rct_palette* lightfx_get_palette()
|
const GamePalette& lightfx_get_palette()
|
||||||
{
|
{
|
||||||
return &gPalette_light;
|
return gPalette_light;
|
||||||
}
|
}
|
||||||
|
|
||||||
void lightfx_add_3d_light(uint32_t lightID, uint16_t lightIDqualifier, int16_t x, int16_t y, uint16_t z, uint8_t lightType)
|
void lightfx_add_3d_light(uint32_t lightID, uint16_t lightIDqualifier, int16_t x, int16_t y, uint16_t z, uint8_t lightType)
|
||||||
@@ -971,12 +971,12 @@ void lightfx_apply_palette_filter(uint8_t i, uint8_t* r, uint8_t* g, uint8_t* b)
|
|||||||
std::max(
|
std::max(
|
||||||
0.0f, (-overExpose + static_cast<float>(*b) * reduceColourNat * natLightB + envFog * fogB + addLightNatB))));
|
0.0f, (-overExpose + static_cast<float>(*b) * reduceColourNat * natLightB + envFog * fogB + addLightNatB))));
|
||||||
|
|
||||||
rct_palette_entry* dstEntry = &gPalette_light.entries[i];
|
auto dstEntry = &gPalette_light[i];
|
||||||
dstEntry->red = static_cast<uint8_t>(
|
dstEntry->Red = static_cast<uint8_t>(
|
||||||
std::min<float>(0xFF, (static_cast<float>(*r) * reduceColourLit * boost + lightFog) * elecMultR));
|
std::min<float>(0xFF, (static_cast<float>(*r) * reduceColourLit * boost + lightFog) * elecMultR));
|
||||||
dstEntry->green = static_cast<uint8_t>(
|
dstEntry->Green = static_cast<uint8_t>(
|
||||||
std::min<float>(0xFF, (static_cast<float>(*g) * reduceColourLit * boost + lightFog) * elecMultG));
|
std::min<float>(0xFF, (static_cast<float>(*g) * reduceColourLit * boost + lightFog) * elecMultG));
|
||||||
dstEntry->blue = static_cast<uint8_t>(
|
dstEntry->Blue = static_cast<uint8_t>(
|
||||||
std::min<float>(0xFF, (static_cast<float>(*b) * reduceColourLit * boost + lightFog) * elecMultB));
|
std::min<float>(0xFF, (static_cast<float>(*b) * reduceColourLit * boost + lightFog) * elecMultB));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
struct CoordsXY;
|
struct CoordsXY;
|
||||||
struct Vehicle;
|
struct Vehicle;
|
||||||
struct rct_drawpixelinfo;
|
struct rct_drawpixelinfo;
|
||||||
struct rct_palette;
|
struct GamePalette;
|
||||||
|
|
||||||
enum LIGHTFX_LIGHT_TYPE
|
enum LIGHTFX_LIGHT_TYPE
|
||||||
{
|
{
|
||||||
@@ -57,7 +57,7 @@ void lightfx_render_lights_to_frontbuffer();
|
|||||||
void lightfx_update_viewport_settings();
|
void lightfx_update_viewport_settings();
|
||||||
|
|
||||||
void* lightfx_get_front_buffer();
|
void* lightfx_get_front_buffer();
|
||||||
const rct_palette* lightfx_get_palette();
|
const GamePalette& lightfx_get_palette();
|
||||||
|
|
||||||
void lightfx_add_3d_light(uint32_t lightID, uint16_t lightIDqualifier, int16_t x, int16_t y, uint16_t z, uint8_t lightType);
|
void lightfx_add_3d_light(uint32_t lightID, uint16_t lightIDqualifier, int16_t x, int16_t y, uint16_t z, uint8_t lightType);
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ void drawing_engine_resize()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawing_engine_set_palette(const rct_palette_entry* colours)
|
void drawing_engine_set_palette(const GamePalette& colours)
|
||||||
{
|
{
|
||||||
auto context = GetContext();
|
auto context = GetContext();
|
||||||
if (context != nullptr)
|
if (context != nullptr)
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
|
|
||||||
struct rct_drawpixelinfo;
|
struct rct_drawpixelinfo;
|
||||||
struct rct_palette_entry;
|
struct GamePalette;
|
||||||
|
|
||||||
extern rct_string_id DrawingEngineStringIds[3];
|
extern rct_string_id DrawingEngineStringIds[3];
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ int32_t drawing_engine_get_type();
|
|||||||
bool drawing_engine_requires_new_window(int32_t srcEngine, int32_t dstEngine);
|
bool drawing_engine_requires_new_window(int32_t srcEngine, int32_t dstEngine);
|
||||||
void drawing_engine_init();
|
void drawing_engine_init();
|
||||||
void drawing_engine_resize();
|
void drawing_engine_resize();
|
||||||
void drawing_engine_set_palette(const rct_palette_entry* colours);
|
void drawing_engine_set_palette(const GamePalette& colours);
|
||||||
void drawing_engine_copy_rect(int32_t x, int32_t y, int32_t width, int32_t height, int32_t dx, int32_t dy);
|
void drawing_engine_copy_rect(int32_t x, int32_t y, int32_t width, int32_t height, int32_t dx, int32_t dy);
|
||||||
void drawing_engine_dispose();
|
void drawing_engine_dispose();
|
||||||
|
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ void X8DrawingEngine::Resize(uint32_t width, uint32_t height)
|
|||||||
ConfigureBits(width, height, pitch);
|
ConfigureBits(width, height, pitch);
|
||||||
}
|
}
|
||||||
|
|
||||||
void X8DrawingEngine::SetPalette([[maybe_unused]] const rct_palette_entry* palette)
|
void X8DrawingEngine::SetPalette([[maybe_unused]] const GamePalette& palette)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ namespace OpenRCT2
|
|||||||
|
|
||||||
void Initialise() override;
|
void Initialise() override;
|
||||||
void Resize(uint32_t width, uint32_t height) override;
|
void Resize(uint32_t width, uint32_t height) override;
|
||||||
void SetPalette(const rct_palette_entry* palette) override;
|
void SetPalette(const GamePalette& palette) override;
|
||||||
void SetVSync(bool vsync) override;
|
void SetVSync(bool vsync) override;
|
||||||
void Invalidate(int32_t left, int32_t top, int32_t right, int32_t bottom) override;
|
void Invalidate(int32_t left, int32_t top, int32_t right, int32_t bottom) override;
|
||||||
void BeginDraw() override;
|
void BeginDraw() override;
|
||||||
|
|||||||
@@ -67,8 +67,8 @@ static uint8_t findClosestPaletteIndex(uint8_t red, uint8_t green, uint8_t blue)
|
|||||||
|
|
||||||
for (int i = PALETTE_INDEX_0; i < PALETTE_INDEX_230; i++)
|
for (int i = PALETTE_INDEX_0; i < PALETTE_INDEX_230; i++)
|
||||||
{
|
{
|
||||||
const int32_t distance = std::pow(gPalette[i].red - red, 2) + std::pow(gPalette[i].green - green, 2)
|
const int32_t distance = std::pow(gPalette[i].Red - red, 2) + std::pow(gPalette[i].Green - green, 2)
|
||||||
+ std::pow(gPalette[i].blue - blue, 2);
|
+ std::pow(gPalette[i].Blue - blue, 2);
|
||||||
|
|
||||||
if (distance < closestDistance)
|
if (distance < closestDistance)
|
||||||
{
|
{
|
||||||
@@ -90,9 +90,9 @@ uint8_t blendColours(const uint8_t paletteIndex1, const uint8_t paletteIndex2)
|
|||||||
return BlendColourMap[cMin][cMax];
|
return BlendColourMap[cMin][cMax];
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t red = (gPalette[cMin].red + gPalette[cMax].red) / 2;
|
uint8_t red = (gPalette[cMin].Red + gPalette[cMax].Red) / 2;
|
||||||
uint8_t green = (gPalette[cMin].green + gPalette[cMax].green) / 2;
|
uint8_t green = (gPalette[cMin].Green + gPalette[cMax].Green) / 2;
|
||||||
uint8_t blue = (gPalette[cMin].blue + gPalette[cMax].blue) / 2;
|
uint8_t blue = (gPalette[cMin].Blue + gPalette[cMax].Blue) / 2;
|
||||||
|
|
||||||
BlendColourMap[cMin][cMax] = findClosestPaletteIndex(red, green, blue);
|
BlendColourMap[cMin][cMax] = findClosestPaletteIndex(red, green, blue);
|
||||||
return BlendColourMap[cMin][cMax];
|
return BlendColourMap[cMin][cMax];
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ using namespace OpenRCT2::Drawing;
|
|||||||
|
|
||||||
uint8_t gScreenshotCountdown = 0;
|
uint8_t gScreenshotCountdown = 0;
|
||||||
|
|
||||||
static bool WriteDpiToFile(const std::string_view& path, const rct_drawpixelinfo* dpi, const rct_palette& palette)
|
static bool WriteDpiToFile(const std::string_view& path, const rct_drawpixelinfo* dpi, const GamePalette& palette)
|
||||||
{
|
{
|
||||||
auto const pixels8 = dpi->bits;
|
auto const pixels8 = dpi->bits;
|
||||||
auto const pixelsLen = (dpi->width + dpi->pitch) * dpi->height;
|
auto const pixelsLen = (dpi->width + dpi->pitch) * dpi->height;
|
||||||
@@ -52,7 +52,7 @@ static bool WriteDpiToFile(const std::string_view& path, const rct_drawpixelinfo
|
|||||||
image.Height = dpi->height;
|
image.Height = dpi->height;
|
||||||
image.Depth = 8;
|
image.Depth = 8;
|
||||||
image.Stride = dpi->width + dpi->pitch;
|
image.Stride = dpi->width + dpi->pitch;
|
||||||
image.Palette = std::make_unique<rct_palette>(palette);
|
image.Palette = std::make_unique<GamePalette>(palette);
|
||||||
image.Pixels = std::vector<uint8_t>(pixels8, pixels8 + pixelsLen);
|
image.Pixels = std::vector<uint8_t>(pixels8, pixels8 + pixelsLen);
|
||||||
Imaging::WriteToFile(path, image, IMAGE_FORMAT::PNG);
|
Imaging::WriteToFile(path, image, IMAGE_FORMAT::PNG);
|
||||||
return true;
|
return true;
|
||||||
@@ -92,16 +92,6 @@ void screenshot_check()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static rct_palette screenshot_get_rendered_palette()
|
|
||||||
{
|
|
||||||
rct_palette palette;
|
|
||||||
for (int32_t i = 0; i < 256; i++)
|
|
||||||
{
|
|
||||||
palette.entries[i] = gPalette[i];
|
|
||||||
}
|
|
||||||
return palette;
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::string screenshot_get_park_name()
|
static std::string screenshot_get_park_name()
|
||||||
{
|
{
|
||||||
return GetContext()->GetGameState()->GetPark().Name;
|
return GetContext()->GetGameState()->GetPark().Name;
|
||||||
@@ -178,8 +168,7 @@ std::string screenshot_dump_png(rct_drawpixelinfo* dpi)
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
auto renderedPalette = screenshot_get_rendered_palette();
|
if (WriteDpiToFile(path->c_str(), dpi, gPalette))
|
||||||
if (WriteDpiToFile(path->c_str(), dpi, renderedPalette))
|
|
||||||
{
|
{
|
||||||
return *path;
|
return *path;
|
||||||
}
|
}
|
||||||
@@ -425,8 +414,7 @@ void screenshot_giant()
|
|||||||
dpi = CreateDPI(viewport);
|
dpi = CreateDPI(viewport);
|
||||||
|
|
||||||
RenderViewport(nullptr, viewport, dpi);
|
RenderViewport(nullptr, viewport, dpi);
|
||||||
auto renderedPalette = screenshot_get_rendered_palette();
|
WriteDpiToFile(path->c_str(), &dpi, gPalette);
|
||||||
WriteDpiToFile(path->c_str(), &dpi, renderedPalette);
|
|
||||||
|
|
||||||
// Show user that screenshot saved successfully
|
// Show user that screenshot saved successfully
|
||||||
auto ft = Formatter::Common();
|
auto ft = Formatter::Common();
|
||||||
@@ -744,8 +732,7 @@ int32_t cmdline_for_screenshot(const char** argv, int32_t argc, ScreenshotOption
|
|||||||
dpi = CreateDPI(viewport);
|
dpi = CreateDPI(viewport);
|
||||||
|
|
||||||
RenderViewport(nullptr, viewport, dpi);
|
RenderViewport(nullptr, viewport, dpi);
|
||||||
auto renderedPalette = screenshot_get_rendered_palette();
|
WriteDpiToFile(outputPath, &dpi, gPalette);
|
||||||
WriteDpiToFile(outputPath, &dpi, renderedPalette);
|
|
||||||
}
|
}
|
||||||
catch (const std::exception& e)
|
catch (const std::exception& e)
|
||||||
{
|
{
|
||||||
@@ -838,8 +825,7 @@ void CaptureImage(const CaptureOptions& options)
|
|||||||
auto outputPath = ResolveFilenameForCapture(options.Filename);
|
auto outputPath = ResolveFilenameForCapture(options.Filename);
|
||||||
auto dpi = CreateDPI(viewport);
|
auto dpi = CreateDPI(viewport);
|
||||||
RenderViewport(nullptr, viewport, dpi);
|
RenderViewport(nullptr, viewport, dpi);
|
||||||
auto renderedPalette = screenshot_get_rendered_palette();
|
WriteDpiToFile(outputPath, &dpi, gPalette);
|
||||||
WriteDpiToFile(outputPath, &dpi, renderedPalette);
|
|
||||||
ReleaseDPI(dpi);
|
ReleaseDPI(dpi);
|
||||||
|
|
||||||
gCurrentRotation = backupRotation;
|
gCurrentRotation = backupRotation;
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ static LARGE_INTEGER _entryTimestamp;
|
|||||||
|
|
||||||
using update_palette_func = void (*)(const uint8_t*, int32_t, int32_t);
|
using update_palette_func = void (*)(const uint8_t*, int32_t, int32_t);
|
||||||
|
|
||||||
rct_palette_entry gPalette[256];
|
GamePalette gPalette;
|
||||||
|
|
||||||
void platform_update_palette(const uint8_t* colours, int32_t start_index, int32_t num_colours)
|
void platform_update_palette(const uint8_t* colours, int32_t start_index, int32_t num_colours)
|
||||||
{
|
{
|
||||||
@@ -95,18 +95,18 @@ void platform_update_palette(const uint8_t* colours, int32_t start_index, int32_
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gPalette[i].red = r;
|
gPalette[i].Red = r;
|
||||||
gPalette[i].green = g;
|
gPalette[i].Green = g;
|
||||||
gPalette[i].blue = b;
|
gPalette[i].Blue = b;
|
||||||
gPalette[i].alpha = 0;
|
gPalette[i].Alpha = 0;
|
||||||
colours += 4;
|
colours += 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fix #1749 and #6535: rainbow path, donut shop and pause button contain black spots that should be white.
|
// Fix #1749 and #6535: rainbow path, donut shop and pause button contain black spots that should be white.
|
||||||
gPalette[255].alpha = 0;
|
gPalette[255].Alpha = 0;
|
||||||
gPalette[255].red = 255;
|
gPalette[255].Red = 255;
|
||||||
gPalette[255].green = 255;
|
gPalette[255].Green = 255;
|
||||||
gPalette[255].blue = 255;
|
gPalette[255].Blue = 255;
|
||||||
|
|
||||||
if (!gOpenRCT2Headless)
|
if (!gOpenRCT2Headless)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user