diff --git a/cmd/v2/lib/common/itemlist.go b/cmd/v2/lib/common/itemlist.go index 6e228441b..07ccbda3f 100644 --- a/cmd/v2/lib/common/itemlist.go +++ b/cmd/v2/lib/common/itemlist.go @@ -144,6 +144,7 @@ func (f *ItemList) AddItemWithText(val string) { return } newItem := Item{ + Id: val, Text: val, Quantity: 1, Checked: false, //默认不选中 @@ -211,9 +212,9 @@ func (f *ItemList) ChangeItem(tmpDir, projectDir string) { } } f.AddItemWithText(file.Name()) - f.SelItemIds = append(f.SelItemIds, file.Name()) + // f.SelItemIds = append(f.SelItemIds, file.Name()) f.ItemTotal++ - logrus.Debugf("%v", file.Name()) + // logrus.Debugf("%v", file.Name()) } } } diff --git a/cmd/v2/ui/tool_gen.go b/cmd/v2/ui/tool_luban.go similarity index 85% rename from cmd/v2/ui/tool_gen.go rename to cmd/v2/ui/tool_luban.go index 6e5ff0ef0..0c2e4b65e 100644 --- a/cmd/v2/ui/tool_gen.go +++ b/cmd/v2/ui/tool_luban.go @@ -150,8 +150,8 @@ func (this *appGen) LazyInit(obs observer.Observer) error { this.goList.ItemList = this.goList.CreateDefaultCheckList() // 覆盖 -go - go_allSelBtn := &widget.Button{Icon: theme.CheckButtonIcon()} - go_allCancelBtn := &widget.Button{Icon: theme.CheckButtonCheckedIcon()} + go_allSelBtn := &widget.Button{Icon: theme.CheckButtonCheckedIcon()} + go_allCancelBtn := &widget.Button{Icon: theme.CheckButtonIcon()} go_overrideBtn := &widget.Button{Text: "覆盖", Icon: theme.ConfirmIcon()} go_overrideBtn.Hide() go_allSelBtn.Hide() @@ -214,12 +214,14 @@ func (this *appGen) LazyInit(obs observer.Observer) error { // 复选列表 this.jsonList.ItemList = this.jsonList.CreateDefaultCheckList() - // 覆盖 -go - json_allSelBtn := &widget.Button{Icon: theme.CheckButtonIcon()} - json_allCancelBtn := &widget.Button{Icon: theme.CheckButtonCheckedIcon()} + // 覆盖 -json + json_allSelBtn := &widget.Button{Icon: theme.CheckButtonCheckedIcon()} + json_allCancelBtn := &widget.Button{Icon: theme.CheckButtonIcon()} json_overrideBtn := &widget.Button{Text: "覆盖", Icon: theme.ConfirmIcon()} json_overrideBtn.Hide() json_allSelBtn.Hide() + + // 点击覆盖按钮 json_overrideBtn.OnTapped = func() { json_overrideBtn.Disable() defer func() { @@ -227,8 +229,8 @@ func (this *appGen) LazyInit(obs observer.Observer) error { this.jsonList.ItemList.Refresh() }() for _, v := range this.jsonList.SelItemIds { - // logrus.WithField("path1", filepath.Join(tmpDir.Text, "json", v)).Debug("copy json") - // logrus.WithField("path2", filepath.Join(projectDir.Text, outputJsonDir.Text, v)).Debug("copy json") + logrus.WithField("path", v).Debug("select json") + // // logrus.WithField("path2", filepath.Join(projectDir.Text, outputJsonDir.Text, v)).Debug("copy json") _, err := common.Copy(filepath.Join(tmpDir.Text, "json", v), filepath.Join(projectDir.Text, outputJsonDir.Text, v)) if err != nil { @@ -241,10 +243,10 @@ func (this *appGen) LazyInit(obs observer.Observer) error { } //取消checked - json_allCancelBtn.OnTapped = func() { + json_allSelBtn.OnTapped = func() { defer func() { - json_allCancelBtn.Hide() - json_allSelBtn.Show() + json_allCancelBtn.Show() + json_allSelBtn.Hide() }() list := this.jsonList list.SelItemIds = []string{} @@ -257,10 +259,10 @@ func (this *appGen) LazyInit(obs observer.Observer) error { } //选择所有 - json_allSelBtn.OnTapped = func() { + json_allCancelBtn.OnTapped = func() { defer func() { - json_allCancelBtn.Show() - json_allSelBtn.Hide() + json_allCancelBtn.Hide() + json_allSelBtn.Show() }() list := this.jsonList for i, v := range list.CachedList.Items { @@ -272,6 +274,12 @@ func (this *appGen) LazyInit(obs observer.Observer) error { list.ItemList.Refresh() } + // 资源管理器 + explorBtn := &widget.Button{Text: "资源管理器", Icon: theme.FolderIcon()} + explorBtn.OnTapped = func() { + OpenExplor(filepath.Join(workDir.Text, inputDir.Text)) + } + genBtn := &widget.Button{Text: "生成", Icon: theme.ConfirmIcon()} genBtn.OnTapped = func() { genBtn.Disable() @@ -292,25 +300,6 @@ func (this *appGen) LazyInit(obs observer.Observer) error { return } - commandStr := `%s -h %s -j cfg -- -d %s --input_data_dir %s --output_code_dir %s --output_data_dir %s --gen_types %s --go:bright_module_name bright -s server` - - arg := fmt.Sprintf(commandStr, - filepath.Join(workDir.Text, client.Text), - serverAddr.Text, - filepath.Join(workDir.Text, define.Text), - filepath.Join(workDir.Text, inputDir.Text), - filepath.Join(tmpDir.Text, "go"), - filepath.Join(tmpDir.Text, "json"), - getType(), - ) - - logrus.Debug(arg) - c := exec.Command("cmd.exe", "/c", arg) - if err := c.Run(); err != nil { - dialog.ShowError(err, toolWin.w) - return - } - changeGo := func() { this.goList.ChangeItem(filepath.Join(tmpDir.Text, "go"), filepath.Join(projectDir.Text, outputCodeDir.Text)) this.goList.TitleLabel.SetText(fmt.Sprintf("(%d/%d个)", len(this.goList.SelItemIds), this.goList.ItemTotal)) @@ -325,15 +314,48 @@ func (this *appGen) LazyInit(obs observer.Observer) error { this.jsonList.TitleLabel.Show() } - // 更新列表 - if genTypeText == "go" { - changeGo() - } else if genTypeText == "json" { - changeJson() - } else if genTypeText == "all" { - changeGo() - changeJson() + gen := func() { + commandStr := `%s -h %s -j cfg -- -d %s --input_data_dir %s --output_code_dir %s --output_data_dir %s --gen_types %s --go:bright_module_name bright -s server` + + arg := fmt.Sprintf(commandStr, + filepath.Join(workDir.Text, client.Text), + serverAddr.Text, + filepath.Join(workDir.Text, define.Text), + filepath.Join(workDir.Text, inputDir.Text), + filepath.Join(tmpDir.Text, "go"), + filepath.Join(tmpDir.Text, "json"), + getType(), + ) + + logrus.Debug(arg) + c := exec.Command("cmd.exe", "/c", arg) + if err := c.Run(); err != nil { + dialog.ShowError(err, toolWin.w) + return + } + + // 更新列表 + if genTypeText == "go" { + changeGo() + } else if genTypeText == "json" { + changeJson() + } else if genTypeText == "all" { + changeGo() + changeJson() + } } + + dc := dialog.NewConfirm("提示", "Excel文件需要更新吗?", func(b bool) { + if !b { + gen() + return + } + + OpenExplor(filepath.Join(workDir.Text, inputDir.Text)) + }, toolWin.w) + dc.SetDismissText("不更新") + dc.SetConfirmText("更新") + dc.Show() } //使用说明 @@ -353,7 +375,7 @@ func (this *appGen) LazyInit(obs observer.Observer) error { }) // layout - left := container.NewVBox(form, container.NewHBox(&layout.Spacer{}, desBtn, saveBtn, genBtn)) + left := container.NewVBox(form, container.NewHBox(&layout.Spacer{}, desBtn, saveBtn, &layout.Spacer{}, explorBtn, genBtn)) right := container.NewGridWithColumns(2, container.NewBorder( container.NewHBox(go_allSelBtn, go_allCancelBtn, go_overrideBtn, widget.NewLabel("Go文件"), this.goList.TitleLabel), diff --git a/cmd/v2/ui/tool_term.go b/cmd/v2/ui/tool_term.go index d0b3a770b..eecb08825 100644 --- a/cmd/v2/ui/tool_term.go +++ b/cmd/v2/ui/tool_term.go @@ -349,7 +349,8 @@ func (this *appTerm) LazyInit(obs observer.Observer) error { defer func() { syncBtn.Enable() this.upProgress.Hide() - dialog.ShowConfirm("提示", "所有文件均上传完毕,静等1-2分钟", func(b bool) {}, toolWin.w) + reloadItem() + dialog.ShowInformation("提示", "所有文件均上传完毕,需等1-2分钟待文件热更", toolWin.w) }() syncBtn.Disable() this.upProgress.Show() diff --git a/cmd/v2/ui/views/friend_assistlist.go b/cmd/v2/ui/views/friend_assistlist.go index 2226ef6cc..2c2701a49 100644 --- a/cmd/v2/ui/views/friend_assistlist.go +++ b/cmd/v2/ui/views/friend_assistlist.go @@ -6,6 +6,9 @@ import ( "go_dreamfactory/pb" "fyne.io/fyne/v2" + "fyne.io/fyne/v2/container" + "fyne.io/fyne/v2/theme" + "fyne.io/fyne/v2/widget" "github.com/sirupsen/logrus" ) @@ -22,5 +25,11 @@ func (this *FriendAssistListView) CreateView(t *model.TestCase) fyne.CanvasObjec } } defer this.friendAssistList() - return this.form + refreshBtn := widget.NewButtonWithIcon("", theme.ViewRefreshIcon(), func() { + this.friendAssistList() + }) + + buttonBar := container.NewHBox(refreshBtn) + c := container.NewBorder(buttonBar, nil, nil, nil) + return c } diff --git a/cmd/v2/ui/views/hero_list.go b/cmd/v2/ui/views/hero_list.go index c7d682dd7..4cc46dc20 100644 --- a/cmd/v2/ui/views/hero_list.go +++ b/cmd/v2/ui/views/hero_list.go @@ -2,6 +2,7 @@ package formview import ( "fmt" + "go_dreamfactory/cmd/v2/lib/common" "go_dreamfactory/cmd/v2/model" "go_dreamfactory/cmd/v2/service" "go_dreamfactory/cmd/v2/service/observer" @@ -14,97 +15,38 @@ import ( "fyne.io/fyne/v2/theme" "fyne.io/fyne/v2/widget" "github.com/sirupsen/logrus" - "github.com/spf13/cast" ) type HeroListView struct { - ListBaseView - subWindows *SubWindowListView - heroList []*pb.DBHero - flag bool + BaseformView + itemList common.ItemList + flag bool + heroList func() } func (this *HeroListView) CreateView(t *model.TestCase) fyne.CanvasObject { - // init required - this.initItemList() + this.itemList = *common.NewItemList() + this.itemList.ItemList = this.itemList.CreateList() - // create friend list view - l := this.createItemList() - l.OnSelected = func(id widget.ListItemID) { - //创建window - m := this.itemListData.DataList[id] - // if this.subWindows == nil { - this.subWindows = NewSubWindowView(m.Id, m.Label, this.obs) - this.subWindows.initItemList() - this.subWindows.createItemListWithCheck() - this.subWindows.createWindows() - // } - - // TODO 升星 - starBtn := widget.NewButtonWithIcon("升星", theme.ConfirmIcon(), func() { - if err := service.GetPttService().SendToClient(t.MainType, hero.StrengthenUpStar, - &pb.HeroStrengthenUpStarReq{ - HeroObjID: m.Id, - // HeroRace: heroRace, - // Hero: hero, - }); err != nil { - logrus.Error(err) - return - } - }) - - lvBtn := widget.NewButtonWithIcon("升级", theme.ConfirmIcon(), func() { - var cards []*pb.MapStringInt32 - for _, v := range this.subWindows.selItemIds { - cards = append(cards, &pb.MapStringInt32{ - Key: v, - Value: 1, - }) - } - if err := service.GetPttService().SendToClient(t.MainType, hero.StrengthenUplv, - &pb.HeroStrengthenUplvReq{ - HeroObjID: m.Id, - ExpCards: cards, - }); err != nil { - logrus.Error(err) - return - } - }) - - this.subWindows.itemListData = model.NewItemModelList() - for _, v := range this.heroList { - if v.CardType == 3 { //不显示类型是3的 - fm := &model.ItemModel{ - Id: cast.ToString(v.Id), - Label: fmt.Sprintf("%s Lv:%d S:%d T:%d", cast.ToString(v.HeroID), v.Lv, v.Star, v.CardType), - } - this.subWindows.itemListData.DataList = append(this.subWindows.itemListData.DataList, fm) - } - } - - split := container.NewHSplit(this.subWindows.dataListWidget, container.NewVBox(starBtn, lvBtn)) - split.Offset = 1 - - this.subWindows.w.SetContent(split) - - this.subWindows.w.Show() - } - - // hero list button - heroListBtn := widget.NewButtonWithIcon("英雄列表", theme.ConfirmIcon(), func() { + this.heroList = func() { if err := service.GetPttService().SendToClient(t.MainType, t.SubType, &pb.HeroListReq{}); err != nil { logrus.Error(err) + return } + } + defer this.heroList() + + refreshBtn := widget.NewButtonWithIcon("", theme.ViewRefreshIcon(), func() { + this.itemList.Reset() + this.heroList() }) - // layout - split := container.NewHSplit(this.dataListWidget, container.NewVBox(heroListBtn)) - split.Offset = 1 + //layout + buttonBar := container.NewHBox(refreshBtn) + c := container.NewBorder(buttonBar, nil, nil, nil, this.itemList.ItemList) - //data listener for this.dataListener() - - return split + return c } func (this *HeroListView) dataListener() { @@ -118,25 +60,22 @@ func (this *HeroListView) dataListener() { data.SubType == hero.HeroSubTypeList) { return } - rsp := &pb.HeroListResp{} + if !comm.ProtoUnmarshal(data, rsp) { - logrus.Error("hero_list unmarshal err") + logrus.Error("unmarshal err") return } - this.heroList = rsp.List - this.itemListData = model.NewItemModelList() - for _, v := range rsp.List { - if v.CardType != 3 { //不显示类型是3的 - fm := &model.ItemModel{ - Id: cast.ToString(v.Id), - Label: fmt.Sprintf("%s Lv:%d S:%d T:%d", cast.ToString(v.HeroID), v.Lv, v.Star, v.CardType), - } - this.itemListData.DataList = append(this.itemListData.DataList, fm) + for i, v := range rsp.List { + item := common.Item{ + Id: v.Id, + Text: fmt.Sprintf("%d ID:%v Star:%d Lv:%d Type:%d Count:%d", + i+1, v.HeroID, v.Star, v.Lv, v.CardType, v.SameCount), } + this.itemList.AddItem(item) } - this.reloadListData() + }, }) this.flag = true