forked from rosebudai/OpenRCT2-Web
Replace DrawTextNoFormatting() with a flag
This commit is contained in:
5 files changed
+17
-18
No files matched your search
@@ -344,18 +344,21 @@ void InGameConsole::Draw(RenderTarget& rt) const
|
||||
if (textColour.colour == OpenRCT2::Drawing::Colour::black)
|
||||
{
|
||||
DrawTextBasic(rt, screenCoords, "{BLACK}", { textColour, style });
|
||||
DrawTextNoFormatting(rt, screenCoords, _consoleLines[index].first, { kColourNull, style });
|
||||
DrawTextBasic(
|
||||
rt, screenCoords, _consoleLines[index].first, { kColourNull, style, { TextPaintFlag::noFormatting } });
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawTextNoFormatting(rt, screenCoords, _consoleLines[index].first, { textColour, style });
|
||||
DrawTextBasic(
|
||||
rt, screenCoords, _consoleLines[index].first, { textColour, style, { TextPaintFlag::noFormatting } });
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string lineColour = FormatTokenToStringWithBraces(_consoleLines[index].second);
|
||||
DrawTextBasic(rt, screenCoords, lineColour, { textColour, style });
|
||||
DrawTextNoFormatting(rt, screenCoords, _consoleLines[index].first, { OpenRCT2::Drawing::kColourNull, style });
|
||||
DrawTextBasic(
|
||||
rt, screenCoords, _consoleLines[index].first, { kColourNull, style, { TextPaintFlag::noFormatting } });
|
||||
}
|
||||
|
||||
screenCoords.y += lineHeight;
|
||||
@@ -367,11 +370,11 @@ void InGameConsole::Draw(RenderTarget& rt) const
|
||||
if (textColour.colour == OpenRCT2::Drawing::Colour::black)
|
||||
{
|
||||
DrawTextBasic(rt, screenCoords, "{BLACK}", { textColour, style });
|
||||
DrawTextNoFormatting(rt, screenCoords, _consoleCurrentLine, { OpenRCT2::Drawing::kColourNull, style });
|
||||
DrawTextBasic(rt, screenCoords, _consoleCurrentLine, { kColourNull, style, { TextPaintFlag::noFormatting } });
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawTextNoFormatting(rt, screenCoords, _consoleCurrentLine, { textColour, style });
|
||||
DrawTextBasic(rt, screenCoords, _consoleCurrentLine, { textColour, style, { TextPaintFlag::noFormatting } });
|
||||
}
|
||||
|
||||
// Draw caret
|
||||
|
||||
@@ -1196,7 +1196,8 @@ namespace OpenRCT2::Ui
|
||||
{
|
||||
u8string wrappedString;
|
||||
wrapString(widget.string, bottomRight.x - topLeft.x - 5, FontStyle::medium, &wrappedString, nullptr);
|
||||
DrawTextNoFormatting(rt, { topLeft.x + 2, topLeft.y }, wrappedString, { w.colours[1] });
|
||||
DrawTextBasic(
|
||||
rt, { topLeft.x + 2, topLeft.y }, wrappedString, { w.colours[1], { TextPaintFlag::noFormatting } });
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -1206,7 +1207,7 @@ namespace OpenRCT2::Ui
|
||||
u8string wrappedString;
|
||||
wrapString(*textInput->Buffer, bottomRight.x - topLeft.x - 5 - 6, FontStyle::medium, &wrappedString, nullptr);
|
||||
|
||||
DrawTextNoFormatting(rt, { topLeft.x + 2, topLeft.y }, wrappedString, { w.colours[1] });
|
||||
DrawTextBasic(rt, { topLeft.x + 2, topLeft.y }, wrappedString, { w.colours[1], { TextPaintFlag::noFormatting } });
|
||||
|
||||
// Make a trimmed view of the string for measuring the width.
|
||||
int32_t curX = topLeft.x
|
||||
|
||||
@@ -245,7 +245,9 @@ namespace OpenRCT2::Ui::Windows
|
||||
for (int32_t line = 0; line <= no_lines; line++)
|
||||
{
|
||||
screenCoords.x = windowPos.x + 12;
|
||||
DrawTextNoFormatting(rt, screenCoords, wrapPointer, { colours[1], FontStyle::medium, TextAlignment::left });
|
||||
DrawTextBasic(
|
||||
rt, screenCoords, wrapPointer,
|
||||
{ colours[1], FontStyle::medium, { TextPaintFlag::noFormatting }, TextAlignment::left });
|
||||
|
||||
size_t string_length = GetStringSize(wrapPointer) - 1;
|
||||
if (!cur_drawn && (textInput->SelectionStart <= char_count + string_length))
|
||||
|
||||
@@ -80,9 +80,9 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
static void DrawText(
|
||||
RenderTarget& rt, const ScreenCoordsXY& coords, u8string_view text, const TextPaint& paint, bool noFormatting = false)
|
||||
static void DrawText(RenderTarget& rt, const ScreenCoordsXY& coords, u8string_view text, const TextPaint& paint)
|
||||
{
|
||||
auto noFormatting = paint.flags.has(TextPaintFlag::noFormatting);
|
||||
int32_t width = getStringWidth(text, paint.fontStyle, noFormatting);
|
||||
|
||||
auto alignedCoords = coords;
|
||||
@@ -114,11 +114,6 @@ static void DrawText(
|
||||
}
|
||||
}
|
||||
|
||||
void DrawTextNoFormatting(RenderTarget& rt, const ScreenCoordsXY& coords, u8string_view string, TextPaint textPaint)
|
||||
{
|
||||
DrawText(rt, coords, string, textPaint, true);
|
||||
}
|
||||
|
||||
void DrawTextBasic(RenderTarget& rt, const ScreenCoordsXY& coords, StringId format, TextPaint textPaint)
|
||||
{
|
||||
DrawTextBasic(rt, coords, LanguageGetString(format), textPaint);
|
||||
|
||||
@@ -38,6 +38,7 @@ enum class TextAlignment
|
||||
enum class TextPaintFlag
|
||||
{
|
||||
underline,
|
||||
noFormatting,
|
||||
};
|
||||
using TextPaintFlags = FlagHolder<uint8_t, TextPaintFlag>;
|
||||
|
||||
@@ -210,9 +211,6 @@ struct TextPaint
|
||||
}
|
||||
};
|
||||
|
||||
void DrawTextNoFormatting(
|
||||
OpenRCT2::Drawing::RenderTarget& rt, const ScreenCoordsXY& coords, u8string_view string, TextPaint textPaint = {});
|
||||
|
||||
void DrawTextBasic(
|
||||
OpenRCT2::Drawing::RenderTarget& rt, const ScreenCoordsXY& coords, StringId format, TextPaint textPaint = {});
|
||||
void DrawTextBasic(
|
||||
|
||||
Reference in new issue
Block a user