Exemplo n.º 1
0
        public static void CleanGameDirectory(bool removeSettingsValue = false)
        {
            var metaLocation  = AppDomain.CurrentDomain.BaseDirectory;
            var filterList    = File.ReadLines(Path.Combine(metaLocation, Settings.Default.FilterLocation));
            var gameDirectory = GetSettings.Return(SettingTypes.GameLocation);

            foreach (var item in filterList)
            {
                var tempPath = Path.Combine(gameDirectory, item);

                if (File.Exists(tempPath))
                {
                    File.Delete(tempPath);
                }

                if (Directory.Exists(tempPath))
                {
                    Directory.Delete(tempPath, true);
                }
            }

            if (removeSettingsValue)
            {
                SaveSettings.Save(SettingTypes.InstalledPreset, "");
            }
        }
Exemplo n.º 2
0
        public static void InstallPreset(string presetName)
        {
            var metaLocation      = AppDomain.CurrentDomain.BaseDirectory;
            var gameDirectory     = GetSettings.Return(SettingTypes.GameLocation);
            var presetLocation    = Path.Combine(metaLocation, Settings.Default.PresetDirectory, presetName);
            var filterList        = File.ReadLines(Path.Combine(metaLocation, Settings.Default.FilterLocation));
            var presetFiles       = Directory.GetFiles(presetLocation).Where(x => new FileInfo(x).Name != "meta.ini").ToList();
            var presetDirectories = Directory.GetDirectories(presetLocation).ToList();

            // Clean the game directory of all existing files.
            foreach (var item in filterList)
            {
                var tempPath = Path.Combine(gameDirectory, item);

                if (File.Exists(tempPath))
                {
                    File.Delete(tempPath);
                }

                if (Directory.Exists(tempPath))
                {
                    Directory.Delete(tempPath, true);
                }
            }

            // Copy the selected files into the game directory.
            presetFiles.ForEach(x => File.Copy(x, Path.Combine(gameDirectory, new FileInfo(x).Name)));
            presetDirectories.ForEach(x => DirCopyTo(x, Path.Combine(gameDirectory, new DirectoryInfo(x).Name)));

            // Finally, save the preset.
            SaveSettings.Save(SettingTypes.InstalledPreset, presetName);
        }
Exemplo n.º 3
0
        public static void UninstallPreset(string presetName)
        {
            var metaLocation   = AppDomain.CurrentDomain.BaseDirectory;
            var presetLocation = Path.Combine(metaLocation, Settings.Default.PresetDirectory, presetName);

            // Delete the directory the preset is located in
            DeleteDirectory(presetLocation);

            // Check to see if the END is set to be currently installed. If it is, remove it from the settings.
            if (presetName == GetSettings.Return(SettingTypes.InstalledPreset))
            {
                // Clean the game directory
                CleanGameDirectory();
                SaveSettings.Save(SettingTypes.InstalledPreset, "");
            }
        }