2017-07-22 22:08:25 +02:00
|
|
|
/*****************************************************************************
|
2020-07-21 15:04:34 +02:00
|
|
|
* Copyright (c) 2014-2020 OpenRCT2 developers
|
2017-07-22 22:08:25 +02:00
|
|
|
*
|
2018-06-15 14:07:34 +02:00
|
|
|
* For a complete list of all authors, please refer to contributors.md
|
|
|
|
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
|
2017-07-22 22:08:25 +02:00
|
|
|
*
|
2018-06-15 14:07:34 +02:00
|
|
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
2017-07-22 22:08:25 +02:00
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "../common.h"
|
2021-02-27 12:49:14 +01:00
|
|
|
#include "../interface/Colour.h"
|
2021-02-27 12:40:20 +01:00
|
|
|
#include "Font.h"
|
2018-03-13 13:14:02 +01:00
|
|
|
|
2020-07-08 14:14:43 +02:00
|
|
|
struct ScreenCoordsXY;
|
2018-03-13 13:14:02 +01:00
|
|
|
struct rct_drawpixelinfo;
|
2020-08-26 14:57:49 +02:00
|
|
|
class Formatter;
|
2017-07-22 22:08:25 +02:00
|
|
|
|
|
|
|
enum class TextAlignment
|
|
|
|
{
|
|
|
|
LEFT,
|
|
|
|
CENTRE,
|
|
|
|
RIGHT
|
|
|
|
};
|
|
|
|
|
2021-02-26 21:11:26 +01:00
|
|
|
enum class TextUnderline
|
|
|
|
{
|
|
|
|
Off,
|
|
|
|
On,
|
|
|
|
};
|
|
|
|
|
2017-07-22 22:08:25 +02:00
|
|
|
struct TextPaint
|
|
|
|
{
|
2021-02-27 12:49:14 +01:00
|
|
|
colour_t Colour = COLOUR_BLACK;
|
2021-02-27 12:40:20 +01:00
|
|
|
FontSpriteBase SpriteBase = FontSpriteBase::SMALL;
|
2021-02-26 21:11:26 +01:00
|
|
|
TextUnderline UnderlineText = TextUnderline::Off;
|
2018-06-22 22:59:03 +02:00
|
|
|
TextAlignment Alignment = TextAlignment::LEFT;
|
2021-02-27 13:04:52 +01:00
|
|
|
|
|
|
|
explicit TextPaint()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
TextPaint(colour_t colour)
|
|
|
|
: Colour(colour)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
TextPaint(FontSpriteBase spriteBase)
|
|
|
|
: SpriteBase(spriteBase)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
TextPaint(TextUnderline underlineText)
|
|
|
|
: UnderlineText(underlineText)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
TextPaint(TextAlignment alignment)
|
|
|
|
: Alignment(alignment)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
TextPaint(colour_t colour, FontSpriteBase spriteBase)
|
|
|
|
: Colour(colour)
|
|
|
|
, SpriteBase(spriteBase)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
TextPaint(colour_t colour, TextUnderline underlineText)
|
|
|
|
: Colour(colour)
|
|
|
|
, UnderlineText(underlineText)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
TextPaint(colour_t colour, TextAlignment alignment)
|
|
|
|
: Colour(colour)
|
|
|
|
, Alignment(alignment)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
TextPaint(FontSpriteBase spriteBase, TextUnderline underlineText)
|
|
|
|
: SpriteBase(spriteBase)
|
|
|
|
, UnderlineText(underlineText)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
TextPaint(FontSpriteBase spriteBase, TextAlignment alignment)
|
|
|
|
: SpriteBase(spriteBase)
|
|
|
|
, Alignment(alignment)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
TextPaint(colour_t colour, FontSpriteBase spriteBase, TextUnderline underlineText)
|
|
|
|
: Colour(colour)
|
|
|
|
, SpriteBase(spriteBase)
|
|
|
|
, UnderlineText(underlineText)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
TextPaint(colour_t colour, FontSpriteBase spriteBase, TextAlignment alignment)
|
|
|
|
: Colour(colour)
|
|
|
|
, SpriteBase(spriteBase)
|
|
|
|
, Alignment(alignment)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
TextPaint(colour_t colour, TextUnderline underlineText, TextAlignment alignment)
|
|
|
|
: Colour(colour)
|
|
|
|
, UnderlineText(underlineText)
|
|
|
|
, Alignment(alignment)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
TextPaint(FontSpriteBase spriteBase, TextUnderline underlineText, TextAlignment alignment)
|
|
|
|
: SpriteBase(spriteBase)
|
|
|
|
, UnderlineText(underlineText)
|
|
|
|
, Alignment(alignment)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
TextPaint(colour_t colour, FontSpriteBase spriteBase, TextUnderline underlineText, TextAlignment alignment)
|
|
|
|
: Colour(colour)
|
|
|
|
, SpriteBase(spriteBase)
|
|
|
|
, UnderlineText(underlineText)
|
|
|
|
, Alignment(alignment)
|
|
|
|
{
|
|
|
|
}
|
2017-07-22 22:08:25 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class StaticLayout
|
|
|
|
{
|
|
|
|
private:
|
2020-07-08 14:43:23 +02:00
|
|
|
utf8string Buffer;
|
|
|
|
TextPaint Paint;
|
|
|
|
int32_t LineCount = 0;
|
|
|
|
int32_t LineHeight;
|
|
|
|
int32_t MaxWidth;
|
2017-07-22 22:08:25 +02:00
|
|
|
|
2017-10-14 23:53:45 +02:00
|
|
|
StaticLayout();
|
2018-06-22 22:59:03 +02:00
|
|
|
StaticLayout(const StaticLayout&);
|
2017-10-14 23:53:45 +02:00
|
|
|
|
2017-07-22 22:08:25 +02:00
|
|
|
public:
|
2020-07-31 11:13:28 +02:00
|
|
|
StaticLayout(utf8string source, const TextPaint& paint, int32_t width);
|
2020-07-08 14:14:43 +02:00
|
|
|
void Draw(rct_drawpixelinfo* dpi, const ScreenCoordsXY& coords);
|
2018-06-20 17:28:51 +02:00
|
|
|
int32_t GetHeight();
|
|
|
|
int32_t GetWidth();
|
|
|
|
int32_t GetLineCount();
|
2017-07-22 22:08:25 +02:00
|
|
|
};
|
2020-08-26 14:44:30 +02:00
|
|
|
|
2021-02-27 13:10:00 +01:00
|
|
|
void DrawTextBasic(
|
|
|
|
rct_drawpixelinfo* dpi, const ScreenCoordsXY& coords, rct_string_id format, const Formatter& ft, TextPaint textPaint);
|
|
|
|
void DrawTextBasic(
|
|
|
|
rct_drawpixelinfo* dpi, const ScreenCoordsXY& coords, rct_string_id format, const void* args, TextPaint textPaint);
|
2020-08-26 14:57:49 +02:00
|
|
|
void DrawTextBasic(
|
2020-08-26 15:38:27 +02:00
|
|
|
rct_drawpixelinfo* dpi, const ScreenCoordsXY& coords, rct_string_id format, const Formatter& ft, colour_t colour,
|
2020-08-28 18:03:51 +02:00
|
|
|
TextAlignment alignment = TextAlignment::LEFT, bool underline = false);
|
2020-08-26 14:44:30 +02:00
|
|
|
void DrawTextBasic(
|
2020-08-26 15:38:27 +02:00
|
|
|
rct_drawpixelinfo* dpi, const ScreenCoordsXY& coords, rct_string_id format, const void* args, colour_t colour,
|
2020-08-28 18:03:51 +02:00
|
|
|
TextAlignment alignment = TextAlignment::LEFT, bool underline = false);
|
2020-08-26 14:57:49 +02:00
|
|
|
void DrawTextEllipsised(
|
|
|
|
rct_drawpixelinfo* dpi, const ScreenCoordsXY& coords, int32_t width, rct_string_id format, const Formatter& ft,
|
2020-08-28 18:03:51 +02:00
|
|
|
colour_t colour, TextAlignment alignment = TextAlignment::LEFT, bool underline = false);
|