-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsplits.go
More file actions
89 lines (83 loc) · 2.22 KB
/
Copy pathsplits.go
File metadata and controls
89 lines (83 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package main
import (
"bufio"
"bytes"
_ "embed"
"errors"
"io"
"os"
"regexp"
"github.com/wailsapp/wails/v2/pkg/runtime"
)
//go:embed hk-split-maker/src/asset/hollowknight/splits.txt
var splitsFileBuf []byte
var splitsDictIdToDescriptions = make(map[string]string)
func initSplitsFile() error {
rd := bufio.NewReader(bytes.NewReader(splitsFileBuf))
re, err := regexp.Compile(`\[Description\("(.*?)"\)\s*,\s*ToolTip\("(.*?)"\)]`)
if err != nil {
return err
}
var isNameLine bool
line, isPrefix, err := rd.ReadLine()
var result []string
for ; err == nil; line, isPrefix, err = rd.ReadLine() {
if isPrefix {
err = errors.New("尚未支持这种文件,尽情期待更新")
break
}
line = bytes.Trim(bytes.TrimSpace(line), ",")
if len(line) == 0 {
continue
}
if isNameLine {
if len(result) == 3 {
description := translate(result[1])
splitsDictIdToDescriptions[string(line)] = description
isNameLine = false
} else {
err = errors.New("splits.txt文件格式错误")
break
}
} else {
result = re.FindStringSubmatch(string(line))
if result == nil {
err = errors.New("splits.txt文件格式错误")
break
}
isNameLine = true
}
}
if errors.Is(err, io.EOF) {
return nil
}
return err
}
//go:embed blank-colo-save.dat
var blankColoSave []byte
func (a *App) coloNotice(...any) {
if v, err := runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{
Type: runtime.QuestionDialog,
Title: "提示",
Message: "愚人斗兽场相关的Splits需要专用的存档才能正常使用。是否要生成专用存档?",
Buttons: []string{"Yes", "No"},
DefaultButton: "Yes",
CancelButton: "No",
}); err != nil {
runtime.LogError(a.ctx, err.Error())
} else if v == "Yes" {
if err = os.WriteFile("user4.dat", blankColoSave, 0644); err != nil {
_, _ = runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{
Type: runtime.ErrorDialog,
Title: "错误",
Message: err.Error(),
})
} else {
_, _ = runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{
Type: runtime.InfoDialog,
Title: "提示",
Message: "已成功生成 user4.dat ,请自行放入空洞骑士的存档目录",
})
}
}
}