Exemplo n.º 1
0
        private void BackgroundWorkerScanForGames(object sender, DoWorkEventArgs doWorkEventArgs)
        {
            workingProgress = WorkingProgress.ScanningForGames;
            var          ldm    = new LocalDataManager();
            var          cfg    = ldm.LoadConfig();
            DialogResult result =
                MessageBox.Show(
                    "This is the first time you are running GameLoader, do you want it to check for installed games?",
                    "Check for games", MessageBoxButtons.YesNo);
            List <string> fs = cfg.GamesFolders;

            if (result == DialogResult.Yes)
            {
                string[] paths    = GameSuggestions.GetGameFolders();
                string   question =
                    $"I found these paths: {Environment.NewLine}{string.Join(Environment.NewLine, paths)}{Environment.NewLine}Do you want to use them?{Environment.NewLine}You can add other folders to auto-discovery later if you want. ";
                result = MessageBox.Show(question, "Found paths", MessageBoxButtons.YesNo);
                if (result == DialogResult.Yes)
                {
                    fs.AddRange(paths.Distinct());
                }
            }
            ldm.SaveConfig(cfg);
            SearchFoldersForGames(fs);
        }
Exemplo n.º 2
0
 private void SearchFoldersForGames(List <string> fs)
 {
     using (BackgroundWorker bw = new BackgroundWorker())
     {
         bw.DoWork += delegate
         {
             foreach (string folder in fs)
             {
                 string[]  paths = GameSuggestions.GetGameFolders(folder);
                 GameAdder ga    = new GameAdder();
                 ga.DataReady += AdderOnDataReady;
                 ga.AddGames(paths);
             }
             workingProgress = WorkingProgress.BusyDoingNothing;
         };
         bw.RunWorkerAsync();
     }
 }
Exemplo n.º 3
0
        private void AddAutodiscoveryFolderButton_Click(object sender, EventArgs e)
        {
            string t = AddAutoDiscoveryTextBox.Text;

            if (string.IsNullOrWhiteSpace(t))
            {
                return;
            }
            if (!Directory.Exists(t))
            {
                MessageBox.Show("Directory does not exist");
                return;
            }
            LocalDataManager ldm = new LocalDataManager();
            Config           cfg = ldm.LoadConfig();

            cfg.GamesFolders.Add(t);
            GameAdder ga = new GameAdder();

            ga.DataReady += AdderOnDataReady;
            ga.AddGames(GameSuggestions.GetGameFolders(t));
            AddAutoDiscoveryTextBox.Text = "";
        }