public DiscSelection() { this.InitializeComponent(); this.ShowCloseButton = false; btnSelect.IsEnabled = false; // get the mainwindow MainWindow mw = Application.Current.Windows.OfType <MainWindow>().FirstOrDefault(); int numRowsCount = mw.dgGameList.SelectedItems.Count; if (numRowsCount != 1) { return; } GamesLibraryModel drv = (GamesLibraryModel)mw.dgGameList.SelectedItem; if (drv == null) { return; } int romId = drv.ID; // create new GameLauncher instance GameLauncher gl = new GameLauncher(romId); LaunchString = gl.GetCommandLineArguments(); // choose disc string path = Game.GetGame(romId).gamePath; string[] sheets = DiscScan.ParseM3UFile(path); if (sheets == null || sheets.Length == 0) { MessageBox.Show("ERROR: Track Sheets Could Not be Parsed."); this.Close(); } DiscArray = sheets; this.Title = "Choose Disc to Launch"; this.Refresh(); List <DSel> g = new List <DSel>(); for (int i = 0; i < DiscArray.Length; i++) { DSel ds = new DSel(); ds.DiscNumber = i; ds.DiscName = DiscArray[i]; g.Add(ds); } // make sure list is ordered g.OrderBy(a => a.DiscNumber); dgReturnedGames.ItemsSource = g; }
public ScraperGamePicker() { this.InitializeComponent(); this.ShowCloseButton = false; btnSelect.IsEnabled = false; // get the mainwindow mw = Application.Current.Windows.OfType <MainWindow>().FirstOrDefault(); int GameId = mw.InspGame.gameId; int systemId = mw.InspGame.systemId; // check for pcecd games if (systemId == 18) { systemId = 7; } string sysName = GSystem.GetSystemName(systemId); this.Title = "Fuzzy Search Results for " + sysName; this.Refresh(); ScraperSearch gs = new ScraperSearch(); // get a list of all games for this platform - higest match first //List<SearchOrdering> games = gs.ShowPlatformGames(systemId, row.Game); GamesLibraryModel row = new GamesLibraryModel(); row.ID = mw.InspGame.gameId; row.Game = mw.InspGame.gameName; List <SearchOrdering> games = gs.ShowPlatformGamesBySub(systemId, row); List <GameListItem> g = new List <GameListItem>(); foreach (var gam in games) { if (gam.Matches == 0 || gam.Game.GDBTitle == "") { continue; } GameListItem gli = new GameListItem(); gli.GamesDBId = gam.Game.gid; gli.GameName = gam.Game.GDBTitle; //gli.Matches = gam.Matches; int wordcount = row.Game.Split(' ').Length; gli.Percentage = Convert.ToInt32((Convert.ToDouble(gam.Matches) / Convert.ToDouble(wordcount)) * 100); gli.Platform = gam.Game.GDBPlatformName; g.Add(gli); } // make sure list is ordered descending g.OrderByDescending(a => a.Matches); dgReturnedGames.ItemsSource = g; }
public List <SearchOrdering> ShowPlatformGamesBySub(int systemId, GamesLibraryModel game) { // get gamesdb sub entry var subIdObj = GSystem.GetSubSystems() .Where(a => a.systemName == game.System).FirstOrDefault(); if (subIdObj == null) { // no sub found SystemCollection = PlatformGames.Where(a => GSystem.GetMedLaunchSystemIdFromGDBPlatformId(a.pid) == systemId).ToList(); } else { // sub found SystemCollection = PlatformGames.Where(a => a.pid == subIdObj.theGamesDBPlatformId.First()).ToList(); } // megadrive check if (game.System == "Sega Mega Drive/Genesis") { if (game.Country == "US" || game.Country == "USA") { SystemCollection = SystemCollection.Where(a => a.pid == 18).ToList(); } else if (game.Country == "EU" || game.Country == "EUR" || game.Country == "JP" || game.Country == "JAP" || game.Country == "JPN") { SystemCollection = SystemCollection.Where(a => a.pid == 36).ToList(); } else { // show all games } } // Match all words and return a list ordered by higest matches List <SearchOrdering> searchResult = OrderByMatchedWords(StripSymbols(game.Game.ToLower())); return(searchResult); }
public RomInspector() { this.InitializeComponent(); // get the mainwindow MainWindow mw = Application.Current.Windows.OfType <MainWindow>().FirstOrDefault(); int numRowsCount = mw.dgGameList.SelectedItems.Count; if (numRowsCount != 1) { return; } GamesLibraryModel drv = (GamesLibraryModel)mw.dgGameList.SelectedItem; if (drv == null) { return; } int romId = drv.ID; // get game object Game g = Game.GetGame(romId); GameObj = g; // populate tab textboxes with game name tbRawInspecResults.Text = g.gamePath; tbLibInspecResults.Text = g.gamePath; // init manual config button if (g.ManualEditSet == true) { btnToggleManualEdit.IsChecked = true; EnableControls(); } else { btnToggleManualEdit.IsChecked = false; DisableControls(); } // init ucon64 wrapper ucon64_wrapper.UconWrapper u = new ucon64_wrapper.UconWrapper(System.AppDomain.CurrentDomain.BaseDirectory + @"\ucon64-bin\ucon64.exe"); string gamePath = Game.ReturnActualGamePath(g); UconResult obj = new UconResult(); // is it a ROM or a DISC? string extension = System.IO.Path.GetExtension(gamePath); if (extension.ToLower().Contains(".m3u") || extension.ToLower().Contains(".cue") || extension.ToLower().Contains(".ccd") || extension.ToLower().Contains(".toc") ) { if (g.systemId == 13) { // saturn DiscGameFile dgf = new DiscGameFile(gamePath, g.systemId); // get saturn data from disk image var file = DiscScan.ParseTrackSheetForImageFiles(dgf, g.systemId).FirstOrDefault(); if (file != null) { var satInfo = MedDiscUtils.GetSSData(file.FullPath); string outp = "Initialising MedLaunch Sega Saturn DISC Interogator\n*******************************************\n\n"; outp += satInfo.Title + "\n"; outp += satInfo.SerialNumber + "\n"; outp += satInfo.Date + "\n"; outp += satInfo.Country + "\n"; outp += satInfo.JpnTitle + "\n"; outp += satInfo.PeriphCode + "\n"; outp += satInfo.CountryCode + "\n"; tbInsResult.Text = outp; // pop tbs tbIntGame.Text = satInfo.Title; tbIntRegion.Text = satInfo.Country; tbIntYear.Text = satInfo.Date; tbIntVersion.Text = satInfo.SerialNumber; } } else if (g.systemId == 9) { // psx DiscGameFile dgf = new DiscGameFile(gamePath, g.systemId); var files = DiscScan.ParseTrackSheetForImageFiles(dgf, g.systemId); // iterate through each image file and scan it int cnt = 0; foreach (var im in files) { var res = u.ScanGame(im.FullPath, uConOps.GetSystemType(g.systemId)); tbInsResult.Text += res.RawOutput; if (files.Count > 1) { tbInsResult.Text += "\n****************************\n"; } if (cnt == 0) { obj = res; } cnt++; } } /* * DiscGameFile dgf = new DiscGameFile(gamePath, g.systemId); * var files = DiscScan.ParseTrackSheetForImageFiles(dgf, g.systemId); * * // iterate through each image file and scan it * int cnt = 0; * foreach (var im in files) * { * var res = u.ScanGame(im.FullPath, uConOps.GetSystemType(g.systemId)); * tbInsResult.Text += res.RawOutput; * if (files.Count > 1) * tbInsResult.Text += "\n****************************\n"; * if (cnt == 0) * obj = res; * cnt++; * } */ } else { // check whether game is within 7zip or part of a multi-game archive if (g.gamePath.Contains("*/")) { // need to extract game first before scanning GameLauncher gl = new GameLauncher(g.gameId); string tempPath = gl.BuildFullGamePath(Paths.GetSystemPath(g.systemId), g.gamePath); // scan game var re = u.ScanGame(tempPath, uConOps.GetSystemType(g.systemId)); // update textbox tbInsResult.Text = re.RawOutput; obj = re; } else { // no extraction needed var result = u.ScanGame(gamePath, uConOps.GetSystemType(g.systemId)); // update text box tbInsResult.Text = result.RawOutput; obj = result; } // library data tab } if (GameObj.systemId == 9) { // get the playstation serial string ser = MedDiscUtils.GetPSXSerial(GameObj.gamePath); tbIntVersion.Text = ser; } PopulateLibraryData(); LookupDAT(); LookupScrapeMatched(); /* populate other textboxes */ // raw if (g.systemId != 13) { tbIntSystem.Text = obj.Data.DetectedSystemType; tbIntGame.Text = obj.Data.DetectedGameName; tbIntPublisher.Text = obj.Data.DetectedPublisher; tbIntRegion.Text = obj.Data.DetectedRegion; tbIntType.Text = obj.Data.DetectedRomType; tbIntYear.Text = obj.Data.DetectedYear; tbIntChecksumString.Text = obj.Data.DetectedChecksumComparison; if (obj.Data.IsInterleaved == true) { tbIntInterleaving.Text = "Yes"; } if (obj.Data.IsInterleaved == false) { tbIntInterleaving.Text = "No"; } tbIntChecksumCrc.Text = obj.Data.CRC32; if (tbIntChecksumString.Text.Contains("Bad,")) { tbIntChecksumString.Foreground = new SolidColorBrush(Colors.Red); } if (tbIntChecksumString.Text.Contains("OK,")) { tbIntChecksumString.Foreground = new SolidColorBrush(Colors.Green); } tbIntVersion.Text = obj.Data.DetectedVersion; tbIntPadding.Text = obj.Data.DetectedPadding; tbIntSize.Text = obj.Data.DetectedSize; // status box string resultMessage = obj.Status; if (obj.Data.systemType == SystemType.Genesis && obj.Data.romType == RomType.SMD) { if (obj.Data.IsChecksumValid == false) { resultMessage = "Checksum invalid\n"; if (obj.Data.IsInterleaved == true) { // needs de-interleaving resultMessage += "Also, this is a genesis SMD ROM that is interleaved. Mednafen will not run this game and MedLaunch cannot currently convert it."; } if (obj.Data.IsInterleaved == false) { // game will most probably play resultMessage += "However this is a genesis ROM that is NOT interleaved. It should work in Mednafen."; } } else { resultMessage = "Checksum is valid\n"; if (obj.Data.IsInterleaved == true) { // needs de-interleaving resultMessage += "This is a genesis SMD ROM that is interleaved. MedLaunch will auto-convert this game at launch-time so that it works with Mednafen."; } if (obj.Data.IsInterleaved == false) { // game will most probably play resultMessage += "This is a genesis ROM that is NOT interleaved. It should work in Mednafen without conversion."; } } } tbIntResult.Text = resultMessage; } //populate rom field on library tab LookupROM(); // add gameobj to mainwindow mw.InspGame = GameObj; }
/// <summary> /// Scrape multiple games that have been selected in the games library (either scrape unscraped, or re-scrape all) /// </summary> /// <param name="list"></param> /// <param name="scrapeType"></param> public async static void ScrapeMultiple(List <GamesLibraryModel> list, ScrapeType scrapeType, int systemId) { // instantiate instance of this class ScraperSearch gs = new ScraperSearch(); // get mainwindow MainWindow MWindow = Application.Current.Windows.OfType <MainWindow>().FirstOrDefault(); // popup progress dialog var mySettings = new MetroDialogSettings() { NegativeButtonText = "Cancel Scraping", AnimateShow = false, AnimateHide = false }; var controller = await MWindow.ShowProgressAsync("Scraping Data", "Initialising...", true, settings : mySettings); controller.SetCancelable(true); await Task.Delay(100); await Task.Run(() => { // check whether list is null and generate it if it is (so scraping/rescraping whole systems or favorites) if (list == null) { list = new List <GamesLibraryModel>(); List <Game> games = new List <Game>(); if (scrapeType == ScrapeType.Favorites || scrapeType == ScrapeType.RescrapeFavorites) { games = Game.GetGames().Where(a => a.isFavorite == true && a.hidden != true).ToList(); } else { // get all games that have matching systemId and are not marked as hidden games = Game.GetGames(systemId).Where(a => a.hidden != true).ToList(); } // populate list foreach (var g in games) { GamesLibraryModel glm = new GamesLibraryModel(); glm.ID = g.gameId; list.Add(glm); } } // iterate through each game in list - match local then scrape int iter = 0; int maxCount = list.Count(); int skip = 0; controller.Minimum = iter; controller.Maximum = maxCount; foreach (var game in list) { if (controller.IsCanceled) { controller.CloseAsync(); return; } iter++; controller.SetProgress(iter); // game game object from the database Game g = Game.GetGame(game.ID); string countString = iter + " of " + maxCount + " (" + skip + " skipped)"; switch (scrapeType) { // scrape selected games (that have no been scraped yet) case ScrapeType.Selected: case ScrapeType.Favorites: case ScrapeType.ScrapeSystem: if (g.gdbId == null || g.gdbId == 0 || Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + @"Data\Games\" + g.gdbId.ToString()) == false) { // scraping can happen DoScrape(controller, g, countString, gs, false); } else { // the game already has a valid gdbid set AND has a game directory on disc. skip++; } break; // rescrape all selected games case ScrapeType.SelectedRescrape: case ScrapeType.RescrapeFavorites: case ScrapeType.RescrapeSystem: // scraping must always happen DoScrape(controller, g, countString, gs, true); break; } } }); await controller.CloseAsync(); if (controller.IsCanceled) { await MWindow.ShowMessageAsync("MedLaunch Scraper", "Scraping Cancelled"); GamesLibraryVisualHandler.RefreshGamesLibrary(); } else { await MWindow.ShowMessageAsync("MedLaunch Scraper", "Scraping Completed"); GamesLibraryVisualHandler.RefreshGamesLibrary(); } }