Changeset - r24210:b9baa2f1bb39
[Not reviewed]
master
0 4 0
Michael Lutz - 4 years ago 2020-05-17 21:31:49
michi@icosahedron.de
Codechange: Consistently use WChar when passing characters around, and also define it as char32_t.
4 files changed with 6 insertions and 6 deletions:
0 comments (0 inline, 0 general)
src/fontcache.cpp
Show inline comments
 
@@ -102,19 +102,19 @@ SpriteFontCache::SpriteFontCache(FontSiz
 
 */
 
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);
 
	this->glyph_to_spriteid_map[GB(key, 8, 8)][GB(key, 0, 8)] = sprite;
 
}
 

	
src/gfx_func.h
Show inline comments
 
@@ -109,13 +109,13 @@ DECLARE_ENUM_AS_BIT_SET(StringAlignment)
 

	
 
int DrawString(int left, int right, int top, const char *str, TextColour colour = TC_FROMSTRING, StringAlignment align = SA_LEFT, bool underline = false, FontSize fontsize = FS_NORMAL);
 
int DrawString(int left, int right, int top, StringID str, TextColour colour = TC_FROMSTRING, StringAlignment align = SA_LEFT, bool underline = false, FontSize fontsize = FS_NORMAL);
 
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);
 
void GfxDrawLine(int left, int top, int right, int bottom, int colour, int width = 1, int dash = 0);
 
void DrawBox(int x, int y, int dx1, int dy1, int dx2, int dy2, int dx3, int dy3);
 

	
 
@@ -161,13 +161,13 @@ void CursorTick();
 
void UpdateCursorSize();
 
bool ChangeResInGame(int w, int h);
 
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);
 

	
 
int GetCharacterHeight(FontSize size);
 

	
 
/** Height of characters in the small (#FS_SMALL) font. @note Some characters may be oversized. */
src/string_type.h
Show inline comments
 
@@ -29,13 +29,13 @@ enum CharSetFilter {
 
	CS_NUMERAL_SPACE,     ///< Only numbers and spaces
 
	CS_ALPHA,             ///< Only alphabetic values
 
	CS_HEXADECIMAL,       ///< Only hexadecimal characters
 
};
 

	
 
/** 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 */
 
static const WChar CHAR_TD_LRM = 0x200E; ///< The next character acts like a left-to-right character.
 
static const WChar CHAR_TD_RLM = 0x200F; ///< The next character acts like a right-to-left character.
 
static const WChar CHAR_TD_LRE = 0x202A; ///< The following text is embedded left-to-right.
src/textbuf_type.h
Show inline comments
 
@@ -50,13 +50,13 @@ struct Textbuf {
 
	void Assign(const char *text);
 
	void CDECL Print(const char *format, ...) WARN_FORMAT(2, 3);
 

	
 
	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);
 
	bool MovePos(uint16 keycode);
 

	
 
	HandleKeyPressResult HandleKeyPress(WChar key, uint16 keycode);
0 comments (0 inline, 0 general)