1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-16 11:33:03 +01:00

Use ColourFlags in TextDrawInfo

This commit is contained in:
Gymnasiast
2025-10-16 23:25:24 +02:00
parent 64ef3da5a4
commit 9c2000565d
5 changed files with 20 additions and 29 deletions

View File

@@ -1211,7 +1211,7 @@ void OpenGLDrawingContext::DrawTTFBitmap(
right += clip.GetLeft() - rt.x;
bottom += clip.GetTop() - rt.y;
if (info->flags & TEXT_DRAW_FLAG_OUTLINE)
if (info->colourFlags.has(ColourFlag::withOutline))
{
std::array<ivec4, 4> boundsArr = { {
{ left + 1, top, right + 1, bottom },
@@ -1235,7 +1235,7 @@ void OpenGLDrawingContext::DrawTTFBitmap(
command.zoom = 1.0f;
}
}
if (info->flags & TEXT_DRAW_FLAG_INSET)
if (info->colourFlags.has(ColourFlag::inset))
{
DrawRectCommand& command = _commandBuffers.rects.allocate();
command.clip = { clip.GetLeft(), clip.GetTop(), clip.GetRight(), clip.GetBottom() };

View File

@@ -273,7 +273,7 @@ void GfxDrawStringLeftCentred(
/**
* Changes the palette so that the next character changes colour
*/
static void ColourCharacter(TextColour colour, const uint16_t* current_font_flags, uint8_t* palette_pointer)
static void ColourCharacter(TextColour colour, bool withOutline, uint8_t* palette_pointer)
{
int32_t colour32 = 0;
const G1Element* g1 = GfxGetG1Element(SPR_TEXT_PALETTE);
@@ -283,7 +283,7 @@ static void ColourCharacter(TextColour colour, const uint16_t* current_font_flag
std::memcpy(&colour32, &g1->offset[idx], sizeof(colour32));
}
if (!(*current_font_flags & TEXT_DRAW_FLAG_OUTLINE))
if (!withOutline)
{
colour32 = colour32 & 0x0FF0000FF;
}
@@ -298,12 +298,12 @@ static void ColourCharacter(TextColour colour, const uint16_t* current_font_flag
* 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, const uint16_t* current_font_flags, uint8_t* palette_pointer)
static void ColourCharacterWindow(colour_t colour, bool withOutline, uint8_t* palette_pointer)
{
int32_t eax;
eax = ColourMapA[colour].colour_11;
if (*current_font_flags & TEXT_DRAW_FLAG_OUTLINE)
if (withOutline)
{
eax |= 0x0A0A00;
}
@@ -569,27 +569,24 @@ static void TTFProcessFormatCode(RenderTarget& rt, const FmtString::Token& token
info->fontStyle = FontStyle::medium;
break;
case FormatToken::outlineEnable:
info->flags |= TEXT_DRAW_FLAG_OUTLINE;
info->colourFlags.set(ColourFlag::withOutline);
break;
case FormatToken::outlineDisable:
info->flags &= ~TEXT_DRAW_FLAG_OUTLINE;
info->colourFlags.unset(ColourFlag::withOutline);
break;
case FormatToken::colourWindow1:
{
uint16_t flags = info->flags;
ColourCharacterWindow(gCurrentWindowColours[0], &flags, info->palette);
ColourCharacterWindow(gCurrentWindowColours[0], info->colourFlags.has(ColourFlag::withOutline), info->palette);
break;
}
case FormatToken::colourWindow2:
{
uint16_t flags = info->flags;
ColourCharacterWindow(gCurrentWindowColours[1], &flags, info->palette);
ColourCharacterWindow(gCurrentWindowColours[1], info->colourFlags.has(ColourFlag::withOutline), info->palette);
break;
}
case FormatToken::colourWindow3:
{
uint16_t flags = info->flags;
ColourCharacterWindow(gCurrentWindowColours[2], &flags, info->palette);
ColourCharacterWindow(gCurrentWindowColours[2], info->colourFlags.has(ColourFlag::withOutline), info->palette);
break;
}
case FormatToken::inlineSprite:
@@ -609,9 +606,8 @@ static void TTFProcessFormatCode(RenderTarget& rt, const FmtString::Token& token
default:
if (FormatTokenIsColour(token.kind))
{
uint16_t flags = info->flags;
auto colourIndex = FormatTokenToTextColour(token.kind);
ColourCharacter(colourIndex, &flags, info->palette);
ColourCharacter(colourIndex, info->colourFlags.has(ColourFlag::withOutline), info->palette);
}
break;
}
@@ -753,20 +749,14 @@ static void TTFProcessInitialColour(ColourWithFlags colour, TextDrawInfo* info)
{
if (colour.colour != kTextColour254 && colour.colour != kTextColour255)
{
info->flags &= ~(TEXT_DRAW_FLAG_INSET | TEXT_DRAW_FLAG_OUTLINE);
if (colour.flags.has(ColourFlag::withOutline))
{
info->flags |= TEXT_DRAW_FLAG_OUTLINE;
}
info->colourFlags = colour.flags;
if (!colour.flags.has(ColourFlag::inset))
{
uint16_t flags = info->flags;
ColourCharacterWindow(colour.colour, &flags, reinterpret_cast<uint8_t*>(&info->palette));
ColourCharacterWindow(
colour.colour, info->colourFlags.has(ColourFlag::withOutline), reinterpret_cast<uint8_t*>(&info->palette));
}
else
{
info->flags |= TEXT_DRAW_FLAG_INSET;
uint32_t eax = 0;
switch (info->darkness)
{

View File

@@ -9,6 +9,8 @@
#pragma once
#include "../interface/Colour.h"
#include <cstdint>
enum class FontStyle : uint8_t;
@@ -23,6 +25,7 @@ struct TextDrawInfo
int32_t maxX;
int32_t maxY;
int32_t flags;
ColourFlags colourFlags;
TextDarkness darkness;
uint8_t palette[8];
FontStyle fontStyle;

View File

@@ -115,8 +115,6 @@ struct RenderTarget
enum : uint32_t
{
TEXT_DRAW_FLAG_INSET = 1 << 0,
TEXT_DRAW_FLAG_OUTLINE = 1 << 1,
TEXT_DRAW_FLAG_NO_FORMATTING = 1 << 28,
TEXT_DRAW_FLAG_Y_OFFSET_EFFECT = 1 << 29,
TEXT_DRAW_FLAG_TTF = 1 << 30,

View File

@@ -747,14 +747,14 @@ void X8DrawingContext::DrawTTFBitmap(
const uint8_t fgColor = info->palette[1];
const uint8_t bgColor = info->palette[3];
if (info->flags & TEXT_DRAW_FLAG_OUTLINE)
if (info->colourFlags.has(ColourFlag::withOutline))
{
DrawTTFBitmapInternal<false>(rt, bgColor, surface, x + 1, y, 0);
DrawTTFBitmapInternal<false>(rt, bgColor, surface, x - 1, y, 0);
DrawTTFBitmapInternal<false>(rt, bgColor, surface, x, y + 1, 0);
DrawTTFBitmapInternal<false>(rt, bgColor, surface, x, y - 1, 0);
}
if (info->flags & TEXT_DRAW_FLAG_INSET)
if (info->colourFlags.has(ColourFlag::inset))
{
DrawTTFBitmapInternal<false>(rt, bgColor, surface, x + 1, y + 1, 0);
}