From 2a36c956a4398793b0554ee9bc10b58af2c3519b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Mr=C3=B3wka?= Date: Wed, 18 Nov 2020 08:50:31 +0100 Subject: [PATCH] Label fix (#931) --- d2common/d2resource/languages_map.go | 24 ++++++++++++------------ d2core/d2ui/label.go | 6 +++++- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/d2common/d2resource/languages_map.go b/d2common/d2resource/languages_map.go index af6a012f..2a549692 100644 --- a/d2common/d2resource/languages_map.go +++ b/d2common/d2resource/languages_map.go @@ -28,18 +28,18 @@ func GetLanguageLiteral(code byte) string { // Source https://github.com/eezstreet/OpenD2/blob/065f6e466048482b28b9dbc6286908dc1e0d10f6/Shared/D2Shared.hpp#L36 func getCharsets() map[string]string { return map[string]string{ - "ENG": "LATIN", // (English) - "ESP": "LATIN", // (Spanish) - "DEU": "LATIN", // (German) - "FRA": "LATIN", // (French) - "POR": "LATIN", // (Portuguese) - "ITA": "LATIN", // (Italian) - "JPN": "JAPAN", // (Japanese) - "KOR": "KOREAN", // (Korean) - "SIN": "LATIN", // - "CHI": "CHINESE", // (Chinese) - "POL": "LATIN2", // (Polish) - "RUS": "RUSSIAN", // (Russian) + "ENG": "LATIN", // (English) + "ESP": "LATIN", // (Spanish) + "DEU": "LATIN", // (German) + "FRA": "LATIN", // (French) + "POR": "LATIN", // (Portuguese) + "ITA": "LATIN", // (Italian) + "JPN": "JPN", // (Japanese) + "KOR": "KOR", // (Korean) + "SIN": "LATIN", // + "CHI": "CHI", // (Chinese) + "POL": "LATIN2", // (Polish) + "RUS": "CYR", // (Russian) } } diff --git a/d2core/d2ui/label.go b/d2core/d2ui/label.go index 4ce6fe60..1e80cef1 100644 --- a/d2core/d2ui/label.go +++ b/d2core/d2ui/label.go @@ -133,7 +133,11 @@ func (v *Label) processColorTokens(str string) string { matchToken := tokenMatch.Find(match) matchStr := string(tokenMatch.ReplaceAll(match, empty)) token := ColorToken(matchToken) + theColor := getColor(token) + if theColor == nil { + continue + } if v.Color == nil { v.Color = make(map[int]color.Color) @@ -183,7 +187,7 @@ func getColor(token ColorToken) color.Color { chosen := colors[token] if chosen == nil { - return colors[ColorTokenWhite] + return nil } return chosen