Clean project layout and fix release workflow
Some checks failed
build-windows-exe / build (push) Failing after 1m13s
Some checks failed
build-windows-exe / build (push) Failing after 1m13s
This commit is contained in:
@@ -33,20 +33,33 @@ type VrcLogConfig struct {
|
||||
}
|
||||
|
||||
type GUIConfig struct {
|
||||
TopMost bool
|
||||
FontSize int
|
||||
AutoUnmuteOnSelfLeave bool
|
||||
RefreshIntervalValue int
|
||||
RefreshIntervalUnit string
|
||||
HistoryRegex string
|
||||
HistoryFromDate string
|
||||
HistoryToDate string
|
||||
TopMost bool
|
||||
FontSize int
|
||||
AutoUnmuteOnSelfLeave bool
|
||||
RefreshIntervalValue int
|
||||
RefreshIntervalUnit string
|
||||
HistoryRegex string
|
||||
HistoryFromDate string
|
||||
HistoryToDate string
|
||||
HistoryExportDir string
|
||||
HistoryExportIncludeTime bool
|
||||
HistoryExportIncludeWorld bool
|
||||
HistoryExportIncludeJoinLeave bool
|
||||
HistoryExportCustomEnabled bool
|
||||
HistoryExportCustom string
|
||||
}
|
||||
|
||||
func Load(path string) (*Config, error) {
|
||||
cfg := &Config{
|
||||
OSC: OSCConfig{Host: "127.0.0.1", Port: 9001},
|
||||
GUI: GUIConfig{FontSize: 18, RefreshIntervalValue: 2, RefreshIntervalUnit: "sec"},
|
||||
GUI: GUIConfig{
|
||||
FontSize: 18,
|
||||
RefreshIntervalValue: 2,
|
||||
RefreshIntervalUnit: "sec",
|
||||
HistoryExportIncludeTime: true,
|
||||
HistoryExportIncludeWorld: true,
|
||||
HistoryExportIncludeJoinLeave: true,
|
||||
},
|
||||
}
|
||||
if path == "" {
|
||||
path = filepath.Join(common.RootDir(), "config", "config.toml")
|
||||
@@ -76,8 +89,7 @@ func Load(path string) (*Config, error) {
|
||||
continue
|
||||
}
|
||||
key := strings.TrimSpace(parts[0])
|
||||
val := strings.TrimSpace(parts[1])
|
||||
val = strings.Trim(val, "\"'")
|
||||
val := parseConfigValue(parts[1])
|
||||
switch section {
|
||||
case "osc":
|
||||
switch key {
|
||||
@@ -135,6 +147,18 @@ func Load(path string) (*Config, error) {
|
||||
cfg.GUI.HistoryFromDate = normalizeHistoryDate(val)
|
||||
case "history_to":
|
||||
cfg.GUI.HistoryToDate = normalizeHistoryDate(val)
|
||||
case "history_export_dir":
|
||||
cfg.GUI.HistoryExportDir = strings.TrimSpace(val)
|
||||
case "history_export_include_time":
|
||||
cfg.GUI.HistoryExportIncludeTime = parseBool(val, true)
|
||||
case "history_export_include_world":
|
||||
cfg.GUI.HistoryExportIncludeWorld = parseBool(val, true)
|
||||
case "history_export_include_join_leave":
|
||||
cfg.GUI.HistoryExportIncludeJoinLeave = parseBool(val, true)
|
||||
case "history_export_custom_enabled":
|
||||
cfg.GUI.HistoryExportCustomEnabled = parseBool(val, false)
|
||||
case "history_export_custom":
|
||||
cfg.GUI.HistoryExportCustom = strings.TrimSpace(val)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -144,6 +168,8 @@ func Load(path string) (*Config, error) {
|
||||
cfg.GUI.RefreshIntervalUnit = normalizeRefreshIntervalUnit(cfg.GUI.RefreshIntervalUnit)
|
||||
cfg.GUI.HistoryFromDate = normalizeHistoryDate(cfg.GUI.HistoryFromDate)
|
||||
cfg.GUI.HistoryToDate = normalizeHistoryDate(cfg.GUI.HistoryToDate)
|
||||
cfg.GUI.HistoryExportDir = strings.TrimSpace(cfg.GUI.HistoryExportDir)
|
||||
cfg.GUI.HistoryExportCustom = strings.TrimSpace(cfg.GUI.HistoryExportCustom)
|
||||
if cfg.VrcLog.GuestFile != "" {
|
||||
if !filepath.IsAbs(cfg.VrcLog.GuestFile) {
|
||||
cfg.VrcLog.GuestFile = filepath.Join(common.RootDir(), cfg.VrcLog.GuestFile)
|
||||
@@ -155,6 +181,17 @@ func Load(path string) (*Config, error) {
|
||||
return cfg, scanner.Err()
|
||||
}
|
||||
|
||||
func parseConfigValue(raw string) string {
|
||||
raw = strings.TrimSpace(raw)
|
||||
if raw == "" {
|
||||
return ""
|
||||
}
|
||||
if unquoted, err := strconv.Unquote(raw); err == nil {
|
||||
return strings.TrimSpace(unquoted)
|
||||
}
|
||||
return strings.TrimSpace(strings.Trim(raw, "\"'"))
|
||||
}
|
||||
|
||||
func SaveGUI(path string, gui GUIConfig) error {
|
||||
path = resolvePath(path)
|
||||
if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
|
||||
@@ -263,6 +300,12 @@ func appendGUISection(out *[]string, gui GUIConfig) {
|
||||
fmt.Sprintf("history_regex = %q", gui.HistoryRegex),
|
||||
fmt.Sprintf("history_from = %q", gui.HistoryFromDate),
|
||||
fmt.Sprintf("history_to = %q", gui.HistoryToDate),
|
||||
fmt.Sprintf("history_export_dir = %q", strings.TrimSpace(gui.HistoryExportDir)),
|
||||
fmt.Sprintf("history_export_include_time = %t", gui.HistoryExportIncludeTime),
|
||||
fmt.Sprintf("history_export_include_world = %t", gui.HistoryExportIncludeWorld),
|
||||
fmt.Sprintf("history_export_include_join_leave = %t", gui.HistoryExportIncludeJoinLeave),
|
||||
fmt.Sprintf("history_export_custom_enabled = %t", gui.HistoryExportCustomEnabled),
|
||||
fmt.Sprintf("history_export_custom = %q", strings.TrimSpace(gui.HistoryExportCustom)),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user