Skip to content

Commit

Permalink
新增了“LiveSplit一键修复”的功能
Browse files Browse the repository at this point in the history
  • Loading branch information
CuteReimu committed Jul 28, 2022
1 parent 89f515f commit a46dd33
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ jobs:
with:
go-version: 1.17

- name: Download LiveSplit Files
run: |
curl -O https://raw.githubusercontent.com/LiveSplit/LiveSplit.AutoSplitters/master/LiveSplit.AutoSplitters.xml
curl -O https://raw.githubusercontent.com/ShootMe/LiveSplit.HollowKnight/master/Components/LiveSplit.HollowKnight.dll
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.idea/
*.xml

# Binaries for programs and plugins
*.exe
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@

8. 打开LiveSplit -> 右键 -> Open Splits -> From File... ,选择刚刚保存的文件即可。

## 编译说明

**在Windows下可直接运行`build.bat`编译。**

如果想要自己使用`go build`进行编译,建议参考`build.bat`

## 如何优化翻译

请不要直接在这个repo修改`translate.tsv`文件,请前往[CuteReimu/hk-split-maker](https://github.com/CuteReimu/hk-split-maker)修改,修改后会自动同步到这里。
Expand Down
2 changes: 2 additions & 0 deletions build.bat
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
@echo off
bitsadmin /transfer n https://raw.githubusercontent.com/LiveSplit/LiveSplit.AutoSplitters/master/LiveSplit.AutoSplitters.xml %~dp0\LiveSplit.AutoSplitters.xml
bitsadmin /transfer n https://raw.githubusercontent.com/ShootMe/LiveSplit.HollowKnight/master/Components/LiveSplit.HollowKnight.dll %~dp0\LiveSplit.HollowKnight.dll
go build -ldflags "-s -w -H=windowsgui" -o hksplitmaker.exe github.com/CuteReimu/hksplitmaker
49 changes: 49 additions & 0 deletions livesplit.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package main

import (
_ "embed"
"github.com/lxn/walk"
"github.com/lxn/win"
"os"
"path/filepath"
)

//go:embed LiveSplit.AutoSplitters.xml
var liveSplitAutoSplittersXml []byte

//go:embed LiveSplit.HollowKnight.dll
var liveSplitHollowKnightDll []byte

func fixLiveSplit() {
walk.MsgBox(mainWindow, "提示", "请选择LiveSplit.exe", walk.MsgBoxIconInformation)
dlg := new(walk.FileDialog)
dlg.Title = "请选择LiveSplit.exe"
dlg.Filter = "LiveSplit.exe|LiveSplit.exe"
dlg.Flags = win.OFN_FILEMUSTEXIST
if ok, err := dlg.ShowOpen(mainWindow); err != nil {
walk.MsgBox(mainWindow, "内部错误", err.Error(), walk.MsgBoxIconError)
} else if ok {
file := dlg.FilePath
if filepath.Base(file) != "LiveSplit.exe" {
walk.MsgBox(mainWindow, "错误", "您选择的并不是LiveSplit.exe", walk.MsgBoxIconError)
return
}
dir := filepath.Dir(file)
_, err := os.Stat(filepath.Join(dir, "Components"))
if err != nil {
walk.MsgBox(mainWindow, "错误", "计时器目录似乎有些问题,无法一键修复", walk.MsgBoxIconError)
return
}
err = os.WriteFile(filepath.Join(dir, "LiveSplit.AutoSplitters.xml"), liveSplitAutoSplittersXml, 0644)
if err != nil {
walk.MsgBox(mainWindow, "内部错误", err.Error(), walk.MsgBoxIconError)
return
}
err = os.WriteFile(filepath.Join(dir, "Components", "LiveSplit.HollowKnight.dll"), liveSplitHollowKnightDll, 0644)
if err != nil {
walk.MsgBox(mainWindow, "内部错误", err.Error(), walk.MsgBoxIconError)
return
}
walk.MsgBox(mainWindow, "提示", "修复成功,建议使用管理员模式打开计时器", walk.MsgBoxIconInformation)
}
}
4 changes: 4 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ func main() {
TextAlignment: AlignHFarVCenter,
Text: "Auto Splitter Version: 3.1.5.0",
},
PushButton{
Text: "LiveSplit一键修复",
OnClicked: fixLiveSplit,
},
},
},
ScrollView{
Expand Down

0 comments on commit a46dd33

Please sign in to comment.