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); }
private void LoadConfig() { LocalDataManager ldm = new LocalDataManager(); Config cfg = ldm.LoadConfig(); fastFolderTextBox.Text = cfg.OutputPath; if (cfg.FirstRun) { cfg.FirstRun = false; ldm.SaveConfig(cfg); using (BackgroundWorker bw = new BackgroundWorker()) { bw.DoWork += BackgroundWorkerScanForGames; bw.RunWorkerAsync(); } } else { SearchFoldersForGames(cfg.GamesFolders); } }
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 = ""; }
private void saveFastFolderButton_Click(object sender, EventArgs e) { if (Games.Any(g => g.Status != GameStatus.Deactivated)) { MessageBox.Show("Not all games are deactivated, please do this first!"); return; } string text = fastFolderTextBox.Text; if (string.IsNullOrWhiteSpace(text)) { MessageBox.Show("You have to enter a path"); return; } if (File.Exists(text)) { MessageBox.Show("There is a file at this path. It is therefor not valid"); return; } if (!Directory.Exists(text)) { DialogResult result = MessageBox.Show("The destination folder does not exist, do you want me to create it?", "Directory not found", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { Directory.CreateDirectory(text); } else { return; } } LocalDataManager ldm = new LocalDataManager(); Config cfg = ldm.LoadConfig(); cfg.OutputPath = text; ldm.SaveConfig(cfg); }