RWELabs / Stardew-Valley-Mod-Manager

[Passion Project] The Stardew Valley Mod Manager is a powerful tool that is designed to be used alongside SMAPI to help you install and manage mods, automatically install modpacks and manage your game saves.
Other
29 stars 1 forks source link

[Issue] False positive warning for SMAPI not being installed #7

Closed Crutionix closed 2 years ago

Crutionix commented 2 years ago

Issue: The application presents a warning banner informing the user that SMAPI is not detected in the Stardew Valley directory even though SMAPI is not only installed in the directory - but in some cases, the warning was not present at an earlier point despite no file changes being made.

Steps to Replicate:

  1. Have Stardew Valley and SMAPI installed to the same directory.
  2. Be (un)lucky enough for it to give the false positive.

Suggested Resolution: Check and adjust the way that the application detects SMAPI being installed.

RyanWalpole commented 2 years ago

Currently the code is flawed in that it only fires the warning banner dependent on the file version of the SMAPI executable being fetched.

try 
             {
                var SMAPIVersion = FileVersionInfo.GetVersionInfo(Properties.Settings.Default.StardewDir + 
                @"\StardewModdingAPI.exe");

                string SMAPIVersionText = "SMAPI " + "v" + SMAPIVersion.FileVersion;

                SMAPIVer.Text = SMAPIVersionText;

                SMAPIWarning.Visible = false;
                SMAPIVer.Visible = true;
             }

catch
            {
                SMAPIVer.Text = "SMAPI Not Installed";
                SMAPIWarning.Visible = true;
                SMAPIVer.Visible = true;
            }

If the file version takes too long to be fetched or doesn't get fetched, there's no fail safe for the warning.

RyanWalpole commented 2 years ago

Planned Resolution: Add the following code to the startup behaviour for the form, after the SMAPI version has been detected.

if(File.Exists(Properties.Settings.Default.StardewDir + @"\StardewModdingAPI.exe"))
            {
                SMAPIWarning.Visible = false;
                SMAPIVer.Visible = true;
                //MessageBox.Show(Properties.Settings.Default.StardewDir + @"\StardewModdingAPI.exe");
            }
            else if (!File.Exists(Properties.Settings.Default.StardewDir + @"\StardewModdingAPI.exe"))
            {
                SMAPIWarning.Visible = true;
                SMAPIVer.Visible = true;
            }

This should add a failsafe that will only show the warning if the file itself is found to not exist rather than if the file version is not detected/obtained fast enough.

RyanWalpole commented 2 years ago

Issue Resolution

RyanWalpole commented 2 years ago

Fix Testing: Was able to replicate the issue and have observed that the fix has worked successfully.

Documentation: Issues: Stardew Valley Mod Manager - SDV Mod Manager says SMAPI is not detected but it is installed. on the SDV Mod Manager Wiki