public void ShowUnscraped(object sender, FilterEventArgs e) { GamesLibraryModel g = e.Item as GamesLibraryModel; if (g != null) { if (g.Coop == null && g.ESRB == null && g.Players == null) { // possibly not scraped - check for psx string system = g.System; int sysId = GSystem.GetSystemIdSubFirst(system); if (GSystem.GetSystemCode(sysId).ToLower() != "psx") { e.Accepted = true; } else { e.Accepted = false; } } else { e.Accepted = false; } } }
/// <summary> /// Name back all [system].cfg files in the mednafen directory /// </summary> public static void SystemConfigsOn() { // get a list of systems var systems = from s in GSystem.GetSystems() select s.systemCode.ToLower(); // check the mednafen directory exists before proceeding if (Paths.isMednafenPathValid() == false) { return; } string medpath = Paths.GetPaths().mednafenExe; // iterate through each system name foreach (string sys in systems) { // check for system.cfgBackup if (File.Exists(medpath + "\\" + sys + ".cfgBackup")) { // does an original file already exist? if (File.Exists(medpath + "\\" + sys + ".cfg")) { // do nothing return; } // rename system.cfg File.Move(medpath + "\\" + sys + ".cfgBackup", medpath + "\\" + sys + ".cfg"); } } }
public void ImportSystemConfigFromDisk(ProgressDialogController controller, GSystem sys) { _ConfigBaseSettings = ConfigBaseSettings.GetConfig(2000000000 + sys.systemId); if (_ConfigBaseSettings == null) { // invalid config id return; } string configPath = _Paths.mednafenExe + @"\" + sys.systemCode + ".cfg"; var specCfg = LoadConfigFromDisk(configPath); if (specCfg.Count == 0) { return; } // data was returned - begin import if (controller != null) { controller.SetMessage("Importing " + sys.systemCode + ".cfg"); } ParseConfigIncoming(specCfg, 2000000000 + sys.systemId); // set to enabled //_ConfigBaseSettings.isEnabled = true; //ConfigBaseSettings.SetConfig(_ConfigBaseSettings); }
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; }
private void PopulateEnvironmentVariables() { gridEnvironmentVars.Rows.Clear(); foreach (var kv in GSystem.GetEnvironmentVariables()) { gridEnvironmentVars.Rows.Add(kv.Key, kv.Value); } }
/// <summary> /// Return a search list /// </summary> /// <param name="systemId"></param> /// <param name="gameName"></param> /// <returns></returns> public List <SearchOrdering> ShowPlatformGames(int systemId, string gameName) { // get a list with all games for this system SystemCollection = PlatformGames.Where(a => GSystem.GetMedLaunchSystemIdFromGDBPlatformId(a.pid) == systemId).ToList(); // Match all words and return a list ordered by higest matches List <SearchOrdering> searchResult = OrderByMatchedWords(StripSymbols(gameName.ToLower())); return(searchResult); }
public void ShowLynx(object sender, FilterEventArgs e) { GamesLibraryModel g = e.Item as GamesLibraryModel; if (g != null) { int sysId = GSystem.GetSystemIdSubFirst(g.System); e.Accepted = (sysId == 3) ? true : false; } }
public static List <GSystem> GetSystems() { List <GSystem> systems = new List <GSystem>(); using (var sysCon = new MyDbContext()) { var sys = GSystem.GetSystems(); foreach (GSystem g in sys) { systems.Add(g); } return(systems); } }
public static void GetInfo(int gameID, Label sysLabel, TextBlock sysDesc, Image sysImage)//, Image gameImage) { // gets game and system info from the database and populates the right information panel // get system info first using (var context = new MyDbContext()) { var gameInfo = (from g in context.Game where g.gameId == gameID select g).FirstOrDefault(); List <GSystem> si = GSystem.GetSystems(); var sysInfo = (from s in si where s.systemId == gameInfo.systemId select new { s.systemName, s.systemDescription, s.systemId }).FirstOrDefault(); // image handling string image = @"Graphics\Icons\na.png"; if (sysInfo != null) { if (sysInfo.systemId == 10) { // master system image = @"Graphics\Systems\snes.jpg"; } else { image = @"Graphics\Icons\na.png"; } } // set system image BitmapImage b = new BitmapImage(); b.BeginInit(); b.UriSource = new Uri(image, UriKind.Relative); b.EndInit(); // ... Get Image reference from sender. //var image = sender as Image; // ... Assign Source. sysImage.Source = b; //sysImage.Source = new BitmapImage(new Uri(image, UriKind.Relative)); // set system label sysLabel.Content = sysInfo.systemName; // set system description sysDesc.Text = sysInfo.systemDescription; } }
/// <summary> /// remove hidden systems from results set /// </summary> /// <param name="results"></param> /// <returns></returns> public static List <DataGridGamesView> RemoveHidden(List <DataGridGamesView> results) { bool[] visibilities = GlobalSettings.GetVisArray(); // check whether there are actually any hidden systems bool systemsHidden = false; for (int i = 1; i <= visibilities.Length; i++) { if (i == 16 || i == 17) { continue; } if (visibilities[i - 1] == false) { systemsHidden = true; break; } } if (systemsHidden == false) { // there are no hidden systems - just return the results as-is return(results); } else { // there are hidden systems - remove them from results for (int i = 1; i <= visibilities.Length; i++) { if (i == 16 || i == 17) // skip fast and faust { continue; } if (visibilities[i - 1] == false) { results = (from a in results where a.System != GSystem.GetSystemName(i) select a).ToList(); } } return(results); } }
public bool DoesParamContainSystemCode(string param) { // convert list of systemcodes to hashset var s = (from z in GSystem.GetSystems() select z.systemCode); bool itDoes = false; foreach (string code in s) { if (param.Contains(code)) { itDoes = true; break; } } return(itDoes); }
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 void ImportAll(ProgressDialogController controller) { if (controller != null) { controller.SetMessage("Importing Mednafen Configs from disk\nPlease wait....."); } // import mednafen-09x.cfg into relevant config files ImportBaseConfigFromDisk(null); // get any system specific .cfg files List <GSystem> systems = GSystem.GetSystems(); foreach (GSystem sys in systems) { ImportSystemConfigFromDisk(null, sys); } // now save to database SaveToDatabase(); }
public static List <TruRipObject> Go() { // Import data for each system List <GSystem> systems = GSystem.GetSystems().ToList(); List <TruRipObject> l = new List <TruRipObject>(); foreach (var sys in systems) { // get a list of strings containing all data info for this system List <string> dats = LoadDATs(sys.systemId); // iterate through each data and parse the information into a new object foreach (string s in dats) { List <TruRipObject> list = Parse(s, sys.systemId); l.AddRange(list); } } l.Distinct(); return(l); }
public static void CheckGamesExist(MediaType mediaType) { List <GSystem> sys = new List <GSystem>(); if (mediaType == MediaType.DISC) { sys = GSystem.GetSystems().Where(a => a.systemId == 8 || a.systemId == 9 || a.systemId == 13 || a.systemId == 18).ToList(); } else if (mediaType == MediaType.ROM) { sys = GSystem.GetSystems().Where(a => a.systemId != 8 && a.systemId != 9 && a.systemId != 13 && a.systemId != 18).ToList(); } foreach (var s in sys) { } }
public void ExecutePython(string script_filename, string args) { //string script_filename = "playground_bitcoin.py"; //string args = string.Format("KRAKEN_OHLC {0} {1}", cboKrakenSymbols.Text, cboKrakenMinutes.Text); //EnableButton(false); IgnoreResetStatus = true; Status("Running Python script: " + script_filename + " ..."); StatusColor(Color.Yellow); GSystem.ProcessExited += GSystem_ProcessExited; StartStatusTimer(); try { GSystem.RunPython(script_filename, args, this.Handle); } catch (Exception ex) { string errorMsg = string.Format("An error occurred attempting to launch Python.\n\nCheck the app settings to ensure your Python is configured correctly.\n({0})", ex.Message); MessageBox.Show(this, errorMsg, "Python Error"); } }
public static HashSet <string> GetAllowedFileExtensions(int systemId) { var exts = (from g in GSystem.GetSystems() where g.systemId == systemId select g).SingleOrDefault(); string archive = exts.supportedArchiveExtensions; string nonArchive = exts.supportedFileExtensions; HashSet <string> supported = new HashSet <string>(); char c = ','; string[] aSplit = archive.Split(c); string[] nSplit = nonArchive.Split(c); foreach (string s in aSplit) { supported.Add(s); } foreach (string s in nSplit) { supported.Add(s); } return(supported); }
// remove all disk-based games from db for a certain system public static void RemoveDisks(int sysId) { MessageBoxResult result = MessageBox.Show("This operation will wipe out ALL the " + GSystem.GetSystemName(sysId) + " games in your library database (but they will not be deleted from disk)\n\nAre you sure you wish to continue?", "WARNING", MessageBoxButton.OKCancel, MessageBoxImage.Warning); if (result == MessageBoxResult.OK) { // get all disks for specific system using (var context = new MyDbContext()) { List <Game> disks = (from a in context.Game where a.systemId == sysId select a).ToList(); Game.DeleteGames(disks); GameListBuilder.UpdateFlag(); } } }
public static GamesLibraryModel CreateModelFromGame(Game game)//, List<LibraryDataGDBLink> links) { /* * if (links == null) * links = LibraryDataGDBLink.GetLibraryData().ToList(); */ GamesLibraryModel d = new GamesLibraryModel(); d.ID = game.gameId; // check for subsystem if (game.subSystemId != null && game.subSystemId > 0) { string subName = GSystem.GetSubSystemName(game.subSystemId.Value); d.System = subName; } else { d.System = GSystem.GetSystemName(game.systemId); } d.LastPlayed = DbEF.FormatDate(game.gameLastPlayed); d.Favorite = game.isFavorite; d.Country = game.Country; if (game.romNameFromDAT != null) { /* * if (game.romNameFromDAT.Contains("(USA)")) * d.Country = "USA"; * if (game.romNameFromDAT.Contains("(Europe)")) * d.Country = "EUR"; * if (game.romNameFromDAT.Contains("(Japan)")) * d.Country = "JPN"; */ } d.Flags = game.OtherFlags; d.Language = game.Language; d.Publisher = game.Publisher; d.Developer = game.Developer; d.Year = game.Year; d.Coop = game.Coop; d.ESRB = game.ESRB; d.Players = game.Players; d.Year = game.Year; if (game.ManualEditSet == true) { if (game.gameNameEdited != null && game.gameNameEdited != "") { d.Game = game.gameNameEdited; } } else { if (game.gameNameFromDAT != null && game.gameNameFromDAT != "") { d.Game = game.gameNameFromDAT; } else { d.Game = game.gameName; } } //d.Game = game.gameName; /* * if (game.gameNameFromDAT != null && game.gameNameFromDAT != "") * d.Game = game.gameNameFromDAT; * else * d.Game = game.gameName; */ //d.DatName = game.gameNameFromDAT; d.DatRom = game.romNameFromDAT; /* * if (game.gdbId != null && game.gdbId > 0) * { * var link = links.Where(x => x.GDBId == game.gdbId).SingleOrDefault(); // LibraryDataGDBLink.GetLibraryData(game.gdbId.Value); * if (link != null) * { * if (link.Publisher != null && link.Publisher != "") * d.Publisher = link.Publisher; * * d.Developer = link.Developer; * * if (link.Year != null && link.Year != "") * d.Year = DbEF.ReturnYear(link.Year); * d.Players = link.Players; * d.Coop = link.Coop; * d.ESRB = link.ESRB; * } * } */ //d.Year = "2914"; // last minute region detection if ((d.Country == null || d.Country.Trim() == "") && d.Game != null) { if (d.Game.Contains("(Japan)")) { d.Country = "Japan"; } if (d.Game.Contains("(Europe)")) { d.Country = "Europe"; } if (d.Game.Contains("(USA)")) { d.Country = "USA"; } if (d.Game.Contains("(Usa, Europe)")) { d.Country = "USA, Europe"; } // goodtools if (d.Game.Contains("(W)")) { d.Country = "World"; } if (d.Game.Contains("(U)")) { d.Country = "USA"; } if (d.Game.Contains("(As)")) { d.Country = "Asia"; } if (d.Game.Contains("(E)")) { d.Country = "Europe"; } } return(d); }
public static void HideControls(WrapPanel wp, int configId) { // get a class object with all child controls UIHandler ui = UIHandler.GetChildren(wp); ConfigsVisualHandler cv = new ConfigsVisualHandler(); //Border b = (Border)cv.MWindow.FindName("brdNONDYNAMICvfilters"); // get a list of system codes List <string> codes = (from a in GSystem.GetSystems() select a.systemCode.ToString().ToLower()).ToList(); // iterate through each ui element and collapse the ones that are not needed for system specific settings if (configId != 2000000000) { //b.Visibility = Visibility.Collapsed; foreach (Button x in ui.Buttons) { if (x.Name.StartsWith("cfg___")) { x.Visibility = Visibility.Collapsed; } } foreach (CheckBox x in ui.CheckBoxes) { if (x.Name.StartsWith("cfg___")) { x.Visibility = Visibility.Collapsed; } } foreach (ComboBox x in ui.ComboBoxes) { if (x.Name.StartsWith("cfg___")) { x.Visibility = Visibility.Collapsed; } } foreach (NumericUpDown x in ui.NumericUpDowns) { if (x.Name.StartsWith("cfg___")) { x.Visibility = Visibility.Collapsed; } } foreach (RadioButton x in ui.RadioButtons) { if (x.Name.StartsWith("cfg___")) { x.Visibility = Visibility.Collapsed; } } foreach (Slider x in ui.Sliders) { if (x.Name.StartsWith("cfg___")) { x.Visibility = Visibility.Collapsed; } } foreach (TextBox x in ui.TextBoxes) { if (x.Name.StartsWith("cfg___") || x.Name.StartsWith("tb_Generic__")) { x.Visibility = Visibility.Collapsed; } } foreach (Label x in ui.Labels) { if (x.Name.StartsWith("cfg___") || x.Name.StartsWith("lbl_cfg___") || x.Name.StartsWith("lbl_Generic__")) { x.Visibility = Visibility.Collapsed; } } } else { GlobalSettings gs = GlobalSettings.GetGlobals(); if (gs.showAllBaseSettings == true) { //b.Visibility = Visibility.Collapsed; } else { //b.Visibility = Visibility.Visible; foreach (Button x in ui.Buttons) { if (x.Name.StartsWith("cfg___")) { x.Visibility = Visibility.Visible; } } foreach (CheckBox x in ui.CheckBoxes) { if (x.Name.StartsWith("cfg___")) { x.Visibility = Visibility.Visible; } } foreach (ComboBox x in ui.ComboBoxes) { if (x.Name.StartsWith("cfg___")) { x.Visibility = Visibility.Visible; } } foreach (NumericUpDown x in ui.NumericUpDowns) { if (x.Name.StartsWith("cfg___")) { x.Visibility = Visibility.Visible; } } foreach (RadioButton x in ui.RadioButtons) { if (x.Name.StartsWith("cfg___")) { x.Visibility = Visibility.Visible; } } foreach (Slider x in ui.Sliders) { if (x.Name.StartsWith("cfg___")) { x.Visibility = Visibility.Visible; } } foreach (TextBox x in ui.TextBoxes) { if (x.Name.StartsWith("cfg___") || x.Name.StartsWith("tb_Generic__")) { x.Visibility = Visibility.Visible; } } foreach (Label x in ui.Labels) { if (x.Name.StartsWith("cfg___") || x.Name.StartsWith("lbl_cfg___") || x.Name.StartsWith("lbl_Generic__")) { x.Visibility = Visibility.Visible; } } } } }
// constructor public GameScanner() { // load master dat from disk string filePath = AppDomain.CurrentDomain.BaseDirectory + @"Data\System\DATMaster.json"; DAT = JsonConvert.DeserializeObject <IEnumerable <DATMerge> >(File.ReadAllText(filePath)); db = new MyDbContext(); Games = (from g in db.Game select g).ToList(); Paths = (from p in db.Paths where p.pathId == 1 select p).ToList().SingleOrDefault(); Systems = GSystem.GetSystems(); RomSystems = new List <GSystem>(); DiskSystems = new List <GSystem>(); // populate RomSystems and DiskSystems foreach (GSystem gs in Systems) { // exlude non-path systems if (gs.systemId == 16 || gs.systemId == 17) { continue; } // populate disksystems if (gs.systemId == 18 || // pcecd gs.systemId == 8 || // pcfx gs.systemId == 9 || // psx gs.systemId == 13) // Saturn { DiskSystems.Add(gs); } else { RomSystems.Add(gs); } } RomSystemsWithPaths = new List <GSystem>(); DiskSystemsWithPaths = new List <GSystem>(); // populate RomSystemsWithPaths with only entries that only have Rom paths set (and are not non-path systems like snes_faust and pce_fast) and where ROM directories are valid foreach (var sys in RomSystems) { if (GetPath(sys.systemId) == null || GetPath(sys.systemId) == "" || !Directory.Exists(GetPath(sys.systemId))) { continue; } RomSystemsWithPaths.Add(sys); } /* * for (int i = 1; RomSystems.Count >= i; i++) * { * if (GetPath(i) == null || GetPath(i) == "") * continue; * * MessageBoxResult result2 = MessageBox.Show(RomSystems[i - 1].systemName); * RomSystemsWithPaths.Add(RomSystems[i - 1]); * } */ // populate DiskSystemsWithPaths with only entries that only have Disk paths set (and are not non-path systems like snes_faust and pce_fast) foreach (var sys in DiskSystems) { if (GetPath(sys.systemId) == null || GetPath(sys.systemId) == "") { continue; } DiskSystemsWithPaths.Add(sys); } // per system lists GamesGB = (from g in Games where g.systemId == 1 select g).ToList(); GamesGBA = (from g in Games where g.systemId == 2 select g).ToList(); GamesLYNX = (from g in Games where g.systemId == 3 select g).ToList(); GamesMD = (from g in Games where g.systemId == 4 select g).ToList(); GamesGG = (from g in Games where g.systemId == 5 select g).ToList(); GamesNGP = (from g in Games where g.systemId == 6 select g).ToList(); GamesPCE = (from g in Games where g.systemId == 7 select g).ToList(); GamesPCFX = (from g in Games where g.systemId == 8 select g).ToList(); GamesPSX = (from g in Games where g.systemId == 9 select g).ToList(); GamesSMS = (from g in Games where g.systemId == 10 select g).ToList(); GamesNES = (from g in Games where g.systemId == 11 select g).ToList(); GamesSNES = (from g in Games where g.systemId == 12 select g).ToList(); GamesSS = (from g in Games where g.systemId == 13 select g).ToList(); GamesVB = (from g in Games where g.systemId == 14 select g).ToList(); GamesWSWAN = (from g in Games where g.systemId == 15 select g).ToList(); GamesPCECD = (from g in Games where g.systemId == 18 select g).ToList(); RomsToUpdate = new List <Game>(); RomsToAdd = new List <Game>(); DisksToUpdate = new List <Game>(); DisksToAdd = new List <Game>(); AddedStats = 0; HiddenStats = 0; UpdatedStats = 0; UntouchedStats = 0; }
public static List <MobyPlatformGame> GamesListScrape(ProgressDialogController controller) { string BaseUrl = "http://www.mobygames.com/browse/games/"; // get all platforms List <GSystem> systems = GSystem.GetSystems(); List <MobyPlatformGame> allGames = new List <MobyPlatformGame>(); // iterate through each system foreach (GSystem s in systems) { if (s.systemId == 16 || s.systemId == 17) { break; } foreach (string sys in s.MobyPlatformName) { if (controller != null) { controller.SetMessage("Scraping basic list of all " + sys + " games"); if (controller.IsCanceled) { return(null); } } // build initial query string to get the search page string param = sys + "/list-games"; string initialPage = ReturnWebpage(BaseUrl, param, 10000); /* Get the total number of games available for this system */ // split the html to list via line breaks List <string> html = initialPage.Split('\n').ToList(); // get only the line that contains the number of games string hLine = html.Where(a => a.Contains(" games)")).FirstOrDefault(); // get only the substring "xxx games" string resultString = Regex.Match(hLine, @"(?<=\().+?(?=\))").Value; // split by whitespace string[] gArr = resultString.Split(' '); // get int number of games int totalGames = Convert.ToInt32(gArr[0]); HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(initialPage); // build a list of page URLs double numberofpages = Convert.ToDouble(totalGames) / 25; int numberOfPages = Convert.ToInt32(Math.Ceiling(numberofpages)); // connect to every page and import all the game information for (int i = 0; i < numberOfPages; i++) { if (controller != null) { if (controller.IsCanceled) { return(null); } } int offset = i * 25; string p = sys + "/offset," + offset + "/so,0a/list-games"; HtmlDocument hDoc = new HtmlDocument(); if (i == 0) { hDoc = doc; } else { string htmlRes = ReturnWebpage(BaseUrl, p, 10000); hDoc.LoadHtml(htmlRes); } // get just the data table we are interested in HtmlNode objectTable = hDoc.GetElementbyId("mof_object_list"); // iterate through each row and scrape the game information int cGame = 1; foreach (HtmlNode row in objectTable.SelectNodes("tbody/tr")) { int currentGameNumber = offset + cGame; if (controller != null) { if (controller.IsCanceled) { return(null); } controller.SetMessage("Scraping basic list of all " + sys + " games\nGame: (" + currentGameNumber + " of " + totalGames + ")\nPage: (" + (i + 1) + " of " + numberOfPages + ")"); controller.Minimum = 1; controller.Maximum = totalGames; controller.SetProgress(Convert.ToDouble(currentGameNumber)); } HtmlNode[] cells = (from a in row.SelectNodes("td") select a).ToArray(); string Title = cells[0].InnerText.Trim(); //var allLi = row.SelectSingleNode("//a[@href]"); string URLstring = cells[0].InnerHtml.Trim(); Regex regex = new Regex("href\\s*=\\s*(?:\"(?<1>[^\"]*)\"|(?<1>\\S+))", RegexOptions.IgnoreCase); Match match; string URL = ""; for (match = regex.Match(URLstring); match.Success; match = match.NextMatch()) { URL = match.Groups[1].ToString(); } MobyPlatformGame game = new MobyPlatformGame(); game.SystemId = s.systemId; game.PlatformName = sys; game.Title = WebUtility.HtmlDecode(Title); game.UrlName = WebUtility.HtmlDecode(URL.Split('/').LastOrDefault()); // add game to main list allGames.Add(game); cGame++; } } } } return(allGames); }
public static void RefreshCoreVisibilities() { // get mainwindow MainWindow mw = Application.Current.Windows.OfType <MainWindow>().FirstOrDefault(); // get the current settings GlobalSettings gs = GlobalSettings.GetGlobals(); // create an array of values bool[] b = new bool[] { gs.coreVis1, gs.coreVis2, gs.coreVis3, gs.coreVis4, gs.coreVis5, gs.coreVis6, gs.coreVis7, gs.coreVis8, gs.coreVis9, gs.coreVis10, gs.coreVis11, gs.coreVis12, gs.coreVis13, gs.coreVis14, gs.coreVis15, gs.coreVis16, gs.coreVis17, gs.coreVis18 }; // iterate through each setting and set visibilities for (int i = 1; i <= b.Length; i++) { // games library filters string sysCode = GSystem.GetSystemCode(i); TextInfo textInfo = new CultureInfo("en-US", false).TextInfo; RadioButton rb = (RadioButton)mw.FindName("btn" + textInfo.ToTitleCase(sysCode)); if (rb != null) { if (b[i - 1] == true) { rb.Visibility = Visibility.Visible; } else { rb.Visibility = Visibility.Collapsed; } } // games library actual filtering //todo // config filters RadioButton configRb = (RadioButton)mw.FindName("btnConfig" + textInfo.ToTitleCase(sysCode)); if (configRb != null) { if (b[i - 1] == true) { configRb.Visibility = Visibility.Visible; } else { configRb.Visibility = Visibility.Collapsed; } } // settings filters (game paths) Button pathBtn = (Button)mw.FindName("btnPath" + textInfo.ToTitleCase(sysCode)); TextBox pathTb = (TextBox)mw.FindName("tbPath" + textInfo.ToTitleCase(sysCode)); if (pathBtn != null) { if (b[i - 1] == true) { pathBtn.Visibility = Visibility.Visible; pathTb.Visibility = Visibility.Visible; } else { pathBtn.Visibility = Visibility.Collapsed; pathTb.Visibility = Visibility.Collapsed; } } // controls filters // config filters RadioButton controlRb = (RadioButton)mw.FindName("btnControl" + textInfo.ToTitleCase(sysCode)); if (controlRb != null) { if (b[i - 1] == true) { controlRb.Visibility = Visibility.Visible; } else { controlRb.Visibility = Visibility.Collapsed; } } } /* get selected filter buttons - if they are invisible then select a different one */ // games library filters WrapPanel wpGamesList = (WrapPanel)mw.FindName("wpGamesList"); List <RadioButton> _filterButtonsLib = UIHandler.GetLogicalChildCollection <RadioButton>(wpGamesList); RadioButton btnShowAll = (RadioButton)mw.FindName("btnShowAll"); // get selected library filter button var gSel = _filterButtonsLib.Where(a => a.IsChecked == true); if (gSel.Count() > 0) { RadioButton gSelBut = gSel.FirstOrDefault(); if (gSelBut.Visibility == Visibility.Collapsed) { // selected button is invisible - select the showall filter button btnShowAll.IsChecked = true; } } else { // no button is selected btnShowAll.IsChecked = true; } // configs // handle fast and faust RadioButton btnConfigSnes_Faust = (RadioButton)mw.FindName("btnConfigSnes_Faust"); RadioButton btnConfigPce_Fast = (RadioButton)mw.FindName("btnConfigPce_Fast"); RadioButton btnConfigSnes = (RadioButton)mw.FindName("btnConfigSnes"); RadioButton btnConfigPce = (RadioButton)mw.FindName("btnConfigPce"); if (btnConfigSnes.Visibility == Visibility.Collapsed) { btnConfigSnes_Faust.Visibility = Visibility.Collapsed; } else { btnConfigSnes_Faust.Visibility = Visibility.Visible; } if (b[17] == false) { if (btnConfigPce.Visibility == Visibility.Collapsed) { btnConfigPce_Fast.Visibility = Visibility.Collapsed; } else { btnConfigPce_Fast.Visibility = Visibility.Visible; } } else { btnConfigPce_Fast.Visibility = Visibility.Visible; btnConfigPce.Visibility = Visibility.Visible; } WrapPanel wpConfigLeftPane = (WrapPanel)mw.FindName("wpConfigLeftPane"); List <RadioButton> _filterButtons = UIHandler.GetLogicalChildCollection <RadioButton>(wpConfigLeftPane); // get selected config button var cSel = _filterButtons.Where(a => a.IsChecked == true); if (cSel.Count() > 0) { RadioButton cSelBut = cSel.FirstOrDefault(); if (cSelBut.Visibility == Visibility.Collapsed) { // selected button is invisible - find the next one that IS visible and click it SetRadioButton(_filterButtons); } } else { // no button is selected SetRadioButton(_filterButtons); } // controls // handle fast and faust RadioButton btnControlSnes_Faust = (RadioButton)mw.FindName("btnControlSnes_Faust"); RadioButton btnControlPce_Fast = (RadioButton)mw.FindName("btnControlPce_Fast"); RadioButton btnControlSnes = (RadioButton)mw.FindName("btnControlSnes"); RadioButton btnControlPce = (RadioButton)mw.FindName("btnControlPce"); if (btnControlSnes.Visibility == Visibility.Collapsed) { btnControlSnes_Faust.Visibility = Visibility.Collapsed; } else { btnControlSnes_Faust.Visibility = Visibility.Visible; } if (b[17] == false) { if (btnConfigPce.Visibility == Visibility.Collapsed) { btnControlPce_Fast.Visibility = Visibility.Collapsed; } else { btnControlPce_Fast.Visibility = Visibility.Visible; } } else { btnControlPce_Fast.Visibility = Visibility.Visible; btnControlPce.Visibility = Visibility.Visible; } if (btnControlPce.Visibility == Visibility.Collapsed) { btnControlPce_Fast.Visibility = Visibility.Collapsed; } else { btnControlPce_Fast.Visibility = Visibility.Visible; } WrapPanel wpControlLeftPane = (WrapPanel)mw.FindName("wpControlLeftPane"); List <RadioButton> _filterButtonsControl = UIHandler.GetLogicalChildCollection <RadioButton>(wpControlLeftPane); // get selected config button var contSel = _filterButtonsControl.Where(a => a.IsChecked == true); if (contSel.Count() > 0) { RadioButton contSelBut = contSel.FirstOrDefault(); if (contSelBut.Visibility == Visibility.Collapsed) { // selected button is invisible - find the next one that IS visible and click it SetRadioButton(_filterButtonsControl); } } else { // no button is selected SetRadioButton(_filterButtonsControl); } // Completely hide whole panels if NO system is visible var b2 = b.Where(a => a == true).ToList(); DataGrid dgGameList = (DataGrid)mw.FindName("dgGameList"); WrapPanel ConfigWrapPanel = (WrapPanel)mw.FindName("ConfigWrapPanel"); Grid controlGrid = (Grid)mw.FindName("controlGrid"); if (b2.Count == 0) { dgGameList.Visibility = Visibility.Collapsed; ConfigWrapPanel.Visibility = Visibility.Collapsed; controlGrid.Visibility = Visibility.Collapsed; } else { dgGameList.Visibility = Visibility.Visible; ConfigWrapPanel.Visibility = Visibility.Visible; controlGrid.Visibility = Visibility.Visible; } }
public static void InitialSeed() { // check whether initial seed needs to continue bool doSeed = false; using (var db = new MyDbContext()) { var se = db.GlobalSettings.FirstOrDefault(); if (se == null || se.databaseGenerated == false) { doSeed = true; } } if (doSeed == true) { // populate Versions table Versions version = Versions.GetVersionDefaults(); using (var context = new MyDbContext()) { context.Versions.Add(version); context.SaveChanges(); } // default netplay settings ConfigNetplaySettings npSettings = ConfigNetplaySettings.GetNetplayDefaults(); using (var context = new MyDbContext()) { context.ConfigNetplaySettings.Add(npSettings); context.SaveChanges(); } // default ConfigBaseSettings population ConfigBaseSettings cfbs = ConfigBaseSettings.GetConfigDefaults(); cfbs.ConfigId = 2000000000; // base configuration using (var context = new MyDbContext()) { context.ConfigBaseSettings.Add(cfbs); context.SaveChanges(); } // create system specific configs (set to disabled by default) List <GSystem> gamesystems = GSystem.GetSystems(); using (var gsContext = new MyDbContext()) { // iterate through each system and create a default config for them - setting them to disabled, setting their ID to 2000000000 + SystemID // and setting their systemident to systemid foreach (GSystem System in gamesystems) { int def = 2000000000; ConfigBaseSettings c = ConfigBaseSettings.GetConfigDefaults(); c.ConfigId = def + System.systemId; c.systemIdent = System.systemId; c.isEnabled = false; // add to databsae gsContext.ConfigBaseSettings.Add(c); gsContext.SaveChanges(); } } // Populate Servers List <ConfigServerSettings> servers = ConfigServerSettings.GetServerDefaults(); using (var context = new MyDbContext()) { context.ConfigServerSettings.AddRange(servers); context.SaveChanges(); } // Create General Settings Entry GlobalSettings gs = GlobalSettings.GetGlobalDefaults(); using (var context = new MyDbContext()) { context.GlobalSettings.Add(gs); context.SaveChanges(); } // create mednanet general entry MednaNetSettings ms = MednaNetSettings.GetMednaNetDefaults(); using (var context = new MyDbContext()) { context.MednaNetSettings.Add(ms); context.SaveChanges(); } // create Paths entry Paths paths = new Paths { pathId = 1 }; using (var context = new MyDbContext()) { context.Paths.Add(paths); context.SaveChanges(); } // initial seeding complete. mark GeneralSettings table so that regeneration does not occur GlobalSettings set; using (var context = new MyDbContext()) { set = (from a in context.GlobalSettings where a.settingsId == 1 select a).FirstOrDefault <GlobalSettings>(); } if (set != null) { set.databaseGenerated = true; } using (var dbCtx = new MyDbContext()) { dbCtx.Entry(set).State = EntityState.Modified; dbCtx.SaveChanges(); } } }
// Constructor public GameLauncher(int gameId) { db = new MyDbContext(); GameId = gameId; // get Game object Game game = (from g in db.Game where g.gameId == gameId select g).SingleOrDefault(); ConfigId = game.configId; RomPath = game.gamePath; RomName = game.gameName; // get globals Global = (from g in db.GlobalSettings where g.settingsId == 1 select g).SingleOrDefault(); SystemId = game.systemId; // do PSX sbi check and check whether game file actually exists (as it might have been renamed) if (SystemId == 9 && File.Exists(game.gamePath)) { // get all implied files from othe cue/m3u that is in the database string cuePath = game.gamePath; // this is never relative with disc-based games DiscGameFile originalCue = new DiscGameFile(cuePath, 9); List <DiscGameFile> imageFiles = new List <DiscGameFile>(); // DiscScan.ParseTrackSheetForImageFiles(new DiscGameFile(cuePath, 9), 9); // check whether m3u if (originalCue.Extension.ToLower() == ".m3u") { // get all cue files var allc = DiscScan.ParseTrackSheet(originalCue, CueType.m3u, SystemId); foreach (var g in allc) { imageFiles.Add(g); } } else { // standard cue file imageFiles.Add(originalCue); } // iterate through each image and check for serial number for (int i = 0; i < imageFiles.Count; i++) { string serial = MedDiscUtils.GetPSXSerial(imageFiles[i].FullPath); if (serial == null || serial == "") { continue; } // add serial to imageFiles imageFiles[i].ExtraInfo = serial; } // if imageFile has only one entry, then this matches originalCue if (imageFiles.Count == 1) { if (PsxSBI.IsSbiAvailable(imageFiles.First().ExtraInfo) == true) { // sbi is available - check whether sbi already exists string sbipath = imageFiles.First().FullPath.Replace(imageFiles.First().Extension, ".sbi"); //if (!File.Exists(imageFiles.First().FolderPath + "\\" + imageFiles.First().FileName.Replace(imageFiles.First().Extension, "") + ".sbi")) if (!File.Exists(sbipath)) { var result = MessagePopper.ShowMessageDialog("MedLaunch has determined that you need an available SBI patch file to play this game properly.\n\nDo you wish to copy this file to your disc directory?\n", "SBI Patch Needed - " + imageFiles.First().FileName, MessagePopper.DialogButtonOptions.YESNO); //MessageBoxResult result = MessageBox.Show("MedLaunch has determined that you need an available SBI patch file to play this game properly.\n\nDo you wish to copy this file to your disc directory?\n", // "SBI Patch Needed - " + imageFiles.First().FileName, MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessagePopper.ReturnResult.Affirmative) { // copy sbi file to folder (named the same as the cue file) originalCue.ExtraInfo = imageFiles.First().ExtraInfo; //PsxSBI.InstallSBIFile(originalCue); PsxSBI.InstallSBIFile(imageFiles.First()); } } } } // if imageFiles has multiple entries - it will have come from an m3u file if (imageFiles.Count > 1) { // create an array of m3u cue files string[] cues = File.ReadAllLines(originalCue.FullPath); // loop through for (int image = 0; image < imageFiles.Count; image++) { if (PsxSBI.IsSbiAvailable(imageFiles[image].ExtraInfo) == true) { // sbi is available - prompt user if (!File.Exists(imageFiles[image].FolderPath + "\\" + imageFiles[image].FileName.Replace(imageFiles[image].Extension, "") + ".sbi")) { var result = MessagePopper.ShowMessageDialog("MedLaunch has determined that you need an available SBI patch file to play this game properly.\n\nDo you wish to copy this file to your disc directory?\n", "SBI Patch Needed - " + imageFiles.First().FileName, MessagePopper.DialogButtonOptions.YESNO); //MessageBoxResult result = MessageBox.Show("MedLaunch has determined that you need an available SBI patch file to play this game properly.\n\nDo you wish to copy this file to your disc directory?\n", //"SBI Patch Needed - " + imageFiles[image].FileName + imageFiles[image].Extension, MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessagePopper.ReturnResult.Affirmative) { // copy sbi file to folder (named the same as the cue file) DiscGameFile d = new DiscGameFile(cues[image], 9); d.ExtraInfo = imageFiles[image].ExtraInfo; PsxSBI.InstallSBIFile(d); } } } } } } // logic for faust & fast if (game.systemId == 12) { if (Global.enableSnes_faust == true) { SystemId = 16; //MessageBoxResult result = MessageBox.Show("FAUST DETECTED"); } else { SystemId = game.systemId; } } if (game.systemId == 7 || game.systemId == 18) { if (Global.enablePce_fast == true) { SystemId = 17; } else { SystemId = 7; } } gSystem = GSystem.GetSystems().Where(a => a.systemId == SystemId).Single(); SystemCode = gSystem.systemCode; RomFolder = GetRomFolder(SystemId, db); MednafenFolder = (from m in db.Paths select m.mednafenExe).SingleOrDefault(); // set the config id int actualConfigId = SystemId + 2000000000; // take general settings from base config (2000000000) and system specific settings from actual config ConfigBaseSettings _config = (from c in db.ConfigBaseSettings where (c.ConfigId == actualConfigId) select c).SingleOrDefault(); List <ConfigObject> sysConfigObject = ListFromType(_config).Where(a => !a.Key.StartsWith("__")).ToList(); SysConfigObject = new List <ConfigObject>(); foreach (var x in sysConfigObject) { var systems = GSystem.GetSystems().Where(a => a.systemCode != SystemCode); bool isValid = true; foreach (var sc in systems) { if (x.Key.StartsWith(sc.systemCode + "__")) { isValid = false; break; } } if (isValid == true) { SysConfigObject.Add(x); } } // if option is enabled save system specific config for this system if (Global.saveSystemConfigs == true) { if (SystemCode == "pcecd") { SystemCode = "pce"; } SaveSystemConfigToDisk(SystemCode, SysConfigObject); } // build actual config list //ConfObject = new List<ConfigObject>(); //ConfObject.AddRange(GenConfigObject); //ConfObject.AddRange(SysConfigObject); /* * if (_config.isEnabled == true) * { * Config = _config; * } * else * { * Config = (from c in db.ConfigBaseSettings * where c.ConfigId == 2000000000 * select c).SingleOrDefault(); * } */ // get netplay Netplay = (from n in db.ConfigNetplaySettings where n.ConfigNPId == 1 select n).SingleOrDefault(); // get server Server = (from s in db.ConfigServerSettings where s.ConfigServerId == Global.serverSelected select s).SingleOrDefault(); // get overide server settings (password and gamekey from custom ServerOveride = (from s in db.ConfigServerSettings where s.ConfigServerId == 100 select s).SingleOrDefault(); }
public string BuildFullGamePath(string GamesFolder, string GamePath) { string path = string.Empty; string extension = string.Empty; // check whether relative or absolute path has been set in the database for this game if (RomPath.StartsWith(".")) { // path is relative (rom autoimported from defined path) - build path path = GamesFolder + GamePath.TrimStart('.'); } else { // rom or disk has been manually added with full path - return just full path path = GamePath; } // create cache directory if it does not exist string cacheDir = AppDomain.CurrentDomain.BaseDirectory + "Data\\Cache"; Directory.CreateDirectory(cacheDir); /* now do archive processing */ if (path.Contains("*/")) { // this is an archive file with a direct reference to a ROM inside string[] arr = path.Split(new string[] { "*/" }, StringSplitOptions.None); string archivePath = arr[0]; string archiveFile = arr[1]; // copy specific rom from archive to cache folder and get cache rom path string cacheRom = Archive.ExtractFile(archivePath, archiveFile, cacheDir); //Archiving.SetupArchiveChild(archivePath, archiveFile, cacheDir); if (cacheRom != string.Empty) { return(ParseSMD(cacheRom, cacheDir)); } } else if (path.ToLower().Contains(".7z") || path.ToLower().Contains(".zip")) { // This is a standard archive with no defined link extension = System.IO.Path.GetExtension(path).ToLower(); if (extension == ".zip") //zip { // this should be a zip file with a single rom inside - pass directly to mednafen as is using (System.IO.Compression.ZipArchive ar = System.IO.Compression.ZipFile.OpenRead(path)) { foreach (System.IO.Compression.ZipArchiveEntry entry in ar.Entries) { if (entry.FullName.EndsWith(".smd", StringComparison.OrdinalIgnoreCase)) { entry.Archive.ExtractToDirectory(cacheDir, true); return(ParseSMD(Path.Combine(cacheDir, entry.FullName), cacheDir)); } } } return(path); } else if (extension == ".7z") { /* archive detected - extract contents to cache directory and modify path variable accordingly * this is a legacy option really - in case people have a single rom in a .7z file in their library that * has not been directly referenced in the gamepath */ // inspect the archive Archive arch = new Archive(path); var res = arch.ProcessArchive(null); // iterate through List <CompressionResult> resList = new List <CompressionResult>(); foreach (var v in res.Results) { if (GSystem.IsFileAllowed(v.RomName, SystemId)) { resList.Add(v); } } if (resList.Count == 0) { return(path); } // there should only be one result - take the first one var resFinal = resList.FirstOrDefault(); // extract the rom to the cache string cacheFile = Archive.ExtractFile(path, resFinal.InternalPath, cacheDir); /* * // check whether file already exists in cache * string cacheFile = cacheDir + "\\" + resFinal.FileName; * if (File.Exists(cacheFile)) * { * // file exists - check size * long length = new System.IO.FileInfo(cacheFile).Length; * * if (length != filesize) * { * arch.ExtractArchive(cacheDir); * } * } * else * { * // extract contents of archive to cache folder * arch.ExtractArchive(cacheDir); * } */ // return the new path to the rom return(ParseSMD(cacheFile, cacheDir)); } else if (extension == ".zip") //zip { // this should be a zip file with a single rom inside - pass directly to mednafen as is (unless its an smd file) using (System.IO.Compression.ZipArchive ar = System.IO.Compression.ZipFile.OpenRead(path)) { foreach (System.IO.Compression.ZipArchiveEntry entry in ar.Entries) { if (entry.FullName.EndsWith(".smd", StringComparison.OrdinalIgnoreCase)) { entry.Archive.ExtractToDirectory(cacheDir, true); return(ParseSMD(Path.Combine(cacheDir, entry.FullName), cacheDir)); } } } return(path); } } return(ParseSMD(path, cacheDir)); }
/* Methods */ public static void DoScrape(ProgressDialogController controller, Game game, string countString, ScraperSearch gs, bool rescrape) { // ignore if manual editing is set if (game.ManualEditSet == true) { return; } string gameName = game.gameName; int systemId = game.systemId; int gameId = game.gameId; // attempt local match for game controller.SetMessage("Attempting local search match for:\n" + gameName + " (" + GSystem.GetSystemCode(systemId) + ")" + "\n(" + countString); List <ScraperMaster> results = gs.SearchGameLocal(gameName, systemId, gameId).ToList(); if (results.Count == 0) { // no results returned return; } if (results.Count == 1) { // one result returned - add GdbId to the Game table Game.SetGdbId(gameId, results.Single().gid); // also add it to our locagames object (so it is not skipped in the next part) //game.gdbId = results.Single().gid; } if (results.Count > 1) { // more than one result returned - do nothing (because a definite match was not found) return; } /* Begin scraping */ bool scrapingNeeded = false; // check game directory if (!Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + @"Data\Games\" + results.Single().gid.ToString())) { // directory does not exist - scraping needed scrapingNeeded = true; } else { // directory does exist - check whether json file is present if (!File.Exists(AppDomain.CurrentDomain.BaseDirectory + @"Data\Games\" + results.Single().gid.ToString() + @"\" + results.Single().gid.ToString() + ".json")) { // json file is not present - scraping needed scrapingNeeded = true; } } // if rescrape bool has been set - always rescrape if (rescrape == true) { scrapingNeeded = true; } if (scrapingNeeded == false) { return; } // do scrape string message = "Scraping Started....\nGetting data for: " + gameName + " (" + GSystem.GetSystemCode(systemId) + ")" + "\n(" + countString; controller.SetMessage(message); ScraperHandler sh = new ScraperHandler(results.Single().gid, gameId, false); sh.ScrapeGame(controller); //GameListBuilder.UpdateFlag(); }
public static string SelectGameFile() { // get all game system allowed file extensions var systems = GSystem.GetSystems(); List <string> exts = new List <string>(); foreach (var s in systems) { string sup = s.supportedFileExtensions; string[] spl = sup.Split(','); if (spl.Length > 0) { foreach (string e in spl) { exts.Add(e); } } } // remove duplicates exts.Distinct(); // add ZIP extension exts.Add(".zip"); // convert allowed types to filter string string filter = ""; string fStart = "Allowed Types ("; string fEnd = ""; foreach (string i in exts) { if (i == "") { continue; } fStart += "*" + i + ","; fEnd += "*" + i + ";"; } char comma = ','; char semi = ';'; filter = (fStart.TrimEnd(comma)) + ")|" + (fEnd.TrimEnd(semi)); //MessageBox.Show(filter); // open the file dialog showing only allowed file types - multi-select disabled OpenFileDialog filePath = new OpenFileDialog(); filePath.Multiselect = false; filePath.Filter = filter; filePath.Title = "Select a single ROM, Disc or playlist file to run with Mednafen"; filePath.ShowDialog(); if (filePath.FileName.Length > 0) { // file has been selected string file = filePath.FileName; return(file); } else { // no files selected - return empty string return(null); } }
public static void ScrapeBasicDocsList(ProgressDialogController controller) { List <ReplacementDocs> rdlist = new List <ReplacementDocs>(); // iterate through mednafen systems var systems = GSystem.GetSystems(); foreach (var sys in systems) { controller.SetMessage("Getting manual links for: " + sys.systemName + "\n"); if (sys.systemId == 16 || sys.systemId == 17 || sys.systemId == 18) { continue; } List <int> rdsystems = ConvertSystemId2RDSystemId(sys.systemId); // iterate through replacementdocs systems foreach (int s in rdsystems) { // get the whole page for this system WebOps wo = new WebOps(); wo.BaseUrl = "http://www.replacementdocs.com/download.php?"; wo.Params = "1.list." + s.ToString() + ".1000.download_name.ASC"; wo.Timeout = 20000; string result = wo.ApiCall(); HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(result); HtmlNode table = doc.DocumentNode.SelectSingleNode("//table[contains(@class, 'fborder')]"); // iterate through each table row foreach (HtmlNode row in table.ChildNodes) { if (row.ChildNodes.Count > 0) { HtmlNode[] cells = (from a in row.SelectNodes("td") select a).ToArray(); if (cells[0].InnerHtml.Contains("download.php?view.")) { // this is a data cell string title = cells[0].InnerText.Replace("\t", "").Trim(); string url = cells[0].InnerHtml.Replace("\t", "").Trim().Replace("<a href='download.php?view.", ""); string[] urlArr = url.Split('\''); string fileId = urlArr[0]; var recordcheck = (from a in rdlist where a.GameName == title && a.TGBSystemName == ConvertRDSystemId2TGBPlatformName(s) select a).ToList(); if (recordcheck.Count > 0) { ReplacementDocs r = recordcheck.FirstOrDefault(); r.Urls.Add("http://www.replacementdocs.com/request.php?" + fileId); r.Urls.Distinct(); rdlist.Add(r); } else { ReplacementDocs r = new ReplacementDocs(); r.GameName = title; r.TGBSystemName = ConvertRDSystemId2TGBPlatformName(s); r.Urls.Add("http://www.replacementdocs.com/request.php?" + fileId); r.Urls.Distinct(); rdlist.Add(r); } rdlist.Distinct(); } } } } } // save rdlist to json string json = JsonConvert.SerializeObject(rdlist, Formatting.Indented); File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + @"..\..\Data\System\replacementdocs-manuals.json", json); }
// Constructor public GameLauncher(int gameId) { db = new MyDbContext(); GameId = gameId; // get Game object Game game = (from g in db.Game where g.gameId == gameId select g).SingleOrDefault(); ConfigId = game.configId; RomPath = game.gamePath; RomName = game.gameName; // get globals Global = (from g in db.GlobalSettings where g.settingsId == 1 select g).SingleOrDefault(); SystemId = game.systemId; // logic for faust & fast if (game.systemId == 12) { if (Global.enableSnes_faust == true) { SystemId = 16; //MessageBoxResult result = MessageBox.Show("FAUST DETECTED"); } else { SystemId = game.systemId; } } if (game.systemId == 7 || game.systemId == 18) { if (Global.enablePce_fast == true) { SystemId = 17; } else { SystemId = 7; } } gSystem = GSystem.GetSystems().Where(a => a.systemId == SystemId).Single(); SystemCode = gSystem.systemCode; RomFolder = GetRomFolder(SystemId, db); MednafenFolder = (from m in db.Paths select m.mednafenExe).SingleOrDefault(); // set the config id int actualConfigId = SystemId + 2000000000; // take general settings from base config (2000000000) and system specific settings from actual config ConfigBaseSettings _config = (from c in db.ConfigBaseSettings where (c.ConfigId == actualConfigId) select c).SingleOrDefault(); List <ConfigObject> sysConfigObject = ListFromType(_config).Where(a => !a.Key.StartsWith("__")).ToList(); SysConfigObject = new List <ConfigObject>(); foreach (var x in sysConfigObject) { var systems = GSystem.GetSystems().Where(a => a.systemCode != SystemCode); bool isValid = true; foreach (var sc in systems) { if (x.Key.StartsWith(sc.systemCode + "__")) { isValid = false; break; } } if (isValid == true) { SysConfigObject.Add(x); } } // if option is enabled save system specific config for this system if (Global.saveSystemConfigs == true) { if (SystemCode == "pcecd") { SystemCode = "pce"; } SaveSystemConfigToDisk(SystemCode, SysConfigObject); } // build actual config list //ConfObject = new List<ConfigObject>(); //ConfObject.AddRange(GenConfigObject); //ConfObject.AddRange(SysConfigObject); /* * if (_config.isEnabled == true) * { * Config = _config; * } * else * { * Config = (from c in db.ConfigBaseSettings * where c.ConfigId == 2000000000 * select c).SingleOrDefault(); * } */ // get netplay Netplay = (from n in db.ConfigNetplaySettings where n.ConfigNPId == 1 select n).SingleOrDefault(); // get server Server = (from s in db.ConfigServerSettings where s.ConfigServerId == Global.serverSelected select s).SingleOrDefault(); // get overide server settings (password and gamekey from custom ServerOveride = (from s in db.ConfigServerSettings where s.ConfigServerId == 100 select s).SingleOrDefault(); }