Пример #1
0
        /// <summary>
        /// Checks if the Factorio Steam version is present on the system.
        /// </summary>
        /// <returns>Returns true if the Factorio Steam version is present on the system, otherwise false.</returns>
        public static bool IsPresent()
        {
            var steamLibraries = SteamHelper.ListSteamLibraries(false);

            if ((steamLibraries == null) || (steamLibraries.Count == 0))
            {
                return(false);
            }

            foreach (var library in steamLibraries)
            {
                var factorioDir = library.EnumerateDirectories("Factorio").FirstOrDefault();
                if (factorioDir != null)
                {
                    if (FactorioFolder.TryLoad(factorioDir, out var folder))
                    {
                        if (folder.Is64Bit == Environment.Is64BitOperatingSystem)
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
Пример #2
0
        public static bool TryLoad(DirectoryInfo directory, out FactorioFolder folder)
        {
            folder = null;

            if (!directory.Exists)
            {
                return(false);
            }
            if (!TryLoadVersion(directory, out var version))
            {
                return(false);
            }
            if (!TryLoadBitness(directory, out bool is64Bit, out var executable))
            {
                return(false);
            }

            folder = new FactorioFolder(directory, executable, version, is64Bit);
            return(true);
        }
Пример #3
0
        /// <summary>
        /// Loads all installed versions of Factorio.
        /// </summary>
        /// <returns>Returns a list that contains all installed Factorio versions.</returns>
        public static List <FactorioVersion> LoadInstalledVersions()
        {
            var versionList = new List <FactorioVersion>();

            DirectoryInfo factorioDirectory = App.Instance.Settings.GetFactorioDirectory();

            if (factorioDirectory.Exists)
            {
                foreach (var directory in factorioDirectory.EnumerateDirectories())
                {
                    if (FactorioFolder.TryLoad(directory, out var folder))
                    {
                        if (folder.Is64Bit == Environment.Is64BitOperatingSystem)
                        {
                            folder.RenameToUnique();
                            versionList.Add(new FactorioVersion(folder));
                        }
                    }
                }
            }

            return(versionList);
        }
Пример #4
0
 private FactorioSteamVersion(FactorioFolder folder)
     : base(folder, false, new DirectoryInfo(SteamAppDataPath))
 {
 }