Skip to content

Commit

Permalink
fixing stability issues
Browse files Browse the repository at this point in the history
  • Loading branch information
KiameV committed Dec 22, 2022
1 parent 8eaf02f commit 76e1818
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 9 deletions.
18 changes: 14 additions & 4 deletions actions/steps/steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"github.com/kiamev/moogle-mod-manager/config"
"github.com/kiamev/moogle-mod-manager/discover"
"github.com/kiamev/moogle-mod-manager/downloads"
"github.com/kiamev/moogle-mod-manager/files"
"github.com/kiamev/moogle-mod-manager/files/archive"
Expand Down Expand Up @@ -57,11 +58,20 @@ func VerifyEnable(state *State) (mods.Result, error) {
}
if len(c.Requires) > 0 {
for _, mc = range c.Requires {
var name string
mod, found, enabled = managed.IsModEnabled(state.Game, mc.ModID())
if !found {
return mods.Error, fmt.Errorf("[%s] cannot be enabled because [%s] is not enabled", tm.DisplayName(), mc.ModID())
} else if !enabled {
return mods.Error, fmt.Errorf("[%s] cannot be enabled because [%s] is not enabled", tm.DisplayName(), mod.DisplayName())
if !enabled {
if !found || mod == nil {
name, _ = discover.GetDisplayName(state.Game, mc.ModID())
}
if name == "" {
if mod != nil {
name = mod.DisplayName()
} else {
name = string(mc.ModID())
}
}
return mods.Error, fmt.Errorf("[%s] cannot be enabled because [%s] is not enabled", tm.DisplayName(), name)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion browser/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

const (
Version = "v0.7.2"
Version = "v0.7.3"

tagUrl = `https://api.github.com/repos/KiameV/ffprModManager/tags`
relUrl = `https://github.com/KiameV/ffprModManager/releases/%s`
Expand Down
1 change: 1 addition & 0 deletions mods/mod.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ var Categories = []string{
string(EnemySprite),
string(GameOverhauls),
string(Gameplay),
string(Fonts),
string(PlayerNpcSprites),
string(ScriptText),
string(Soundtrack),
Expand Down
2 changes: 1 addition & 1 deletion scripts/findSupportedMods.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func getGameFiles(apiKey string, i int, g game) error {
}
}
}
if len(fs.Files) == 0 {
if len(fs.Files) == 1 {
if easy {
sfo.WriteString(fullSb.String())
} else {
Expand Down
16 changes: 15 additions & 1 deletion ui/config-installer/configInstaller.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (ui *configInstallerUI) Draw(w fyne.Window) {
ui.prevConfigs = append(ui.prevConfigs, ui.currentConfig)
ui.toInstall = append(ui.toInstall, ui.currentChoice.DownloadFiles)
if ui.currentChoice.NextConfigurationName == nil {
tis, err := mods.NewToInstallForMod(ui.mod.ModKind.Kind, ui.mod, ui.toInstall)
tis, err := mods.NewToInstallForMod(ui.mod.ModKind.Kind, ui.mod, ui.uniqueToInstall())
if err != nil {
util.ShowErrorLong(err)
state.ShowPreviousScreen()
Expand Down Expand Up @@ -178,3 +178,17 @@ func (ui *configInstallerUI) popChoice() (c *mods.Configuration) {
ui.prevConfigs = ui.prevConfigs[:l]
return
}

func (ui *configInstallerUI) uniqueToInstall() []*mods.DownloadFiles {
l := make(map[string]*mods.DownloadFiles)
for _, df := range ui.toInstall {
if df.DownloadName != "" {
l[df.DownloadName] = df
}
}
result := make([]*mods.DownloadFiles, 0, len(l))
for _, df := range l {
result = append(result, df)
}
return result
}
1 change: 1 addition & 0 deletions ui/local/localUI.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ func (ui *localUI) removeSelectedMod() {
util.ShowErrorLong(err)
return
}
_ = managed.Save()
for i, m := range ui.mods {
if m == ui.selectedMod {
ui.mods = append(ui.mods[:i], ui.mods[i+1:]...)
Expand Down
6 changes: 4 additions & 2 deletions ui/mod-author/author.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,10 @@ func (a *ModAuthorer) Draw(w fyne.Window) {
if len(a.configsDef.list.Items) == 0 {
util.DisplayDownloadsAndFiles(tis)
} else {
if err = state.GetScreen(state.ConfigInstaller).(config_installer.ConfigInstaller).Setup(mod, state.GetBaseDir(), func(_ mods.Result, tis []*mods.ToInstall) error {
util.DisplayDownloadsAndFiles(tis)
if err = state.GetScreen(state.ConfigInstaller).(config_installer.ConfigInstaller).Setup(mod, state.GetBaseDir(), func(r mods.Result, tis []*mods.ToInstall) error {
if r == mods.Ok && len(tis) > 0 {
util.DisplayDownloadsAndFiles(tis)
}
return nil
}); err != nil {
util.ShowErrorLong(err)
Expand Down
3 changes: 3 additions & 0 deletions ui/util/sandbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ func DisplayDownloadsAndFiles(toInstall []*mods.ToInstall) {
}()
sb := strings.Builder{}
for _, ti := range toInstall {
if ti.Download == nil {
continue
}
sb.WriteString(fmt.Sprintf("## %s\n\n", ti.Download.Name))
sb.WriteString("### Sources:\n\n")
if ti.Download.Hosted != nil {
Expand Down

0 comments on commit 76e1818

Please sign in to comment.