Codechange: Consistently use WChar when passing characters around, and also define it as char32_t.

desync-debugging
Michael Lutz 4 years ago
parent 43cd892e0c
commit 808c8198d5

@ -105,13 +105,13 @@ SpriteFontCache::~SpriteFontCache()
this->ClearGlyphToSpriteMap();
}
SpriteID SpriteFontCache::GetUnicodeGlyph(GlyphID key)
SpriteID SpriteFontCache::GetUnicodeGlyph(WChar key)
{
if (this->glyph_to_spriteid_map[GB(key, 8, 8)] == nullptr) return 0;
return this->glyph_to_spriteid_map[GB(key, 8, 8)][GB(key, 0, 8)];
}
void SpriteFontCache::SetUnicodeGlyph(GlyphID key, SpriteID sprite)
void SpriteFontCache::SetUnicodeGlyph(WChar key, SpriteID sprite)
{
if (this->glyph_to_spriteid_map == nullptr) this->glyph_to_spriteid_map = CallocT<SpriteID*>(256);
if (this->glyph_to_spriteid_map[GB(key, 8, 8)] == nullptr) this->glyph_to_spriteid_map[GB(key, 8, 8)] = CallocT<SpriteID>(256);

@ -112,7 +112,7 @@ int DrawString(int left, int right, int top, StringID str, TextColour colour = T
int DrawStringMultiLine(int left, int right, int top, int bottom, const char *str, TextColour colour = TC_FROMSTRING, StringAlignment align = (SA_TOP | SA_LEFT), bool underline = false, FontSize fontsize = FS_NORMAL);
int DrawStringMultiLine(int left, int right, int top, int bottom, StringID str, TextColour colour = TC_FROMSTRING, StringAlignment align = (SA_TOP | SA_LEFT), bool underline = false, FontSize fontsize = FS_NORMAL);
void DrawCharCentered(uint32 c, int x, int y, TextColour colour);
void DrawCharCentered(WChar c, int x, int y, TextColour colour);
void GfxFillRect(int left, int top, int right, int bottom, int colour, FillRectMode mode = FILLRECT_OPAQUE);
void GfxFillPolygon(const std::vector<Point> &shape, int colour, FillRectMode mode = FILLRECT_OPAQUE);
@ -164,7 +164,7 @@ void SortResolutions();
bool ToggleFullScreen(bool fs);
/* gfx.cpp */
byte GetCharacterWidth(FontSize size, uint32 key);
byte GetCharacterWidth(FontSize size, WChar key);
byte GetDigitWidth(FontSize size = FS_NORMAL);
void GetBroadestDigit(uint *front, uint *next, FontSize size = FS_NORMAL);

@ -32,7 +32,7 @@ enum CharSetFilter {
};
/** Type for wide characters, i.e. non-UTF8 encoded unicode characters. */
typedef uint32 WChar;
typedef char32_t WChar;
/* The following are directional formatting codes used to get the LTR and RTL strings right:
* http://www.unicode.org/unicode/reports/tr9/#Directional_Formatting_Codes */

@ -53,7 +53,7 @@ struct Textbuf {
void DeleteAll();
bool InsertClipboard();
bool InsertChar(uint32 key);
bool InsertChar(WChar key);
bool InsertString(const char *str, bool marked, const char *caret = nullptr, const char *insert_location = nullptr, const char *replacement_end = nullptr);
bool DeleteChar(uint16 keycode);

Loading…
Cancel
Save