mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-04 13:42:55 +01:00
Use TextColours in the text drawing structs
This commit is contained in:
@@ -1229,7 +1229,7 @@ void OpenGLDrawingContext::DrawTTFBitmap(
|
||||
command.texMaskBounds = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
command.palettes = { 0, 0, 0 };
|
||||
command.flags = DrawRectCommand::FLAG_TTF_TEXT;
|
||||
command.colour = info->palette[3];
|
||||
command.colour = info->palette.shadowOutline;
|
||||
command.bounds = b;
|
||||
command.depth = _drawCount++;
|
||||
command.zoom = 1.0f;
|
||||
@@ -1245,7 +1245,7 @@ void OpenGLDrawingContext::DrawTTFBitmap(
|
||||
command.texMaskBounds = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
command.palettes = { 0, 0, 0 };
|
||||
command.flags = DrawRectCommand::FLAG_TTF_TEXT;
|
||||
command.colour = info->palette[3];
|
||||
command.colour = info->palette.shadowOutline;
|
||||
command.bounds = { left + 1, top + 1, right + 1, bottom + 1 };
|
||||
command.depth = _drawCount++;
|
||||
command.zoom = 1.0f;
|
||||
@@ -1259,7 +1259,7 @@ void OpenGLDrawingContext::DrawTTFBitmap(
|
||||
command.texMaskBounds = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
command.palettes = { 0, 0, 0 };
|
||||
command.flags = DrawRectCommand::FLAG_TTF_TEXT | (hintingThreshold << 8);
|
||||
command.colour = info->palette[1];
|
||||
command.colour = info->palette.fill;
|
||||
command.bounds = { left, top, right, bottom };
|
||||
command.depth = _drawCount++;
|
||||
command.zoom = 1.0f;
|
||||
|
||||
@@ -274,7 +274,7 @@ void GfxDrawStringLeftCentred(
|
||||
/**
|
||||
* Changes the palette so that the next character changes colour
|
||||
*/
|
||||
static void ColourCharacter(Drawing::TextColour colour, bool withOutline, uint8_t* palette_pointer)
|
||||
static void ColourCharacter(Drawing::TextColour colour, bool withOutline, Drawing::TextColours& textPalette)
|
||||
{
|
||||
auto mapping = Drawing::getTextColourMapping(colour);
|
||||
|
||||
@@ -283,31 +283,29 @@ static void ColourCharacter(Drawing::TextColour colour, bool withOutline, uint8_
|
||||
mapping.sunnyOutline = PaletteIndex::pi0;
|
||||
mapping.shadowOutline = PaletteIndex::pi0;
|
||||
}
|
||||
// Adjust text palette. Store current colour?
|
||||
palette_pointer[1] = mapping.fill;
|
||||
palette_pointer[2] = mapping.sunnyOutline;
|
||||
palette_pointer[3] = mapping.shadowOutline;
|
||||
palette_pointer[4] = PaletteIndex::pi0;
|
||||
|
||||
textPalette = mapping;
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the palette so that the next character changes colour
|
||||
* This is specific to changing to a predefined window related colour
|
||||
*/
|
||||
static void ColourCharacterWindow(colour_t colour, bool withOutline, uint8_t* palette_pointer)
|
||||
static void ColourCharacterWindow(colour_t colour, bool withOutline, Drawing::TextColours& textPalette)
|
||||
{
|
||||
int32_t eax;
|
||||
Drawing::TextColours mapping = {
|
||||
ColourMapA[colour].colour_11,
|
||||
PaletteIndex::pi0,
|
||||
PaletteIndex::pi0,
|
||||
};
|
||||
|
||||
eax = ColourMapA[colour].colour_11;
|
||||
if (withOutline)
|
||||
{
|
||||
eax |= 0x0A0A00;
|
||||
mapping.sunnyOutline = PaletteIndex::pi10;
|
||||
mapping.shadowOutline = PaletteIndex::pi10;
|
||||
}
|
||||
// Adjust text palette. Store current colour?
|
||||
palette_pointer[1] = eax & 0xFF;
|
||||
palette_pointer[2] = (eax >> 8) & 0xFF;
|
||||
palette_pointer[3] = (eax >> 16) & 0xFF;
|
||||
palette_pointer[4] = (eax >> 24) & 0xFF;
|
||||
|
||||
textPalette = mapping;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -486,7 +484,12 @@ static void TTFDrawCharacterSprite(RenderTarget& rt, int32_t codepoint, TextDraw
|
||||
screenCoords.y += *info->yOffset++;
|
||||
}
|
||||
|
||||
PaletteMap paletteMap(info->palette);
|
||||
uint8_t palette[8]{};
|
||||
palette[1] = info->palette.fill;
|
||||
palette[2] = info->palette.sunnyOutline;
|
||||
palette[3] = info->palette.shadowOutline;
|
||||
|
||||
PaletteMap paletteMap(palette);
|
||||
GfxDrawGlyph(rt, sprite, screenCoords, paletteMap);
|
||||
}
|
||||
|
||||
@@ -748,38 +751,30 @@ static void TTFProcessInitialColour(ColourWithFlags colour, TextDrawInfo* info)
|
||||
info->colourFlags = colour.flags;
|
||||
if (!colour.flags.has(ColourFlag::inset))
|
||||
{
|
||||
ColourCharacterWindow(
|
||||
colour.colour, info->colourFlags.has(ColourFlag::withOutline), reinterpret_cast<uint8_t*>(&info->palette));
|
||||
ColourCharacterWindow(colour.colour, info->colourFlags.has(ColourFlag::withOutline), info->palette);
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32_t eax = 0;
|
||||
Drawing::TextColours newPalette = {};
|
||||
switch (info->darkness)
|
||||
{
|
||||
case TextDarkness::extraDark:
|
||||
eax = ColourMapA[colour.colour].mid_light;
|
||||
eax = eax << 16;
|
||||
eax = eax | ColourMapA[colour.colour].dark;
|
||||
newPalette.fill = ColourMapA[colour.colour].dark;
|
||||
newPalette.shadowOutline = ColourMapA[colour.colour].mid_light;
|
||||
break;
|
||||
|
||||
case TextDarkness::dark:
|
||||
eax = ColourMapA[colour.colour].light;
|
||||
eax = eax << 16;
|
||||
eax = eax | ColourMapA[colour.colour].mid_dark;
|
||||
newPalette.fill = ColourMapA[colour.colour].mid_dark;
|
||||
newPalette.shadowOutline = ColourMapA[colour.colour].light;
|
||||
break;
|
||||
|
||||
case TextDarkness::regular:
|
||||
eax = ColourMapA[colour.colour].lighter;
|
||||
eax = eax << 16;
|
||||
eax = eax | ColourMapA[colour.colour].mid_light;
|
||||
newPalette.fill = ColourMapA[colour.colour].mid_light;
|
||||
newPalette.shadowOutline = ColourMapA[colour.colour].lighter;
|
||||
break;
|
||||
}
|
||||
|
||||
// Adjust text palette. Store current colour? ;
|
||||
info->palette[1] = eax & 0xFF;
|
||||
info->palette[2] = (eax >> 8) & 0xFF;
|
||||
info->palette[3] = (eax >> 16) & 0xFF;
|
||||
info->palette[4] = (eax >> 24) & 0xFF;
|
||||
info->palette = newPalette;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -809,10 +804,10 @@ void TTFDrawString(
|
||||
info.textDrawFlags.set(TextDrawFlag::noFormatting);
|
||||
}
|
||||
|
||||
std::memcpy(info.palette, gTextPalette, sizeof(info.palette));
|
||||
info.palette = gTextPalette;
|
||||
TTFProcessInitialColour(colour, &info);
|
||||
TTFProcessString(rt, text, &info);
|
||||
std::memcpy(gTextPalette, info.palette, sizeof(info.palette));
|
||||
gTextPalette = info.palette;
|
||||
|
||||
rt.lastStringPos = { info.x, info.y };
|
||||
}
|
||||
@@ -868,10 +863,10 @@ void GfxDrawStringWithYOffsets(
|
||||
info.textDrawFlags.set(TextDrawFlag::ttf);
|
||||
}
|
||||
|
||||
std::memcpy(info.palette, gTextPalette, sizeof(info.palette));
|
||||
info.palette = gTextPalette;
|
||||
TTFProcessInitialColour(colour, &info);
|
||||
TTFProcessString(rt, text, &info);
|
||||
std::memcpy(gTextPalette, info.palette, sizeof(info.palette));
|
||||
gTextPalette = info.palette;
|
||||
|
||||
rt.lastStringPos = { info.x, info.y };
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "../core/FlagHolder.hpp"
|
||||
#include "../interface/Colour.h"
|
||||
#include "../interface/ColourWithFlags.h"
|
||||
#include "TextColour.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
@@ -38,7 +39,7 @@ struct TextDrawInfo
|
||||
TextDrawFlags textDrawFlags{};
|
||||
OpenRCT2::ColourFlags colourFlags{};
|
||||
TextDarkness darkness{};
|
||||
uint8_t palette[8]{};
|
||||
OpenRCT2::Drawing::TextColours palette{};
|
||||
FontStyle fontStyle{};
|
||||
const int8_t* yOffset{};
|
||||
};
|
||||
|
||||
@@ -84,8 +84,10 @@ int32_t gPickupPeepX;
|
||||
int32_t gPickupPeepY;
|
||||
|
||||
// Originally 0x9ABE04
|
||||
uint8_t gTextPalette[0x8] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
OpenRCT2::Drawing::TextColours gTextPalette = {
|
||||
PaletteIndex::pi0,
|
||||
PaletteIndex::pi0,
|
||||
PaletteIndex::pi0,
|
||||
};
|
||||
|
||||
bool gPaintForceRedraw{ false };
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "Font.h"
|
||||
#include "ImageId.hpp"
|
||||
#include "Text.h"
|
||||
#include "TextColour.h"
|
||||
|
||||
#include <array>
|
||||
#include <cassert>
|
||||
@@ -458,7 +459,7 @@ extern OpenRCT2::Drawing::GamePalette gPalette;
|
||||
extern OpenRCT2::Drawing::GamePalette gGamePalette;
|
||||
extern uint32_t gPaletteEffectFrame;
|
||||
|
||||
extern uint8_t gTextPalette[];
|
||||
extern OpenRCT2::Drawing::TextColours gTextPalette;
|
||||
extern const TranslucentWindowPalette kTranslucentWindowPalettes[COLOUR_COUNT];
|
||||
|
||||
extern ImageId gPickupPeepImage;
|
||||
|
||||
@@ -102,12 +102,12 @@ void DrawText(RenderTarget& rt, const ScreenCoordsXY& coords, const TextPaint& p
|
||||
{
|
||||
Rectangle::fill(
|
||||
rt, { { alignedCoords + ScreenCoordsXY{ 0, 11 } }, { alignedCoords + ScreenCoordsXY{ width, 11 } } },
|
||||
gTextPalette[1]);
|
||||
if (gTextPalette[2] != 0)
|
||||
gTextPalette.fill);
|
||||
if (gTextPalette.sunnyOutline != 0)
|
||||
{
|
||||
Rectangle::fill(
|
||||
rt, { { alignedCoords + ScreenCoordsXY{ 1, 12 } }, { alignedCoords + ScreenCoordsXY{ width + 1, 12 } } },
|
||||
gTextPalette[2]);
|
||||
gTextPalette.sunnyOutline);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,9 +27,9 @@ namespace OpenRCT2::Drawing
|
||||
|
||||
struct TextColours
|
||||
{
|
||||
PaletteIndex fill;
|
||||
PaletteIndex sunnyOutline;
|
||||
PaletteIndex shadowOutline;
|
||||
PaletteIndex fill{};
|
||||
PaletteIndex sunnyOutline{};
|
||||
PaletteIndex shadowOutline{};
|
||||
};
|
||||
|
||||
TextColours getTextColourMapping(TextColour textColour);
|
||||
|
||||
@@ -744,8 +744,8 @@ void X8DrawingContext::DrawTTFBitmap(
|
||||
RenderTarget& rt, TextDrawInfo* info, TTFSurface* surface, int32_t x, int32_t y, uint8_t hintingThreshold)
|
||||
{
|
||||
#ifndef DISABLE_TTF
|
||||
const uint8_t fgColor = info->palette[1];
|
||||
const uint8_t bgColor = info->palette[3];
|
||||
const uint8_t fgColor = info->palette.fill;
|
||||
const uint8_t bgColor = info->palette.shadowOutline;
|
||||
|
||||
if (info->colourFlags.has(ColourFlag::withOutline))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user