mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-09-01 08:54:20 -04: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",
|
"d2sfx.mpq",
|
||||||
"d2video.mpq",
|
"d2video.mpq",
|
||||||
"d2speech.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"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/mitchellh/go-homedir"
|
"github.com/mitchellh/go-homedir"
|
||||||
@ -22,6 +23,7 @@ type Configuration struct {
|
|||||||
VsyncEnabled bool
|
VsyncEnabled bool
|
||||||
MpqPath string
|
MpqPath string
|
||||||
MpqLoadOrder []string
|
MpqLoadOrder []string
|
||||||
|
MpqMacLoadOrder []string
|
||||||
SfxVolume float64
|
SfxVolume float64
|
||||||
BgmVolume float64
|
BgmVolume float64
|
||||||
}
|
}
|
||||||
@ -39,17 +41,26 @@ func LoadConfiguration() *Configuration {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
// Path fixup for wine-installed diablo 2 in linux
|
if runtime.GOOS == "darwin" {
|
||||||
if config.MpqPath[0] != '/' {
|
if config.MpqPath[0] != '/' {
|
||||||
if _, err := os.Stat(config.MpqPath); os.IsNotExist(err) {
|
config.MpqPath = "/Applications/Diablo II/"
|
||||||
homeDir, _ := homedir.Dir()
|
}
|
||||||
newPath := strings.ReplaceAll(config.MpqPath, `C:\`, homeDir+"/.wine/drive_c/")
|
config.MpqLoadOrder = config.MpqMacLoadOrder
|
||||||
newPath = strings.ReplaceAll(newPath, "C:/", homeDir+"/.wine/drive_c/")
|
} else {
|
||||||
newPath = strings.ReplaceAll(newPath, `\`, "/")
|
// Path fixup for wine-installed diablo 2 in linux
|
||||||
if _, err := os.Stat(newPath); !os.IsNotExist(err) {
|
if config.MpqPath[0] != '/' {
|
||||||
config.MpqPath = newPath
|
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
|
return &config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user