public static async void RestoreMatches() { R.Data.Configuration.AutoDetectChangesEnabled = false; R.Data.Configuration.LazyLoadingEnabled = false; R.Data.Matches.Load(); int i = 0; await Task.Run(() => { foreach (Match match in R.Data.Matches) { Release release = R.Data.Releases.FirstOrDefault(x => x.Rom.SHA1 == match.SHA1 && x.Region_ID == match.Region_ID); if (release != null) { Reporter.Report((i++).ToString() + " Matched " + release.TitleAndRegion); release.ID_GB = release.ID_GB ?? match.ID_GB; release.ID_GDB = release.ID_GDB ?? match.ID_GDB; release.ID_OVG = release.ID_OVG ?? match.ID_OVG; } } R.Data.Save(); // TODO Report total }); }
async void GetPlatformArt(bool selected) { try { // Cache the number of art files so we can see how many we got int platformArtCount = Directory.GetFiles(FileLocation.Art.Console).Count(); await Task.Run(() => { Reporter.Report("Opening databases..."); R.Data.GDBPlatforms.Load(); Reporter.Report("Scraping art files..."); List <IDBobject> list = new List <IDBobject>(); // Cache selected items in case the user changes them during scrape // If items are selected, cache them if (selected) { foreach (IDBobject idbObject in SelectedDBs) { list.Add(idbObject); } } // If no items are selected, cache the entire collection else { dynamic MainBigThing = MainBigSelection; list.AddRange(MainBigThing.FilteredCollection); } // Scrape art in the order of most usefull if (Properties.Settings.Default.ScrapePlatformConsole) { GetArtSub(list, ArtType.Console, 0); } if (Properties.Settings.Default.ScrapePlatformController) { GetArtSub(list, ArtType.Controller, 0); } if (Properties.Settings.Default.ScrapePlatformBoxFront) { GetArtSub(list, ArtType.BoxFront, 0); } if (Properties.Settings.Default.ScrapePlatformBanner) { GetArtSub(list, ArtType.Banner, 0); } if (Properties.Settings.Default.ScrapePlatformBoxBack) { GetArtSub(list, ArtType.BoxBack, 0); } }); } catch { } finally { TaskInProgress = false; } }
async void GetReleaseArt(bool selected) { try { // Cache the art count prior to scraping to find out how many we get int boxFrontCount = Directory.GetFiles(FileLocation.Art.BoxFront).Count(); int boxBackCount = Directory.GetFiles(FileLocation.Art.BoxBack).Count(); int bannerCount = Directory.GetFiles(FileLocation.Art.Banner).Count(); int screenCount = Directory.GetFiles(FileLocation.Art.Screen).Count(); int logoCount = Directory.GetFiles(FileLocation.Art.Logo).Count(); await Task.Run(() => { Reporter.Report("Opening databases..."); R.Data.GDBReleases.Load(); R.Data.GBReleases.Load(); R.Data.OVGReleases.Load(); R.Data.LBReleases.Include(x => x.LBImages).Load(); Reporter.Report("Scraping art files..."); List <IDBobject> list = new List <IDBobject>(); // Cache selected items in case the user changes them during scrape // If items are selected, cache them if (selected) { foreach (IDBobject idbObject in SelectedDBs) { list.Add(idbObject); } } // If no items are selected, cache the entire collection else { dynamic MainBigThing = MainBigSelection; list.AddRange(MainBigThing.FilteredCollection); } // Scrape art in the order of most usefull if (Properties.Settings.Default.ScrapeReleaseBoxFront) { GetArtSub(list, ArtType.BoxFront, 0); } if (Properties.Settings.Default.ScrapeReleaseLogo) { GetArtSub(list, ArtType.Logo, 0); } if (Properties.Settings.Default.ScrapeReleaseScreen) { GetArtSub(list, ArtType.Screen, 0); } if (Properties.Settings.Default.ScrapeReleaseBanner) { GetArtSub(list, ArtType.Banner, 0); } if (Properties.Settings.Default.ScrapeReleaseBoxBack) { GetArtSub(list, ArtType.BoxBack, 0); } }); boxFrontCount = Directory.GetFiles(FileLocation.Art.BoxFront).Count() - boxFrontCount; boxBackCount = Directory.GetFiles(FileLocation.Art.BoxBack).Count() - boxBackCount; bannerCount = Directory.GetFiles(FileLocation.Art.Banner).Count() - bannerCount; screenCount = Directory.GetFiles(FileLocation.Art.Screen).Count() - screenCount; logoCount = Directory.GetFiles(FileLocation.Art.Logo).Count() - logoCount; Reporter.Report($"Added {boxFrontCount} box front art images."); Reporter.Report($"Added {boxBackCount} box back art images."); Reporter.Report($"Added {bannerCount} banner images."); Reporter.Report($"Added {logoCount} clear logos."); Reporter.Report($"Added {screenCount} screenshots."); } catch { } finally { TaskInProgress = false; } }
public async void Play(Emulator emulator = null) { await Task.Run(() => { using (Process emulatorProcess = new Process()) { // Choose default emulator if necessary if (emulator == null || !Platform.Emulators.Contains(emulator)) { emulator = Platform.Emulator; } Reporter.Report("Launching " + Title + " using " + emulator.Title); emulatorProcess.StartInfo.CreateNoWindow = false; emulatorProcess.StartInfo.UseShellExecute = false; emulatorProcess.StartInfo.RedirectStandardOutput = true; emulatorProcess.StartInfo.RedirectStandardError = true; emulatorProcess.StartInfo.WorkingDirectory = Path.GetDirectoryName(emulator.FilePath); emulatorProcess.StartInfo.FileName = emulator.FilePath; if (emulator.ID == CONSTANTS.HIGAN_EMULATOR_ID) { emulatorProcess.StartInfo.Arguments = @"""" + FileLocation.HiganRoms + Platform.HiganRomFolder + @"\" + Path.GetFileNameWithoutExtension(Rom.FileName) + Platform.HiganExtension + @""""; } // Strip out .xls if system = MAME if (emulator.ID == CONSTANTS.MAME_ID) { if (Platform.ID == CONSTANTS.CHANNELF_PLATFORM_ID) { emulatorProcess.StartInfo.Arguments = "channelf -cart " + @"""" + FilePath + @""""; // + " -skip_gameinfo -nowindow"; } else { emulatorProcess.StartInfo.Arguments = Path.GetFileNameWithoutExtension(Rom.FileName); } } else { emulatorProcess.StartInfo.Arguments = FilePath; } try { emulatorProcess.Start(); emulatorProcess.PriorityClass = ProcessPriorityClass.High; if (!IsAdult && IsGame) { PlayCount++; } } catch (Exception) { // TODO: report something usefull here if the process fails to start } string output = emulatorProcess.StandardOutput.ReadToEnd(); string error = emulatorProcess.StandardError.ReadToEnd(); Reporter.Report(output); Reporter.Report(error); } }); }
public void CompareToDB(int threshold, bool ConsiderRegion) { List.Clear(); // List for storing matches List <Compare> Matches = new List <Compare>(); int distance; bool goAhead = !ConsiderRegion; Release release; IDBRelease dbRelease; int N_r = RReleases.Count; // Loop over all Releases for (int i_r = 0; i_r < N_r; i_r++) { if ((RReleases.Count / 10 != 0) && (i_r % (RReleases.Count / 10) == 0)) { Reporter.Report("Comparing " + i_r + @" / " + RReleases.Count); } release = RReleases[i_r]; // Compare current Release to each relase in DBreleases for (int i_db = 0; i_db < DBreleases.Count; i_db++) { dbRelease = DBreleases[i_db]; if (ConsiderRegion) { goAhead = (release.Region.Title == dbRelease.RegionTitle); } if (goAhead) { // Get distance between Rom i and Game j distance = LevenshteinDistance.Compute(release.Title.Wash(), dbRelease.Title.Wash()); // Add the current rom/game to a list of matches for consideration Matches.Add(new Compare(distance, dbRelease.ID, i_db, dbRelease.Title, release.Title, i_r, release.Region.Title, dbRelease.RegionTitle)); // If the current match is perfect, store it and check the accept box. Stop looking through the regions. if (Matches.Last().Distance == 0) { Matches.Last().AcceptMatch = true; break; } } } if (Matches.Any()) { // Find the closest match, then add the threshold from the DataBaseWindow checkbox int min = Matches.Min(em => em.Distance + threshold); // Add all of the compares from the list of matches whose distances are closer than the chosen minimum // These are the matches to be displayed for consideration List.AddRange(new List <Compare>(Matches.Where(n => n.Distance == min).Select(n => n).ToList())); } Matches.Clear(); } }