forked from rosebudai/OpenRCT2-Web
Move game palette-related stuff into Palette.{cpp.h}
This commit is contained in:
23 files changed
+352
-302
No files matched your search
@@ -19,6 +19,7 @@
|
||||
#include <openrct2/ParkImporter.h>
|
||||
#include <openrct2/core/Console.hpp>
|
||||
#include <openrct2/drawing/Drawing.h>
|
||||
#include <openrct2/drawing/Palette.h>
|
||||
#include <openrct2/drawing/ScrollingText.h>
|
||||
#include <openrct2/entity/EntityRegistry.h>
|
||||
#include <openrct2/interface/Viewport.h>
|
||||
@@ -441,7 +442,7 @@ namespace OpenRCT2::Title
|
||||
ContextBroadcastIntent(&intent);
|
||||
Ui::Windows::WindowScenerySetDefaultPlacementConfiguration();
|
||||
News::InitQueue(gameState);
|
||||
LoadPalette();
|
||||
Drawing::LoadPalette();
|
||||
gScreenAge = 0;
|
||||
gGamePaused = false;
|
||||
gGameSpeed = 1;
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <openrct2/core/String.hpp>
|
||||
#include <openrct2/drawing/ColourMap.h>
|
||||
#include <openrct2/drawing/Drawing.h>
|
||||
#include <openrct2/drawing/Palette.h>
|
||||
#include <openrct2/drawing/Rectangle.h>
|
||||
#include <openrct2/drawing/Text.h>
|
||||
#include <openrct2/interface/WidgetIndexGlobals.h>
|
||||
@@ -1721,7 +1722,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
if (Editor::_numSelectedObjectsForType[EnumValue(ObjectType::water)] == 0)
|
||||
{
|
||||
// Reloads the default cyan water palette if no palette was selected.
|
||||
LoadPalette();
|
||||
Drawing::LoadPalette();
|
||||
}
|
||||
if (showFallbackWarning)
|
||||
ContextShowError(STR_OBJECT_SELECTION_FALLBACK_IMAGES_WARNING, kStringIdEmpty, {});
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
#include "drawing/IDrawingEngine.h"
|
||||
#include "drawing/Image.h"
|
||||
#include "drawing/LightFX.h"
|
||||
#include "drawing/Palette.h"
|
||||
#include "drawing/PickupPeep.h"
|
||||
#include "entity/EntityTweener.h"
|
||||
#include "entity/PatrolArea.h"
|
||||
@@ -1390,7 +1391,7 @@ namespace OpenRCT2
|
||||
|
||||
if (GameIsNotPaused())
|
||||
{
|
||||
gPaletteEffectFrame += gCurrentDeltaTime;
|
||||
Drawing::gPaletteEffectFrame += gCurrentDeltaTime;
|
||||
}
|
||||
|
||||
DateUpdateRealTimeOfDay();
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#include "core/FileSystem.hpp"
|
||||
#include "core/Path.hpp"
|
||||
#include "core/String.hpp"
|
||||
#include "drawing/Drawing.h"
|
||||
#include "drawing/Palette.h"
|
||||
#include "drawing/ScrollingText.h"
|
||||
#include "entity/EntityList.h"
|
||||
#include "entity/EntityRegistry.h"
|
||||
@@ -374,7 +374,7 @@ void GameLoadInit()
|
||||
gWindowUpdateTicks = 0;
|
||||
gCurrentRealTimeTicks = 0;
|
||||
|
||||
LoadPalette();
|
||||
Drawing::LoadPalette();
|
||||
|
||||
if (!gOpenRCT2Headless)
|
||||
{
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "ReplayManager.h"
|
||||
#include "actions/GameActionRunner.h"
|
||||
#include "config/Config.h"
|
||||
#include "drawing/Drawing.h"
|
||||
#include "drawing/Palette.h"
|
||||
#include "entity/EntityTweener.h"
|
||||
#include "entity/PatrolArea.h"
|
||||
#include "interface/Screenshot.h"
|
||||
@@ -84,7 +84,7 @@ namespace OpenRCT2
|
||||
auto clipboardIntent = Intent(INTENT_ACTION_CLEAR_TILE_INSPECTOR_CLIPBOARD);
|
||||
ContextBroadcastIntent(&clipboardIntent);
|
||||
|
||||
LoadPalette();
|
||||
Drawing::LoadPalette();
|
||||
|
||||
CheatsReset();
|
||||
ClearRestrictedScenery();
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
#include "../core/EnumUtils.hpp"
|
||||
#include "Drawing.h"
|
||||
#include "Palette.h"
|
||||
#include "PaletteType.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
@@ -10,23 +10,16 @@
|
||||
#include "Drawing.h"
|
||||
|
||||
#include "../Context.h"
|
||||
#include "../Diagnostic.h"
|
||||
#include "../Game.h"
|
||||
#include "../GameState.h"
|
||||
#include "../OpenRCT2.h"
|
||||
#include "../SpriteIds.h"
|
||||
#include "../config/Config.h"
|
||||
#include "../core/Guard.hpp"
|
||||
#include "../interface/ScreenCoords.hpp"
|
||||
#include "../object/ObjectEntryManager.h"
|
||||
#include "../object/WaterEntry.h"
|
||||
#include "../util/Util.h"
|
||||
#include "../world/Weather.h"
|
||||
#include "Drawing.Sprite.h"
|
||||
#include "FilterPaletteIds.h"
|
||||
#include "Font.h"
|
||||
#include "LightFX.h"
|
||||
#include "NewDrawing.h"
|
||||
#include "Palette.h"
|
||||
#include "Rectangle.h"
|
||||
#include "RenderTarget.h"
|
||||
#include "Text.h"
|
||||
@@ -38,19 +31,6 @@
|
||||
using namespace OpenRCT2;
|
||||
using namespace OpenRCT2::Drawing;
|
||||
|
||||
static constexpr auto kPaletteOffsetDynamic = PaletteIndex::pi10;
|
||||
static constexpr uint8_t kPaletteLengthDynamic = 236;
|
||||
|
||||
static constexpr uint8_t kPaletteLengthWaterWaves = 5;
|
||||
static constexpr uint8_t kPaletteLengthWaterSparkles = 5;
|
||||
|
||||
static constexpr auto kPaletteOffsetAnimated = PaletteIndex::waterWaves0;
|
||||
static constexpr uint8_t kPaletteLengthAnimated = 16;
|
||||
|
||||
GamePalette gPalette;
|
||||
GamePalette gGamePalette;
|
||||
uint32_t gPaletteEffectFrame;
|
||||
|
||||
bool gPaintForceRedraw{ false };
|
||||
|
||||
static constexpr FilterPaletteID kGlassPaletteIds[kColourNumTotal] = {
|
||||
@@ -430,70 +410,6 @@ void GfxFilterPixel(RenderTarget& rt, const ScreenCoordsXY& coords, FilterPalett
|
||||
Rectangle::filter(rt, { coords, coords }, palette);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x00683854
|
||||
* a1 (ebx)
|
||||
* product (cl)
|
||||
*/
|
||||
void GfxTransposePalette(ImageIndex pal, uint8_t product)
|
||||
{
|
||||
const auto* g1 = GfxGetG1Palette(pal);
|
||||
if (g1 == nullptr)
|
||||
return;
|
||||
|
||||
auto index = g1->startIndex;
|
||||
auto* src = g1->palette;
|
||||
|
||||
for (auto numColours = g1->numColours; numColours > 0; numColours--)
|
||||
{
|
||||
auto& dst = gGamePalette[index];
|
||||
// Make sure the image never gets darker than the void colour (not-quite-black), to avoid the background colour
|
||||
// jumping between void and 100% black.
|
||||
dst.blue = std::max<uint8_t>(35, ((src->blue * product) >> 8));
|
||||
dst.green = std::max<uint8_t>(35, ((src->green * product) >> 8));
|
||||
dst.red = std::max<uint8_t>(23, ((src->red * product) >> 8));
|
||||
src++;
|
||||
|
||||
index++;
|
||||
}
|
||||
UpdatePalette(gGamePalette, PaletteIndex::pi10, 236);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006837E3
|
||||
*/
|
||||
void LoadPalette()
|
||||
{
|
||||
if (gOpenRCT2NoGraphics)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const auto& waterEntry = getActiveWaterEntry();
|
||||
Guard::Assert(waterEntry.mainPalette != kImageIndexUndefined, "Failed to load water palette");
|
||||
auto palette = waterEntry.mainPalette;
|
||||
|
||||
const auto* g1 = GfxGetG1Palette(palette);
|
||||
if (g1 != nullptr)
|
||||
{
|
||||
auto index = g1->startIndex;
|
||||
auto* src = g1->palette;
|
||||
for (auto numColours = g1->numColours; numColours > 0; numColours--)
|
||||
{
|
||||
auto& dst = gGamePalette[index];
|
||||
dst.blue = src->blue;
|
||||
dst.green = src->green;
|
||||
dst.red = src->red;
|
||||
src++;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
UpdatePalette(gGamePalette, PaletteIndex::pi10, 236);
|
||||
GfxInvalidateScreen();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006ED7E5
|
||||
@@ -590,191 +506,10 @@ FilterPaletteID GetGlassPaletteId(Colour c)
|
||||
return kGlassPaletteIds[EnumValue(c)];
|
||||
}
|
||||
|
||||
void UpdatePalette(std::span<const BGRAColour> palette, PaletteIndex startIndex, int32_t numColours)
|
||||
{
|
||||
for (int32_t i = EnumValue(startIndex); i < numColours + EnumValue(startIndex); i++)
|
||||
{
|
||||
const auto& colour = palette[i];
|
||||
uint8_t b = colour.blue;
|
||||
uint8_t g = colour.green;
|
||||
uint8_t r = colour.red;
|
||||
|
||||
if (LightFx::IsAvailable())
|
||||
{
|
||||
LightFx::ApplyPaletteFilter(i, &r, &g, &b);
|
||||
}
|
||||
else
|
||||
{
|
||||
float night = gDayNightCycle;
|
||||
if (night >= 0 && Weather::gLightningFlash == 0)
|
||||
{
|
||||
r = Lerp(r, SoftLight(r, 8), night);
|
||||
g = Lerp(g, SoftLight(g, 8), night);
|
||||
b = Lerp(b, SoftLight(b, 128), night);
|
||||
}
|
||||
}
|
||||
|
||||
gPalette[i].blue = b;
|
||||
gPalette[i].green = g;
|
||||
gPalette[i].red = r;
|
||||
gPalette[i].alpha = 0;
|
||||
}
|
||||
|
||||
// Fix #1749 and #6535: rainbow path, donut shop and pause button contain black spots that should be white.
|
||||
gPalette[255].blue = 255;
|
||||
gPalette[255].green = 255;
|
||||
gPalette[255].red = 255;
|
||||
gPalette[255].alpha = 0;
|
||||
|
||||
if (!gOpenRCT2Headless)
|
||||
{
|
||||
DrawingEngineSetPalette(gPalette);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006838BD
|
||||
*/
|
||||
void UpdatePaletteEffects()
|
||||
{
|
||||
const auto& waterEntry = getActiveWaterEntry();
|
||||
|
||||
if (Weather::gLightningFlash == 1)
|
||||
{
|
||||
// Change palette to lighter colour during lightning
|
||||
auto palette = waterEntry.mainPalette;
|
||||
const auto* g1 = GfxGetG1Palette(palette);
|
||||
if (g1 != nullptr)
|
||||
{
|
||||
auto startIndex = g1->startIndex;
|
||||
|
||||
for (int32_t i = 0; i < g1->numColours; i++)
|
||||
{
|
||||
auto& paletteOffset = gGamePalette[startIndex + i];
|
||||
const auto& g1PaletteEntry = g1->palette[i];
|
||||
paletteOffset.blue = -((0xFF - g1PaletteEntry.blue) / 2) - 1;
|
||||
paletteOffset.green = -((0xFF - g1PaletteEntry.green) / 2) - 1;
|
||||
paletteOffset.red = -((0xFF - g1PaletteEntry.red) / 2) - 1;
|
||||
}
|
||||
|
||||
UpdatePalette(gGamePalette, kPaletteOffsetDynamic, kPaletteLengthDynamic);
|
||||
}
|
||||
Weather::gLightningFlash++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Weather::gLightningFlash == 2)
|
||||
{
|
||||
// Change palette back to normal after lightning
|
||||
auto palette = waterEntry.mainPalette;
|
||||
const auto* g1 = GfxGetG1Palette(palette);
|
||||
if (g1 != nullptr)
|
||||
{
|
||||
auto startIndex = g1->startIndex;
|
||||
|
||||
for (int32_t i = 0; i < g1->numColours; i++)
|
||||
{
|
||||
auto& paletteOffset = gGamePalette[startIndex + i];
|
||||
const auto& g1PaletteEntry = g1->palette[i];
|
||||
paletteOffset.blue = g1PaletteEntry.blue;
|
||||
paletteOffset.green = g1PaletteEntry.green;
|
||||
paletteOffset.red = g1PaletteEntry.red;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Animate the water/lava/chain movement palette
|
||||
uint32_t shade = 0;
|
||||
if (Config::Get().general.renderWeatherGloom)
|
||||
{
|
||||
auto paletteId = Weather::getWeatherGloomPaletteId(getGameState().weatherCurrent);
|
||||
if (paletteId != FilterPaletteID::paletteNull)
|
||||
{
|
||||
shade = 1;
|
||||
if (paletteId != FilterPaletteID::paletteDarken1)
|
||||
{
|
||||
shade = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
uint32_t j = gPaletteEffectFrame;
|
||||
j = ((static_cast<uint16_t>((~j / 2) * 128) * 15) >> 16);
|
||||
|
||||
auto waterId = waterEntry.waterWavesPalette;
|
||||
const auto* g1 = GfxGetG1Palette(shade + waterId);
|
||||
if (g1 != nullptr)
|
||||
{
|
||||
const auto* g1PaletteEntry = &g1->palette[j];
|
||||
int32_t n = kPaletteLengthWaterWaves;
|
||||
for (int32_t i = 0; i < n; i++)
|
||||
{
|
||||
auto& vd = gGamePalette[EnumValue(PaletteIndex::waterWaves0) + i];
|
||||
vd.blue = g1PaletteEntry->blue;
|
||||
vd.green = g1PaletteEntry->green;
|
||||
vd.red = g1PaletteEntry->red;
|
||||
g1PaletteEntry += 3;
|
||||
if (g1PaletteEntry >= &g1->palette[3 * n])
|
||||
{
|
||||
g1PaletteEntry -= 3 * n;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
waterId = waterEntry.waterSparklesPalette;
|
||||
g1 = GfxGetG1Palette(shade + waterId);
|
||||
if (g1 != nullptr)
|
||||
{
|
||||
auto* src = &g1->palette[j];
|
||||
int32_t n = kPaletteLengthWaterSparkles;
|
||||
for (int32_t i = 0; i < n; i++)
|
||||
{
|
||||
auto& vd = gGamePalette[EnumValue(PaletteIndex::waterSparkles0) + i];
|
||||
vd.blue = src->blue;
|
||||
vd.green = src->green;
|
||||
vd.red = src->red;
|
||||
src += 3;
|
||||
if (src >= &g1->palette[3 * n])
|
||||
{
|
||||
src -= 3 * n;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
j = (static_cast<uint16_t>(gPaletteEffectFrame * -960) * 3) >> 16;
|
||||
waterId = SPR_GAME_PALETTE_4;
|
||||
g1 = GfxGetG1Palette(shade + waterId);
|
||||
if (g1 != nullptr)
|
||||
{
|
||||
auto* src = &g1->palette[j];
|
||||
const int32_t n = 3;
|
||||
for (int32_t i = 0; i < n; i++)
|
||||
{
|
||||
auto& vd = gGamePalette[EnumValue(PaletteIndex::primaryRemap0) + i];
|
||||
vd.blue = src->blue;
|
||||
vd.green = src->green;
|
||||
vd.red = src->red;
|
||||
src++;
|
||||
if (src >= &g1->palette[3])
|
||||
{
|
||||
src -= n;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UpdatePalette(gGamePalette, kPaletteOffsetAnimated, kPaletteLengthAnimated);
|
||||
if (Weather::gLightningFlash == 2)
|
||||
{
|
||||
UpdatePalette(gGamePalette, kPaletteOffsetDynamic, kPaletteLengthDynamic);
|
||||
Weather::gLightningFlash = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RefreshVideo()
|
||||
{
|
||||
ContextRecreateWindow();
|
||||
DrawingEngineSetPalette(gPalette);
|
||||
DrawingEngineSetPalette(Drawing::gPalette);
|
||||
GfxInvalidateScreen();
|
||||
}
|
||||
|
||||
|
||||
@@ -13,10 +13,8 @@
|
||||
#include "Colour.h"
|
||||
#include "ImageId.hpp"
|
||||
#include "PaletteMap.h"
|
||||
#include "PaletteType.h"
|
||||
|
||||
#include <optional>
|
||||
#include <span>
|
||||
|
||||
struct ScreenCoordsXY;
|
||||
struct ScreenLine;
|
||||
@@ -43,10 +41,6 @@ namespace OpenRCT2::Drawing
|
||||
|
||||
constexpr uint8_t kPaletteTotalOffsets = 192;
|
||||
|
||||
extern OpenRCT2::Drawing::GamePalette gPalette;
|
||||
extern OpenRCT2::Drawing::GamePalette gGamePalette;
|
||||
extern uint32_t gPaletteEffectFrame;
|
||||
|
||||
extern const OpenRCT2::Drawing::TranslucentWindowPalette kTranslucentWindowPalettes[OpenRCT2::Drawing::kColourNumTotal];
|
||||
|
||||
extern bool gPaintForceRedraw;
|
||||
@@ -57,10 +51,6 @@ bool ClipRenderTarget(
|
||||
void GfxSetDirtyBlocks(const ScreenRect& rect);
|
||||
void GfxInvalidateScreen();
|
||||
|
||||
// palette
|
||||
void GfxTransposePalette(ImageIndex pal, uint8_t product);
|
||||
void LoadPalette();
|
||||
|
||||
// other
|
||||
void GfxClear(OpenRCT2::Drawing::RenderTarget& rt, OpenRCT2::Drawing::PaletteIndex paletteIndex);
|
||||
void GfxFilterPixel(
|
||||
@@ -85,9 +75,6 @@ void FASTCALL GfxDrawSpriteRawMasked(
|
||||
|
||||
std::optional<uint32_t> GetPaletteG1Index(OpenRCT2::Drawing::FilterPaletteID paletteId);
|
||||
std::optional<OpenRCT2::Drawing::PaletteMap> GetPaletteMapForColour(OpenRCT2::Drawing::FilterPaletteID paletteId);
|
||||
void UpdatePalette(
|
||||
std::span<const OpenRCT2::Drawing::BGRAColour> palette, OpenRCT2::Drawing::PaletteIndex startIndex, int32_t numColours);
|
||||
void UpdatePaletteEffects();
|
||||
|
||||
void RefreshVideo();
|
||||
void ToggleWindowedMode();
|
||||
|
||||
@@ -0,0 +1,285 @@
|
||||
/*****************************************************************************
|
||||
* Copyright (c) 2014-2026 OpenRCT2 developers
|
||||
*
|
||||
* For a complete list of all authors, please refer to contributors.md
|
||||
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
|
||||
*
|
||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||
*****************************************************************************/
|
||||
|
||||
#include "Palette.h"
|
||||
|
||||
#include "../Game.h"
|
||||
#include "../GameState.h"
|
||||
#include "../OpenRCT2.h"
|
||||
#include "../SpriteIds.h"
|
||||
#include "../config/Config.h"
|
||||
#include "../object/WaterEntry.h"
|
||||
#include "../util/Util.h"
|
||||
#include "../world/Weather.h"
|
||||
#include "Drawing.Sprite.h"
|
||||
#include "Drawing.h"
|
||||
#include "FilterPaletteIds.h"
|
||||
#include "LightFX.h"
|
||||
#include "NewDrawing.h"
|
||||
|
||||
namespace OpenRCT2::Drawing
|
||||
{
|
||||
static constexpr auto kPaletteOffsetDynamic = PaletteIndex::pi10;
|
||||
static constexpr uint8_t kPaletteLengthDynamic = 236;
|
||||
|
||||
static constexpr uint8_t kPaletteLengthWaterWaves = 5;
|
||||
static constexpr uint8_t kPaletteLengthWaterSparkles = 5;
|
||||
|
||||
static constexpr auto kPaletteOffsetAnimated = PaletteIndex::waterWaves0;
|
||||
static constexpr uint8_t kPaletteLengthAnimated = 16;
|
||||
|
||||
GamePalette gPalette;
|
||||
GamePalette gGamePalette;
|
||||
uint32_t gPaletteEffectFrame;
|
||||
|
||||
void UpdatePalette(std::span<const BGRAColour> palette, PaletteIndex startIndex, int32_t numColours)
|
||||
{
|
||||
for (int32_t i = EnumValue(startIndex); i < numColours + EnumValue(startIndex); i++)
|
||||
{
|
||||
const auto& colour = palette[i];
|
||||
uint8_t b = colour.blue;
|
||||
uint8_t g = colour.green;
|
||||
uint8_t r = colour.red;
|
||||
|
||||
if (LightFx::IsAvailable())
|
||||
{
|
||||
LightFx::ApplyPaletteFilter(i, &r, &g, &b);
|
||||
}
|
||||
else
|
||||
{
|
||||
float night = gDayNightCycle;
|
||||
if (night >= 0 && Weather::gLightningFlash == 0)
|
||||
{
|
||||
r = Lerp(r, SoftLight(r, 8), night);
|
||||
g = Lerp(g, SoftLight(g, 8), night);
|
||||
b = Lerp(b, SoftLight(b, 128), night);
|
||||
}
|
||||
}
|
||||
|
||||
gPalette[i].blue = b;
|
||||
gPalette[i].green = g;
|
||||
gPalette[i].red = r;
|
||||
gPalette[i].alpha = 0;
|
||||
}
|
||||
|
||||
// Fix #1749 and #6535: rainbow path, donut shop and pause button contain black spots that should be white.
|
||||
gPalette[255].blue = 255;
|
||||
gPalette[255].green = 255;
|
||||
gPalette[255].red = 255;
|
||||
gPalette[255].alpha = 0;
|
||||
|
||||
if (!gOpenRCT2Headless)
|
||||
{
|
||||
DrawingEngineSetPalette(gPalette);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006838BD
|
||||
*/
|
||||
void UpdatePaletteEffects()
|
||||
{
|
||||
const auto& waterEntry = getActiveWaterEntry();
|
||||
|
||||
if (Weather::gLightningFlash == 1)
|
||||
{
|
||||
// Change palette to lighter colour during lightning
|
||||
auto palette = waterEntry.mainPalette;
|
||||
const auto* g1 = GfxGetG1Palette(palette);
|
||||
if (g1 != nullptr)
|
||||
{
|
||||
auto startIndex = g1->startIndex;
|
||||
|
||||
for (int32_t i = 0; i < g1->numColours; i++)
|
||||
{
|
||||
auto& paletteOffset = gGamePalette[startIndex + i];
|
||||
const auto& g1PaletteEntry = g1->palette[i];
|
||||
paletteOffset.blue = -((0xFF - g1PaletteEntry.blue) / 2) - 1;
|
||||
paletteOffset.green = -((0xFF - g1PaletteEntry.green) / 2) - 1;
|
||||
paletteOffset.red = -((0xFF - g1PaletteEntry.red) / 2) - 1;
|
||||
}
|
||||
|
||||
UpdatePalette(gGamePalette, kPaletteOffsetDynamic, kPaletteLengthDynamic);
|
||||
}
|
||||
Weather::gLightningFlash++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Weather::gLightningFlash == 2)
|
||||
{
|
||||
// Change palette back to normal after lightning
|
||||
auto palette = waterEntry.mainPalette;
|
||||
const auto* g1 = GfxGetG1Palette(palette);
|
||||
if (g1 != nullptr)
|
||||
{
|
||||
auto startIndex = g1->startIndex;
|
||||
|
||||
for (int32_t i = 0; i < g1->numColours; i++)
|
||||
{
|
||||
auto& paletteOffset = gGamePalette[startIndex + i];
|
||||
const auto& g1PaletteEntry = g1->palette[i];
|
||||
paletteOffset.blue = g1PaletteEntry.blue;
|
||||
paletteOffset.green = g1PaletteEntry.green;
|
||||
paletteOffset.red = g1PaletteEntry.red;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Animate the water/lava/chain movement palette
|
||||
uint32_t shade = 0;
|
||||
if (Config::Get().general.renderWeatherGloom)
|
||||
{
|
||||
auto paletteId = Weather::getWeatherGloomPaletteId(getGameState().weatherCurrent);
|
||||
if (paletteId != FilterPaletteID::paletteNull)
|
||||
{
|
||||
shade = 1;
|
||||
if (paletteId != FilterPaletteID::paletteDarken1)
|
||||
{
|
||||
shade = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
uint32_t j = gPaletteEffectFrame;
|
||||
j = ((static_cast<uint16_t>((~j / 2) * 128) * 15) >> 16);
|
||||
|
||||
auto waterId = waterEntry.waterWavesPalette;
|
||||
const auto* g1 = GfxGetG1Palette(shade + waterId);
|
||||
if (g1 != nullptr)
|
||||
{
|
||||
const auto* g1PaletteEntry = &g1->palette[j];
|
||||
int32_t n = kPaletteLengthWaterWaves;
|
||||
for (int32_t i = 0; i < n; i++)
|
||||
{
|
||||
auto& vd = gGamePalette[EnumValue(PaletteIndex::waterWaves0) + i];
|
||||
vd.blue = g1PaletteEntry->blue;
|
||||
vd.green = g1PaletteEntry->green;
|
||||
vd.red = g1PaletteEntry->red;
|
||||
g1PaletteEntry += 3;
|
||||
if (g1PaletteEntry >= &g1->palette[3 * n])
|
||||
{
|
||||
g1PaletteEntry -= 3 * n;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
waterId = waterEntry.waterSparklesPalette;
|
||||
g1 = GfxGetG1Palette(shade + waterId);
|
||||
if (g1 != nullptr)
|
||||
{
|
||||
auto* src = &g1->palette[j];
|
||||
int32_t n = kPaletteLengthWaterSparkles;
|
||||
for (int32_t i = 0; i < n; i++)
|
||||
{
|
||||
auto& vd = gGamePalette[EnumValue(PaletteIndex::waterSparkles0) + i];
|
||||
vd.blue = src->blue;
|
||||
vd.green = src->green;
|
||||
vd.red = src->red;
|
||||
src += 3;
|
||||
if (src >= &g1->palette[3 * n])
|
||||
{
|
||||
src -= 3 * n;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
j = (static_cast<uint16_t>(gPaletteEffectFrame * -960) * 3) >> 16;
|
||||
waterId = SPR_GAME_PALETTE_4;
|
||||
g1 = GfxGetG1Palette(shade + waterId);
|
||||
if (g1 != nullptr)
|
||||
{
|
||||
auto* src = &g1->palette[j];
|
||||
const int32_t n = 3;
|
||||
for (int32_t i = 0; i < n; i++)
|
||||
{
|
||||
auto& vd = gGamePalette[EnumValue(PaletteIndex::primaryRemap0) + i];
|
||||
vd.blue = src->blue;
|
||||
vd.green = src->green;
|
||||
vd.red = src->red;
|
||||
src++;
|
||||
if (src >= &g1->palette[3])
|
||||
{
|
||||
src -= n;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UpdatePalette(gGamePalette, kPaletteOffsetAnimated, kPaletteLengthAnimated);
|
||||
if (Weather::gLightningFlash == 2)
|
||||
{
|
||||
UpdatePalette(gGamePalette, kPaletteOffsetDynamic, kPaletteLengthDynamic);
|
||||
Weather::gLightningFlash = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x00683854
|
||||
* a1 (ebx)
|
||||
* product (cl)
|
||||
*/
|
||||
void GfxTransposePalette(ImageIndex pal, uint8_t product)
|
||||
{
|
||||
const auto* g1 = GfxGetG1Palette(pal);
|
||||
if (g1 == nullptr)
|
||||
return;
|
||||
|
||||
auto index = g1->startIndex;
|
||||
auto* src = g1->palette;
|
||||
|
||||
for (auto numColours = g1->numColours; numColours > 0; numColours--)
|
||||
{
|
||||
auto& dst = gGamePalette[index];
|
||||
// Make sure the image never gets darker than the void colour (not-quite-black), to avoid the background colour
|
||||
// jumping between void and 100% black.
|
||||
dst.blue = std::max<uint8_t>(35, ((src->blue * product) >> 8));
|
||||
dst.green = std::max<uint8_t>(35, ((src->green * product) >> 8));
|
||||
dst.red = std::max<uint8_t>(23, ((src->red * product) >> 8));
|
||||
src++;
|
||||
|
||||
index++;
|
||||
}
|
||||
UpdatePalette(gGamePalette, PaletteIndex::pi10, 236);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006837E3
|
||||
*/
|
||||
void LoadPalette()
|
||||
{
|
||||
if (gOpenRCT2NoGraphics)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const auto& waterEntry = getActiveWaterEntry();
|
||||
Guard::Assert(waterEntry.mainPalette != kImageIndexUndefined, "Failed to load water palette");
|
||||
auto palette = waterEntry.mainPalette;
|
||||
|
||||
const auto* g1 = GfxGetG1Palette(palette);
|
||||
if (g1 != nullptr)
|
||||
{
|
||||
auto index = g1->startIndex;
|
||||
auto* src = g1->palette;
|
||||
for (auto numColours = g1->numColours; numColours > 0; numColours--)
|
||||
{
|
||||
auto& dst = gGamePalette[index];
|
||||
dst.blue = src->blue;
|
||||
dst.green = src->green;
|
||||
dst.red = src->red;
|
||||
src++;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
UpdatePalette(gGamePalette, PaletteIndex::pi10, 236);
|
||||
GfxInvalidateScreen();
|
||||
}
|
||||
} // namespace OpenRCT2::Drawing
|
||||
@@ -0,0 +1,30 @@
|
||||
/*****************************************************************************
|
||||
* Copyright (c) 2014-2026 OpenRCT2 developers
|
||||
*
|
||||
* For a complete list of all authors, please refer to contributors.md
|
||||
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
|
||||
*
|
||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ImageIndexType.h"
|
||||
#include "PaletteType.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <span>
|
||||
|
||||
namespace OpenRCT2::Drawing
|
||||
{
|
||||
enum class PaletteIndex : uint8_t;
|
||||
|
||||
extern GamePalette gPalette;
|
||||
extern GamePalette gGamePalette;
|
||||
extern uint32_t gPaletteEffectFrame;
|
||||
|
||||
void UpdatePalette(std::span<const BGRAColour> palette, PaletteIndex startIndex, int32_t numColours);
|
||||
void UpdatePaletteEffects();
|
||||
void GfxTransposePalette(ImageIndex pal, uint8_t product);
|
||||
void LoadPalette();
|
||||
} // namespace OpenRCT2::Drawing
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "../core/String.hpp"
|
||||
#include "../drawing/Drawing.h"
|
||||
#include "../drawing/NewDrawing.h"
|
||||
#include "../drawing/Palette.h"
|
||||
#include "../drawing/X8DrawingEngine.h"
|
||||
#include "../localisation/Formatter.h"
|
||||
#include "../localisation/StringIds.h"
|
||||
|
||||
@@ -266,6 +266,7 @@
|
||||
<ClInclude Include="drawing\LightFX.h" />
|
||||
<ClInclude Include="drawing\NewDrawing.h" />
|
||||
<ClInclude Include="drawing\PaletteIndex.h" />
|
||||
<ClInclude Include="drawing\Palette.h" />
|
||||
<ClInclude Include="drawing\PaletteMap.h" />
|
||||
<ClInclude Include="drawing\PaletteType.h" />
|
||||
<ClInclude Include="drawing\PickupPeep.h" />
|
||||
@@ -911,6 +912,7 @@
|
||||
<ClCompile Include="drawing\LightFX.cpp" />
|
||||
<ClCompile Include="drawing\Line.cpp" />
|
||||
<ClCompile Include="drawing\NewDrawing.cpp" />
|
||||
<ClCompile Include="drawing\Palette.cpp" />
|
||||
<ClCompile Include="drawing\PaletteMap.cpp" />
|
||||
<ClCompile Include="drawing\PickupPeep.cpp" />
|
||||
<ClCompile Include="drawing\Rectangle.cpp" />
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
#include "../core/Guard.hpp"
|
||||
#include "../core/IStream.hpp"
|
||||
#include "../core/Json.hpp"
|
||||
#include "../drawing/Drawing.h"
|
||||
#include "../drawing/ImageImporter.h"
|
||||
#include "../drawing/Palette.h"
|
||||
#include "../drawing/Text.h"
|
||||
#include "../interface/ScreenCoords.hpp"
|
||||
#include "../localisation/Language.h"
|
||||
@@ -38,7 +38,7 @@ namespace OpenRCT2
|
||||
_legacyType.waterWavesPalette = _legacyType.mainPalette + 1;
|
||||
_legacyType.waterSparklesPalette = _legacyType.mainPalette + 4;
|
||||
|
||||
LoadPalette();
|
||||
Drawing::LoadPalette();
|
||||
}
|
||||
|
||||
void WaterObject::Unload()
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "../drawing/Drawing.String.h"
|
||||
#include "../drawing/Drawing.h"
|
||||
#include "../drawing/IDrawingEngine.h"
|
||||
#include "../drawing/Palette.h"
|
||||
#include "../drawing/PickupPeep.h"
|
||||
#include "../drawing/Text.h"
|
||||
#include "../interface/Viewport.h"
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include "../core/Guard.hpp"
|
||||
#include "../core/Path.hpp"
|
||||
#include "../core/Random.hpp"
|
||||
#include "../drawing/Drawing.h"
|
||||
#include "../drawing/Palette.h"
|
||||
#include "../drawing/PaletteIndex.h"
|
||||
#include "../entity/Duck.h"
|
||||
#include "../entity/Staff.h"
|
||||
@@ -363,7 +363,7 @@ static void ScenarioUpdateDayNightCycle()
|
||||
// Only update palette if day / night cycle has changed
|
||||
if (gDayNightCycle != currentDayNightCycle)
|
||||
{
|
||||
UpdatePalette(gGamePalette, Drawing::PaletteIndex::pi10, 236);
|
||||
Drawing::UpdatePalette(Drawing::gGamePalette, Drawing::PaletteIndex::pi10, 236);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "../../audio/Audio.h"
|
||||
#include "../../core/EnumUtils.hpp"
|
||||
#include "../../drawing/Drawing.h"
|
||||
#include "../../drawing/Palette.h"
|
||||
#include "../../entity/EntityList.h"
|
||||
#include "../../entity/Guest.h"
|
||||
#include "../../entity/Staff.h"
|
||||
@@ -673,7 +674,7 @@ namespace OpenRCT2::Editor
|
||||
auto newPaletteEntry = ObjectEntryDescriptor(*item);
|
||||
if (objectManager.GetLoadedObject(newPaletteEntry) != nullptr || objectManager.LoadObject(newPaletteEntry) != nullptr)
|
||||
{
|
||||
LoadPalette();
|
||||
Drawing::LoadPalette();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include "../../actions/park/LandSetRightsAction.h"
|
||||
#include "../../audio/Audio.h"
|
||||
#include "../../core/Path.hpp"
|
||||
#include "../../drawing/Drawing.h"
|
||||
#include "../../drawing/Palette.h"
|
||||
#include "../../entity/EntityList.h"
|
||||
#include "../../entity/Guest.h"
|
||||
#include "../../entity/PatrolArea.h"
|
||||
@@ -58,7 +58,7 @@ void EditorScene::Load()
|
||||
OpenEditorWindows();
|
||||
resetMainViewport();
|
||||
|
||||
LoadPalette();
|
||||
Drawing::LoadPalette();
|
||||
gScreenAge = 0;
|
||||
gameState.scenarioOptions.name = LanguageGetString(STR_MY_NEW_SCENARIO);
|
||||
|
||||
@@ -312,7 +312,7 @@ void EditorScene::FinaliseMainView()
|
||||
windowManager->BroadcastIntent(Intent(INTENT_ACTION_CLEAR_TILE_INSPECTOR_CLIPBOARD));
|
||||
|
||||
gWindowUpdateTicks = 0;
|
||||
LoadPalette();
|
||||
Drawing::LoadPalette();
|
||||
}
|
||||
|
||||
void EditorScene::resetMainViewport()
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "../../GameState.h"
|
||||
#include "../../OpenRCT2.h"
|
||||
#include "../../audio/Audio.h"
|
||||
#include "../../drawing/Drawing.h"
|
||||
#include "../../drawing/Palette.h"
|
||||
#include "../../world/Map.h"
|
||||
#include "EditorController.h"
|
||||
|
||||
@@ -39,7 +39,7 @@ void TrackDesignerScene::Load()
|
||||
OpenEditorWindows();
|
||||
resetMainViewport();
|
||||
|
||||
LoadPalette();
|
||||
Drawing::LoadPalette();
|
||||
|
||||
GameLoadScripts();
|
||||
GameNotifyMapChanged();
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "../../GameState.h"
|
||||
#include "../../OpenRCT2.h"
|
||||
#include "../../audio/Audio.h"
|
||||
#include "../../drawing/Drawing.h"
|
||||
#include "../../drawing/Palette.h"
|
||||
#include "../../world/Map.h"
|
||||
#include "EditorController.h"
|
||||
|
||||
@@ -39,7 +39,7 @@ void TrackManagerScene::Load()
|
||||
OpenEditorWindows();
|
||||
resetMainViewport();
|
||||
|
||||
LoadPalette();
|
||||
Drawing::LoadPalette();
|
||||
|
||||
GameLoadScripts();
|
||||
GameNotifyMapChanged();
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "../../audio/AudioMixer.h"
|
||||
#include "../../drawing/Drawing.h"
|
||||
#include "../../drawing/NewDrawing.h"
|
||||
#include "../../drawing/Palette.h"
|
||||
#include "../../drawing/PaletteIndex.h"
|
||||
#include "../../drawing/Rectangle.h"
|
||||
#include "../../scenes/SceneManager.h"
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "../../config/Config.h"
|
||||
#include "../../core/Console.hpp"
|
||||
#include "../../drawing/Drawing.h"
|
||||
#include "../../drawing/Palette.h"
|
||||
#include "../../interface/Screenshot.h"
|
||||
#include "../../interface/Window.h"
|
||||
#include "../../network/NetworkBase.h"
|
||||
@@ -153,7 +154,7 @@ void TitleScene::Tick()
|
||||
{
|
||||
gameStateUpdateLogic();
|
||||
}
|
||||
UpdatePaletteEffects();
|
||||
Drawing::UpdatePaletteEffects();
|
||||
// update_weather_animation();
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <openrct2/actions/ride/RideSetPriceAction.h>
|
||||
#include <openrct2/actions/ride/RideSetStatusAction.h>
|
||||
#include <openrct2/drawing/Drawing.h>
|
||||
#include <openrct2/drawing/Palette.h>
|
||||
#include <openrct2/entity/EntityRegistry.h>
|
||||
#include <openrct2/entity/EntityTweener.h>
|
||||
#include <openrct2/entity/Peep.h>
|
||||
@@ -60,7 +61,7 @@ static std::unique_ptr<IContext> localStartGame(const std::string& parkPath)
|
||||
gameState.entities.resetEntitySpatialIndices();
|
||||
|
||||
ResetAllSpriteQuadrantPlacements();
|
||||
LoadPalette();
|
||||
Drawing::LoadPalette();
|
||||
EntityTweener::get().reset();
|
||||
MapAnimations::MarkAllTiles();
|
||||
FixInvalidVehicleSpriteSizes();
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <openrct2/core/MemoryStream.h>
|
||||
#include <openrct2/core/String.hpp>
|
||||
#include <openrct2/drawing/Drawing.h>
|
||||
#include <openrct2/drawing/Palette.h>
|
||||
#include <openrct2/entity/EntityRegistry.h>
|
||||
#include <openrct2/entity/EntityTweener.h>
|
||||
#include <openrct2/object/ObjectManager.h>
|
||||
@@ -60,7 +61,7 @@ static void GameInit(bool retainSpatialIndices)
|
||||
gameState.entities.resetEntitySpatialIndices();
|
||||
|
||||
ResetAllSpriteQuadrantPlacements();
|
||||
LoadPalette();
|
||||
Drawing::LoadPalette();
|
||||
EntityTweener::get().reset();
|
||||
MapAnimations::MarkAllTiles();
|
||||
FixInvalidVehicleSpriteSizes();
|
||||
|
||||
Reference in new issue
Block a user