vchelaru / FlatRedBall

Cross-platform 2D game engine focused on ultimate productivity built in .NET
http://flatredball.com
MIT License
366 stars 59 forks source link

FRB Editor should detect if XNA Redistributable 4.0 is installed #1203

Open vchelaru opened 11 months ago

vchelaru commented 11 months ago

While we are working to get rid of this requirement, there are still two apps which do require it:

  1. Gum
  2. AnimationEditor

The Gum requirement is especially important because without Gum, font caches cannot be refreshed, and errors appear in the FRB Editor.

To solve this, the FRB Editor should check for the presence of the XNA Framework Redistributable 4.0.

https://www.microsoft.com/en-us/download/details.aspx?id=27598

This should probably be part of the Gum plugin error reporting.

vchelaru commented 11 months ago

This should be easy, but turns out I can't find good info on this. I searched around and tried the following:

private bool CheckForXnaRuntime()
{
    string baseKeyName = @"SOFTWARE\Microsoft\XNA\Game Studio";
    Microsoft.Win32.RegistryKey installedFrameworkVersions = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(baseKeyName);

    string[] versionNames = installedFrameworkVersions.GetSubKeyNames();

    bool found = false;
    foreach (string s in versionNames)
    {
        if (s == "v4.0")
        {
            found = true;
            break;
        }
    }

    return found;

}

bool IsXNA4Installed()
{
    const string XNA4RegistryPath = @"SOFTWARE\Microsoft\Microsoft XNA\Framework\v4.0";

    using (RegistryKey rk = Registry.LocalMachine.OpenSubKey(XNA4RegistryPath))
    {
        if (rk != null)
        {
            object installValue = rk.GetValue("Installed");
            if (installValue != null)
            {
                int installed = (int)installValue;
                if (installed == 1)
                {
                    return true;
                }
            }
        }
    }

    return false;
}

Both methods failed on my Windows 10 machine.

I've spent too much time on this problem, not sure if anyone else has ideas.

AristurtleDev commented 2 months ago

I can take this