This should gradually replace all the direct rendering of game texts
throughout the code. The interface is made to closly mirror that of the
art fonts as that is what will eventually be used for rendering Unicode
fonts both in the menus and ingame.
fixup! ✨ Generic game text render function
58 lines
1.4 KiB
C++
58 lines
1.4 KiB
C++
/**
|
|
* @file text_render.hpp
|
|
*
|
|
* Text rendering.
|
|
*/
|
|
#pragma once
|
|
|
|
#include <cstdint>
|
|
|
|
#include <SDL.h>
|
|
|
|
#include "DiabloUI/ui_item.h"
|
|
#include "engine.h"
|
|
|
|
namespace devilution {
|
|
|
|
enum GameFontTables : uint8_t {
|
|
GameFontSmall,
|
|
GameFontMed,
|
|
GameFontBig,
|
|
};
|
|
|
|
enum text_color : uint8_t {
|
|
COL_WHITE,
|
|
COL_BLUE,
|
|
COL_RED,
|
|
COL_GOLD,
|
|
COL_BLACK,
|
|
};
|
|
|
|
extern const uint8_t gbFontTransTbl[256];
|
|
extern const uint8_t fontframe[3][128];
|
|
extern const uint8_t fontkern[3][68];
|
|
|
|
extern std::optional<CelSprite> pPanelText;
|
|
extern std::optional<CelSprite> pMedTextCels;
|
|
extern std::optional<CelSprite> BigTGold_cel;
|
|
|
|
extern std::optional<CelSprite> pSPentSpn2Cels;
|
|
|
|
void InitText();
|
|
void FreeText();
|
|
|
|
/**
|
|
* @brief Print letter to the given buffer
|
|
* @param out The buffer to print to
|
|
* @param sx Backbuffer offset
|
|
* @param sy Backbuffer offset
|
|
* @param nCel Number of letter in Windows-1252
|
|
* @param col text_color color value
|
|
*/
|
|
void PrintChar(const CelOutputBuffer &out, int sx, int sy, int nCel, text_color col);
|
|
int GetLineWidth(const char *text, GameFontTables size = GameFontSmall);
|
|
void WordWrapGameString(char *text, size_t width, size_t size = GameFontSmall);
|
|
void DrawString(const CelOutputBuffer &out, const char *text, const SDL_Rect &rect, uint16_t flags = 0, bool drawTextCursor = false);
|
|
int PentSpn2Spin();
|
|
|
|
} // namespace devilution
|