Skip to content

Commit

Permalink
增加Tooltip,优化显示,增加其它模板
Browse files Browse the repository at this point in the history
  • Loading branch information
CuteReimu committed Feb 24, 2022
1 parent 4f0e95c commit 52d76a2
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 27 deletions.
22 changes: 13 additions & 9 deletions autosplits.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,26 +123,26 @@ func addLine(initAll bool) {
Layout: HBox{},
MaxSize: Size{Width: 0, Height: 25},
Children: []Widget{
LineEdit{AssignTo: &line.name, MinSize: Size{Width: 200}},
LineEdit{AssignTo: &line.name, MinSize: Size{Width: 200}, ToolTipText: "片段名"},
ComboBox{AssignTo: &line.splitId, Editable: true, MinSize: Size{Width: 200},
Model: &splitIdModel{}, Value: splitDescriptions[0],
OnTextChanged: func() {
onSearchSplitId(initAll, line.splitId)
onSearchSplitId(initAll, line)
},
},
PushButton{Text: "✘", MaxSize: Size{Width: 25}, OnClicked: func() {
PushButton{Text: "✘", MaxSize: Size{Width: 25}, ToolTipText: "删除", OnClicked: func() {
if len(lines) > 1 {
removeLine(line)
}
}},
PushButton{Text: "↑+", MaxSize: Size{Width: 25},
PushButton{Text: "↑+", MaxSize: Size{Width: 25}, ToolTipText: "在上方增加一行",
OnClicked: func() {
idx := splitLinesView.Children().Index(line.line)
addLine(true)
moveLine(idx)
},
},
PushButton{Text: "↓+", MaxSize: Size{Width: 25},
PushButton{Text: "↓+", MaxSize: Size{Width: 25}, ToolTipText: "在下方增加一行",
OnClicked: func() {
idx := splitLinesView.Children().Index(line.line)
addLine(true)
Expand Down Expand Up @@ -197,7 +197,7 @@ func resetLines(count int) {
ComboBox{AssignTo: &line.splitId, Editable: true, MinSize: Size{Width: 200},
Model: &splitIdModel{}, Value: splitDescriptions[0],
OnTextChanged: func() {
onSearchSplitId(false, line.splitId)
onSearchSplitId(false, line)
},
},
PushButton{Text: "✘", MaxSize: Size{Width: 25}, OnClicked: func() {
Expand Down Expand Up @@ -257,9 +257,9 @@ func moveLine(index int) {
lines[index].splitTime = nil
}

func onSearchSplitId(initAll bool, splitIdComboBox *walk.ComboBox) {
s := splitIdComboBox.Text()
model := splitIdComboBox.Model().(*splitIdModel)
func onSearchSplitId(initAll bool, line *lineData) {
s := line.splitId.Text()
model := line.splitId.Model().(*splitIdModel)
if len(model.items) == 0 {
if initAll {
model.items = splitDescriptions
Expand All @@ -272,6 +272,10 @@ func onSearchSplitId(initAll bool, splitIdComboBox *walk.ComboBox) {
if len(s) > 0 {
for _, text := range model.items {
if text == s {
err := line.name.SetText(dropBrackets(text))
if err != nil {
walk.MsgBox(mainWindow, "错误", err.Error(), walk.MsgBoxIconError)
}
return
}
}
Expand Down
17 changes: 6 additions & 11 deletions categories.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,7 @@ func initCategories() {
walk.MsgBox(nil, "错误", err.Error(), walk.MsgBoxIconError)
panic(err)
}
for groupName, v := range categoryDirectoryCache {
if groupName != "Individual Level" && groupName != "Main" && groupName != "Category Extensions" {
continue
}
for _, v := range categoryDirectoryCache {
for _, info := range v {
buf, err := assets.ReadFile(path.Join(hkSplitMakerDir, "categories", info.FileName+".json"))
if err != nil {
Expand All @@ -66,7 +63,7 @@ func initCategories() {
continue
}
if j.EndingSplit.Icon != "HollowKnightBoss" && j.EndingSplit.Icon != "RadianceBoss" {
panic(info.FileName)
continue
}
count++
}
Expand All @@ -80,7 +77,7 @@ func initCategories() {
if foundPer {
continue
}
if count >= 2 && j.Ordered /*&& len(j.SplitIds) <= 50*/ {
if count >= 2 && j.Ordered {
categoriesCache[translate(info.DisplayName)] = j
}
}
Expand Down Expand Up @@ -206,11 +203,9 @@ func onSelectCategory() {
}

func dropBrackets(s string) string {
rs := []rune(s)
for i, r := range rs {
if r == '(' {
return string(rs[:i])
}
idx := strings.LastIndex(s, "(")
if idx > 0 {
return s[:idx]
}
return s
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ require (
)

require (
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect
golang.org/x/sys v0.0.0-20220224003255-dbe011f71a99 // indirect
gopkg.in/Knetic/govaluate.v3 v3.0.0 // indirect
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ github.com/lxn/win v0.0.0-20210218163916-a377121e959e/go.mod h1:KxxjdtRkfNoYDCUP
golang.org/x/sys v0.0.0-20201018230417-eeed37f84f13/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM=
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220224003255-dbe011f71a99 h1:Us899Z5PCfOrSgeCYWobI1/bSigAz9Rhf8+fz5Grkzc=
golang.org/x/sys v0.0.0-20220224003255-dbe011f71a99/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gopkg.in/Knetic/govaluate.v3 v3.0.0 h1:18mUyIt4ZlRlFZAAfVetz4/rzlJs9yhN+U02F4u1AOc=
gopkg.in/Knetic/govaluate.v3 v3.0.0/go.mod h1:csKLBORsPbafmSCGTEh3U7Ozmsuq8ZSIlKk1bcqph0E=
13 changes: 7 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ func main() {
Layout: HBox{},
Children: []Widget{
TextLabel{TextAlignment: AlignHFarVCenter, Text: "你可以"},
PushButton{Text: "打开已有的Splits文件", OnClicked: onClickLoadSplitFile},
TextLabel{TextAlignment: AlignHFarVCenter, Text: ",也可以使用现有的模板"},
PushButton{Text: "打开已有的lss文件", OnClicked: onClickLoadSplitFile},
TextLabel{TextAlignment: AlignHFarVCenter, Text: "或者把文件拖拽进来,也可以使用现有模板"},
ComboBox{
AssignTo: &categoriesComboBox,
Model: func() []string {
Expand Down Expand Up @@ -89,8 +89,9 @@ func main() {
Layout: HBox{},
Children: []Widget{
CheckBox{
AssignTo: &startTriggerCheckBox,
Text: "自动开始",
AssignTo: &startTriggerCheckBox,
Text: "自动开始",
ToolTipText: "对于全关的速通和万神殿某一门的速通,不要勾选",
OnClicked: func() {
startTriggerComboBox.SetEnabled(startTriggerCheckBox.Checked())
},
Expand Down Expand Up @@ -118,10 +119,10 @@ func main() {
Composite{
Layout: HBox{},
Children: []Widget{
LineEdit{AssignTo: &finalLine.name, Text: "空洞骑士"},
LineEdit{AssignTo: &finalLine.name, Text: "空洞骑士", ToolTipText: "片段名"},
ComboBox{AssignTo: &finalLine.splitId, Visible: false, Editable: true, Model: splitDescriptions, MaxSize: Size{Width: 200}, Value: splitDescriptions[0]},
ComboBox{AssignTo: &finalLine.splitId2, Editable: true, Model: []string{"空洞骑士", "辐光", "无上辐光"}, MaxSize: Size{Width: 200}, Value: "空洞骑士"},
CheckBox{AssignTo: &finalLine.endTrigger, Checked: true, Text: "以游戏结束停止计时",
CheckBox{AssignTo: &finalLine.endTrigger, Checked: true, Text: "以游戏结束停止计时", ToolTipText: "如果是以游戏结束或者万神殿某一门结束停止计时,不要勾选",
OnCheckedChanged: func() {
finalLine.splitId.SetVisible(!finalLine.endTrigger.Checked())
finalLine.splitId2.SetVisible(finalLine.endTrigger.Checked())
Expand Down

0 comments on commit 52d76a2

Please sign in to comment.