70 lines
1.4 KiB
Go
70 lines
1.4 KiB
Go
|
package config
|
||
|
|
||
|
import (
|
||
|
"os"
|
||
|
"path"
|
||
|
"runtime"
|
||
|
)
|
||
|
|
||
|
type FileConfig struct {
|
||
|
Path string
|
||
|
Name string
|
||
|
Type string
|
||
|
}
|
||
|
|
||
|
func GetDefaultConfigPath() string {
|
||
|
var filePath string
|
||
|
switch os_name := runtime.GOOS; os_name {
|
||
|
case "windows":
|
||
|
appData := os.Getenv("APPDATA")
|
||
|
filePath = path.Join(appData, "hudly", ".conf")
|
||
|
case "darwin":
|
||
|
homePath := os.Getenv("HOME")
|
||
|
filePath = path.Join(homePath, "Library", "Application Support", "hudly", ".conf")
|
||
|
case "linux":
|
||
|
homePath := os.Getenv("HOME")
|
||
|
filePath = path.Join(homePath, ".config", "hudly", ".conf")
|
||
|
default:
|
||
|
panic("unknown operating system")
|
||
|
}
|
||
|
return filePath
|
||
|
}
|
||
|
|
||
|
type Config struct {
|
||
|
ConfigVersion int
|
||
|
PlayerName string
|
||
|
PlayerUUID string
|
||
|
AltNames []string
|
||
|
AltUUIDs []string
|
||
|
AppFeaturesConfig AppFeaturesConfig
|
||
|
}
|
||
|
|
||
|
type AppFeaturesConfig struct {
|
||
|
CheckGuildChat bool
|
||
|
CheckOfficerChat bool
|
||
|
CheckPartyChat bool
|
||
|
CheckPartyList bool
|
||
|
CheckLobbyMessages bool
|
||
|
CheckQueueMessages bool
|
||
|
CheckInGameMessages bool
|
||
|
}
|
||
|
|
||
|
func GetDefaultConfig() *Config {
|
||
|
return &Config{
|
||
|
ConfigVersion: 1,
|
||
|
PlayerName: "",
|
||
|
PlayerUUID: "",
|
||
|
AltNames: []string{},
|
||
|
AltUUIDs: []string{},
|
||
|
AppFeaturesConfig: AppFeaturesConfig{
|
||
|
CheckGuildChat: true,
|
||
|
CheckOfficerChat: false,
|
||
|
CheckPartyChat: true,
|
||
|
CheckPartyList: true,
|
||
|
CheckLobbyMessages: false,
|
||
|
CheckQueueMessages: true,
|
||
|
CheckInGameMessages: true,
|
||
|
},
|
||
|
}
|
||
|
}
|