diff --git a/bin/json/game_rdtask.json b/bin/json/game_rdtask.json index 6850f6143..566790c03 100644 --- a/bin/json/game_rdtask.json +++ b/bin/json/game_rdtask.json @@ -94,7 +94,7 @@ 101 ], "sidequest": [ - 2002, + 2022, 2004 ] }, diff --git a/bin/json/game_rdtaskchoose.json b/bin/json/game_rdtaskchoose.json index 88efa335c..e2f313556 100644 --- a/bin/json/game_rdtaskchoose.json +++ b/bin/json/game_rdtaskchoose.json @@ -3,6 +3,11 @@ "id": 10001, "num": 1, "preTid": 0, + "Entity": [], + "EntityChange": [], + "EntityStateChange": [], + "EntityInteractive": [], + "gotoLevel": 0, "needItem": [ 0 ], @@ -12,6 +17,11 @@ "id": 10002, "num": 2, "preTid": 104, + "Entity": [], + "EntityChange": [], + "EntityStateChange": [], + "EntityInteractive": [], + "gotoLevel": 0, "needItem": [ 0 ], @@ -21,6 +31,11 @@ "id": 10003, "num": 1, "preTid": 0, + "Entity": [], + "EntityChange": [], + "EntityStateChange": [], + "EntityInteractive": [], + "gotoLevel": 0, "needItem": [ 0 ], @@ -30,6 +45,11 @@ "id": 10004, "num": 1, "preTid": 0, + "Entity": [], + "EntityChange": [], + "EntityStateChange": [], + "EntityInteractive": [], + "gotoLevel": 0, "needItem": [ 0 ], @@ -39,6 +59,11 @@ "id": 10005, "num": 2, "preTid": 105, + "Entity": [], + "EntityChange": [], + "EntityStateChange": [], + "EntityInteractive": [], + "gotoLevel": 0, "needItem": [ 0 ], @@ -48,6 +73,11 @@ "id": 10006, "num": 1, "preTid": 105, + "Entity": [], + "EntityChange": [], + "EntityStateChange": [], + "EntityInteractive": [], + "gotoLevel": 0, "needItem": [ 0 ], @@ -57,6 +87,11 @@ "id": 10007, "num": 2, "preTid": 0, + "Entity": [], + "EntityChange": [], + "EntityStateChange": [], + "EntityInteractive": [], + "gotoLevel": 0, "needItem": [ 0 ], @@ -66,6 +101,11 @@ "id": 10008, "num": 3, "preTid": 0, + "Entity": [], + "EntityChange": [], + "EntityStateChange": [], + "EntityInteractive": [], + "gotoLevel": 0, "needItem": [ 0 ], @@ -75,6 +115,15 @@ "id": 10009, "num": 1, "preTid": 0, + "Entity": [ + "Earth" + ], + "EntityChange": [], + "EntityStateChange": [], + "EntityInteractive": [ + false + ], + "gotoLevel": 0, "needItem": [ 0 ], @@ -84,6 +133,15 @@ "id": 100010, "num": 2, "preTid": 105, + "Entity": [ + "Earth" + ], + "EntityChange": [], + "EntityStateChange": [], + "EntityInteractive": [ + false + ], + "gotoLevel": 0, "needItem": [ 0 ], @@ -93,6 +151,15 @@ "id": 100011, "num": 1, "preTid": 0, + "Entity": [ + "Earth" + ], + "EntityChange": [], + "EntityStateChange": [], + "EntityInteractive": [ + false + ], + "gotoLevel": 101, "needItem": [ 0 ], @@ -102,6 +169,15 @@ "id": 100012, "num": 2, "preTid": 0, + "Entity": [ + "Earth" + ], + "EntityChange": [], + "EntityStateChange": [], + "EntityInteractive": [ + false + ], + "gotoLevel": 0, "needItem": [ 0 ], @@ -111,6 +187,13 @@ "id": 20001, "num": 1, "preTid": 104, + "Entity": [ + "Earth" + ], + "EntityChange": [], + "EntityStateChange": [], + "EntityInteractive": [], + "gotoLevel": 0, "needItem": [ 0 ], @@ -120,6 +203,13 @@ "id": 20002, "num": 2, "preTid": 0, + "Entity": [ + "Earth" + ], + "EntityChange": [], + "EntityStateChange": [], + "EntityInteractive": [], + "gotoLevel": 0, "needItem": [ 0 ], @@ -129,6 +219,13 @@ "id": 20003, "num": 1, "preTid": 0, + "Entity": [ + "Earth" + ], + "EntityChange": [], + "EntityStateChange": [], + "EntityInteractive": [], + "gotoLevel": 0, "needItem": [ 0 ], @@ -138,6 +235,13 @@ "id": 20004, "num": 1, "preTid": 0, + "Entity": [ + "Earth" + ], + "EntityChange": [], + "EntityStateChange": [], + "EntityInteractive": [], + "gotoLevel": 0, "needItem": [ 0 ], @@ -147,6 +251,13 @@ "id": 20005, "num": 1, "preTid": 0, + "Entity": [ + "Earth" + ], + "EntityChange": [], + "EntityStateChange": [], + "EntityInteractive": [], + "gotoLevel": 0, "needItem": [ 0 ], @@ -156,6 +267,13 @@ "id": 20006, "num": 1, "preTid": 0, + "Entity": [ + "Earth" + ], + "EntityChange": [], + "EntityStateChange": [], + "EntityInteractive": [], + "gotoLevel": 0, "needItem": [ 0 ], @@ -165,6 +283,13 @@ "id": 20007, "num": 1, "preTid": 0, + "Entity": [ + "Earth" + ], + "EntityChange": [], + "EntityStateChange": [], + "EntityInteractive": [], + "gotoLevel": 0, "needItem": [ 0 ], @@ -174,6 +299,13 @@ "id": 20008, "num": 1, "preTid": 0, + "Entity": [ + "Earth" + ], + "EntityChange": [], + "EntityStateChange": [], + "EntityInteractive": [], + "gotoLevel": 0, "needItem": [ 0 ], @@ -183,6 +315,13 @@ "id": 20009, "num": 2, "preTid": 0, + "Entity": [ + "Earth" + ], + "EntityChange": [], + "EntityStateChange": [], + "EntityInteractive": [], + "gotoLevel": 0, "needItem": [ 0 ], @@ -192,6 +331,13 @@ "id": 200010, "num": 2, "preTid": 0, + "Entity": [ + "Earth" + ], + "EntityChange": [], + "EntityStateChange": [], + "EntityInteractive": [], + "gotoLevel": 0, "needItem": [ 0 ], @@ -201,6 +347,13 @@ "id": 200011, "num": 2, "preTid": 0, + "Entity": [ + "Earth" + ], + "EntityChange": [], + "EntityStateChange": [], + "EntityInteractive": [], + "gotoLevel": 0, "needItem": [ 0 ], @@ -210,6 +363,13 @@ "id": 200012, "num": 2, "preTid": 0, + "Entity": [ + "Earth" + ], + "EntityChange": [], + "EntityStateChange": [], + "EntityInteractive": [], + "gotoLevel": 0, "needItem": [ 0 ], @@ -219,6 +379,13 @@ "id": 200013, "num": 1, "preTid": 0, + "Entity": [ + "Earth" + ], + "EntityChange": [], + "EntityStateChange": [], + "EntityInteractive": [], + "gotoLevel": 0, "needItem": [ 0 ], @@ -228,6 +395,13 @@ "id": 200014, "num": 1, "preTid": 0, + "Entity": [ + "Earth" + ], + "EntityChange": [], + "EntityStateChange": [], + "EntityInteractive": [], + "gotoLevel": 0, "needItem": [ 0 ], @@ -237,6 +411,13 @@ "id": 200015, "num": 1, "preTid": 0, + "Entity": [ + "Earth" + ], + "EntityChange": [], + "EntityStateChange": [], + "EntityInteractive": [], + "gotoLevel": 0, "needItem": [ 0 ], @@ -246,6 +427,13 @@ "id": 200016, "num": 1, "preTid": 0, + "Entity": [ + "Earth" + ], + "EntityChange": [], + "EntityStateChange": [], + "EntityInteractive": [], + "gotoLevel": 0, "needItem": [ 0 ], diff --git a/bin/json/game_rdtaskside.json b/bin/json/game_rdtaskside.json index 888202ddc..a6d2421a9 100644 --- a/bin/json/game_rdtaskside.json +++ b/bin/json/game_rdtaskside.json @@ -18,6 +18,7 @@ "modelstate": 0, "popup": "", "special": "", + "enableAi": false, "boxreplace": "", "timeline": "", "chooseId": [ @@ -80,6 +81,7 @@ "modelstate": 0, "popup": "", "special": "", + "enableAi": false, "boxreplace": "", "timeline": "", "chooseId": [], @@ -108,6 +110,7 @@ "modelstate": 0, "popup": "", "special": "", + "enableAi": false, "boxreplace": "", "timeline": "", "chooseId": [ @@ -139,6 +142,7 @@ "modelstate": 0, "popup": "", "special": "", + "enableAi": false, "boxreplace": "", "timeline": "", "chooseId": [ @@ -171,6 +175,7 @@ "modelstate": 0, "popup": "", "special": "", + "enableAi": false, "boxreplace": "", "timeline": "", "chooseId": [], @@ -199,6 +204,7 @@ "modelstate": 0, "popup": "", "special": "", + "enableAi": false, "boxreplace": "", "timeline": "", "chooseId": [ @@ -230,6 +236,7 @@ "modelstate": 0, "popup": "", "special": "", + "enableAi": false, "boxreplace": "", "timeline": "", "chooseId": [ @@ -262,6 +269,7 @@ "modelstate": 0, "popup": "", "special": "", + "enableAi": false, "boxreplace": "", "timeline": "", "chooseId": [], @@ -276,7 +284,7 @@ "objType": 1, "location": "middle", "point": "model_02", - "storyBegin": 201, + "storyBegin": 301, "Entity": [ "Earth" ], @@ -294,6 +302,7 @@ "modelstate": 0, "popup": "", "special": "", + "enableAi": true, "boxreplace": "", "timeline": "", "chooseId": [ @@ -318,7 +327,7 @@ "Reward": [ { "a": "hero", - "t": "25004", + "t": "44006", "n": 1 } ] @@ -332,7 +341,7 @@ "objType": 1, "location": "middle", "point": "model_02", - "storyBegin": 202, + "storyBegin": 305, "Entity": [ "Earth" ], @@ -350,6 +359,7 @@ "modelstate": 0, "popup": "", "special": "", + "enableAi": false, "boxreplace": "", "timeline": "", "chooseId": [ @@ -366,7 +376,7 @@ "objType": 1, "location": "middle", "point": "model_03", - "storyBegin": 203, + "storyBegin": 303, "Entity": [ "Earth" ], @@ -384,6 +394,7 @@ "modelstate": 0, "popup": "", "special": "", + "enableAi": false, "boxreplace": "", "timeline": "", "chooseId": [], @@ -398,7 +409,7 @@ "objType": 1, "location": "middle", "point": "model_03", - "storyBegin": 203, + "storyBegin": 302, "Entity": [ "Earth" ], @@ -416,6 +427,7 @@ "modelstate": 0, "popup": "", "special": "", + "enableAi": false, "boxreplace": "", "timeline": "", "chooseId": [], @@ -430,7 +442,7 @@ "objType": 2, "location": "right", "point": "icon_05", - "storyBegin": 204, + "storyBegin": 306, "Entity": [ "Earth" ], @@ -448,6 +460,7 @@ "modelstate": 0, "popup": "", "special": "", + "enableAi": false, "boxreplace": "", "timeline": "", "chooseId": [ @@ -475,7 +488,7 @@ "objType": 2, "location": "right", "point": "icon_05", - "storyBegin": 207, + "storyBegin": 307, "Entity": [ "Earth" ], @@ -493,6 +506,7 @@ "modelstate": 0, "popup": "", "special": "", + "enableAi": false, "boxreplace": "", "timeline": "", "chooseId": [ @@ -521,12 +535,13 @@ "modelaction": "Enter", "rotation": { "x": 0, - "y": -90, + "y": 90, "z": 0 }, "modelstate": 0, "popup": "", "special": "", + "enableAi": false, "boxreplace": "", "timeline": "", "chooseId": [], @@ -541,7 +556,7 @@ "objType": 1, "location": "middle", "point": "model_02", - "storyBegin": 218, + "storyBegin": 308, "Entity": [ "Earth" ], @@ -553,12 +568,13 @@ "modelaction": "Enter", "rotation": { "x": 0, - "y": 90, + "y": -90, "z": 0 }, "modelstate": 0, "popup": "", "special": "", + "enableAi": false, "boxreplace": "", "timeline": "", "chooseId": [ @@ -594,11 +610,12 @@ "modelstate": 0, "popup": "", "special": "", + "enableAi": false, "boxreplace": "", "timeline": "", "chooseId": [], "endTid": -1, - "storyEnd": 0, + "storyEnd": 227, "reward": [], "nextTid": 100208, "CD": 0 @@ -620,12 +637,13 @@ "modelaction": "", "rotation": { "x": 0, - "y": -90, + "y": 90, "z": 0 }, "modelstate": 0, "popup": "", "special": "", + "enableAi": false, "boxreplace": "", "timeline": "", "chooseId": [], @@ -652,12 +670,13 @@ "modelaction": "", "rotation": { "x": 0, - "y": 90, + "y": -90, "z": 0 }, "modelstate": 0, "popup": "", "special": "", + "enableAi": false, "boxreplace": "", "timeline": "", "chooseId": [], @@ -690,6 +709,7 @@ "modelstate": 0, "popup": "", "special": "", + "enableAi": false, "boxreplace": "", "timeline": "", "chooseId": [ @@ -725,6 +745,7 @@ "modelstate": 0, "popup": "", "special": "", + "enableAi": false, "boxreplace": "", "timeline": "", "chooseId": [ @@ -760,6 +781,7 @@ "modelstate": 0, "popup": "", "special": "", + "enableAi": false, "boxreplace": "", "timeline": "", "chooseId": [ @@ -795,6 +817,7 @@ "modelstate": 0, "popup": "", "special": "", + "enableAi": false, "boxreplace": "", "timeline": "", "chooseId": [ @@ -829,6 +852,7 @@ "modelstate": 0, "popup": "", "special": "", + "enableAi": false, "boxreplace": "", "timeline": "", "chooseId": [ @@ -863,6 +887,7 @@ "modelstate": 0, "popup": "", "special": "", + "enableAi": false, "boxreplace": "", "timeline": "", "chooseId": [], @@ -897,6 +922,7 @@ "modelstate": 0, "popup": "", "special": "", + "enableAi": false, "boxreplace": "", "timeline": "", "chooseId": [], @@ -931,6 +957,7 @@ "modelstate": 0, "popup": "", "special": "", + "enableAi": false, "boxreplace": "", "timeline": "", "chooseId": [ @@ -968,6 +995,7 @@ "modelstate": 0, "popup": "", "special": "", + "enableAi": false, "boxreplace": "", "timeline": "", "chooseId": [ @@ -1005,6 +1033,7 @@ "modelstate": 0, "popup": "", "special": "", + "enableAi": false, "boxreplace": "", "timeline": "", "chooseId": [], @@ -1013,5 +1042,40 @@ "reward": [], "nextTid": 100215, "CD": 0 + }, + { + "id": 2022, + "objType": 1, + "location": "middle", + "point": "model_02", + "storyBegin": 304, + "Entity": [ + "Earth" + ], + "EntityChange": [], + "EntityStateChange": [], + "EntityInteractive": [ + false + ], + "modelaction": "", + "rotation": { + "x": 0, + "y": -180, + "z": 0 + }, + "modelstate": 0, + "popup": "", + "special": "", + "enableAi": false, + "boxreplace": "", + "timeline": "", + "chooseId": [ + 20003 + ], + "endTid": -1, + "storyEnd": 0, + "reward": [], + "nextTid": 100204, + "CD": 0 } ] \ No newline at end of file diff --git a/cmd/v2/ui/app_monitor.go b/cmd/v2/ui/app_monitor.go index 5e7c67150..c840a1d6e 100644 --- a/cmd/v2/ui/app_monitor.go +++ b/cmd/v2/ui/app_monitor.go @@ -88,6 +88,7 @@ func (this *appMonitor) reloadMonitorData() { d := this.monitorData.AsInterfaceArray() this.monitorBinding.Set(d) } + this.monitorList.ScrollToBottom() } func (this *appMonitor) createMonitorList() { diff --git a/cmd/v2/ui/list.go b/cmd/v2/ui/list.go new file mode 100644 index 000000000..722600133 --- /dev/null +++ b/cmd/v2/ui/list.go @@ -0,0 +1,72 @@ +package ui + +import "strings" + +var replacer *strings.Replacer + +func init() { + trimChars := "0123456789-()/½⅓¼⅕⅙⅐⅛⅑⅔⅖¾⅗⅘" + tcs := make([]string, len(trimChars)*2) + for i, c := range trimChars { + tcs[i*2] = string(c) + tcs[i*2+1] = "" + } + replacer = strings.NewReplacer(tcs...) +} + +type List struct { + Name string `json:"name"` + Group string `json:"group"` + Items []Item `json:"items"` + // ID is the Mealie API reference for the list. + ID int `json:"id"` +} + +var sortableText map[string]string = map[string]string{} + +func (l List) Len() int { return len(l.Items) } +func (l List) Swap(i, j int) { l.Items[i], l.Items[j] = l.Items[j], l.Items[i] } + +func (l List) Less(i, j int) bool { + var ok bool + var it, jt string + li := l.Items[i] + lit := li.Text + if it, ok = sortableText[lit]; !ok { + it = replacer.Replace(strings.ToUpper(lit)) + it = strings.TrimLeft(it, " ") + sortableText[lit] = it + } + lj := l.Items[j] + ljt := lj.Text + if jt, ok = sortableText[ljt]; !ok { + jt = replacer.Replace(strings.ToUpper(ljt)) + jt = strings.TrimLeft(jt, " ") + sortableText[ljt] = jt + } + if !li.Checked { + if lj.Checked { + return true + } + return it < jt + } + if !lj.Checked { + return false + } + return it < jt +} + +type Item struct { + Title string `json:"title"` + Text string `json:"text"` + Quantity int `json:"quantity"` + Checked bool `json:"checked"` +} + +func NewList(name string) List { + return List{ + ID: -1, + Name: name, + Items: []Item{}, + } +} diff --git a/cmd/v2/ui/tool_gen.go b/cmd/v2/ui/tool_gen.go index 2f53123a7..104f4c030 100644 --- a/cmd/v2/ui/tool_gen.go +++ b/cmd/v2/ui/tool_gen.go @@ -12,10 +12,11 @@ import ( "os/exec" "path/filepath" "runtime" + "sort" + "strings" "fyne.io/fyne/v2" "fyne.io/fyne/v2/container" - "fyne.io/fyne/v2/data/binding" "fyne.io/fyne/v2/dialog" "fyne.io/fyne/v2/layout" "fyne.io/fyne/v2/storage" @@ -27,11 +28,9 @@ import ( type appGen struct { appAdapter - obs observer.Observer - goList *fileList - jsonList *fileList - goChkList *widget.List - jsonChkList *widget.List + obs observer.Observer + goList *fileList + jsonList *fileList } func (this *appGen) LazyInit(obs observer.Observer) error { @@ -169,19 +168,20 @@ func (this *appGen) LazyInit(obs observer.Observer) error { this.goList.titleLabel = widget.NewLabel("Go文件") this.goList.titleLabel.Hide() // 复选列表 - this.goChkList = this.goList.createList() + this.goList.itemList = this.goList.createList() // 覆盖 -go - go_allSelBtn := &widget.Button{Icon: theme.CheckButtonCheckedIcon()} - go_allCancelBtn := &widget.Button{Icon: theme.CheckButtonIcon()} + go_allSelBtn := &widget.Button{Icon: theme.CheckButtonIcon()} + go_allCancelBtn := &widget.Button{Icon: theme.CheckButtonCheckedIcon()} go_overrideBtn := &widget.Button{Text: "覆盖", Icon: theme.ConfirmIcon()} go_overrideBtn.Hide() go_allSelBtn.Hide() + + // 覆盖 go_overrideBtn.OnTapped = func() { go_overrideBtn.Disable() defer func() { go_overrideBtn.Enable() - // _ = common.RemoveContents(filepath.Join(tmpDir.Text, "go")) }() for _, v := range this.goList.selItemIds { // logrus.WithField("path1", filepath.Join(tmpDir.Text, "go", v)).Debug("copy go") @@ -191,18 +191,49 @@ func (this *appGen) LazyInit(obs observer.Observer) error { if err != nil { logrus.Error(err) } + this.goList.deleteItem(v) } } + //取消checked + go_allCancelBtn.OnTapped = func() { + defer func() { + go_allCancelBtn.Hide() + go_allSelBtn.Show() + }() + this.goList.selItemIds = []string{} + for i, v := range this.goList.cachedList.Items { + this.goList.cachedList.Items[i].Checked = false + this.goList.itemList.UpdateItem(i, widget.NewCheck(v.Text, nil)) + } + this.goList.titleLabel.SetText(fmt.Sprintf("(%d/%d)", len(this.goList.selItemIds), this.goList.fileTotal)) + this.goList.itemList.Refresh() + } + + //选择所有 + go_allSelBtn.OnTapped = func() { + defer func() { + go_allCancelBtn.Show() + go_allSelBtn.Hide() + }() + for i, v := range this.goList.cachedList.Items { + this.goList.cachedList.Items[i].Checked = true + this.goList.selItemIds = append(this.goList.selItemIds, v.Text) + this.goList.itemList.UpdateItem(i, widget.NewCheck(v.Text, nil)) + } + this.goList.titleLabel.SetText(fmt.Sprintf("(%d/%d)", len(this.goList.selItemIds), this.goList.fileTotal)) + this.goList.itemList.Refresh() + } + // json this.jsonList.titleLabel = widget.NewLabel("Json文件") this.jsonList.titleLabel.Hide() // 复选列表 - this.jsonChkList = this.jsonList.createList() + this.jsonList.itemList = this.jsonList.createList() // 覆盖 -go - json_allSelBtn := &widget.Button{Icon: theme.CheckButtonCheckedIcon()} - json_allCancelBtn := &widget.Button{Icon: theme.CheckButtonIcon()} + json_allSelBtn := &widget.Button{Icon: theme.CheckButtonIcon()} + json_allCancelBtn := &widget.Button{Icon: theme.CheckButtonCheckedIcon()} json_overrideBtn := &widget.Button{Text: "覆盖", Icon: theme.ConfirmIcon()} json_overrideBtn.Hide() json_allSelBtn.Hide() @@ -220,10 +251,42 @@ func (this *appGen) LazyInit(obs observer.Observer) error { if err != nil { logrus.Error(err) } - logrus.Debug(v) + this.jsonList.deleteItem(v) } } + //取消checked + json_allCancelBtn.OnTapped = func() { + defer func() { + json_allCancelBtn.Hide() + json_allSelBtn.Show() + }() + list := this.jsonList + list.selItemIds = []string{} + for i, v := range list.cachedList.Items { + list.cachedList.Items[i].Checked = false + list.itemList.UpdateItem(i, widget.NewCheck(v.Text, nil)) + } + list.titleLabel.SetText(fmt.Sprintf("(%d/%d)", len(list.selItemIds), list.fileTotal)) + list.itemList.Refresh() + } + + //选择所有 + json_allSelBtn.OnTapped = func() { + defer func() { + json_allCancelBtn.Show() + json_allSelBtn.Hide() + }() + list := this.jsonList + for i, v := range list.cachedList.Items { + list.cachedList.Items[i].Checked = true + list.selItemIds = append(list.selItemIds, v.Text) + list.itemList.UpdateItem(i, widget.NewCheck(v.Text, nil)) + } + list.titleLabel.SetText(fmt.Sprintf("(%d/%d)", len(list.selItemIds), list.fileTotal)) + list.itemList.Refresh() + } + genBtn := &widget.Button{Text: "生成", Icon: theme.ConfirmIcon()} genBtn.OnTapped = func() { genBtn.Disable() @@ -277,15 +340,13 @@ func (this *appGen) LazyInit(obs observer.Observer) error { left := container.NewVBox(form, container.NewHBox(&layout.Spacer{}, saveBtn, genBtn)) right := container.NewGridWithColumns(2, container.NewBorder( - container.NewHBox(go_allCancelBtn, go_overrideBtn, widget.NewLabel("Go文件"), this.goList.titleLabel), + container.NewHBox(go_allSelBtn, go_allCancelBtn, go_overrideBtn, widget.NewLabel("Go文件"), this.goList.titleLabel), nil, nil, nil, - container.NewMax(container.NewVScroll(this.goChkList))), + this.goList.itemList), container.NewBorder( - container.NewHBox(json_allCancelBtn, json_overrideBtn, widget.NewLabel("Json文件"), this.jsonList.titleLabel), + container.NewHBox(json_allSelBtn, json_allCancelBtn, json_overrideBtn, widget.NewLabel("Json文件"), this.jsonList.titleLabel), nil, nil, nil, - container.NewMax(container.NewVScroll(this.jsonChkList)), - ), - ) + this.jsonList.itemList)) content.Objects = append(content.Objects, container.NewGridWithColumns(2, left, right)) @@ -294,68 +355,78 @@ func (this *appGen) LazyInit(obs observer.Observer) error { } type fileList struct { - dataBinding binding.UntypedList - selItemIds []string //选择的ID - itemListData *model.ItemModelList - fileTotal int //文件总数 - titleLabel *widget.Label + selItemIds []string //选择的ID + fileTotal int //文件总数 + titleLabel *widget.Label + cachedList List + itemList *widget.List } func NewFileList() *fileList { return &fileList{ - dataBinding: binding.NewUntypedList(), - titleLabel: &widget.Label{}, + titleLabel: &widget.Label{}, + cachedList: NewList(""), } } -func (f *fileList) cretaeHeader() *widget.List { - // header - return widget.NewList( +func (f *fileList) createList() *widget.List { + f.itemList = widget.NewList( func() int { - return 1 + return len(f.cachedList.Items) }, func() fyne.CanvasObject { - return container.NewGridWithColumns(3, - widget.NewLabelWithStyle("", fyne.TextAlignLeading, fyne.TextStyle{}), - widget.NewLabelWithStyle("", fyne.TextAlignCenter, fyne.TextStyle{})) + return widget.NewCheck("Template", func(bool) {}) }, func(id widget.ListItemID, item fyne.CanvasObject) { - item.(*fyne.Container).Objects[0].(*widget.Label).SetText(common.APP_MONITOR_TITLE_ID) - item.(*fyne.Container).Objects[1].(*widget.Label).SetText(common.APP_MONITOR_TITLE_DATA) - }, - ) -} + c, _ := item.(*widget.Check) + c.Text = f.cachedList.Items[id].Text + c.Checked = f.cachedList.Items[id].Checked -func (f *fileList) createList() *widget.List { - return widget.NewListWithData(f.dataBinding, - func() fyne.CanvasObject { - return container.NewHBox( - &widget.Check{Checked: true}, - // widget.NewCheck("", func(b bool) { }), - widget.NewLabelWithStyle("", fyne.TextAlignCenter, fyne.TextStyle{}), - widget.NewLabel(""), - ) - }, - func(data binding.DataItem, item fyne.CanvasObject) { - o, _ := data.(binding.Untyped).Get() - pd := o.(*model.ItemModel) - item.(*fyne.Container).Objects[0].(*widget.Check).OnChanged = func(b bool) { + c.OnChanged = func(b bool) { if b { - f.selItemIds = append(f.selItemIds, pd.Id) + f.selItemIds = append(f.selItemIds, c.Text) } else { - f.selItemIds = utils.DeleteString(f.selItemIds, pd.Id) + f.selItemIds = utils.DeleteString(f.selItemIds, c.Text) } f.titleLabel.SetText(fmt.Sprintf("(%d/%d)", len(f.selItemIds), f.fileTotal)) + f.cachedList.Items[id].Checked = b + // sort.Sort(f.cachedList) + f.itemList.Refresh() } - item.(*fyne.Container).Objects[1].(*widget.Label).SetText(pd.Label) + c.Refresh() }, ) + return f.itemList +} + +func (f *fileList) addItem(val string) { + val = strings.TrimSpace(val) + if len(val) == 0 { + return + } + newItem := Item{ + Text: val, + Quantity: 1, + Checked: true, //默认选中 + } + f.cachedList.Items = append(f.cachedList.Items, newItem) + sort.Sort(f.cachedList) + f.itemList.Refresh() +} + +func (f *fileList) deleteItem(name string) { + for i, v := range f.cachedList.Items { + if v.Text == name { + f.cachedList.Items = append(f.cachedList.Items[:i], f.cachedList.Items[i+1:]...) + } + } + f.itemList.Refresh() } func (f *fileList) changeItem(tmpDir, projectDir string) { f.fileTotal = 0 f.selItemIds = []string{} - f.itemListData = model.NewItemModelList() + f.cachedList = NewList("") tmpFiles, err := ioutil.ReadDir(tmpDir) if err != nil { logrus.Error(err) @@ -382,25 +453,12 @@ func (f *fileList) changeItem(tmpDir, projectDir string) { continue } } - fm := &model.ItemModel{ - Id: file.Name(), - Label: file.Name(), - } - f.itemListData.DataList = append(f.itemListData.DataList, fm) - f.selItemIds = append(f.selItemIds, fm.Id) + f.addItem(file.Name()) + f.selItemIds = append(f.selItemIds, file.Name()) f.fileTotal++ - logrus.Debugf("%v", fm.Id) + logrus.Debugf("%v", file.Name()) } } - - f.reloadListData() -} - -func (f *fileList) reloadListData() { - if f.itemListData != nil { - d := f.itemListData.AsInterfaceArray() - f.dataBinding.Set(d) - } } func (a *appGen) GetAppName() string { diff --git a/cmd/v2/ui/views/bingoview.go b/cmd/v2/ui/views/bingoview.go index f25e6d339..2768430f9 100644 --- a/cmd/v2/ui/views/bingoview.go +++ b/cmd/v2/ui/views/bingoview.go @@ -45,7 +45,7 @@ func (this *BingoView) CreateView(t *model.TestCase) fyne.CanvasObject { aSel = &widget.Select{} gridContainer = container.NewGridWithColumns(3, aSel, tEntry, nEntry) - aSel.Options = []string{"选择", "attr", "item", "hero", "equi"} + aSel.Options = []string{"选择", "attr", "item", "hero", "equi","mapid","pataid"} aSel.SetSelected("选择") aSel.OnChanged = func(s string) { if s == "attr" {