mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2025-02-07 00:56:51 -05:00
Add OSX support for path fixups. (#251)
This commit is contained in:
parent
a194913609
commit
4eeac5c1d9
15
config.json
15
config.json
@ -20,5 +20,18 @@
|
||||
"d2sfx.mpq",
|
||||
"d2video.mpq",
|
||||
"d2speech.mpq"
|
||||
]
|
||||
],
|
||||
"MpqMacLoadOrder": [
|
||||
"Diablo II Patch",
|
||||
"Diablo II Expansion Data",
|
||||
"Diablo II Expansion Movies",
|
||||
"Diablo II Expansion Music",
|
||||
"Diablo II Expansion Speech",
|
||||
"Diablo II Game Data",
|
||||
"Diablo II Graphics",
|
||||
"Diablo II Movies",
|
||||
"Diablo II Music",
|
||||
"Diablo II Sounds",
|
||||
"Diablo II Speech"
|
||||
]
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
"log"
|
||||
"os"
|
||||
"path"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/mitchellh/go-homedir"
|
||||
@ -22,6 +23,7 @@ type Configuration struct {
|
||||
VsyncEnabled bool
|
||||
MpqPath string
|
||||
MpqLoadOrder []string
|
||||
MpqMacLoadOrder []string
|
||||
SfxVolume float64
|
||||
BgmVolume float64
|
||||
}
|
||||
@ -39,17 +41,26 @@ func LoadConfiguration() *Configuration {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
// Path fixup for wine-installed diablo 2 in linux
|
||||
if config.MpqPath[0] != '/' {
|
||||
if _, err := os.Stat(config.MpqPath); os.IsNotExist(err) {
|
||||
homeDir, _ := homedir.Dir()
|
||||
newPath := strings.ReplaceAll(config.MpqPath, `C:\`, homeDir+"/.wine/drive_c/")
|
||||
newPath = strings.ReplaceAll(newPath, "C:/", homeDir+"/.wine/drive_c/")
|
||||
newPath = strings.ReplaceAll(newPath, `\`, "/")
|
||||
if _, err := os.Stat(newPath); !os.IsNotExist(err) {
|
||||
config.MpqPath = newPath
|
||||
if runtime.GOOS == "darwin" {
|
||||
if config.MpqPath[0] != '/' {
|
||||
config.MpqPath = "/Applications/Diablo II/"
|
||||
}
|
||||
config.MpqLoadOrder = config.MpqMacLoadOrder
|
||||
} else {
|
||||
// Path fixup for wine-installed diablo 2 in linux
|
||||
if config.MpqPath[0] != '/' {
|
||||
if _, err := os.Stat(config.MpqPath); os.IsNotExist(err) {
|
||||
homeDir, _ := homedir.Dir()
|
||||
newPath := strings.ReplaceAll(config.MpqPath, `C:\`, homeDir+"/.wine/drive_c/")
|
||||
newPath = strings.ReplaceAll(newPath, "C:/", homeDir+"/.wine/drive_c/")
|
||||
newPath = strings.ReplaceAll(newPath, `\`, "/")
|
||||
if _, err := os.Stat(newPath); !os.IsNotExist(err) {
|
||||
config.MpqPath = newPath
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return &config
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user