mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2025-02-20 23:47:16 -05:00
Added support for charset
This commit is contained in:
parent
9ab89a59d4
commit
bbba67487d
@ -67,6 +67,7 @@ type App struct {
|
|||||||
gitBranch string
|
gitBranch string
|
||||||
gitCommit string
|
gitCommit string
|
||||||
language string
|
language string
|
||||||
|
charset string
|
||||||
asset *d2asset.AssetManager
|
asset *d2asset.AssetManager
|
||||||
inputManager d2interface.InputManager
|
inputManager d2interface.InputManager
|
||||||
terminal d2interface.Terminal
|
terminal d2interface.Terminal
|
||||||
@ -460,6 +461,9 @@ func (a *App) initConfig(config *d2config.Configuration) error {
|
|||||||
func (a *App) initLanguage() {
|
func (a *App) initLanguage() {
|
||||||
a.language = a.asset.LoadLanguage(d2resource.LocalLanguage)
|
a.language = a.asset.LoadLanguage(d2resource.LocalLanguage)
|
||||||
a.asset.Loader.SetLanguage(&a.language)
|
a.asset.Loader.SetLanguage(&a.language)
|
||||||
|
|
||||||
|
a.charset = d2resource.GetFontCharset(a.language)
|
||||||
|
a.asset.Loader.SetCharset(&a.charset)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) initDataDictionaries() error {
|
func (a *App) initDataDictionaries() error {
|
||||||
|
@ -48,6 +48,7 @@ func NewLoader(l d2util.LogLevel) (*Loader, error) {
|
|||||||
// that have been added
|
// that have been added
|
||||||
type Loader struct {
|
type Loader struct {
|
||||||
language *string
|
language *string
|
||||||
|
charset *string
|
||||||
d2interface.Cache
|
d2interface.Cache
|
||||||
*d2util.Logger
|
*d2util.Logger
|
||||||
Sources []asset.Source
|
Sources []asset.Source
|
||||||
@ -58,15 +59,22 @@ func (l *Loader) SetLanguage(language *string) {
|
|||||||
l.language = language
|
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
|
// 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)
|
// of each asset source root (regardless of the type of asset source)
|
||||||
func (l *Loader) Load(subPath string) (asset.Asset, error) {
|
func (l *Loader) Load(subPath string) (asset.Asset, error) {
|
||||||
subPath = filepath.Clean(subPath)
|
subPath = filepath.Clean(subPath)
|
||||||
|
|
||||||
if l.language != nil {
|
if l.language != nil {
|
||||||
lang := l.language
|
charset := l.charset
|
||||||
subPath = strings.ReplaceAll(subPath, fontToken, "latin")
|
language := l.language
|
||||||
subPath = strings.ReplaceAll(subPath, tableToken, *lang)
|
|
||||||
|
subPath = strings.ReplaceAll(subPath, fontToken, *charset)
|
||||||
|
subPath = strings.ReplaceAll(subPath, tableToken, *language)
|
||||||
}
|
}
|
||||||
|
|
||||||
// first, we check the cache for an existing entry
|
// first, we check the cache for an existing entry
|
||||||
|
@ -24,3 +24,28 @@ func GetLanguageLiteral(code byte) string {
|
|||||||
|
|
||||||
return languages[code]
|
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 ---
|
// --- Credits ---
|
||||||
|
|
||||||
CreditsBackground = "/data/global/ui/CharSelect/creditsbckgexpand.dc6"
|
CreditsBackground = "/data/global/ui/CharSelect/creditsbckgexpand.dc6"
|
||||||
CreditsText = "/data/local/ui/{LANG}/ExpansionCredits.txt"
|
CreditsText = "/data/local/ui/" + LanguageTableToken + "/ExpansionCredits.txt"
|
||||||
|
|
||||||
// --- Cinematics ---
|
// --- Cinematics ---
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user