示例#1
0
        public SAV_FolderList()
        {
            InitializeComponent();

            // Preprogrammed folders
            var locs = new List <CustomFolderPath>
            {
                new CustomFolderPath(Main.BackupPath, "PKHeX Backups")
            };

            locs.AddRange(GetUserPaths());
            locs.AddRange(Get3DSPaths());
            locs.AddRange(GetSwitchPaths());
            addIfExists(CyberGadgetUtil.GetCacheFolder(), "CGSE Cache");
            addIfExists(CyberGadgetUtil.GetTempFolder(), "CGSE Temp");

            var paths = locs.GroupBy(z => z.Path).Select(z => z.First())
                        .OrderByDescending(z => Directory.Exists(z.Path));

            foreach (var loc in paths)
            {
                AddButton(loc.DisplayText, loc.Path);
            }

            WinFormsUtil.TranslateInterface(this, Main.CurrentLanguage);

            void addIfExists(string path, string text)
            {
                if (Directory.Exists(path))
                {
                    locs.Add(new CustomFolderPath(path, text));
                }
            }
        }
示例#2
0
        public SAV_FolderList()
        {
            InitializeComponent();

            // Preprogrammed folders
            var locs = new List <CustomFolderPath>
            {
                new CustomFolderPath {
                    Path = Main.BackupPath, DisplayText = "PKHeX Backups"
                }
            };

            locs.AddRange(getUserPaths());
            locs.AddRange(get3DSPaths());
            locs.Add(new CustomFolderPath {
                Path = CyberGadgetUtil.GetCacheFolder(), DisplayText = "CGSE Cache"
            });
            locs.Add(new CustomFolderPath {
                Path = CyberGadgetUtil.GetTempFolder(), DisplayText = "CGSE Temp"
            });

            foreach (var loc in locs.GroupBy(z => z.Path))
            {
                addButton(loc.First().DisplayText, loc.First().Path);
            }

            WinFormsUtil.TranslateInterface(this, Main.curlanguage);
        }
示例#3
0
        /// <summary>
        /// Opens a dialog to open a <see cref="SaveFile"/>, <see cref="PKM"/> file, or any other supported file.
        /// </summary>
        /// <param name="Extensions">Misc extensions of <see cref="PKM"/> files supported by the SAV.</param>
        /// <param name="path">Output result path</param>
        /// <returns>Result of whether or not a file is to be loaded from the output path.</returns>
        public static bool OpenSAVPKMDialog(IEnumerable <string> Extensions, out string path)
        {
            string         supported = string.Join(";", Extensions.Select(s => $"*.{s}").Concat(new[] { "*.pkm" }));
            OpenFileDialog ofd       = new OpenFileDialog
            {
                Filter = "All Files|*.*" +
                         $"|Supported Files (*.*)|main;*.bin;{supported};*.bak" + ExtraSaveExtensions +
                         "|Save Files (*.sav)|main" + ExtraSaveExtensions +
                         "|Decrypted PKM File (*.pkm)|" + supported +
                         "|Binary File|*.bin" +
                         "|Backup File|*.bak"
            };

            // Detect main
            string cgse      = "";
            string pathCache = CyberGadgetUtil.GetCacheFolder();

            if (Directory.Exists(pathCache))
            {
                cgse = Path.Combine(pathCache);
            }

            string msg = null;
            var    sav = SaveDetection.DetectSaveFile(Environment.GetLogicalDrives(), ref msg, cgse);

            if (sav == null && !string.IsNullOrWhiteSpace(msg))
            {
                Error(msg);
            }

            if (sav != null)
            {
                ofd.FileName = sav.FileName;
            }

            if (ofd.ShowDialog() != DialogResult.OK)
            {
                path = null;
                return(false);
            }

            path = ofd.FileName;
            return(true);
        }
示例#4
0
        /// <summary>
        /// Opens a dialog to open a <see cref="SaveFile"/>, <see cref="PKM"/> file, or any other supported file.
        /// </summary>
        /// <param name="Extensions">Misc extensions of <see cref="PKM"/> files supported by the SAV.</param>
        /// <param name="path">Output result path</param>
        /// <returns>Result of whether or not a file is to be loaded from the output path.</returns>
        public static bool OpenSAVPKMDialog(IEnumerable <string> Extensions, out string path)
        {
            string         supported = string.Join(";", Extensions.Select(s => $"*.{s}").Concat(new[] { "*.pkm" }));
            OpenFileDialog ofd       = new OpenFileDialog
            {
                Filter = "All Files|*.*" +
                         $"|Supported Files|main;*.sav;*.dat;*.gci;*.bin;{supported};*.bak" +
                         "|3DS Main Files|main" +
                         "|Save Files|*.sav;*.dat;*.gci" +
                         "|Decrypted PKM File|" + supported +
                         "|Binary File|*.bin" +
                         "|Backup File|*.bak"
            };

            // Detect main
            string cgse      = "";
            string pathCache = CyberGadgetUtil.GetCacheFolder();

            if (Directory.Exists(pathCache))
            {
                cgse = Path.Combine(pathCache);
            }
            if (!PathUtilWindows.DetectSaveFile(out path, cgse) && !string.IsNullOrEmpty(path))
            {
                Error(path); // `path` contains the error message
                path = null;
            }

            if (path != null)
            {
                ofd.FileName = path;
            }

            if (ofd.ShowDialog() != DialogResult.OK)
            {
                return(false);
            }

            path = ofd.FileName;
            return(true);
        }
示例#5
0
        private static List <CustomFolderPath> GetPathList(IReadOnlyList <string> drives)
        {
            var locs = new List <CustomFolderPath>
            {
                new CustomFolderPath(Main.BackupPath, "PKHeX Backups")
            };

            locs.AddRange(GetUserPaths());

            locs.AddRange(GetConsolePaths(drives));
            locs.AddRange(GetSwitchPaths(drives));
            addIfExists(CyberGadgetUtil.GetCacheFolder(), "CGSE Cache");
            addIfExists(CyberGadgetUtil.GetTempFolder(), "CGSE Temp");
            void addIfExists(string path, string text)
            {
                if (Directory.Exists(path))
                {
                    locs.Add(new CustomFolderPath(path, text));
                }
            }

            return(locs.GroupBy(z => z.Path).Select(z => z.First())
                   .OrderByDescending(z => Directory.Exists(z.Path)).ToList());
        }