mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-23 23:04:36 +01:00
Move platform_update_palette() to Drawing.cpp
This commit is contained in:
@@ -167,7 +167,7 @@ void update_palette_effects()
|
||||
paletteOffset[(i * 4) + 1] = -((0xFF - g1->offset[(i * 3) + 1]) / 2) - 1;
|
||||
paletteOffset[(i * 4) + 2] = -((0xFF - g1->offset[(i * 3) + 2]) / 2) - 1;
|
||||
}
|
||||
platform_update_palette(gGamePalette, PALETTE_OFFSET_DYNAMIC, PALETTE_LENGTH_DYNAMIC);
|
||||
UpdatePalette(gGamePalette, PALETTE_OFFSET_DYNAMIC, PALETTE_LENGTH_DYNAMIC);
|
||||
}
|
||||
gClimateLightningFlash++;
|
||||
}
|
||||
@@ -286,10 +286,10 @@ void update_palette_effects()
|
||||
}
|
||||
}
|
||||
|
||||
platform_update_palette(gGamePalette, PALETTE_OFFSET_ANIMATED, PALETTE_LENGTH_ANIMATED);
|
||||
UpdatePalette(gGamePalette, PALETTE_OFFSET_ANIMATED, PALETTE_LENGTH_ANIMATED);
|
||||
if (gClimateLightningFlash == 2)
|
||||
{
|
||||
platform_update_palette(gGamePalette, PALETTE_OFFSET_DYNAMIC, PALETTE_LENGTH_DYNAMIC);
|
||||
UpdatePalette(gGamePalette, PALETTE_OFFSET_DYNAMIC, PALETTE_LENGTH_DYNAMIC);
|
||||
gClimateLightningFlash = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "Drawing.h"
|
||||
|
||||
#include "../Context.h"
|
||||
#include "../Game.h"
|
||||
#include "../OpenRCT2.h"
|
||||
#include "../common.h"
|
||||
#include "../core/Guard.hpp"
|
||||
@@ -17,8 +18,10 @@
|
||||
#include "../platform/platform.h"
|
||||
#include "../sprites.h"
|
||||
#include "../util/Util.h"
|
||||
#include "../world/Climate.h"
|
||||
#include "../world/Location.hpp"
|
||||
#include "../world/Water.h"
|
||||
#include "LightFX.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
@@ -600,7 +603,7 @@ void gfx_transpose_palette(int32_t pal, uint8_t product)
|
||||
source_pointer += 3;
|
||||
dest_pointer += 4;
|
||||
}
|
||||
platform_update_palette(gGamePalette, 10, 236);
|
||||
UpdatePalette(gGamePalette, 10, 236);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -641,7 +644,7 @@ void load_palette()
|
||||
dst += 4;
|
||||
}
|
||||
}
|
||||
platform_update_palette(gGamePalette, 10, 236);
|
||||
UpdatePalette(gGamePalette, 10, 236);
|
||||
gfx_invalidate_screen();
|
||||
}
|
||||
|
||||
@@ -787,3 +790,49 @@ FilterPaletteID GetGlassPaletteId(colour_t c)
|
||||
{
|
||||
return GlassPaletteIds[c];
|
||||
}
|
||||
|
||||
void UpdatePalette(const uint8_t* colours, int32_t start_index, int32_t num_colours)
|
||||
{
|
||||
colours += start_index * 4;
|
||||
|
||||
for (int32_t i = start_index; i < num_colours + start_index; i++)
|
||||
{
|
||||
uint8_t r = colours[2];
|
||||
uint8_t g = colours[1];
|
||||
uint8_t b = colours[0];
|
||||
|
||||
#ifdef __ENABLE_LIGHTFX__
|
||||
if (lightfx_is_available())
|
||||
{
|
||||
lightfx_apply_palette_filter(i, &r, &g, &b);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
float night = gDayNightCycle;
|
||||
if (night >= 0 && gClimateLightningFlash == 0)
|
||||
{
|
||||
r = lerp(r, soft_light(r, 8), night);
|
||||
g = lerp(g, soft_light(g, 8), night);
|
||||
b = lerp(b, soft_light(b, 128), night);
|
||||
}
|
||||
}
|
||||
|
||||
gPalette[i].Red = r;
|
||||
gPalette[i].Green = g;
|
||||
gPalette[i].Blue = b;
|
||||
gPalette[i].Alpha = 0;
|
||||
colours += 4;
|
||||
}
|
||||
|
||||
// Fix #1749 and #6535: rainbow path, donut shop and pause button contain black spots that should be white.
|
||||
gPalette[255].Alpha = 0;
|
||||
gPalette[255].Red = 255;
|
||||
gPalette[255].Green = 255;
|
||||
gPalette[255].Blue = 255;
|
||||
|
||||
if (!gOpenRCT2Headless)
|
||||
{
|
||||
drawing_engine_set_palette(gPalette);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -599,5 +599,6 @@ extern void (*mask_fn)(
|
||||
|
||||
std::optional<uint32_t> GetPaletteG1Index(colour_t paletteId);
|
||||
std::optional<PaletteMap> GetPaletteMapForColour(colour_t paletteId);
|
||||
void UpdatePalette(const uint8_t* colours, int32_t start_index, int32_t num_colours);
|
||||
|
||||
#include "NewDrawing.h"
|
||||
|
||||
@@ -141,52 +141,6 @@ namespace Platform
|
||||
|
||||
GamePalette gPalette;
|
||||
|
||||
void platform_update_palette(const uint8_t* colours, int32_t start_index, int32_t num_colours)
|
||||
{
|
||||
colours += start_index * 4;
|
||||
|
||||
for (int32_t i = start_index; i < num_colours + start_index; i++)
|
||||
{
|
||||
uint8_t r = colours[2];
|
||||
uint8_t g = colours[1];
|
||||
uint8_t b = colours[0];
|
||||
|
||||
#ifdef __ENABLE_LIGHTFX__
|
||||
if (lightfx_is_available())
|
||||
{
|
||||
lightfx_apply_palette_filter(i, &r, &g, &b);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
float night = gDayNightCycle;
|
||||
if (night >= 0 && gClimateLightningFlash == 0)
|
||||
{
|
||||
r = lerp(r, soft_light(r, 8), night);
|
||||
g = lerp(g, soft_light(g, 8), night);
|
||||
b = lerp(b, soft_light(b, 128), night);
|
||||
}
|
||||
}
|
||||
|
||||
gPalette[i].Red = r;
|
||||
gPalette[i].Green = g;
|
||||
gPalette[i].Blue = b;
|
||||
gPalette[i].Alpha = 0;
|
||||
colours += 4;
|
||||
}
|
||||
|
||||
// Fix #1749 and #6535: rainbow path, donut shop and pause button contain black spots that should be white.
|
||||
gPalette[255].Alpha = 0;
|
||||
gPalette[255].Red = 255;
|
||||
gPalette[255].Green = 255;
|
||||
gPalette[255].Blue = 255;
|
||||
|
||||
if (!gOpenRCT2Headless)
|
||||
{
|
||||
drawing_engine_set_palette(gPalette);
|
||||
}
|
||||
}
|
||||
|
||||
void platform_toggle_windowed_mode()
|
||||
{
|
||||
int32_t targetMode = gConfigGeneral.fullscreen_mode == 0 ? 2 : 0;
|
||||
|
||||
@@ -82,7 +82,6 @@ struct file_dialog_desc
|
||||
};
|
||||
|
||||
// Platform shared definitions
|
||||
void platform_update_palette(const uint8_t* colours, int32_t start_index, int32_t num_colours);
|
||||
void platform_toggle_windowed_mode();
|
||||
void platform_refresh_video(bool recreate_window);
|
||||
|
||||
|
||||
@@ -389,7 +389,7 @@ static void scenario_update_daynight_cycle()
|
||||
// Only update palette if day / night cycle has changed
|
||||
if (gDayNightCycle != currentDayNightCycle)
|
||||
{
|
||||
platform_update_palette(gGamePalette, 10, 236);
|
||||
UpdatePalette(gGamePalette, 10, 236);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user