mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-11-02 17:27:23 -04:00
Merge pull request #929 from PushUpek/charset_support
Added support for charset
This commit is contained in:
commit
cefea41810
@ -67,6 +67,7 @@ type App struct {
|
||||
gitBranch string
|
||||
gitCommit string
|
||||
language string
|
||||
charset string
|
||||
asset *d2asset.AssetManager
|
||||
inputManager d2interface.InputManager
|
||||
terminal d2interface.Terminal
|
||||
@ -460,6 +461,9 @@ func (a *App) initConfig(config *d2config.Configuration) error {
|
||||
func (a *App) initLanguage() {
|
||||
a.language = a.asset.LoadLanguage(d2resource.LocalLanguage)
|
||||
a.asset.Loader.SetLanguage(&a.language)
|
||||
|
||||
a.charset = d2resource.GetFontCharset(a.language)
|
||||
a.asset.Loader.SetCharset(&a.charset)
|
||||
}
|
||||
|
||||
func (a *App) initDataDictionaries() error {
|
||||
|
@ -48,6 +48,7 @@ func NewLoader(l d2util.LogLevel) (*Loader, error) {
|
||||
// that have been added
|
||||
type Loader struct {
|
||||
language *string
|
||||
charset *string
|
||||
d2interface.Cache
|
||||
*d2util.Logger
|
||||
Sources []asset.Source
|
||||
@ -58,15 +59,22 @@ func (l *Loader) SetLanguage(language *string) {
|
||||
l.language = language
|
||||
}
|
||||
|
||||
// SetCharset sets the charset for loader
|
||||
func (l *Loader) SetCharset(charset *string) {
|
||||
l.charset = charset
|
||||
}
|
||||
|
||||
// Load attempts to load an asset with the given sub-path. The sub-path is relative to the root
|
||||
// of each asset source root (regardless of the type of asset source)
|
||||
func (l *Loader) Load(subPath string) (asset.Asset, error) {
|
||||
subPath = filepath.Clean(subPath)
|
||||
|
||||
if l.language != nil {
|
||||
lang := l.language
|
||||
subPath = strings.ReplaceAll(subPath, fontToken, "latin")
|
||||
subPath = strings.ReplaceAll(subPath, tableToken, *lang)
|
||||
charset := l.charset
|
||||
language := l.language
|
||||
|
||||
subPath = strings.ReplaceAll(subPath, fontToken, *charset)
|
||||
subPath = strings.ReplaceAll(subPath, tableToken, *language)
|
||||
}
|
||||
|
||||
// first, we check the cache for an existing entry
|
||||
|
@ -24,3 +24,28 @@ func GetLanguageLiteral(code byte) string {
|
||||
|
||||
return languages[code]
|
||||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
}
|
||||
|
||||
// GetFontCharset returns string representation of font charset
|
||||
func GetFontCharset(language string) string {
|
||||
charset := getCharsets()
|
||||
|
||||
return charset[language]
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ const (
|
||||
// --- Credits ---
|
||||
|
||||
CreditsBackground = "/data/global/ui/CharSelect/creditsbckgexpand.dc6"
|
||||
CreditsText = "/data/local/ui/{LANG}/ExpansionCredits.txt"
|
||||
CreditsText = "/data/local/ui/" + LanguageTableToken + "/ExpansionCredits.txt"
|
||||
|
||||
// --- Cinematics ---
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user