minor edits (#401)

* make game update at 25fps, ui update at max fps

* minor edits to func names, d2resource constants

* renamed `loadDictionary` to `loadTextDictionary` to avoid confusion with `LoadDataDictionary`
* updated line in main.go that calls `loadTextDictionary`
* added tokens as constants inside of `d2resource/resource_paths.go` that are used in font/language paths
* moved locale string handling stuff into it's own func, now uses tokens defined in d2resource

* minor edits to func names, d2resource constants

* renamed `loadDictionary` to `loadTextDictionary` to avoid confusion with `LoadDataDictionary`
* updated line in main.go that calls `loadTextDictionary`
* added tokens as constants inside of `d2resource/resource_paths.go` that are used in font/language paths
* moved locale string handling stuff into it's own func, now uses tokens defined in d2resource

* fix: accidentally renamed func in d2asset

* git is hard

accidentally added changes not meant for this commit
This commit is contained in:
dk 2020-06-22 14:36:45 -07:00 committed by GitHub
parent 0c27ae63e6
commit 953271b8e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 43 additions and 56 deletions

View File

@ -97,21 +97,26 @@ const (
CursorDefault = "/data/global/ui/CURSOR/ohand.DC6"
// --- Fonts ---
// --- Fonts & Locale (strings) ---
Font6 = "/data/local/FONT/{LANG_FONT}/font6"
Font8 = "/data/local/FONT/{LANG_FONT}/font8"
Font16 = "/data/local/FONT/{LANG_FONT}/font16"
Font24 = "/data/local/FONT/{LANG_FONT}/font24"
Font30 = "/data/local/FONT/{LANG_FONT}/font30"
Font42 = "/data/local/FONT/{LANG_FONT}/font42"
FontFormal12 = "/data/local/FONT/{LANG_FONT}/fontformal12"
FontFormal11 = "/data/local/FONT/{LANG_FONT}/fontformal11"
FontFormal10 = "/data/local/FONT/{LANG_FONT}/fontformal10"
FontExocet10 = "/data/local/FONT/{LANG_FONT}/fontexocet10"
FontExocet8 = "/data/local/FONT/{LANG_FONT}/fontexocet8"
FontSucker = "/data/local/FONT/{LANG_FONT}/ReallyTheLastSucker"
FontRediculous = "/data/local/FONT/{LANG_FONT}/fontridiculous"
LanguageFontToken = "{LANG_FONT}"
LanguageTableToken = "{LANG}"
Font6 = "/data/local/FONT/" + LanguageFontToken + "/font6"
Font8 = "/data/local/FONT/" + LanguageFontToken + "/font8"
Font16 = "/data/local/FONT/" + LanguageFontToken + "/font16"
Font24 = "/data/local/FONT/" + LanguageFontToken + "/font24"
Font30 = "/data/local/FONT/" + LanguageFontToken + "/font30"
Font42 = "/data/local/FONT/" + LanguageFontToken + "/font42"
FontFormal12 = "/data/local/FONT/" + LanguageFontToken + "/fontformal12"
FontFormal11 = "/data/local/FONT/" + LanguageFontToken + "/fontformal11"
FontFormal10 = "/data/local/FONT/" + LanguageFontToken + "/fontformal10"
FontExocet10 = "/data/local/FONT/" + LanguageFontToken + "/fontexocet10"
FontExocet8 = "/data/local/FONT/" + LanguageFontToken + "/fontexocet8"
FontSucker = "/data/local/FONT/" + LanguageFontToken + "/ReallyTheLastSucker"
FontRediculous = "/data/local/FONT/" + LanguageFontToken + "/fontridiculous"
ExpansionStringTable = "/data/local/lng/" + LanguageTableToken + "/expansionstring.tbl"
StringTable = "/data/local/lng/" + LanguageTableToken + "/string.tbl"
PatchStringTable = "/data/local/lng/" + LanguageTableToken + "/patchstring.tbl"
// --- UI ---
@ -165,16 +170,13 @@ const (
// --- Data ---
ExpansionStringTable = "/data/local/LNG/{LANG}/expansionstring.tbl"
StringTable = "/data/local/LNG/{LANG}/string.tbl"
PatchStringTable = "/data/local/LNG/{LANG}/patchstring.tbl"
LevelPreset = "/data/global/excel/LvlPrest.txt"
LevelType = "/data/global/excel/LvlTypes.txt"
ObjectType = "/data/global/excel/objtype.bin"
LevelWarp = "/data/global/excel/LvlWarp.bin"
LevelDetails = "/data/global/excel/Levels.txt"
LevelMaze = "/data/global/excel/LvlMaze.txt"
LevelSubstitutions = "/data/global/excel/LvlSub.txt"
LevelPreset = "/data/global/excel/LvlPrest.txt"
LevelType = "/data/global/excel/LvlTypes.txt"
ObjectType = "/data/global/excel/objtype.bin"
LevelWarp = "/data/global/excel/LvlWarp.bin"
LevelDetails = "/data/global/excel/Levels.txt"
LevelMaze = "/data/global/excel/LvlMaze.txt"
LevelSubstitutions = "/data/global/excel/LvlSub.txt"
ObjectDetails = "/data/global/excel/Objects.txt"
SoundSettings = "/data/global/excel/Sounds.txt"

View File

@ -33,7 +33,7 @@ func GetDictionaryEntryCount() int {
return len(lookupTable)
}
func LoadDictionary(dictionaryData []byte) {
func LoadTextDictionary(dictionaryData []byte) {
if lookupTable == nil {
lookupTable = make(map[string]string)
}

View File

@ -85,8 +85,7 @@ func LoadFile(filePath string) ([]byte, error) {
data, err := singleton.fileManager.loadFile(filePath)
if err != nil {
attemptedPath := singleton.fileManager.fixupFilePath(filePath)
log.Printf("error loading file %s (%v)", attemptedPath, err.Error())
log.Printf("error loading file %s (%v)", filePath, err.Error())
}
return data, err

View File

@ -4,6 +4,7 @@ import (
"strings"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2resource"
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2config"
)
@ -50,37 +51,22 @@ func (fm *fileManager) fileExists(filePath string) (bool, error) {
}
func (fm *fileManager) fixupFilePath(filePath string) string {
filePath = strings.ReplaceAll(filePath, "{LANG}", fm.config.Language)
if fm.config.Language != "ENG" {
filePath = strings.ReplaceAll(filePath, "expansionstring", "string")
}
// hack, no string table entries present in d2exp, set to english instead
if fm.config.Language == "RUS" {
filePath = strings.ReplaceAll(filePath, "RUS", "ENG")
}
// hack, POR doesn't have string.tbl
if fm.config.Language == "POR" {
toReplace := "POR/string.tbl"
fallback := "ENG/string.tbl"
filePath = strings.ReplaceAll(filePath, toReplace, fallback)
}
// hack, POL doesn't have string.tbl
if fm.config.Language == "POL" {
toReplace := "POL/string.tbl"
fallback := "ENG/string.tbl"
filePath = strings.ReplaceAll(filePath, toReplace, fallback)
}
// hack, CHI doesn't have the fonts in the mpq
// if strings.ToUpper(d2resource.LanguageCode) == "CHI" {
// filePath = strings.ReplaceAll(filePath, "{LANG_FONT}", fm.config.Language)
// } else {
filePath = strings.ReplaceAll(filePath, "{LANG_FONT}", "latin")
// }
filePath = fm.removeLocaleTokens(filePath)
filePath = strings.ToLower(filePath)
filePath = strings.ReplaceAll(filePath, `/`, "\\")
filePath = strings.TrimPrefix(filePath, "\\")
return filePath
}
func (fm *fileManager) removeLocaleTokens(filePath string) string {
tableToken := d2resource.LanguageTableToken
fontToken := d2resource.LanguageFontToken
filePath = strings.ReplaceAll(filePath, tableToken, fm.config.Language)
// fixme: not all languages==latin
filePath = strings.ReplaceAll(filePath, fontToken, "latin")
return filePath
}

View File

@ -477,7 +477,7 @@ func loadStrings() error {
return err
}
d2common.LoadDictionary(data)
d2common.LoadTextDictionary(data)
}
return nil