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"
|
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
|
|
|
|
{
|
2018-06-22 22:59:03 +02:00
|
|
|
uint8_t Colour = 0;
|
|
|
|
int16_t SpriteBase = 0;
|
2021-02-26 21:11:26 +01:00
|
|
|
TextUnderline UnderlineText = TextUnderline::Off;
|
2018-06-22 22:59:03 +02:00
|
|
|
TextAlignment Alignment = TextAlignment::LEFT;
|
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
|
|
|
|
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);
|